summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commandline.cpp8
-rw-r--r--src/commandline.h3
-rw-r--r--src/main.cpp5
-rw-r--r--src/moapplication.cpp8
-rw-r--r--src/moapplication.h4
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 19b43d77..6d21745e 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();
};