Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor data directory on portable mode #1209

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
sgourdas marked this conversation as resolved.
Show resolved Hide resolved
"scroll-next-tab": "Scroll to next tab",
"scroll-previous-tab": "Scroll to previous tab"
}
1 change: 1 addition & 0 deletions resources/i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
9 changes: 6 additions & 3 deletions src/settingsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions src/settingsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
Loading