--- qsampler/trunk/src/qsamplerOptions.cpp 2015/03/06 23:18:51 2723 +++ qsampler/trunk/src/qsamplerOptions.cpp 2019/08/21 17:10:11 3558 @@ -1,8 +1,8 @@ // qsamplerOptions.cpp // /**************************************************************************** - Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela. All rights reserved. - Copyright (C) 2007,2015 Christian Schoenebeck + Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2007,2008,2015 Christian Schoenebeck This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,6 +27,9 @@ #include #include +#include +#include + #include #ifdef CONFIG_LIBGIG @@ -162,7 +165,7 @@ { // Make program version available in the future. m_settings.beginGroup("/Program"); - m_settings.setValue("/Version", QSAMPLER_VERSION); + m_settings.setValue("/Version", CONFIG_BUILD_VERSION); m_settings.endGroup(); // And go into general options group. @@ -286,20 +289,20 @@ { QTextStream out(stderr); const QString sEol = "\n\n"; - int iCmdArgs = 0; const int argc = args.count(); + int iCmdArgs = 0; - for (int i = 1; i < argc; i++) { + for (int i = 1; i < argc; ++i) { if (iCmdArgs > 0) { sSessionFile += " "; sSessionFile += args.at(i); - iCmdArgs++; + ++iCmdArgs; continue; } QString sArg = args.at(i); - QString sVal = QString::null; + QString sVal; const int iEqual = sArg.indexOf("="); if (iEqual >= 0) { sVal = sArg.right(sArg.length() - iEqual - 1); @@ -321,7 +324,7 @@ } sServerHost = sVal; if (iEqual < 0) - i++; + ++i; } else if (sArg == "-p" || sArg == "--port") { if (sVal.isNull()) { @@ -330,14 +333,18 @@ } iServerPort = sVal.toInt(); if (iEqual < 0) - i++; + ++i; } else if (sArg == "-?" || sArg == "--help") { print_usage(args.at(0)); return false; } else if (sArg == "-v" || sArg == "--version") { - out << QObject::tr("Qt: %1\n").arg(qVersion()); + out << QString("Qt: %1\n") + .arg(qVersion()); + out << QString("%1: %2\n") + .arg(QSAMPLER_TITLE) + .arg(CONFIG_BUILD_VERSION); #ifdef CONFIG_LIBGIG out << QString("%1: %2\n") .arg(gig::libraryName().c_str()) @@ -346,14 +353,13 @@ out << QString("%1: %2\n") .arg(::lscp_client_package()) .arg(::lscp_client_version()); - out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); return false; } else { // If we don't have one by now, // this will be the startup sesion file... sSessionFile += sArg; - iCmdArgs++; + ++iCmdArgs; } } @@ -369,25 +375,46 @@ { // Try to restore old form window positioning. if (pWidget) { + // if (bVisible) pWidget->show(); -- force initial exposure? + m_settings.beginGroup("/Geometry/" + pWidget->objectName()); + #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + const QByteArray& geometry + = m_settings.value("/geometry").toByteArray(); + if (geometry.isEmpty()) { + QWidget *pParent = pWidget->parentWidget(); + if (pParent) + pParent = pParent->window(); + if (pParent == nullptr) + pParent = QApplication::desktop(); + if (pParent) { + QRect wrect(pWidget->geometry()); + wrect.moveCenter(pParent->geometry().center()); + pWidget->move(wrect.topLeft()); + } + } else { + pWidget->restoreGeometry(geometry); + } + #else//--LOAD_OLD_GEOMETRY QPoint wpos; QSize wsize; - m_settings.beginGroup("/Geometry/" + pWidget->objectName()); wpos.setX(m_settings.value("/x", -1).toInt()); wpos.setY(m_settings.value("/y", -1).toInt()); wsize.setWidth(m_settings.value("/width", -1).toInt()); wsize.setHeight(m_settings.value("/height", -1).toInt()); - if (!bVisible) bVisible = m_settings.value("/visible", false).toBool(); - m_settings.endGroup(); if (wpos.x() > 0 && wpos.y() > 0) pWidget->move(wpos); if (wsize.width() > 0 && wsize.height() > 0) pWidget->resize(wsize); + #endif // else - // pWidget->adjustSize(); + // pWidget->adjustSize(); + if (!bVisible) + bVisible = m_settings.value("/visible", false).toBool(); if (bVisible) pWidget->show(); - // else - // pWidget->hide(); + else + pWidget->hide(); + m_settings.endGroup(); } } @@ -399,13 +426,17 @@ // only save the form geometry while its up and visible) if (pWidget) { m_settings.beginGroup("/Geometry/" + pWidget->objectName()); + #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + m_settings.setValue("/geometry", pWidget->saveGeometry()); + #else//--SAVE_OLD_GEOMETRY const QPoint& wpos = pWidget->pos(); const QSize& wsize = pWidget->size(); - if (!bVisible) bVisible = pWidget->isVisible(); m_settings.setValue("/x", wpos.x()); m_settings.setValue("/y", wpos.y()); m_settings.setValue("/width", wsize.width()); m_settings.setValue("/height", wsize.height()); + #endif + if (!bVisible) bVisible = pWidget->isVisible(); m_settings.setValue("/visible", bVisible); m_settings.endGroup(); } @@ -574,3 +605,4 @@ // end of qsamplerOptions.cpp +