From a32eadee6a8c11b54a4056b9c6305b261815ebe6 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 25 Jan 2019 20:20:16 +0100 Subject: [PATCH] Display cmd. arguments if SHIFT is pressed --- src/swiftlauncher/swiftlauncher.cpp | 61 ++++++++++++++++++++++++----- src/swiftlauncher/swiftlauncher.h | 14 +++++-- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index 43d36f24d..fabd68b6c 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -22,6 +22,7 @@ #include "blackmisc/icons.h" #include "blackmisc/logmessage.h" #include "blackmisc/loghandler.h" +#include #include #include #include @@ -235,9 +236,9 @@ void CSwiftLauncher::setHeaderInfo(const CArtifact &latestArtifact) } } -void CSwiftLauncher::startSwiftCore() +bool CSwiftLauncher::setSwiftCoreExecutable() { - if (!sGui || sGui->isShuttingDown()) { return; } + if (!sGui || sGui->isShuttingDown()) { return false; } this->saveSetup(); QStringList args = ui->comp_DBusSelector->getDBusCmdLineArgs(); if (ui->rb_SwiftCoreAudioOnCore->isChecked()) @@ -247,13 +248,14 @@ void CSwiftLauncher::startSwiftCore() m_executableArgs = sGui->argumentsJoined(args); m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftCoreExecutableName()); - this->startDetached(); + return true; } -void CSwiftLauncher::setSwiftDataExecutable() +bool CSwiftLauncher::setSwiftDataExecutable() { m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftDataExecutableName()); m_executableArgs = sGui->argumentsJoined({}, CNetworkVatlib::vatlibArguments()); + return true; } bool CSwiftLauncher::setSwiftGuiExecutable() @@ -277,8 +279,8 @@ bool CSwiftLauncher::setSwiftGuiExecutable() if (!CSwiftLauncher::canConnectSwiftOnDBusServer(dBus, msg)) { const CStatusMessage m(this, CStatusMessage::SeverityError, - "DBus server for '" + dBus + "' can not be connected.\n\n" + - "Likely the core is not running or is not reachable.\n\n" + + "DBus server for '" + dBus + "' can not be connected.\n" + + "Likely the core is not running or is not reachable.\n" + "Details: " + msg, true); this->showStatusMessage(m); return false; @@ -368,26 +370,55 @@ void CSwiftLauncher::startButtonPressed() const qreal scaleFactor = ui->comp_Scale->getScaleFactor(); CGuiApplication::highDpiScreenSupport(scaleFactor); + const Qt::KeyboardModifiers km = QGuiApplication::queryKeyboardModifiers(); + const bool shift = km.testFlag(Qt::ShiftModifier); + if (sender == ui->tb_SwiftGui) { if (this->setSwiftGuiExecutable()) { - this->accept(); + if (shift) + { + this->popupExecutableArgs(); + } + else + { + this->accept(); + } } } else if (sender == ui->tb_SwiftMappingTool) { ui->tb_SwiftMappingTool->setEnabled(false); m_startMappingToolWaitCycles = 2; - this->setSwiftDataExecutable(); - this->accept(); + if (this->setSwiftDataExecutable()) + { + if (shift) + { + this->popupExecutableArgs(); + } + else + { + this->accept(); + } + } } else if (sender == ui->tb_SwiftCore) { if (this->isStandaloneGuiSelected()) { ui->rb_SwiftCoreAudioOnGui->setChecked(true); } ui->tb_SwiftCore->setEnabled(false); m_startCoreWaitCycles = 2; - this->startSwiftCore(); + if (this->setSwiftCoreExecutable()) + { + if (shift) + { + this->popupExecutableArgs(); + } + else + { + this->startDetached(); + } + } } else if (sender == ui->tb_Database) { @@ -408,6 +439,11 @@ void CSwiftLauncher::showStatusMessage(const CStatusMessage &msg) ui->fr_SwiftLauncherMain->showOverlayMessage(msg, 5000); } +void CSwiftLauncher::showStatusMessage(const QString &htmlMsg) +{ + ui->fr_SwiftLauncherMain->showOverlayMessage(htmlMsg, 5000); +} + void CSwiftLauncher::appendLogMessage(const CStatusMessage &message) { ui->comp_SwiftLauncherLog->appendStatusMessageToList(message); @@ -486,3 +522,8 @@ void CSwiftLauncher::onCoreModeReleased() { ui->comp_DBusSelector->setEnabled(!ui->rb_SwiftStandalone->isChecked()); } + +void CSwiftLauncher::popupExecutableArgs() +{ + QMessageBox::information(this, "Command line", this->getCmdLine()); +} diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index e2b9741df..d2089990e 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -58,7 +58,7 @@ public: explicit CSwiftLauncher(QWidget *parent = nullptr); //! Destructor - virtual ~CSwiftLauncher(); + virtual ~CSwiftLauncher() override; //! Executable (to be started) const QString &getExecutable() const { return m_executable; } @@ -118,11 +118,11 @@ private: //! \sa CSwiftLauncher::displayLatestNews void loadLatestNews(); - //! Start the core - void startSwiftCore(); + //! Executaable for core + bool setSwiftCoreExecutable(); //! Set executable for swift data - void setSwiftDataExecutable(); + bool setSwiftDataExecutable(); //! Set executable for swift GUI bool setSwiftGuiExecutable(); @@ -157,6 +157,9 @@ private: //! Display status message as overlay void showStatusMessage(const BlackMisc::CStatusMessage &msg); + //! Display status message as overlay + void showStatusMessage(const QString &htmlMsg); + //! Append status message void appendLogMessage(const BlackMisc::CStatusMessage &message); @@ -184,6 +187,9 @@ private: //! Core mode has been changed void onCoreModeReleased(); + //! Display a popup with the cmd line args + void popupExecutableArgs(); + //! Command line static QString toCmdLine(const QString &exe, const QStringList &exeArgs); };