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

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

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

revision 1509 by capela, Thu Nov 22 11:10:44 2007 UTC revision 1803 by schoenebeck, Sun Dec 7 13:58:16 2008 UTC
# Line 1  Line 1 
1  // qsamplerOptions.cpp  // qsamplerOptions.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2008, 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 22  Line 22 
22    
23  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
24  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
25    #include "qsamplerMainForm.h"
26    
27  #include <QTextStream>  #include <QTextStream>
28  #include <QComboBox>  #include <QComboBox>
# Line 33  Line 34 
34  #endif  #endif
35    
36    
37    namespace QSampler {
38    
39  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
40  // qsamplerOptions - Prototype settings structure.  // QSampler::Options - Prototype settings structure.
41  //  //
42    
43  // Constructor.  // Constructor.
44  qsamplerOptions::qsamplerOptions (void)  Options::Options (void)
45          : m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE)          : m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE)
46  {  {
47          // Begin into general options group.          // Begin into general options group.
# Line 48  qsamplerOptions::qsamplerOptions (void) Line 51  qsamplerOptions::qsamplerOptions (void)
51          m_settings.beginGroup("/Server");          m_settings.beginGroup("/Server");
52          sServerHost    = m_settings.value("/ServerHost", "localhost").toString();          sServerHost    = m_settings.value("/ServerHost", "localhost").toString();
53          iServerPort    = m_settings.value("/ServerPort", 8888).toInt();          iServerPort    = m_settings.value("/ServerPort", 8888).toInt();
54            #if defined(__APPLE__)  //  Toshi Nagata 20080105
55            //  TODO: Should this be a configure option?
56            iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt();
57            #else
58          iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt();          iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt();
59            #endif
60          bServerStart   = m_settings.value("/ServerStart", true).toBool();          bServerStart   = m_settings.value("/ServerStart", true).toBool();
61            #if defined(__APPLE__)  //  Toshi Nagata 20080113
62            sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler.starter").toString();
63            #else
64          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString();          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString();
65            #endif
66          iStartDelay    = m_settings.value("/StartDelay", 3).toInt();          iStartDelay    = m_settings.value("/StartDelay", 3).toInt();
67          m_settings.endGroup();          m_settings.endGroup();
68    
69            // Load logging options...
70            m_settings.beginGroup("/Logging");
71            bMessagesLog     = m_settings.value("/MessagesLog", false).toBool();
72            sMessagesLogPath = m_settings.value("/MessagesLogPath", "qsampler.log").toString();
73            m_settings.endGroup();
74    
75          // Load display options...          // Load display options...
76          m_settings.beginGroup("/Display");          m_settings.beginGroup("/Display");
77          sDisplayFont     = m_settings.value("/DisplayFont").toString();          sDisplayFont     = m_settings.value("/DisplayFont").toString();
# Line 69  qsamplerOptions::qsamplerOptions (void) Line 87  qsamplerOptions::qsamplerOptions (void)
87          bStdoutCapture   = m_settings.value("/StdoutCapture", true).toBool();          bStdoutCapture   = m_settings.value("/StdoutCapture", true).toBool();
88          bCompletePath    = m_settings.value("/CompletePath", true).toBool();          bCompletePath    = m_settings.value("/CompletePath", true).toBool();
89          iMaxRecentFiles  = m_settings.value("/MaxRecentFiles", 5).toInt();          iMaxRecentFiles  = m_settings.value("/MaxRecentFiles", 5).toInt();
90            iBaseFontSize    = m_settings.value("/BaseFontSize", 0).toInt();
91    // if libgig provides a fast way to retrieve instrument names even for large
92    // .gig files, then we enable this feature by default
93    #if HAVE_LIBGIG_SETAUTOLOAD
94            bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool();
95    #else
96          bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool();          bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool();
97    #endif
98          m_settings.endGroup();          m_settings.endGroup();
99    
100          // And go into view options group.          // And go into view options group.
# Line 93  qsamplerOptions::qsamplerOptions (void) Line 118  qsamplerOptions::qsamplerOptions (void)
118          }          }
119          m_settings.endGroup();          m_settings.endGroup();
120    
121            // Sampler fine tuning settings.
122            m_settings.beginGroup("/Tuning");
123            iMaxVoices  = m_settings.value("/MaxVoices",  -1).toInt();
124            iMaxStreams = m_settings.value("/MaxStreams",  -1).toInt();
125            m_settings.endGroup();
126    
127          // Last but not least, get the default directories.          // Last but not least, get the default directories.
128          m_settings.beginGroup("/Default");          m_settings.beginGroup("/Default");
129          sSessionDir    = m_settings.value("/SessionDir").toString();          sSessionDir    = m_settings.value("/SessionDir").toString();
# Line 110  qsamplerOptions::qsamplerOptions (void) Line 141  qsamplerOptions::qsamplerOptions (void)
141    
142    
143  // Default Destructor.  // Default Destructor.
144  qsamplerOptions::~qsamplerOptions (void)  Options::~Options (void)
145  {  {
146          // Make program version available in the future.          // Make program version available in the future.
147          m_settings.beginGroup("/Program");          m_settings.beginGroup("/Program");
# Line 130  qsamplerOptions::~qsamplerOptions (void) Line 161  qsamplerOptions::~qsamplerOptions (void)
161          m_settings.setValue("/StartDelay", iStartDelay);          m_settings.setValue("/StartDelay", iStartDelay);
162          m_settings.endGroup();          m_settings.endGroup();
163    
164            // Save logging options...
165            m_settings.beginGroup("/Logging");
166            m_settings.setValue("/MessagesLog", bMessagesLog);
167            m_settings.setValue("/MessagesLogPath", sMessagesLogPath);
168            m_settings.endGroup();
169    
170          // Save display options.          // Save display options.
171          m_settings.beginGroup("/Display");          m_settings.beginGroup("/Display");
172          m_settings.setValue("/DisplayFont", sDisplayFont);          m_settings.setValue("/DisplayFont", sDisplayFont);
# Line 145  qsamplerOptions::~qsamplerOptions (void) Line 182  qsamplerOptions::~qsamplerOptions (void)
182          m_settings.setValue("/StdoutCapture", bStdoutCapture);          m_settings.setValue("/StdoutCapture", bStdoutCapture);
183          m_settings.setValue("/CompletePath", bCompletePath);          m_settings.setValue("/CompletePath", bCompletePath);
184          m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles);          m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles);
185            m_settings.setValue("/BaseFontSize", iBaseFontSize);
186          m_settings.setValue("/InstrumentNames", bInstrumentNames);          m_settings.setValue("/InstrumentNames", bInstrumentNames);
187          m_settings.endGroup();          m_settings.endGroup();
188    
# Line 166  qsamplerOptions::~qsamplerOptions (void) Line 204  qsamplerOptions::~qsamplerOptions (void)
204                  m_settings.setValue("/File" + QString::number(++iFile), iter.next());                  m_settings.setValue("/File" + QString::number(++iFile), iter.next());
205          m_settings.endGroup();          m_settings.endGroup();
206    
207            // Sampler fine tuning settings.
208            m_settings.beginGroup("/Tuning");
209            if (iMaxVoices > 0)
210                    m_settings.setValue("/MaxVoices", iMaxVoices);
211            if (iMaxStreams >= 0)
212                    m_settings.setValue("/MaxStreams", iMaxStreams);
213            m_settings.endGroup();
214    
215          // Default directories.          // Default directories.
216          m_settings.beginGroup("/Default");          m_settings.beginGroup("/Default");
217          m_settings.setValue("/SessionDir", sSessionDir);          m_settings.setValue("/SessionDir", sSessionDir);
# Line 185  qsamplerOptions::~qsamplerOptions (void) Line 231  qsamplerOptions::~qsamplerOptions (void)
231  // Settings accessor.  // Settings accessor.
232  //  //
233    
234  QSettings& qsamplerOptions::settings (void)  QSettings& Options::settings (void)
235  {  {
236          return m_settings;          return m_settings;
237  }  }
# Line 196  QSettings& qsamplerOptions::settings (vo Line 242  QSettings& qsamplerOptions::settings (vo
242  //  //
243    
244  // Help about command line options.  // Help about command line options.
245  void qsamplerOptions::print_usage ( const char *arg0 )  void Options::print_usage ( const char *arg0 )
246  {  {
247          QTextStream out(stderr);          QTextStream out(stderr);
248          out << QObject::tr("Usage: %1 [options] [session-file]\n\n"          out << QObject::tr("Usage: %1 [options] [session-file]\n\n"
# Line 212  void qsamplerOptions::print_usage ( cons Line 258  void qsamplerOptions::print_usage ( cons
258    
259    
260  // Parse command line arguments into m_settings.  // Parse command line arguments into m_settings.
261  bool qsamplerOptions::parse_args ( int argc, char **argv )  bool Options::parse_args ( int argc, char **argv )
262  {  {
263          QTextStream out(stderr);          QTextStream out(stderr);
264          const QString sEol = "\n\n";          const QString sEol = "\n\n";
# Line 291  bool qsamplerOptions::parse_args ( int a Line 337  bool qsamplerOptions::parse_args ( int a
337  //---------------------------------------------------------------------------  //---------------------------------------------------------------------------
338  // Widget geometry persistence helper methods.  // Widget geometry persistence helper methods.
339    
340  void qsamplerOptions::loadWidgetGeometry ( QWidget *pWidget )  void Options::loadWidgetGeometry ( QWidget *pWidget )
341  {  {
342          // Try to restore old form window positioning.          // Try to restore old form window positioning.
343          if (pWidget) {          if (pWidget) {
# Line 319  void qsamplerOptions::loadWidgetGeometry Line 365  void qsamplerOptions::loadWidgetGeometry
365  }  }
366    
367    
368  void qsamplerOptions::saveWidgetGeometry ( QWidget *pWidget )  void Options::saveWidgetGeometry ( QWidget *pWidget )
369  {  {
370          // Try to save form window position...          // Try to save form window position...
371          // (due to X11 window managers ideossincrasies, we better          // (due to X11 window managers ideossincrasies, we better
# Line 342  void qsamplerOptions::saveWidgetGeometry Line 388  void qsamplerOptions::saveWidgetGeometry
388  //---------------------------------------------------------------------------  //---------------------------------------------------------------------------
389  // Combo box history persistence helper implementation.  // Combo box history persistence helper implementation.
390    
391  void qsamplerOptions::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )
392  {  {
393          // Load combobox list from configuration settings file...          // Load combobox list from configuration settings file...
394          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
# Line 365  void qsamplerOptions::loadComboBoxHistor Line 411  void qsamplerOptions::loadComboBoxHistor
411  }  }
412    
413    
414  void qsamplerOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )
415  {  {
416          // Add current text as latest item...          // Add current text as latest item...
417          const QString& sCurrentText = pComboBox->currentText();          const QString& sCurrentText = pComboBox->currentText();
# Line 394  void qsamplerOptions::saveComboBoxHistor Line 440  void qsamplerOptions::saveComboBoxHistor
440          m_settings.endGroup();          m_settings.endGroup();
441  }  }
442    
443    int Options::getMaxVoices() {
444    #ifndef CONFIG_MAX_VOICES
445            return -1;
446    #else
447            if (iMaxVoices > 0) return iMaxVoices;
448            return getEffectiveMaxVoices();
449    #endif // CONFIG_MAX_VOICES
450    }
451    
452    int Options::getEffectiveMaxVoices() {
453    #ifndef CONFIG_MAX_VOICES
454            return -1;
455    #else
456            MainForm *pMainForm = MainForm::getInstance();
457            if (!pMainForm || !pMainForm->client())
458                    return -1;
459    
460            return ::lscp_get_voices(pMainForm->client());
461    #endif // CONFIG_MAX_VOICES
462    }
463    
464    void Options::setMaxVoices(int iMaxVoices) {
465    #ifdef CONFIG_MAX_VOICES
466            if (iMaxVoices < 1) return;
467    
468            MainForm *pMainForm = MainForm::getInstance();
469            if (!pMainForm || !pMainForm->client())
470                    return;
471    
472            lscp_status_t result =
473                    ::lscp_set_voices(pMainForm->client(), iMaxVoices);
474    
475            if (result != LSCP_OK) {
476                    pMainForm->appendMessagesClient("lscp_set_voices");
477                    return;
478            }
479    
480            this->iMaxVoices = iMaxVoices;
481    #endif // CONFIG_MAX_VOICES
482    }
483    
484    int Options::getMaxStreams() {
485    #ifndef CONFIG_MAX_VOICES
486            return -1;
487    #else
488            if (iMaxStreams > 0) return iMaxStreams;
489            return getEffectiveMaxStreams();
490    #endif // CONFIG_MAX_VOICES
491    }
492    
493    int Options::getEffectiveMaxStreams() {
494    #ifndef CONFIG_MAX_VOICES
495            return -1;
496    #else
497            MainForm *pMainForm = MainForm::getInstance();
498            if (!pMainForm || !pMainForm->client())
499                    return -1;
500    
501            return ::lscp_get_streams(pMainForm->client());
502    #endif // CONFIG_MAX_VOICES
503    }
504    
505    void Options::setMaxStreams(int iMaxStreams) {
506    #ifdef CONFIG_MAX_VOICES
507            if (iMaxStreams < 0) return;
508    
509            MainForm *pMainForm = MainForm::getInstance();
510            if (!pMainForm || !pMainForm->client())
511                    return;
512    
513            lscp_status_t result =
514                    ::lscp_set_streams(pMainForm->client(), iMaxStreams);
515    
516            if (result != LSCP_OK) {
517                    pMainForm->appendMessagesClient("lscp_set_streams");
518                    return;
519            }
520    
521            this->iMaxStreams = iMaxStreams;
522    #endif // CONFIG_MAX_VOICES
523    }
524    
525    void Options::sendFineTuningSettings() {
526            setMaxVoices(iMaxVoices);
527            setMaxStreams(iMaxStreams);
528    
529            MainForm *pMainForm = MainForm::getInstance();
530            if (!pMainForm || !pMainForm->client())
531                    return;
532    
533            pMainForm->appendMessages(QObject::tr("Sent fine tuning settings."));
534    }
535    
536    } // namespace QSampler
537    
538    
539  // end of qsamplerOptions.cpp  // end of qsamplerOptions.cpp

Legend:
Removed from v.1509  
changed lines
  Added in v.1803

  ViewVC Help
Powered by ViewVC