| 1 | /* |
|---|
| 2 | * Hydrogen |
|---|
| 3 | * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] |
|---|
| 4 | * |
|---|
| 5 | * http://www.hydrogen-music.org |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | * (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY, without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | * |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | #include "SampleEditor.h" |
|---|
| 24 | #include "../HydrogenApp.h" |
|---|
| 25 | #include "InstrumentEditor/InstrumentEditor.h" |
|---|
| 26 | #include "../widgets/Button.h" |
|---|
| 27 | |
|---|
| 28 | #include <hydrogen/data_path.h> |
|---|
| 29 | #include <hydrogen/h2_exception.h> |
|---|
| 30 | #include <hydrogen/Preferences.h> |
|---|
| 31 | #include <hydrogen/sample.h> |
|---|
| 32 | #include <hydrogen/audio_engine.h> |
|---|
| 33 | |
|---|
| 34 | #include <QModelIndex> |
|---|
| 35 | #include <QTreeWidget> |
|---|
| 36 | #include <QMessageBox> |
|---|
| 37 | |
|---|
| 38 | using namespace H2Core; |
|---|
| 39 | using namespace std; |
|---|
| 40 | |
|---|
| 41 | SampleEditor::SampleEditor ( QWidget* pParent ) |
|---|
| 42 | : QDialog ( pParent ) |
|---|
| 43 | , Object ( "SampleEditor" ) |
|---|
| 44 | { |
|---|
| 45 | setupUi ( this ); |
|---|
| 46 | INFOLOG ( "INIT" ); |
|---|
| 47 | setWindowTitle ( trUtf8 ( "SampleEditor" ) ); |
|---|
| 48 | setFixedSize ( width(), height() ); |
|---|
| 49 | installEventFilter( this ); |
|---|
| 50 | m_pSampleEditorStatus = false; //set true if sample changes are save |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | SampleEditor::~SampleEditor() |
|---|
| 55 | { |
|---|
| 56 | INFOLOG ( "DESTROY" ); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | bool SampleEditor::getCloseQuestion() |
|---|
| 61 | { |
|---|
| 62 | bool close = false; |
|---|
| 63 | int err = QMessageBox::information( this, "Hydrogen", tr( "Close dialog! maybe there is some unsaved work on sample.\nAre you sure?"), tr("&Ok"), tr("&Cancel"), 0, 1 ); |
|---|
| 64 | if ( err == 0 ) close = true; |
|---|
| 65 | return close; |
|---|
| 66 | |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | void SampleEditor::setSampleName( QString name ) |
|---|
| 71 | { |
|---|
| 72 | QString newfilename = name.section( '/', -1 ); |
|---|
| 73 | // newfilename.replace( "." + newfilename.section( '.', -1 ), ""); |
|---|
| 74 | |
|---|
| 75 | QString windowname = "SampleEditor " + newfilename; |
|---|
| 76 | m_samplename = name; |
|---|
| 77 | setWindowTitle ( windowname ); |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|