46 setObjectName(
"SoundLibraryPropertiesDialog" );
53 setWindowFlags( windowFlags() | Qt::CustomizeWindowHint |
54 Qt::WindowMinMaxButtonsHint );
59 setWindowTitle( tr(
"SoundLibrary Properties" ) );
62 connect( licenseComboBox, SIGNAL( currentIndexChanged(
int ) ),
65 connect( imageLicenseComboBox, SIGNAL( currentIndexChanged(
int ) ),
68 bool bDrumkitWritable =
false;
70 if ( pDrumkit !=
nullptr ){
73 pDrumkit->get_path() );
76 bDrumkitWritable =
true;
79 nameTxt->setText( pDrumkit->get_name() );
81 if ( bDrumkitNameLocked ) {
82 nameTxt->setIsActive(
false );
83 nameTxt->setToolTip( tr(
"Altering the name of a drumkit would result in the creation of a new one. To do so, you need to load the drumkit (if you haven't done so already) using right click > load and select Drumkits > Save As in the main menu" ) );
86 authorTxt->setText( QString( pDrumkit->get_author() ) );
87 infoTxt->append( QString( pDrumkit->get_info() ) );
89 License license = pDrumkit->get_license();
90 licenseComboBox->setCurrentIndex(
static_cast<int>( license.
getType() ) );
93 imageText->setText( QString( pDrumkit->get_image() ) );
95 License imageLicense = pDrumkit->get_image_license();
96 imageLicenseComboBox->setCurrentIndex(
static_cast<int>( imageLicense.
getType() ) );
101 licenseStringLbl->hide();
102 licenseStringTxt->hide();
105 imageLicenseStringLbl->hide();
106 imageLicenseStringTxt->hide();
109 licenseComboBox->setToolTip( pCommonStrings->getLicenseComboToolTip() );
110 licenseStringLbl->setText( pCommonStrings->getLicenseStringLbl() );
111 licenseStringTxt->setToolTip( pCommonStrings->getLicenseStringToolTip() );
112 imageLicenseComboBox->setToolTip( pCommonStrings->getLicenseComboToolTip() );
113 imageLicenseStringLbl->setText( pCommonStrings->getLicenseStringLbl() );
114 imageLicenseStringTxt->setToolTip( pCommonStrings->getLicenseStringToolTip() );
118 if ( ! bDrumkitWritable && bDrumkitNameLocked ) {
119 QString sToolTip = tr(
"The current drumkit is read-only. Please use Drumkits > Save As in the main menu to create a new one first." );
123 authorTxt->setIsActive(
false );
124 authorTxt->setToolTip( sToolTip );
125 infoTxt->setEnabled(
false );
126 infoTxt->setReadOnly(
true );
127 infoTxt->setToolTip( sToolTip );
128 licenseComboBox->setIsActive(
false );
129 licenseComboBox->setToolTip( sToolTip );
130 licenseStringTxt->setIsActive(
false );
131 licenseStringTxt->setToolTip( sToolTip );
132 imageText->setIsActive(
false );
133 imageText->setToolTip( sToolTip );
134 imageLicenseComboBox->setIsActive(
false );
135 imageLicenseComboBox->setToolTip( sToolTip );
136 imageLicenseStringTxt->setIsActive(
false );
137 imageLicenseStringTxt->setToolTip( sToolTip );
138 saveBtn->setIsActive(
false );
139 saveBtn->setToolTip( sToolTip );
140 imageBrowsePushButton->setIsActive(
false );
141 imageBrowsePushButton->setToolTip( sToolTip );
145 infoTxt->setStyleSheet( QString(
"\
148 background-color: %2; \
150 .arg( pPref->getColorTheme()->m_windowTextColor.name() )
151 .arg( pPref->getColorTheme()->m_windowColor.name() ) );
155 saveBtn->setFixedFontSize( 12 );
156 saveBtn->setSize( QSize( 70, 23 ) );
157 saveBtn->setBorderRadius( 3 );
158 m_cancelBtn->setFixedFontSize( 12 );
159 m_cancelBtn->setSize( QSize( 70, 23 ) );
160 m_cancelBtn->setBorderRadius( 3 );
161 imageBrowsePushButton->setFixedFontSize( 12 );
162 imageBrowsePushButton->setBorderRadius( 3 );
163 imageBrowsePushButton->setSize( QSize( 70, 23 ) );
165 contentTable->setColumnCount( 4 );
166 contentTable->setHorizontalHeaderLabels( QStringList() <<
167 tr(
"Instrument" ) <<
171 contentTable->verticalHeader()->hide();
172 contentTable->horizontalHeader()->setStretchLastSection(
true );
174 contentTable->setColumnWidth( 0, 160 );
175 contentTable->setColumnWidth( 1, 80 );
176 contentTable->setColumnWidth( 2, 210 );
210 auto contentVector =
m_pDrumkit->summarizeContent();
212 if ( contentVector.size() > 0 ) {
213 contentTable->show();
214 contentLabel->show();
215 contentTable->setRowCount( contentVector.size() );
217 int nFirstMismatchRow = -1;
219 for (
int ii = 0; ii < contentVector.size(); ++ ii ) {
220 const auto ccontent = contentVector[ ii ];
222 QLineEdit* pInstrumentItem =
new QLineEdit( ccontent->m_sInstrumentName );
223 pInstrumentItem->setEnabled(
false );
224 pInstrumentItem->setToolTip( ccontent->m_sInstrumentName );
225 QLineEdit* pComponentItem =
new QLineEdit( ccontent->m_sComponentName );
226 pComponentItem->setEnabled(
false );
227 pComponentItem->setToolTip( ccontent->m_sComponentName );
228 QLineEdit* pSampleItem =
new QLineEdit( ccontent->m_sSampleName );
229 pSampleItem->setEnabled(
false );
230 pSampleItem->setToolTip( ccontent->m_sSampleName );
231 QLineEdit* pLicenseItem =
232 new QLineEdit( ccontent->m_license.getLicenseString() );
233 pLicenseItem->setEnabled(
false );
234 pLicenseItem->setToolTip( ccontent->m_license.getLicenseString() );
237 if ( ccontent->m_license !=
m_pDrumkit->get_license() ) {
238 QString sRed = QString(
"color: %1; background-color: %2" )
239 .arg( pPref->getColorTheme()->m_buttonRedColor.name() )
240 .arg( pPref->getColorTheme()->m_windowColor.name() );
241 pInstrumentItem->setStyleSheet( sRed );
242 pComponentItem->setStyleSheet( sRed );
243 pSampleItem->setStyleSheet( sRed );
244 pLicenseItem->setStyleSheet( sRed );
246 if ( nFirstMismatchRow == -1 ) {
247 nFirstMismatchRow = ii;
251 contentTable->setCellWidget( ii, 0, pInstrumentItem );
252 contentTable->setCellWidget( ii, 1, pComponentItem );
253 contentTable->setCellWidget( ii, 2, pSampleItem );
254 contentTable->setCellWidget( ii, 3, pLicenseItem );
258 if ( nFirstMismatchRow != -1 ) {
259 contentTable->showRow( nFirstMismatchRow );
263 contentTable->hide();
264 contentLabel->hide();
302 QPixmap *pPixmap =
new QPixmap ( filename );
305 if ( pPixmap->isNull() ) {
306 ERRORLOG( QString(
"Unable to load pixmap from [%1]" ).arg( filename ) );
307 drumkitImageLabel->hide();
312 int x = (int) drumkitImageLabel->size().width();
313 int y = drumkitImageLabel->size().height();
314 float labelAspect = (float) x / y;
315 float imageAspect = (float) pPixmap->width() / pPixmap->height();
317 if ( ( x < pPixmap->width() ) || ( y < pPixmap->height() ) )
319 if ( labelAspect >= imageAspect )
322 *pPixmap = pPixmap->scaledToHeight( y );
327 *pPixmap = pPixmap->scaledToWidth( x );
330 drumkitImageLabel->setPixmap(*pPixmap);
331 drumkitImageLabel->show();
374 auto pSong = pHydrogen->getSong();
381 License licenseCheck( licenseStringTxt->text() );
382 if (
static_cast<int>(licenseCheck.
getType()) != licenseComboBox->currentIndex() ) {
383 if ( QMessageBox::warning(
this,
"Hydrogen",
384 tr(
"Specified drumkit License String does not comply with the license selected in the combo box." ),
385 QMessageBox::Ok | QMessageBox::Cancel,
386 QMessageBox::Cancel )
387 == QMessageBox::Cancel ) {
388 WARNINGLOG( QString(
"Abort, since drumkit License String [%1] does not comply to selected License Type [%2]" )
389 .arg( licenseStringTxt->text() )
395 License imageLicenseCheck( imageLicenseStringTxt->text() );
396 if (
static_cast<int>(imageLicenseCheck.
getType()) !=
397 imageLicenseComboBox->currentIndex() ) {
398 if ( QMessageBox::warning(
this,
"Hydrogen",
399 tr(
"Specified image License String does not comply with the license selected in the combo box." ),
400 QMessageBox::Ok | QMessageBox::Cancel,
401 QMessageBox::Cancel )
402 == QMessageBox::Cancel ) {
403 WARNINGLOG( QString(
"Abort, since drumkit image License String [%1] does not comply to selected License Type [%2]" )
404 .arg( imageLicenseStringTxt->text() )
412 if ( nameTxt->text().isEmpty() ){
413 QMessageBox::warning(
this,
"Hydrogen", tr(
"The name of the drumkit must not be left empty" ) );
417 QString sNewLicenseString( licenseStringTxt->text() );
418 if ( licenseComboBox->currentIndex() ==
420 sNewLicenseString =
"";
422 License newLicense( sNewLicenseString );
425 QString sNewImageLicenseString( imageLicenseStringTxt->text() );
426 if ( imageLicenseComboBox->currentIndex() ==
428 sNewImageLicenseString =
"";
430 License newImageLicense( sNewImageLicenseString );
433 const QString sOldPath =
m_pDrumkit->get_path();
434 if (
m_pDrumkit->get_name() != nameTxt->text() ) {
444 if (
m_pDrumkit->get_license() != newLicense ) {
449 ERRORLOG(
"User cancelled dialog due to licensing issues." );
455 QString sOldImagePath;
456 if ( imageText->text() !=
m_pDrumkit->get_image() ) {
457 int nRes = QMessageBox::information(
this,
"Hydrogen",
458 tr(
"Delete previous drumkit image" )
459 .append( QString(
" [%1]" ).arg(
m_pDrumkit->get_image() ) ),
460 QMessageBox::Yes | QMessageBox::No );
461 if ( nRes == QMessageBox::Yes ) {
462 sOldImagePath = QString(
"%1/%2" ).arg( sOldPath )
468 if (
m_pDrumkit->get_image_license() != newImageLicense ) {
469 m_pDrumkit->set_image_license( newImageLicense );
472 QApplication::setOverrideCursor(Qt::WaitCursor);
476 QApplication::restoreOverrideCursor();
477 QMessageBox::information(
this,
"Hydrogen", tr (
"Saving of this drumkit failed."));
478 ERRORLOG(
"Saving of this drumkit failed." );
487 if ( fileInfo.dir().absolutePath() !=
m_pDrumkit->get_path() ) {
490 const QString sTargetPath =
491 QString(
"%1/%2" ).arg(
m_pDrumkit->get_path() )
492 .arg( fileInfo.fileName() );
498 if ( ! sOldImagePath.isEmpty() ) {
502 pHydrogen->getSoundLibraryDatabase()->updateDrumkits();
504 QApplication::restoreOverrideCursor();