mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
fix: Remove help/version message dialogs for Gui application
These methods did not quit the application and hence the application exits with code -1. Further, when calling swift with a commandline argument, the user might expect to get a commandline output and not a GUI popup.
This commit is contained in:
@@ -1459,9 +1459,10 @@ namespace BlackCore
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
void CApplication::cmdLineVersionMessage() const
|
||||
void CApplication::cmdLineVersionMessage()
|
||||
{
|
||||
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion()));
|
||||
m_parser.showVersion(); // terminates
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
QStringList CApplication::argumentsJoined(const QStringList &newArguments, const QStringList &removeArguments) const
|
||||
|
||||
@@ -595,12 +595,6 @@ namespace BlackCore
|
||||
//! Init class, allows to init from BlackGui::CGuiApplication as well (pseudo virtual)
|
||||
void init(bool withMetadata);
|
||||
|
||||
//! Display help message
|
||||
virtual void cmdLineHelpMessage();
|
||||
|
||||
//! Display version message
|
||||
virtual void cmdLineVersionMessage() const;
|
||||
|
||||
//! Is the command line option represented in the given arguments?
|
||||
static int indexOfCommandLineOption(const QCommandLineOption &option, const QStringList &args = CApplication::arguments());
|
||||
|
||||
@@ -660,6 +654,12 @@ namespace BlackCore
|
||||
//! Read the setup
|
||||
BlackMisc::CStatusMessageList loadSetup();
|
||||
|
||||
//! Display help message
|
||||
void cmdLineHelpMessage();
|
||||
|
||||
//! Display version message
|
||||
void cmdLineVersionMessage();
|
||||
|
||||
//! Problem with network access manager
|
||||
void onChangedNetworkAccessibility(QNetworkAccessManager::NetworkAccessibility accessible);
|
||||
|
||||
|
||||
@@ -469,52 +469,6 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
QString CGuiApplication::beautifyHelpMessage(const QString &helpText)
|
||||
{
|
||||
// just formatting Qt help message into HTML table
|
||||
if (helpText.isEmpty()) { return {}; }
|
||||
const QStringList lines(helpText.split('\n'));
|
||||
QString html;
|
||||
bool tableMode = false;
|
||||
bool pendingTr = false;
|
||||
for (const QString &l : lines)
|
||||
{
|
||||
QString lt(l.trimmed());
|
||||
if (!tableMode && lt.startsWith("-"))
|
||||
{
|
||||
tableMode = true;
|
||||
html += "<table>\n";
|
||||
}
|
||||
if (!tableMode)
|
||||
{
|
||||
html += l.toHtmlEscaped();
|
||||
html += "<br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
// in table mode
|
||||
if (lt.startsWith("-"))
|
||||
{
|
||||
if (pendingTr)
|
||||
{
|
||||
html += "</td></tr>\n";
|
||||
}
|
||||
html += "<tr><td>";
|
||||
thread_local const QRegularExpression reg("[ ]{2,}");
|
||||
html += lt.replace(reg, "</td><td>");
|
||||
pendingTr = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
html += " ";
|
||||
html += l.simplified().toHtmlEscaped();
|
||||
}
|
||||
}
|
||||
}
|
||||
html += "</table>\n";
|
||||
return html;
|
||||
}
|
||||
|
||||
double CGuiApplication::parseScaleFactor(int argc, char *argv[])
|
||||
{
|
||||
for (int i = 1; i < argc; ++i)
|
||||
@@ -1098,35 +1052,6 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
void CGuiApplication::cmdLineHelpMessage()
|
||||
{
|
||||
if (CBuildConfig::isRunningOnWindowsNtPlatform())
|
||||
{
|
||||
const QString helpText(CGuiApplication::beautifyHelpMessage(m_parser.helpText()));
|
||||
QMessageBox::information(nullptr, QGuiApplication::applicationDisplayName(),
|
||||
"<html><head/><body>" + helpText + "</body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
CApplication::cmdLineHelpMessage();
|
||||
}
|
||||
}
|
||||
|
||||
void CGuiApplication::cmdLineVersionMessage() const
|
||||
{
|
||||
if (CBuildConfig::isRunningOnWindowsNtPlatform())
|
||||
{
|
||||
QMessageBox::information(nullptr,
|
||||
QGuiApplication::applicationDisplayName(),
|
||||
QGuiApplication::applicationDisplayName() + ' ' +
|
||||
QCoreApplication::applicationVersion());
|
||||
}
|
||||
else
|
||||
{
|
||||
CApplication::cmdLineVersionMessage();
|
||||
}
|
||||
}
|
||||
|
||||
bool CGuiApplication::parsingHookIn()
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -309,12 +309,6 @@ namespace BlackGui
|
||||
void alwaysOnTop(bool onTop);
|
||||
|
||||
protected:
|
||||
//! @{
|
||||
//! print messages generated during parsing / cmd handling
|
||||
virtual void cmdLineHelpMessage() override;
|
||||
virtual void cmdLineVersionMessage() const override;
|
||||
//! @}
|
||||
|
||||
//! Handle parsing of special GUI cmd arguments
|
||||
virtual bool parsingHookIn() override;
|
||||
|
||||
@@ -354,9 +348,6 @@ namespace BlackGui
|
||||
BlackMisc::CSettingReadOnly<Settings::TGeneralGui> m_guiSettings { this, &CGuiApplication::settingsChanged };
|
||||
BlackMisc::CSettingReadOnly<Settings::TUpdateNotificationSettings> m_updateSetting { this }; //!< update notification settings
|
||||
|
||||
//! Qt help message to formatted HTML
|
||||
static QString beautifyHelpMessage(const QString &helpText);
|
||||
|
||||
//! Reload widget style from settings
|
||||
void settingsChanged();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user