mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
refs #485, first version of a Gui/Core application class
Also specialized GUI application class for standard GUI
This commit is contained in:
committed by
Mathew Sutcliffe
parent
d9aac6427b
commit
158efe819a
@@ -69,39 +69,6 @@ namespace BlackGui
|
||||
return (mw && mw->isFrameless());
|
||||
}
|
||||
|
||||
void CGuiUtility::initSwiftGuiApplication(QApplication &a, const QString &applicationName, const QPixmap &icon)
|
||||
{
|
||||
CCoreFacade::registerMetadata(); // register metadata
|
||||
CCookieManager::instance(); // init cookie manager if ever needed
|
||||
|
||||
CLogHandler::instance()->install(); // make sure we have a log handler!
|
||||
|
||||
QApplication::setApplicationName(applicationName);
|
||||
QApplication::setApplicationVersion(CProject::version());
|
||||
QApplication::setWindowIcon(icon);
|
||||
|
||||
// Logging
|
||||
QString executableName = QFileInfo(QCoreApplication::applicationFilePath()).completeBaseName();
|
||||
QString category("swift." + executableName);
|
||||
|
||||
// Translations
|
||||
QFile file(":blackmisc/translations/blackmisc_i18n_de.qm");
|
||||
CLogMessage(category).debug() << (file.exists() ? "Found translations in resources" : "No translations in resources");
|
||||
QTranslator translator;
|
||||
if (translator.load("blackmisc_i18n_de", ":blackmisc/translations/"))
|
||||
{
|
||||
CLogMessage(category).debug() << "Translator loaded";
|
||||
}
|
||||
|
||||
// File logger
|
||||
static const QString logPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/org.swift-project/logs";
|
||||
CFileLogger *fileLogger = new CFileLogger(executableName, logPath, &a);
|
||||
fileLogger->changeLogPattern(CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityDebug));
|
||||
|
||||
// GUI icon
|
||||
a.installTranslator(&translator);
|
||||
}
|
||||
|
||||
bool CGuiUtility::lenientTitleComparison(const QString &title, const QString &comparison)
|
||||
{
|
||||
if (title == comparison) { return true; }
|
||||
@@ -274,34 +241,4 @@ namespace BlackGui
|
||||
// then finally
|
||||
delete layout;
|
||||
}
|
||||
|
||||
void CGuiUtility::commandLineErrorMessage(const QString &errorMessage, const QCommandLineParser &parser)
|
||||
{
|
||||
# ifdef Q_OS_WIN
|
||||
QMessageBox::warning(nullptr, QGuiApplication::applicationDisplayName(), "<html><head/><body><h2>" + errorMessage + "</h2><pre>" + parser.helpText() + "</pre></body></html>");
|
||||
# else
|
||||
fputs(qPrintable(errorMessage), stderr);
|
||||
fputs("\n\n", stderr);
|
||||
fputs(qPrintable(parser.helpText()), stderr);
|
||||
# endif
|
||||
}
|
||||
|
||||
void CGuiUtility::commandLineVersionRequested()
|
||||
{
|
||||
# ifdef Q_OS_WIN
|
||||
QMessageBox::information(nullptr, QGuiApplication::applicationDisplayName(), QGuiApplication::applicationDisplayName() + ' ' + QCoreApplication::applicationVersion());
|
||||
# else
|
||||
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion()));
|
||||
# endif
|
||||
}
|
||||
|
||||
void CGuiUtility::commandLineHelpRequested(QCommandLineParser &parser)
|
||||
{
|
||||
# ifdef Q_OS_WIN
|
||||
QMessageBox::information(nullptr, QGuiApplication::applicationDisplayName(), "<html><head/><body><pre>" + parser.helpText() + "</pre></body></html>");
|
||||
# else
|
||||
parser.showHelp(); // terminates
|
||||
Q_UNREACHABLE();
|
||||
# endif
|
||||
}
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user