/[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 2723 by capela, Fri Mar 6 23:18:51 2015 UTC revision 3558 by capela, Wed Aug 21 17:10:11 2019 UTC
# Line 1  Line 1 
1  // qsamplerOptions.cpp  // qsamplerOptions.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007,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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 27  Line 27 
27  #include <QTextStream>  #include <QTextStream>
28  #include <QComboBox>  #include <QComboBox>
29    
30    #include <QApplication>
31    #include <QDesktopWidget>
32    
33  #include <lscp/client.h>  #include <lscp/client.h>
34    
35  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
# Line 162  void Options::saveOptions (void) Line 165  void Options::saveOptions (void)
165  {  {
166          // Make program version available in the future.          // Make program version available in the future.
167          m_settings.beginGroup("/Program");          m_settings.beginGroup("/Program");
168          m_settings.setValue("/Version", QSAMPLER_VERSION);          m_settings.setValue("/Version", CONFIG_BUILD_VERSION);
169          m_settings.endGroup();          m_settings.endGroup();
170    
171          // And go into general options group.          // And go into general options group.
# Line 286  bool Options::parse_args ( const QString Line 289  bool Options::parse_args ( const QString
289  {  {
290          QTextStream out(stderr);          QTextStream out(stderr);
291          const QString sEol = "\n\n";          const QString sEol = "\n\n";
         int iCmdArgs = 0;  
292          const int argc = args.count();          const int argc = args.count();
293            int iCmdArgs = 0;
294    
295          for (int i = 1; i < argc; i++) {          for (int i = 1; i < argc; ++i) {
296    
297                  if (iCmdArgs > 0) {                  if (iCmdArgs > 0) {
298                          sSessionFile += " ";                          sSessionFile += " ";
299                          sSessionFile += args.at(i);                          sSessionFile += args.at(i);
300                          iCmdArgs++;                          ++iCmdArgs;
301                          continue;                          continue;
302                  }                  }
303    
304                  QString sArg = args.at(i);                  QString sArg = args.at(i);
305                  QString sVal = QString::null;                  QString sVal;
306                  const int iEqual = sArg.indexOf("=");                  const int iEqual = sArg.indexOf("=");
307                  if (iEqual >= 0) {                  if (iEqual >= 0) {
308                          sVal = sArg.right(sArg.length() - iEqual - 1);                          sVal = sArg.right(sArg.length() - iEqual - 1);
# Line 321  bool Options::parse_args ( const QString Line 324  bool Options::parse_args ( const QString
324                          }                          }
325                          sServerHost = sVal;                          sServerHost = sVal;
326                          if (iEqual < 0)                          if (iEqual < 0)
327                                  i++;                                  ++i;
328                  }                  }
329                  else if (sArg == "-p" || sArg == "--port") {                  else if (sArg == "-p" || sArg == "--port") {
330                          if (sVal.isNull()) {                          if (sVal.isNull()) {
# Line 330  bool Options::parse_args ( const QString Line 333  bool Options::parse_args ( const QString
333                          }                          }
334                          iServerPort = sVal.toInt();                          iServerPort = sVal.toInt();
335                          if (iEqual < 0)                          if (iEqual < 0)
336                                  i++;                                  ++i;
337                  }                  }
338                  else if (sArg == "-?" || sArg == "--help") {                  else if (sArg == "-?" || sArg == "--help") {
339                          print_usage(args.at(0));                          print_usage(args.at(0));
340                          return false;                          return false;
341                  }                  }
342                  else if (sArg == "-v" || sArg == "--version") {                  else if (sArg == "-v" || sArg == "--version") {
343                          out << QObject::tr("Qt: %1\n").arg(qVersion());                          out << QString("Qt: %1\n")
344                                    .arg(qVersion());
345                            out << QString("%1: %2\n")
346                                    .arg(QSAMPLER_TITLE)
347                                    .arg(CONFIG_BUILD_VERSION);
348                  #ifdef CONFIG_LIBGIG                  #ifdef CONFIG_LIBGIG
349                          out << QString("%1: %2\n")                          out << QString("%1: %2\n")
350                                  .arg(gig::libraryName().c_str())                                  .arg(gig::libraryName().c_str())
# Line 346  bool Options::parse_args ( const QString Line 353  bool Options::parse_args ( const QString
353                          out << QString("%1: %2\n")                          out << QString("%1: %2\n")
354                                  .arg(::lscp_client_package())                                  .arg(::lscp_client_package())
355                                  .arg(::lscp_client_version());                                  .arg(::lscp_client_version());
                         out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION);  
356                          return false;                          return false;
357                  }                  }
358                  else {                  else {
359                          // If we don't have one by now,                          // If we don't have one by now,
360                          // this will be the startup sesion file...                          // this will be the startup sesion file...
361                          sSessionFile += sArg;                          sSessionFile += sArg;
362                          iCmdArgs++;                          ++iCmdArgs;
363                  }                  }
364          }          }
365    
# Line 369  void Options::loadWidgetGeometry ( QWidg Line 375  void Options::loadWidgetGeometry ( QWidg
375  {  {
376          // Try to restore old form window positioning.          // Try to restore old form window positioning.
377          if (pWidget) {          if (pWidget) {
378            //      if (bVisible) pWidget->show(); -- force initial exposure?
379                    m_settings.beginGroup("/Geometry/" + pWidget->objectName());
380            #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
381                    const QByteArray& geometry
382                            = m_settings.value("/geometry").toByteArray();
383                    if (geometry.isEmpty()) {
384                            QWidget *pParent = pWidget->parentWidget();
385                            if (pParent)
386                                    pParent = pParent->window();
387                            if (pParent == nullptr)
388                                    pParent = QApplication::desktop();
389                            if (pParent) {
390                                    QRect wrect(pWidget->geometry());
391                                    wrect.moveCenter(pParent->geometry().center());
392                                    pWidget->move(wrect.topLeft());
393                            }
394                    } else {
395                            pWidget->restoreGeometry(geometry);
396                    }
397            #else//--LOAD_OLD_GEOMETRY
398                  QPoint wpos;                  QPoint wpos;
399                  QSize  wsize;                  QSize  wsize;
                 m_settings.beginGroup("/Geometry/" + pWidget->objectName());  
400                  wpos.setX(m_settings.value("/x", -1).toInt());                  wpos.setX(m_settings.value("/x", -1).toInt());
401                  wpos.setY(m_settings.value("/y", -1).toInt());                  wpos.setY(m_settings.value("/y", -1).toInt());
402                  wsize.setWidth(m_settings.value("/width", -1).toInt());                  wsize.setWidth(m_settings.value("/width", -1).toInt());
403                  wsize.setHeight(m_settings.value("/height", -1).toInt());                  wsize.setHeight(m_settings.value("/height", -1).toInt());
                 if (!bVisible) bVisible = m_settings.value("/visible", false).toBool();  
                 m_settings.endGroup();  
404                  if (wpos.x() > 0 && wpos.y() > 0)                  if (wpos.x() > 0 && wpos.y() > 0)
405                          pWidget->move(wpos);                          pWidget->move(wpos);
406                  if (wsize.width() > 0 && wsize.height() > 0)                  if (wsize.width() > 0 && wsize.height() > 0)
407                          pWidget->resize(wsize);                          pWidget->resize(wsize);
408            #endif
409          //      else          //      else
410          //              pWidget->adjustSize();          //      pWidget->adjustSize();
411                    if (!bVisible)
412                            bVisible = m_settings.value("/visible", false).toBool();
413                  if (bVisible)                  if (bVisible)
414                          pWidget->show();                          pWidget->show();
415          //      else                  else
416          //              pWidget->hide();                          pWidget->hide();
417                    m_settings.endGroup();
418          }          }
419  }  }
420    
# Line 399  void Options::saveWidgetGeometry ( QWidg Line 426  void Options::saveWidgetGeometry ( QWidg
426          // only save the form geometry while its up and visible)          // only save the form geometry while its up and visible)
427          if (pWidget) {          if (pWidget) {
428                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());                  m_settings.beginGroup("/Geometry/" + pWidget->objectName());
429            #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
430                    m_settings.setValue("/geometry", pWidget->saveGeometry());
431            #else//--SAVE_OLD_GEOMETRY
432                  const QPoint& wpos  = pWidget->pos();                  const QPoint& wpos  = pWidget->pos();
433                  const QSize&  wsize = pWidget->size();                  const QSize&  wsize = pWidget->size();
                 if (!bVisible) bVisible = pWidget->isVisible();  
434                  m_settings.setValue("/x", wpos.x());                  m_settings.setValue("/x", wpos.x());
435                  m_settings.setValue("/y", wpos.y());                  m_settings.setValue("/y", wpos.y());
436                  m_settings.setValue("/width", wsize.width());                  m_settings.setValue("/width", wsize.width());
437                  m_settings.setValue("/height", wsize.height());                  m_settings.setValue("/height", wsize.height());
438            #endif
439                    if (!bVisible) bVisible = pWidget->isVisible();
440                  m_settings.setValue("/visible", bVisible);                  m_settings.setValue("/visible", bVisible);
441                  m_settings.endGroup();                  m_settings.endGroup();
442          }          }
# Line 574  void Options::sendFineTuningSettings() { Line 605  void Options::sendFineTuningSettings() {
605    
606    
607  // end of qsamplerOptions.cpp  // end of qsamplerOptions.cpp
608    

Legend:
Removed from v.2723  
changed lines
  Added in v.3558

  ViewVC Help
Powered by ViewVC