/[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 1643 by nagata, Sun Jan 13 16:44:00 2008 UTC revision 3855 by capela, Thu Feb 4 10:09:42 2021 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-2021, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007,2008,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>
29    
30    #include <QApplication>
31    
32    #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
33    #include <QDesktopWidget>
34    #endif
35    
36  #include <lscp/client.h>  #include <lscp/client.h>
37    
38  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
39    #if defined(Q_CC_GNU) || defined(Q_CC_MINGW)
40    #pragma GCC diagnostic push
41    #pragma GCC diagnostic ignored "-Wunused-parameter"
42    #endif
43  #include <gig.h>  #include <gig.h>
44    #if defined(Q_CC_GNU) || defined(Q_CC_MINGW)
45    #pragma GCC diagnostic pop
46    #endif
47  #endif  #endif
48    
49    
# Line 43  namespace QSampler { Line 57  namespace QSampler {
57  Options::Options (void)  Options::Options (void)
58          : m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE)          : m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE)
59  {  {
60            loadOptions();
61    }
62    
63    
64    // Default Destructor.
65    Options::~Options (void)
66    {
67            saveOptions();
68    }
69    
70    
71    // Explicit load method.
72    void Options::loadOptions (void)
73    {
74          // Begin into general options group.          // Begin into general options group.
75          m_settings.beginGroup("/Options");          m_settings.beginGroup("/Options");
76    
# Line 50  Options::Options (void) Line 78  Options::Options (void)
78          m_settings.beginGroup("/Server");          m_settings.beginGroup("/Server");
79          sServerHost    = m_settings.value("/ServerHost", "localhost").toString();          sServerHost    = m_settings.value("/ServerHost", "localhost").toString();
80          iServerPort    = m_settings.value("/ServerPort", 8888).toInt();          iServerPort    = m_settings.value("/ServerPort", 8888).toInt();
81          #if defined(__APPLE__)  //  Toshi Nagata 20080105  #if defined(__APPLE__)  //  Toshi Nagata 20080105
82          //  TODO: Should this be a configure option?          //  TODO: Should this be a configure option?
83          iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt();          iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt();
84          #else  #else
85          iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt();          iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt();
86          #endif  #endif
87          bServerStart   = m_settings.value("/ServerStart", true).toBool();          bServerStart   = m_settings.value("/ServerStart", true).toBool();
88          #if defined(__APPLE__)  //  Toshi Nagata 20080113  #if defined(__APPLE__)
89          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler.starter").toString();          sServerCmdLine = m_settings.value("/ServerCmdLine", "/usr/local/bin/linuxsampler").toString();
90          #else  #else
91          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString();          sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString();
92          #endif  #endif
93          iStartDelay    = m_settings.value("/StartDelay", 3).toInt();          iStartDelay    = m_settings.value("/StartDelay", 3).toInt();
94          m_settings.endGroup();          m_settings.endGroup();
95    
96            // Load logging options...
97            m_settings.beginGroup("/Logging");
98            bMessagesLog     = m_settings.value("/MessagesLog", false).toBool();
99            sMessagesLogPath = m_settings.value("/MessagesLogPath", "qsampler.log").toString();
100            m_settings.endGroup();
101    
102          // Load display options...          // Load display options...
103          m_settings.beginGroup("/Display");          m_settings.beginGroup("/Display");
104          sDisplayFont     = m_settings.value("/DisplayFont").toString();          sDisplayFont     = m_settings.value("/DisplayFont").toString();
# Line 76  Options::Options (void) Line 110  Options::Options (void)
110          bMessagesLimit   = m_settings.value("/MessagesLimit", true).toBool();          bMessagesLimit   = m_settings.value("/MessagesLimit", true).toBool();
111          iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt();          iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt();
112          bConfirmRemove   = m_settings.value("/ConfirmRemove", true).toBool();          bConfirmRemove   = m_settings.value("/ConfirmRemove", true).toBool();
113            bConfirmReset    = m_settings.value("/ConfirmReset", true).toBool();
114            bConfirmRestart  = m_settings.value("/ConfirmRestart", true).toBool();
115            bConfirmError    = m_settings.value("/ConfirmError", true).toBool();
116          bKeepOnTop       = m_settings.value("/KeepOnTop", true).toBool();          bKeepOnTop       = m_settings.value("/KeepOnTop", true).toBool();
117          bStdoutCapture   = m_settings.value("/StdoutCapture", true).toBool();          bStdoutCapture   = m_settings.value("/StdoutCapture", true).toBool();
118          bCompletePath    = m_settings.value("/CompletePath", true).toBool();          bCompletePath    = m_settings.value("/CompletePath", true).toBool();
119          iMaxRecentFiles  = m_settings.value("/MaxRecentFiles", 5).toInt();          iMaxRecentFiles  = m_settings.value("/MaxRecentFiles", 5).toInt();
120            iBaseFontSize    = m_settings.value("/BaseFontSize", 0).toInt();
121  // 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
122  // .gig files, then we enable this feature by default  // .gig files, then we enable this feature by default
123  #if HAVE_LIBGIG_SETAUTOLOAD  #ifdef CONFIG_LIBGIG_SETAUTOLOAD
124          bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool();          bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool();
125  #else  #else
126          bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool();          bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool();
127  #endif  #endif
128          m_settings.endGroup();          m_settings.endGroup();
129    
130            // Load custom options...
131            m_settings.beginGroup("/Custom");
132            sCustomColorTheme = m_settings.value("/ColorTheme").toString();
133            sCustomStyleTheme = m_settings.value("/StyleTheme").toString();
134            m_settings.endGroup();
135    
136          // And go into view options group.          // And go into view options group.
137          m_settings.beginGroup("/View");          m_settings.beginGroup("/View");
138          bMenubar     = m_settings.value("/Menubar", true).toBool();          bMenubar     = m_settings.value("/Menubar", true).toBool();
# Line 110  Options::Options (void) Line 154  Options::Options (void)
154          }          }
155          m_settings.endGroup();          m_settings.endGroup();
156    
157            // Sampler fine tuning settings.
158            m_settings.beginGroup("/Tuning");
159            iMaxVoices  = m_settings.value("/MaxVoices",  -1).toInt();
160            iMaxStreams = m_settings.value("/MaxStreams",  -1).toInt();
161            m_settings.endGroup();
162    
163          // Last but not least, get the default directories.          // Last but not least, get the default directories.
164          m_settings.beginGroup("/Default");          m_settings.beginGroup("/Default");
165          sSessionDir    = m_settings.value("/SessionDir").toString();          sSessionDir    = m_settings.value("/SessionDir").toString();
# Line 126  Options::Options (void) Line 176  Options::Options (void)
176  }  }
177    
178    
179  // Default Destructor.  // Explicit save method.
180  Options::~Options (void)  void Options::saveOptions (void)
181  {  {
182          // Make program version available in the future.          // Make program version available in the future.
183          m_settings.beginGroup("/Program");          m_settings.beginGroup("/Program");
184          m_settings.setValue("/Version", QSAMPLER_VERSION);          m_settings.setValue("/Version", CONFIG_BUILD_VERSION);
185          m_settings.endGroup();          m_settings.endGroup();
186    
187          // And go into general options group.          // And go into general options group.
# Line 147  Options::~Options (void) Line 197  Options::~Options (void)
197          m_settings.setValue("/StartDelay", iStartDelay);          m_settings.setValue("/StartDelay", iStartDelay);
198          m_settings.endGroup();          m_settings.endGroup();
199    
200            // Save logging options...
201            m_settings.beginGroup("/Logging");
202            m_settings.setValue("/MessagesLog", bMessagesLog);
203            m_settings.setValue("/MessagesLogPath", sMessagesLogPath);
204            m_settings.endGroup();
205    
206          // Save display options.          // Save display options.
207          m_settings.beginGroup("/Display");          m_settings.beginGroup("/Display");
208          m_settings.setValue("/DisplayFont", sDisplayFont);          m_settings.setValue("/DisplayFont", sDisplayFont);
# Line 158  Options::~Options (void) Line 214  Options::~Options (void)
214          m_settings.setValue("/MessagesLimit", bMessagesLimit);          m_settings.setValue("/MessagesLimit", bMessagesLimit);
215          m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines);          m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines);
216          m_settings.setValue("/ConfirmRemove", bConfirmRemove);          m_settings.setValue("/ConfirmRemove", bConfirmRemove);
217            m_settings.setValue("/ConfirmReset", bConfirmReset);
218            m_settings.setValue("/ConfirmRestart", bConfirmRestart);
219            m_settings.setValue("/ConfirmError", bConfirmError);
220          m_settings.setValue("/KeepOnTop", bKeepOnTop);          m_settings.setValue("/KeepOnTop", bKeepOnTop);
221          m_settings.setValue("/StdoutCapture", bStdoutCapture);          m_settings.setValue("/StdoutCapture", bStdoutCapture);
222          m_settings.setValue("/CompletePath", bCompletePath);          m_settings.setValue("/CompletePath", bCompletePath);
223          m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles);          m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles);
224            m_settings.setValue("/BaseFontSize", iBaseFontSize);
225          m_settings.setValue("/InstrumentNames", bInstrumentNames);          m_settings.setValue("/InstrumentNames", bInstrumentNames);
226          m_settings.endGroup();          m_settings.endGroup();
227    
228            // Save custom options...
229            m_settings.beginGroup("/Custom");
230            m_settings.setValue("/ColorTheme", sCustomColorTheme);
231            m_settings.setValue("/StyleTheme", sCustomStyleTheme);
232            m_settings.endGroup();
233    
234          // View options group.          // View options group.
235          m_settings.beginGroup("/View");          m_settings.beginGroup("/View");
236          m_settings.setValue("/Menubar", bMenubar);          m_settings.setValue("/Menubar", bMenubar);
# Line 183  Options::~Options (void) Line 249  Options::~Options (void)
249                  m_settings.setValue("/File" + QString::number(++iFile), iter.next());                  m_settings.setValue("/File" + QString::number(++iFile), iter.next());
250          m_settings.endGroup();          m_settings.endGroup();
251    
252            // Sampler fine tuning settings.
253            m_settings.beginGroup("/Tuning");
254            if (iMaxVoices > 0)
255                    m_settings.setValue("/MaxVoices", iMaxVoices);
256            if (iMaxStreams >= 0)
257                    m_settings.setValue("/MaxStreams", iMaxStreams);
258            m_settings.endGroup();
259    
260          // Default directories.          // Default directories.
261          m_settings.beginGroup("/Default");          m_settings.beginGroup("/Default");
262          m_settings.setValue("/SessionDir", sSessionDir);          m_settings.setValue("/SessionDir", sSessionDir);
# Line 196  Options::~Options (void) Line 270  Options::~Options (void)
270          m_settings.setValue("/Volume", iVolume);          m_settings.setValue("/Volume", iVolume);
271          m_settings.setValue("/Loadmode", iLoadMode);          m_settings.setValue("/Loadmode", iLoadMode);
272          m_settings.endGroup();          m_settings.endGroup();
273    
274            // Save/commit to disk.
275            m_settings.sync();
276  }  }
277    
278    
279  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
280  // Settings accessor.  // Settings accessor.
281  //  //
# Line 213  QSettings& Options::settings (void) Line 291  QSettings& Options::settings (void)
291  //  //
292    
293  // Help about command line options.  // Help about command line options.
294  void Options::print_usage ( const char *arg0 )  void Options::print_usage ( const QString& arg0 )
295  {  {
296          QTextStream out(stderr);          QTextStream out(stderr);
297          out << QObject::tr("Usage: %1 [options] [session-file]\n\n"          out << QObject::tr("Usage: %1 [options] [session-file]\n\n"
298                  QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n"                  QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n"
299                  "Options:\n\n"                  "Options:\n\n"
300                  "  -s, --start\n\tStart linuxsampler server locally\n\n"                  "  -s, --start\n\tStart linuxsampler server locally\n\n"
301                  "  -h, --hostname\n\tSpecify linuxsampler server hostname\n\n"                  "  -h, --hostname\n\tSpecify linuxsampler server hostname (default = localhost)\n\n"
302                  "  -p, --port\n\tSpecify linuxsampler server port number\n\n"                  "  -p, --port\n\tSpecify linuxsampler server port number (default = 8888)\n\n"
303                  "  -?, --help\n\tShow help about command line options\n\n"                  "  -?, --help\n\tShow help about command line options\n\n"
304                  "  -v, --version\n\tShow version information\n\n")                  "  -v, --version\n\tShow version information\n\n")
305                  .arg(arg0);                  .arg(arg0);
# Line 229  void Options::print_usage ( const char * Line 307  void Options::print_usage ( const char *
307    
308    
309  // Parse command line arguments into m_settings.  // Parse command line arguments into m_settings.
310  bool Options::parse_args ( int argc, char **argv )  bool Options::parse_args ( const QStringList& args )
311  {  {
312          QTextStream out(stderr);          QTextStream out(stderr);
313          const QString sEol = "\n\n";          const QString sEol = "\n\n";
314            const int argc = args.count();
315          int iCmdArgs = 0;          int iCmdArgs = 0;
316    
317          for (int i = 1; i < argc; i++) {          for (int i = 1; i < argc; ++i) {
318    
319                  if (iCmdArgs > 0) {                  if (iCmdArgs > 0) {
320                          sSessionFile += " ";                          sSessionFile += " ";
321                          sSessionFile += argv[i];                          sSessionFile += args.at(i);
322                          iCmdArgs++;                          ++iCmdArgs;
323                          continue;                          continue;
324                  }                  }
325    
326                  QString sArg = argv[i];                  QString sArg = args.at(i);
327                  QString sVal = QString::null;                  QString sVal;
328                  int iEqual = sArg.indexOf("=");                  const int iEqual = sArg.indexOf("=");
329                  if (iEqual >= 0) {                  if (iEqual >= 0) {
330                          sVal = sArg.right(sArg.length() - iEqual - 1);                          sVal = sArg.right(sArg.length() - iEqual - 1);
331                          sArg = sArg.left(iEqual);                          sArg = sArg.left(iEqual);
332                  }                  }
333                  else if (i < argc)                  else if (i < argc - 1) {
334                          sVal = argv[i + 1];                          sVal = args.at(i + 1);
335                            if (sVal[0] == '-')
336                                    sVal.clear();
337                    }
338    
339                  if (sArg == "-s" || sArg == "--start") {                  if (sArg == "-s" || sArg == "--start") {
340                          bServerStart = true;                          bServerStart = true;
341                  }                  }
342                  else if (sArg == "-h" || sArg == "--hostname") {                  else if (sArg == "-h" || sArg == "--hostname") {
343                          if (sVal.isNull()) {                          if (sVal.isNull()) {
344                                  out << QObject::tr("Option -h requires an argument (hostname).") + sEol;                                  out << QObject::tr("Option -h requires an argument (host).") + sEol;
345                                  return false;                                  return false;
346                          }                          }
347                          sServerHost = sVal;                          sServerHost = sVal;
348                          if (iEqual < 0)                          if (iEqual < 0)
349                                  i++;                                  ++i;
350                  }                  }
351                  else if (sArg == "-p" || sArg == "--port") {                  else if (sArg == "-p" || sArg == "--port") {
352                          if (sVal.isNull()) {                          if (sVal.isNull()) {
# Line 273  bool Options::parse_args ( int argc, cha Line 355  bool Options::parse_args ( int argc, cha
355                          }                          }
356                          iServerPort = sVal.toInt();                          iServerPort = sVal.toInt();
357                          if (iEqual < 0)                          if (iEqual < 0)
358                                  i++;                                  ++i;
359                  }                  }
360                  else if (sArg == "-?" || sArg == "--help") {                  else if (sArg == "-?" || sArg == "--help") {
361                          print_usage(argv[0]);                          print_usage(args.at(0));
362                          return false;                          return false;
363                  }                  }
364                  else if (sArg == "-v" || sArg == "--version") {                  else if (sArg == "-v" || sArg == "--version") {
365                          out << QObject::tr("Qt: %1\n").arg(qVersion());                          out << QString("Qt: %1").arg(qVersion());
366  #ifdef CONFIG_LIBGIG                  #if defined(QT_STATIC)
367                            out << "-static";
368                    #endif
369                            out << '\n';
370                    #ifdef CONFIG_LIBGIG
371                          out << QString("%1: %2\n")                          out << QString("%1: %2\n")
372                                  .arg(gig::libraryName().c_str())                                  .arg(gig::libraryName().c_str())
373                                  .arg(gig::libraryVersion().c_str());                                  .arg(gig::libraryVersion().c_str());
374  #endif                  #endif
375                          out << QString("%1: %2\n")                          out << QString("%1: %2\n")
376                                  .arg(::lscp_client_package())                                  .arg(::lscp_client_package())
377                                  .arg(::lscp_client_version());                                  .arg(::lscp_client_version());
378                          out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION);                          out << QString("%1: %2\n")
379                                    .arg(QSAMPLER_TITLE)
380                                    .arg(CONFIG_BUILD_VERSION);
381                          return false;                          return false;
382                  }                  }
383                  else {                  else {
384                          // If we don't have one by now,                          // If we don't have one by now,
385                          // this will be the startup sesion file...                          // this will be the startup sesion file...
386                          sSessionFile += sArg;                          sSessionFile += sArg;
387                          iCmdArgs++;                          ++iCmdArgs;
388                  }                  }
389          }          }
390    
# Line 308  bool Options::parse_args ( int argc, cha Line 396  bool Options::parse_args ( int argc, cha
396  //---------------------------------------------------------------------------  //---------------------------------------------------------------------------
397  // Widget geometry persistence helper methods.  // Widget geometry persistence helper methods.
398    
399  void Options::loadWidgetGeometry ( QWidget *pWidget )  void Options::loadWidgetGeometry ( QWidget *pWidget, bool bVisible )
400  {  {
401          // Try to restore old form window positioning.          // Try to restore old form window positioning.
402          if (pWidget) {          if (pWidget) {
403                  QPoint fpos;          //      if (bVisible) pWidget->show(); -- force initial exposure?
                 QSize  fsize;  
                 bool bVisible;  
404                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
405                  fpos.setX(m_settings.value("/x", -1).toInt());          #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
406                  fpos.setY(m_settings.value("/y", -1).toInt());                  const QByteArray& geometry
407                  fsize.setWidth(m_settings.value("/width", -1).toInt());                          = m_settings.value("/geometry").toByteArray();
408                  fsize.setHeight(m_settings.value("/height", -1).toInt());                  if (geometry.isEmpty()) {
409                  bVisible = m_settings.value("/visible", false).toBool();                          QWidget *pParent = pWidget->parentWidget();
410                  m_settings.endGroup();                          if (pParent)
411                  if (fpos.x() > 0 && fpos.y() > 0)                                  pParent = pParent->window();
412                          pWidget->move(fpos);                  #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
413                  if (fsize.width() > 0 && fsize.height() > 0)                          if (pParent == nullptr)
414                          pWidget->resize(fsize);                                  pParent = QApplication::desktop();
415                  else                  #endif
416                          pWidget->adjustSize();                          if (pParent) {
417                                    QRect wrect(pWidget->geometry());
418                                    wrect.moveCenter(pParent->geometry().center());
419                                    pWidget->move(wrect.topLeft());
420                            }
421                    } else {
422                            pWidget->restoreGeometry(geometry);
423                    }
424            #else//--LOAD_OLD_GEOMETRY
425                    QPoint wpos;
426                    QSize  wsize;
427                    wpos.setX(m_settings.value("/x", -1).toInt());
428                    wpos.setY(m_settings.value("/y", -1).toInt());
429                    wsize.setWidth(m_settings.value("/width", -1).toInt());
430                    wsize.setHeight(m_settings.value("/height", -1).toInt());
431                    if (wpos.x() > 0 && wpos.y() > 0)
432                            pWidget->move(wpos);
433                    if (wsize.width() > 0 && wsize.height() > 0)
434                            pWidget->resize(wsize);
435            #endif
436            //      else
437            //      pWidget->adjustSize();
438                    if (!bVisible)
439                            bVisible = m_settings.value("/visible", false).toBool();
440                  if (bVisible)                  if (bVisible)
441                          pWidget->show();                          pWidget->show();
442                  else                  else
443                          pWidget->hide();                          pWidget->hide();
444                    m_settings.endGroup();
445          }          }
446  }  }
447    
448    
449  void Options::saveWidgetGeometry ( QWidget *pWidget )  void Options::saveWidgetGeometry ( QWidget *pWidget, bool bVisible )
450  {  {
451          // Try to save form window position...          // Try to save form window position...
452          // (due to X11 window managers ideossincrasies, we better          // (due to X11 window managers ideossincrasies, we better
453          // only save the form geometry while its up and visible)          // only save the form geometry while its up and visible)
454          if (pWidget) {          if (pWidget) {
455                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
456                  bool bVisible = pWidget->isVisible();          #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
457                  const QPoint& fpos  = pWidget->pos();                  m_settings.setValue("/geometry", pWidget->saveGeometry());
458                  const QSize&  fsize = pWidget->size();          #else//--SAVE_OLD_GEOMETRY
459                  m_settings.setValue("/x", fpos.x());                  const QPoint& wpos  = pWidget->pos();
460                  m_settings.setValue("/y", fpos.y());                  const QSize&  wsize = pWidget->size();
461                  m_settings.setValue("/width", fsize.width());                  m_settings.setValue("/x", wpos.x());
462                  m_settings.setValue("/height", fsize.height());                  m_settings.setValue("/y", wpos.y());
463                    m_settings.setValue("/width", wsize.width());
464                    m_settings.setValue("/height", wsize.height());
465            #endif
466                    if (!bVisible) bVisible = pWidget->isVisible();
467                  m_settings.setValue("/visible", bVisible);                  m_settings.setValue("/visible", bVisible);
468                  m_settings.endGroup();                  m_settings.endGroup();
469          }          }
# Line 361  void Options::saveWidgetGeometry ( QWidg Line 475  void Options::saveWidgetGeometry ( QWidg
475    
476  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit )
477  {  {
478            const bool bBlockSignals = pComboBox->blockSignals(true);
479    
480          // Load combobox list from configuration settings file...          // Load combobox list from configuration settings file...
481          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
482    
# Line 368  void Options::loadComboBoxHistory ( QCom Line 484  void Options::loadComboBoxHistory ( QCom
484                  pComboBox->setUpdatesEnabled(false);                  pComboBox->setUpdatesEnabled(false);
485                  pComboBox->setDuplicatesEnabled(false);                  pComboBox->setDuplicatesEnabled(false);
486                  pComboBox->clear();                  pComboBox->clear();
487                  for (int i = 0; i < iLimit; i++) {                  for (int i = 0; i < iLimit; ++i) {
488                          const QString& sText = m_settings.value(                          const QString& sText = m_settings.value(
489                                  "/Item" + QString::number(i + 1)).toString();                                  "/Item" + QString::number(i + 1)).toString();
490                          if (sText.isEmpty())                          if (sText.isEmpty())
# Line 379  void Options::loadComboBoxHistory ( QCom Line 495  void Options::loadComboBoxHistory ( QCom
495          }          }
496    
497          m_settings.endGroup();          m_settings.endGroup();
498    
499            pComboBox->blockSignals(bBlockSignals);
500  }  }
501    
502    
503  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )  void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )
504  {  {
505            const bool bBlockSignals = pComboBox->blockSignals(true);
506    
507          // Add current text as latest item...          // Add current text as latest item...
508          const QString& sCurrentText = pComboBox->currentText();          const QString sCurrentText = pComboBox->currentText();
509          int iCount = pComboBox->count();          int iCount = pComboBox->count();
510          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; i++) {
511                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
512                  if (sText == sCurrentText) {                  if (sText == sCurrentText) {
513                          pComboBox->removeItem(i);                          pComboBox->removeItem(i);
514                          iCount--;                          --iCount;
515                          break;                          break;
516                  }                  }
517          }          }
518          while (iCount >= iLimit)          while (iCount >= iLimit)
519                  pComboBox->removeItem(--iCount);                  pComboBox->removeItem(--iCount);
520          pComboBox->insertItem(0, sCurrentText);          pComboBox->insertItem(0, sCurrentText);
521          iCount++;          pComboBox->setCurrentIndex(0);
522            ++iCount;
523    
524          // Save combobox list to configuration settings file...          // Save combobox list to configuration settings file...
525          m_settings.beginGroup("/History/" + pComboBox->objectName());          m_settings.beginGroup("/History/" + pComboBox->objectName());
526          for (int i = 0; i < iCount; i++) {          for (int i = 0; i < iCount; ++i) {
527                  const QString& sText = pComboBox->itemText(i);                  const QString& sText = pComboBox->itemText(i);
528                  if (sText.isEmpty())                  if (sText.isEmpty())
529                          break;                          break;
530                  m_settings.setValue("/Item" + QString::number(i + 1), sText);                  m_settings.setValue("/Item" + QString::number(i + 1), sText);
531          }          }
532          m_settings.endGroup();          m_settings.endGroup();
533    
534            pComboBox->blockSignals(bBlockSignals);
535    }
536    
537    
538    int Options::getMaxVoices() {
539    #ifndef CONFIG_MAX_VOICES
540            return -1;
541    #else
542            if (iMaxVoices > 0) return iMaxVoices;
543            return getEffectiveMaxVoices();
544    #endif // CONFIG_MAX_VOICES
545    }
546    
547    int Options::getEffectiveMaxVoices() {
548    #ifndef CONFIG_MAX_VOICES
549            return -1;
550    #else
551            MainForm *pMainForm = MainForm::getInstance();
552            if (!pMainForm || !pMainForm->client())
553                    return -1;
554    
555            return ::lscp_get_voices(pMainForm->client());
556    #endif // CONFIG_MAX_VOICES
557    }
558    
559    void Options::setMaxVoices(int iMaxVoices) {
560    #ifdef CONFIG_MAX_VOICES
561            if (iMaxVoices < 1) return;
562    
563            MainForm *pMainForm = MainForm::getInstance();
564            if (!pMainForm || !pMainForm->client())
565                    return;
566    
567            lscp_status_t result =
568                    ::lscp_set_voices(pMainForm->client(), iMaxVoices);
569    
570            if (result != LSCP_OK) {
571                    pMainForm->appendMessagesClient("lscp_set_voices");
572                    return;
573            }
574    
575            this->iMaxVoices = iMaxVoices;
576    #endif // CONFIG_MAX_VOICES
577    }
578    
579    int Options::getMaxStreams() {
580    #ifndef CONFIG_MAX_VOICES
581            return -1;
582    #else
583            if (iMaxStreams > 0) return iMaxStreams;
584            return getEffectiveMaxStreams();
585    #endif // CONFIG_MAX_VOICES
586    }
587    
588    int Options::getEffectiveMaxStreams() {
589    #ifndef CONFIG_MAX_VOICES
590            return -1;
591    #else
592            MainForm *pMainForm = MainForm::getInstance();
593            if (!pMainForm || !pMainForm->client())
594                    return -1;
595    
596            return ::lscp_get_streams(pMainForm->client());
597    #endif // CONFIG_MAX_VOICES
598    }
599    
600    void Options::setMaxStreams(int iMaxStreams) {
601    #ifdef CONFIG_MAX_VOICES
602            if (iMaxStreams < 0) return;
603    
604            MainForm *pMainForm = MainForm::getInstance();
605            if (!pMainForm || !pMainForm->client())
606                    return;
607    
608            lscp_status_t result =
609                    ::lscp_set_streams(pMainForm->client(), iMaxStreams);
610    
611            if (result != LSCP_OK) {
612                    pMainForm->appendMessagesClient("lscp_set_streams");
613                    return;
614            }
615    
616            this->iMaxStreams = iMaxStreams;
617    #endif // CONFIG_MAX_VOICES
618    }
619    
620    void Options::sendFineTuningSettings() {
621            setMaxVoices(iMaxVoices);
622            setMaxStreams(iMaxStreams);
623    
624            MainForm *pMainForm = MainForm::getInstance();
625            if (!pMainForm || !pMainForm->client())
626                    return;
627    
628            pMainForm->appendMessages(QObject::tr("Sent fine tuning settings."));
629  }  }
630    
631  } // namespace QSampler  } // namespace QSampler
632    
633    
634  // end of qsamplerOptions.cpp  // end of qsamplerOptions.cpp
635    

Legend:
Removed from v.1643  
changed lines
  Added in v.3855

  ViewVC Help
Powered by ViewVC