/[svn]/qsampler/trunk/src/qsamplerOptionsForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerOptionsForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3648 by capela, Tue Dec 10 10:34:06 2019 UTC revision 4038 by capela, Sun May 15 18:43:41 2022 UTC
# Line 1  Line 1 
1  // qsamplerOptionsForm.cpp  // qsamplerOptionsForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2022, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007, Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 33  Line 33 
33    
34  #include <QStyleFactory>  #include <QStyleFactory>
35    
 namespace QSampler {  
36    
37  // Default (empty/blank) name.  // Default (empty/blank) name.
38  static const char *g_pszDefName = QT_TR_NOOP("(default)");  static const char *g_pszDefName = QT_TRANSLATE_NOOP("qsamplerOptionsForm", "(default)");
39    
40    
41    namespace QSampler {
42    
43  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
44  // QSampler::OptionsForm -- Options form implementation.  // QSampler::OptionsForm -- Options form implementation.
# Line 46  OptionsForm::OptionsForm ( QWidget* pPar Line 48  OptionsForm::OptionsForm ( QWidget* pPar
48          : QDialog(pParent)          : QDialog(pParent)
49  {  {
50          m_ui.setupUi(this);          m_ui.setupUi(this);
51    #if QT_VERSION < QT_VERSION_CHECK(6, 1, 0)
52            QDialog::setWindowIcon(QIcon(":/images/qsampler.png"));
53    #endif
54          // No settings descriptor initially (the caller will set it).          // No settings descriptor initially (the caller will set it).
55          m_pOptions = nullptr;          m_pOptions = nullptr;
56    
# Line 224  void OptionsForm::setup ( Options *pOpti Line 228  void OptionsForm::setup ( Options *pOpti
228                  || !font.fromString(m_pOptions->sMessagesFont))                  || !font.fromString(m_pOptions->sMessagesFont))
229                  font = QFont("Monospace", 8);                  font = QFont("Monospace", 8);
230          pal = m_ui.MessagesFontTextLabel->palette();          pal = m_ui.MessagesFontTextLabel->palette();
231          pal.setColor(QPalette::Background, pal.base().color());          pal.setColor(QPalette::Window, pal.base().color());
232          m_ui.MessagesFontTextLabel->setPalette(pal);          m_ui.MessagesFontTextLabel->setPalette(pal);
233          m_ui.MessagesFontTextLabel->setFont(font);          m_ui.MessagesFontTextLabel->setFont(font);
234          m_ui.MessagesFontTextLabel->setText(font.family()          m_ui.MessagesFontTextLabel->setText(font.family()
# Line 343  void OptionsForm::accept (void) Line 347  void OptionsForm::accept (void)
347                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();
348                  m_pOptions->iBaseFontSize  = m_ui.BaseFontSizeComboBox->currentText().toInt();                  m_pOptions->iBaseFontSize  = m_ui.BaseFontSizeComboBox->currentText().toInt();
349                  // Custom color/style theme options...                  // Custom color/style theme options...
                 const QString sOldCustomStyleTheme = m_pOptions->sCustomStyleTheme;  
350                  if (m_ui.CustomStyleThemeComboBox->currentIndex() > 0)                  if (m_ui.CustomStyleThemeComboBox->currentIndex() > 0)
351                          m_pOptions->sCustomStyleTheme = m_ui.CustomStyleThemeComboBox->currentText();                          m_pOptions->sCustomStyleTheme = m_ui.CustomStyleThemeComboBox->currentText();
352                  else                  else
353                          m_pOptions->sCustomStyleTheme.clear();                          m_pOptions->sCustomStyleTheme.clear();
                 const QString sOldCustomColorTheme = m_pOptions->sCustomColorTheme;  
354                  if (m_ui.CustomColorThemeComboBox->currentIndex() > 0)                  if (m_ui.CustomColorThemeComboBox->currentIndex() > 0)
355                          m_pOptions->sCustomColorTheme = m_ui.CustomColorThemeComboBox->currentText();                          m_pOptions->sCustomColorTheme = m_ui.CustomColorThemeComboBox->currentText();
356                  else                  else
357                          m_pOptions->sCustomColorTheme.clear();                          m_pOptions->sCustomColorTheme.clear();
                 // Check whether restart is needed or whether  
                 // custom options maybe set up immediately...  
                 int iNeedRestart = 0;  
                 if (m_pOptions->sCustomStyleTheme != sOldCustomStyleTheme) {  
                         if (m_pOptions->sCustomStyleTheme.isEmpty()) {  
                                 ++iNeedRestart;  
                         } else {  
                                 QApplication::setStyle(  
                                         QStyleFactory::create(m_pOptions->sCustomStyleTheme));  
                         }  
                 }  
                 if (m_pOptions->sCustomColorTheme != sOldCustomColorTheme) {  
                         if (m_pOptions->sCustomColorTheme.isEmpty()) {  
                                 ++iNeedRestart;  
                         } else {  
                                 QPalette pal;  
                                 if (PaletteForm::namedPalette(  
                                                 &m_pOptions->settings(), m_pOptions->sCustomColorTheme, pal))  
                                         QApplication::setPalette(pal);  
                         }  
                 }  
                 // Show restart message if needed...  
                 if (iNeedRestart > 0) {  
                         QMessageBox::information(this,  
                                 tr("Information"),  
                                 tr("Some settings may be only effective\n"  
                                 "next time you start this application."));  
                 }  
358                  // Reset dirty flag.                  // Reset dirty flag.
359                  m_iDirtyCount = 0;                  m_iDirtyCount = 0;
360          }          }
361    
362          // if the user modified the limits, apply them to the sampler          // If the user modified the limits, apply them to the sampler
363          // (and store it later in qsampler's configuration)          // (and store it later in qsampler's configuration)
364          if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled())          if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled())
365                  m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value());                  m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value());
# Line 526  void OptionsForm::chooseMessagesFont (vo Line 500  void OptionsForm::chooseMessagesFont (vo
500  void OptionsForm::toggleDisplayEffect ( bool bOn )  void OptionsForm::toggleDisplayEffect ( bool bOn )
501  {  {
502          QPalette pal;          QPalette pal;
503          pal.setColor(QPalette::Foreground, Qt::green);          pal.setColor(QPalette::WindowText, Qt::green);
504          if (bOn) {          if (bOn) {
505                  QPixmap pm(":/images/displaybg1.png");                  QPixmap pm(":/images/displaybg1.png");
506                  pal.setBrush(QPalette::Background, QBrush(pm));                  pal.setBrush(QPalette::Window, QBrush(pm));
507          } else {          } else {
508                  pal.setColor(QPalette::Background, Qt::black);                  pal.setColor(QPalette::Window, Qt::black);
509          }          }
510          m_ui.DisplayFontTextLabel->setPalette(pal);          m_ui.DisplayFontTextLabel->setPalette(pal);
511    
# Line 591  void OptionsForm::resetCustomColorThemes Line 565  void OptionsForm::resetCustomColorThemes
565                  PaletteForm::namedPaletteList(&m_pOptions->settings()));                  PaletteForm::namedPaletteList(&m_pOptions->settings()));
566    
567          int iCustomColorTheme = 0;          int iCustomColorTheme = 0;
568          if (!sCustomColorTheme.isEmpty())          if (!sCustomColorTheme.isEmpty()) {
569                  iCustomColorTheme = m_ui.CustomColorThemeComboBox->findText(                  iCustomColorTheme = m_ui.CustomColorThemeComboBox->findText(
570                          sCustomColorTheme);                          sCustomColorTheme);
571                    if (iCustomColorTheme < 0)
572                            iCustomColorTheme = 0;
573            }
574          m_ui.CustomColorThemeComboBox->setCurrentIndex(iCustomColorTheme);          m_ui.CustomColorThemeComboBox->setCurrentIndex(iCustomColorTheme);
575  }  }
576    
# Line 608  void OptionsForm::resetCustomStyleThemes Line 585  void OptionsForm::resetCustomStyleThemes
585          m_ui.CustomStyleThemeComboBox->addItems(QStyleFactory::keys());          m_ui.CustomStyleThemeComboBox->addItems(QStyleFactory::keys());
586    
587          int iCustomStyleTheme = 0;          int iCustomStyleTheme = 0;
588          if (!sCustomStyleTheme.isEmpty())          if (!sCustomStyleTheme.isEmpty()) {
589                  iCustomStyleTheme = m_ui.CustomStyleThemeComboBox->findText(                  iCustomStyleTheme = m_ui.CustomStyleThemeComboBox->findText(
590                          sCustomStyleTheme);                          sCustomStyleTheme);
591                    if (iCustomStyleTheme < 0)
592                            iCustomStyleTheme = 0;
593            }
594          m_ui.CustomStyleThemeComboBox->setCurrentIndex(iCustomStyleTheme);          m_ui.CustomStyleThemeComboBox->setCurrentIndex(iCustomStyleTheme);
595  }  }
596    

Legend:
Removed from v.3648  
changed lines
  Added in v.4038

  ViewVC Help
Powered by ViewVC