summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2016-11-16 15:09:57 +0100
committerAleix Pol <[email protected]>2016-11-16 15:09:57 +0100
commit17ffab70201124d36522c80aaf1ab19584a42a47 (patch)
treee914aad0552c464bd58d8650b3c9fb4d99d2d984
parentf6bef735485b56fe5eacccf20af264733d9e684d (diff)
Prefer types to logic
-rw-r--r--discover/main.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/discover/main.cpp b/discover/main.cpp
index 3e92348..4c584fa 100644
--- a/discover/main.cpp
+++ b/discover/main.cpp
@@ -32,16 +32,12 @@
#include <QTextStream>
#include <QStandardPaths>
-DiscoverMainWindow::CompactMode decodeCompactMode(const QString &str)
-{
- if (str == QLatin1String("auto"))
- return DiscoverMainWindow::Auto;
- else if (str == QLatin1String("compact"))
- return DiscoverMainWindow::Compact;
- else if (str == QLatin1String("full"))
- return DiscoverMainWindow::Full;
- return DiscoverMainWindow::Full;
-}
+typedef QHash<QString, DiscoverMainWindow::CompactMode> StringCompactMode;
+Q_GLOBAL_STATIC_WITH_ARGS(StringCompactMode, s_decodeCompactMode, (StringCompactMode {
+ { QLatin1String("auto"), DiscoverMainWindow::Auto },
+ { QLatin1String("compact"), DiscoverMainWindow::Compact },
+ { QLatin1String("full"), DiscoverMainWindow::Full }
+}))
QCommandLineParser* createParser()
{
@@ -114,7 +110,7 @@ int main(int argc, char** argv)
KDBusService* service = new KDBusService(KDBusService::Unique, &app);
- mainWindow = new DiscoverMainWindow(decodeCompactMode(parser->value(QStringLiteral("compact"))));
+ mainWindow = new DiscoverMainWindow(s_decodeCompactMode->value(parser->value(QStringLiteral("compact")), DiscoverMainWindow::Full));
QObject::connect(&app, &QApplication::aboutToQuit, mainWindow, &DiscoverMainWindow::deleteLater);
QObject::connect(service, &KDBusService::activateRequested, mainWindow, [mainWindow](const QStringList &arguments, const QString &/*workingDirectory*/){
mainWindow->rootObject()->raise();