diff options
| author | Peter Penz <[email protected]> | 2010-07-24 20:39:19 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2010-07-24 20:39:19 +0000 |
| commit | d93d198db6eef9186177aa5a918b300a6b749627 (patch) | |
| tree | f62173c59b35860245b087bf5115d9e866c2eece /src/settings/general | |
| parent | 49eb864b03b6370e403c6f048ab18d1478eab045 (diff) | |
Sourcecode hierarchy cleanup: Use subfolders inside the "settings" folder
svn path=/trunk/KDE/kdebase/apps/; revision=1154129
Diffstat (limited to 'src/settings/general')
| -rw-r--r-- | src/settings/general/behaviorsettingspage.cpp | 223 | ||||
| -rw-r--r-- | src/settings/general/behaviorsettingspage.h | 80 | ||||
| -rw-r--r-- | src/settings/general/contextmenusettingspage.cpp | 94 | ||||
| -rw-r--r-- | src/settings/general/contextmenusettingspage.h | 51 | ||||
| -rw-r--r-- | src/settings/general/generalsettingspage.cpp | 92 | ||||
| -rw-r--r-- | src/settings/general/generalsettingspage.h | 56 | ||||
| -rw-r--r-- | src/settings/general/previewssettingspage.cpp | 182 | ||||
| -rw-r--r-- | src/settings/general/previewssettingspage.h | 66 | ||||
| -rw-r--r-- | src/settings/general/statusbarsettingspage.cpp | 85 | ||||
| -rw-r--r-- | src/settings/general/statusbarsettingspage.h | 51 |
10 files changed, 980 insertions, 0 deletions
diff --git a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp new file mode 100644 index 000000000..0d7a4a0ab --- /dev/null +++ b/src/settings/general/behaviorsettingspage.cpp @@ -0,0 +1,223 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz ([email protected]) 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 "dolphin_generalsettings.h" +#include <settings/filemetadataconfigurationdialog.h> +#include <settings/dolphinsettings.h> +#include <viewproperties.h> + +#include <kdialog.h> +#include <klocale.h> + +#include <QCheckBox> +#include <QGroupBox> +#include <QHBoxLayout> +#include <QLabel> +#include <QRadioButton> +#include <QVBoxLayout> + +const bool CONFIRM_TRASH = false; +const bool CONFIRM_DELETE = true; + +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_configureToolTips(0), + m_showSelectionToggle(0), + m_naturalSorting(0) +{ + QVBoxLayout* topLayout = new QVBoxLayout(this); + + // 'View Properties' box + QGroupBox* propsBox = new QGroupBox(i18nc("@title:group", "View Properties"), this); + propsBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); + + 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"), this); + confirmBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); + 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())); + m_confirmClosingMultipleTabs = new QCheckBox(i18nc("@option:check Ask for Confirmation When", + "Closing windows with multiple tabs"), confirmBox); + connect(m_confirmClosingMultipleTabs, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + QVBoxLayout* confirmBoxLayout = new QVBoxLayout(confirmBox); + confirmBoxLayout->addWidget(m_confirmMoveToTrash); + confirmBoxLayout->addWidget(m_confirmDelete); + confirmBoxLayout->addWidget(m_confirmClosingMultipleTabs); + + // 'Rename inline' + m_renameInline = new QCheckBox(i18nc("@option:check", "Rename inline"), this); + connect(m_renameInline, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + // 'Show tooltips' + QWidget* toolTipContainer = new QWidget(this); + QHBoxLayout* toolTipsLayout = new QHBoxLayout(toolTipContainer); + toolTipsLayout->setMargin(0); + m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips"), toolTipContainer); + connect(m_showToolTips, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + connect(m_showToolTips, SIGNAL(toggled(bool)), this, SLOT(updateConfigureButton())); + + m_configureToolTips = new QLabel(toolTipContainer); + connect(m_configureToolTips, SIGNAL(linkActivated(const QString&)), + this, SLOT(configureToolTips())); + + toolTipsLayout->addWidget(m_showToolTips); + toolTipsLayout->addWidget(m_configureToolTips, 1, Qt::AlignLeft); + + // 'Show selection marker' + m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker"), this); + connect(m_showSelectionToggle, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + // 'Natural sorting of items' + m_naturalSorting = new QCheckBox(i18nc("option:check", "Natural sorting of items"), this); + connect(m_naturalSorting, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + + topLayout->addWidget(propsBox); + topLayout->addWidget(confirmBox); + topLayout->addWidget(m_renameInline); + topLayout->addWidget(toolTipContainer); + topLayout->addWidget(m_showSelectionToggle); + topLayout->addWidget(m_naturalSorting); + topLayout->addStretch(); + + 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->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked()); + settings->setRenameInline(m_renameInline->isChecked()); + settings->setShowToolTips(m_showToolTips->isChecked()); + settings->setShowSelectionToggle(m_showSelectionToggle->isChecked()); + settings->writeConfig(); + + const bool naturalSorting = m_naturalSorting->isChecked(); + if (KGlobalSettings::naturalSorting() != naturalSorting) { + KConfigGroup group(KGlobal::config(), "KDE"); + group.writeEntry("NaturalSorting", naturalSorting, KConfig::Persistent | KConfig::Global); + KGlobalSettings::emitChange(KGlobalSettings::NaturalSortingChanged); + } +} + +void BehaviorSettingsPage::restoreDefaults() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->useDefaults(true); + loadSettings(); + settings->useDefaults(false); + m_confirmMoveToTrash->setChecked(CONFIRM_TRASH); + m_confirmDelete->setChecked(CONFIRM_DELETE); +} + +void BehaviorSettingsPage::updateConfigureButton() +{ + if (m_showToolTips->isChecked()) { + m_configureToolTips->setText("<a href=\"configure\">" + + i18nc("@action:button", "Configure...") + + "</a>"); + } else { + m_configureToolTips->setText(QString()); + } +} + +void BehaviorSettingsPage::configureToolTips() +{ + FileMetaDataConfigurationDialog* dialog = new FileMetaDataConfigurationDialog(); + dialog->setDescription(i18nc("@label::textbox", + "Select which data should be shown in the tooltip.")); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); + dialog->raise(); + dialog->activateWindow(); +} + +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", CONFIRM_TRASH)); + m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", CONFIRM_DELETE)); + + m_confirmClosingMultipleTabs->setChecked(settings->confirmClosingMultipleTabs()); + m_renameInline->setChecked(settings->renameInline()); + m_showToolTips->setChecked(settings->showToolTips()); + m_showSelectionToggle->setChecked(settings->showSelectionToggle()); + m_naturalSorting->setChecked(KGlobalSettings::naturalSorting()); + + updateConfigureButton(); +} + +#include "behaviorsettingspage.moc" diff --git a/src/settings/general/behaviorsettingspage.h b/src/settings/general/behaviorsettingspage.h new file mode 100644 index 000000000..331e45806 --- /dev/null +++ b/src/settings/general/behaviorsettingspage.h @@ -0,0 +1,80 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz * + * [email protected] * + * * + * 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 <settings/settingspagebase.h> +#include <kurl.h> + +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 KUrl& url, QWidget* parent); + virtual ~BehaviorSettingsPage(); + + /** @see SettingsPageBase::applySettings() */ + virtual void applySettings(); + + /** @see SettingsPageBase::restoreDefaults() */ + virtual void restoreDefaults(); + +private slots: + /** + * Updates the visibility state of the configure + * button m_configureToolTips. + */ + void updateConfigureButton(); + + /** + * Opens a dialog which allows the user to specify which + * meta data should be shown in the tooltip. + */ + void configureToolTips(); + +private: + void loadSettings(); + +private: + KUrl m_url; + + QRadioButton* m_localProps; + QRadioButton* m_globalProps; + + QCheckBox* m_confirmMoveToTrash; + QCheckBox* m_confirmDelete; + QCheckBox* m_confirmClosingMultipleTabs; + + QCheckBox* m_renameInline; + QCheckBox* m_showToolTips; + QLabel* m_configureToolTips; + QCheckBox* m_showSelectionToggle; + QCheckBox* m_naturalSorting; +}; + +#endif diff --git a/src/settings/general/contextmenusettingspage.cpp b/src/settings/general/contextmenusettingspage.cpp new file mode 100644 index 000000000..233e899b4 --- /dev/null +++ b/src/settings/general/contextmenusettingspage.cpp @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz <[email protected]> * + * * + * 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 <settings/dolphinsettings.h> +#include <dolphin_generalsettings.h> + +#include <kdialog.h> +#include <klocale.h> +#include <kvbox.h> + +#include <QCheckBox> +#include <QVBoxLayout> + +const bool SHOW_DELETE = false; + +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()); + settings->writeConfig(); +} + +void ContextMenuSettingsPage::restoreDefaults() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->useDefaults(true); + loadSettings(); + settings->useDefaults(false); + m_showDeleteCommand->setChecked(SHOW_DELETE); +} + +void ContextMenuSettingsPage::loadSettings() +{ + KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals); + KConfigGroup configGroup(globalConfig, "KDE"); + m_showDeleteCommand->setChecked(configGroup.readEntry("ShowDeleteCommand", SHOW_DELETE)); + + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + m_showCopyMoveMenu->setChecked(settings->showCopyMoveMenu()); +} + +#include "contextmenusettingspage.moc" diff --git a/src/settings/general/contextmenusettingspage.h b/src/settings/general/contextmenusettingspage.h new file mode 100644 index 000000000..8a11c23c5 --- /dev/null +++ b/src/settings/general/contextmenusettingspage.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz <[email protected]> * + * * + * 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 <settings/settingspagebase.h> + +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/general/generalsettingspage.cpp b/src/settings/general/generalsettingspage.cpp new file mode 100644 index 000000000..e156dadfc --- /dev/null +++ b/src/settings/general/generalsettingspage.cpp @@ -0,0 +1,92 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz * + * [email protected] * + * * + * 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 "generalsettingspage.h" + +#include "behaviorsettingspage.h" +#include "contextmenusettingspage.h" +#include "previewssettingspage.h" +#include <settings/settingspagebase.h> +#include "statusbarsettingspage.h" + +#include <kdialog.h> +#include <klocale.h> +#include <kiconloader.h> +#include <ktabwidget.h> + +#include <QVBoxLayout> + +GeneralSettingsPage::GeneralSettingsPage(const KUrl& url, QWidget* parent) : + SettingsPageBase(parent), + m_pages() +{ + QVBoxLayout* topLayout = new QVBoxLayout(this); + topLayout->setMargin(0); + topLayout->setSpacing(KDialog::spacingHint()); + + KTabWidget* tabWidget = new KTabWidget(this); + + // 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())); + + // initialize 'Previews' tab + PreviewsSettingsPage* previewsPage = new PreviewsSettingsPage(tabWidget); + tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews")); + connect(previewsPage, SIGNAL(changed()), this, SIGNAL(changed())); + + // 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())); + + // 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_pages.append(behaviorPage); + m_pages.append(previewsPage); + m_pages.append(contextMenuPage); + m_pages.append(statusBarPage); + + topLayout->addWidget(tabWidget, 0, 0); +} + +GeneralSettingsPage::~GeneralSettingsPage() +{ +} + +void GeneralSettingsPage::applySettings() +{ + foreach (SettingsPageBase* page, m_pages) { + page->applySettings(); + } +} + +void GeneralSettingsPage::restoreDefaults() +{ + foreach (SettingsPageBase* page, m_pages) { + page->restoreDefaults(); + } +} + +#include "generalsettingspage.moc" diff --git a/src/settings/general/generalsettingspage.h b/src/settings/general/generalsettingspage.h new file mode 100644 index 000000000..0d28664f5 --- /dev/null +++ b/src/settings/general/generalsettingspage.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz * + * [email protected] * + * * + * 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 GENERALSETTINGSPAGE_H +#define GENERALSETTINGSPAGE_H + +#include <QWidget> +#include <settings/settingspagebase.h> + +class KUrl; +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 KUrl& url, QWidget* parent); + virtual ~GeneralSettingsPage(); + + /** @see SettingsPageBase::applySettings() */ + virtual void applySettings(); + + /** @see SettingsPageBase::restoreDefaults() */ + virtual void restoreDefaults(); + +private: + QList<SettingsPageBase*> m_pages; +}; + +#endif diff --git a/src/settings/general/previewssettingspage.cpp b/src/settings/general/previewssettingspage.cpp new file mode 100644 index 000000000..1059e8547 --- /dev/null +++ b/src/settings/general/previewssettingspage.cpp @@ -0,0 +1,182 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz <[email protected]> * + * * + * 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 "dolphin_generalsettings.h" + +#include <kconfiggroup.h> +#include <kdialog.h> +#include <kglobal.h> +#include <klocale.h> +#include <KNumInput> +#include <kservicetypetrader.h> +#include <kservice.h> + +#include <settings/dolphinsettings.h> + +#include <QCheckBox> +#include <QGroupBox> +#include <QLabel> +#include <QListWidget> +#include <QRadioButton> +#include <QShowEvent> +#include <QSlider> +#include <QGridLayout> + +// default settings +namespace { + const bool UseThumbnails = true; + const int MaxLocalPreviewSize = 5; // 5 MB + const int MaxRemotePreviewSize = 0; // 0 MB +} + +PreviewsSettingsPage::PreviewsSettingsPage(QWidget* parent) : + SettingsPageBase(parent), + m_initialized(false), + m_previewPluginsList(0), + m_enabledPreviewPlugins(), + m_localFileSizeBox(0), + m_remoteFileSizeBox(0) +{ + QVBoxLayout* topLayout = new QVBoxLayout(this); + topLayout->setSpacing(KDialog::spacingHint()); + topLayout->setMargin(KDialog::marginHint()); + + // Create group box "Show previews for:" + QGroupBox* listBox = new QGroupBox(i18nc("@title:group", "Show previews for"), this); + + m_previewPluginsList = new QListWidget(this); + m_previewPluginsList->setSortingEnabled(true); + m_previewPluginsList->setSelectionMode(QAbstractItemView::NoSelection); + connect(m_previewPluginsList, SIGNAL(itemClicked(QListWidgetItem*)), + this, SIGNAL(changed())); + + QVBoxLayout* listBoxLayout = new QVBoxLayout(listBox); + listBoxLayout->addWidget(m_previewPluginsList); + + // Create group box "Don't create previews for" + QGroupBox* fileSizeBox = new QGroupBox(i18nc("@title:group", "Do not create previews for"), this); + + QLabel* localFileSizeLabel = new QLabel(i18nc("@label Don't create previews for: <Local files above:> XX MByte", + "Local files above:"), this); + + m_localFileSizeBox = new KIntSpinBox(this); + m_localFileSizeBox->setSingleStep(1); + m_localFileSizeBox->setSuffix(QLatin1String(" MB")); + m_localFileSizeBox->setRange(0, 9999); /* MB */ + connect(m_localFileSizeBox, SIGNAL(valueChanged(int)), + this, SIGNAL(changed())); + + QLabel* remoteFileSizeLabel = new QLabel(i18nc("@label Don't create previews for: <Remote files above:> XX MByte", + "Remote files above:"), this); + + m_remoteFileSizeBox = new KIntSpinBox(this); + m_remoteFileSizeBox->setSingleStep(1); + m_remoteFileSizeBox->setSuffix(QLatin1String(" MB")); + m_remoteFileSizeBox->setRange(0, 9999); /* MB */ + connect(m_remoteFileSizeBox, SIGNAL(valueChanged(int)), + this, SIGNAL(changed())); + + QGridLayout* fileSizeBoxLayout = new QGridLayout(fileSizeBox); + fileSizeBoxLayout->addWidget(localFileSizeLabel, 0, 0, Qt::AlignRight); + fileSizeBoxLayout->addWidget(m_localFileSizeBox, 0, 1); + fileSizeBoxLayout->addWidget(remoteFileSizeLabel, 1, 0, Qt::AlignRight); + fileSizeBoxLayout->addWidget(m_remoteFileSizeBox, 1, 1); + + topLayout->addWidget(listBox); + topLayout->addWidget(fileSizeBox); + + loadSettings(); +} + + +PreviewsSettingsPage::~PreviewsSettingsPage() +{ +} + +void PreviewsSettingsPage::applySettings() +{ + m_enabledPreviewPlugins.clear(); + const int count = m_previewPluginsList->count(); + for (int i = 0; i < count; ++i) { + const QListWidgetItem* item = m_previewPluginsList->item(i); + if (item->checkState() == Qt::Checked) { + const QString enabledPlugin = item->data(Qt::UserRole).toString(); + m_enabledPreviewPlugins.append(enabledPlugin); + } + } + + KConfigGroup globalConfig(KGlobal::config(), QLatin1String("PreviewSettings")); + globalConfig.writeEntry("Plugins", m_enabledPreviewPlugins); + + globalConfig.writeEntry("MaximumSize", + m_localFileSizeBox->value() * 1024 * 1024, + KConfigBase::Normal | KConfigBase::Global); + globalConfig.writeEntry("MaximumRemoteSize", + m_remoteFileSizeBox->value() * 1024 * 1024, + KConfigBase::Normal | KConfigBase::Global); + globalConfig.sync(); +} + +void PreviewsSettingsPage::restoreDefaults() +{ + m_localFileSizeBox->setValue(MaxLocalPreviewSize); + m_remoteFileSizeBox->setValue(MaxRemotePreviewSize); +} + +void PreviewsSettingsPage::showEvent(QShowEvent* event) +{ + if (!event->spontaneous() && !m_initialized) { + QMetaObject::invokeMethod(this, "loadPreviewPlugins", Qt::QueuedConnection); + m_initialized = true; + } + SettingsPageBase::showEvent(event); +} + +void PreviewsSettingsPage::loadPreviewPlugins() +{ + const KService::List plugins = KServiceTypeTrader::self()->query(QLatin1String("ThumbCreator")); + foreach (const KSharedPtr<KService>& service, plugins) { + QListWidgetItem* item = new QListWidgetItem(service->name(), + m_previewPluginsList); + item->setData(Qt::UserRole, service->desktopEntryName()); + const bool show = m_enabledPreviewPlugins.contains(service->desktopEntryName()); + item->setCheckState(show ? Qt::Checked : Qt::Unchecked); + } +} + +void PreviewsSettingsPage::loadSettings() +{ + KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings"); + m_enabledPreviewPlugins = globalConfig.readEntry("Plugins", QStringList() + << QLatin1String("directorythumbnail") + << QLatin1String("imagethumbnail") + << QLatin1String("jpegthumbnail")); + + const int maxLocalByteSize = globalConfig.readEntry("MaximumSize", MaxLocalPreviewSize * 1024 * 1024); + const int maxLocalMByteSize = maxLocalByteSize / (1024 * 1024); + m_localFileSizeBox->setValue(maxLocalMByteSize); + + const int maxRemoteByteSize = globalConfig.readEntry("MaximumRemoteSize", MaxRemotePreviewSize * 1024 * 1024); + const int maxRemoteMByteSize = maxRemoteByteSize / (1024 * 1024); + m_remoteFileSizeBox->setValue(maxRemoteMByteSize); +} + +#include "previewssettingspage.moc" diff --git a/src/settings/general/previewssettingspage.h b/src/settings/general/previewssettingspage.h new file mode 100644 index 000000000..4b59ec87b --- /dev/null +++ b/src/settings/general/previewssettingspage.h @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2006 by Peter Penz <[email protected]> * + * * + * 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 <settings/settingspagebase.h> + +class QListWidget; +class KIntSpinBox; + +/** + * @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(); + +protected: + virtual void showEvent(QShowEvent* event); + +private slots: + void loadPreviewPlugins(); + +private: + void loadSettings(); + +private: + bool m_initialized; + QListWidget* m_previewPluginsList; + QStringList m_enabledPreviewPlugins; + KIntSpinBox* m_localFileSizeBox; + KIntSpinBox* m_remoteFileSizeBox; +}; + +#endif diff --git a/src/settings/general/statusbarsettingspage.cpp b/src/settings/general/statusbarsettingspage.cpp new file mode 100644 index 000000000..5c2d34af8 --- /dev/null +++ b/src/settings/general/statusbarsettingspage.cpp @@ -0,0 +1,85 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz <[email protected]> * + * * + * 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 <dolphin_generalsettings.h> + +#include <kdialog.h> +#include <klocale.h> +#include <kvbox.h> + +#include <settings/dolphinsettings.h> + +#include <QCheckBox> +#include <QVBoxLayout> + +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()); + settings->writeConfig(); +} + +void StatusBarSettingsPage::restoreDefaults() +{ + GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + settings->useDefaults(true); + loadSettings(); + settings->useDefaults(false); +} + +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/general/statusbarsettingspage.h b/src/settings/general/statusbarsettingspage.h new file mode 100644 index 000000000..6e9667be4 --- /dev/null +++ b/src/settings/general/statusbarsettingspage.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz <[email protected]> * + * * + * 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 <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: + 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 |
