/[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 3067 by capela, Mon Jan 2 15:31:47 2017 UTC revision 3837 by capela, Tue Dec 1 17:46:41 2020 UTC
# Line 1  Line 1 
1  // qsamplerOptions.cpp  // qsamplerOptions.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2017, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2020, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007,2008,2015 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
# Line 27  Line 27 
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
# Line 114  void Options::loadOptions (void) Line 120  void Options::loadOptions (void)
120  #endif  #endif
121          m_settings.endGroup();          m_settings.endGroup();
122    
123            // Load custom options...
124            m_settings.beginGroup("/Custom");
125            sCustomColorTheme = m_settings.value("/ColorTheme").toString();
126            sCustomStyleTheme = m_settings.value("/StyleTheme").toString();
127            m_settings.endGroup();
128    
129          // And go into view options group.          // And go into view options group.
130          m_settings.beginGroup("/View");          m_settings.beginGroup("/View");
131          bMenubar     = m_settings.value("/Menubar", true).toBool();          bMenubar     = m_settings.value("/Menubar", true).toBool();
# Line 206  void Options::saveOptions (void) Line 218  void Options::saveOptions (void)
218          m_settings.setValue("/InstrumentNames", bInstrumentNames);          m_settings.setValue("/InstrumentNames", bInstrumentNames);
219          m_settings.endGroup();          m_settings.endGroup();
220    
221            // Save custom options...
222            m_settings.beginGroup("/Custom");
223            m_settings.setValue("/ColorTheme", sCustomColorTheme);
224            m_settings.setValue("/StyleTheme", sCustomStyleTheme);
225            m_settings.endGroup();
226    
227          // View options group.          // View options group.
228          m_settings.beginGroup("/View");          m_settings.beginGroup("/View");
229          m_settings.setValue("/Menubar", bMenubar);          m_settings.setValue("/Menubar", bMenubar);
# Line 286  bool Options::parse_args ( const QString Line 304  bool Options::parse_args ( const QString
304  {  {
305          QTextStream out(stderr);          QTextStream out(stderr);
306          const QString sEol = "\n\n";          const QString sEol = "\n\n";
         int iCmdArgs = 0;  
307          const int argc = args.count();          const int argc = args.count();
308            int iCmdArgs = 0;
309    
310          for (int i = 1; i < argc; i++) {          for (int i = 1; i < argc; ++i) {
311    
312                  if (iCmdArgs > 0) {                  if (iCmdArgs > 0) {
313                          sSessionFile += " ";                          sSessionFile += " ";
314                          sSessionFile += args.at(i);                          sSessionFile += args.at(i);
315                          iCmdArgs++;                          ++iCmdArgs;
316                          continue;                          continue;
317                  }                  }
318    
319                  QString sArg = args.at(i);                  QString sArg = args.at(i);
320                  QString sVal = QString::null;                  QString sVal;
321                  const int iEqual = sArg.indexOf("=");                  const int iEqual = sArg.indexOf("=");
322                  if (iEqual >= 0) {                  if (iEqual >= 0) {
323                          sVal = sArg.right(sArg.length() - iEqual - 1);                          sVal = sArg.right(sArg.length() - iEqual - 1);
# Line 321  bool Options::parse_args ( const QString Line 339  bool Options::parse_args ( const QString
339                          }                          }
340                          sServerHost = sVal;                          sServerHost = sVal;
341                          if (iEqual < 0)                          if (iEqual < 0)
342                                  i++;                                  ++i;
343                  }                  }
344                  else if (sArg == "-p" || sArg == "--port") {                  else if (sArg == "-p" || sArg == "--port") {
345                          if (sVal.isNull()) {                          if (sVal.isNull()) {
# Line 330  bool Options::parse_args ( const QString Line 348  bool Options::parse_args ( const QString
348                          }                          }
349                          iServerPort = sVal.toInt();                          iServerPort = sVal.toInt();
350                          if (iEqual < 0)                          if (iEqual < 0)
351                                  i++;                                  ++i;
352                  }                  }
353                  else if (sArg == "-?" || sArg == "--help") {                  else if (sArg == "-?" || sArg == "--help") {
354                          print_usage(args.at(0));                          print_usage(args.at(0));
355                          return false;                          return false;
356                  }                  }
357                  else if (sArg == "-v" || sArg == "--version") {                  else if (sArg == "-v" || sArg == "--version") {
358                          out << QString("Qt: %1\n")                          out << QString("Qt: %1").arg(qVersion());
359                                  .arg(qVersion());                  #if defined(QT_STATIC)
360                            out << "-static";
361                    #endif
362                            out << '\n';
363                          out << QString("%1: %2\n")                          out << QString("%1: %2\n")
364                                  .arg(QSAMPLER_TITLE)                                  .arg(QSAMPLER_TITLE)
365                                  .arg(CONFIG_BUILD_VERSION);                                  .arg(CONFIG_BUILD_VERSION);
# Line 356  bool Options::parse_args ( const QString Line 377  bool Options::parse_args ( const QString
377                          // If we don't have one by now,                          // If we don't have one by now,
378                          // this will be the startup sesion file...                          // this will be the startup sesion file...
379                          sSessionFile += sArg;                          sSessionFile += sArg;
380                          iCmdArgs++;                          ++iCmdArgs;
381                  }                  }
382          }          }
383    
# Line 374  void Options::loadWidgetGeometry ( QWidg Line 395  void Options::loadWidgetGeometry ( QWidg
395          if (pWidget) {          if (pWidget) {
396          //      if (bVisible) pWidget->show(); -- force initial exposure?          //      if (bVisible) pWidget->show(); -- force initial exposure?
397                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
398          #if QT_VERSION >= 0x050000          #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
399                  const QByteArray& geometry                  const QByteArray& geometry
400                          = m_settings.value("/geometry").toByteArray();                          = m_settings.value("/geometry").toByteArray();
401                  if (!geometry.isEmpty())                  if (geometry.isEmpty()) {
402                            QWidget *pParent = pWidget->parentWidget();
403                            if (pParent)
404                                    pParent = pParent->window();
405                    #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
406                            if (pParent == nullptr)
407                                    pParent = QApplication::desktop();
408                    #endif
409                            if (pParent) {
410                                    QRect wrect(pWidget->geometry());
411                                    wrect.moveCenter(pParent->geometry().center());
412                                    pWidget->move(wrect.topLeft());
413                            }
414                    } else {
415                          pWidget->restoreGeometry(geometry);                          pWidget->restoreGeometry(geometry);
416                    }
417          #else//--LOAD_OLD_GEOMETRY          #else//--LOAD_OLD_GEOMETRY
418                  QPoint wpos;                  QPoint wpos;
419                  QSize  wsize;                  QSize  wsize;
# Line 411  void Options::saveWidgetGeometry ( QWidg Line 446  void Options::saveWidgetGeometry ( QWidg
446          // only save the form geometry while its up and visible)          // only save the form geometry while its up and visible)
447          if (pWidget) {          if (pWidget) {
448                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
449          #if QT_VERSION >= 0x050000          #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
450                  m_settings.setValue("/geometry", pWidget->saveGeometry());                  m_settings.setValue("/geometry", pWidget->saveGeometry());
451          #else//--SAVE_OLD_GEOMETRY          #else//--SAVE_OLD_GEOMETRY
452                  const QPoint& wpos  = pWidget->pos();                  const QPoint& wpos  = pWidget->pos();

Legend:
Removed from v.3067  
changed lines
  Added in v.3837

  ViewVC Help
Powered by ViewVC