diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/main.cpp b/src/main.cpp index 7989f8b..98e52d4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,7 +9,7 @@ #include <QCommandLineParser> namespace { -bool _testMode, _autoSetup, _showGui, _backgroundMode, _wakeup; +bool _testMode, _autoSetup, _showGui, _backgroundMode, _wakeup, _center; } namespace CommandLine @@ -18,6 +18,8 @@ bool testMode() { return _testMode; } bool autoSetup() { return _autoSetup; } bool showGui() { return _showGui; } bool backgroundMode() { return _backgroundMode; } +bool wakeup() { return _wakeup; } +bool center() { return _center; } } static void parseCommandLine(const QCoreApplication &a); @@ -49,24 +51,26 @@ int main(int argc, char *argv[]) parseCommandLine(*a); - if (_wakeup) { + if (CommandLine::wakeup()) { return Bus::inst()->registerService() ? 0 : 1; } ScreenSetup::inst()->initModes(); + ScreenMode currentMode; - if (CommandLine::autoSetup()) { + if (CommandLine::center()) { + ScreenSetup::inst()->setCenteredClone(); + currentMode = ScreenMode::Clone; + } else if (CommandLine::autoSetup()) { currentMode = ScreenSetup::inst()->setDefaultMode(CommandLine::testMode()); } else { currentMode = ScreenSetup::inst()->getCurrentMode(); } - bool showNow = (CommandLine::showGui() && currentMode != ScreenMode::Single); - Widget *w = nullptr; - if (CommandLine::backgroundMode() || showNow) { + if (CommandLine::backgroundMode() || CommandLine::showGui()) { w = new Widget(); - if (showNow) { + if (CommandLine::showGui()) { w->show(); } } @@ -84,24 +88,28 @@ static void parseCommandLine(const QCoreApplication &a) parser.addVersionOption(); // Option for adding modes and trying to auto-setup QCommandLineOption oAutoSetup(QStringList() << "a" << "auto", - QCoreApplication::translate("main", "Automatically configure modes and set up screens.")); + QCoreApplication::translate("main", "Automatically configure modes and set up screens.")); parser.addOption(oAutoSetup); // Show config GUI if more than one screen QCommandLineOption oShowGui(QStringList() << "g" << "gui", - QCoreApplication::translate("main", "Show config GUI if more than one screen is connected.")); + QCoreApplication::translate("main", "Show config GUI right away.")); parser.addOption(oShowGui); // Keep running and detect screen setup changes QCommandLineOption oBackground(QStringList() << "b" << "background", - QCoreApplication::translate("main", "Keep running in background and show GUI again when number of screens changes.")); + QCoreApplication::translate("main", "Keep running in background and show GUI when number of screens changes.")); parser.addOption(oBackground); // Test mode -- pretend to do setup QCommandLineOption oTest(QStringList() << "t" << "test", - QCoreApplication::translate("main", "Test mode, don't actually apply any changes.")); - parser.addOption(oTest); + QCoreApplication::translate("main", "Test mode, don't actually apply any changes.")); + //parser.addOption(oTest); TODO Not fully implemented so disabled for now // Wakeup beamergui daemon via DBus connect QCommandLineOption oWakeup(QStringList() << "w" << "wakeup", - QCoreApplication::translate("main", "Connect to system bus to trigger wakeup of wainting beamergui.")); + QCoreApplication::translate("main", "Connect to system bus to trigger wakeup of wainting beamergui.")); parser.addOption(oWakeup); + // Set all outputs to clone mode and center them according to the largest output + QCommandLineOption oCenter(QStringList() << "c" << "center", + QCoreApplication::translate("main", "Set all outputs to clone mode. If size differs, center outputs according to largest output.")); + parser.addOption(oCenter); // PARSE parser.process(a); _testMode = parser.isSet(oTest); @@ -109,4 +117,6 @@ static void parseCommandLine(const QCoreApplication &a) _showGui = parser.isSet(oShowGui); _backgroundMode = parser.isSet(oBackground); _wakeup = parser.isSet(oWakeup); + _center = parser.isSet(oCenter); } + |