From 8acb68ed2835410af934459073048339c7b262a0 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 17 Jan 2009 18:42:06 +0000 Subject: Relayout of the settings dialog, so that all Dolphin KPart relevant settings can be made available in Konqueror's settings dialog too. Further cleanups and layout fixes are required and will be done during the next week. svn path=/trunk/KDE/kdebase/apps/; revision=912587 --- src/settings/behaviorsettingspage.cpp | 162 +++++++++++++++++++++++++ src/settings/behaviorsettingspage.h | 64 ++++++++++ src/settings/contextmenusettingspage.cpp | 88 ++++++++++++++ src/settings/contextmenusettingspage.h | 51 ++++++++ src/settings/dolphinsettingsdialog.cpp | 31 ++++- src/settings/dolphinsettingsdialog.h | 7 +- src/settings/generalsettingspage.cpp | 162 +++++++------------------ src/settings/generalsettingspage.h | 31 ++--- src/settings/generalviewsettingspage.cpp | 201 ------------------------------- src/settings/generalviewsettingspage.h | 73 ----------- src/settings/navigationsettingspage.cpp | 112 +++++++++++++++++ src/settings/navigationsettingspage.h | 54 +++++++++ src/settings/previewssettingspage.cpp | 138 +++++++++++++++++++++ src/settings/previewssettingspage.h | 62 ++++++++++ src/settings/servicessettingspage.cpp | 55 +++++++++ src/settings/servicessettingspage.h | 50 ++++++++ src/settings/startupsettingspage.cpp | 7 +- src/settings/startupsettingspage.h | 6 +- src/settings/statusbarsettingspage.cpp | 81 +++++++++++++ src/settings/statusbarsettingspage.h | 51 ++++++++ src/settings/viewsettingspage.cpp | 24 +--- src/settings/viewsettingspage.h | 5 +- 22 files changed, 1064 insertions(+), 451 deletions(-) create mode 100644 src/settings/behaviorsettingspage.cpp create mode 100644 src/settings/behaviorsettingspage.h create mode 100644 src/settings/contextmenusettingspage.cpp create mode 100644 src/settings/contextmenusettingspage.h delete mode 100644 src/settings/generalviewsettingspage.cpp delete mode 100644 src/settings/generalviewsettingspage.h create mode 100644 src/settings/navigationsettingspage.cpp create mode 100644 src/settings/navigationsettingspage.h create mode 100644 src/settings/previewssettingspage.cpp create mode 100644 src/settings/previewssettingspage.h create mode 100644 src/settings/servicessettingspage.cpp create mode 100644 src/settings/servicessettingspage.h create mode 100644 src/settings/statusbarsettingspage.cpp create mode 100644 src/settings/statusbarsettingspage.h (limited to 'src/settings') diff --git a/src/settings/behaviorsettingspage.cpp b/src/settings/behaviorsettingspage.cpp new file mode 100644 index 000000000..a5bcc63c7 --- /dev/null +++ b/src/settings/behaviorsettingspage.cpp @@ -0,0 +1,162 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) and * + * and Patrice Tremblay * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "behaviorsettingspage.h" + +#include "dolphinsettings.h" +#include "dolphin_generalsettings.h" + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) : + SettingsPageBase(parent), + m_url(url), + m_localProps(0), + m_globalProps(0), + m_confirmMoveToTrash(0), + m_confirmDelete(0), + m_renameInline(0), + m_showToolTips(0), + m_showSelectionToggle(0) +{ + const int spacing = KDialog::spacingHint(); + + QVBoxLayout* topLayout = new QVBoxLayout(this); + KVBox* vBox = new KVBox(this); + vBox->setSpacing(spacing); + + // 'View Properties' box + QGroupBox* propsBox = new QGroupBox(i18nc("@title:group", "View Properties"), vBox); + + m_localProps = new QRadioButton(i18nc("@option:radio", "Remember view properties for each folder"), propsBox); + connect(m_localProps, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + m_globalProps = new QRadioButton(i18nc("@option:radio", "Use common view properties for all folders"), propsBox); + connect(m_globalProps, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox); + propsBoxLayout->addWidget(m_localProps); + propsBoxLayout->addWidget(m_globalProps); + + // 'Ask Confirmation For' box + QGroupBox* confirmBox = new QGroupBox(i18nc("@title:group", "Ask For Confirmation When"), vBox); + m_confirmMoveToTrash = new QCheckBox(i18nc("@option:check Ask for Confirmation When", + "Moving files or folders to trash"), confirmBox); + connect(m_confirmMoveToTrash, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for Confirmation When", + "Deleting files or folders"), confirmBox); + connect(m_confirmDelete, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + QVBoxLayout* confirmBoxLayout = new QVBoxLayout(confirmBox); + confirmBoxLayout->addWidget(m_confirmMoveToTrash); + confirmBoxLayout->addWidget(m_confirmDelete); + + m_renameInline = new QCheckBox(i18nc("@option:check", "Rename inline"), vBox); + connect(m_renameInline, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips"), vBox); + connect(m_showToolTips, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker"), vBox); + connect(m_showSelectionToggle, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + // Add a dummy widget with no restriction regarding + // a vertical resizing. This assures that the dialog layout + // is not stretched vertically. + new QWidget(vBox); + + topLayout->addWidget(vBox); + + loadSettings(); +} + +BehaviorSettingsPage::~BehaviorSettingsPage() +{ +} + +void BehaviorSettingsPage::applySettings() +{ + ViewProperties props(m_url); // read current view properties + + const bool useGlobalProps = m_globalProps->isChecked(); + + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setGlobalViewProps(useGlobalProps); + + if (useGlobalProps) { + // 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); + } + + KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::NoGlobals); + KConfigGroup confirmationGroup(kioConfig, "Confirmations"); + confirmationGroup.writeEntry("ConfirmTrash", m_confirmMoveToTrash->isChecked()); + confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked()); + confirmationGroup.sync(); + + settings->setRenameInline(m_renameInline->isChecked()); + settings->setShowToolTips(m_showToolTips->isChecked()); + settings->setShowSelectionToggle(m_showSelectionToggle->isChecked()); +} + +void BehaviorSettingsPage::restoreDefaults() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setDefaults(); + + // TODO: reset default settings for trash and show delete command... + + loadSettings(); +} + +void BehaviorSettingsPage::loadSettings() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + if (settings->globalViewProps()) { + m_globalProps->setChecked(true); + } else { + m_localProps->setChecked(true); + } + + KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::IncludeGlobals); + const KConfigGroup confirmationGroup(kioConfig, "Confirmations"); + m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", false)); + m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", true)); + + m_renameInline->setChecked(settings->renameInline()); + m_showToolTips->setChecked(settings->showToolTips()); + m_showSelectionToggle->setChecked(settings->showSelectionToggle()); +} + +#include "behaviorsettingspage.moc" diff --git a/src/settings/behaviorsettingspage.h b/src/settings/behaviorsettingspage.h new file mode 100644 index 000000000..401f2240a --- /dev/null +++ b/src/settings/behaviorsettingspage.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz * + * peter.penz@gmx.at * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ +#ifndef BEHAVIORSETTINGSPAGE_H +#define BEHAVIORSETTINGSPAGE_H + +#include +#include + +class DolphinMainWindow; +class QCheckBox; +class QRadioButton; + +/** + * @brief Tab page for the 'Behavior' settings of the Dolphin settings dialog. + */ +class BehaviorSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + BehaviorSettingsPage(const KUrl& url, QWidget* parent); + virtual ~BehaviorSettingsPage(); + + /** @see SettingsPageBase::applySettings() */ + virtual void applySettings(); + + /** @see SettingsPageBase::restoreDefaults() */ + virtual void restoreDefaults(); + +private: + void loadSettings(); + +private: + KUrl m_url; + + QRadioButton* m_localProps; + QRadioButton* m_globalProps; + + QCheckBox* m_confirmMoveToTrash; + QCheckBox* m_confirmDelete; + + QCheckBox* m_renameInline; + QCheckBox* m_showToolTips; + QCheckBox* m_showSelectionToggle; +}; + +#endif diff --git a/src/settings/contextmenusettingspage.cpp b/src/settings/contextmenusettingspage.cpp new file mode 100644 index 000000000..77f781c57 --- /dev/null +++ b/src/settings/contextmenusettingspage.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "contextmenusettingspage.h" +#include "dolphinsettings.h" +#include "dolphin_generalsettings.h" + +#include +#include +#include + +#include +#include + +ContextMenuSettingsPage::ContextMenuSettingsPage(QWidget* parent) : + SettingsPageBase(parent), + m_showDeleteCommand(0), + m_showCopyMoveMenu(0) +{ + QVBoxLayout* topLayout = new QVBoxLayout(this); + KVBox* vBox = new KVBox(this); + vBox->setSpacing(KDialog::spacingHint()); + + m_showDeleteCommand = new QCheckBox(i18nc("@option:check", "Show 'Delete' command"), vBox); + connect(m_showDeleteCommand, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + m_showCopyMoveMenu = new QCheckBox(i18nc("@option:check", "Show 'Copy To' and 'Move To' commands"), vBox); + connect(m_showCopyMoveMenu, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + // Add a dummy widget with no restriction regarding + // a vertical resizing. This assures that the dialog layout + // is not stretched vertically. + new QWidget(vBox); + + topLayout->addWidget(vBox); + + loadSettings(); +} + +ContextMenuSettingsPage::~ContextMenuSettingsPage() +{ +} + +void ContextMenuSettingsPage::applySettings() +{ + KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals); + KConfigGroup configGroup(globalConfig, "KDE"); + configGroup.writeEntry("ShowDeleteCommand", m_showDeleteCommand->isChecked()); + configGroup.sync(); + + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setShowCopyMoveMenu(m_showCopyMoveMenu->isChecked()); +} + +void ContextMenuSettingsPage::restoreDefaults() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setDefaults(); + loadSettings(); +} + +void ContextMenuSettingsPage::loadSettings() +{ + KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals); + KConfigGroup configGroup(globalConfig, "KDE"); + m_showDeleteCommand->setChecked(configGroup.readEntry("ShowDeleteCommand", false)); + + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + m_showCopyMoveMenu->setChecked(settings->showCopyMoveMenu()); +} + +#include "contextmenusettingspage.moc" diff --git a/src/settings/contextmenusettingspage.h b/src/settings/contextmenusettingspage.h new file mode 100644 index 000000000..8a11c23c5 --- /dev/null +++ b/src/settings/contextmenusettingspage.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ +#ifndef CONTEXTMENUSETTINGSPAGE_H +#define CONTEXTMENUSETTINGSPAGE_H + +#include + +class QCheckBox; + +/** + * @brief Page for the 'Context Menu' settings of the Dolphin settings dialog. + */ +class ContextMenuSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + ContextMenuSettingsPage(QWidget* parent); + virtual ~ContextMenuSettingsPage(); + + /** @see SettingsPageBase::applySettings() */ + virtual void applySettings(); + + /** @see SettingsPageBase::restoreDefaults() */ + virtual void restoreDefaults(); + +private: + void loadSettings(); + +private: + QCheckBox* m_showDeleteCommand; + QCheckBox* m_showCopyMoveMenu; +}; + +#endif diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp index 54ac74bde..64ebdeed7 100644 --- a/src/settings/dolphinsettingsdialog.cpp +++ b/src/settings/dolphinsettingsdialog.cpp @@ -23,6 +23,8 @@ #include #include #include "generalsettingspage.h" +#include "navigationsettingspage.h" +#include "servicessettingspage.h" #include "startupsettingspage.h" #include "viewsettingspage.h" @@ -30,8 +32,8 @@ #include #include -DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) : - KPageDialog(mainWindow), +DolphinSettingsDialog::DolphinSettingsDialog(const KUrl& url, QWidget* parent) : + KPageDialog(parent), m_pages() { @@ -44,19 +46,36 @@ DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) : enableButtonApply(false); setDefaultButton(Ok); - StartupSettingsPage* startupSettingsPage = new StartupSettingsPage(mainWindow, this); + // Startup + StartupSettingsPage* startupSettingsPage = new StartupSettingsPage(url, this); KPageWidgetItem* startupSettingsFrame = addPage(startupSettingsPage, i18nc("@title:group", "Startup")); startupSettingsFrame->setIcon(KIcon("go-home")); connect(startupSettingsPage, SIGNAL(changed()), this, SLOT(enableApply())); - ViewSettingsPage* viewSettingsPage = new ViewSettingsPage(mainWindow, this); + // View Modes + ViewSettingsPage* viewSettingsPage = new ViewSettingsPage(this); KPageWidgetItem* viewSettingsFrame = addPage(viewSettingsPage, i18nc("@title:group", "View Modes")); viewSettingsFrame->setIcon(KIcon("view-choose")); connect(viewSettingsPage, SIGNAL(changed()), this, SLOT(enableApply())); - GeneralSettingsPage* generalSettingsPage = new GeneralSettingsPage(mainWindow, this); + // Navigation + NavigationSettingsPage* navigationSettingsPage = new NavigationSettingsPage(this); + KPageWidgetItem* navigationSettingsFrame = addPage(navigationSettingsPage, + i18nc("@title:group", "Navigation")); + navigationSettingsFrame->setIcon(KIcon("input-mouse")); + connect(navigationSettingsPage, SIGNAL(changed()), this, SLOT(enableApply())); + + // Services + ServicesSettingsPage* servicesSettingsPage = new ServicesSettingsPage(this); + KPageWidgetItem* servicesSettingsFrame = addPage(servicesSettingsPage, + i18nc("@title:group", "Services")); + servicesSettingsFrame->setIcon(KIcon("services")); + connect(servicesSettingsPage, SIGNAL(changed()), this, SLOT(enableApply())); + + // General + GeneralSettingsPage* generalSettingsPage = new GeneralSettingsPage(url, this); KPageWidgetItem* generalSettingsFrame = addPage(generalSettingsPage, i18nc("@title:group General settings", "General")); generalSettingsFrame->setIcon(KIcon("system-run")); @@ -67,6 +86,8 @@ DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) : m_pages.append(startupSettingsPage); m_pages.append(viewSettingsPage); + m_pages.append(navigationSettingsPage); + m_pages.append(servicesSettingsPage); m_pages.append(generalSettingsPage); } diff --git a/src/settings/dolphinsettingsdialog.h b/src/settings/dolphinsettingsdialog.h index fc17b3774..90cfd3493 100644 --- a/src/settings/dolphinsettingsdialog.h +++ b/src/settings/dolphinsettingsdialog.h @@ -23,22 +23,21 @@ #include +class KUrl; class DolphinMainWindow; class SettingsPageBase; /** * @brief Settings dialog for Dolphin. * - * Contains the pages for startup settings, general settings and view settings. - * - * @author Peter Penz + * Contains the pages for Startup, View Modes, Navigation, Services and General. */ class DolphinSettingsDialog : public KPageDialog { Q_OBJECT public: - explicit DolphinSettingsDialog(DolphinMainWindow* mainWindow); + explicit DolphinSettingsDialog(const KUrl& url, QWidget* parent); virtual ~DolphinSettingsDialog(); protected slots: diff --git a/src/settings/generalsettingspage.cpp b/src/settings/generalsettingspage.cpp index 86b6f1939..6b7d5917c 100644 --- a/src/settings/generalsettingspage.cpp +++ b/src/settings/generalsettingspage.cpp @@ -1,6 +1,6 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) and * - * and Patrice Tremblay * + * Copyright (C) 2006 by Peter Penz * + * peter.penz@gmx.at * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -15,99 +15,60 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "generalsettingspage.h" -#include "settings/dolphinsettings.h" - -#include "dolphin_generalsettings.h" +#include "behaviorsettingspage.h" +#include "contextmenusettingspage.h" +#include "previewssettingspage.h" +#include "settingspagebase.h" +#include "statusbarsettingspage.h" #include #include -#include +#include +#include -#include -#include -#include #include -GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* parent) : +GeneralSettingsPage::GeneralSettingsPage(const KUrl& url, QWidget* parent) : SettingsPageBase(parent), - m_confirmMoveToTrash(0), - m_confirmDelete(0), - m_showDeleteCommand(0), - m_showCopyMoveMenu(0), - m_showZoomSlider(0), - m_showSpaceInfo(0), - m_browseThroughArchives(0), - m_renameInline(0), - m_autoExpandFolders(0) + m_pages() { - Q_UNUSED(mainWin); - - const int spacing = KDialog::spacingHint(); - QVBoxLayout* topLayout = new QVBoxLayout(this); - KVBox* vBox = new KVBox(this); - vBox->setSpacing(spacing); - - // create 'Ask Confirmation For' group - QGroupBox* confirmBox = new QGroupBox(i18nc("@title:group", "Ask For Confirmation When"), vBox); - m_confirmMoveToTrash = new QCheckBox(i18nc("@option:check Ask for Confirmation When", - "Moving files or folders to trash"), confirmBox); - connect(m_confirmMoveToTrash, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for Confirmation When", - "Deleting files or folders"), confirmBox); - connect(m_confirmDelete, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - QVBoxLayout* confirmBoxLayout = new QVBoxLayout(confirmBox); - confirmBoxLayout->addWidget(m_confirmMoveToTrash); - confirmBoxLayout->addWidget(m_confirmDelete); - - QGroupBox* contextMenuBox = new QGroupBox(i18nc("@title:group", "Context Menu"), vBox); - - // create 'Show the command 'Delete' in context menu' checkbox - m_showDeleteCommand = new QCheckBox(i18nc("@option:check", "Show 'Delete' command"), contextMenuBox); - connect(m_showDeleteCommand, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - m_showCopyMoveMenu = new QCheckBox(i18nc("@option:check", "Show 'Copy To' and 'Move To' commands"), contextMenuBox); - connect(m_showCopyMoveMenu, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - QVBoxLayout* contextMenuBoxLayout = new QVBoxLayout(contextMenuBox); - contextMenuBoxLayout->addWidget(m_showDeleteCommand); - contextMenuBoxLayout->addWidget(m_showCopyMoveMenu); + topLayout->setMargin(0); + topLayout->setSpacing(KDialog::spacingHint()); - QGroupBox* statusBarBox = new QGroupBox(i18nc("@title:group", "Status Bar"), vBox); + KTabWidget* tabWidget = new KTabWidget(this); - m_showZoomSlider = new QCheckBox(i18nc("@option:check", "Show zoom slider"), statusBarBox); - connect(m_showZoomSlider, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + // initialize 'Behavior' tab + BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(url, tabWidget); + tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior")); + connect(behaviorPage, SIGNAL(changed()), this, SIGNAL(changed())); - m_showSpaceInfo = new QCheckBox(i18nc("@option:check", "Show space information"), statusBarBox); - connect(m_showSpaceInfo, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + // initialize 'Previews' tab + PreviewsSettingsPage* previewsPage = new PreviewsSettingsPage(tabWidget); + tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews")); + connect(previewsPage, SIGNAL(changed()), this, SIGNAL(changed())); - QVBoxLayout* statusBarBoxLayout = new QVBoxLayout(statusBarBox); - statusBarBoxLayout->addWidget(m_showZoomSlider); - statusBarBoxLayout->addWidget(m_showSpaceInfo); + // initialize 'Context Menu' tab + ContextMenuSettingsPage* contextMenuPage = new ContextMenuSettingsPage(tabWidget); + tabWidget->addTab(contextMenuPage, i18nc("@title:tab Context Menu settings", "Context Menu")); + connect(contextMenuPage, SIGNAL(changed()), this, SIGNAL(changed())); - m_browseThroughArchives = new QCheckBox(i18nc("@option:check", "Browse through archives"), vBox); - connect(m_browseThroughArchives, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + // initialize 'Status Bar' tab + StatusBarSettingsPage* statusBarPage = new StatusBarSettingsPage(tabWidget); + tabWidget->addTab(statusBarPage, i18nc("@title:tab Status Bar settings", "Status Bar")); + connect(statusBarPage, SIGNAL(changed()), this, SIGNAL(changed())); - m_renameInline = new QCheckBox(i18nc("@option:check", "Rename inline"), vBox); - connect(m_renameInline, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + m_pages.append(behaviorPage); + m_pages.append(previewsPage); + m_pages.append(contextMenuPage); + m_pages.append(statusBarPage); - m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox); - connect(m_autoExpandFolders, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - // Add a dummy widget with no restriction regarding - // a vertical resizing. This assures that the dialog layout - // is not stretched vertically. - new QWidget(vBox); - - topLayout->addWidget(vBox); - - loadSettings(); + topLayout->addWidget(tabWidget, 0, 0); } GeneralSettingsPage::~GeneralSettingsPage() @@ -116,55 +77,16 @@ GeneralSettingsPage::~GeneralSettingsPage() void GeneralSettingsPage::applySettings() { - GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - - KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::NoGlobals); - KConfigGroup confirmationGroup(kioConfig, "Confirmations"); - confirmationGroup.writeEntry("ConfirmTrash", m_confirmMoveToTrash->isChecked()); - confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked()); - confirmationGroup.sync(); - - KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals); - KConfigGroup configGroup(globalConfig, "KDE"); - configGroup.writeEntry("ShowDeleteCommand", m_showDeleteCommand->isChecked()); - configGroup.sync(); - - settings->setShowCopyMoveMenu(m_showCopyMoveMenu->isChecked()); - settings->setShowZoomSlider(m_showZoomSlider->isChecked()); - settings->setShowSpaceInfo(m_showSpaceInfo->isChecked()); - settings->setBrowseThroughArchives(m_browseThroughArchives->isChecked()); - settings->setRenameInline(m_renameInline->isChecked()); - settings->setAutoExpandFolders(m_autoExpandFolders->isChecked()); + foreach (SettingsPageBase* page, m_pages) { + page->applySettings(); + } } void GeneralSettingsPage::restoreDefaults() { - GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - settings->setDefaults(); - - // TODO: reset default settings for trash and show delete command... - - loadSettings(); -} - -void GeneralSettingsPage::loadSettings() -{ - KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::IncludeGlobals); - const KConfigGroup confirmationGroup(kioConfig, "Confirmations"); - m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", false)); - m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", true)); - - KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals); - KConfigGroup configGroup(globalConfig, "KDE"); - m_showDeleteCommand->setChecked(configGroup.readEntry("ShowDeleteCommand", false)); - - GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - m_showCopyMoveMenu->setChecked(settings->showCopyMoveMenu()); - m_showZoomSlider->setChecked(settings->showZoomSlider()); - m_showSpaceInfo->setChecked(settings->showSpaceInfo()); - m_browseThroughArchives->setChecked(settings->browseThroughArchives()); - m_renameInline->setChecked(settings->renameInline()); - m_autoExpandFolders->setChecked(settings->autoExpandFolders()); + foreach (SettingsPageBase* page, m_pages) { + page->restoreDefaults(); + } } #include "generalsettingspage.moc" diff --git a/src/settings/generalsettingspage.h b/src/settings/generalsettingspage.h index 4059dc3c6..ac1e7c61c 100644 --- a/src/settings/generalsettingspage.h +++ b/src/settings/generalsettingspage.h @@ -15,26 +15,33 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef GENERALSETTINGSPAGE_H #define GENERALSETTINGSPAGE_H +#include #include +class KUrl; +class SettingsPageBase; class DolphinMainWindow; -class QLineEdit; -class QCheckBox; /** * @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(DolphinMainWindow* mainWindow, QWidget* parent); + GeneralSettingsPage(const KUrl& url, QWidget* parent); virtual ~GeneralSettingsPage(); /** @see SettingsPageBase::applySettings() */ @@ -44,21 +51,7 @@ public: virtual void restoreDefaults(); private: - void loadSettings(); - -private: - QCheckBox* m_confirmMoveToTrash; - QCheckBox* m_confirmDelete; - - QCheckBox* m_showDeleteCommand; - QCheckBox* m_showCopyMoveMenu; - - QCheckBox* m_showZoomSlider; - QCheckBox* m_showSpaceInfo; - - QCheckBox* m_browseThroughArchives; - QCheckBox* m_renameInline; - QCheckBox* m_autoExpandFolders; + QList m_pages; }; #endif diff --git a/src/settings/generalviewsettingspage.cpp b/src/settings/generalviewsettingspage.cpp deleted file mode 100644 index acea9649c..000000000 --- a/src/settings/generalviewsettingspage.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "generalviewsettingspage.h" -#include "dolphinmainwindow.h" -#include "settings/dolphinsettings.h" -#include "dolphinviewcontainer.h" -#include "viewproperties.h" - -#include "dolphin_generalsettings.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -GeneralViewSettingsPage::GeneralViewSettingsPage(const KUrl& url, - QWidget* parent) : - ViewSettingsPageBase(parent), - m_url(url), - m_localProps(0), - m_globalProps(0), - m_maxPreviewSize(0), - m_spinBox(0), - m_useFileThumbnails(0), - m_showSelectionToggle(0), - m_showToolTips(0) -{ - const int spacing = KDialog::spacingHint(); - const int margin = KDialog::marginHint(); - const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - - setSpacing(spacing); - setMargin(margin); - - QGroupBox* propsBox = new QGroupBox(i18nc("@title:group", "View Properties"), this); - - m_localProps = new QRadioButton(i18nc("@option:radio", "Remember view properties for each folder"), propsBox); - connect(m_localProps, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - m_globalProps = new QRadioButton(i18nc("@option:radio", "Use common view properties for all folders"), propsBox); - connect(m_globalProps, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox); - propsBoxLayout->addWidget(m_localProps); - propsBoxLayout->addWidget(m_globalProps); - - // create 'File Previews' box - QGroupBox* previewBox = new QGroupBox(i18nc("@title:group", "File Previews"), this); - - KHBox* vBox = new KHBox(previewBox); - vBox->setSpacing(spacing); - - new QLabel(i18nc("@label:slider", "Maximum file size:"), vBox); - m_maxPreviewSize = new QSlider(Qt::Horizontal, vBox); - - m_spinBox = new QSpinBox(vBox); - - connect(m_maxPreviewSize, SIGNAL(valueChanged(int)), - m_spinBox, SLOT(setValue(int))); - connect(m_spinBox, SIGNAL(valueChanged(int)), - m_maxPreviewSize, SLOT(setValue(int))); - - connect(m_maxPreviewSize, SIGNAL(valueChanged(int)), - this, SIGNAL(changed())); - connect(m_spinBox, SIGNAL(valueChanged(int)), - this, SIGNAL(changed())); - - m_useFileThumbnails = new QCheckBox(i18nc("@option:check", "Use thumbnails embedded in files"), previewBox); - connect(m_useFileThumbnails, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - QVBoxLayout* previewBoxLayout = new QVBoxLayout(previewBox); - previewBoxLayout->addWidget(vBox); - previewBoxLayout->addWidget(m_useFileThumbnails); - - m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker"), this); - connect(m_showSelectionToggle, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips"), this); - connect(m_showToolTips, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - // Add a dummy widget with no restriction regarding - // a vertical resizing. This assures that the dialog layout - // is not stretched vertically. - new QWidget(this); - - loadSettings(); -} - - -GeneralViewSettingsPage::~GeneralViewSettingsPage() -{ -} - -void GeneralViewSettingsPage::applySettings() -{ - ViewProperties props(m_url); // read current view properties - - const bool useGlobalProps = m_globalProps->isChecked(); - - GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - settings->setGlobalViewProps(useGlobalProps); - - if (useGlobalProps) { - // 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); - } - - KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings"); - const int byteCount = m_maxPreviewSize->value() * 1024 * 1024; // value() returns size in MB - globalConfig.writeEntry("MaximumSize", - byteCount, - KConfigBase::Normal | KConfigBase::Global); - globalConfig.writeEntry("UseFileThumbnails", - m_useFileThumbnails->isChecked(), - KConfigBase::Normal | KConfigBase::Global); - globalConfig.sync(); - - settings->setShowSelectionToggle(m_showSelectionToggle->isChecked()); - settings->setShowToolTips(m_showToolTips->isChecked()); -} - -void GeneralViewSettingsPage::restoreDefaults() -{ - GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - settings->setDefaults(); - loadSettings(); -} - -void GeneralViewSettingsPage::loadSettings() -{ - GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - if (settings->globalViewProps()) { - m_globalProps->setChecked(true); - } else { - m_localProps->setChecked(true); - } - - const int min = 1; // MB - const int max = 100; // MB - m_maxPreviewSize->setRange(min, max); - m_maxPreviewSize->setPageStep(10); - m_maxPreviewSize->setSingleStep(1); - m_maxPreviewSize->setTickPosition(QSlider::TicksBelow); - - KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings"); - // TODO: The default value of 5 MB must match with the default value inside - // kdelibs/kio/kio/previewjob.cpp. Maybe a static getter method in PreviewJob - // should be added for getting the default size? - const int maxByteSize = globalConfig.readEntry("MaximumSize", 5 * 1024 * 1024 /* 5 MB */); - int maxMByteSize = maxByteSize / (1024 * 1024); - if (maxMByteSize < 1) { - maxMByteSize = 1; - } else if (maxMByteSize > max) { - maxMByteSize = max; - } - - m_spinBox->setRange(min, max); - m_spinBox->setSingleStep(1); - m_spinBox->setSuffix(" MB"); - - m_maxPreviewSize->setValue(maxMByteSize); - m_spinBox->setValue(m_maxPreviewSize->value()); - - const bool useFileThumbnails = globalConfig.readEntry("UseFileThumbnails", true); - m_useFileThumbnails->setChecked(useFileThumbnails); - - m_showSelectionToggle->setChecked(settings->showSelectionToggle()); - m_showToolTips->setChecked(settings->showToolTips()); -} - -#include "generalviewsettingspage.moc" diff --git a/src/settings/generalviewsettingspage.h b/src/settings/generalviewsettingspage.h deleted file mode 100644 index b0bd7e005..000000000 --- a/src/settings/generalviewsettingspage.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef GENERALVIEWSETTINGSPAGE_H -#define GENERALVIEWSETTINGSPAGE_H - -#include -#include - -class DolphinMainWindow; -class QCheckBox; -class QRadioButton; -class QSlider; -class QSpinBox; - -/** - * @brief Represents the page from the Dolphin Settings which allows - * to modify general settings for the view modes. - */ -class GeneralViewSettingsPage : public ViewSettingsPageBase -{ - Q_OBJECT - -public: - /** - * @param url URL of the currently shown directory, which is used - * to read the viewproperties. - * @param parent Parent widget of the settings page. - */ - GeneralViewSettingsPage(const KUrl& url, QWidget* parent); - virtual ~GeneralViewSettingsPage(); - - /** - * Applies the general settings for the view modes - * The settings are persisted automatically when - * closing Dolphin. - */ - virtual void applySettings(); - - /** Restores the settings to default values. */ - virtual void restoreDefaults(); - -private: - void loadSettings(); - -private: - KUrl m_url; - QRadioButton* m_localProps; - QRadioButton* m_globalProps; - QSlider* m_maxPreviewSize; - QSpinBox* m_spinBox; - QCheckBox* m_useFileThumbnails; - QCheckBox* m_showSelectionToggle; - QCheckBox* m_showToolTips; -}; - -#endif diff --git a/src/settings/navigationsettingspage.cpp b/src/settings/navigationsettingspage.cpp new file mode 100644 index 000000000..81ca7e83a --- /dev/null +++ b/src/settings/navigationsettingspage.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "navigationsettingspage.h" + +#include "settings/dolphinsettings.h" + +#include "dolphin_generalsettings.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) : + SettingsPageBase(parent), + m_browseThroughArchives(0), + m_autoExpandFolders(0) +{ + const int spacing = KDialog::spacingHint(); + + QVBoxLayout* topLayout = new QVBoxLayout(this); + KVBox* vBox = new KVBox(this); + vBox->setSpacing(spacing); + + // create 'Mouse' group + QGroupBox* mouseBox = new QGroupBox(i18nc("@title:group", "Mouse"), vBox); + m_singleClick = new QRadioButton(i18nc("@option:check Mouse Settings", + "Single-click to open files and folders"), mouseBox); + connect(m_singleClick, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + m_doubleClick = new QRadioButton(i18nc("@option:check Mouse Settings", + "Double-click to open files and folders"), mouseBox); + connect(m_doubleClick, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + QVBoxLayout* mouseBoxLayout = new QVBoxLayout(mouseBox); + mouseBoxLayout->addWidget(m_singleClick); + mouseBoxLayout->addWidget(m_doubleClick); + + m_browseThroughArchives = new QCheckBox(i18nc("@option:check", "Browse through archives"), vBox); + connect(m_browseThroughArchives, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox); + connect(m_autoExpandFolders, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + // Add a dummy widget with no restriction regarding + // a vertical resizing. This assures that the dialog layout + // is not stretched vertically. + new QWidget(vBox); + + topLayout->addWidget(vBox); + + loadSettings(); +} + +NavigationSettingsPage::~NavigationSettingsPage() +{ +} + +void NavigationSettingsPage::applySettings() +{ + KConfig config("kcminputrc"); + KConfigGroup group = config.group("Mouse"); + group.writeEntry("SingleClick", m_singleClick->isChecked(), KConfig::Persistent|KConfig::Global); + config.sync(); + KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE); + + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setBrowseThroughArchives(m_browseThroughArchives->isChecked()); + settings->setAutoExpandFolders(m_autoExpandFolders->isChecked()); +} + +void NavigationSettingsPage::restoreDefaults() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setDefaults(); + loadSettings(); +} + +void NavigationSettingsPage::loadSettings() +{ + const bool singleClick = KGlobalSettings::singleClick(); + m_singleClick->setChecked(singleClick); + m_doubleClick->setChecked(!singleClick); + + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + m_browseThroughArchives->setChecked(settings->browseThroughArchives()); + m_autoExpandFolders->setChecked(settings->autoExpandFolders()); +} + +#include "navigationsettingspage.moc" diff --git a/src/settings/navigationsettingspage.h b/src/settings/navigationsettingspage.h new file mode 100644 index 000000000..10f75b1a0 --- /dev/null +++ b/src/settings/navigationsettingspage.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ +#ifndef NAVIGATIONSETTINGSPAGE_H +#define NAVIGATIONSETTINGSPAGE_H + +#include + +class QCheckBox; +class QRadioButton; + +/** + * @brief Page for the 'Navigation' settings of the Dolphin settings dialog. + */ +class NavigationSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + NavigationSettingsPage(QWidget* parent); + virtual ~NavigationSettingsPage(); + + /** @see SettingsPageBase::applySettings() */ + virtual void applySettings(); + + /** @see SettingsPageBase::restoreDefaults() */ + virtual void restoreDefaults(); + +private: + void loadSettings(); + +private: + QRadioButton* m_singleClick; + QRadioButton* m_doubleClick; + QCheckBox* m_browseThroughArchives; + QCheckBox* m_autoExpandFolders; +}; + +#endif diff --git a/src/settings/previewssettingspage.cpp b/src/settings/previewssettingspage.cpp new file mode 100644 index 000000000..d0fb0ac90 --- /dev/null +++ b/src/settings/previewssettingspage.cpp @@ -0,0 +1,138 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "previewssettingspage.h" +#include "dolphinsettings.h" + +#include "dolphin_generalsettings.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +PreviewsSettingsPage::PreviewsSettingsPage(QWidget* parent) : + SettingsPageBase(parent), + m_maxPreviewSize(0), + m_spinBox(0), + m_useFileThumbnails(0) +{ + KVBox* vBox = new KVBox(this); + vBox->setSpacing(KDialog::spacingHint()); + vBox->setMargin(KDialog::marginHint()); + + new QLabel("TODO: a major rewrite of this dialog will be done in 4.3", vBox); + + KHBox* hBox = new KHBox(vBox); + hBox->setSpacing(KDialog::spacingHint()); + + new QLabel(i18nc("@label:slider", "Maximum file size:"), hBox); + m_maxPreviewSize = new QSlider(Qt::Horizontal, hBox); + + m_spinBox = new QSpinBox(hBox); + + connect(m_maxPreviewSize, SIGNAL(valueChanged(int)), + m_spinBox, SLOT(setValue(int))); + connect(m_spinBox, SIGNAL(valueChanged(int)), + m_maxPreviewSize, SLOT(setValue(int))); + + connect(m_maxPreviewSize, SIGNAL(valueChanged(int)), + this, SIGNAL(changed())); + connect(m_spinBox, SIGNAL(valueChanged(int)), + this, SIGNAL(changed())); + + m_useFileThumbnails = new QCheckBox(i18nc("@option:check", "Use thumbnails embedded in files"), vBox); + connect(m_useFileThumbnails, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + // Add a dummy widget with no restriction regarding + // a vertical resizing. This assures that the dialog layout + // is not stretched vertically. + new QWidget(vBox); + + loadSettings(); +} + + +PreviewsSettingsPage::~PreviewsSettingsPage() +{ +} + +void PreviewsSettingsPage::applySettings() +{ + KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings"); + const int byteCount = m_maxPreviewSize->value() * 1024 * 1024; // value() returns size in MB + globalConfig.writeEntry("MaximumSize", + byteCount, + KConfigBase::Normal | KConfigBase::Global); + globalConfig.writeEntry("UseFileThumbnails", + m_useFileThumbnails->isChecked(), + KConfigBase::Normal | KConfigBase::Global); + globalConfig.sync(); +} + +void PreviewsSettingsPage::restoreDefaults() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setDefaults(); + loadSettings(); +} + +void PreviewsSettingsPage::loadSettings() +{ + const int min = 1; // MB + const int max = 100; // MB + m_maxPreviewSize->setRange(min, max); + m_maxPreviewSize->setPageStep(10); + m_maxPreviewSize->setSingleStep(1); + m_maxPreviewSize->setTickPosition(QSlider::TicksBelow); + + KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings"); + // TODO: The default value of 5 MB must match with the default value inside + // kdelibs/kio/kio/previewjob.cpp. Maybe a static getter method in PreviewJob + // should be added for getting the default size? + const int maxByteSize = globalConfig.readEntry("MaximumSize", 5 * 1024 * 1024 /* 5 MB */); + int maxMByteSize = maxByteSize / (1024 * 1024); + if (maxMByteSize < 1) { + maxMByteSize = 1; + } else if (maxMByteSize > max) { + maxMByteSize = max; + } + + m_spinBox->setRange(min, max); + m_spinBox->setSingleStep(1); + m_spinBox->setSuffix(" MB"); + + m_maxPreviewSize->setValue(maxMByteSize); + m_spinBox->setValue(m_maxPreviewSize->value()); + + const bool useFileThumbnails = globalConfig.readEntry("UseFileThumbnails", true); + m_useFileThumbnails->setChecked(useFileThumbnails); +} + +#include "previewssettingspage.moc" diff --git a/src/settings/previewssettingspage.h b/src/settings/previewssettingspage.h new file mode 100644 index 000000000..5833a3db5 --- /dev/null +++ b/src/settings/previewssettingspage.h @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef PREVIEWSSETTINGSPAGE_H +#define PREVIEWSSETTINGSPAGE_H + +#include +#include + +class DolphinMainWindow; +class QCheckBox; +class QRadioButton; +class QSlider; +class QSpinBox; + +/** + * @brief Allows the configuration of file previews. + */ +class PreviewsSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + PreviewsSettingsPage(QWidget* parent); + virtual ~PreviewsSettingsPage(); + + /** + * Applies the general settings for the view modes + * The settings are persisted automatically when + * closing Dolphin. + */ + virtual void applySettings(); + + /** Restores the settings to default values. */ + virtual void restoreDefaults(); + +private: + void loadSettings(); + +private: + QSlider* m_maxPreviewSize; + QSpinBox* m_spinBox; + QCheckBox* m_useFileThumbnails; +}; + +#endif diff --git a/src/settings/servicessettingspage.cpp b/src/settings/servicessettingspage.cpp new file mode 100644 index 000000000..ee00814a9 --- /dev/null +++ b/src/settings/servicessettingspage.cpp @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "servicessettingspage.h" + +#include "dolphinsettings.h" + +#include "dolphin_generalsettings.h" + +#include +#include +#include + +ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) : + SettingsPageBase(parent) +{ + loadSettings(); +} + +ServicesSettingsPage::~ServicesSettingsPage() +{ +} + +void ServicesSettingsPage::applySettings() +{ +} + +void ServicesSettingsPage::restoreDefaults() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setDefaults(); + loadSettings(); +} + +void ServicesSettingsPage::loadSettings() +{ +} + +#include "servicessettingspage.moc" diff --git a/src/settings/servicessettingspage.h b/src/settings/servicessettingspage.h new file mode 100644 index 000000000..a64602f13 --- /dev/null +++ b/src/settings/servicessettingspage.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ +#ifndef SERVICESSETTINGSPAGE_H +#define SERVICESSETTINGSPAGE_H + +#include + +class QLineEdit; +class QCheckBox; + +/** + * @brief Page for the 'Services' settings of the Dolphin settings dialog. + */ +class ServicesSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + ServicesSettingsPage(QWidget* parent); + virtual ~ServicesSettingsPage(); + + /** @see SettingsPageBase::applySettings() */ + virtual void applySettings(); + + /** @see SettingsPageBase::restoreDefaults() */ + virtual void restoreDefaults(); + +private: + void loadSettings(); + +private: +}; + +#endif diff --git a/src/settings/startupsettingspage.cpp b/src/settings/startupsettingspage.cpp index 767fcab66..9ea529132 100644 --- a/src/settings/startupsettingspage.cpp +++ b/src/settings/startupsettingspage.cpp @@ -39,9 +39,9 @@ #include #include -StartupSettingsPage::StartupSettingsPage(DolphinMainWindow* mainWin, QWidget* parent) : +StartupSettingsPage::StartupSettingsPage(const KUrl& url, QWidget* parent) : SettingsPageBase(parent), - m_mainWindow(mainWin), + m_url(url), m_homeUrl(0), m_splitView(0), m_editableUrl(0), @@ -147,8 +147,7 @@ void StartupSettingsPage::selectHomeUrl() void StartupSettingsPage::useCurrentLocation() { - const DolphinView* view = m_mainWindow->activeViewContainer()->view(); - m_homeUrl->setText(view->url().prettyUrl()); + m_homeUrl->setText(m_url.prettyUrl()); } void StartupSettingsPage::useDefaultLocation() diff --git a/src/settings/startupsettingspage.h b/src/settings/startupsettingspage.h index 04844f00c..98219a5a4 100644 --- a/src/settings/startupsettingspage.h +++ b/src/settings/startupsettingspage.h @@ -20,8 +20,8 @@ #define STARTUPSETTINGSPAGE_H #include +#include -class DolphinMainWindow; class KLineEdit; class QCheckBox; @@ -36,7 +36,7 @@ class StartupSettingsPage : public SettingsPageBase Q_OBJECT public: - StartupSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent); + StartupSettingsPage(const KUrl& url, QWidget* parent); virtual ~StartupSettingsPage(); /** @see SettingsPageBase::applySettings() */ @@ -54,7 +54,7 @@ private: void loadSettings(); private: - DolphinMainWindow* m_mainWindow; + KUrl m_url; KLineEdit* m_homeUrl; QCheckBox* m_splitView; diff --git a/src/settings/statusbarsettingspage.cpp b/src/settings/statusbarsettingspage.cpp new file mode 100644 index 000000000..c733c0b3a --- /dev/null +++ b/src/settings/statusbarsettingspage.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "statusbarsettingspage.h" +#include "dolphinsettings.h" +#include "dolphin_generalsettings.h" + +#include +#include +#include + +#include +#include + +StatusBarSettingsPage::StatusBarSettingsPage(QWidget* parent) : + SettingsPageBase(parent), + m_showZoomSlider(0), + m_showSpaceInfo(0) +{ + QVBoxLayout* topLayout = new QVBoxLayout(this); + KVBox* vBox = new KVBox(this); + vBox->setSpacing(KDialog::spacingHint()); + + m_showZoomSlider = new QCheckBox(i18nc("@option:check", "Show zoom slider"), vBox); + connect(m_showZoomSlider, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + m_showSpaceInfo = new QCheckBox(i18nc("@option:check", "Show space information"), vBox); + connect(m_showSpaceInfo, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + // Add a dummy widget with no restriction regarding + // a vertical resizing. This assures that the dialog layout + // is not stretched vertically. + new QWidget(vBox); + + topLayout->addWidget(vBox); + + loadSettings(); +} + +StatusBarSettingsPage::~StatusBarSettingsPage() +{ +} + +void StatusBarSettingsPage::applySettings() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setShowZoomSlider(m_showZoomSlider->isChecked()); + settings->setShowSpaceInfo(m_showSpaceInfo->isChecked()); +} + +void StatusBarSettingsPage::restoreDefaults() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->setDefaults(); + loadSettings(); +} + +void StatusBarSettingsPage::loadSettings() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + m_showZoomSlider->setChecked(settings->showZoomSlider()); + m_showSpaceInfo->setChecked(settings->showSpaceInfo()); +} + +#include "statusbarsettingspage.moc" diff --git a/src/settings/statusbarsettingspage.h b/src/settings/statusbarsettingspage.h new file mode 100644 index 000000000..6e9667be4 --- /dev/null +++ b/src/settings/statusbarsettingspage.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ +#ifndef STATUSBARSETTINGSPAGE_H +#define STATUSBARSETTINGSPAGE_H + +#include + +class QCheckBox; + +/** + * @brief Tab page for the 'Status Bar' settings of the Dolphin settings dialog. + */ +class StatusBarSettingsPage : public SettingsPageBase +{ + Q_OBJECT + +public: + StatusBarSettingsPage(QWidget* parent); + virtual ~StatusBarSettingsPage(); + + /** @see SettingsPageBase::applySettings() */ + virtual void applySettings(); + + /** @see SettingsPageBase::restoreDefaults() */ + virtual void restoreDefaults(); + +private: + void loadSettings(); + +private: + QCheckBox* m_showZoomSlider; + QCheckBox* m_showSpaceInfo; +}; + +#endif diff --git a/src/settings/viewsettingspage.cpp b/src/settings/viewsettingspage.cpp index 44d32af81..deb7a31bb 100644 --- a/src/settings/viewsettingspage.cpp +++ b/src/settings/viewsettingspage.cpp @@ -20,25 +20,18 @@ #include "viewsettingspage.h" -#include "settings/columnviewsettingspage.h" -#include "settings/detailsviewsettingspage.h" -#include "dolphinmainwindow.h" -#include "dolphinviewcontainer.h" -#include "settings/generalviewsettingspage.h" -#include "settings/iconsviewsettingspage.h" +#include "columnviewsettingspage.h" +#include "iconsviewsettingspage.h" +#include "detailsviewsettingspage.h" -#include -#include -#include +#include #include #include #include #include - -ViewSettingsPage::ViewSettingsPage(DolphinMainWindow* mainWindow, - QWidget* parent) : +ViewSettingsPage::ViewSettingsPage(QWidget* parent) : SettingsPageBase(parent), m_pages() { @@ -48,12 +41,6 @@ ViewSettingsPage::ViewSettingsPage(DolphinMainWindow* mainWindow, KTabWidget* tabWidget = new KTabWidget(this); - // initialize 'General' tab - const KUrl& url = mainWindow->activeViewContainer()->url(); - GeneralViewSettingsPage* generalPage = new GeneralViewSettingsPage(url, tabWidget); - tabWidget->addTab(generalPage, KIcon("view-choose"), i18nc("@title:tab General settings", "General")); - connect(generalPage, SIGNAL(changed()), this, SIGNAL(changed())); - // initialize 'Icons' tab IconsViewSettingsPage* iconsPage = new IconsViewSettingsPage(tabWidget); tabWidget->addTab(iconsPage, KIcon("view-list-icons"), i18nc("@title:tab", "Icons")); @@ -69,7 +56,6 @@ ViewSettingsPage::ViewSettingsPage(DolphinMainWindow* mainWindow, tabWidget->addTab(columnPage, KIcon("view-file-columns"), i18nc("@title:tab", "Column")); connect(columnPage, SIGNAL(changed()), this, SIGNAL(changed())); - m_pages.append(generalPage); m_pages.append(iconsPage); m_pages.append(detailsPage); m_pages.append(columnPage); diff --git a/src/settings/viewsettingspage.h b/src/settings/viewsettingspage.h index 5e76b30d1..56e9f910d 100644 --- a/src/settings/viewsettingspage.h +++ b/src/settings/viewsettingspage.h @@ -20,11 +20,10 @@ #ifndef VIEWSETTINGSPAGE_H #define VIEWSETTINGSPAGE_H -#include #include class ViewSettingsPageBase; -class DolphinMainWindow; +class QWidget; /** * @brief Page for the 'View' settings of the Dolphin settings dialog. @@ -37,7 +36,7 @@ class ViewSettingsPage : public SettingsPageBase Q_OBJECT public: - ViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent); + ViewSettingsPage(QWidget* parent); virtual ~ViewSettingsPage(); /** @see SettingsPageBase::applySettings() */ -- cgit v1.3