root/trunk/gui/src/SoundLibrary/SoundLibraryPropertiesDialog.cpp @ 392

Revision 392, 3.6 KB (checked in by smoors, 5 years ago)

fixed some typos

Line 
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 <QtGui>
24
25#include "../HydrogenApp.h"
26#include "SoundLibraryPropertiesDialog.h"
27#include "../InstrumentRack.h"
28#include "SoundLibraryPanel.h"
29#include <hydrogen/SoundLibrary.h>
30#include <hydrogen/hydrogen.h>
31
32namespace H2Core
33{
34
35//globals
36Drumkit *drumkitinfo = NULL ;
37Drumkit *predrumkit = NULL;
38QString oldName = "";
39
40SoundLibraryPropertiesDialog::SoundLibraryPropertiesDialog( QWidget* pParent, Drumkit *drumkitInfo, Drumkit *preDrumKit )
41 : QDialog( pParent )
42 , Object( "SoundLibraryPropertiesDialog" )
43{
44        setupUi( this );
45        INFOLOG( "INIT" );
46        setWindowTitle( trUtf8( "SoundLibrary Properties" ) ); 
47        setFixedSize( width(), height() );
48        predrumkit = preDrumKit;
49
50        //display the current drumkit infos into the qlineedit
51        if ( drumkitInfo != NULL ){
52                drumkitinfo = drumkitInfo;
53                nameTxt->setText( QString( drumkitInfo->getName() ) );
54                oldName = drumkitInfo->getName();
55                authorTxt->setText( QString( drumkitInfo->getAuthor() ) );
56                infoTxt->append( QString( drumkitInfo->getInfo() ) );
57                licenseTxt->setText( QString( drumkitInfo->getLicense() ) );
58        }
59
60}
61
62
63
64
65SoundLibraryPropertiesDialog::~SoundLibraryPropertiesDialog()
66{
67        INFOLOG( "DESTROY" );
68
69}
70
71
72
73void SoundLibraryPropertiesDialog::on_saveBtn_clicked()
74{
75       
76        bool reload = false;
77
78        //load the selected drumkit to save it correct.... later the old drumkit will be reloaded
79        if ( drumkitinfo != NULL ){
80                if ( Hydrogen::get_instance()->getCurrentDrumkitname() != drumkitinfo->getName() ){
81                        Hydrogen::get_instance()->loadDrumkit( drumkitinfo );
82                        Hydrogen::get_instance()->getSong()->__is_modified = true;     
83                }
84        }
85               
86        //check the drumkit name. if the name is a new one, one qmessagebox with question "are you sure" will displayed.
87        if ( nameTxt->text() != oldName  ){
88                int res = QMessageBox::information( this, "Hydrogen", tr( "Warning! You're changing the drumkit name. This creates a new drumkit with this name.\nAre you sure?"), tr("&Ok"), tr("&Cancel"), 0, 1 );
89                if ( res == 1 ) {
90                        return;
91                }
92                else
93                {       
94                        reload = true;
95                }
96        }
97
98        //save the drumkit     
99        H2Core::Drumkit::save(
100                        nameTxt->text(),
101                        authorTxt->text(),
102                        infoTxt->toHtml(),
103                        licenseTxt->text()
104        );
105       
106        //check the name and set the drumkitinfo to current drumkit
107        if ( drumkitinfo != NULL && nameTxt->text() != "" ){
108                drumkitinfo->setName( nameTxt->text() );
109                drumkitinfo->setAuthor( authorTxt->text() );
110                drumkitinfo->setInfo( infoTxt->toHtml() );
111                drumkitinfo->setLicense( licenseTxt->text() );
112        }
113       
114
115        //check pre loaded drumkit name  and reload the old drumkit
116        if ( predrumkit != NULL ){
117                Hydrogen::get_instance()->loadDrumkit( predrumkit );
118                Hydrogen::get_instance()->getSong()->__is_modified = true;
119        }
120
121        //reload if necessary
122        if ( reload == true ){
123                HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList();
124        }
125
126        accept();
127       
128}
129
130}
Note: See TracBrowser for help on using the browser.