Skip to content

Commit 0c094a1

Browse files
committed
Dialogs and bugfixes
1 parent 9baea1c commit 0c094a1

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

src/installationmanager.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -667,20 +667,21 @@ InstallationResult InstallationManager::install(const QString& fileName,
667667
if (category != 0 && categoryIndex == 0U &&
668668
Settings::instance().nexus().categoryMappings()) {
669669
QMessageBox nexusQuery;
670+
nexusQuery.setWindowTitle(tr("No category found"));
670671
nexusQuery.setText(tr(
671672
"This Nexus category has not yet been mapped. Do you wish to proceed without "
672673
"setting a category, proceed and disable automatic Nexus mappings, or stop "
673674
"and configure your category mappings?"));
674-
nexusQuery.addButton(tr("&Proceed"), QMessageBox::YesRole);
675-
nexusQuery.addButton(tr("&Disable"), QMessageBox::AcceptRole);
676-
nexusQuery.addButton(tr("&Stop && Configure"), QMessageBox::DestructiveRole);
677-
auto ret = nexusQuery.exec();
678-
switch (ret) {
679-
case 1:
675+
QPushButton* proceedButton =
676+
nexusQuery.addButton(tr("&Proceed"), QMessageBox::YesRole);
677+
QPushButton* disableButton =
678+
nexusQuery.addButton(tr("&Disable"), QMessageBox::AcceptRole);
679+
QPushButton* stopButton =
680+
nexusQuery.addButton(tr("&Stop && Configure"), QMessageBox::DestructiveRole);
681+
nexusQuery.exec();
682+
if (nexusQuery.clickedButton() == disableButton) {
680683
Settings::instance().nexus().setCategoryMappings(false);
681-
case 0:
682-
break;
683-
case 2:
684+
} else if (nexusQuery.clickedButton() == stopButton) {
684685
return MOBase::IPluginInstaller::RESULT_CATEGORYREQUESTED;
685686
}
686687
} else {

src/modlistviewactions.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,29 @@ void ModListViewActions::checkModsForUpdates() const
262262

263263
void ModListViewActions::assignCategories() const
264264
{
265+
if (!GlobalSettings::hideAssignCategoriesQuestion()) {
266+
QMessageBox warning;
267+
warning.setWindowTitle(tr("Are you sure?"));
268+
warning.setText(
269+
tr("This action will remove any existing categories on any mod with a valid "
270+
"Nexus category mapping. Are you certain you want to proceed?"));
271+
warning.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
272+
QCheckBox dontShow(tr("&Don't show this again"));
273+
warning.setCheckBox(&dontShow);
274+
auto result = warning.exec();
275+
if (dontShow.isChecked())
276+
GlobalSettings::setHideAssignCategoriesQuestion(true);
277+
if (result == QMessageBox::Cancel)
278+
return;
279+
}
265280
for (auto mod : m_core.modList()->allMods()) {
266281
ModInfo::Ptr modInfo = ModInfo::getByName(mod);
267282
QString file = modInfo->installationFile();
268283
int nexusCategory = modInfo->getNexusCategory();
269284
if (!nexusCategory) {
270285
auto download = m_core.downloadManager()->getDownloadIndex(file);
271286
if (download >= 0) {
272-
int nexusCategory = m_core.downloadManager()->getCategoryID(download);
287+
nexusCategory = m_core.downloadManager()->getCategoryID(download);
273288
}
274289
}
275290
int newCategory = CategoryFactory::instance()->resolveNexusID(nexusCategory);

src/settings.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,6 +2450,16 @@ void GlobalSettings::setHideCategoryReminder(bool b)
24502450
settings().setValue("HideCategoryReminder", b);
24512451
}
24522452

2453+
bool GlobalSettings::hideAssignCategoriesQuestion()
2454+
{
2455+
return settings().value("HideAssignCategoriesQuestion", false).toBool();
2456+
}
2457+
2458+
void GlobalSettings::setHideAssignCategoriesQuestion(bool b)
2459+
{
2460+
settings().setValue("HideAssignCategoriesQuestion", b);
2461+
}
2462+
24532463
bool GlobalSettings::nexusApiKey(QString& apiKey)
24542464
{
24552465
QString tempKey = getWindowsCredential("APIKEY");

src/settings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,9 @@ class GlobalSettings
931931
static bool hideCategoryReminder();
932932
static void setHideCategoryReminder(bool b);
933933

934+
static bool hideAssignCategoriesQuestion();
935+
static void setHideAssignCategoriesQuestion(bool b);
936+
934937
// if the key exists from the credentials store, puts it in `apiKey` and
935938
// returns true; otherwise, returns false and leaves `apiKey` untouched
936939
//

0 commit comments

Comments
 (0)