diff options
| author | Qudix <17361645+Qudix@users.noreply.github.com> | 2020-11-10 12:11:20 -0600 |
|---|---|---|
| committer | Qudix <17361645+Qudix@users.noreply.github.com> | 2020-11-10 12:11:20 -0600 |
| commit | 62caad3cdbf6b616594c1d9d17d837f942ae110b (patch) | |
| tree | 94270f70c8e467d59ce8c5599526e67857f8060e /src | |
| parent | b9bc1a2d56be5efc4478f1487c3e7dfb3529102d (diff) | |
| parent | 9c21d1e4f6a42043bc4cf86f1235750ee8ce6f64 (diff) | |
Merge branch 'master' of https://github.com/ModOrganizer2/modorganizer into master
Diffstat (limited to 'src')
| -rw-r--r-- | src/commandline.cpp | 54 | ||||
| -rw-r--r-- | src/commandline.h | 8 | ||||
| -rw-r--r-- | src/instancemanagerdialog.cpp | 8 | ||||
| -rw-r--r-- | src/main.cpp | 5 |
4 files changed, 41 insertions, 34 deletions
diff --git a/src/commandline.cpp b/src/commandline.cpp index fd2fcb51..bb9ff9b8 100644 --- a/src/commandline.cpp +++ b/src/commandline.cpp @@ -100,29 +100,29 @@ std::optional<int> CommandLine::run(const std::wstring& line) try { - // parse the the remainder of the command line according to the - // command's options - po::wcommand_line_parser parser(opts); + // legacy commands handle their own parsing, such as 'launch'; don't + // attempt to parse anything here + if (!c->legacy()) { + // parse the the remainder of the command line according to the + // command's options + po::wcommand_line_parser parser(opts); - auto co = c->allOptions(); - parser.options(co); + auto co = c->allOptions(); + parser.options(co); - if (c->allow_unregistered()) { - parser.allow_unregistered(); - } - - auto pos = c->positional(); - parser.positional(pos); + auto pos = c->positional(); + parser.positional(pos); - parsed = parser.run(); + parsed = parser.run(); - po::store(parsed, m_vm); - po::notify(m_vm); + po::store(parsed, m_vm); + po::notify(m_vm); - if (m_vm.count("help")) { - env::Console console; - std::cout << usage(c.get()) << "\n"; - return 0; + if (m_vm.count("help")) { + env::Console console; + std::cout << usage(c.get()) << "\n"; + return 0; + } } // run the command @@ -405,11 +405,6 @@ std::string Command::usageLine() const return name() + " " + getUsageLine(); } -bool Command::allow_unregistered() const -{ - return false; -} - po::options_description Command::allOptions() const { po::options_description d; @@ -435,6 +430,11 @@ po::positional_options_description Command::positional() const return getPositional(); } +bool Command::legacy() const +{ + return true; +} + std::string Command::getUsageLine() const { return "[options]"; @@ -522,14 +522,14 @@ std::optional<int> CrashDumpCommand::doRun() } -bool LaunchCommand::allow_unregistered() const +Command::Meta LaunchCommand::meta() const { - return true; + return {"launch", "(internal, do not use)"}; } -Command::Meta LaunchCommand::meta() const +bool LaunchCommand::legacy() const { - return {"launch", "(internal, do not use)"}; + return true; } std::optional<int> LaunchCommand::doRun() diff --git a/src/commandline.h b/src/commandline.h index baa0bfb9..09c1bb8e 100644 --- a/src/commandline.h +++ b/src/commandline.h @@ -45,10 +45,10 @@ public: // po::positional_options_description positional() const; - // whether the command allows for unregistered options; this is only used for - // the old `launch` command and shouldn't be used anywhere else + // when this returns true, the command line is not parsed at all and doRun() + // is expected to use untouched() // - virtual bool allow_unregistered() const; + virtual bool legacy() const; // runs this command, eventually calls doRun() // @@ -136,7 +136,7 @@ protected: class LaunchCommand : public Command { public: - bool allow_unregistered() const override; + bool legacy() const override; protected: Meta meta() const override; diff --git a/src/instancemanagerdialog.cpp b/src/instancemanagerdialog.cpp index b461d39d..ff76e121 100644 --- a/src/instancemanagerdialog.cpp +++ b/src/instancemanagerdialog.cpp @@ -473,12 +473,18 @@ void InstanceManagerDialog::deleteInstance() auto* item = new QListWidgetItem(f.path); if (f.mandatoryDelete) { + // disable, cannot uncheck mandatory items item->setFlags(item->flags() & (~Qt::ItemIsEnabled)); + + // checked by default + item->setCheckState(Qt::Checked); } else { item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + + // unchecked by default + item->setCheckState(Qt::Unchecked); } - item->setCheckState(Qt::Checked); list->addItem(item); } diff --git a/src/main.cpp b/src/main.cpp index 554ed006..877236e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,8 +17,6 @@ int forwardToPrimary(MOMultiProcess& multiProcess, const cl::CommandLine& cl); int main(int argc, char *argv[]) { - TimeThis tt("main()"); - MOShared::SetThisThreadName("main"); setExceptionHandlers(); @@ -29,6 +27,9 @@ int main(int argc, char *argv[]) initLogging(); + // must be after logging + TimeThis tt("main()"); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); MOApplication app(cl, argc, argv); |
