From 489b56b68bb29e81337e115c490eea4403001b71 Mon Sep 17 00:00:00 2001 From: Dimosthenis Krallis Date: Fri, 18 Aug 2023 07:07:48 +0000 Subject: Dolphin settings revamp It includes a move of the settings in the Navigation and Startup sections to the Interface (formerly Behavior) section. It also includes a new tab in the View (formerly View Mode) section, called General where some settings regarding Display style, Browsing and Miscellaneous settings The Interface section has new tabs named Folders & Tabs and Status & Location bars respectively where most of the Startup and Navigation settings moved. The `dolphin/kcms/kcm_dolphinnavigation` kcm is removed. --- src/settings/dolphinsettingsdialog.cpp | 38 +-- src/settings/general/behaviorsettingspage.cpp | 195 --------------- src/settings/general/behaviorsettingspage.h | 59 ----- .../general/configurepreviewplugindialog.cpp | 73 ------ .../general/configurepreviewplugindialog.h | 36 --- src/settings/general/confirmationssettingspage.cpp | 177 -------------- src/settings/general/confirmationssettingspage.h | 48 ---- src/settings/general/generalsettingspage.cpp | 74 ------ src/settings/general/generalsettingspage.h | 43 ---- src/settings/general/previewssettingspage.cpp | 205 ---------------- src/settings/general/previewssettingspage.h | 59 ----- src/settings/general/statusbarsettingspage.cpp | 77 ------ src/settings/general/statusbarsettingspage.h | 40 ---- .../interface/configurepreviewplugindialog.cpp | 73 ++++++ .../interface/configurepreviewplugindialog.h | 36 +++ .../interface/confirmationssettingspage.cpp | 177 ++++++++++++++ src/settings/interface/confirmationssettingspage.h | 48 ++++ src/settings/interface/folderstabssettingspage.cpp | 263 +++++++++++++++++++++ src/settings/interface/folderstabssettingspage.h | 69 ++++++ src/settings/interface/interfacesettingspage.cpp | 74 ++++++ src/settings/interface/interfacesettingspage.h | 42 ++++ src/settings/interface/previewssettingspage.cpp | 205 ++++++++++++++++ src/settings/interface/previewssettingspage.h | 59 +++++ .../statusandlocationbarssettingspage.cpp | 128 ++++++++++ .../interface/statusandlocationbarssettingspage.h | 55 +++++ src/settings/kcm/kcmdolphingeneral.cpp | 17 +- src/settings/kcm/kcmdolphinnavigation.cpp | 48 ---- src/settings/kcm/kcmdolphinnavigation.h | 32 --- src/settings/kcm/kcmdolphinnavigation.json | 63 ----- src/settings/navigation/navigationsettingspage.cpp | 82 ------- src/settings/navigation/navigationsettingspage.h | 41 ---- src/settings/startup/startupsettingspage.cpp | 233 ------------------ src/settings/startup/startupsettingspage.h | 64 ----- src/settings/viewmodes/contentdisplaytab.cpp | 54 ++++- src/settings/viewmodes/contentdisplaytab.h | 8 + src/settings/viewmodes/generalviewsettingspage.cpp | 133 +++++++++++ src/settings/viewmodes/generalviewsettingspage.h | 50 ++++ src/settings/viewmodes/viewsettingspage.cpp | 9 +- src/settings/viewmodes/viewsettingspage.h | 2 +- 39 files changed, 1501 insertions(+), 1688 deletions(-) delete mode 100644 src/settings/general/behaviorsettingspage.cpp delete mode 100644 src/settings/general/behaviorsettingspage.h delete mode 100644 src/settings/general/configurepreviewplugindialog.cpp delete mode 100644 src/settings/general/configurepreviewplugindialog.h delete mode 100644 src/settings/general/confirmationssettingspage.cpp delete mode 100644 src/settings/general/confirmationssettingspage.h delete mode 100644 src/settings/general/generalsettingspage.cpp delete mode 100644 src/settings/general/generalsettingspage.h delete mode 100644 src/settings/general/previewssettingspage.cpp delete mode 100644 src/settings/general/previewssettingspage.h delete mode 100644 src/settings/general/statusbarsettingspage.cpp delete mode 100644 src/settings/general/statusbarsettingspage.h create mode 100644 src/settings/interface/configurepreviewplugindialog.cpp create mode 100644 src/settings/interface/configurepreviewplugindialog.h create mode 100644 src/settings/interface/confirmationssettingspage.cpp create mode 100644 src/settings/interface/confirmationssettingspage.h create mode 100644 src/settings/interface/folderstabssettingspage.cpp create mode 100644 src/settings/interface/folderstabssettingspage.h create mode 100644 src/settings/interface/interfacesettingspage.cpp create mode 100644 src/settings/interface/interfacesettingspage.h create mode 100644 src/settings/interface/previewssettingspage.cpp create mode 100644 src/settings/interface/previewssettingspage.h create mode 100644 src/settings/interface/statusandlocationbarssettingspage.cpp create mode 100644 src/settings/interface/statusandlocationbarssettingspage.h delete mode 100644 src/settings/kcm/kcmdolphinnavigation.cpp delete mode 100644 src/settings/kcm/kcmdolphinnavigation.h delete mode 100644 src/settings/kcm/kcmdolphinnavigation.json delete mode 100644 src/settings/navigation/navigationsettingspage.cpp delete mode 100644 src/settings/navigation/navigationsettingspage.h delete mode 100644 src/settings/startup/startupsettingspage.cpp delete mode 100644 src/settings/startup/startupsettingspage.h create mode 100644 src/settings/viewmodes/generalviewsettingspage.cpp create mode 100644 src/settings/viewmodes/generalviewsettingspage.h (limited to 'src/settings') diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp index 8c200c747..45aa7b65a 100644 --- a/src/settings/dolphinsettingsdialog.cpp +++ b/src/settings/dolphinsettingsdialog.cpp @@ -10,9 +10,7 @@ #include "contextmenu/contextmenusettingspage.h" #include "dolphin_generalsettings.h" #include "dolphinmainwindow.h" -#include "general/generalsettingspage.h" -#include "navigation/navigationsettingspage.h" -#include "startup/startupsettingspage.h" +#include "interface/interfacesettingspage.h" #include "trash/trashsettingspage.h" #include "viewmodes/viewsettingspage.h" #if HAVE_KUSERFEEDBACK @@ -50,30 +48,18 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl &url, QWidget *parent, K connect(box->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, this, &DolphinSettingsDialog::applySettings); connect(box->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, &DolphinSettingsDialog::restoreDefaults); - // General - GeneralSettingsPage *generalSettingsPage = new GeneralSettingsPage(url, this); - KPageWidgetItem *generalSettingsFrame = addPage(generalSettingsPage, i18nc("@title:group General settings", "General")); - generalSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("system-file-manager"))); - connect(generalSettingsPage, &GeneralSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); - - // Startup - StartupSettingsPage *startupSettingsPage = new StartupSettingsPage(url, this); - KPageWidgetItem *startupSettingsFrame = addPage(startupSettingsPage, i18nc("@title:group", "Startup")); - startupSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-launch-feedback"))); - connect(startupSettingsPage, &StartupSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); - - // View Modes - ViewSettingsPage *viewSettingsPage = new ViewSettingsPage(this); - KPageWidgetItem *viewSettingsFrame = addPage(viewSettingsPage, i18nc("@title:group", "View Modes")); + // Interface + InterfaceSettingsPage *interfaceSettingsPage = new InterfaceSettingsPage(this); + KPageWidgetItem *interfaceSettingsFrame = addPage(interfaceSettingsPage, i18nc("@title:group Interface settings", "Interface")); + interfaceSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("system-file-manager"))); + connect(interfaceSettingsPage, &InterfaceSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); + + // View + ViewSettingsPage *viewSettingsPage = new ViewSettingsPage(url, this); + KPageWidgetItem *viewSettingsFrame = addPage(viewSettingsPage, i18nc("@title:group", "View")); viewSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-icons"))); connect(viewSettingsPage, &ViewSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); - // Navigation - NavigationSettingsPage *navigationSettingsPage = new NavigationSettingsPage(this); - KPageWidgetItem *navigationSettingsFrame = addPage(navigationSettingsPage, i18nc("@title:group", "Navigation")); - navigationSettingsFrame->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-navigation"))); - connect(navigationSettingsPage, &NavigationSettingsPage::changed, this, &DolphinSettingsDialog::enableApply); - // Context Menu auto contextMenuSettingsPage = new ContextMenuSettingsPage(this, actions, @@ -113,10 +99,8 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl &url, QWidget *parent, K } #endif - m_pages.append(generalSettingsPage); - m_pages.append(startupSettingsPage); + m_pages.append(interfaceSettingsPage); m_pages.append(viewSettingsPage); - m_pages.append(navigationSettingsPage); m_pages.append(contextMenuSettingsPage); if (trashSettingsPage) { m_pages.append(trashSettingsPage); diff --git a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp deleted file mode 100644 index 662fcc26a..000000000 --- a/src/settings/general/behaviorsettingspage.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006 Peter Penz (peter.penz@gmx.at) and Patrice Tremblay - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "behaviorsettingspage.h" - -#include "global.h" -#include "views/viewproperties.h" - -#include - -#include -#include -#include -#include -#include - -BehaviorSettingsPage::BehaviorSettingsPage(const QUrl &url, QWidget *parent) - : SettingsPageBase(parent) - , m_url(url) - , m_localViewProps(nullptr) - , m_globalViewProps(nullptr) - , m_showToolTips(nullptr) - , m_showSelectionToggle(nullptr) - , m_naturalSorting(nullptr) - , m_caseSensitiveSorting(nullptr) - , m_caseInsensitiveSorting(nullptr) - , m_renameInline(nullptr) - , m_useTabForSplitViewSwitch(nullptr) -{ - QFormLayout *topLayout = new QFormLayout(this); - - // View properties - m_globalViewProps = new QRadioButton(i18nc("@option:radio", "Use common display style for all folders")); - m_localViewProps = new QRadioButton(i18nc("@option:radio", "Remember display style for each folder")); - m_localViewProps->setToolTip(i18nc("@info", "Dolphin will create a hidden .directory file in each folder you change view properties for.")); - - QButtonGroup *viewGroup = new QButtonGroup(this); - viewGroup->addButton(m_globalViewProps); - viewGroup->addButton(m_localViewProps); - topLayout->addRow(i18nc("@title:group", "View: "), m_globalViewProps); - topLayout->addRow(QString(), m_localViewProps); - - topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - - // Sorting properties - m_naturalSorting = new QRadioButton(i18nc("option:radio", "Natural")); - m_caseInsensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical, case insensitive")); - m_caseSensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical, case sensitive")); - - QButtonGroup *sortingModeGroup = new QButtonGroup(this); - sortingModeGroup->addButton(m_naturalSorting); - sortingModeGroup->addButton(m_caseInsensitiveSorting); - sortingModeGroup->addButton(m_caseSensitiveSorting); - topLayout->addRow(i18nc("@title:group", "Sorting mode: "), m_naturalSorting); - topLayout->addRow(QString(), m_caseInsensitiveSorting); - topLayout->addRow(QString(), m_caseSensitiveSorting); - - // Split Views - topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - - // 'Switch between panes of split views with tab key' - m_useTabForSplitViewSwitch = new QCheckBox(i18nc("option:check split view panes", "Switch between panes with Tab key")); - topLayout->addRow(i18nc("@title:group", "Split view: "), m_useTabForSplitViewSwitch); - - // 'Close active pane when turning off split view' - m_closeActiveSplitView = new QCheckBox(i18nc("option:check", "Turning off split view closes active pane")); - topLayout->addRow(QString(), m_closeActiveSplitView); - m_closeActiveSplitView->setToolTip(i18n("When deactivated, turning off split view will close the inactive pane")); - - topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - -#if HAVE_BALOO - // 'Show tooltips' - m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips")); - topLayout->addRow(i18nc("@title:group", "Miscellaneous: "), m_showToolTips); -#endif - - // 'Show selection marker' - m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker")); -#if HAVE_BALOO - topLayout->addRow(QString(), m_showSelectionToggle); -#else - topLayout->addRow(i18nc("@title:group", "Miscellaneous: "), m_showSelectionToggle); -#endif - - // 'Inline renaming of items' - m_renameInline = new QCheckBox(i18nc("option:check", "Rename inline")); - topLayout->addRow(QString(), m_renameInline); - - loadSettings(); - - connect(m_localViewProps, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); - connect(m_globalViewProps, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); -#if HAVE_BALOO - connect(m_showToolTips, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed); -#endif - connect(m_showSelectionToggle, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed); - connect(m_naturalSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); - connect(m_caseInsensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); - connect(m_caseSensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed); - connect(m_renameInline, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed); - connect(m_useTabForSplitViewSwitch, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed); - connect(m_closeActiveSplitView, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed); -} - -BehaviorSettingsPage::~BehaviorSettingsPage() -{ -} - -void BehaviorSettingsPage::applySettings() -{ - GeneralSettings *settings = GeneralSettings::self(); - ViewProperties props(m_url); // read current view properties - - const bool useGlobalViewProps = m_globalViewProps->isChecked(); - settings->setGlobalViewProps(useGlobalViewProps); -#if HAVE_BALOO - settings->setShowToolTips(m_showToolTips->isChecked()); -#endif - settings->setShowSelectionToggle(m_showSelectionToggle->isChecked()); - setSortingChoiceValue(settings); - settings->setRenameInline(m_renameInline->isChecked()); - settings->setUseTabForSwitchingSplitView(m_useTabForSplitViewSwitch->isChecked()); - settings->setCloseActiveSplitView(m_closeActiveSplitView->isChecked()); - settings->save(); - - if (useGlobalViewProps) { - // Remember the global view properties by applying the current view properties. - // It is important that GeneralSettings::globalViewProps() is set before - // the class ViewProperties is used, as ViewProperties uses this setting - // to find the destination folder for storing the view properties. - ViewProperties globalProps(m_url); - globalProps.setDirProperties(props); - } -} - -void BehaviorSettingsPage::restoreDefaults() -{ - GeneralSettings *settings = GeneralSettings::self(); - settings->useDefaults(true); - loadSettings(); - settings->useDefaults(false); -} - -void BehaviorSettingsPage::loadSettings() -{ - const bool useGlobalViewProps = GeneralSettings::globalViewProps(); - m_localViewProps->setChecked(!useGlobalViewProps); - m_globalViewProps->setChecked(useGlobalViewProps); - -#if HAVE_BALOO - m_showToolTips->setChecked(GeneralSettings::showToolTips()); -#endif - m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle()); - m_renameInline->setChecked(GeneralSettings::renameInline()); - m_useTabForSplitViewSwitch->setChecked(GeneralSettings::useTabForSwitchingSplitView()); - m_closeActiveSplitView->setChecked(GeneralSettings::closeActiveSplitView()); - - loadSortingChoiceSettings(); -} - -void BehaviorSettingsPage::setSortingChoiceValue(GeneralSettings *settings) -{ - using Choice = GeneralSettings::EnumSortingChoice; - if (m_naturalSorting->isChecked()) { - settings->setSortingChoice(Choice::NaturalSorting); - } else if (m_caseInsensitiveSorting->isChecked()) { - settings->setSortingChoice(Choice::CaseInsensitiveSorting); - } else if (m_caseSensitiveSorting->isChecked()) { - settings->setSortingChoice(Choice::CaseSensitiveSorting); - } -} - -void BehaviorSettingsPage::loadSortingChoiceSettings() -{ - using Choice = GeneralSettings::EnumSortingChoice; - switch (GeneralSettings::sortingChoice()) { - case Choice::NaturalSorting: - m_naturalSorting->setChecked(true); - break; - case Choice::CaseInsensitiveSorting: - m_caseInsensitiveSorting->setChecked(true); - break; - case Choice::CaseSensitiveSorting: - m_caseSensitiveSorting->setChecked(true); - break; - default: - Q_UNREACHABLE(); - } -} - -#include "moc_behaviorsettingspage.cpp" diff --git a/src/settings/general/behaviorsettingspage.h b/src/settings/general/behaviorsettingspage.h deleted file mode 100644 index ba8ce6384..000000000 --- a/src/settings/general/behaviorsettingspage.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ -#ifndef BEHAVIORSETTINGSPAGE_H -#define BEHAVIORSETTINGSPAGE_H - -#include "dolphin_generalsettings.h" -#include "settings/settingspagebase.h" - -#include - -class QCheckBox; -class QLabel; -class QRadioButton; - -/** - * @brief Tab page for the 'Behavior' settings of the Dolphin settings dialog. - */ -class BehaviorSettingsPage : public SettingsPageBase -{ - Q_OBJECT - -public: - BehaviorSettingsPage(const QUrl &url, QWidget *parent); - ~BehaviorSettingsPage() override; - - /** @see SettingsPageBase::applySettings() */ - void applySettings() override; - - /** @see SettingsPageBase::restoreDefaults() */ - void restoreDefaults() override; - -private: - void loadSettings(); - void setSortingChoiceValue(GeneralSettings *settings); - void loadSortingChoiceSettings(); - -private: - QUrl m_url; - - QRadioButton *m_localViewProps; - QRadioButton *m_globalViewProps; - - QCheckBox *m_showToolTips; - QLabel *m_configureToolTips; - QCheckBox *m_showSelectionToggle; - - QRadioButton *m_naturalSorting; - QRadioButton *m_caseSensitiveSorting; - QRadioButton *m_caseInsensitiveSorting; - - QCheckBox *m_renameInline; - QCheckBox *m_useTabForSplitViewSwitch; - QCheckBox *m_closeActiveSplitView; -}; - -#endif diff --git a/src/settings/general/configurepreviewplugindialog.cpp b/src/settings/general/configurepreviewplugindialog.cpp deleted file mode 100644 index 8846d8261..000000000 --- a/src/settings/general/configurepreviewplugindialog.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2011 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "configurepreviewplugindialog.h" - -#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString &pluginName, const QString &desktopEntryName, QWidget *parent) - : QDialog(parent) -{ - QSharedPointer previewPlugin; - const QString pluginPath = QPluginLoader(desktopEntryName).fileName(); - if (!pluginPath.isEmpty()) { - newCreator create = (newCreator)QLibrary::resolve(pluginPath, "new_creator"); - if (create) { - previewPlugin.reset(dynamic_cast(create())); - } - } - - setWindowTitle(i18nc("@title:window", "Configure Preview for %1", pluginName)); - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); - setMinimumWidth(400); - - auto layout = new QVBoxLayout(this); - - if (previewPlugin) { - auto configurationWidget = previewPlugin->createConfigurationWidget(); - configurationWidget->setParent(this); - layout->addWidget(configurationWidget); - - layout->addStretch(); - - connect(this, &ConfigurePreviewPluginDialog::accepted, this, [=] { - // TODO: It would be great having a mechanism to tell PreviewJob that only previews - // for a specific MIME-type should be regenerated. As this is not available yet we - // delete the whole thumbnails directory. - previewPlugin->writeConfiguration(configurationWidget); - - // https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#DIRECTORY - const QString thumbnailsPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/thumbnails/"); - KIO::del(QUrl::fromLocalFile(thumbnailsPath), KIO::HideProgressInfo); - }); - } - - auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); - connect(buttonBox, &QDialogButtonBox::accepted, this, &ConfigurePreviewPluginDialog::accept); - connect(buttonBox, &QDialogButtonBox::rejected, this, &ConfigurePreviewPluginDialog::reject); - layout->addWidget(buttonBox); - - auto okButton = buttonBox->button(QDialogButtonBox::Ok); - okButton->setShortcut(Qt::CTRL | Qt::Key_Return); - okButton->setDefault(true); -} - -#include "moc_configurepreviewplugindialog.cpp" - -#endif // KIO_VERSION diff --git a/src/settings/general/configurepreviewplugindialog.h b/src/settings/general/configurepreviewplugindialog.h deleted file mode 100644 index 66504cce2..000000000 --- a/src/settings/general/configurepreviewplugindialog.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2011 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef CONFIGUREPREVIEWPLUGINDIALOG_H -#define CONFIGUREPREVIEWPLUGINDIALOG_H - -#include - -#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) - -#include - -/** - * @brief Dialog for configuring preview-plugins. - */ -class ConfigurePreviewPluginDialog : public QDialog -{ - Q_OBJECT - -public: - /** - * @param pluginName User visible name of the plugin - * @param desktopEntryName The name of the plugin that is noted in the desktopentry. - * Is used to instantiate the plugin to get the configuration - * widget. - * @param parent Parent widget. - */ - ConfigurePreviewPluginDialog(const QString &pluginName, const QString &desktopEntryName, QWidget *parent); - ~ConfigurePreviewPluginDialog() override = default; -}; -#endif // KIOWIDGETS_BUILD_DEPRECATED_SINCE - -#endif diff --git a/src/settings/general/confirmationssettingspage.cpp b/src/settings/general/confirmationssettingspage.cpp deleted file mode 100644 index 61c3a14b6..000000000 --- a/src/settings/general/confirmationssettingspage.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2012 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "confirmationssettingspage.h" - -#include "dolphin_generalsettings.h" -#include "global.h" - -#include - -#include -#include -#include -#include -#include - -namespace -{ -enum ScriptExecution { AlwaysAsk = 0, Open = 1, Execute = 2 }; - -const bool ConfirmEmptyTrash = true; -const bool ConfirmTrash = false; -const bool ConfirmDelete = true; -const int ConfirmScriptExecution = ScriptExecution::AlwaysAsk; -} - -ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget *parent) - : SettingsPageBase(parent) - , m_confirmMoveToTrash(nullptr) - , m_confirmEmptyTrash(nullptr) - , m_confirmDelete(nullptr) - , - -#if HAVE_TERMINAL - m_confirmClosingTerminalRunningProgram(nullptr) - , -#endif - - m_confirmClosingMultipleTabs(nullptr) -{ - QVBoxLayout *topLayout = new QVBoxLayout(this); - - QLabel *confirmLabelKde = new QLabel(i18nc("@title:group", "Ask for confirmation in all KDE applications when:"), this); - confirmLabelKde->setWordWrap(true); - - m_confirmMoveToTrash = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Moving files or folders to trash"), this); - m_confirmEmptyTrash = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Emptying trash"), this); - m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Deleting files or folders"), this); - - QLabel *confirmLabelDolphin = new QLabel(i18nc("@title:group", "Ask for confirmation in Dolphin when:"), this); - confirmLabelDolphin->setWordWrap(true); - - m_confirmClosingMultipleTabs = new QCheckBox(i18nc("@option:check Ask for confirmation in Dolphin when", "Closing windows with multiple tabs"), this); - -#if HAVE_TERMINAL - m_confirmClosingTerminalRunningProgram = - new QCheckBox(i18nc("@option:check Ask for confirmation when", "Closing windows with a program running in the Terminal panel"), this); -#endif - - QHBoxLayout *executableScriptLayout = new QHBoxLayout(); - QLabel *executableScriptLabel = new QLabel(i18nc("@title:group", "When opening an executable file:"), this); - confirmLabelKde->setWordWrap(true); - executableScriptLayout->addWidget(executableScriptLabel); - - m_confirmScriptExecution = new QComboBox(this); - m_confirmScriptExecution->addItems({i18n("Always ask"), i18n("Open in application"), i18n("Run script")}); - executableScriptLayout->addWidget(m_confirmScriptExecution); - - topLayout->addWidget(confirmLabelKde); - topLayout->addWidget(m_confirmMoveToTrash); - topLayout->addWidget(m_confirmEmptyTrash); - topLayout->addWidget(m_confirmDelete); - topLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT); - topLayout->addWidget(confirmLabelDolphin); - topLayout->addWidget(m_confirmClosingMultipleTabs); - -#if HAVE_TERMINAL - topLayout->addWidget(m_confirmClosingTerminalRunningProgram); -#endif - - topLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT); - topLayout->addLayout(executableScriptLayout); - - topLayout->addStretch(); - - loadSettings(); - - connect(m_confirmMoveToTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); - connect(m_confirmEmptyTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); - connect(m_confirmDelete, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); - connect(m_confirmScriptExecution, QOverload::of(&QComboBox::currentIndexChanged), this, &ConfirmationsSettingsPage::changed); - connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); - -#if HAVE_TERMINAL - connect(m_confirmClosingTerminalRunningProgram, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); -#endif -} - -ConfirmationsSettingsPage::~ConfirmationsSettingsPage() -{ -} - -void ConfirmationsSettingsPage::applySettings() -{ - KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig(QStringLiteral("kiorc"), KConfig::NoGlobals); - KConfigGroup confirmationGroup(kioConfig, "Confirmations"); - confirmationGroup.writeEntry("ConfirmTrash", m_confirmMoveToTrash->isChecked()); - confirmationGroup.writeEntry("ConfirmEmptyTrash", m_confirmEmptyTrash->isChecked()); - confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked()); - - KConfigGroup scriptExecutionGroup(kioConfig, "Executable scripts"); - const int index = m_confirmScriptExecution->currentIndex(); - switch (index) { - case ScriptExecution::AlwaysAsk: - scriptExecutionGroup.writeEntry("behaviourOnLaunch", "alwaysAsk"); - break; - case ScriptExecution::Open: - scriptExecutionGroup.writeEntry("behaviourOnLaunch", "open"); - break; - case ScriptExecution::Execute: - scriptExecutionGroup.writeEntry("behaviourOnLaunch", "execute"); - break; - } - kioConfig->sync(); - - GeneralSettings *settings = GeneralSettings::self(); - settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked()); - -#if HAVE_TERMINAL - settings->setConfirmClosingTerminalRunningProgram(m_confirmClosingTerminalRunningProgram->isChecked()); -#endif - - settings->save(); -} - -void ConfirmationsSettingsPage::restoreDefaults() -{ - GeneralSettings *settings = GeneralSettings::self(); - settings->useDefaults(true); - loadSettings(); - settings->useDefaults(false); - - m_confirmMoveToTrash->setChecked(ConfirmTrash); - m_confirmEmptyTrash->setChecked(ConfirmEmptyTrash); - m_confirmDelete->setChecked(ConfirmDelete); - m_confirmScriptExecution->setCurrentIndex(ConfirmScriptExecution); -} - -void ConfirmationsSettingsPage::loadSettings() -{ - KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig(QStringLiteral("kiorc"), KConfig::IncludeGlobals); - const KConfigGroup confirmationGroup(kioConfig, "Confirmations"); - m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", ConfirmTrash)); - m_confirmEmptyTrash->setChecked(confirmationGroup.readEntry("ConfirmEmptyTrash", ConfirmEmptyTrash)); - m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", ConfirmDelete)); - - const KConfigGroup scriptExecutionGroup(KSharedConfig::openConfig(QStringLiteral("kiorc")), "Executable scripts"); - const QString value = scriptExecutionGroup.readEntry("behaviourOnLaunch", "alwaysAsk"); - if (value == QLatin1String("alwaysAsk")) { - m_confirmScriptExecution->setCurrentIndex(ScriptExecution::AlwaysAsk); - } else if (value == QLatin1String("execute")) { - m_confirmScriptExecution->setCurrentIndex(ScriptExecution::Execute); - } else /* if (value == QLatin1String("open"))*/ { - m_confirmScriptExecution->setCurrentIndex(ScriptExecution::Open); - } - - m_confirmClosingMultipleTabs->setChecked(GeneralSettings::confirmClosingMultipleTabs()); - -#if HAVE_TERMINAL - m_confirmClosingTerminalRunningProgram->setChecked(GeneralSettings::confirmClosingTerminalRunningProgram()); -#endif -} - -#include "moc_confirmationssettingspage.cpp" diff --git a/src/settings/general/confirmationssettingspage.h b/src/settings/general/confirmationssettingspage.h deleted file mode 100644 index 56dd1a78c..000000000 --- a/src/settings/general/confirmationssettingspage.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2012 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ -#ifndef CONFIRMATIONSSETTINGSPAGE_H -#define CONFIRMATIONSSETTINGSPAGE_H - -#include "config-dolphin.h" -#include "settings/settingspagebase.h" - -class QCheckBox; -class QComboBox; - -/** - * @brief Page for the enabling or disabling confirmation dialogs. - */ -class ConfirmationsSettingsPage : public SettingsPageBase -{ - Q_OBJECT - -public: - explicit ConfirmationsSettingsPage(QWidget *parent); - ~ConfirmationsSettingsPage() override; - - /** @see SettingsPageBase::applySettings() */ - void applySettings() override; - - /** @see SettingsPageBase::restoreDefaults() */ - void restoreDefaults() override; - -private: - void loadSettings(); - -private: - QCheckBox *m_confirmMoveToTrash; - QCheckBox *m_confirmEmptyTrash; - QCheckBox *m_confirmDelete; - -#if HAVE_TERMINAL - QCheckBox *m_confirmClosingTerminalRunningProgram; -#endif - - QCheckBox *m_confirmClosingMultipleTabs; - QComboBox *m_confirmScriptExecution; -}; - -#endif diff --git a/src/settings/general/generalsettingspage.cpp b/src/settings/general/generalsettingspage.cpp deleted file mode 100644 index 61c2e3adc..000000000 --- a/src/settings/general/generalsettingspage.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "generalsettingspage.h" - -#include "behaviorsettingspage.h" -#include "confirmationssettingspage.h" -#include "previewssettingspage.h" -#include "statusbarsettingspage.h" - -#include - -#include -#include - -GeneralSettingsPage::GeneralSettingsPage(const QUrl &url, QWidget *parent) - : SettingsPageBase(parent) - , m_pages() -{ - QVBoxLayout *topLayout = new QVBoxLayout(this); - topLayout->setContentsMargins(0, 0, 0, 0); - - QTabWidget *tabWidget = new QTabWidget(this); - - // initialize 'Behavior' tab - BehaviorSettingsPage *behaviorPage = new BehaviorSettingsPage(url, tabWidget); - tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior")); - connect(behaviorPage, &BehaviorSettingsPage::changed, this, &GeneralSettingsPage::changed); - - // initialize 'Previews' tab - PreviewsSettingsPage *previewsPage = new PreviewsSettingsPage(tabWidget); - tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews")); - connect(previewsPage, &PreviewsSettingsPage::changed, this, &GeneralSettingsPage::changed); - - // initialize 'Context Menu' tab - ConfirmationsSettingsPage *confirmationsPage = new ConfirmationsSettingsPage(tabWidget); - tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations")); - connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, &GeneralSettingsPage::changed); - - // initialize 'Status Bar' tab - StatusBarSettingsPage *statusBarPage = new StatusBarSettingsPage(tabWidget); - tabWidget->addTab(statusBarPage, i18nc("@title:tab Status Bar settings", "Status Bar")); - connect(statusBarPage, &StatusBarSettingsPage::changed, this, &GeneralSettingsPage::changed); - - m_pages.append(behaviorPage); - m_pages.append(previewsPage); - m_pages.append(confirmationsPage); - m_pages.append(statusBarPage); - - topLayout->addWidget(tabWidget, 0, {}); -} - -GeneralSettingsPage::~GeneralSettingsPage() -{ -} - -void GeneralSettingsPage::applySettings() -{ - for (SettingsPageBase *page : qAsConst(m_pages)) { - page->applySettings(); - } -} - -void GeneralSettingsPage::restoreDefaults() -{ - for (SettingsPageBase *page : qAsConst(m_pages)) { - page->restoreDefaults(); - } -} - -#include "moc_generalsettingspage.cpp" diff --git a/src/settings/general/generalsettingspage.h b/src/settings/general/generalsettingspage.h deleted file mode 100644 index bb9099af0..000000000 --- a/src/settings/general/generalsettingspage.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ -#ifndef GENERALSETTINGSPAGE_H -#define GENERALSETTINGSPAGE_H - -#include "settings/settingspagebase.h" - -#include - -class QUrl; -class SettingsPageBase; - -/** - * @brief Page for the 'General' settings of the Dolphin settings dialog. - * - * The general settings include: - * - Behavior - * - Previews - * - Context Menu - * - Status Bar - */ -class GeneralSettingsPage : public SettingsPageBase -{ - Q_OBJECT - -public: - GeneralSettingsPage(const QUrl &url, QWidget *parent); - ~GeneralSettingsPage() override; - - /** @see SettingsPageBase::applySettings() */ - void applySettings() override; - - /** @see SettingsPageBase::restoreDefaults() */ - void restoreDefaults() override; - -private: - QList m_pages; -}; - -#endif diff --git a/src/settings/general/previewssettingspage.cpp b/src/settings/general/previewssettingspage.cpp deleted file mode 100644 index ef98d0f8d..000000000 --- a/src/settings/general/previewssettingspage.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "previewssettingspage.h" - -#include "configurepreviewplugindialog.h" -#include "dolphin_generalsettings.h" -#include "settings/serviceitemdelegate.h" -#include "settings/servicemodel.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -// default settings -namespace -{ -const int DefaultMaxLocalPreviewSize = 0; // 0 MB -const int DefaultMaxRemotePreviewSize = 0; // 0 MB -} - -PreviewsSettingsPage::PreviewsSettingsPage(QWidget *parent) - : SettingsPageBase(parent) - , m_initialized(false) - , m_listView(nullptr) - , m_enabledPreviewPlugins() - , m_localFileSizeBox(nullptr) - , m_remoteFileSizeBox(nullptr) -{ - QVBoxLayout *topLayout = new QVBoxLayout(this); - - QLabel *showPreviewsLabel = new QLabel(i18nc("@title:group", "Show previews in the view for:"), this); - - m_listView = new QListView(this); - QScroller::grabGesture(m_listView->viewport(), QScroller::TouchGesture); - -#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) - ServiceItemDelegate *delegate = new ServiceItemDelegate(m_listView, m_listView); - connect(delegate, &ServiceItemDelegate::requestServiceConfiguration, this, &PreviewsSettingsPage::configureService); - m_listView->setItemDelegate(delegate); -#endif - - ServiceModel *serviceModel = new ServiceModel(this); - QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); - proxyModel->setSourceModel(serviceModel); - proxyModel->setSortRole(Qt::DisplayRole); - proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - - m_listView->setModel(proxyModel); - m_listView->setVerticalScrollMode(QListView::ScrollPerPixel); - m_listView->setUniformItemSizes(true); - - QLabel *localFileSizeLabel = new QLabel(i18n("Skip previews for local files above:"), this); - - m_localFileSizeBox = new QSpinBox(this); - m_localFileSizeBox->setSingleStep(1); - m_localFileSizeBox->setSuffix(i18nc("Mebibytes; used as a suffix in a spinbox showing e.g. '3 MiB'", " MiB")); - m_localFileSizeBox->setRange(0, 9999999); /* MB */ - m_localFileSizeBox->setSpecialValueText(i18n("No limit")); - - QHBoxLayout *localFileSizeBoxLayout = new QHBoxLayout(); - localFileSizeBoxLayout->addWidget(localFileSizeLabel); - localFileSizeBoxLayout->addStretch(0); - localFileSizeBoxLayout->addWidget(m_localFileSizeBox); - - QLabel *remoteFileSizeLabel = new QLabel(i18nc("@label", "Skip previews for remote files above:"), this); - - m_remoteFileSizeBox = new QSpinBox(this); - m_remoteFileSizeBox->setSingleStep(1); - m_remoteFileSizeBox->setSuffix(i18nc("Mebibytes; used as a suffix in a spinbox showing e.g. '3 MiB'", " MiB")); - m_remoteFileSizeBox->setRange(0, 9999999); /* MB */ - m_remoteFileSizeBox->setSpecialValueText(i18n("No previews")); - - QHBoxLayout *remoteFileSizeBoxLayout = new QHBoxLayout(); - remoteFileSizeBoxLayout->addWidget(remoteFileSizeLabel); - remoteFileSizeBoxLayout->addStretch(0); - remoteFileSizeBoxLayout->addWidget(m_remoteFileSizeBox); - - topLayout->addWidget(showPreviewsLabel); - topLayout->addWidget(m_listView); - topLayout->addLayout(localFileSizeBoxLayout); - topLayout->addLayout(remoteFileSizeBoxLayout); - - loadSettings(); - - connect(m_listView, &QListView::clicked, this, &PreviewsSettingsPage::changed); - connect(m_localFileSizeBox, &QSpinBox::valueChanged, this, &PreviewsSettingsPage::changed); - connect(m_remoteFileSizeBox, &QSpinBox::valueChanged, this, &PreviewsSettingsPage::changed); -} - -PreviewsSettingsPage::~PreviewsSettingsPage() -{ -} - -void PreviewsSettingsPage::applySettings() -{ - const QAbstractItemModel *model = m_listView->model(); - const int rowCount = model->rowCount(); - if (rowCount > 0) { - m_enabledPreviewPlugins.clear(); - for (int i = 0; i < rowCount; ++i) { - const QModelIndex index = model->index(i, 0); - const bool checked = model->data(index, Qt::CheckStateRole).toBool(); - if (checked) { - const QString enabledPlugin = model->data(index, Qt::UserRole).toString(); - m_enabledPreviewPlugins.append(enabledPlugin); - } - } - } - - KConfigGroup globalConfig(KSharedConfig::openConfig(), QStringLiteral("PreviewSettings")); - globalConfig.writeEntry("Plugins", m_enabledPreviewPlugins); - - if (!m_localFileSizeBox->value()) { - globalConfig.deleteEntry("MaximumSize", KConfigBase::Normal | KConfigBase::Global); - } else { - const qulonglong maximumLocalSize = static_cast(m_localFileSizeBox->value()) * 1024 * 1024; - globalConfig.writeEntry("MaximumSize", maximumLocalSize, KConfigBase::Normal | KConfigBase::Global); - } - - const qulonglong maximumRemoteSize = static_cast(m_remoteFileSizeBox->value()) * 1024 * 1024; - globalConfig.writeEntry("MaximumRemoteSize", maximumRemoteSize, KConfigBase::Normal | KConfigBase::Global); - - globalConfig.sync(); -} - -void PreviewsSettingsPage::restoreDefaults() -{ - m_localFileSizeBox->setValue(DefaultMaxLocalPreviewSize); - m_remoteFileSizeBox->setValue(DefaultMaxRemotePreviewSize); -} - -void PreviewsSettingsPage::showEvent(QShowEvent *event) -{ - if (!event->spontaneous() && !m_initialized) { - loadPreviewPlugins(); - m_initialized = true; - } - SettingsPageBase::showEvent(event); -} - -#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) -void PreviewsSettingsPage::configureService(const QModelIndex &index) -{ - const QAbstractItemModel *model = index.model(); - const QString pluginName = model->data(index).toString(); - const QString desktopEntryName = model->data(index, ServiceModel::DesktopEntryNameRole).toString(); - - ConfigurePreviewPluginDialog *dialog = new ConfigurePreviewPluginDialog(pluginName, desktopEntryName, this); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->show(); -} -#endif - -void PreviewsSettingsPage::loadPreviewPlugins() -{ - QAbstractItemModel *model = m_listView->model(); - - const QVector plugins = KIO::PreviewJob::availableThumbnailerPlugins(); - for (const KPluginMetaData &plugin : plugins) { - const bool show = m_enabledPreviewPlugins.contains(plugin.pluginId()); - - model->insertRow(0); - const QModelIndex index = model->index(0, 0); - model->setData(index, show, Qt::CheckStateRole); - model->setData(index, plugin.name(), Qt::DisplayRole); - model->setData(index, plugin.pluginId(), ServiceModel::DesktopEntryNameRole); - -#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) - const bool configurable = plugin.value(QStringLiteral("Configurable"), false); - model->setData(index, configurable, ServiceModel::ConfigurableRole); -#endif - } - - model->sort(Qt::DisplayRole); -} - -void PreviewsSettingsPage::loadSettings() -{ - const KConfigGroup globalConfig(KSharedConfig::openConfig(), QStringLiteral("PreviewSettings")); - m_enabledPreviewPlugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins()); - - const qulonglong defaultLocalPreview = static_cast(DefaultMaxLocalPreviewSize) * 1024 * 1024; - const qulonglong maxLocalByteSize = globalConfig.readEntry("MaximumSize", defaultLocalPreview); - const int maxLocalMByteSize = maxLocalByteSize / (1024 * 1024); - m_localFileSizeBox->setValue(maxLocalMByteSize); - - const qulonglong defaultRemotePreview = static_cast(DefaultMaxRemotePreviewSize) * 1024 * 1024; - const qulonglong maxRemoteByteSize = globalConfig.readEntry("MaximumRemoteSize", defaultRemotePreview); - const int maxRemoteMByteSize = maxRemoteByteSize / (1024 * 1024); - m_remoteFileSizeBox->setValue(maxRemoteMByteSize); -} - -#include "moc_previewssettingspage.cpp" diff --git a/src/settings/general/previewssettingspage.h b/src/settings/general/previewssettingspage.h deleted file mode 100644 index 2c3e4dfef..000000000 --- a/src/settings/general/previewssettingspage.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef PREVIEWSSETTINGSPAGE_H -#define PREVIEWSSETTINGSPAGE_H - -#include - -#include "settings/settingspagebase.h" - -class QSpinBox; -class QListView; -class QModelIndex; - -/** - * @brief Allows the configuration of file previews. - */ -class PreviewsSettingsPage : public SettingsPageBase -{ - Q_OBJECT - -public: - explicit PreviewsSettingsPage(QWidget *parent); - ~PreviewsSettingsPage() override; - - /** - * Applies the general settings for the view modes - * The settings are persisted automatically when - * closing Dolphin. - */ - void applySettings() override; - - /** Restores the settings to default values. */ - void restoreDefaults() override; - -protected: - void showEvent(QShowEvent *event) override; - -private Q_SLOTS: -#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) - void configureService(const QModelIndex &index); -#endif - -private: - void loadPreviewPlugins(); - void loadSettings(); - -private: - bool m_initialized; - QListView *m_listView; - QStringList m_enabledPreviewPlugins; - QSpinBox *m_localFileSizeBox; - QSpinBox *m_remoteFileSizeBox; -}; - -#endif diff --git a/src/settings/general/statusbarsettingspage.cpp b/src/settings/general/statusbarsettingspage.cpp deleted file mode 100644 index 40e34e4f6..000000000 --- a/src/settings/general/statusbarsettingspage.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2009 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "statusbarsettingspage.h" - -#include "dolphin_generalsettings.h" - -#include - -#include -#include - -StatusBarSettingsPage::StatusBarSettingsPage(QWidget *parent) - : SettingsPageBase(parent) - , m_showStatusBar(nullptr) - , m_showZoomSlider(nullptr) - , m_showSpaceInfo(nullptr) -{ - m_showStatusBar = new QCheckBox(i18nc("@option:check", "Show status bar"), this); - m_showZoomSlider = new QCheckBox(i18nc("@option:check", "Show zoom slider"), this); - m_showSpaceInfo = new QCheckBox(i18nc("@option:check", "Show space information"), this); - - QVBoxLayout *topLayout = new QVBoxLayout(this); - topLayout->addWidget(m_showStatusBar); - topLayout->addWidget(m_showZoomSlider); - topLayout->addWidget(m_showSpaceInfo); - topLayout->addStretch(); - - loadSettings(); - - connect(m_showStatusBar, &QCheckBox::toggled, this, &StatusBarSettingsPage::changed); - connect(m_showStatusBar, &QCheckBox::toggled, this, &StatusBarSettingsPage::onShowStatusBarToggled); - connect(m_showZoomSlider, &QCheckBox::toggled, this, &StatusBarSettingsPage::changed); - connect(m_showSpaceInfo, &QCheckBox::toggled, this, &StatusBarSettingsPage::changed); -} - -StatusBarSettingsPage::~StatusBarSettingsPage() -{ -} - -void StatusBarSettingsPage::onShowStatusBarToggled() -{ - const bool checked = m_showStatusBar->isChecked(); - m_showZoomSlider->setEnabled(checked); - m_showSpaceInfo->setEnabled(checked); -} - -void StatusBarSettingsPage::applySettings() -{ - GeneralSettings *settings = GeneralSettings::self(); - settings->setShowStatusBar(m_showStatusBar->isChecked()); - settings->setShowZoomSlider(m_showZoomSlider->isChecked()); - settings->setShowSpaceInfo(m_showSpaceInfo->isChecked()); - settings->save(); -} - -void StatusBarSettingsPage::restoreDefaults() -{ - GeneralSettings *settings = GeneralSettings::self(); - settings->useDefaults(true); - loadSettings(); - settings->useDefaults(false); -} - -void StatusBarSettingsPage::loadSettings() -{ - m_showStatusBar->setChecked(GeneralSettings::showStatusBar()); - m_showZoomSlider->setChecked(GeneralSettings::showZoomSlider()); - m_showSpaceInfo->setChecked(GeneralSettings::showSpaceInfo()); - - onShowStatusBarToggled(); -} - -#include "moc_statusbarsettingspage.cpp" diff --git a/src/settings/general/statusbarsettingspage.h b/src/settings/general/statusbarsettingspage.h deleted file mode 100644 index adff05dc1..000000000 --- a/src/settings/general/statusbarsettingspage.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2009 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ -#ifndef STATUSBARSETTINGSPAGE_H -#define STATUSBARSETTINGSPAGE_H - -#include "settings/settingspagebase.h" - -class QCheckBox; - -/** - * @brief Tab page for the 'Status Bar' settings of the Dolphin settings dialog. - */ -class StatusBarSettingsPage : public SettingsPageBase -{ - Q_OBJECT - -public: - explicit StatusBarSettingsPage(QWidget *parent); - ~StatusBarSettingsPage() override; - - /** @see SettingsPageBase::applySettings() */ - void applySettings() override; - - /** @see SettingsPageBase::restoreDefaults() */ - void restoreDefaults() override; - -private: - void loadSettings(); - void onShowStatusBarToggled(); - -private: - QCheckBox *m_showStatusBar; - QCheckBox *m_showZoomSlider; - QCheckBox *m_showSpaceInfo; -}; - -#endif diff --git a/src/settings/interface/configurepreviewplugindialog.cpp b/src/settings/interface/configurepreviewplugindialog.cpp new file mode 100644 index 000000000..8846d8261 --- /dev/null +++ b/src/settings/interface/configurepreviewplugindialog.cpp @@ -0,0 +1,73 @@ +/* + * SPDX-FileCopyrightText: 2011 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "configurepreviewplugindialog.h" + +#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString &pluginName, const QString &desktopEntryName, QWidget *parent) + : QDialog(parent) +{ + QSharedPointer previewPlugin; + const QString pluginPath = QPluginLoader(desktopEntryName).fileName(); + if (!pluginPath.isEmpty()) { + newCreator create = (newCreator)QLibrary::resolve(pluginPath, "new_creator"); + if (create) { + previewPlugin.reset(dynamic_cast(create())); + } + } + + setWindowTitle(i18nc("@title:window", "Configure Preview for %1", pluginName)); + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); + setMinimumWidth(400); + + auto layout = new QVBoxLayout(this); + + if (previewPlugin) { + auto configurationWidget = previewPlugin->createConfigurationWidget(); + configurationWidget->setParent(this); + layout->addWidget(configurationWidget); + + layout->addStretch(); + + connect(this, &ConfigurePreviewPluginDialog::accepted, this, [=] { + // TODO: It would be great having a mechanism to tell PreviewJob that only previews + // for a specific MIME-type should be regenerated. As this is not available yet we + // delete the whole thumbnails directory. + previewPlugin->writeConfiguration(configurationWidget); + + // https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#DIRECTORY + const QString thumbnailsPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/thumbnails/"); + KIO::del(QUrl::fromLocalFile(thumbnailsPath), KIO::HideProgressInfo); + }); + } + + auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); + connect(buttonBox, &QDialogButtonBox::accepted, this, &ConfigurePreviewPluginDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &ConfigurePreviewPluginDialog::reject); + layout->addWidget(buttonBox); + + auto okButton = buttonBox->button(QDialogButtonBox::Ok); + okButton->setShortcut(Qt::CTRL | Qt::Key_Return); + okButton->setDefault(true); +} + +#include "moc_configurepreviewplugindialog.cpp" + +#endif // KIO_VERSION diff --git a/src/settings/interface/configurepreviewplugindialog.h b/src/settings/interface/configurepreviewplugindialog.h new file mode 100644 index 000000000..66504cce2 --- /dev/null +++ b/src/settings/interface/configurepreviewplugindialog.h @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2011 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef CONFIGUREPREVIEWPLUGINDIALOG_H +#define CONFIGUREPREVIEWPLUGINDIALOG_H + +#include + +#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) + +#include + +/** + * @brief Dialog for configuring preview-plugins. + */ +class ConfigurePreviewPluginDialog : public QDialog +{ + Q_OBJECT + +public: + /** + * @param pluginName User visible name of the plugin + * @param desktopEntryName The name of the plugin that is noted in the desktopentry. + * Is used to instantiate the plugin to get the configuration + * widget. + * @param parent Parent widget. + */ + ConfigurePreviewPluginDialog(const QString &pluginName, const QString &desktopEntryName, QWidget *parent); + ~ConfigurePreviewPluginDialog() override = default; +}; +#endif // KIOWIDGETS_BUILD_DEPRECATED_SINCE + +#endif diff --git a/src/settings/interface/confirmationssettingspage.cpp b/src/settings/interface/confirmationssettingspage.cpp new file mode 100644 index 000000000..61c3a14b6 --- /dev/null +++ b/src/settings/interface/confirmationssettingspage.cpp @@ -0,0 +1,177 @@ +/* + * SPDX-FileCopyrightText: 2012 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "confirmationssettingspage.h" + +#include "dolphin_generalsettings.h" +#include "global.h" + +#include + +#include +#include +#include +#include +#include + +namespace +{ +enum ScriptExecution { AlwaysAsk = 0, Open = 1, Execute = 2 }; + +const bool ConfirmEmptyTrash = true; +const bool ConfirmTrash = false; +const bool ConfirmDelete = true; +const int ConfirmScriptExecution = ScriptExecution::AlwaysAsk; +} + +ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget *parent) + : SettingsPageBase(parent) + , m_confirmMoveToTrash(nullptr) + , m_confirmEmptyTrash(nullptr) + , m_confirmDelete(nullptr) + , + +#if HAVE_TERMINAL + m_confirmClosingTerminalRunningProgram(nullptr) + , +#endif + + m_confirmClosingMultipleTabs(nullptr) +{ + QVBoxLayout *topLayout = new QVBoxLayout(this); + + QLabel *confirmLabelKde = new QLabel(i18nc("@title:group", "Ask for confirmation in all KDE applications when:"), this); + confirmLabelKde->setWordWrap(true); + + m_confirmMoveToTrash = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Moving files or folders to trash"), this); + m_confirmEmptyTrash = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Emptying trash"), this); + m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for confirmation when", "Deleting files or folders"), this); + + QLabel *confirmLabelDolphin = new QLabel(i18nc("@title:group", "Ask for confirmation in Dolphin when:"), this); + confirmLabelDolphin->setWordWrap(true); + + m_confirmClosingMultipleTabs = new QCheckBox(i18nc("@option:check Ask for confirmation in Dolphin when", "Closing windows with multiple tabs"), this); + +#if HAVE_TERMINAL + m_confirmClosingTerminalRunningProgram = + new QCheckBox(i18nc("@option:check Ask for confirmation when", "Closing windows with a program running in the Terminal panel"), this); +#endif + + QHBoxLayout *executableScriptLayout = new QHBoxLayout(); + QLabel *executableScriptLabel = new QLabel(i18nc("@title:group", "When opening an executable file:"), this); + confirmLabelKde->setWordWrap(true); + executableScriptLayout->addWidget(executableScriptLabel); + + m_confirmScriptExecution = new QComboBox(this); + m_confirmScriptExecution->addItems({i18n("Always ask"), i18n("Open in application"), i18n("Run script")}); + executableScriptLayout->addWidget(m_confirmScriptExecution); + + topLayout->addWidget(confirmLabelKde); + topLayout->addWidget(m_confirmMoveToTrash); + topLayout->addWidget(m_confirmEmptyTrash); + topLayout->addWidget(m_confirmDelete); + topLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT); + topLayout->addWidget(confirmLabelDolphin); + topLayout->addWidget(m_confirmClosingMultipleTabs); + +#if HAVE_TERMINAL + topLayout->addWidget(m_confirmClosingTerminalRunningProgram); +#endif + + topLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT); + topLayout->addLayout(executableScriptLayout); + + topLayout->addStretch(); + + loadSettings(); + + connect(m_confirmMoveToTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); + connect(m_confirmEmptyTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); + connect(m_confirmDelete, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); + connect(m_confirmScriptExecution, QOverload::of(&QComboBox::currentIndexChanged), this, &ConfirmationsSettingsPage::changed); + connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); + +#if HAVE_TERMINAL + connect(m_confirmClosingTerminalRunningProgram, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); +#endif +} + +ConfirmationsSettingsPage::~ConfirmationsSettingsPage() +{ +} + +void ConfirmationsSettingsPage::applySettings() +{ + KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig(QStringLiteral("kiorc"), KConfig::NoGlobals); + KConfigGroup confirmationGroup(kioConfig, "Confirmations"); + confirmationGroup.writeEntry("ConfirmTrash", m_confirmMoveToTrash->isChecked()); + confirmationGroup.writeEntry("ConfirmEmptyTrash", m_confirmEmptyTrash->isChecked()); + confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked()); + + KConfigGroup scriptExecutionGroup(kioConfig, "Executable scripts"); + const int index = m_confirmScriptExecution->currentIndex(); + switch (index) { + case ScriptExecution::AlwaysAsk: + scriptExecutionGroup.writeEntry("behaviourOnLaunch", "alwaysAsk"); + break; + case ScriptExecution::Open: + scriptExecutionGroup.writeEntry("behaviourOnLaunch", "open"); + break; + case ScriptExecution::Execute: + scriptExecutionGroup.writeEntry("behaviourOnLaunch", "execute"); + break; + } + kioConfig->sync(); + + GeneralSettings *settings = GeneralSettings::self(); + settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked()); + +#if HAVE_TERMINAL + settings->setConfirmClosingTerminalRunningProgram(m_confirmClosingTerminalRunningProgram->isChecked()); +#endif + + settings->save(); +} + +void ConfirmationsSettingsPage::restoreDefaults() +{ + GeneralSettings *settings = GeneralSettings::self(); + settings->useDefaults(true); + loadSettings(); + settings->useDefaults(false); + + m_confirmMoveToTrash->setChecked(ConfirmTrash); + m_confirmEmptyTrash->setChecked(ConfirmEmptyTrash); + m_confirmDelete->setChecked(ConfirmDelete); + m_confirmScriptExecution->setCurrentIndex(ConfirmScriptExecution); +} + +void ConfirmationsSettingsPage::loadSettings() +{ + KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig(QStringLiteral("kiorc"), KConfig::IncludeGlobals); + const KConfigGroup confirmationGroup(kioConfig, "Confirmations"); + m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", ConfirmTrash)); + m_confirmEmptyTrash->setChecked(confirmationGroup.readEntry("ConfirmEmptyTrash", ConfirmEmptyTrash)); + m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", ConfirmDelete)); + + const KConfigGroup scriptExecutionGroup(KSharedConfig::openConfig(QStringLiteral("kiorc")), "Executable scripts"); + const QString value = scriptExecutionGroup.readEntry("behaviourOnLaunch", "alwaysAsk"); + if (value == QLatin1String("alwaysAsk")) { + m_confirmScriptExecution->setCurrentIndex(ScriptExecution::AlwaysAsk); + } else if (value == QLatin1String("execute")) { + m_confirmScriptExecution->setCurrentIndex(ScriptExecution::Execute); + } else /* if (value == QLatin1String("open"))*/ { + m_confirmScriptExecution->setCurrentIndex(ScriptExecution::Open); + } + + m_confirmClosingMultipleTabs->setChecked(GeneralSettings::confirmClosingMultipleTabs()); + +#if HAVE_TERMINAL + m_confirmClosingTerminalRunningProgram->setChecked(GeneralSettings::confirmClosingTerminalRunningProgram()); +#endif +} + +#include "moc_confirmationssettingspage.cpp" diff --git a/src/settings/interface/confirmationssettingspage.h b/src/settings/interface/confirmationssettingspage.h new file mode 100644 index 000000000..56dd1a78c --- /dev/null +++ b/src/settings/interface/confirmationssettingspage.h @@ -0,0 +1,48 @@ +/* + * SPDX-FileCopyrightText: 2012 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef CONFIRMATIONSSETTINGSPAGE_H +#define CONFIRMATIONSSETTINGSPAGE_H + +#include "config-dolphin.h" +#include "settings/settingspagebase.h" + +class QCheckBox; +class QComboBox; + +/** + * @brief Page for the enabling or disabling confirmation dialogs. + */ +class ConfirmationsSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + explicit ConfirmationsSettingsPage(QWidget *parent); + ~ConfirmationsSettingsPage() override; + + /** @see SettingsPageBase::applySettings() */ + void applySettings() override; + + /** @see SettingsPageBase::restoreDefaults() */ + void restoreDefaults() override; + +private: + void loadSettings(); + +private: + QCheckBox *m_confirmMoveToTrash; + QCheckBox *m_confirmEmptyTrash; + QCheckBox *m_confirmDelete; + +#if HAVE_TERMINAL + QCheckBox *m_confirmClosingTerminalRunningProgram; +#endif + + QCheckBox *m_confirmClosingMultipleTabs; + QComboBox *m_confirmScriptExecution; +}; + +#endif diff --git a/src/settings/interface/folderstabssettingspage.cpp b/src/settings/interface/folderstabssettingspage.cpp new file mode 100644 index 000000000..d71ad2d96 --- /dev/null +++ b/src/settings/interface/folderstabssettingspage.cpp @@ -0,0 +1,263 @@ +/* + * SPDX-FileCopyrightText: 2006 Peter Penz (peter.penz@gmx.at) and Patrice Tremblay + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "folderstabssettingspage.h" +#include "dolphinmainwindow.h" +#include "dolphinviewcontainer.h" +#include "global.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +FoldersTabsSettingsPage::FoldersTabsSettingsPage(QWidget *parent) + : SettingsPageBase(parent) + , m_homeUrlBoxLayoutContainer(nullptr) + , m_buttonBoxLayoutContainer(nullptr) + , m_homeUrlRadioButton(nullptr) + , m_homeUrl(nullptr) + , m_rememberOpenedTabsRadioButton(nullptr) + , m_openNewTabAfterLastTab(nullptr) + , m_openNewTabAfterCurrentTab(nullptr) + , m_splitView(nullptr) + , m_filterBar(nullptr) + , m_showFullPathInTitlebar(nullptr) + , m_openExternallyCalledFolderInNewTab(nullptr) + , m_useTabForSplitViewSwitch(nullptr) +{ + QFormLayout *topLayout = new QFormLayout(this); + + // Show on startup + m_rememberOpenedTabsRadioButton = new QRadioButton(i18nc("@option:radio Show on startup", "Folders, tabs, and window state from last time")); + m_homeUrlRadioButton = new QRadioButton(); + // HACK: otherwise the radio button has too much spacing in a grid layout + m_homeUrlRadioButton->setMaximumWidth(24); + + QButtonGroup *initialViewGroup = new QButtonGroup(this); + initialViewGroup->addButton(m_rememberOpenedTabsRadioButton); + initialViewGroup->addButton(m_homeUrlRadioButton); + + // create 'Home URL' editor + m_homeUrlBoxLayoutContainer = new QWidget(this); + QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(m_homeUrlBoxLayoutContainer); + homeUrlBoxLayout->setContentsMargins(0, 0, 0, 0); + + m_homeUrl = new QLineEdit(); + m_homeUrl->setClearButtonEnabled(true); + homeUrlBoxLayout->addWidget(m_homeUrl); + + QPushButton *selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString()); + homeUrlBoxLayout->addWidget(selectHomeUrlButton); + +#ifndef QT_NO_ACCESSIBILITY + selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); +#endif + + connect(selectHomeUrlButton, &QPushButton::clicked, this, &FoldersTabsSettingsPage::selectHomeUrl); + + m_buttonBoxLayoutContainer = new QWidget(this); + QHBoxLayout *buttonBoxLayout = new QHBoxLayout(m_buttonBoxLayoutContainer); + buttonBoxLayout->setContentsMargins(0, 0, 0, 0); + + QPushButton *useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location")); + buttonBoxLayout->addWidget(useCurrentButton); + connect(useCurrentButton, &QPushButton::clicked, this, &FoldersTabsSettingsPage::useCurrentLocation); + QPushButton *useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location")); + buttonBoxLayout->addWidget(useDefaultButton); + connect(useDefaultButton, &QPushButton::clicked, this, &FoldersTabsSettingsPage::useDefaultLocation); + + QGridLayout *startInLocationLayout = new QGridLayout(); + startInLocationLayout->setHorizontalSpacing(0); + startInLocationLayout->setContentsMargins(0, 0, 0, 0); + startInLocationLayout->addWidget(m_homeUrlRadioButton, 0, 0); + startInLocationLayout->addWidget(m_homeUrlBoxLayoutContainer, 0, 1); + startInLocationLayout->addWidget(m_buttonBoxLayoutContainer, 1, 1); + + topLayout->addRow(i18nc("@label:textbox", "Show on startup:"), m_rememberOpenedTabsRadioButton); + topLayout->addRow(QString(), startInLocationLayout); + + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); + // Opening Folders + m_openExternallyCalledFolderInNewTab = new QCheckBox(i18nc("@option:check Opening Folders", "Keep a single Dolphin window, opening new folders in tabs")); + topLayout->addRow(i18nc("@label:checkbox", "Opening Folders:"), m_openExternallyCalledFolderInNewTab); + // Window + m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar")); + topLayout->addRow(i18nc("@label:checkbox", "Window:"), m_showFullPathInTitlebar); + m_filterBar = new QCheckBox(i18nc("@option:check Window Startup Settings", "Show filter bar")); + topLayout->addRow(QString(), m_filterBar); + + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); + + // Tabs properties + m_openNewTabAfterCurrentTab = new QRadioButton(i18nc("option:radio", "After current tab")); + m_openNewTabAfterLastTab = new QRadioButton(i18nc("option:radio", "At end of tab bar")); + QButtonGroup *tabsBehaviorGroup = new QButtonGroup(this); + tabsBehaviorGroup->addButton(m_openNewTabAfterCurrentTab); + tabsBehaviorGroup->addButton(m_openNewTabAfterLastTab); + topLayout->addRow(i18nc("@title:group", "Open new tabs: "), m_openNewTabAfterCurrentTab); + topLayout->addRow(QString(), m_openNewTabAfterLastTab); + + // Split Views + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); + + // 'Switch between panes of split views with tab key' + m_useTabForSplitViewSwitch = new QCheckBox(i18nc("option:check split view panes", "Switch between panes with Tab key")); + topLayout->addRow(i18nc("@title:group", "Split view: "), m_useTabForSplitViewSwitch); + + // 'Close active pane when turning off split view' + m_closeActiveSplitView = new QCheckBox(i18nc("option:check", "Turning off split view closes active pane")); + topLayout->addRow(QString(), m_closeActiveSplitView); + m_closeActiveSplitView->setToolTip(i18n("When deactivated, turning off split view will close the inactive pane")); + + // 'Begin in split view mode' + m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Begin in split view mode")); + topLayout->addRow(i18n("New windows:"), m_splitView); + + loadSettings(); + + updateInitialViewOptions(); + + connect(m_homeUrl, &QLineEdit::textChanged, this, &FoldersTabsSettingsPage::slotSettingsChanged); + connect(m_rememberOpenedTabsRadioButton, &QRadioButton::toggled, this, &FoldersTabsSettingsPage::slotSettingsChanged); + connect(m_homeUrlRadioButton, &QRadioButton::toggled, this, &FoldersTabsSettingsPage::slotSettingsChanged); + + connect(m_splitView, &QCheckBox::toggled, this, &FoldersTabsSettingsPage::slotSettingsChanged); + connect(m_filterBar, &QCheckBox::toggled, this, &FoldersTabsSettingsPage::slotSettingsChanged); + + connect(m_openExternallyCalledFolderInNewTab, &QCheckBox::toggled, this, &FoldersTabsSettingsPage::slotSettingsChanged); + connect(m_showFullPathInTitlebar, &QCheckBox::toggled, this, &FoldersTabsSettingsPage::slotSettingsChanged); + + connect(m_useTabForSplitViewSwitch, &QCheckBox::toggled, this, &FoldersTabsSettingsPage::changed); + connect(m_closeActiveSplitView, &QCheckBox::toggled, this, &FoldersTabsSettingsPage::changed); + + connect(m_openNewTabAfterCurrentTab, &QRadioButton::toggled, this, &FoldersTabsSettingsPage::changed); + connect(m_openNewTabAfterLastTab, &QRadioButton::toggled, this, &FoldersTabsSettingsPage::changed); +} + +FoldersTabsSettingsPage::~FoldersTabsSettingsPage() +{ +} + +void FoldersTabsSettingsPage::applySettings() +{ + GeneralSettings *settings = GeneralSettings::self(); + + settings->setUseTabForSwitchingSplitView(m_useTabForSplitViewSwitch->isChecked()); + settings->setCloseActiveSplitView(m_closeActiveSplitView->isChecked()); + const QUrl url(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile)); + if (url.isValid() && KProtocolManager::supportsListing(url)) { + KIO::StatJob *job = KIO::statDetails(url, KIO::StatJob::SourceSide, KIO::StatDetail::StatBasic, KIO::JobFlag::HideProgressInfo); + connect(job, &KJob::result, this, [this, settings, url](KJob *job) { + if (job->error() == 0 && qobject_cast(job)->statResult().isDir()) { + settings->setHomeUrl(url.toDisplayString(QUrl::PreferLocalFile)); + } else { + showSetDefaultDirectoryError(); + } + }); + } else { + showSetDefaultDirectoryError(); + } + + // Remove saved state if "remember open tabs" has been turned off + if (!m_rememberOpenedTabsRadioButton->isChecked()) { + KConfigGroup windowState{KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "WindowState"}; + if (windowState.exists()) { + windowState.deleteGroup(); + } + } + + settings->setRememberOpenedTabs(m_rememberOpenedTabsRadioButton->isChecked()); + settings->setSplitView(m_splitView->isChecked()); + settings->setFilterBar(m_filterBar->isChecked()); + settings->setOpenExternallyCalledFolderInNewTab(m_openExternallyCalledFolderInNewTab->isChecked()); + settings->setShowFullPathInTitlebar(m_showFullPathInTitlebar->isChecked()); + + settings->setOpenNewTabAfterLastTab(m_openNewTabAfterLastTab->isChecked()); + + settings->save(); +} + +void FoldersTabsSettingsPage::restoreDefaults() +{ + GeneralSettings *settings = GeneralSettings::self(); + settings->useDefaults(true); + loadSettings(); + settings->useDefaults(false); +} + +void FoldersTabsSettingsPage::slotSettingsChanged() +{ + // Provide a hint that the startup settings have been changed. This allows the views + // to apply the startup settings only if they have been explicitly changed by the user + // (see bug #254947). + GeneralSettings::setModifiedStartupSettings(true); + + // Enable and disable home URL controls appropriately + updateInitialViewOptions(); + Q_EMIT changed(); +} + +void FoldersTabsSettingsPage::updateInitialViewOptions() +{ + m_homeUrlBoxLayoutContainer->setEnabled(m_homeUrlRadioButton->isChecked()); + m_buttonBoxLayoutContainer->setEnabled(m_homeUrlRadioButton->isChecked()); +} + +void FoldersTabsSettingsPage::selectHomeUrl() +{ + const QUrl homeUrl(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile)); + QUrl url = QFileDialog::getExistingDirectoryUrl(this, QString(), homeUrl); + if (!url.isEmpty()) { + m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile)); + slotSettingsChanged(); + } +} + +void FoldersTabsSettingsPage::useCurrentLocation() +{ + m_homeUrl->setText(m_url.toDisplayString(QUrl::PreferLocalFile)); +} + +void FoldersTabsSettingsPage::useDefaultLocation() +{ + m_homeUrl->setText(QDir::homePath()); +} + +void FoldersTabsSettingsPage::loadSettings() +{ + const QUrl url(Dolphin::homeUrl()); + m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile)); + m_rememberOpenedTabsRadioButton->setChecked(GeneralSettings::rememberOpenedTabs()); + m_homeUrlRadioButton->setChecked(!GeneralSettings::rememberOpenedTabs()); + m_splitView->setChecked(GeneralSettings::splitView()); + m_filterBar->setChecked(GeneralSettings::filterBar()); + m_showFullPathInTitlebar->setChecked(GeneralSettings::showFullPathInTitlebar()); + m_openExternallyCalledFolderInNewTab->setChecked(GeneralSettings::openExternallyCalledFolderInNewTab()); + + m_useTabForSplitViewSwitch->setChecked(GeneralSettings::useTabForSwitchingSplitView()); + m_closeActiveSplitView->setChecked(GeneralSettings::closeActiveSplitView()); + + m_openNewTabAfterLastTab->setChecked(GeneralSettings::openNewTabAfterLastTab()); + m_openNewTabAfterCurrentTab->setChecked(!m_openNewTabAfterLastTab->isChecked()); +} + +void FoldersTabsSettingsPage::showSetDefaultDirectoryError() +{ + KMessageBox::error(this, i18nc("@info", "The location for the home folder is invalid or does not exist, it will not be applied.")); +} + +#include "moc_folderstabssettingspage.cpp" diff --git a/src/settings/interface/folderstabssettingspage.h b/src/settings/interface/folderstabssettingspage.h new file mode 100644 index 000000000..89e5c0982 --- /dev/null +++ b/src/settings/interface/folderstabssettingspage.h @@ -0,0 +1,69 @@ +/* + * SPDX-FileCopyrightText: 2008 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef FOLDERSTABSSETTINGSPAGE_H +#define FOLDERSTABSSETTINGSPAGE_H + +#include "dolphin_generalsettings.h" +#include "settings/settingspagebase.h" + +#include +#include + +class QCheckBox; +class QLineEdit; +class QLabel; +class QRadioButton; + +/** + * @brief Tab page for the 'Behavior' settings of the Dolphin settings dialog. + */ +class FoldersTabsSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + FoldersTabsSettingsPage(QWidget *parent); + ~FoldersTabsSettingsPage() override; + + /** @see SettingsPageBase::applySettings() */ + void applySettings() override; + + /** @see SettingsPageBase::restoreDefaults() */ + void restoreDefaults() override; + +public: + QWidget *m_homeUrlBoxLayoutContainer; + QWidget *m_buttonBoxLayoutContainer; + QRadioButton *m_homeUrlRadioButton; + +private Q_SLOTS: + void slotSettingsChanged(); + void updateInitialViewOptions(); + void selectHomeUrl(); + void useCurrentLocation(); + void useDefaultLocation(); + +private: + void loadSettings(); + void showSetDefaultDirectoryError(); + +private: + QUrl m_url; + QLineEdit *m_homeUrl; + QRadioButton *m_rememberOpenedTabsRadioButton; + + QRadioButton *m_openNewTabAfterLastTab; + QRadioButton *m_openNewTabAfterCurrentTab; + + QCheckBox *m_splitView; + QCheckBox *m_filterBar; + QCheckBox *m_showFullPathInTitlebar; + QCheckBox *m_openExternallyCalledFolderInNewTab; + QCheckBox *m_useTabForSplitViewSwitch; + QCheckBox *m_closeActiveSplitView; +}; + +#endif diff --git a/src/settings/interface/interfacesettingspage.cpp b/src/settings/interface/interfacesettingspage.cpp new file mode 100644 index 000000000..e941cf467 --- /dev/null +++ b/src/settings/interface/interfacesettingspage.cpp @@ -0,0 +1,74 @@ +/* + * SPDX-FileCopyrightText: 2006 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "interfacesettingspage.h" + +#include "confirmationssettingspage.h" +#include "folderstabssettingspage.h" +#include "previewssettingspage.h" +#include "statusandlocationbarssettingspage.h" + +#include + +#include +#include + +InterfaceSettingsPage::InterfaceSettingsPage(QWidget *parent) + : SettingsPageBase(parent) + , m_pages() +{ + QVBoxLayout *topLayout = new QVBoxLayout(this); + topLayout->setContentsMargins(0, 0, 0, 0); + + QTabWidget *tabWidget = new QTabWidget(this); + + // initialize 'Folders & Tabs' tab + FoldersTabsSettingsPage *foldersTabsPage = new FoldersTabsSettingsPage(tabWidget); + tabWidget->addTab(foldersTabsPage, i18nc("@title:tab Folders & Tabs settings", "Folders && Tabs")); + connect(foldersTabsPage, &FoldersTabsSettingsPage::changed, this, &InterfaceSettingsPage::changed); + + // initialize 'Previews' tab + PreviewsSettingsPage *previewsPage = new PreviewsSettingsPage(tabWidget); + tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews")); + connect(previewsPage, &PreviewsSettingsPage::changed, this, &InterfaceSettingsPage::changed); + + // initialize 'Context Menu' tab + ConfirmationsSettingsPage *confirmationsPage = new ConfirmationsSettingsPage(tabWidget); + tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations")); + connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, &InterfaceSettingsPage::changed); + + // initialize 'Status & location bars' tab + StatusAndLocationBarsSettingsPage *statusAndLocationBarsPage = new StatusAndLocationBarsSettingsPage(tabWidget, foldersTabsPage); + tabWidget->addTab(statusAndLocationBarsPage, i18nc("@title:tab Status & Location bars settings", "Status && Location bars")); + connect(statusAndLocationBarsPage, &StatusAndLocationBarsSettingsPage::changed, this, &InterfaceSettingsPage::changed); + + m_pages.append(foldersTabsPage); + m_pages.append(previewsPage); + m_pages.append(confirmationsPage); + m_pages.append(statusAndLocationBarsPage); + + topLayout->addWidget(tabWidget, 0, {}); +} + +InterfaceSettingsPage::~InterfaceSettingsPage() +{ +} + +void InterfaceSettingsPage::applySettings() +{ + for (SettingsPageBase *page : qAsConst(m_pages)) { + page->applySettings(); + } +} + +void InterfaceSettingsPage::restoreDefaults() +{ + for (SettingsPageBase *page : qAsConst(m_pages)) { + page->restoreDefaults(); + } +} + +#include "moc_interfacesettingspage.cpp" diff --git a/src/settings/interface/interfacesettingspage.h b/src/settings/interface/interfacesettingspage.h new file mode 100644 index 000000000..1faee1afb --- /dev/null +++ b/src/settings/interface/interfacesettingspage.h @@ -0,0 +1,42 @@ +/* + * SPDX-FileCopyrightText: 2006 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef INTERFACESETTINGSPAGE_H +#define INTERFACESETTINGSPAGE_H + +#include "settings/settingspagebase.h" + +#include + +class QUrl; +class SettingsPageBase; + +/** + * @brief Page for the 'Interface' settings of the Dolphin settings dialog. + * + * The interface settings include: + * - Folders & Tabs + * - Previews + * - Context Menu + */ +class InterfaceSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + InterfaceSettingsPage(QWidget *parent); + ~InterfaceSettingsPage() override; + + /** @see SettingsPageBase::applySettings() */ + void applySettings() override; + + /** @see SettingsPageBase::restoreDefaults() */ + void restoreDefaults() override; + +private: + QList m_pages; +}; + +#endif diff --git a/src/settings/interface/previewssettingspage.cpp b/src/settings/interface/previewssettingspage.cpp new file mode 100644 index 000000000..ef98d0f8d --- /dev/null +++ b/src/settings/interface/previewssettingspage.cpp @@ -0,0 +1,205 @@ +/* + * SPDX-FileCopyrightText: 2006 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "previewssettingspage.h" + +#include "configurepreviewplugindialog.h" +#include "dolphin_generalsettings.h" +#include "settings/serviceitemdelegate.h" +#include "settings/servicemodel.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +// default settings +namespace +{ +const int DefaultMaxLocalPreviewSize = 0; // 0 MB +const int DefaultMaxRemotePreviewSize = 0; // 0 MB +} + +PreviewsSettingsPage::PreviewsSettingsPage(QWidget *parent) + : SettingsPageBase(parent) + , m_initialized(false) + , m_listView(nullptr) + , m_enabledPreviewPlugins() + , m_localFileSizeBox(nullptr) + , m_remoteFileSizeBox(nullptr) +{ + QVBoxLayout *topLayout = new QVBoxLayout(this); + + QLabel *showPreviewsLabel = new QLabel(i18nc("@title:group", "Show previews in the view for:"), this); + + m_listView = new QListView(this); + QScroller::grabGesture(m_listView->viewport(), QScroller::TouchGesture); + +#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) + ServiceItemDelegate *delegate = new ServiceItemDelegate(m_listView, m_listView); + connect(delegate, &ServiceItemDelegate::requestServiceConfiguration, this, &PreviewsSettingsPage::configureService); + m_listView->setItemDelegate(delegate); +#endif + + ServiceModel *serviceModel = new ServiceModel(this); + QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); + proxyModel->setSourceModel(serviceModel); + proxyModel->setSortRole(Qt::DisplayRole); + proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + + m_listView->setModel(proxyModel); + m_listView->setVerticalScrollMode(QListView::ScrollPerPixel); + m_listView->setUniformItemSizes(true); + + QLabel *localFileSizeLabel = new QLabel(i18n("Skip previews for local files above:"), this); + + m_localFileSizeBox = new QSpinBox(this); + m_localFileSizeBox->setSingleStep(1); + m_localFileSizeBox->setSuffix(i18nc("Mebibytes; used as a suffix in a spinbox showing e.g. '3 MiB'", " MiB")); + m_localFileSizeBox->setRange(0, 9999999); /* MB */ + m_localFileSizeBox->setSpecialValueText(i18n("No limit")); + + QHBoxLayout *localFileSizeBoxLayout = new QHBoxLayout(); + localFileSizeBoxLayout->addWidget(localFileSizeLabel); + localFileSizeBoxLayout->addStretch(0); + localFileSizeBoxLayout->addWidget(m_localFileSizeBox); + + QLabel *remoteFileSizeLabel = new QLabel(i18nc("@label", "Skip previews for remote files above:"), this); + + m_remoteFileSizeBox = new QSpinBox(this); + m_remoteFileSizeBox->setSingleStep(1); + m_remoteFileSizeBox->setSuffix(i18nc("Mebibytes; used as a suffix in a spinbox showing e.g. '3 MiB'", " MiB")); + m_remoteFileSizeBox->setRange(0, 9999999); /* MB */ + m_remoteFileSizeBox->setSpecialValueText(i18n("No previews")); + + QHBoxLayout *remoteFileSizeBoxLayout = new QHBoxLayout(); + remoteFileSizeBoxLayout->addWidget(remoteFileSizeLabel); + remoteFileSizeBoxLayout->addStretch(0); + remoteFileSizeBoxLayout->addWidget(m_remoteFileSizeBox); + + topLayout->addWidget(showPreviewsLabel); + topLayout->addWidget(m_listView); + topLayout->addLayout(localFileSizeBoxLayout); + topLayout->addLayout(remoteFileSizeBoxLayout); + + loadSettings(); + + connect(m_listView, &QListView::clicked, this, &PreviewsSettingsPage::changed); + connect(m_localFileSizeBox, &QSpinBox::valueChanged, this, &PreviewsSettingsPage::changed); + connect(m_remoteFileSizeBox, &QSpinBox::valueChanged, this, &PreviewsSettingsPage::changed); +} + +PreviewsSettingsPage::~PreviewsSettingsPage() +{ +} + +void PreviewsSettingsPage::applySettings() +{ + const QAbstractItemModel *model = m_listView->model(); + const int rowCount = model->rowCount(); + if (rowCount > 0) { + m_enabledPreviewPlugins.clear(); + for (int i = 0; i < rowCount; ++i) { + const QModelIndex index = model->index(i, 0); + const bool checked = model->data(index, Qt::CheckStateRole).toBool(); + if (checked) { + const QString enabledPlugin = model->data(index, Qt::UserRole).toString(); + m_enabledPreviewPlugins.append(enabledPlugin); + } + } + } + + KConfigGroup globalConfig(KSharedConfig::openConfig(), QStringLiteral("PreviewSettings")); + globalConfig.writeEntry("Plugins", m_enabledPreviewPlugins); + + if (!m_localFileSizeBox->value()) { + globalConfig.deleteEntry("MaximumSize", KConfigBase::Normal | KConfigBase::Global); + } else { + const qulonglong maximumLocalSize = static_cast(m_localFileSizeBox->value()) * 1024 * 1024; + globalConfig.writeEntry("MaximumSize", maximumLocalSize, KConfigBase::Normal | KConfigBase::Global); + } + + const qulonglong maximumRemoteSize = static_cast(m_remoteFileSizeBox->value()) * 1024 * 1024; + globalConfig.writeEntry("MaximumRemoteSize", maximumRemoteSize, KConfigBase::Normal | KConfigBase::Global); + + globalConfig.sync(); +} + +void PreviewsSettingsPage::restoreDefaults() +{ + m_localFileSizeBox->setValue(DefaultMaxLocalPreviewSize); + m_remoteFileSizeBox->setValue(DefaultMaxRemotePreviewSize); +} + +void PreviewsSettingsPage::showEvent(QShowEvent *event) +{ + if (!event->spontaneous() && !m_initialized) { + loadPreviewPlugins(); + m_initialized = true; + } + SettingsPageBase::showEvent(event); +} + +#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) +void PreviewsSettingsPage::configureService(const QModelIndex &index) +{ + const QAbstractItemModel *model = index.model(); + const QString pluginName = model->data(index).toString(); + const QString desktopEntryName = model->data(index, ServiceModel::DesktopEntryNameRole).toString(); + + ConfigurePreviewPluginDialog *dialog = new ConfigurePreviewPluginDialog(pluginName, desktopEntryName, this); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); +} +#endif + +void PreviewsSettingsPage::loadPreviewPlugins() +{ + QAbstractItemModel *model = m_listView->model(); + + const QVector plugins = KIO::PreviewJob::availableThumbnailerPlugins(); + for (const KPluginMetaData &plugin : plugins) { + const bool show = m_enabledPreviewPlugins.contains(plugin.pluginId()); + + model->insertRow(0); + const QModelIndex index = model->index(0, 0); + model->setData(index, show, Qt::CheckStateRole); + model->setData(index, plugin.name(), Qt::DisplayRole); + model->setData(index, plugin.pluginId(), ServiceModel::DesktopEntryNameRole); + +#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) + const bool configurable = plugin.value(QStringLiteral("Configurable"), false); + model->setData(index, configurable, ServiceModel::ConfigurableRole); +#endif + } + + model->sort(Qt::DisplayRole); +} + +void PreviewsSettingsPage::loadSettings() +{ + const KConfigGroup globalConfig(KSharedConfig::openConfig(), QStringLiteral("PreviewSettings")); + m_enabledPreviewPlugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins()); + + const qulonglong defaultLocalPreview = static_cast(DefaultMaxLocalPreviewSize) * 1024 * 1024; + const qulonglong maxLocalByteSize = globalConfig.readEntry("MaximumSize", defaultLocalPreview); + const int maxLocalMByteSize = maxLocalByteSize / (1024 * 1024); + m_localFileSizeBox->setValue(maxLocalMByteSize); + + const qulonglong defaultRemotePreview = static_cast(DefaultMaxRemotePreviewSize) * 1024 * 1024; + const qulonglong maxRemoteByteSize = globalConfig.readEntry("MaximumRemoteSize", defaultRemotePreview); + const int maxRemoteMByteSize = maxRemoteByteSize / (1024 * 1024); + m_remoteFileSizeBox->setValue(maxRemoteMByteSize); +} + +#include "moc_previewssettingspage.cpp" diff --git a/src/settings/interface/previewssettingspage.h b/src/settings/interface/previewssettingspage.h new file mode 100644 index 000000000..2c3e4dfef --- /dev/null +++ b/src/settings/interface/previewssettingspage.h @@ -0,0 +1,59 @@ +/* + * SPDX-FileCopyrightText: 2006 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef PREVIEWSSETTINGSPAGE_H +#define PREVIEWSSETTINGSPAGE_H + +#include + +#include "settings/settingspagebase.h" + +class QSpinBox; +class QListView; +class QModelIndex; + +/** + * @brief Allows the configuration of file previews. + */ +class PreviewsSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + explicit PreviewsSettingsPage(QWidget *parent); + ~PreviewsSettingsPage() override; + + /** + * Applies the general settings for the view modes + * The settings are persisted automatically when + * closing Dolphin. + */ + void applySettings() override; + + /** Restores the settings to default values. */ + void restoreDefaults() override; + +protected: + void showEvent(QShowEvent *event) override; + +private Q_SLOTS: +#if KIOWIDGETS_BUILD_DEPRECATED_SINCE(5, 87) + void configureService(const QModelIndex &index); +#endif + +private: + void loadPreviewPlugins(); + void loadSettings(); + +private: + bool m_initialized; + QListView *m_listView; + QStringList m_enabledPreviewPlugins; + QSpinBox *m_localFileSizeBox; + QSpinBox *m_remoteFileSizeBox; +}; + +#endif diff --git a/src/settings/interface/statusandlocationbarssettingspage.cpp b/src/settings/interface/statusandlocationbarssettingspage.cpp new file mode 100644 index 000000000..5e0536a6e --- /dev/null +++ b/src/settings/interface/statusandlocationbarssettingspage.cpp @@ -0,0 +1,128 @@ +/* + * SPDX-FileCopyrightText: 2023 Dimosthenis Krallis + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "statusandlocationbarssettingspage.h" +#include "dolphinmainwindow.h" +#include "dolphinviewcontainer.h" +#include "settings/interface/folderstabssettingspage.h" + +#include + +#include +#include + +#include +#include + +StatusAndLocationBarsSettingsPage::StatusAndLocationBarsSettingsPage(QWidget *parent, FoldersTabsSettingsPage *foldersPage) + : SettingsPageBase(parent) + , m_editableUrl(nullptr) + , m_showFullPath(nullptr) + , m_showStatusBar(nullptr) + , m_showZoomSlider(nullptr) + , m_showSpaceInfo(nullptr) +{ + // We need to update some urls at the Folders & Tabs tab. We get that from foldersPage and set it on a private attribute + // foldersTabsPage. That way, we can modify the necessary stuff from here. Specifically, any changes on locationUpdateInitialViewOptions() + // which is a copy of updateInitialViewOptions() on Folders & Tabs. + foldersTabsPage = foldersPage; + + QFormLayout *topLayout = new QFormLayout(this); + + // Status bar + m_showStatusBar = new QCheckBox(i18nc("@option:check", "Show status bar"), this); + m_showZoomSlider = new QCheckBox(i18nc("@option:check", "Show zoom slider"), this); + m_showSpaceInfo = new QCheckBox(i18nc("@option:check", "Show space information"), this); + + topLayout->addRow(i18nc("@title:group", "Status Bar: "), m_showStatusBar); + topLayout->addRow(QString(), m_showZoomSlider); + topLayout->addRow(QString(), m_showSpaceInfo); + + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); + + // Location bar + m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Make location bar editable")); + topLayout->addRow(i18n("Location bar:"), m_editableUrl); + + m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar")); + topLayout->addRow(QString(), m_showFullPath); + + loadSettings(); + + locationUpdateInitialViewOptions(); + + connect(m_editableUrl, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::locationSlotSettingsChanged); + connect(m_showFullPath, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::locationSlotSettingsChanged); + + connect(m_showStatusBar, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::changed); + connect(m_showStatusBar, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::onShowStatusBarToggled); + connect(m_showZoomSlider, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::changed); + connect(m_showSpaceInfo, &QCheckBox::toggled, this, &StatusAndLocationBarsSettingsPage::changed); +} + +StatusAndLocationBarsSettingsPage::~StatusAndLocationBarsSettingsPage() +{ +} + +void StatusAndLocationBarsSettingsPage::applySettings() +{ + GeneralSettings *settings = GeneralSettings::self(); + + settings->setEditableUrl(m_editableUrl->isChecked()); + settings->setShowFullPath(m_showFullPath->isChecked()); + + settings->setShowStatusBar(m_showStatusBar->isChecked()); + settings->setShowZoomSlider(m_showZoomSlider->isChecked()); + settings->setShowSpaceInfo(m_showSpaceInfo->isChecked()); + + settings->save(); +} + +void StatusAndLocationBarsSettingsPage::onShowStatusBarToggled() +{ + const bool checked = m_showStatusBar->isChecked(); + m_showZoomSlider->setEnabled(checked); + m_showSpaceInfo->setEnabled(checked); +} + +void StatusAndLocationBarsSettingsPage::restoreDefaults() +{ + GeneralSettings *settings = GeneralSettings::self(); + settings->useDefaults(true); + loadSettings(); + settings->useDefaults(false); +} + +void StatusAndLocationBarsSettingsPage::locationSlotSettingsChanged() +{ + // Provide a hint that the startup settings have been changed. This allows the views + // to apply the startup settings only if they have been explicitly changed by the user + // (see bug #254947). + GeneralSettings::setModifiedStartupSettings(true); + + // Enable and disable home URL controls appropriately + locationUpdateInitialViewOptions(); + Q_EMIT changed(); +} + +void StatusAndLocationBarsSettingsPage::locationUpdateInitialViewOptions() +{ + foldersTabsPage->m_homeUrlBoxLayoutContainer->setEnabled(foldersTabsPage->m_homeUrlRadioButton->isChecked()); + foldersTabsPage->m_buttonBoxLayoutContainer->setEnabled(foldersTabsPage->m_homeUrlRadioButton->isChecked()); +} + +void StatusAndLocationBarsSettingsPage::loadSettings() +{ + m_editableUrl->setChecked(GeneralSettings::editableUrl()); + m_showFullPath->setChecked(GeneralSettings::showFullPath()); + m_showStatusBar->setChecked(GeneralSettings::showStatusBar()); + m_showZoomSlider->setChecked(GeneralSettings::showZoomSlider()); + m_showSpaceInfo->setChecked(GeneralSettings::showSpaceInfo()); + + onShowStatusBarToggled(); +} + +#include "moc_statusandlocationbarssettingspage.cpp" diff --git a/src/settings/interface/statusandlocationbarssettingspage.h b/src/settings/interface/statusandlocationbarssettingspage.h new file mode 100644 index 000000000..c22ff2041 --- /dev/null +++ b/src/settings/interface/statusandlocationbarssettingspage.h @@ -0,0 +1,55 @@ +/* + * SPDX-FileCopyrightText: 2009 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef STATUSANDLOCATIONBARSSETTINGSPAGE_H +#define STATUSANDLOCATIONBARSSETTINGSPAGE_H + +#include "dolphin_generalsettings.h" +#include "folderstabssettingspage.h" +#include "settings/settingspagebase.h" + +#include + +class QCheckBox; +class QLineEdit; +class QLabel; +class QRadioButton; + +/** + * @brief Tab page for the 'Behavior' settings of the Dolphin settings dialog. + */ +class StatusAndLocationBarsSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + StatusAndLocationBarsSettingsPage(QWidget *parent, FoldersTabsSettingsPage *foldersPage); + ~StatusAndLocationBarsSettingsPage() override; + + /** @see SettingsPageBase::applySettings() */ + void applySettings() override; + + /** @see SettingsPageBase::restoreDefaults() */ + void restoreDefaults() override; + +private Q_SLOTS: + void locationSlotSettingsChanged(); + void locationUpdateInitialViewOptions(); + +private: + void loadSettings(); + void onShowStatusBarToggled(); + +private: + FoldersTabsSettingsPage *foldersTabsPage; + QCheckBox *m_editableUrl; + QCheckBox *m_showFullPath; + + QCheckBox *m_showStatusBar; + QCheckBox *m_showZoomSlider; + QCheckBox *m_showSpaceInfo; +}; + +#endif diff --git a/src/settings/kcm/kcmdolphingeneral.cpp b/src/settings/kcm/kcmdolphingeneral.cpp index c002da926..32241d112 100644 --- a/src/settings/kcm/kcmdolphingeneral.cpp +++ b/src/settings/kcm/kcmdolphingeneral.cpp @@ -6,9 +6,10 @@ #include "kcmdolphingeneral.h" -#include "settings/general/behaviorsettingspage.h" -#include "settings/general/confirmationssettingspage.h" -#include "settings/general/previewssettingspage.h" +#include "settings/interface/confirmationssettingspage.h" +#include "settings/interface/folderstabssettingspage.h" +#include "settings/interface/interfacesettingspage.h" +#include "settings/interface/previewssettingspage.h" #include #include @@ -30,10 +31,10 @@ DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget *parent, const QV QTabWidget *tabWidget = new QTabWidget(this); - // initialize 'Behavior' tab - BehaviorSettingsPage *behaviorPage = new BehaviorSettingsPage(QUrl::fromLocalFile(QDir::homePath()), tabWidget); - tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior")); - connect(behaviorPage, &BehaviorSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged); + // initialize 'Folders & Tabs' tab + FoldersTabsSettingsPage *foldersTabsPage = new FoldersTabsSettingsPage(tabWidget); + tabWidget->addTab(foldersTabsPage, i18nc("@title:tab Behavior settings", "Behavior")); + connect(foldersTabsPage, &FoldersTabsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged); // initialize 'Previews' tab PreviewsSettingsPage *previewsPage = new PreviewsSettingsPage(tabWidget); @@ -44,7 +45,7 @@ DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget *parent, const QV ConfirmationsSettingsPage *confirmationsPage = new ConfirmationsSettingsPage(tabWidget); tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations")); connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged); - m_pages.append(behaviorPage); + m_pages.append(foldersTabsPage); m_pages.append(previewsPage); m_pages.append(confirmationsPage); diff --git a/src/settings/kcm/kcmdolphinnavigation.cpp b/src/settings/kcm/kcmdolphinnavigation.cpp deleted file mode 100644 index dd4756d8b..000000000 --- a/src/settings/kcm/kcmdolphinnavigation.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2009 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "kcmdolphinnavigation.h" - -#include "settings/navigation/navigationsettingspage.h" -#include - -#include - -#include - -K_PLUGIN_CLASS_WITH_JSON(DolphinNavigationConfigModule, "kcmdolphinnavigation.json") - -DolphinNavigationConfigModule::DolphinNavigationConfigModule(QWidget *parent, const QVariantList &args) - : KCModule(parent, args) - , m_navigation(nullptr) -{ - setButtons(KCModule::Default | KCModule::Help | KCModule::Apply); - - QVBoxLayout *topLayout = new QVBoxLayout(this); - topLayout->setContentsMargins(0, 0, 0, 0); - - m_navigation = new NavigationSettingsPage(this); - connect(m_navigation, &NavigationSettingsPage::changed, this, &DolphinNavigationConfigModule::markAsChanged); - topLayout->addWidget(m_navigation, 0, {}); -} - -DolphinNavigationConfigModule::~DolphinNavigationConfigModule() -{ -} - -void DolphinNavigationConfigModule::save() -{ - m_navigation->applySettings(); -} - -void DolphinNavigationConfigModule::defaults() -{ - m_navigation->restoreDefaults(); -} - -#include "kcmdolphinnavigation.moc" - -#include "moc_kcmdolphinnavigation.cpp" diff --git a/src/settings/kcm/kcmdolphinnavigation.h b/src/settings/kcm/kcmdolphinnavigation.h deleted file mode 100644 index 97d7bff85..000000000 --- a/src/settings/kcm/kcmdolphinnavigation.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2009 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef KCMDOLPHINNAVIGATION_H -#define KCMDOLPHINNAVIGATION_H - -#include - -class NavigationSettingsPage; - -/** - * @brief Allow to configure the Dolphin navigation. - */ -class DolphinNavigationConfigModule : public KCModule -{ - Q_OBJECT - -public: - DolphinNavigationConfigModule(QWidget *parent, const QVariantList &args); - ~DolphinNavigationConfigModule() override; - - void save() override; - void defaults() override; - -private: - NavigationSettingsPage *m_navigation; -}; - -#endif diff --git a/src/settings/kcm/kcmdolphinnavigation.json b/src/settings/kcm/kcmdolphinnavigation.json deleted file mode 100644 index 8bf2cbfd8..000000000 --- a/src/settings/kcm/kcmdolphinnavigation.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "KPlugin": { - "Icon": "preferences-desktop-navigation", - "Name": "Navigation", - "Name[ar]": "التّنقّل", - "Name[az]": "Naviqasiya", - "Name[be]": "Навігацыя", - "Name[bg]": "Навигация", - "Name[ca@valencia]": "Navegació", - "Name[ca]": "Navegació", - "Name[cs]": "Navigace", - "Name[da]": "Navigation", - "Name[de]": "Navigation", - "Name[en_GB]": "Navigation", - "Name[eo]": "Navigado", - "Name[es]": "Navegación", - "Name[et]": "Liikumine", - "Name[eu]": "Nabigatzea", - "Name[fi]": "Selaus", - "Name[fr]": "Navigation", - "Name[gl]": "Navegación", - "Name[he]": "ניווט", - "Name[hi]": "संचालन", - "Name[hu]": "Navigálás", - "Name[ia]": "Navigation", - "Name[id]": "Navigasi", - "Name[ie]": "Navigation", - "Name[is]": "Skoðun", - "Name[it]": "Navigazione", - "Name[ja]": "ナビゲーション", - "Name[ka]": "ნავიგაცია", - "Name[ko]": "탐색", - "Name[lt]": "Naršymas", - "Name[lv]": "Navigācija", - "Name[ml]": "നാവിഗേഷന്‍", - "Name[my]": "လမ်းညွှန်", - "Name[nb]": "Navigasjon", - "Name[nl]": "Navigatie", - "Name[nn]": "Navigasjon", - "Name[pa]": "ਨੇਵੀਗੇਸ਼ਨ", - "Name[pl]": "Poruszanie się", - "Name[pt]": "Navegação", - "Name[pt_BR]": "Navegação", - "Name[ro]": "Navigare", - "Name[ru]": "Навигация", - "Name[se]": "Navigašuvdna", - "Name[sk]": "Navigácia", - "Name[sl]": "Krmarjenje", - "Name[sr@ijekavian]": "Навигација", - "Name[sr@ijekavianlatin]": "Navigacija", - "Name[sr@latin]": "Navigacija", - "Name[sr]": "Навигација", - "Name[sv]": "Navigering", - "Name[ta]": "உலாவல்", - "Name[tr]": "Dolaşım", - "Name[uk]": "Навігація", - "Name[vi]": "Điều hướng", - "Name[x-test]": "xxNavigationxx", - "Name[zh_CN]": "导航", - "Name[zh_TW]": "導覽" - }, - "X-DocPath": "dolphin/configuring-dolphin.html#preferences-dialog-navigation" -} diff --git a/src/settings/navigation/navigationsettingspage.cpp b/src/settings/navigation/navigationsettingspage.cpp deleted file mode 100644 index 3b38e52e7..000000000 --- a/src/settings/navigation/navigationsettingspage.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2009 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "navigationsettingspage.h" - -#include "dolphin_generalsettings.h" -#include "global.h" - -#include - -#include -#include -#include -#include - -NavigationSettingsPage::NavigationSettingsPage(QWidget *parent) - : SettingsPageBase(parent) - , m_openArchivesAsFolder(nullptr) - , m_autoExpandFolders(nullptr) - , m_openNewTabAfterLastTab(nullptr) - , m_openNewTabAfterCurrentTab(nullptr) -{ - QFormLayout *topLayout = new QFormLayout(this); - - // Tabs properties - m_openNewTabAfterCurrentTab = new QRadioButton(i18nc("option:radio", "After current tab")); - m_openNewTabAfterLastTab = new QRadioButton(i18nc("option:radio", "At end of tab bar")); - QButtonGroup *tabsBehaviorGroup = new QButtonGroup(this); - tabsBehaviorGroup->addButton(m_openNewTabAfterCurrentTab); - tabsBehaviorGroup->addButton(m_openNewTabAfterLastTab); - topLayout->addRow(i18nc("@title:group", "Open new tabs: "), m_openNewTabAfterCurrentTab); - topLayout->addRow(QString(), m_openNewTabAfterLastTab); - - topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - - m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder")); - m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations")); - topLayout->addRow(i18nc("@title:group", "General: "), m_openArchivesAsFolder); - topLayout->addRow(QString(), m_autoExpandFolders); - - loadSettings(); - - connect(m_openArchivesAsFolder, &QCheckBox::toggled, this, &NavigationSettingsPage::changed); - connect(m_autoExpandFolders, &QCheckBox::toggled, this, &NavigationSettingsPage::changed); - connect(m_openNewTabAfterCurrentTab, &QRadioButton::toggled, this, &NavigationSettingsPage::changed); - connect(m_openNewTabAfterLastTab, &QRadioButton::toggled, this, &NavigationSettingsPage::changed); -} - -NavigationSettingsPage::~NavigationSettingsPage() -{ -} - -void NavigationSettingsPage::applySettings() -{ - GeneralSettings *settings = GeneralSettings::self(); - settings->setBrowseThroughArchives(m_openArchivesAsFolder->isChecked()); - settings->setAutoExpandFolders(m_autoExpandFolders->isChecked()); - settings->setOpenNewTabAfterLastTab(m_openNewTabAfterLastTab->isChecked()); - - settings->save(); -} - -void NavigationSettingsPage::restoreDefaults() -{ - GeneralSettings *settings = GeneralSettings::self(); - settings->useDefaults(true); - loadSettings(); - settings->useDefaults(false); -} - -void NavigationSettingsPage::loadSettings() -{ - m_openArchivesAsFolder->setChecked(GeneralSettings::browseThroughArchives()); - m_autoExpandFolders->setChecked(GeneralSettings::autoExpandFolders()); - m_openNewTabAfterLastTab->setChecked(GeneralSettings::openNewTabAfterLastTab()); - m_openNewTabAfterCurrentTab->setChecked(!m_openNewTabAfterLastTab->isChecked()); -} - -#include "moc_navigationsettingspage.cpp" diff --git a/src/settings/navigation/navigationsettingspage.h b/src/settings/navigation/navigationsettingspage.h deleted file mode 100644 index e0f92884f..000000000 --- a/src/settings/navigation/navigationsettingspage.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2009 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ -#ifndef NAVIGATIONSETTINGSPAGE_H -#define NAVIGATIONSETTINGSPAGE_H - -#include "settings/settingspagebase.h" - -class QCheckBox; -class QRadioButton; - -/** - * @brief Page for the 'Navigation' settings of the Dolphin settings dialog. - */ -class NavigationSettingsPage : public SettingsPageBase -{ - Q_OBJECT - -public: - explicit NavigationSettingsPage(QWidget *parent); - ~NavigationSettingsPage() override; - - /** @see SettingsPageBase::applySettings() */ - void applySettings() override; - - /** @see SettingsPageBase::restoreDefaults() */ - void restoreDefaults() override; - -private: - void loadSettings(); - -private: - QCheckBox *m_openArchivesAsFolder; - QCheckBox *m_autoExpandFolders; - QRadioButton *m_openNewTabAfterLastTab; - QRadioButton *m_openNewTabAfterCurrentTab; -}; - -#endif diff --git a/src/settings/startup/startupsettingspage.cpp b/src/settings/startup/startupsettingspage.cpp deleted file mode 100644 index dc15ee39a..000000000 --- a/src/settings/startup/startupsettingspage.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2008 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "startupsettingspage.h" - -#include "dolphin_generalsettings.h" -#include "dolphinmainwindow.h" -#include "dolphinviewcontainer.h" -#include "global.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -StartupSettingsPage::StartupSettingsPage(const QUrl &url, QWidget *parent) - : SettingsPageBase(parent) - , m_url(url) - , m_homeUrl(nullptr) - , m_homeUrlBoxLayoutContainer(nullptr) - , m_buttonBoxLayoutContainer(nullptr) - , m_rememberOpenedTabsRadioButton(nullptr) - , m_homeUrlRadioButton(nullptr) - , m_splitView(nullptr) - , m_editableUrl(nullptr) - , m_showFullPath(nullptr) - , m_filterBar(nullptr) - , m_showFullPathInTitlebar(nullptr) - , m_openExternallyCalledFolderInNewTab(nullptr) -{ - QFormLayout *topLayout = new QFormLayout(this); - - m_rememberOpenedTabsRadioButton = new QRadioButton(i18nc("@option:radio Startup Settings", "Folders, tabs, and window state from last time")); - m_homeUrlRadioButton = new QRadioButton(); - // HACK: otherwise the radio button has too much spacing in a grid layout - m_homeUrlRadioButton->setMaximumWidth(24); - - QButtonGroup *initialViewGroup = new QButtonGroup(this); - initialViewGroup->addButton(m_rememberOpenedTabsRadioButton); - initialViewGroup->addButton(m_homeUrlRadioButton); - - // create 'Home URL' editor - m_homeUrlBoxLayoutContainer = new QWidget(this); - QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(m_homeUrlBoxLayoutContainer); - homeUrlBoxLayout->setContentsMargins(0, 0, 0, 0); - - m_homeUrl = new QLineEdit(); - m_homeUrl->setClearButtonEnabled(true); - homeUrlBoxLayout->addWidget(m_homeUrl); - - QPushButton *selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString()); - homeUrlBoxLayout->addWidget(selectHomeUrlButton); - -#ifndef QT_NO_ACCESSIBILITY - selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); -#endif - - connect(selectHomeUrlButton, &QPushButton::clicked, this, &StartupSettingsPage::selectHomeUrl); - - m_buttonBoxLayoutContainer = new QWidget(this); - QHBoxLayout *buttonBoxLayout = new QHBoxLayout(m_buttonBoxLayoutContainer); - buttonBoxLayout->setContentsMargins(0, 0, 0, 0); - - QPushButton *useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location")); - buttonBoxLayout->addWidget(useCurrentButton); - connect(useCurrentButton, &QPushButton::clicked, this, &StartupSettingsPage::useCurrentLocation); - QPushButton *useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location")); - buttonBoxLayout->addWidget(useDefaultButton); - connect(useDefaultButton, &QPushButton::clicked, this, &StartupSettingsPage::useDefaultLocation); - - QGridLayout *startInLocationLayout = new QGridLayout(); - startInLocationLayout->setHorizontalSpacing(0); - startInLocationLayout->setContentsMargins(0, 0, 0, 0); - startInLocationLayout->addWidget(m_homeUrlRadioButton, 0, 0); - startInLocationLayout->addWidget(m_homeUrlBoxLayoutContainer, 0, 1); - startInLocationLayout->addWidget(m_buttonBoxLayoutContainer, 1, 1); - - topLayout->addRow(i18nc("@label:textbox", "Show on startup:"), m_rememberOpenedTabsRadioButton); - topLayout->addRow(QString(), startInLocationLayout); - - topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - - m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Begin in split view mode")); - topLayout->addRow(i18n("New windows:"), m_splitView); - m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar")); - topLayout->addRow(QString(), m_filterBar); - m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Make location bar editable")); - topLayout->addRow(QString(), m_editableUrl); - - topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); - - m_openExternallyCalledFolderInNewTab = new QCheckBox(i18nc("@option:check Startup Settings", "Open new folders in tabs")); - topLayout->addRow(i18nc("@label:checkbox", "General:"), m_openExternallyCalledFolderInNewTab); - m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar")); - topLayout->addRow(QString(), m_showFullPath); - m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar")); - topLayout->addRow(QString(), m_showFullPathInTitlebar); - - loadSettings(); - - updateInitialViewOptions(); - - connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); - connect(m_rememberOpenedTabsRadioButton, &QRadioButton::toggled, this, &StartupSettingsPage::slotSettingsChanged); - connect(m_homeUrlRadioButton, &QRadioButton::toggled, this, &StartupSettingsPage::slotSettingsChanged); - - connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); - connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); - connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); - - connect(m_openExternallyCalledFolderInNewTab, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); - connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); - connect(m_showFullPathInTitlebar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); -} - -StartupSettingsPage::~StartupSettingsPage() -{ -} - -void StartupSettingsPage::applySettings() -{ - GeneralSettings *settings = GeneralSettings::self(); - - const QUrl url(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile)); - if (url.isValid() && KProtocolManager::supportsListing(url)) { - KIO::StatJob *job = KIO::statDetails(url, KIO::StatJob::SourceSide, KIO::StatDetail::StatBasic, KIO::JobFlag::HideProgressInfo); - connect(job, &KJob::result, this, [this, settings, url](KJob *job) { - if (job->error() == 0 && qobject_cast(job)->statResult().isDir()) { - settings->setHomeUrl(url.toDisplayString(QUrl::PreferLocalFile)); - } else { - showSetDefaultDirectoryError(); - } - }); - } else { - showSetDefaultDirectoryError(); - } - - // Remove saved state if "remember open tabs" has been turned off - if (!m_rememberOpenedTabsRadioButton->isChecked()) { - KConfigGroup windowState{KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "WindowState"}; - if (windowState.exists()) { - windowState.deleteGroup(); - } - } - - settings->setRememberOpenedTabs(m_rememberOpenedTabsRadioButton->isChecked()); - settings->setSplitView(m_splitView->isChecked()); - settings->setEditableUrl(m_editableUrl->isChecked()); - settings->setFilterBar(m_filterBar->isChecked()); - settings->setOpenExternallyCalledFolderInNewTab(m_openExternallyCalledFolderInNewTab->isChecked()); - settings->setShowFullPath(m_showFullPath->isChecked()); - settings->setShowFullPathInTitlebar(m_showFullPathInTitlebar->isChecked()); - settings->save(); -} - -void StartupSettingsPage::restoreDefaults() -{ - GeneralSettings *settings = GeneralSettings::self(); - settings->useDefaults(true); - loadSettings(); - settings->useDefaults(false); -} - -void StartupSettingsPage::slotSettingsChanged() -{ - // Provide a hint that the startup settings have been changed. This allows the views - // to apply the startup settings only if they have been explicitly changed by the user - // (see bug #254947). - GeneralSettings::setModifiedStartupSettings(true); - - // Enable and disable home URL controls appropriately - updateInitialViewOptions(); - Q_EMIT changed(); -} - -void StartupSettingsPage::updateInitialViewOptions() -{ - m_homeUrlBoxLayoutContainer->setEnabled(m_homeUrlRadioButton->isChecked()); - m_buttonBoxLayoutContainer->setEnabled(m_homeUrlRadioButton->isChecked()); -} - -void StartupSettingsPage::selectHomeUrl() -{ - const QUrl homeUrl(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile)); - QUrl url = QFileDialog::getExistingDirectoryUrl(this, QString(), homeUrl); - if (!url.isEmpty()) { - m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile)); - slotSettingsChanged(); - } -} - -void StartupSettingsPage::useCurrentLocation() -{ - m_homeUrl->setText(m_url.toDisplayString(QUrl::PreferLocalFile)); -} - -void StartupSettingsPage::useDefaultLocation() -{ - m_homeUrl->setText(QDir::homePath()); -} - -void StartupSettingsPage::loadSettings() -{ - const QUrl url(Dolphin::homeUrl()); - m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile)); - m_rememberOpenedTabsRadioButton->setChecked(GeneralSettings::rememberOpenedTabs()); - m_homeUrlRadioButton->setChecked(!GeneralSettings::rememberOpenedTabs()); - m_splitView->setChecked(GeneralSettings::splitView()); - m_editableUrl->setChecked(GeneralSettings::editableUrl()); - m_showFullPath->setChecked(GeneralSettings::showFullPath()); - m_filterBar->setChecked(GeneralSettings::filterBar()); - m_showFullPathInTitlebar->setChecked(GeneralSettings::showFullPathInTitlebar()); - m_openExternallyCalledFolderInNewTab->setChecked(GeneralSettings::openExternallyCalledFolderInNewTab()); -} - -void StartupSettingsPage::showSetDefaultDirectoryError() -{ - KMessageBox::error(this, i18nc("@info", "The location for the home folder is invalid or does not exist, it will not be applied.")); -} - -#include "moc_startupsettingspage.cpp" diff --git a/src/settings/startup/startupsettingspage.h b/src/settings/startup/startupsettingspage.h deleted file mode 100644 index b1cf387fa..000000000 --- a/src/settings/startup/startupsettingspage.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2008 Peter Penz - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ -#ifndef STARTUPSETTINGSPAGE_H -#define STARTUPSETTINGSPAGE_H - -#include "settings/settingspagebase.h" - -#include - -class QCheckBox; -class QLineEdit; -class QRadioButton; - -/** - * @brief Page for the 'Startup' settings of the Dolphin settings dialog. - * - * The startup settings allow to set the home URL and to configure the - * state of the view mode, split mode and the filter bar when starting Dolphin. - */ -class StartupSettingsPage : public SettingsPageBase -{ - Q_OBJECT - -public: - StartupSettingsPage(const QUrl &url, QWidget *parent); - ~StartupSettingsPage() override; - - /** @see SettingsPageBase::applySettings() */ - void applySettings() override; - - /** @see SettingsPageBase::restoreDefaults() */ - void restoreDefaults() override; - -private Q_SLOTS: - void slotSettingsChanged(); - void updateInitialViewOptions(); - void selectHomeUrl(); - void useCurrentLocation(); - void useDefaultLocation(); - -private: - void loadSettings(); - void showSetDefaultDirectoryError(); - -private: - QUrl m_url; - QLineEdit *m_homeUrl; - QWidget *m_homeUrlBoxLayoutContainer; - QWidget *m_buttonBoxLayoutContainer; - QRadioButton *m_rememberOpenedTabsRadioButton; - QRadioButton *m_homeUrlRadioButton; - - QCheckBox *m_splitView; - QCheckBox *m_editableUrl; - QCheckBox *m_showFullPath; - QCheckBox *m_filterBar; - QCheckBox *m_showFullPathInTitlebar; - QCheckBox *m_openExternallyCalledFolderInNewTab; -}; - -#endif diff --git a/src/settings/viewmodes/contentdisplaytab.cpp b/src/settings/viewmodes/contentdisplaytab.cpp index aa320b79e..f674e194e 100644 --- a/src/settings/viewmodes/contentdisplaytab.cpp +++ b/src/settings/viewmodes/contentdisplaytab.cpp @@ -6,6 +6,7 @@ #include "contentdisplaytab.h" #include "dolphin_contentdisplaysettings.h" +#include "dolphin_generalsettings.h" #include #include @@ -18,6 +19,9 @@ ContentDisplayTab::ContentDisplayTab(QWidget *parent) : SettingsPageBase(parent) + , m_naturalSorting(nullptr) + , m_caseSensitiveSorting(nullptr) + , m_caseInsensitiveSorting(nullptr) , m_numberOfItems(nullptr) , m_sizeOfContents(nullptr) , m_recursiveDirectorySizeLimit(nullptr) @@ -29,6 +33,19 @@ ContentDisplayTab::ContentDisplayTab(QWidget *parent) { QFormLayout *topLayout = new QFormLayout(this); + // Sorting Order + m_naturalSorting = new QRadioButton(i18nc("option:radio", "Natural")); + m_caseInsensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical, case insensitive")); + m_caseSensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical, case sensitive")); + + QButtonGroup *sortingOrderGroup = new QButtonGroup(this); + sortingOrderGroup->addButton(m_naturalSorting); + sortingOrderGroup->addButton(m_caseInsensitiveSorting); + sortingOrderGroup->addButton(m_caseSensitiveSorting); + topLayout->addRow(i18nc("@title:group", "Sorting mode: "), m_naturalSorting); + topLayout->addRow(QString(), m_caseInsensitiveSorting); + topLayout->addRow(QString(), m_caseSensitiveSorting); + #ifndef Q_OS_WIN // Sorting properties m_numberOfItems = new QRadioButton(i18nc("option:radio", "Number of items")); @@ -95,6 +112,9 @@ ContentDisplayTab::ContentDisplayTab(QWidget *parent) connect(m_useSymbolicPermissions, &QRadioButton::toggled, this, &SettingsPageBase::changed); connect(m_useNumericPermissions, &QRadioButton::toggled, this, &SettingsPageBase::changed); connect(m_useCombinedPermissions, &QRadioButton::toggled, this, &SettingsPageBase::changed); + connect(m_naturalSorting, &QRadioButton::toggled, this, &SettingsPageBase::changed); + connect(m_caseInsensitiveSorting, &QRadioButton::toggled, this, &SettingsPageBase::changed); + connect(m_caseSensitiveSorting, &QRadioButton::toggled, this, &SettingsPageBase::changed); loadSettings(); } @@ -106,7 +126,7 @@ void ContentDisplayTab::applySettings() settings->setDirectorySizeCount(m_numberOfItems->isChecked()); settings->setRecursiveDirectorySizeLimit(m_recursiveDirectorySizeLimit->value()); #endif - + setSortingChoiceValue(); settings->setUseShortRelativeDates(m_useRelatetiveDates->isChecked()); if (m_useSymbolicPermissions->isChecked()) { @@ -137,6 +157,38 @@ void ContentDisplayTab::loadSettings() m_useSymbolicPermissions->setChecked(settings->usePermissionsFormat() == ContentDisplaySettings::EnumUsePermissionsFormat::SymbolicFormat); m_useNumericPermissions->setChecked(settings->usePermissionsFormat() == ContentDisplaySettings::EnumUsePermissionsFormat::NumericFormat); m_useCombinedPermissions->setChecked(settings->usePermissionsFormat() == ContentDisplaySettings::EnumUsePermissionsFormat::CombinedFormat); + loadSortingChoiceSettings(); +} + +void ContentDisplayTab::setSortingChoiceValue() +{ + auto settings = GeneralSettings::self(); + using Choice = GeneralSettings::EnumSortingChoice; + if (m_naturalSorting->isChecked()) { + settings->setSortingChoice(Choice::NaturalSorting); + } else if (m_caseInsensitiveSorting->isChecked()) { + settings->setSortingChoice(Choice::CaseInsensitiveSorting); + } else if (m_caseSensitiveSorting->isChecked()) { + settings->setSortingChoice(Choice::CaseSensitiveSorting); + } +} + +void ContentDisplayTab::loadSortingChoiceSettings() +{ + using Choice = GeneralSettings::EnumSortingChoice; + switch (GeneralSettings::sortingChoice()) { + case Choice::NaturalSorting: + m_naturalSorting->setChecked(true); + break; + case Choice::CaseInsensitiveSorting: + m_caseInsensitiveSorting->setChecked(true); + break; + case Choice::CaseSensitiveSorting: + m_caseSensitiveSorting->setChecked(true); + break; + default: + Q_UNREACHABLE(); + } } void ContentDisplayTab::restoreDefaults() diff --git a/src/settings/viewmodes/contentdisplaytab.h b/src/settings/viewmodes/contentdisplaytab.h index 5484bf413..3550569fd 100644 --- a/src/settings/viewmodes/contentdisplaytab.h +++ b/src/settings/viewmodes/contentdisplaytab.h @@ -6,6 +6,8 @@ #ifndef GENERALTAB_H #define GENERALTAB_H +#include "dolphin_contentdisplaysettings.h" +#include "dolphin_generalsettings.h" #include "settings/settingspagebase.h" class QRadioButton; @@ -25,6 +27,12 @@ public: private: void loadSettings(); + void setSortingChoiceValue(); + void loadSortingChoiceSettings(); + + QRadioButton *m_naturalSorting; + QRadioButton *m_caseSensitiveSorting; + QRadioButton *m_caseInsensitiveSorting; QRadioButton *m_numberOfItems; QRadioButton *m_sizeOfContents; diff --git a/src/settings/viewmodes/generalviewsettingspage.cpp b/src/settings/viewmodes/generalviewsettingspage.cpp new file mode 100644 index 000000000..0b2a96cb5 --- /dev/null +++ b/src/settings/viewmodes/generalviewsettingspage.cpp @@ -0,0 +1,133 @@ +/* + * SPDX-FileCopyrightText: 2006 Peter Penz (peter.penz@gmx.at) and Patrice Tremblay + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "generalviewsettingspage.h" +#include "dolphin_generalsettings.h" +#include "dolphinmainwindow.h" +#include "views/viewproperties.h" + +#include + +#include +#include +#include +#include + +GeneralViewSettingsPage::GeneralViewSettingsPage(const QUrl &url, QWidget *parent) + : SettingsPageBase(parent) + , m_url(url) + , m_localViewProps(nullptr) + , m_globalViewProps(nullptr) + , m_showToolTips(nullptr) + , m_showSelectionToggle(nullptr) + , m_renameInline(nullptr) +{ + QFormLayout *topLayout = new QFormLayout(this); + + // Display style + m_globalViewProps = new QRadioButton(i18nc("@option:radio", "Use common display style for all folders")); + m_localViewProps = new QRadioButton(i18nc("@option:radio", "Remember display style for each folder")); + m_localViewProps->setToolTip(i18nc("@info", "Dolphin will create a hidden .directory file in each folder you change view properties for.")); + + QButtonGroup *viewGroup = new QButtonGroup(this); + viewGroup->addButton(m_globalViewProps); + viewGroup->addButton(m_localViewProps); + topLayout->addRow(i18nc("@title:group", "Display style: "), m_globalViewProps); + topLayout->addRow(QString(), m_localViewProps); + + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); + + // Browsing + m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder")); + m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations")); + topLayout->addRow(i18nc("@title:group", "Browsing: "), m_openArchivesAsFolder); + topLayout->addRow(QString(), m_autoExpandFolders); + + topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); + +#if HAVE_BALOO + // 'Show tooltips' + m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips")); + topLayout->addRow(i18nc("@title:group", "Miscellaneous: "), m_showToolTips); +#endif + + // 'Show selection marker' + m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker")); +#if HAVE_BALOO + topLayout->addRow(QString(), m_showSelectionToggle); +#else + topLayout->addRow(i18nc("@title:group", "Miscellaneous: "), m_showSelectionToggle); +#endif + + // 'Inline renaming of items' + m_renameInline = new QCheckBox(i18nc("option:check", "Rename inline")); + topLayout->addRow(QString(), m_renameInline); + + loadSettings(); + + connect(m_localViewProps, &QRadioButton::toggled, this, &GeneralViewSettingsPage::changed); + connect(m_globalViewProps, &QRadioButton::toggled, this, &GeneralViewSettingsPage::changed); + + connect(m_openArchivesAsFolder, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed); + connect(m_autoExpandFolders, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed); +#if HAVE_BALOO + connect(m_showToolTips, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed); +#endif + connect(m_showSelectionToggle, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed); + connect(m_renameInline, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed); +} + +GeneralViewSettingsPage::~GeneralViewSettingsPage() +{ +} + +void GeneralViewSettingsPage::applySettings() +{ + GeneralSettings *settings = GeneralSettings::self(); + ViewProperties props(m_url); // read current view properties + const bool useGlobalViewProps = m_globalViewProps->isChecked(); + settings->setGlobalViewProps(useGlobalViewProps); +#if HAVE_BALOO + settings->setShowToolTips(m_showToolTips->isChecked()); +#endif + settings->setShowSelectionToggle(m_showSelectionToggle->isChecked()); + settings->setRenameInline(m_renameInline->isChecked()); + settings->setAutoExpandFolders(m_autoExpandFolders->isChecked()); + settings->save(); + if (useGlobalViewProps) { + // Remember the global view properties by applying the current view properties. + // It is important that GeneralSettings::globalViewProps() is set before + // the class ViewProperties is used, as ViewProperties uses this setting + // to find the destination folder for storing the view properties. + ViewProperties globalProps(m_url); + globalProps.setDirProperties(props); + } +} + +void GeneralViewSettingsPage::restoreDefaults() +{ + GeneralSettings *settings = GeneralSettings::self(); + settings->useDefaults(true); + loadSettings(); + settings->useDefaults(false); +} + +void GeneralViewSettingsPage::loadSettings() +{ + const bool useGlobalViewProps = GeneralSettings::globalViewProps(); + m_openArchivesAsFolder->setChecked(GeneralSettings::browseThroughArchives()); + m_autoExpandFolders->setChecked(GeneralSettings::autoExpandFolders()); +#if HAVE_BALOO + m_showToolTips->setChecked(GeneralSettings::showToolTips()); +#endif + m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle()); + m_renameInline->setChecked(GeneralSettings::renameInline()); + + m_localViewProps->setChecked(!useGlobalViewProps); + m_globalViewProps->setChecked(useGlobalViewProps); +} + +#include "moc_generalviewsettingspage.cpp" diff --git a/src/settings/viewmodes/generalviewsettingspage.h b/src/settings/viewmodes/generalviewsettingspage.h new file mode 100644 index 000000000..47838b939 --- /dev/null +++ b/src/settings/viewmodes/generalviewsettingspage.h @@ -0,0 +1,50 @@ +/* + * SPDX-FileCopyrightText: 2006 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef GENERALVIEWSETTINGSPAGE_H +#define GENERALVIEWSETTINGSPAGE_H + +#include "settings/settingspagebase.h" +#include + +#include + +class QCheckBox; +class QLabel; +class QRadioButton; + +/** + * @brief Tab page for the 'View tab' settings of the Dolphin settings dialog. + */ +class GeneralViewSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + explicit GeneralViewSettingsPage(const QUrl &url, QWidget *parent); + ~GeneralViewSettingsPage() override; + + /** @see SettingsPageBase::applySettings() */ + void applySettings() override; + + /** @see SettingsPageBase::restoreDefaults() */ + void restoreDefaults() override; + +private: + void loadSettings(); + +private: + QUrl m_url; + QRadioButton *m_localViewProps; + QRadioButton *m_globalViewProps; + QCheckBox *m_showToolTips; + QLabel *m_configureToolTips; + QCheckBox *m_showSelectionToggle; + QCheckBox *m_renameInline; + QCheckBox *m_openArchivesAsFolder; + QCheckBox *m_autoExpandFolders; +}; + +#endif diff --git a/src/settings/viewmodes/viewsettingspage.cpp b/src/settings/viewmodes/viewsettingspage.cpp index 0d4d4277b..8e101c3d2 100644 --- a/src/settings/viewmodes/viewsettingspage.cpp +++ b/src/settings/viewmodes/viewsettingspage.cpp @@ -7,14 +7,14 @@ #include "viewsettingspage.h" #include "contentdisplaytab.h" +#include "generalviewsettingspage.h" #include "viewsettingstab.h" - #include #include #include -ViewSettingsPage::ViewSettingsPage(QWidget *parent) +ViewSettingsPage::ViewSettingsPage(const QUrl &url, QWidget *parent) : SettingsPageBase(parent) , m_tabs() { @@ -23,6 +23,11 @@ ViewSettingsPage::ViewSettingsPage(QWidget *parent) tabWidget = new QTabWidget(this); + // General View tab + GeneralViewSettingsPage *generalViewPage = new GeneralViewSettingsPage(url, tabWidget); + tabWidget->addTab(generalViewPage, QIcon::fromTheme(QStringLiteral("description")), i18nc("@title:tab General View settings", "General")); + connect(generalViewPage, &GeneralViewSettingsPage::changed, this, &ViewSettingsPage::changed); + // Content Display Tab contentDisplayTab = new ContentDisplayTab(tabWidget); tabWidget->addTab(contentDisplayTab, diff --git a/src/settings/viewmodes/viewsettingspage.h b/src/settings/viewmodes/viewsettingspage.h index e52f6b2c0..76743252b 100644 --- a/src/settings/viewmodes/viewsettingspage.h +++ b/src/settings/viewmodes/viewsettingspage.h @@ -24,7 +24,7 @@ class ViewSettingsPage : public SettingsPageBase Q_OBJECT public: - explicit ViewSettingsPage(QWidget *parent); + explicit ViewSettingsPage(const QUrl &url, QWidget *parent); ~ViewSettingsPage() override; /** @see SettingsPageBase::applySettings() */ -- cgit v1.3 From ff852b97f110691cda4c2f63f8d0f6bf8759fe2f Mon Sep 17 00:00:00 2001 From: Méven Car Date: Wed, 23 Aug 2023 13:11:20 +0200 Subject: Re-Allow to set settings in Settings-> View-> General page Regressed in 489b56b68bb29e81337e115c490eea4403001b71 Simplify implementation by sharing making class ViewSettingsPage implement SettingsPageBase sharing implementation with other tabs in viewsettingspage --- src/CMakeLists.txt | 1 + src/settings/kcm/kcmdolphinviewmodes.cpp | 2 +- src/settings/viewmodes/viewsettingspage.cpp | 15 +++++---------- src/settings/viewmodes/viewsettingspage.h | 2 +- src/settings/viewmodes/viewsettingstab.cpp | 4 ++-- src/settings/viewmodes/viewsettingstab.h | 8 ++++---- 6 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src/settings') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce078278a..cd9abec81 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -505,6 +505,7 @@ if(NOT WIN32) settings/viewmodes/dolphinfontrequester.cpp settings/viewmodes/viewmodesettings.cpp settings/viewmodes/viewsettingstab.cpp + settings/settingspagebase.cpp views/zoomlevelinfo.cpp settings/kcm/kcmdolphinviewmodes.h settings/viewmodes/dolphinfontrequester.h diff --git a/src/settings/kcm/kcmdolphinviewmodes.cpp b/src/settings/kcm/kcmdolphinviewmodes.cpp index 867faf69e..962f0f112 100644 --- a/src/settings/kcm/kcmdolphinviewmodes.cpp +++ b/src/settings/kcm/kcmdolphinviewmodes.cpp @@ -67,7 +67,7 @@ void DolphinViewModesConfigModule::save() void DolphinViewModesConfigModule::defaults() { for (ViewSettingsTab *tab : qAsConst(m_tabs)) { - tab->restoreDefaultSettings(); + tab->restoreDefaults(); } reparseConfiguration(); } diff --git a/src/settings/viewmodes/viewsettingspage.cpp b/src/settings/viewmodes/viewsettingspage.cpp index 8e101c3d2..5e740640d 100644 --- a/src/settings/viewmodes/viewsettingspage.cpp +++ b/src/settings/viewmodes/viewsettingspage.cpp @@ -50,6 +50,8 @@ ViewSettingsPage::ViewSettingsPage(const QUrl &url, QWidget *parent) tabWidget->addTab(detailsTab, QIcon::fromTheme(QStringLiteral("view-list-tree")), i18nc("@title:tab", "Details")); connect(detailsTab, &ViewSettingsTab::changed, this, &ViewSettingsPage::changed); + m_tabs.append(generalViewPage); + m_tabs.append(contentDisplayTab); m_tabs.append(iconsTab); m_tabs.append(compactTab); m_tabs.append(detailsTab); @@ -63,23 +65,16 @@ ViewSettingsPage::~ViewSettingsPage() void ViewSettingsPage::applySettings() { - contentDisplayTab->applySettings(); - - for (ViewSettingsTab *tab : qAsConst(m_tabs)) { + for (SettingsPageBase *tab : qAsConst(m_tabs)) { tab->applySettings(); } } void ViewSettingsPage::restoreDefaults() { - if (tabWidget->currentWidget() == contentDisplayTab) { - contentDisplayTab->restoreDefaults(); - return; - } - - for (ViewSettingsTab *tab : qAsConst(m_tabs)) { + for (SettingsPageBase *tab : qAsConst(m_tabs)) { if (tabWidget->currentWidget() == tab) { - tab->restoreDefaultSettings(); + tab->restoreDefaults(); return; } } diff --git a/src/settings/viewmodes/viewsettingspage.h b/src/settings/viewmodes/viewsettingspage.h index 76743252b..eae2a6427 100644 --- a/src/settings/viewmodes/viewsettingspage.h +++ b/src/settings/viewmodes/viewsettingspage.h @@ -36,7 +36,7 @@ public: private: ContentDisplayTab *contentDisplayTab; QTabWidget *tabWidget; - QList m_tabs; + QList m_tabs; }; #endif diff --git a/src/settings/viewmodes/viewsettingstab.cpp b/src/settings/viewmodes/viewsettingstab.cpp index ae80a2558..5aca58ba1 100644 --- a/src/settings/viewmodes/viewsettingstab.cpp +++ b/src/settings/viewmodes/viewsettingstab.cpp @@ -26,7 +26,7 @@ #include ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget *parent) - : QWidget(parent) + : SettingsPageBase(parent) , m_mode(mode) , m_defaultSizeSlider(nullptr) , m_previewSizeSlider(nullptr) @@ -186,7 +186,7 @@ void ViewSettingsTab::applySettings() settings.save(); } -void ViewSettingsTab::restoreDefaultSettings() +void ViewSettingsTab::restoreDefaults() { ViewModeSettings settings(m_mode); settings.useDefaults(true); diff --git a/src/settings/viewmodes/viewsettingstab.h b/src/settings/viewmodes/viewsettingstab.h index 6be8fc3b5..fd4cc85a7 100644 --- a/src/settings/viewmodes/viewsettingstab.h +++ b/src/settings/viewmodes/viewsettingstab.h @@ -7,7 +7,7 @@ #ifndef VIEWSETTINGSTAB_H #define VIEWSETTINGSTAB_H -#include +#include "settings/settingspagebase.h" class DolphinFontRequester; class QComboBox; @@ -19,7 +19,7 @@ class QRadioButton; /** * @brief Represents one tab of the view-settings page. */ -class ViewSettingsTab : public QWidget +class ViewSettingsTab : public SettingsPageBase { Q_OBJECT @@ -29,8 +29,8 @@ public: explicit ViewSettingsTab(Mode mode, QWidget *parent = nullptr); ~ViewSettingsTab() override; - void applySettings(); - void restoreDefaultSettings(); + void applySettings() override; + void restoreDefaults() override; Q_SIGNALS: void changed(); -- cgit v1.3