diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/commandline.cpp | 8 | ||||
| -rw-r--r-- | src/commandline.h | 3 | ||||
| -rw-r--r-- | src/editexecutablesdialog.cpp | 11 | ||||
| -rw-r--r-- | src/main.cpp | 5 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 15 | ||||
| -rw-r--r-- | src/moapplication.cpp | 10 | ||||
| -rw-r--r-- | src/moapplication.h | 4 | ||||
| -rw-r--r-- | src/pluginlistcontextmenu.cpp | 70 |
8 files changed, 80 insertions, 46 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/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index 6e3cecff..7272e3fd 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -141,9 +141,10 @@ void EditExecutablesDialog::loadForcedLibraries() const auto* p = m_organizerCore.currentProfile(); for (const auto& e : m_executablesList) { - if (p->forcedLibrariesEnabled(e.title())) { - m_forcedLibraries.set(e.title(), true, p->determineForcedLibraries(e.title())); - } + m_forcedLibraries.set( + e.title(), + p->forcedLibrariesEnabled(e.title()), + p->determineForcedLibraries(e.title())); } } @@ -242,8 +243,8 @@ bool EditExecutablesDialog::commitChanges() } if (auto libraryList=m_forcedLibraries.find(e.title())) { - if (libraryList && libraryList->enabled && !libraryList->value.empty()) { - profile->setForcedLibrariesEnabled(e.title(), true); + if (libraryList && !libraryList->value.empty()) { + profile->setForcedLibrariesEnabled(e.title(), libraryList->enabled); profile->storeForcedLibraries(e.title(), libraryList->value); } } 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/mainwindow.cpp b/src/mainwindow.cpp index a3144edd..4053a030 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1218,8 +1218,21 @@ void MainWindow::showEvent(QShowEvent *event) m_WasVisible = true; updateProblemsButton(); - // Notify plugin that the MO2 is ready: + // notify plugins that the MO2 is ready m_PluginContainer.startPlugins(this); + + // forces a log list refresh to display startup logs + // + // since the log list is not visible until this point, the automatic + // resize of columns seems to break the log list (since Qt 5.15.1 or + // 5.15.2), an make the list empty on startup (in debug the list is not + // empty because some logs are added after the log list becomes visible) + // + // the reset() forces a re-computation of the column size, thus properly + // the logs that are already in the log model + // + ui->logList->reset(); + ui->logList->scrollToBottom(); } } diff --git a/src/moapplication.cpp b/src/moapplication.cpp index 91cac2b1..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;
}
@@ -398,7 +398,7 @@ void MOApplication::externalMessage(const QString& message) .run();
}
} else if (isNxmLink(message)) {
- MessageDialog::showMessage(tr("Download started"), qApp->activeWindow());
+ MessageDialog::showMessage(tr("Download started"), qApp->activeWindow(), false);
m_core->downloadRequestedNXM(message);
} else {
cl::CommandLine cl;
@@ -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();
};
diff --git a/src/pluginlistcontextmenu.cpp b/src/pluginlistcontextmenu.cpp index e6afd996..c6d4ecec 100644 --- a/src/pluginlistcontextmenu.cpp +++ b/src/pluginlistcontextmenu.cpp @@ -18,14 +18,16 @@ PluginListContextMenu::PluginListContextMenu( if (view->selectionModel()->hasSelection()) { m_selected = view->indexViewToModel(view->selectionModel()->selectedRows()); } - else { + else if (index.isValid()) { m_selected = { index }; } - addAction(tr("Enable selected"), [=]() { m_core.pluginList()->setEnabled(m_selected, true); }); - addAction(tr("Disable selected"), [=]() { m_core.pluginList()->setEnabled(m_selected, false); }); + if (!m_selected.isEmpty()) { + addAction(tr("Enable selected"), [=]() { m_core.pluginList()->setEnabled(m_selected, true); }); + addAction(tr("Disable selected"), [=]() { m_core.pluginList()->setEnabled(m_selected, false); }); - addSeparator(); + addSeparator(); + } addAction(tr("Enable all"), [=]() { if (QMessageBox::question( @@ -42,43 +44,47 @@ PluginListContextMenu::PluginListContextMenu( } }); - addSeparator(); + if (!m_selected.isEmpty()) { + addSeparator(); + addMenu(createSendToContextMenu()); - addMenu(createSendToContextMenu()); - addSeparator(); + addSeparator(); - bool hasLocked = false; - bool hasUnlocked = false; - for (auto& idx : m_selected) { - if (m_core.pluginList()->isEnabled(idx.row())) { - if (m_core.pluginList()->isESPLocked(idx.row())) { - hasLocked = true; - } - else { - hasUnlocked = true; + bool hasLocked = false; + bool hasUnlocked = false; + for (auto& idx : m_selected) { + if (m_core.pluginList()->isEnabled(idx.row())) { + if (m_core.pluginList()->isESPLocked(idx.row())) { + hasLocked = true; + } + else { + hasUnlocked = true; + } } } - } - if (hasLocked) { - addAction(tr("Unlock load order"), [=]() { setESPLock(m_selected, false); }); - } - if (hasUnlocked) { - addAction(tr("Lock load order"), [=]() { setESPLock(m_selected, true); }); + if (hasLocked) { + addAction(tr("Unlock load order"), [=]() { setESPLock(m_selected, false); }); + } + if (hasUnlocked) { + addAction(tr("Lock load order"), [=]() { setESPLock(m_selected, true); }); + } } - addSeparator(); + if (m_index.isValid()) { + addSeparator(); - unsigned int modInfoIndex = ModInfo::getIndex(m_core.pluginList()->origin(m_index.data().toString())); - // this is to avoid showing the option on game files like skyrim.esm - if (modInfoIndex != UINT_MAX) { - addAction(tr("Open Origin in Explorer"), [=]() { openOriginExplorer(m_selected); }); - ModInfo::Ptr modInfo = ModInfo::getByIndex(modInfoIndex); - std::vector<ModInfo::EFlag> flags = modInfo->getFlags(); + unsigned int modInfoIndex = ModInfo::getIndex(m_core.pluginList()->origin(m_index.data().toString())); + // this is to avoid showing the option on game files like skyrim.esm + if (modInfoIndex != UINT_MAX) { + addAction(tr("Open Origin in Explorer"), [=]() { openOriginExplorer(m_selected); }); + ModInfo::Ptr modInfo = ModInfo::getByIndex(modInfoIndex); + std::vector<ModInfo::EFlag> flags = modInfo->getFlags(); - if (!modInfo->isForeign() && m_selected.size() == 1) { - QAction* infoAction = addAction(tr("Open Origin Info..."), [=]() { openOriginInformation(index); }); - setDefaultAction(infoAction); + if (!modInfo->isForeign() && m_selected.size() == 1) { + QAction* infoAction = addAction(tr("Open Origin Info..."), [=]() { openOriginInformation(index); }); + setDefaultAction(infoAction); + } } } |
