diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/commandline.cpp | 12 | ||||
| -rw-r--r-- | src/commandline.h | 2 | ||||
| -rw-r--r-- | src/main.cpp | 6 | ||||
| -rw-r--r-- | src/organizercore.cpp | 19 |
4 files changed, 35 insertions, 4 deletions
diff --git a/src/commandline.cpp b/src/commandline.cpp index f5c4df60..11f43dea 100644 --- a/src/commandline.cpp +++ b/src/commandline.cpp @@ -120,6 +120,7 @@ void CommandLine::createOptions() m_visibleOptions.add_options() ("help", "show this message") ("multiple", "allow multiple instances of MO to run; see below") + ("instance,i", po::value<std::string>(), "use the given instance (defaults to last used)") ("profile,p", po::value<std::string>(), "use the given profile (defaults to last used)"); po::options_description options; @@ -187,6 +188,17 @@ std::optional<QString> CommandLine::profile() const return {}; } +std::optional<QString> CommandLine::instance() const +{ + if (m_shortcut.isValid() && m_shortcut.hasInstance()) { + return m_shortcut.instance(); + } else if (m_vm.count("instance")) { + return QString::fromStdString(m_vm["instance"].as<std::string>()); + } + + return {}; +} + const MOShortcut& CommandLine::shortcut() const { return m_shortcut; diff --git a/src/commandline.h b/src/commandline.h index cdd1c917..ecc19c89 100644 --- a/src/commandline.h +++ b/src/commandline.h @@ -99,6 +99,8 @@ public: bool multiple() const; std::optional<QString> profile() const; + std::optional<QString> instance() const; + const MOShortcut& shortcut() const; std::optional<QString> nxmLink() const; std::optional<QString> executable() const; diff --git a/src/main.cpp b/src/main.cpp index 3c5bc92d..5ae8999c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -874,8 +874,10 @@ int main(int argc, char *argv[]) try { InstanceManager& instanceManager = InstanceManager::instance(); - if (cl.shortcut().isValid() && cl.shortcut().hasInstance()) - instanceManager.overrideInstance(cl.shortcut().instance()); + + if (cl.instance()) + instanceManager.overrideInstance(*cl.instance()); + dataPath = instanceManager.determineDataPath(); } catch (const std::exception &e) { if (strcmp(e.what(),"Canceled")) diff --git a/src/organizercore.cpp b/src/organizercore.cpp index f9cafc95..a9469e6e 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -555,9 +555,24 @@ void OrganizerCore::setCurrentProfile(const QString &profileName) log::debug("selecting profile '{}'", profileName); QDir profileBaseDir(settings().paths().profiles()); - QString profileDir = profileBaseDir.absoluteFilePath(profileName); - if (!QDir(profileDir).exists()) { + const auto subdirs = profileBaseDir.entryList( + QDir::AllDirs | QDir::NoDotAndDotDot); + + QString profileDir; + + // the profile name may not have the correct case, which breaks other parts + // of the ui like the profile combobox, which walks directories on its own + // + // find the real name with the correct case by walking the directories + for (auto&& dirName : subdirs) { + if (QString::compare(dirName, profileName, Qt::CaseInsensitive) == 0) { + profileDir = profileBaseDir.absoluteFilePath(dirName); + break; + } + } + + if (profileDir.isEmpty()) { log::error("profile '{}' does not exist", profileName); // selected profile doesn't exist. Ensure there is at least one profile, |
