Skip to content

Commit

Permalink
Dialogs and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Silarn committed Sep 21, 2023
1 parent 9baea1c commit 0c094a1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/installationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,20 +667,21 @@ InstallationResult InstallationManager::install(const QString& fileName,
if (category != 0 && categoryIndex == 0U &&
Settings::instance().nexus().categoryMappings()) {
QMessageBox nexusQuery;
nexusQuery.setWindowTitle(tr("No category found"));
nexusQuery.setText(tr(
"This Nexus category has not yet been mapped. Do you wish to proceed without "
"setting a category, proceed and disable automatic Nexus mappings, or stop "
"and configure your category mappings?"));
nexusQuery.addButton(tr("&Proceed"), QMessageBox::YesRole);
nexusQuery.addButton(tr("&Disable"), QMessageBox::AcceptRole);
nexusQuery.addButton(tr("&Stop && Configure"), QMessageBox::DestructiveRole);
auto ret = nexusQuery.exec();
switch (ret) {
case 1:
QPushButton* proceedButton =
nexusQuery.addButton(tr("&Proceed"), QMessageBox::YesRole);
QPushButton* disableButton =
nexusQuery.addButton(tr("&Disable"), QMessageBox::AcceptRole);
QPushButton* stopButton =
nexusQuery.addButton(tr("&Stop && Configure"), QMessageBox::DestructiveRole);
nexusQuery.exec();
if (nexusQuery.clickedButton() == disableButton) {
Settings::instance().nexus().setCategoryMappings(false);
case 0:
break;
case 2:
} else if (nexusQuery.clickedButton() == stopButton) {
return MOBase::IPluginInstaller::RESULT_CATEGORYREQUESTED;
}
} else {
Expand Down
17 changes: 16 additions & 1 deletion src/modlistviewactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,29 @@ void ModListViewActions::checkModsForUpdates() const

void ModListViewActions::assignCategories() const
{
if (!GlobalSettings::hideAssignCategoriesQuestion()) {
QMessageBox warning;
warning.setWindowTitle(tr("Are you sure?"));
warning.setText(
tr("This action will remove any existing categories on any mod with a valid "
"Nexus category mapping. Are you certain you want to proceed?"));
warning.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
QCheckBox dontShow(tr("&Don't show this again"));
warning.setCheckBox(&dontShow);
auto result = warning.exec();
if (dontShow.isChecked())
GlobalSettings::setHideAssignCategoriesQuestion(true);
if (result == QMessageBox::Cancel)
return;
}
for (auto mod : m_core.modList()->allMods()) {
ModInfo::Ptr modInfo = ModInfo::getByName(mod);
QString file = modInfo->installationFile();
int nexusCategory = modInfo->getNexusCategory();
if (!nexusCategory) {
auto download = m_core.downloadManager()->getDownloadIndex(file);
if (download >= 0) {
int nexusCategory = m_core.downloadManager()->getCategoryID(download);
nexusCategory = m_core.downloadManager()->getCategoryID(download);
}
}
int newCategory = CategoryFactory::instance()->resolveNexusID(nexusCategory);
Expand Down
10 changes: 10 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,16 @@ void GlobalSettings::setHideCategoryReminder(bool b)
settings().setValue("HideCategoryReminder", b);
}

bool GlobalSettings::hideAssignCategoriesQuestion()
{
return settings().value("HideAssignCategoriesQuestion", false).toBool();
}

void GlobalSettings::setHideAssignCategoriesQuestion(bool b)
{
settings().setValue("HideAssignCategoriesQuestion", b);
}

bool GlobalSettings::nexusApiKey(QString& apiKey)
{
QString tempKey = getWindowsCredential("APIKEY");
Expand Down
3 changes: 3 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,9 @@ class GlobalSettings
static bool hideCategoryReminder();
static void setHideCategoryReminder(bool b);

static bool hideAssignCategoriesQuestion();
static void setHideAssignCategoriesQuestion(bool b);

// if the key exists from the credentials store, puts it in `apiKey` and
// returns true; otherwise, returns false and leaves `apiKey` untouched
//
Expand Down

0 comments on commit 0c094a1

Please sign in to comment.