diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-28 19:05:05 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-28 19:05:05 +0100 |
| commit | a88d3436cc6b2c24ab05400a5ad5e9e67cb95db8 (patch) | |
| tree | 70900eb0da1ea4c9afd304db705393ca8bcc7e2a /src | |
| parent | 41159e4eea0c79670d15b2707f4e6d7c86bb2d65 (diff) | |
Implementation --pick argument.
Diffstat (limited to 'src')
| -rw-r--r-- | src/commandline.cpp | 8 | ||||
| -rw-r--r-- | src/commandline.h | 3 | ||||
| -rw-r--r-- | src/main.cpp | 5 | ||||
| -rw-r--r-- | src/moapplication.cpp | 8 | ||||
| -rw-r--r-- | src/moapplication.h | 4 |
5 files changed, 21 insertions, 7 deletions
diff --git a/src/commandline.cpp b/src/commandline.cpp index 477bfba1..22755dda 100644 --- a/src/commandline.cpp +++ b/src/commandline.cpp @@ -344,6 +344,9 @@ void CommandLine::createOptions() ("multiple", "allow multiple MO processes to run; see below") + ("pick", + "show the select instance dialog on startup") + ("logs", "duplicates the logs to stdout") @@ -424,6 +427,11 @@ std::string CommandLine::usage(const Command* c) const return oss.str(); } +bool CommandLine::pick() const +{ + return (m_vm.count("pick") > 0); +} + bool CommandLine::multiple() const { return (m_vm.count("multiple") > 0); diff --git a/src/commandline.h b/src/commandline.h index 6bd57132..a0b70fb2 100644 --- a/src/commandline.h +++ b/src/commandline.h @@ -318,6 +318,9 @@ public: // std::string usage(const Command* c=nullptr) const; + // whether --pick was given + // + bool pick() const; // whether --multiple was given // diff --git a/src/main.cpp b/src/main.cpp index 0cd9ba26..60d99817 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -80,6 +80,8 @@ int run(int argc, char *argv[]) // stuff that's done only once, even if MO restarts in the loop below app.firstTimeSetup(multiProcess); + // force the "Select instance" dialog on startup (only for first loop) + bool pick = cl.pick(); // MO runs in a loop because it can be restarted in several ways, such as // when switching instances or changing some settings @@ -100,7 +102,8 @@ int run(int argc, char *argv[]) // set up plugins, OrganizerCore, etc. { - const auto r = app.setup(multiProcess); + const auto r = app.setup(multiProcess, pick); + pick = false; if (r == RestartExitCode) { // resets things when MO is "restarted" diff --git a/src/moapplication.cpp b/src/moapplication.cpp index 91cac2b1..1289b6ba 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -183,7 +183,7 @@ void MOApplication::firstTimeSetup(MOMultiProcess& multiProcess) Qt::QueuedConnection);
}
-int MOApplication::setup(MOMultiProcess& multiProcess)
+int MOApplication::setup(MOMultiProcess& multiProcess, bool forceSelect)
{
TimeThis tt("MOApplication setup()");
@@ -192,7 +192,7 @@ int MOApplication::setup(MOMultiProcess& multiProcess) MOBase::details::setPluginDataPath(OrganizerCore::pluginDataPath());
// figuring out the current instance
- m_instance = getCurrentInstance();
+ m_instance = getCurrentInstance(forceSelect);
if (!m_instance) {
return 1;
}
@@ -439,12 +439,12 @@ void MOApplication::externalMessage(const QString& message) }
}
-std::unique_ptr<Instance> MOApplication::getCurrentInstance()
+std::unique_ptr<Instance> MOApplication::getCurrentInstance(bool forceSelect)
{
auto& m = InstanceManager::singleton();
auto currentInstance = m.currentInstance();
- if (!currentInstance)
+ if (forceSelect || !currentInstance)
{
// clear any overrides that might have been given on the command line
m.clearOverrides();
diff --git a/src/moapplication.h b/src/moapplication.h index 65180ece..d10db320 100644 --- a/src/moapplication.h +++ b/src/moapplication.h @@ -47,7 +47,7 @@ public: // called from main() each time MO "restarts", loads settings, plugins,
// OrganizerCore and the current instance
//
- int setup(MOMultiProcess& multiProcess);
+ int setup(MOMultiProcess& multiProcess, bool forceSelect);
// shows splash, starts an api check, shows the main window and blocks until
// MO exits
@@ -85,7 +85,7 @@ private: std::unique_ptr<OrganizerCore> m_core;
void externalMessage(const QString& message);
- std::unique_ptr<Instance> getCurrentInstance();
+ std::unique_ptr<Instance> getCurrentInstance(bool forceSelect);
std::optional<int> setupInstanceLoop(Instance& currentInstance, PluginContainer& pc);
void purgeOldFiles();
};
|
