diff options
Diffstat (limited to 'src/settings/general')
| -rw-r--r-- | src/settings/general/behaviorsettingspage.cpp | 195 | ||||
| -rw-r--r-- | src/settings/general/behaviorsettingspage.h | 59 | ||||
| -rw-r--r-- | src/settings/general/confirmationssettingspage.cpp | 177 | ||||
| -rw-r--r-- | src/settings/general/confirmationssettingspage.h | 48 | ||||
| -rw-r--r-- | src/settings/general/generalsettingspage.cpp | 74 | ||||
| -rw-r--r-- | src/settings/general/generalsettingspage.h | 43 | ||||
| -rw-r--r-- | src/settings/general/previewssettingspage.cpp | 179 | ||||
| -rw-r--r-- | src/settings/general/previewssettingspage.h | 56 | ||||
| -rw-r--r-- | src/settings/general/statusbarsettingspage.cpp | 77 | ||||
| -rw-r--r-- | src/settings/general/statusbarsettingspage.h | 40 |
10 files changed, 0 insertions, 948 deletions
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 ([email protected]) and Patrice Tremblay - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "behaviorsettingspage.h" - -#include "global.h" -#include "views/viewproperties.h" - -#include <KLocalizedString> - -#include <QButtonGroup> -#include <QCheckBox> -#include <QFormLayout> -#include <QRadioButton> -#include <QSpacerItem> - -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 <[email protected]> - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ -#ifndef BEHAVIORSETTINGSPAGE_H -#define BEHAVIORSETTINGSPAGE_H - -#include "dolphin_generalsettings.h" -#include "settings/settingspagebase.h" - -#include <QUrl> - -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/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 <[email protected]> - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "confirmationssettingspage.h" - -#include "dolphin_generalsettings.h" -#include "global.h" - -#include <KLocalizedString> - -#include <QCheckBox> -#include <QComboBox> -#include <QHBoxLayout> -#include <QLabel> -#include <QVBoxLayout> - -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<int>::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 <[email protected]> - * - * 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 <[email protected]> - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "generalsettingspage.h" - -#include "behaviorsettingspage.h" -#include "confirmationssettingspage.h" -#include "previewssettingspage.h" -#include "statusbarsettingspage.h" - -#include <KLocalizedString> - -#include <QTabWidget> -#include <QVBoxLayout> - -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 <[email protected]> - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ -#ifndef GENERALSETTINGSPAGE_H -#define GENERALSETTINGSPAGE_H - -#include "settings/settingspagebase.h" - -#include <QWidget> - -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<SettingsPageBase *> m_pages; -}; - -#endif diff --git a/src/settings/general/previewssettingspage.cpp b/src/settings/general/previewssettingspage.cpp deleted file mode 100644 index dd1ce942e..000000000 --- a/src/settings/general/previewssettingspage.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006 Peter Penz <[email protected]> - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "previewssettingspage.h" - -#include "dolphin_generalsettings.h" -#include "settings/servicemodel.h" - -#include <KIO/PreviewJob> -#include <KLocalizedString> -#include <KPluginMetaData> - -#include <QHBoxLayout> -#include <QLabel> -#include <QListView> -#include <QScroller> -#include <QShowEvent> -#include <QSortFilterProxyModel> -#include <QSpinBox> - -// 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); - - 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).value<Qt::CheckState>() == Qt::Checked; - 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<qulonglong>(m_localFileSizeBox->value()) * 1024 * 1024; - globalConfig.writeEntry("MaximumSize", maximumLocalSize, KConfigBase::Normal | KConfigBase::Global); - } - - const qulonglong maximumRemoteSize = static_cast<qulonglong>(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); -} - -void PreviewsSettingsPage::loadPreviewPlugins() -{ - QAbstractItemModel *model = m_listView->model(); - - const QVector<KPluginMetaData> 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::Checked : Qt::Unchecked, Qt::CheckStateRole); - model->setData(index, plugin.name(), Qt::DisplayRole); - model->setData(index, plugin.pluginId(), ServiceModel::DesktopEntryNameRole); - } - - 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<qulonglong>(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<qulonglong>(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 d6d22ae21..000000000 --- a/src/settings/general/previewssettingspage.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006 Peter Penz <[email protected]> - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef PREVIEWSSETTINGSPAGE_H -#define PREVIEWSSETTINGSPAGE_H - -#include <kiowidgets_export.h> - -#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: - -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 <[email protected]> - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "statusbarsettingspage.h" - -#include "dolphin_generalsettings.h" - -#include <KLocalizedString> - -#include <QCheckBox> -#include <QVBoxLayout> - -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 <[email protected]> - * - * 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 |
