hydrogen 1.2.6
SongPropertiesDialog.cpp
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#include "CommonStrings.h"
25
26#include <core/Basics/Song.h>
27#include <core/Hydrogen.h>
28#include <core/License.h>
29
30#include <QPixmap>
31
32using namespace H2Core;
33
35 : QDialog(parent)
36{
37 setupUi( this );
38
39 auto pCommonStrings = HydrogenApp::get_instance()->getCommonStrings();
40
41 adjustSize();
42 setMaximumSize( width(), height() );
43 setMinimumSize( width(), height() );
44
45 setWindowTitle( tr( "Song properties" ) );
46
47 std::shared_ptr<Song> pSong = Hydrogen::get_instance()->getSong();
48 songNameTxt->setText( pSong->getName() );
49
50 authorTxt->setText( pSong->getAuthor() );
51 notesTxt->append( pSong->getNotes() );
52 connect( licenseComboBox, SIGNAL( currentIndexChanged( int ) ),
53 this, SLOT( licenseComboBoxChanged( int ) ) );
54
55 setupLicenseComboBox( licenseComboBox );
56
57 licenseComboBox->setToolTip( pCommonStrings->getLicenseComboToolTip() );
58 licenseStringTxt->setToolTip( pCommonStrings->getLicenseStringToolTip() );
59
60 licenseComboBox->setCurrentIndex( static_cast<int>( pSong->getLicense().getType() ) );
61 licenseStringTxt->setText( pSong->getLicense().getLicenseString() );
62 if ( pSong->getLicense().getType() == License::Unspecified ) {
63 licenseStringTxt->hide();
64 }
65}
66
67
68
72
74
75 licenseStringTxt->setText( License::LicenseTypeToQString(
76 static_cast<License::LicenseType>( licenseComboBox->currentIndex() ) ) );
77
78 if ( licenseComboBox->currentIndex() == static_cast<int>( License::Unspecified ) ) {
79 licenseStringTxt->hide();
80 }
81 else {
82 licenseStringTxt->show();
83 }
84}
85
90
92{
93 auto pHydrogen = Hydrogen::get_instance();
94 auto pSong = pHydrogen->getSong();
95
96 bool bIsModified = false;
97 if ( songNameTxt->text() != pSong->getName() ) {
98 pSong->setName( songNameTxt->text() );
99 bIsModified = true;
100 }
101 if ( pSong->getAuthor() != authorTxt->text() ) {
102 pSong->setAuthor( authorTxt->text() );
103 bIsModified = true;
104 }
105 if ( pSong->getNotes() != notesTxt->toPlainText() ) {
106 pSong->setNotes( notesTxt->toPlainText() );
107 bIsModified = true;
108 }
109
110 QString sNewLicenseString( licenseStringTxt->text() );
111 if ( licenseComboBox->currentIndex() ==
112 static_cast<int>(License::Unspecified) ) {
113 sNewLicenseString = "";
114 }
115 License newLicense( sNewLicenseString );
116 if ( pSong->getLicense() != newLicense ) {
117 pSong->setLicense( newLicense );
118 bIsModified = true;
119 }
120
121 if ( bIsModified ) {
122 pHydrogen->setIsModified( true );
123 }
124
125 accept();
126}
std::shared_ptr< Song > getSong() const
Get the current song.
Definition Hydrogen.h:123
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
Definition Hydrogen.h:84
Wrapper class to help Hydrogen deal with the license information specified in a drumkit.
Definition License.h:48
LicenseType
A couple of recognized licenses.
Definition License.h:58
@ Unspecified
No license set yet.
Definition License.h:74
static QString LicenseTypeToQString(LicenseType license)
Definition License.h:155
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
std::shared_ptr< CommonStrings > getCommonStrings()
SongPropertiesDialog(QWidget *parent)
void setupLicenseComboBox(QComboBox *pComboBox)