mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #485, finetuning the HTML cmd line help
Turn Qt message into HTML table
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1eb65a873c
commit
8e6c4ad35d
@@ -121,13 +121,70 @@ namespace BlackGui
|
|||||||
CApplication::exit(retcode);
|
CApplication::exit(retcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGuiApplication::ps_startupCompleted()
|
||||||
|
{
|
||||||
|
CApplication::ps_startupCompleted();
|
||||||
|
if (this->m_splashScreen)
|
||||||
|
{
|
||||||
|
this->m_splashScreen->close();
|
||||||
|
this->m_splashScreen.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
html += "<br>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// in table mode
|
||||||
|
if (lt.startsWith("-"))
|
||||||
|
{
|
||||||
|
if (pendingTr)
|
||||||
|
{
|
||||||
|
html += "</td></tr>\n";
|
||||||
|
}
|
||||||
|
html += "<tr><td>";
|
||||||
|
static const QRegExp reg("[ ]{2,}");
|
||||||
|
html += lt.replace(reg, "</td><td>");
|
||||||
|
pendingTr = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
html += " ";
|
||||||
|
html += l.simplified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html += "</table>\n";
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
void CGuiApplication::cmdLineErrorMessage(const QString &errorMessage) const
|
void CGuiApplication::cmdLineErrorMessage(const QString &errorMessage) const
|
||||||
{
|
{
|
||||||
if (CProject::isRunningOnWindowsNtPlatform())
|
if (CProject::isRunningOnWindowsNtPlatform())
|
||||||
{
|
{
|
||||||
|
const QString helpText(beautifyHelpMessageImpl(this->m_parser.helpText()));
|
||||||
QMessageBox::warning(nullptr,
|
QMessageBox::warning(nullptr,
|
||||||
QGuiApplication::applicationDisplayName(),
|
QGuiApplication::applicationDisplayName(),
|
||||||
"<html><head/><body><h2>" + errorMessage + "</h2><pre>" + this->m_parser.helpText() + "</pre></body></html>");
|
"<html><head/><body><h2>" + errorMessage + "</h2>" + helpText + "</body></html>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ namespace BlackGui
|
|||||||
*
|
*
|
||||||
* - style sheet handling
|
* - style sheet handling
|
||||||
* - standard menus
|
* - standard menus
|
||||||
|
* - splash screen support
|
||||||
*
|
*
|
||||||
* Simple example
|
* Simple example
|
||||||
* \snippet swiftlauncher/main.cpp CSwiftGuiStdApplication
|
* \snippet swiftlauncher/main.cpp CSwiftGuiStdApplication
|
||||||
@@ -137,6 +138,9 @@ namespace BlackGui
|
|||||||
QPixmap m_windowIcon;
|
QPixmap m_windowIcon;
|
||||||
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
|
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
|
||||||
QCommandLineOption m_cmdWindowMode { "empty" }; //!< window mode (flags: frameless ...)
|
QCommandLineOption m_cmdWindowMode { "empty" }; //!< window mode (flags: frameless ...)
|
||||||
|
|
||||||
|
//! Qt help message to formatted HTML
|
||||||
|
static QString beautifyHelpMessage(const QString &helpText);
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user