Display cmd. arguments if SHIFT is pressed

This commit is contained in:
Klaus Basan
2019-01-25 20:20:16 +01:00
committed by Mat Sutcliffe
parent 998f0344fa
commit a32eadee6a
2 changed files with 61 additions and 14 deletions

View File

@@ -22,6 +22,7 @@
#include "blackmisc/icons.h" #include "blackmisc/icons.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
#include "blackmisc/loghandler.h" #include "blackmisc/loghandler.h"
#include <QMessageBox>
#include <QPixmap> #include <QPixmap>
#include <QBitmap> #include <QBitmap>
#include <QTimer> #include <QTimer>
@@ -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(); this->saveSetup();
QStringList args = ui->comp_DBusSelector->getDBusCmdLineArgs(); QStringList args = ui->comp_DBusSelector->getDBusCmdLineArgs();
if (ui->rb_SwiftCoreAudioOnCore->isChecked()) if (ui->rb_SwiftCoreAudioOnCore->isChecked())
@@ -247,13 +248,14 @@ void CSwiftLauncher::startSwiftCore()
m_executableArgs = sGui->argumentsJoined(args); m_executableArgs = sGui->argumentsJoined(args);
m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftCoreExecutableName()); m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftCoreExecutableName());
this->startDetached(); return true;
} }
void CSwiftLauncher::setSwiftDataExecutable() bool CSwiftLauncher::setSwiftDataExecutable()
{ {
m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftDataExecutableName()); m_executable = CDirectoryUtils::executableFilePath(CBuildConfig::swiftDataExecutableName());
m_executableArgs = sGui->argumentsJoined({}, CNetworkVatlib::vatlibArguments()); m_executableArgs = sGui->argumentsJoined({}, CNetworkVatlib::vatlibArguments());
return true;
} }
bool CSwiftLauncher::setSwiftGuiExecutable() bool CSwiftLauncher::setSwiftGuiExecutable()
@@ -277,8 +279,8 @@ bool CSwiftLauncher::setSwiftGuiExecutable()
if (!CSwiftLauncher::canConnectSwiftOnDBusServer(dBus, msg)) if (!CSwiftLauncher::canConnectSwiftOnDBusServer(dBus, msg))
{ {
const CStatusMessage m(this, CStatusMessage::SeverityError, const CStatusMessage m(this, CStatusMessage::SeverityError,
"DBus server for '" + dBus + "' can not be connected.\n\n" + "DBus server for '" + dBus + "' can not be connected.\n" +
"Likely the core is not running or is not reachable.\n\n" + "Likely the core is not running or is not reachable.\n" +
"Details: " + msg, true); "Details: " + msg, true);
this->showStatusMessage(m); this->showStatusMessage(m);
return false; return false;
@@ -368,26 +370,55 @@ void CSwiftLauncher::startButtonPressed()
const qreal scaleFactor = ui->comp_Scale->getScaleFactor(); const qreal scaleFactor = ui->comp_Scale->getScaleFactor();
CGuiApplication::highDpiScreenSupport(scaleFactor); CGuiApplication::highDpiScreenSupport(scaleFactor);
const Qt::KeyboardModifiers km = QGuiApplication::queryKeyboardModifiers();
const bool shift = km.testFlag(Qt::ShiftModifier);
if (sender == ui->tb_SwiftGui) if (sender == ui->tb_SwiftGui)
{ {
if (this->setSwiftGuiExecutable()) if (this->setSwiftGuiExecutable())
{ {
this->accept(); if (shift)
{
this->popupExecutableArgs();
}
else
{
this->accept();
}
} }
} }
else if (sender == ui->tb_SwiftMappingTool) else if (sender == ui->tb_SwiftMappingTool)
{ {
ui->tb_SwiftMappingTool->setEnabled(false); ui->tb_SwiftMappingTool->setEnabled(false);
m_startMappingToolWaitCycles = 2; m_startMappingToolWaitCycles = 2;
this->setSwiftDataExecutable(); if (this->setSwiftDataExecutable())
this->accept(); {
if (shift)
{
this->popupExecutableArgs();
}
else
{
this->accept();
}
}
} }
else if (sender == ui->tb_SwiftCore) else if (sender == ui->tb_SwiftCore)
{ {
if (this->isStandaloneGuiSelected()) { ui->rb_SwiftCoreAudioOnGui->setChecked(true); } if (this->isStandaloneGuiSelected()) { ui->rb_SwiftCoreAudioOnGui->setChecked(true); }
ui->tb_SwiftCore->setEnabled(false); ui->tb_SwiftCore->setEnabled(false);
m_startCoreWaitCycles = 2; m_startCoreWaitCycles = 2;
this->startSwiftCore(); if (this->setSwiftCoreExecutable())
{
if (shift)
{
this->popupExecutableArgs();
}
else
{
this->startDetached();
}
}
} }
else if (sender == ui->tb_Database) else if (sender == ui->tb_Database)
{ {
@@ -408,6 +439,11 @@ void CSwiftLauncher::showStatusMessage(const CStatusMessage &msg)
ui->fr_SwiftLauncherMain->showOverlayMessage(msg, 5000); ui->fr_SwiftLauncherMain->showOverlayMessage(msg, 5000);
} }
void CSwiftLauncher::showStatusMessage(const QString &htmlMsg)
{
ui->fr_SwiftLauncherMain->showOverlayMessage(htmlMsg, 5000);
}
void CSwiftLauncher::appendLogMessage(const CStatusMessage &message) void CSwiftLauncher::appendLogMessage(const CStatusMessage &message)
{ {
ui->comp_SwiftLauncherLog->appendStatusMessageToList(message); ui->comp_SwiftLauncherLog->appendStatusMessageToList(message);
@@ -486,3 +522,8 @@ void CSwiftLauncher::onCoreModeReleased()
{ {
ui->comp_DBusSelector->setEnabled(!ui->rb_SwiftStandalone->isChecked()); ui->comp_DBusSelector->setEnabled(!ui->rb_SwiftStandalone->isChecked());
} }
void CSwiftLauncher::popupExecutableArgs()
{
QMessageBox::information(this, "Command line", this->getCmdLine());
}

View File

@@ -58,7 +58,7 @@ public:
explicit CSwiftLauncher(QWidget *parent = nullptr); explicit CSwiftLauncher(QWidget *parent = nullptr);
//! Destructor //! Destructor
virtual ~CSwiftLauncher(); virtual ~CSwiftLauncher() override;
//! Executable (to be started) //! Executable (to be started)
const QString &getExecutable() const { return m_executable; } const QString &getExecutable() const { return m_executable; }
@@ -118,11 +118,11 @@ private:
//! \sa CSwiftLauncher::displayLatestNews //! \sa CSwiftLauncher::displayLatestNews
void loadLatestNews(); void loadLatestNews();
//! Start the core //! Executaable for core
void startSwiftCore(); bool setSwiftCoreExecutable();
//! Set executable for swift data //! Set executable for swift data
void setSwiftDataExecutable(); bool setSwiftDataExecutable();
//! Set executable for swift GUI //! Set executable for swift GUI
bool setSwiftGuiExecutable(); bool setSwiftGuiExecutable();
@@ -157,6 +157,9 @@ private:
//! Display status message as overlay //! Display status message as overlay
void showStatusMessage(const BlackMisc::CStatusMessage &msg); void showStatusMessage(const BlackMisc::CStatusMessage &msg);
//! Display status message as overlay
void showStatusMessage(const QString &htmlMsg);
//! Append status message //! Append status message
void appendLogMessage(const BlackMisc::CStatusMessage &message); void appendLogMessage(const BlackMisc::CStatusMessage &message);
@@ -184,6 +187,9 @@ private:
//! Core mode has been changed //! Core mode has been changed
void onCoreModeReleased(); void onCoreModeReleased();
//! Display a popup with the cmd line args
void popupExecutableArgs();
//! Command line //! Command line
static QString toCmdLine(const QString &exe, const QStringList &exeArgs); static QString toCmdLine(const QString &exe, const QStringList &exeArgs);
}; };