From c17f6e37e5e32138f778cedf66c80e20f1eacd2e Mon Sep 17 00:00:00 2001 From: Janrupf Date: Mon, 13 Mar 2023 16:37:45 +0100 Subject: [PATCH 1/2] feat: Add setting for downloads directory Closes #641 Signed-off-by: Janrupf --- launcher/Application.cpp | 1 + launcher/ui/dialogs/BlockedModsDialog.cpp | 2 +- launcher/ui/pages/global/LauncherPage.cpp | 18 +++++- launcher/ui/pages/global/LauncherPage.h | 1 + launcher/ui/pages/global/LauncherPage.ui | 71 ++++++++++++++--------- 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 321f944b..879af535 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -516,6 +516,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_settings->registerSetting("InstanceDir", "instances"); m_settings->registerSetting({"CentralModsDir", "ModsDir"}, "mods"); m_settings->registerSetting("IconsDir", "icons"); + m_settings->registerSetting("DownloadsDir", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)); // Editors m_settings->registerSetting("JsonEditor", QString()); diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp index eb427953..ff885f10 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.cpp +++ b/launcher/ui/dialogs/BlockedModsDialog.cpp @@ -184,7 +184,7 @@ void BlockedModsDialog::directoryChanged(QString path) /// @brief add the user downloads folder and the global mods folder to the filesystem watcher void BlockedModsDialog::setupWatch() { - const QString downloadsFolder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); + const QString downloadsFolder = APPLICATION->settings()->get("DownloadsDir").toString(); const QString modsFolder = APPLICATION->settings()->get("CentralModsDir").toString(); m_watcher.addPath(downloadsFolder); m_watcher.addPath(modsFolder); diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index a9f44c0b..324eb461 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -140,8 +140,8 @@ void LauncherPage::on_instDirBrowseBtn_clicked() if (result == QMessageBox::Ok) { ui->instDirTextBox->setText(cooked_dir); - } - } + } + } else { ui->instDirTextBox->setText(cooked_dir); @@ -160,6 +160,7 @@ void LauncherPage::on_iconsDirBrowseBtn_clicked() ui->iconsDirTextBox->setText(cooked_dir); } } + void LauncherPage::on_modsDirBrowseBtn_clicked() { QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"), ui->modsDirTextBox->text()); @@ -172,6 +173,17 @@ void LauncherPage::on_modsDirBrowseBtn_clicked() } } +void LauncherPage::on_downloadsDirBrowseBtn_clicked() +{ + QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Downloads Folder"), ui->downloadsDirTextBox->text()); + + if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) + { + QString cooked_dir = FS::NormalizePath(raw_dir); + ui->downloadsDirTextBox->setText(cooked_dir); + } +} + void LauncherPage::on_metadataDisableBtn_clicked() { ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked()); @@ -204,6 +216,7 @@ void LauncherPage::applySettings() s->set("InstanceDir", ui->instDirTextBox->text()); s->set("CentralModsDir", ui->modsDirTextBox->text()); s->set("IconsDir", ui->iconsDirTextBox->text()); + s->set("DownloadsDir", ui->downloadsDirTextBox->text()); auto sortMode = (InstSortMode)ui->sortingModeGroup->checkedId(); switch (sortMode) @@ -260,6 +273,7 @@ void LauncherPage::loadSettings() ui->instDirTextBox->setText(s->get("InstanceDir").toString()); ui->modsDirTextBox->setText(s->get("CentralModsDir").toString()); ui->iconsDirTextBox->setText(s->get("IconsDir").toString()); + ui->downloadsDirTextBox->setText(s->get("DownloadsDir").toString()); QString sortMode = s->get("InstSortMode").toString(); diff --git a/launcher/ui/pages/global/LauncherPage.h b/launcher/ui/pages/global/LauncherPage.h index c60156c2..33f66f1b 100644 --- a/launcher/ui/pages/global/LauncherPage.h +++ b/launcher/ui/pages/global/LauncherPage.h @@ -88,6 +88,7 @@ slots: void on_instDirBrowseBtn_clicked(); void on_modsDirBrowseBtn_clicked(); void on_iconsDirBrowseBtn_clicked(); + void on_downloadsDirBrowseBtn_clicked(); void on_metadataDisableBtn_clicked(); /*! diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index f084d970..1fe55678 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -38,7 +38,7 @@ QTabWidget::Rounded - 1 + 0 @@ -67,13 +67,6 @@ Folders - - - - ... - - - @@ -81,29 +74,12 @@ - - - - ... - - + + - - - - &Icons: - - - iconsDirTextBox - - - - - - @@ -117,6 +93,20 @@ + + + + ... + + + + + + + ... + + + @@ -127,6 +117,33 @@ + + + + &Icons: + + + iconsDirTextBox + + + + + + + Downloads: + + + + + + + + + + ... + + + From 05b6969ee507fce515d4f961814487239a946055 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 14 Mar 2023 13:35:16 +0100 Subject: [PATCH 2/2] fix: add mnemonic to downloads directory setting Signed-off-by: Sefa Eyeoglu --- launcher/ui/pages/global/LauncherPage.ui | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 1fe55678..923b7f95 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -130,7 +130,10 @@ - Downloads: + &Downloads: + + + downloadsDirTextBox