diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp index 9dd77fe..36a30da 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,7 @@ #include <QCommandLineParser> /** - * @brief printPoiToml Print the built-in config (if any) + * @brief printPoiToml Print the built-in config * @param output std::ostream to print to */ void printPoiToml(std::ostream &output) @@ -39,7 +39,7 @@ void printPoiToml(std::ostream &output) int main(int argc, char *argv[]) { - // + // Create application object Browser app(argc, argv); app.setApplicationName("smolbote"); #ifdef GIT_VERSION @@ -48,11 +48,7 @@ int main(int argc, char *argv[]) app.setApplicationVersion("1.0.0"); #endif - if(app.isRunning()) { - qDebug("Another instance is running, returning..."); - return 0; - } - + // parse command line options QCommandLineParser parser; parser.setApplicationDescription("yet another Qt browser"); parser.addHelpOption(); @@ -61,7 +57,7 @@ int main(int argc, char *argv[]) QCommandLineOption configOption(QStringList() << "c" << "config", "Set configuration file.", "PATH"); parser.addOption(configOption); - QCommandLineOption defaultConfigOption(QStringList() << "default-config", "Print default configuration."); + QCommandLineOption defaultConfigOption(QStringList() << "print-defaults", "Print default configuration."); parser.addOption(defaultConfigOption); QCommandLineOption profileOption(QStringList() << "p" << "profile", "Use this profile.", "PROFILE"); @@ -83,6 +79,22 @@ int main(int argc, char *argv[]) parser.process(app); + // Check for another instance + // unless specified not to + if(!parser.isSet(newInstanceOption)) { + app.bindLocalSocket(); + if(app.isRunning()) { + qDebug("Another instance is running, returning..."); + QHash<QString, QVariant> params; + if(parser.isSet(profileOption)) { + params.insert("profile", parser.value(profileOption)); + } + params.insert("urls", QVariant(parser.positionalArguments())); + app.sendMessage(params); + return 0; + } + } + if(parser.isSet(defaultConfigOption)) { printPoiToml(std::cout); return 0; |