mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-06 21:54:15 +01:00
OP-769 main.cpp fixed review comments (OPReview-440)
This commit is contained in:
parent
208e97f476
commit
6074828807
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
The -reset switch will clear all the user settings and will trigger a reload of the factory defaults.
|
The -reset switch will clear all the user settings and will trigger a reload of the factory defaults.
|
||||||
|
|
||||||
You can combine it with the -configfile=<file> command line argument to quickly switch between multiple settings files.
|
You can combine it with the -config-file=<file> command line argument to quickly switch between multiple settings files.
|
||||||
|
|
||||||
[code]
|
[code]
|
||||||
openpilotgcs -reset -config-file ./MyOpenPilotGCS.xml
|
openpilotgcs -reset -config-file ./MyOpenPilotGCS.xml
|
||||||
@ -55,7 +55,7 @@
|
|||||||
Quickly switch configurations
|
Quickly switch configurations
|
||||||
|
|
||||||
[code]
|
[code]
|
||||||
-reset -config-file <relative or absolute path>
|
openpilotgcs -reset -config-file <relative or absolute path>
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
Configuring GCS from installer
|
Configuring GCS from installer
|
||||||
@ -65,14 +65,14 @@
|
|||||||
If the user chooses to start GCS at the end of the installer:
|
If the user chooses to start GCS at the end of the installer:
|
||||||
|
|
||||||
[code]
|
[code]
|
||||||
-D General/OverrideLanguage=de
|
openpilotgcs -D General/OverrideLanguage=de
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
If the user chooses not to start GCS at the end of the installer, you still need to configure GCS.
|
If the user chooses not to start GCS at the end of the installer, you still need to configure GCS.
|
||||||
In that case you can use -exit-after-config
|
In that case you can use -exit-after-config
|
||||||
|
|
||||||
[code]
|
[code]
|
||||||
-D General/OverrideLanguage=de -exit-after-config
|
openpilotgcs -D General/OverrideLanguage=de -exit-after-config
|
||||||
[/code]
|
[/code]
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -127,7 +127,7 @@ namespace {
|
|||||||
|
|
||||||
const char *DEFAULT_CONFIG_FILENAME = "OpenPilotGCS.xml";
|
const char *DEFAULT_CONFIG_FILENAME = "OpenPilotGCS.xml";
|
||||||
|
|
||||||
const char *fixedOptionsC = " [OPTION]... [FILE]...\n"
|
const char *fixedOptionsC = " [OPTION]...\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -help Display this help\n"
|
" -help Display this help\n"
|
||||||
" -version Display application version\n"
|
" -version Display application version\n"
|
||||||
@ -151,66 +151,56 @@ namespace {
|
|||||||
const QLatin1String EXIT_AFTER_CONFIG_OPTION("-exit-after-config");
|
const QLatin1String EXIT_AFTER_CONFIG_OPTION("-exit-after-config");
|
||||||
|
|
||||||
// Helpers for displaying messages. Note that there is no console on Windows.
|
// Helpers for displaying messages. Note that there is no console on Windows.
|
||||||
#ifdef Q_OS_WIN
|
void displayHelpText(QString t)
|
||||||
|
|
||||||
// Format as <pre> HTML
|
|
||||||
inline void toHtml(QString &t)
|
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// No console on Windows. (???)
|
||||||
|
// TODO there is a console on windows and popups are not always desired
|
||||||
t.replace(QLatin1Char('&'), QLatin1String("&"));
|
t.replace(QLatin1Char('&'), QLatin1String("&"));
|
||||||
t.replace(QLatin1Char('<'), QLatin1String("<"));
|
t.replace(QLatin1Char('<'), QLatin1String("<"));
|
||||||
t.replace(QLatin1Char('>'), QLatin1String(">"));
|
t.replace(QLatin1Char('>'), QLatin1String(">"));
|
||||||
t.insert(0, QLatin1String("<html><pre>"));
|
t.insert(0, QLatin1String("<html><pre>"));
|
||||||
t.append(QLatin1String("</pre></html>"));
|
t.append(QLatin1String("</pre></html>"));
|
||||||
}
|
|
||||||
|
|
||||||
void displayHelpText(QString t) // No console on Windows.
|
|
||||||
{
|
|
||||||
toHtml(t);
|
|
||||||
QMessageBox::information(0, APP_NAME, t);
|
QMessageBox::information(0, APP_NAME, t);
|
||||||
}
|
|
||||||
|
|
||||||
void displayError(const QString &t) // No console on Windows.
|
|
||||||
{
|
|
||||||
QMessageBox::critical(0, APP_NAME, t);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void displayHelpText(const QString &t)
|
|
||||||
{
|
|
||||||
qWarning("%s", qPrintable(t));
|
qWarning("%s", qPrintable(t));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayError(const QString &t)
|
void displayError(const QString &t)
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// No console on Windows. (???)
|
||||||
|
// TODO there is a console on windows and popups are not always desired
|
||||||
|
QMessageBox::critical(0, APP_NAME, t);
|
||||||
|
#else
|
||||||
qCritical("%s", qPrintable(t));
|
qCritical("%s", qPrintable(t));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
void printVersion(const ExtensionSystem::PluginSpec *corePlugin, const ExtensionSystem::PluginManager &pm)
|
||||||
|
|
||||||
void printVersion(const ExtensionSystem::PluginSpec *coreplugin, const ExtensionSystem::PluginManager &pm)
|
|
||||||
{
|
{
|
||||||
QString version;
|
QString version;
|
||||||
QTextStream str(&version);
|
QTextStream str(&version);
|
||||||
str << '\n' << APP_NAME << ' ' << coreplugin->version() << " based on Qt " << qVersion() << "\n\n";
|
str << '\n' << APP_NAME << ' ' << corePlugin->version() << " based on Qt " << qVersion() << "\n\n";
|
||||||
pm.formatPluginVersions(str);
|
pm.formatPluginVersions(str);
|
||||||
str << '\n' << coreplugin->copyright() << '\n';
|
str << '\n' << corePlugin->copyright() << '\n';
|
||||||
displayHelpText(version);
|
displayHelpText(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printHelp(const QString &a0, const ExtensionSystem::PluginManager &pm)
|
void printHelp(const QString &appExecName, const ExtensionSystem::PluginManager &pm)
|
||||||
{
|
{
|
||||||
QString help;
|
QString help;
|
||||||
QTextStream str(&help);
|
QTextStream str(&help);
|
||||||
str << "Usage: " << a0 << fixedOptionsC;
|
str << "Usage: " << appExecName << fixedOptionsC;
|
||||||
ExtensionSystem::PluginManager::formatOptions(str, OptionIndent, DescriptionIndent);
|
ExtensionSystem::PluginManager::formatOptions(str, OptionIndent, DescriptionIndent);
|
||||||
pm.formatPluginOptions(str, OptionIndent, DescriptionIndent);
|
pm.formatPluginOptions(str, OptionIndent, DescriptionIndent);
|
||||||
displayHelpText(help);
|
displayHelpText(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString msgCoreLoadFailure(const QString &why)
|
inline QString msgCoreLoadFailure(const QString &reason)
|
||||||
{
|
{
|
||||||
return QCoreApplication::translate("Application", "Failed to load core: %1").arg(why);
|
return QCoreApplication::translate("Application", "Failed to load core plug-in, reason is: %1").arg(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString msgSendArgumentFailed()
|
inline QString msgSendArgumentFailed()
|
||||||
@ -366,8 +356,7 @@ namespace {
|
|||||||
|
|
||||||
// transfer loaded settings to application settings
|
// transfer loaded settings to application settings
|
||||||
QStringList keys = qs.allKeys();
|
QStringList keys = qs.allKeys();
|
||||||
foreach(QString key, keys)
|
foreach(QString key, keys) {
|
||||||
{
|
|
||||||
settings.setValue(key, qs.value(key));
|
settings.setValue(key, qs.value(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,7 +458,7 @@ int main(int argc, char **argv)
|
|||||||
overrideSettings(settings, argc, argv);
|
overrideSettings(settings, argc, argv);
|
||||||
|
|
||||||
// initialize GCS locale
|
// initialize GCS locale
|
||||||
// use the value defined by the General/Locale setting or default to system locale.
|
// use the value defined by the General/Locale setting or default to system Locale.
|
||||||
// the General/Locale setting is not available in the Options dialog, it is a hidden setting but can still be changed:
|
// the General/Locale setting is not available in the Options dialog, it is a hidden setting but can still be changed:
|
||||||
// - through the command line
|
// - through the command line
|
||||||
// - editing the factory defaults XML file before 1st launch
|
// - editing the factory defaults XML file before 1st launch
|
||||||
@ -477,7 +466,7 @@ int main(int argc, char **argv)
|
|||||||
QString localeName = settings.value("General/Locale", QLocale::system().name()).toString();
|
QString localeName = settings.value("General/Locale", QLocale::system().name()).toString();
|
||||||
QLocale::setDefault(localeName);
|
QLocale::setDefault(localeName);
|
||||||
|
|
||||||
// some debuging
|
// some debugging
|
||||||
qDebug() << "main - system locale:" << QLocale::system().name();
|
qDebug() << "main - system locale:" << QLocale::system().name();
|
||||||
qDebug() << "main - GCS locale:" << QLocale().name();
|
qDebug() << "main - GCS locale:" << QLocale().name();
|
||||||
|
|
||||||
@ -512,8 +501,7 @@ int main(int argc, char **argv)
|
|||||||
// find and load core plugin
|
// find and load core plugin
|
||||||
const PluginSpecSet plugins = pluginManager.plugins();
|
const PluginSpecSet plugins = pluginManager.plugins();
|
||||||
ExtensionSystem::PluginSpec *coreplugin = 0;
|
ExtensionSystem::PluginSpec *coreplugin = 0;
|
||||||
foreach (ExtensionSystem::PluginSpec *spec, plugins)
|
foreach (ExtensionSystem::PluginSpec *spec, plugins) {
|
||||||
{
|
|
||||||
if (spec->name() == CORE_PLUGIN_NAME) {
|
if (spec->name() == CORE_PLUGIN_NAME) {
|
||||||
coreplugin = spec;
|
coreplugin = spec;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user