From eabb12ff276376cfa3bb82cfa878584db405e006 Mon Sep 17 00:00:00 2001 From: sgourdas Date: Fri, 13 Sep 2024 16:41:28 +0300 Subject: [PATCH 1/2] Monitor data directory on portable mode --- src/settingsmanager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index 86870a9..27006b6 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -186,12 +186,15 @@ void SettingsManager::setContentType(FilterList contentTypeList) void SettingsManager::initSettings() { + if(isPortableMode()) { + m_downloadDir = m_monitorDir = getDataDirectory(); + } else { + m_downloadDir = m_settings.value("download/dir", getDataDirectory()).toString(); + m_monitorDir = m_settings.value("monitor/dir", QString("")).toString(); + } m_kiwixServerPort = m_settings.value("localKiwixServer/port", 8080).toInt(); m_zoomFactor = m_settings.value("view/zoomFactor", 1).toDouble(); - QString dataDir = getDataDirectory(); - m_downloadDir = isPortableMode() ? dataDir : m_settings.value("download/dir", dataDir).toString(); m_kiwixServerIpAddress = m_settings.value("localKiwixServer/ipAddress", QString("0.0.0.0")).toString(); - m_monitorDir = m_settings.value("monitor/dir", QString("")).toString(); m_moveToTrash = m_settings.value("moveToTrash", true).toBool(); m_reopenTab = m_settings.value("reopenTab", false).toBool(); QString defaultLang = QLocale::languageToString(QLocale().language()) + '|' + QLocale().name().split("_").at(0); From adc5c9c44188cd28b03906b52bf1d5de46ced482 Mon Sep 17 00:00:00 2001 From: sgourdas Date: Tue, 17 Sep 2024 13:10:49 +0300 Subject: [PATCH 2/2] Portable download & monitor settings immutable --- resources/i18n/en.json | 1 + resources/i18n/qqq.json | 1 + src/settingsview.cpp | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/resources/i18n/en.json b/resources/i18n/en.json index 51a4af5..932d3c6 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -166,6 +166,7 @@ "import-reading-list-error": "An error has occured during import of the reading list.", "disable-sandbox": "Application was launched from a network drive. This is known to cause compatibility issues due to the sandbox. Do you want to take the risks and disable it?", "save-page-as": "Save As...", + "portable-disabled-tooltip": "Function disabled in portable mode", "scroll-next-tab": "Scroll to next tab", "scroll-previous-tab": "Scroll to previous tab" } diff --git a/resources/i18n/qqq.json b/resources/i18n/qqq.json index 2e133a2..a0f2e24 100644 --- a/resources/i18n/qqq.json +++ b/resources/i18n/qqq.json @@ -173,6 +173,7 @@ "import-reading-list": "Represents the action of importing a reading list from a file.", "import-reading-list-error": "Error description text for when importing a reading list from a file failed.", "save-page-as": "Represents the action of saving the current tab content to a file chosen by the user.", + "portable-disabled-tooltip": "Tooltip used to explain disabled components in the portable version.", "scroll-next-tab": "Represents the action of scrolling to the next tab of the current tab which toward the end of the tab bar.", "scroll-previous-tab": "Represents the action of scrolling to the previous tab of the current tab which toward the start of the tab bar." } diff --git a/src/settingsview.cpp b/src/settingsview.cpp index 919e667..780a595 100644 --- a/src/settingsview.cpp +++ b/src/settingsview.cpp @@ -18,6 +18,14 @@ namespace } return input; } + + void disableInPortableMode(QWidget* w) + { + w->setEnabled(false); + QString disabledStyle = "color: gray;"; + w->setStyleSheet(disabledStyle); + w->setToolTip(gt("portable-disabled-tooltip")); + } } SettingsView::SettingsView(QWidget *parent) @@ -62,6 +70,12 @@ SettingsView::SettingsView(QWidget *parent) ui->monitorHelp->setToolTip(gt("monitor-directory-tooltip")); ui->moveToTrashLabel->setText(gt("move-files-to-trash")); ui->reopenTabLabel->setText(gt("open-previous-tabs-at-startup")); + if(isPortableMode()) { + disableInPortableMode(ui->browseButton); + disableInPortableMode(ui->resetButton); + disableInPortableMode(ui->monitorBrowse); + disableInPortableMode(ui->monitorClear); + } #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) ui->line_5->hide(); ui->moveToTrashLabel->hide();