/[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 3555 by capela, Tue Aug 13 10:19:32 2019 UTC revision 3761 by capela, Tue Mar 31 11:06:16 2020 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-2020, 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 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    
37    // Default (empty/blank) name.
38    static const char *g_pszDefName = QT_TRANSLATE_NOOP("qsamplerOptionsForm", "(default)");
39    
40    
41  namespace QSampler {  namespace QSampler {
42    
# Line 133  OptionsForm::OptionsForm ( QWidget* pPar Line 141  OptionsForm::OptionsForm ( QWidget* pPar
141          QObject::connect(m_ui.InstrumentNamesCheckBox,          QObject::connect(m_ui.InstrumentNamesCheckBox,
142                  SIGNAL(stateChanged(int)),                  SIGNAL(stateChanged(int)),
143                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
144            QObject::connect(m_ui.CustomColorThemeComboBox,
145                    SIGNAL(activated(int)),
146                    SLOT(optionsChanged()));
147            QObject::connect(m_ui.CustomColorThemeToolButton,
148                    SIGNAL(clicked()),
149                    SLOT(editCustomColorThemes()));
150            QObject::connect(m_ui.CustomStyleThemeComboBox,
151                    SIGNAL(activated(int)),
152                    SLOT(optionsChanged()));
153          QObject::connect(m_ui.BaseFontSizeComboBox,          QObject::connect(m_ui.BaseFontSizeComboBox,
154                  SIGNAL(editTextChanged(const QString&)),                  SIGNAL(editTextChanged(const QString&)),
155                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
# Line 281  void OptionsForm::setup ( Options *pOpti Line 298  void OptionsForm::setup ( Options *pOpti
298          );          );
299  #endif // CONFIG_MAX_VOICES  #endif // CONFIG_MAX_VOICES
300    
301            // Custom display options...
302            resetCustomColorThemes(m_pOptions->sCustomColorTheme);
303            resetCustomStyleThemes(m_pOptions->sCustomStyleTheme);
304    
305          // Done.          // Done.
306          m_iDirtySetup--;          m_iDirtySetup--;
307          stabilizeForm();          stabilizeForm();
# Line 323  void OptionsForm::accept (void) Line 344  void OptionsForm::accept (void)
344                  m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked();                  m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked();
345                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();                  m_pOptions->iMaxRecentFiles  = m_ui.MaxRecentFilesSpinBox->value();
346                  m_pOptions->iBaseFontSize  = m_ui.BaseFontSizeComboBox->currentText().toInt();                  m_pOptions->iBaseFontSize  = m_ui.BaseFontSizeComboBox->currentText().toInt();
347                    // Custom color/style theme options...
348                    if (m_ui.CustomStyleThemeComboBox->currentIndex() > 0)
349                            m_pOptions->sCustomStyleTheme = m_ui.CustomStyleThemeComboBox->currentText();
350                    else
351                            m_pOptions->sCustomStyleTheme.clear();
352                    if (m_ui.CustomColorThemeComboBox->currentIndex() > 0)
353                            m_pOptions->sCustomColorTheme = m_ui.CustomColorThemeComboBox->currentText();
354                    else
355                            m_pOptions->sCustomColorTheme.clear();
356                  // Reset dirty flag.                  // Reset dirty flag.
357                  m_iDirtyCount = 0;                  m_iDirtyCount = 0;
358          }          }
359    
360          // if the user modified the limits, apply them to the sampler          // If the user modified the limits, apply them to the sampler
361          // (and store it later in qsampler's configuration)          // (and store it later in qsampler's configuration)
362          if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled())          if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled())
363                  m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value());                  m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value());
# Line 356  void OptionsForm::reject (void) Line 386  void OptionsForm::reject (void)
386          // Check if there's any pending changes...          // Check if there's any pending changes...
387          if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
388                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
389                          QSAMPLER_TITLE ": " + tr("Warning"),                          tr("Warning"),
390                          tr("Some settings have been changed.\n\n"                          tr("Some settings have been changed.\n\n"
391                          "Do you want to apply the changes?"),                          "Do you want to apply the changes?"),
392                          QMessageBox::Apply |                          QMessageBox::Apply |
# Line 492  void OptionsForm::maxStreamsChanged(int Line 522  void OptionsForm::maxStreamsChanged(int
522          optionsChanged();          optionsChanged();
523  }  }
524    
525    
526    // Custom color palette theme manager.
527    void OptionsForm::editCustomColorThemes (void)
528    {
529            PaletteForm form(this);
530            form.setSettings(&m_pOptions->settings());
531    
532            QString sCustomColorTheme;
533            int iDirtyCustomColorTheme = 0;
534    
535            const int iCustomColorTheme
536                    = m_ui.CustomColorThemeComboBox->currentIndex();
537            if (iCustomColorTheme > 0) {
538                    sCustomColorTheme = m_ui.CustomColorThemeComboBox->itemText(
539                            iCustomColorTheme);
540                    form.setPaletteName(sCustomColorTheme);
541            }
542    
543            if (form.exec() == QDialog::Accepted) {
544                    sCustomColorTheme = form.paletteName();
545                    ++iDirtyCustomColorTheme;
546            }
547    
548            if (iDirtyCustomColorTheme > 0 || form.isDirty()) {
549                    resetCustomColorThemes(sCustomColorTheme);
550                    optionsChanged();
551            }
552    }
553    
554    
555    // Custom color palette themes settler.
556    void OptionsForm::resetCustomColorThemes (
557            const QString& sCustomColorTheme )
558    {
559            m_ui.CustomColorThemeComboBox->clear();
560            m_ui.CustomColorThemeComboBox->addItem(
561                    tr(g_pszDefName));
562            m_ui.CustomColorThemeComboBox->addItems(
563                    PaletteForm::namedPaletteList(&m_pOptions->settings()));
564    
565            int iCustomColorTheme = 0;
566            if (!sCustomColorTheme.isEmpty()) {
567                    iCustomColorTheme = m_ui.CustomColorThemeComboBox->findText(
568                            sCustomColorTheme);
569                    if (iCustomColorTheme < 0)
570                            iCustomColorTheme = 0;
571            }
572            m_ui.CustomColorThemeComboBox->setCurrentIndex(iCustomColorTheme);
573    }
574    
575    
576    // Custom widget style themes settler.
577    void OptionsForm::resetCustomStyleThemes (
578            const QString& sCustomStyleTheme )
579    {
580            m_ui.CustomStyleThemeComboBox->clear();
581            m_ui.CustomStyleThemeComboBox->addItem(
582                    tr(g_pszDefName));
583            m_ui.CustomStyleThemeComboBox->addItems(QStyleFactory::keys());
584    
585            int iCustomStyleTheme = 0;
586            if (!sCustomStyleTheme.isEmpty()) {
587                    iCustomStyleTheme = m_ui.CustomStyleThemeComboBox->findText(
588                            sCustomStyleTheme);
589                    if (iCustomStyleTheme < 0)
590                            iCustomStyleTheme = 0;
591            }
592            m_ui.CustomStyleThemeComboBox->setCurrentIndex(iCustomStyleTheme);
593    }
594    
595    
596  } // namespace QSampler  } // namespace QSampler
597    
598  // end of qsamplerOptionsForm.cpp  // end of qsamplerOptionsForm.cpp

Legend:
Removed from v.3555  
changed lines
  Added in v.3761

  ViewVC Help
Powered by ViewVC