/[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 1527 by schoenebeck, Mon Nov 26 16:00:21 2007 UTC revision 3014 by capela, Mon Oct 17 16:23:15 2016 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-2016, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007,2015 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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# 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            loadOptions();
48    }
49    
50    
51    // Default Destructor.
52    Options::~Options (void)
53    {
54            saveOptions();
55    }
56    
57    
58    // Explicit load method.
59    void Options::loadOptions (void)
60    {
61          // Begin into general options group.          // Begin into general options group.
62          m_settings.beginGroup("/Options");          m_settings.beginGroup("/Options");
63    
# Line 48  qsamplerOptions::qsamplerOptions (void) Line 65  qsamplerOptions::qsamplerOptions (void)
65          m_settings.beginGroup("/Server");          m_settings.beginGroup("/Server");
66          sServerHost    = m_settings.value("/ServerHost", "localhost").toString();          sServerHost    = m_settings.value("/ServerHost", "localhost").toString();
67          iServerPort    = m_settings.value("/ServerPort", 8888).toInt();          iServerPort    = m_settings.value("/ServerPort", 8888).toInt();
68    #if defined(__APPLE__)  //  Toshi Nagata 20080105
69            //  TODO: Should this be a configure option?
70            iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt();
71    #else
72          iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt();          iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt();
73    #endif
74          bServerStart   = m_settings.value("/ServerStart", true).toBool();          bServerStart   = m_settings.value("/ServerStart", true).toBool();
75    #if defined(__APPLE__)
76            sServerCmdLine = m_settings.value("/ServerCmdLine", "/usr/local/bin/linuxsampler").toString();
77    #else
78          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString();          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString();
79    #endif
80          iStartDelay    = m_settings.value("/StartDelay", 3).toInt();          iStartDelay    = m_settings.value("/StartDelay", 3).toInt();
81          m_settings.endGroup();          m_settings.endGroup();
82    
83            // Load logging options...
84            m_settings.beginGroup("/Logging");
85            bMessagesLog     = m_settings.value("/MessagesLog", false).toBool();
86            sMessagesLogPath = m_settings.value("/MessagesLogPath", "qsampler.log").toString();
87            m_settings.endGroup();
88    
89          // Load display options...          // Load display options...
90          m_settings.beginGroup("/Display");          m_settings.beginGroup("/Display");
91          sDisplayFont     = m_settings.value("/DisplayFont").toString();          sDisplayFont     = m_settings.value("/DisplayFont").toString();
# Line 65  qsamplerOptions::qsamplerOptions (void) Line 97  qsamplerOptions::qsamplerOptions (void)
97          bMessagesLimit   = m_settings.value("/MessagesLimit", true).toBool();          bMessagesLimit   = m_settings.value("/MessagesLimit", true).toBool();
98          iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt();          iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt();
99          bConfirmRemove   = m_settings.value("/ConfirmRemove", true).toBool();          bConfirmRemove   = m_settings.value("/ConfirmRemove", true).toBool();
100            bConfirmReset    = m_settings.value("/ConfirmReset", true).toBool();
101            bConfirmRestart  = m_settings.value("/ConfirmRestart", true).toBool();
102            bConfirmError    = m_settings.value("/ConfirmError", true).toBool();
103          bKeepOnTop       = m_settings.value("/KeepOnTop", true).toBool();          bKeepOnTop       = m_settings.value("/KeepOnTop", true).toBool();
104          bStdoutCapture   = m_settings.value("/StdoutCapture", true).toBool();          bStdoutCapture   = m_settings.value("/StdoutCapture", true).toBool();
105          bCompletePath    = m_settings.value("/CompletePath", true).toBool();          bCompletePath    = m_settings.value("/CompletePath", true).toBool();
106          iMaxRecentFiles  = m_settings.value("/MaxRecentFiles", 5).toInt();          iMaxRecentFiles  = m_settings.value("/MaxRecentFiles", 5).toInt();
107            iBaseFontSize    = m_settings.value("/BaseFontSize", 0).toInt();
108  // if libgig provides a fast way to retrieve instrument names even for large  // if libgig provides a fast way to retrieve instrument names even for large
109  // .gig files, then we enable this feature by default  // .gig files, then we enable this feature by default
110  #if HAVE_LIBGIG_SETAUTOLOAD  #ifdef CONFIG_LIBGIG_SETAUTOLOAD
111          bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool();          bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool();
112  #else  #else
113          bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool();          bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool();
# Line 99  qsamplerOptions::qsamplerOptions (void) Line 135  qsamplerOptions::qsamplerOptions (void)
135          }          }
136          m_settings.endGroup();          m_settings.endGroup();
137    
138            // Sampler fine tuning settings.
139            m_settings.beginGroup("/Tuning");
140            iMaxVoices  = m_settings.value("/MaxVoices",  -1).toInt();
141            iMaxStreams = m_settings.value("/MaxStreams",  -1).toInt();
142            m_settings.endGroup();
143    
144          // Last but not least, get the default directories.          // Last but not least, get the default directories.
145          m_settings.beginGroup("/Default");          m_settings.beginGroup("/Default");
146          sSessionDir    = m_settings.value("/SessionDir").toString();          sSessionDir    = m_settings.value("/SessionDir").toString();
# Line 115  qsamplerOptions::qsamplerOptions (void) Line 157  qsamplerOptions::qsamplerOptions (void)
157  }  }
158    
159    
160  // Default Destructor.  // Explicit save method.
161  qsamplerOptions::~qsamplerOptions (void)  void Options::saveOptions (void)
162  {  {
163          // Make program version available in the future.          // Make program version available in the future.
164          m_settings.beginGroup("/Program");          m_settings.beginGroup("/Program");
# Line 136  qsamplerOptions::~qsamplerOptions (void) Line 178  qsamplerOptions::~qsamplerOptions (void)
178          m_settings.setValue("/StartDelay", iStartDelay);          m_settings.setValue("/StartDelay", iStartDelay);
179          m_settings.endGroup();          m_settings.endGroup();
180    
181            // Save logging options...
182            m_settings.beginGroup("/Logging");
183            m_settings.setValue("/MessagesLog", bMessagesLog);
184            m_settings.setValue("/MessagesLogPath", sMessagesLogPath);
185            m_settings.endGroup();
186    
187          // Save display options.          // Save display options.
188          m_settings.beginGroup("/Display");          m_settings.beginGroup("/Display");
189          m_settings.setValue("/DisplayFont", sDisplayFont);          m_settings.setValue("/DisplayFont", sDisplayFont);
# Line 147  qsamplerOptions::~qsamplerOptions (void) Line 195  qsamplerOptions::~qsamplerOptions (void)
195          m_settings.setValue("/MessagesLimit", bMessagesLimit);          m_settings.setValue("/MessagesLimit", bMessagesLimit);
196          m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines);          m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines);
197          m_settings.setValue("/ConfirmRemove", bConfirmRemove);          m_settings.setValue("/ConfirmRemove", bConfirmRemove);
198            m_settings.setValue("/ConfirmReset", bConfirmReset);
199            m_settings.setValue("/ConfirmRestart", bConfirmRestart);
200            m_settings.setValue("/ConfirmError", bConfirmError);
201          m_settings.setValue("/KeepOnTop", bKeepOnTop);          m_settings.setValue("/KeepOnTop", bKeepOnTop);
202          m_settings.setValue("/StdoutCapture", bStdoutCapture);          m_settings.setValue("/StdoutCapture", bStdoutCapture);
203          m_settings.setValue("/CompletePath", bCompletePath);          m_settings.setValue("/CompletePath", bCompletePath);
204          m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles);          m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles);
205            m_settings.setValue("/BaseFontSize", iBaseFontSize);
206          m_settings.setValue("/InstrumentNames", bInstrumentNames);          m_settings.setValue("/InstrumentNames", bInstrumentNames);
207          m_settings.endGroup();          m_settings.endGroup();
208    
# Line 172  qsamplerOptions::~qsamplerOptions (void) Line 224  qsamplerOptions::~qsamplerOptions (void)
224                  m_settings.setValue("/File" + QString::number(++iFile), iter.next());                  m_settings.setValue("/File" + QString::number(++iFile), iter.next());
225          m_settings.endGroup();          m_settings.endGroup();
226    
227            // Sampler fine tuning settings.
228            m_settings.beginGroup("/Tuning");
229            if (iMaxVoices > 0)
230                    m_settings.setValue("/MaxVoices", iMaxVoices);
231            if (iMaxStreams >= 0)
232                    m_settings.setValue("/MaxStreams", iMaxStreams);
233            m_settings.endGroup();
234    
235          // Default directories.          // Default directories.
236          m_settings.beginGroup("/Default");          m_settings.beginGroup("/Default");
237          m_settings.setValue("/SessionDir", sSessionDir);          m_settings.setValue("/SessionDir", sSessionDir);
# Line 185  qsamplerOptions::~qsamplerOptions (void) Line 245  qsamplerOptions::~qsamplerOptions (void)
245          m_settings.setValue("/Volume", iVolume);          m_settings.setValue("/Volume", iVolume);
246          m_settings.setValue("/Loadmode", iLoadMode);          m_settings.setValue("/Loadmode", iLoadMode);
247          m_settings.endGroup();          m_settings.endGroup();
248    
249            // Save/commit to disk.
250            m_settings.sync();
251  }  }
252    
253    
254  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
255  // Settings accessor.  // Settings accessor.
256  //  //
257    
258  QSettings& qsamplerOptions::settings (void)  QSettings& Options::settings (void)
259  {  {
260          return m_settings;          return m_settings;
261  }  }
# Line 202  QSettings& qsamplerOptions::settings (vo Line 266  QSettings& qsamplerOptions::settings (vo
266  //  //
267    
268  // Help about command line options.  // Help about command line options.
269  void qsamplerOptions::print_usage ( const char *arg0 )  void Options::print_usage ( const QString& arg0 )
270  {  {
271          QTextStream out(stderr);          QTextStream out(stderr);
272          out << QObject::tr("Usage: %1 [options] [session-file]\n\n"          out << QObject::tr("Usage: %1 [options] [session-file]\n\n"
273                  QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n"                  QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n"
274                  "Options:\n\n"                  "Options:\n\n"
275                  "  -s, --start\n\tStart linuxsampler server locally\n\n"                  "  -s, --start\n\tStart linuxsampler server locally\n\n"
276                  "  -h, --hostname\n\tSpecify linuxsampler server hostname\n\n"                  "  -h, --hostname\n\tSpecify linuxsampler server hostname (default = localhost)\n\n"
277                  "  -p, --port\n\tSpecify linuxsampler server port number\n\n"                  "  -p, --port\n\tSpecify linuxsampler server port number (default = 8888)\n\n"
278                  "  -?, --help\n\tShow help about command line options\n\n"                  "  -?, --help\n\tShow help about command line options\n\n"
279                  "  -v, --version\n\tShow version information\n\n")                  "  -v, --version\n\tShow version information\n\n")
280                  .arg(arg0);                  .arg(arg0);
# Line 218  void qsamplerOptions::print_usage ( cons Line 282  void qsamplerOptions::print_usage ( cons
282    
283    
284  // Parse command line arguments into m_settings.  // Parse command line arguments into m_settings.
285  bool qsamplerOptions::parse_args ( int argc, char **argv )  bool Options::parse_args ( const QStringList& args )
286  {  {
287          QTextStream out(stderr);          QTextStream out(stderr);
288          const QString sEol = "\n\n";          const QString sEol = "\n\n";
289          int iCmdArgs = 0;          int iCmdArgs = 0;
290            const int argc = args.count();
291    
292          for (int i = 1; i < argc; i++) {          for (int i = 1; i < argc; i++) {
293    
294                  if (iCmdArgs > 0) {                  if (iCmdArgs > 0) {
295                          sSessionFile += " ";                          sSessionFile += " ";
296                          sSessionFile += argv[i];                          sSessionFile += args.at(i);
297                          iCmdArgs++;                          iCmdArgs++;
298                          continue;                          continue;
299                  }                  }
300    
301                  QString sArg = argv[i];                  QString sArg = args.at(i);
302                  QString sVal = QString::null;                  QString sVal = QString::null;
303                  int iEqual = sArg.indexOf("=");                  const int iEqual = sArg.indexOf("=");
304                  if (iEqual >= 0) {                  if (iEqual >= 0) {
305                          sVal = sArg.right(sArg.length() - iEqual - 1);                          sVal = sArg.right(sArg.length() - iEqual - 1);
306                          sArg = sArg.left(iEqual);                          sArg = sArg.left(iEqual);
307                  }                  }
308                  else if (i < argc)                  else if (i < argc - 1) {
309                          sVal = argv[i + 1];                          sVal = args.at(i + 1);
310                            if (sVal[0] == '-')
311                                    sVal.clear();
312                    }
313    
314                  if (sArg == "-s" || sArg == "--start") {                  if (sArg == "-s" || sArg == "--start") {
315                          bServerStart = true;                          bServerStart = true;
316                  }                  }
317                  else if (sArg == "-h" || sArg == "--hostname") {                  else if (sArg == "-h" || sArg == "--hostname") {
318                          if (sVal.isNull()) {                          if (sVal.isNull()) {
319                                  out << QObject::tr("Option -h requires an argument (hostname).") + sEol;                                  out << QObject::tr("Option -h requires an argument (host).") + sEol;
320                                  return false;                                  return false;
321                          }                          }
322                          sServerHost = sVal;                          sServerHost = sVal;
# Line 265  bool qsamplerOptions::parse_args ( int a Line 333  bool qsamplerOptions::parse_args ( int a
333                                  i++;                                  i++;
334                  }                  }
335                  else if (sArg == "-?" || sArg == "--help") {                  else if (sArg == "-?" || sArg == "--help") {
336                          print_usage(argv[0]);                          print_usage(args.at(0));
337                          return false;                          return false;
338                  }                  }
339                  else if (sArg == "-v" || sArg == "--version") {                  else if (sArg == "-v" || sArg == "--version") {
340                          out << QObject::tr("Qt: %1\n").arg(qVersion());                          out << QObject::tr("Qt: %1\n")
341  #ifdef CONFIG_LIBGIG                                  .arg(qVersion());
342                            out << QObject::tr("%1: %2  (%3)\n")
343                                    .arg(QSAMPLER_TITLE)
344                                    .arg(QSAMPLER_VERSION)
345                                    .arg(CONFIG_BUILD_DATE);
346                    #ifdef CONFIG_LIBGIG
347                          out << QString("%1: %2\n")                          out << QString("%1: %2\n")
348                                  .arg(gig::libraryName().c_str())                                  .arg(gig::libraryName().c_str())
349                                  .arg(gig::libraryVersion().c_str());                                  .arg(gig::libraryVersion().c_str());
350  #endif                  #endif
351                          out << QString("%1: %2\n")                          out << QString("%1: %2\n")
352                                  .arg(::lscp_client_package())                                  .arg(::lscp_client_package())
353                                  .arg(::lscp_client_version());                                  .arg(::lscp_client_version());
                         out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION);  
354                          return false;                          return false;
355                  }                  }
356                  else {                  else {
# Line 297  bool qsamplerOptions::parse_args ( int a Line 369  bool qsamplerOptions::parse_args ( int a
369  //---------------------------------------------------------------------------  //---------------------------------------------------------------------------
370  // Widget geometry persistence helper methods.  // Widget geometry persistence helper methods.
371    
372  void qsamplerOptions::loadWidgetGeometry ( QWidget *pWidget )  void Options::loadWidgetGeometry ( QWidget *pWidget, bool bVisible )
373  {  {
374          // Try to restore old form window positioning.          // Try to restore old form window positioning.
375          if (pWidget) {          if (pWidget) {
376                  QPoint fpos;          //      if (bVisible) pWidget->show(); -- force initial exposure?
                 QSize  fsize;  
                 bool bVisible;  
377                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
378                  fpos.setX(m_settings.value("/x", -1).toInt());          #if QT_VERSION >= 0x050000
379                  fpos.setY(m_settings.value("/y", -1).toInt());                  const QByteArray& geometry
380                  fsize.setWidth(m_settings.value("/width", -1).toInt());                          = m_settings.value("/geometry").toByteArray();
381                  fsize.setHeight(m_settings.value("/height", -1).toInt());                  if (!geometry.isEmpty())
382                  bVisible = m_settings.value("/visible", false).toBool();                          pWidget->restoreGeometry(geometry);
383                  m_settings.endGroup();                  else
384                  if (fpos.x() > 0 && fpos.y() > 0)          #else//--LOAD_OLD_GEOMETRY
385                          pWidget->move(fpos);                  QPoint wpos;
386                  if (fsize.width() > 0 && fsize.height() > 0)                  QSize  wsize;
387                          pWidget->resize(fsize);                  wpos.setX(m_settings.value("/x", -1).toInt());
388                    wpos.setY(m_settings.value("/y", -1).toInt());
389                    wsize.setWidth(m_settings.value("/width", -1).toInt());
390                    wsize.setHeight(m_settings.value("/height", -1).toInt());
391                    if (wpos.x() > 0 && wpos.y() > 0)
392                            pWidget->move(wpos);
393                    if (wsize.width() > 0 && wsize.height() > 0)
394                            pWidget->resize(wsize);
395                  else                  else
396                          pWidget->adjustSize();          #endif
397                    pWidget->adjustSize();
398                    if (!bVisible)
399                            bVisible = m_settings.value("/visible", false).toBool();
400                  if (bVisible)                  if (bVisible)
401                          pWidget->show();                          pWidget->show();
402                  else                  else
403                          pWidget->hide();                          pWidget->hide();
404                    m_settings.endGroup();
405          }          }
406  }  }
407    
408    
409  void qsamplerOptions::saveWidgetGeometry ( QWidget *pWidget )  void Options::saveWidgetGeometry ( QWidget *pWidget, bool bVisible )
410  {  {
411          // Try to save form window position...          // Try to save form window position...
412          // (due to X11 window managers ideossincrasies, we better          // (due to X11 window managers ideossincrasies, we better
413          // only save the form geometry while its up and visible)          // only save the form geometry while its up and visible)
414          if (pWidget) {          if (pWidget) {
415                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
416                  bool bVisible = pWidget->isVisible();          #if QT_VERSION >= 0x050000
417                  const QPoint& fpos  = pWidget->pos();                  m_settings.setValue("/geometry", pWidget->saveGeometry());
418                  const QSize&  fsize = pWidget->size();          #else//--SAVE_OLD_GEOMETRY
419                  m_settings.setValue("/x", fpos.x());                  const QPoint& wpos  = pWidget->pos();
420                  m_settings.setValue("/y", fpos.y());                  const QSize&  wsize = pWidget->size();
421                  m_settings.setValue("/width", fsize.width());                  m_settings.setValue("/x", wpos.x());
422                  m_settings.setValue("/height", fsize.height());                  m_settings.setValue("/y", wpos.y());
423                    m_settings.setValue("/width", wsize.width());
424                    m_settings.setValue("/height", wsize.height());
425            #endif
426                    if (!bVisible) bVisible = pWidget->isVisible();
427                  m_settings.setValue("/visible", bVisible);                  m_settings.setValue("/visible", bVisible);
428                  m_settings.endGroup();                  m_settings.endGroup();
429          }          }
# Line 348  void qsamplerOptions::saveWidgetGeometry Line 433  void qsamplerOptions::saveWidgetGeometry
433  //---------------------------------------------------------------------------  //---------------------------------------------------------------------------
434  // Combo box history persistence helper implementation.  // Combo box history persistence helper implementation.
435    
436  void qsamplerOptions::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )
437  {  {
438            const bool bBlockSignals = pComboBox->blockSignals(true);
439    
440          // Load combobox list from configuration settings file...          // Load combobox list from configuration settings file...
441          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
442    
# Line 357  void qsamplerOptions::loadComboBoxHistor Line 444  void qsamplerOptions::loadComboBoxHistor
444                  pComboBox->setUpdatesEnabled(false);                  pComboBox->setUpdatesEnabled(false);
445                  pComboBox->setDuplicatesEnabled(false);                  pComboBox->setDuplicatesEnabled(false);
446                  pComboBox->clear();                  pComboBox->clear();
447                  for (int i = 0; i < iLimit; i++) {                  for (int i = 0; i < iLimit; ++i) {
448                          const QString& sText = m_settings.value(                          const QString& sText = m_settings.value(
449                                  "/Item" + QString::number(i + 1)).toString();                                  "/Item" + QString::number(i + 1)).toString();
450                          if (sText.isEmpty())                          if (sText.isEmpty())
# Line 368  void qsamplerOptions::loadComboBoxHistor Line 455  void qsamplerOptions::loadComboBoxHistor
455          }          }
456    
457          m_settings.endGroup();          m_settings.endGroup();
458    
459            pComboBox->blockSignals(bBlockSignals);
460  }  }
461    
462    
463  void qsamplerOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )
464  {  {
465            const bool bBlockSignals = pComboBox->blockSignals(true);
466    
467          // Add current text as latest item...          // Add current text as latest item...
468          const QString& sCurrentText = pComboBox->currentText();          const QString sCurrentText = pComboBox->currentText();
469          int iCount = pComboBox->count();          int iCount = pComboBox->count();
470          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; i++) {
471                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
472                  if (sText == sCurrentText) {                  if (sText == sCurrentText) {
473                          pComboBox->removeItem(i);                          pComboBox->removeItem(i);
474                          iCount--;                          --iCount;
475                          break;                          break;
476                  }                  }
477          }          }
478          while (iCount >= iLimit)          while (iCount >= iLimit)
479                  pComboBox->removeItem(--iCount);                  pComboBox->removeItem(--iCount);
480          pComboBox->insertItem(0, sCurrentText);          pComboBox->insertItem(0, sCurrentText);
481          iCount++;          pComboBox->setCurrentIndex(0);
482            ++iCount;
483    
484          // Save combobox list to configuration settings file...          // Save combobox list to configuration settings file...
485          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
486          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; ++i) {
487                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
488                  if (sText.isEmpty())                  if (sText.isEmpty())
489                          break;                          break;
490                  m_settings.setValue("/Item" + QString::number(i + 1), sText);                  m_settings.setValue("/Item" + QString::number(i + 1), sText);
491          }          }
492          m_settings.endGroup();          m_settings.endGroup();
493    
494            pComboBox->blockSignals(bBlockSignals);
495    }
496    
497    
498    int Options::getMaxVoices() {
499    #ifndef CONFIG_MAX_VOICES
500            return -1;
501    #else
502            if (iMaxVoices > 0) return iMaxVoices;
503            return getEffectiveMaxVoices();
504    #endif // CONFIG_MAX_VOICES
505    }
506    
507    int Options::getEffectiveMaxVoices() {
508    #ifndef CONFIG_MAX_VOICES
509            return -1;
510    #else
511            MainForm *pMainForm = MainForm::getInstance();
512            if (!pMainForm || !pMainForm->client())
513                    return -1;
514    
515            return ::lscp_get_voices(pMainForm->client());
516    #endif // CONFIG_MAX_VOICES
517    }
518    
519    void Options::setMaxVoices(int iMaxVoices) {
520    #ifdef CONFIG_MAX_VOICES
521            if (iMaxVoices < 1) return;
522    
523            MainForm *pMainForm = MainForm::getInstance();
524            if (!pMainForm || !pMainForm->client())
525                    return;
526    
527            lscp_status_t result =
528                    ::lscp_set_voices(pMainForm->client(), iMaxVoices);
529    
530            if (result != LSCP_OK) {
531                    pMainForm->appendMessagesClient("lscp_set_voices");
532                    return;
533            }
534    
535            this->iMaxVoices = iMaxVoices;
536    #endif // CONFIG_MAX_VOICES
537  }  }
538    
539    int Options::getMaxStreams() {
540    #ifndef CONFIG_MAX_VOICES
541            return -1;
542    #else
543            if (iMaxStreams > 0) return iMaxStreams;
544            return getEffectiveMaxStreams();
545    #endif // CONFIG_MAX_VOICES
546    }
547    
548    int Options::getEffectiveMaxStreams() {
549    #ifndef CONFIG_MAX_VOICES
550            return -1;
551    #else
552            MainForm *pMainForm = MainForm::getInstance();
553            if (!pMainForm || !pMainForm->client())
554                    return -1;
555    
556            return ::lscp_get_streams(pMainForm->client());
557    #endif // CONFIG_MAX_VOICES
558    }
559    
560    void Options::setMaxStreams(int iMaxStreams) {
561    #ifdef CONFIG_MAX_VOICES
562            if (iMaxStreams < 0) return;
563    
564            MainForm *pMainForm = MainForm::getInstance();
565            if (!pMainForm || !pMainForm->client())
566                    return;
567    
568            lscp_status_t result =
569                    ::lscp_set_streams(pMainForm->client(), iMaxStreams);
570    
571            if (result != LSCP_OK) {
572                    pMainForm->appendMessagesClient("lscp_set_streams");
573                    return;
574            }
575    
576            this->iMaxStreams = iMaxStreams;
577    #endif // CONFIG_MAX_VOICES
578    }
579    
580    void Options::sendFineTuningSettings() {
581            setMaxVoices(iMaxVoices);
582            setMaxStreams(iMaxStreams);
583    
584            MainForm *pMainForm = MainForm::getInstance();
585            if (!pMainForm || !pMainForm->client())
586                    return;
587    
588            pMainForm->appendMessages(QObject::tr("Sent fine tuning settings."));
589    }
590    
591    } // namespace QSampler
592    
593    
594  // end of qsamplerOptions.cpp  // end of qsamplerOptions.cpp

Legend:
Removed from v.1527  
changed lines
  Added in v.3014

  ViewVC Help
Powered by ViewVC