/[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 3647 by capela, Thu Aug 22 18:58:38 2019 UTC revision 3648 by capela, Tue Dec 10 10:34:06 2019 UTC
# Line 25  Line 25 
25  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
26  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
27    
28    #include "qsamplerPaletteForm.h"
29    
30  #include <QMessageBox>  #include <QMessageBox>
31  #include <QFontDialog>  #include <QFontDialog>
32  #include <QFileDialog>  #include <QFileDialog>
33    
34    #include <QStyleFactory>
35    
36  namespace QSampler {  namespace QSampler {
37    
38    // Default (empty/blank) name.
39    static const char *g_pszDefName = QT_TR_NOOP("(default)");
40    
41  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
42  // QSampler::OptionsForm -- Options form implementation.  // QSampler::OptionsForm -- Options form implementation.
43  //  //
# Line 133  OptionsForm::OptionsForm ( QWidget* pPar Line 139  OptionsForm::OptionsForm ( QWidget* pPar
139          QObject::connect(m_ui.InstrumentNamesCheckBox,          QObject::connect(m_ui.InstrumentNamesCheckBox,
140                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
141                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
142            QObject::connect(m_ui.CustomColorThemeComboBox,
143                    SIGNAL(activated(int)),
144                    SLOT(optionsChanged()));
145            QObject::connect(m_ui.CustomColorThemeToolButton,
146                    SIGNAL(clicked()),
147                    SLOT(editCustomColorThemes()));
148            QObject::connect(m_ui.CustomStyleThemeComboBox,
149                    SIGNAL(activated(int)),
150                    SLOT(optionsChanged()));
151          QObject::connect(m_ui.BaseFontSizeComboBox,          QObject::connect(m_ui.BaseFontSizeComboBox,
152                  SIGNAL(editTextChanged(const QString&)),                  SIGNAL(editTextChanged(const QString&)),
153                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
# Line 281  void OptionsForm::setup ( Options *pOpti Line 296  void OptionsForm::setup ( Options *pOpti
296          );          );
297  #endif // CONFIG_MAX_VOICES  #endif // CONFIG_MAX_VOICES
298    
299            // Custom display options...
300            resetCustomColorThemes(m_pOptions->sCustomColorTheme);
301            resetCustomStyleThemes(m_pOptions->sCustomStyleTheme);
302    
303          // Done.          // Done.
304          m_iDirtySetup--;          m_iDirtySetup--;
305          stabilizeForm();          stabilizeForm();
# Line 323  void OptionsForm::accept (void) Line 342  void OptionsForm::accept (void)
342                  m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked();                  m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked();
343                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();
344                  m_pOptions->iBaseFontSize  = m_ui.BaseFontSizeComboBox->currentText().toInt();                  m_pOptions->iBaseFontSize  = m_ui.BaseFontSizeComboBox->currentText().toInt();
345                    // Custom color/style theme options...
346                    const QString sOldCustomStyleTheme = m_pOptions->sCustomStyleTheme;
347                    if (m_ui.CustomStyleThemeComboBox->currentIndex() > 0)
348                            m_pOptions->sCustomStyleTheme = m_ui.CustomStyleThemeComboBox->currentText();
349                    else
350                            m_pOptions->sCustomStyleTheme.clear();
351                    const QString sOldCustomColorTheme = m_pOptions->sCustomColorTheme;
352                    if (m_ui.CustomColorThemeComboBox->currentIndex() > 0)
353                            m_pOptions->sCustomColorTheme = m_ui.CustomColorThemeComboBox->currentText();
354                    else
355                            m_pOptions->sCustomColorTheme.clear();
356                    // Check whether restart is needed or whether
357                    // custom options maybe set up immediately...
358                    int iNeedRestart = 0;
359                    if (m_pOptions->sCustomStyleTheme != sOldCustomStyleTheme) {
360                            if (m_pOptions->sCustomStyleTheme.isEmpty()) {
361                                    ++iNeedRestart;
362                            } else {
363                                    QApplication::setStyle(
364                                            QStyleFactory::create(m_pOptions->sCustomStyleTheme));
365                            }
366                    }
367                    if (m_pOptions->sCustomColorTheme != sOldCustomColorTheme) {
368                            if (m_pOptions->sCustomColorTheme.isEmpty()) {
369                                    ++iNeedRestart;
370                            } else {
371                                    QPalette pal;
372                                    if (PaletteForm::namedPalette(
373                                                    &m_pOptions->settings(), m_pOptions->sCustomColorTheme, pal))
374                                            QApplication::setPalette(pal);
375                            }
376                    }
377                    // Show restart message if needed...
378                    if (iNeedRestart > 0) {
379                            QMessageBox::information(this,
380                                    tr("Information"),
381                                    tr("Some settings may be only effective\n"
382                                    "next time you start this application."));
383                    }
384                  // Reset dirty flag.                  // Reset dirty flag.
385                  m_iDirtyCount = 0;                  m_iDirtyCount = 0;
386          }          }
# Line 492  void OptionsForm::maxStreamsChanged(int Line 550  void OptionsForm::maxStreamsChanged(int
550          optionsChanged();          optionsChanged();
551  }  }
552    
553    
554    // Custom color palette theme manager.
555    void OptionsForm::editCustomColorThemes (void)
556    {
557            PaletteForm form(this);
558            form.setSettings(&m_pOptions->settings());
559    
560            QString sCustomColorTheme;
561            int iDirtyCustomColorTheme = 0;
562    
563            const int iCustomColorTheme
564                    = m_ui.CustomColorThemeComboBox->currentIndex();
565            if (iCustomColorTheme > 0) {
566                    sCustomColorTheme = m_ui.CustomColorThemeComboBox->itemText(
567                            iCustomColorTheme);
568                    form.setPaletteName(sCustomColorTheme);
569            }
570    
571            if (form.exec() == QDialog::Accepted) {
572                    sCustomColorTheme = form.paletteName();
573                    ++iDirtyCustomColorTheme;
574            }
575    
576            if (iDirtyCustomColorTheme > 0 || form.isDirty()) {
577                    resetCustomColorThemes(sCustomColorTheme);
578                    optionsChanged();
579            }
580    }
581    
582    
583    // Custom color palette themes settler.
584    void OptionsForm::resetCustomColorThemes (
585            const QString& sCustomColorTheme )
586    {
587            m_ui.CustomColorThemeComboBox->clear();
588            m_ui.CustomColorThemeComboBox->addItem(
589                    tr(g_pszDefName));
590            m_ui.CustomColorThemeComboBox->addItems(
591                    PaletteForm::namedPaletteList(&m_pOptions->settings()));
592    
593            int iCustomColorTheme = 0;
594            if (!sCustomColorTheme.isEmpty())
595                    iCustomColorTheme = m_ui.CustomColorThemeComboBox->findText(
596                            sCustomColorTheme);
597            m_ui.CustomColorThemeComboBox->setCurrentIndex(iCustomColorTheme);
598    }
599    
600    
601    // Custom widget style themes settler.
602    void OptionsForm::resetCustomStyleThemes (
603            const QString& sCustomStyleTheme )
604    {
605            m_ui.CustomStyleThemeComboBox->clear();
606            m_ui.CustomStyleThemeComboBox->addItem(
607                    tr(g_pszDefName));
608            m_ui.CustomStyleThemeComboBox->addItems(QStyleFactory::keys());
609    
610            int iCustomStyleTheme = 0;
611            if (!sCustomStyleTheme.isEmpty())
612                    iCustomStyleTheme = m_ui.CustomStyleThemeComboBox->findText(
613                            sCustomStyleTheme);
614            m_ui.CustomStyleThemeComboBox->setCurrentIndex(iCustomStyleTheme);
615    }
616    
617    
618  } // namespace QSampler  } // namespace QSampler
619    
620  // end of qsamplerOptionsForm.cpp  // end of qsamplerOptionsForm.cpp

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

  ViewVC Help
Powered by ViewVC