┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings')
-rw-r--r--src/settings/additionalinfodialog.cpp102
-rw-r--r--src/settings/additionalinfodialog.h53
-rw-r--r--src/settings/applyviewpropsjob.cpp81
-rw-r--r--src/settings/applyviewpropsjob.h83
-rw-r--r--src/settings/columnviewsettingspage.cpp155
-rw-r--r--src/settings/columnviewsettingspage.h61
-rw-r--r--src/settings/detailsviewsettingspage.cpp147
-rw-r--r--src/settings/detailsviewsettingspage.h60
-rw-r--r--src/settings/dolphin_columnmodesettings.kcfg41
-rw-r--r--src/settings/dolphin_columnmodesettings.kcfgc4
-rw-r--r--src/settings/dolphin_detailsmodesettings.kcfg41
-rw-r--r--src/settings/dolphin_detailsmodesettings.kcfgc4
-rw-r--r--src/settings/dolphin_directoryviewpropertysettings.kcfg65
-rw-r--r--src/settings/dolphin_directoryviewpropertysettings.kcfgc6
-rw-r--r--src/settings/dolphin_generalsettings.kcfg71
-rw-r--r--src/settings/dolphin_generalsettings.kcfgc4
-rw-r--r--src/settings/dolphin_iconsmodesettings.kcfg67
-rw-r--r--src/settings/dolphin_iconsmodesettings.kcfgc4
-rw-r--r--src/settings/dolphinfontrequester.cpp111
-rw-r--r--src/settings/dolphinfontrequester.h79
-rw-r--r--src/settings/dolphinsettings.cpp78
-rw-r--r--src/settings/dolphinsettings.h92
-rw-r--r--src/settings/dolphinsettingsdialog.cpp114
-rw-r--r--src/settings/dolphinsettingsdialog.h60
-rw-r--r--src/settings/generalsettingspage.cpp170
-rw-r--r--src/settings/generalsettingspage.h64
-rw-r--r--src/settings/generalviewsettingspage.cpp201
-rw-r--r--src/settings/generalviewsettingspage.h73
-rw-r--r--src/settings/iconsizegroupbox.cpp116
-rw-r--r--src/settings/iconsizegroupbox.h66
-rw-r--r--src/settings/iconsviewsettingspage.cpp243
-rw-r--r--src/settings/iconsviewsettingspage.h88
-rw-r--r--src/settings/settingspagebase.cpp31
-rw-r--r--src/settings/settingspagebase.h56
-rw-r--r--src/settings/startupsettingspage.cpp169
-rw-r--r--src/settings/startupsettingspage.h66
-rw-r--r--src/settings/viewpropertiesdialog.cpp405
-rw-r--r--src/settings/viewpropertiesdialog.h84
-rw-r--r--src/settings/viewpropsprogressinfo.cpp148
-rw-r--r--src/settings/viewpropsprogressinfo.h78
-rw-r--r--src/settings/viewsettingspage.cpp98
-rw-r--r--src/settings/viewsettingspage.h53
-rw-r--r--src/settings/viewsettingspagebase.cpp31
-rw-r--r--src/settings/viewsettingspagebase.h55
44 files changed, 3878 insertions, 0 deletions
diff --git a/src/settings/additionalinfodialog.cpp b/src/settings/additionalinfodialog.cpp
new file mode 100644
index 000000000..2f735fffe
--- /dev/null
+++ b/src/settings/additionalinfodialog.cpp
@@ -0,0 +1,102 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "additionalinfodialog.h"
+
+#include <klocale.h>
+#include <kvbox.h>
+
+#include <QCheckBox>
+
+AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
+ KFileItemDelegate::InformationList info) :
+ KDialog(parent),
+ m_info(info),
+ m_size(0),
+ m_date(0),
+ m_permissions(0),
+ m_owner(0),
+ m_group(0),
+ m_type(0)
+{
+ setCaption(i18nc("@title:window", "Additional Information"));
+ setButtons(Ok | Cancel);
+ setDefaultButton(Ok);
+
+ KVBox* box = new KVBox(this);
+
+ m_size = new QCheckBox(i18nc("@option:check Additional Information", "Size"), box);
+ m_date = new QCheckBox(i18nc("@option:check Additional Information", "Date"), box);
+ m_permissions = new QCheckBox(i18nc("@option:check Additional Information", "Permissions"), box);
+ m_owner = new QCheckBox(i18nc("@option:check Additional Information", "Owner"), box);
+ m_group = new QCheckBox(i18nc("@option:check Additional Information", "Group"), box);
+ m_type = new QCheckBox(i18nc("@option:check Additional Information", "Type"), box);
+ connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
+
+ m_size->setChecked(info.contains(KFileItemDelegate::Size));
+ m_date->setChecked(info.contains(KFileItemDelegate::ModificationTime));
+ m_permissions->setChecked(info.contains(KFileItemDelegate::Permissions));
+ m_owner->setChecked(info.contains(KFileItemDelegate::Owner));
+ m_group->setChecked(info.contains(KFileItemDelegate::OwnerAndGroup));
+ m_type->setChecked(info.contains(KFileItemDelegate::FriendlyMimeType));
+
+ setMainWidget(box);
+
+ const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
+ "AdditionalInfoDialog");
+ restoreDialogSize(dialogConfig);
+}
+
+AdditionalInfoDialog::~AdditionalInfoDialog()
+{
+ KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
+ "AdditionalInfoDialog");
+ saveDialogSize(dialogConfig, KConfigBase::Persistent);
+}
+
+KFileItemDelegate::InformationList AdditionalInfoDialog::additionalInfo() const
+{
+ return m_info;
+}
+
+void AdditionalInfoDialog::slotOk()
+{
+ m_info.clear();
+
+ if (m_size->isChecked()) {
+ m_info.append(KFileItemDelegate::Size);
+ }
+ if (m_date->isChecked()) {
+ m_info.append(KFileItemDelegate::ModificationTime);
+ }
+ if (m_permissions->isChecked()) {
+ m_info.append(KFileItemDelegate::Permissions);
+ }
+ if (m_owner->isChecked()) {
+ m_info.append(KFileItemDelegate::Owner);
+ }
+ if (m_group->isChecked()) {
+ m_info.append(KFileItemDelegate::OwnerAndGroup);
+ }
+ if (m_type->isChecked()) {
+ m_info.append(KFileItemDelegate::FriendlyMimeType);
+ }
+}
+
+#include "additionalinfodialog.moc"
diff --git a/src/settings/additionalinfodialog.h b/src/settings/additionalinfodialog.h
new file mode 100644
index 000000000..9771960f0
--- /dev/null
+++ b/src/settings/additionalinfodialog.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 ADDITIONALINFODIALOG_H
+#define ADDITIONALINFODIALOG_H
+
+#include <kdialog.h>
+#include <kfileitemdelegate.h>
+
+class QCheckBox;
+
+/**
+ * @brief Dialog for changing the additional information properties of a directory.
+ */
+class AdditionalInfoDialog : public KDialog
+{
+ Q_OBJECT
+
+public:
+ explicit AdditionalInfoDialog(QWidget* parent, KFileItemDelegate::InformationList info);
+ virtual ~AdditionalInfoDialog();
+ KFileItemDelegate::InformationList additionalInfo() const;
+
+private slots:
+ void slotOk();
+
+private:
+ KFileItemDelegate::InformationList m_info;
+ QCheckBox* m_size;
+ QCheckBox* m_date;
+ QCheckBox* m_permissions;
+ QCheckBox* m_owner;
+ QCheckBox* m_group;
+ QCheckBox* m_type;
+};
+
+#endif
diff --git a/src/settings/applyviewpropsjob.cpp b/src/settings/applyviewpropsjob.cpp
new file mode 100644
index 000000000..9250226e9
--- /dev/null
+++ b/src/settings/applyviewpropsjob.cpp
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz <[email protected]> *
+ * *
+ * The code is based on kdelibs/kio/directorysizejob.* *
+ * (C) 2006 by David Faure <[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 "applyviewpropsjob.h"
+#include "viewproperties.h"
+
+ApplyViewPropsJob::ApplyViewPropsJob(const KUrl& dir,
+ const ViewProperties& viewProps) :
+ KIO::Job(),
+ m_viewProps(0),
+ m_progress(0),
+ m_dir(dir)
+{
+ m_viewProps = new ViewProperties(dir);
+ m_viewProps->setViewMode(viewProps.viewMode());
+ m_viewProps->setShowPreview(viewProps.showPreview());
+ m_viewProps->setShowHiddenFiles(viewProps.showHiddenFiles());
+ m_viewProps->setSorting(viewProps.sorting());
+ m_viewProps->setSortOrder(viewProps.sortOrder());
+
+ KIO::ListJob* listJob = KIO::listRecursive(dir, KIO::HideProgressInfo);
+ connect(listJob, SIGNAL(entries(KIO::Job*, const KIO::UDSEntryList&)),
+ SLOT(slotEntries(KIO::Job*, const KIO::UDSEntryList&)));
+ addSubjob(listJob);
+}
+
+ApplyViewPropsJob::~ApplyViewPropsJob()
+{
+ delete m_viewProps; // the properties are written by the destructor
+ m_viewProps = 0;
+}
+
+void ApplyViewPropsJob::slotEntries(KIO::Job*, const KIO::UDSEntryList& list)
+{
+ KIO::UDSEntryList::ConstIterator it = list.begin();
+ const KIO::UDSEntryList::ConstIterator end = list.end();
+ foreach(const KIO::UDSEntry& entry, list) {
+ const QString name = entry.stringValue(KIO::UDSEntry::UDS_NAME);
+ if ((name != ".") && (name != "..") && entry.isDir()) {
+ ++m_progress;
+
+ KUrl url(m_dir);
+ url.addPath(name);
+
+ Q_ASSERT(m_viewProps != 0);
+
+ ViewProperties props(url);
+ props.setDirProperties(*m_viewProps);
+ }
+ }
+}
+
+void ApplyViewPropsJob::slotResult(KJob* job)
+{
+ if (job->error()) {
+ setError(job->error());
+ setErrorText(job->errorText());
+ }
+ emitResult();
+}
+
+#include "applyviewpropsjob.moc"
diff --git a/src/settings/applyviewpropsjob.h b/src/settings/applyviewpropsjob.h
new file mode 100644
index 000000000..da18af966
--- /dev/null
+++ b/src/settings/applyviewpropsjob.h
@@ -0,0 +1,83 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz <[email protected]> *
+ * *
+ * The code is based on kdelibs/kio/kio/directorysizejob.* *
+ * (C) 2006 by David Faure <[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 APPLYVIEWPROPSJOB_H
+#define APPLYVIEWPROPSJOB_H
+
+#include <kio/job.h>
+#include <kfileitem.h>
+#include <kurl.h>
+
+class ViewProperties;
+
+/**
+ * @brief Applies view properties recursively to directories.
+ *
+ * Usage:
+ * \code
+ * KJob* job = new ApplyViewPropsJob(dir, viewProps);
+ * connect(job, SIGNAL(result(KJob*)),
+ * this, SLOT(slotResult(KJob*)));
+ * \endcode
+ *
+ * To be able to show a progress of the operation, the following steps
+ * are recommended:
+ * - Use a DirectorySizeJob to count the number of directories.
+ * - Use a timer to show the current count of directories by invoking
+ * DirectorySizeJob::totalSubdirs() until the result signal is emitted.
+ * - Use the ApplyViewPropsJob.
+ * - Use a timer to show the progress by invoking ApplyViwePropsJob::progress().
+ * In combination with the total directory count it is possible to show a
+ * progress bar now.
+ */
+class ApplyViewPropsJob : public KIO::Job
+{
+ Q_OBJECT
+
+public:
+ /**
+ * @param dir Directory where the view properties should be applied to
+ * (including sub directories).
+ * @param viewProps View properties for the directory \a dir including its
+ * sub directories.
+ */
+ ApplyViewPropsJob(const KUrl& dir, const ViewProperties& viewProps);
+ virtual ~ApplyViewPropsJob();
+ int progress() const;
+
+private slots:
+ virtual void slotResult(KJob* job);
+ void slotEntries(KIO::Job*, const KIO::UDSEntryList&);
+
+private:
+ ViewProperties* m_viewProps;
+ int m_currentItem;
+ int m_progress;
+ KUrl m_dir;
+};
+
+inline int ApplyViewPropsJob::progress() const
+{
+ return m_progress;
+}
+
+#endif
diff --git a/src/settings/columnviewsettingspage.cpp b/src/settings/columnviewsettingspage.cpp
new file mode 100644
index 000000000..5918eaf92
--- /dev/null
+++ b/src/settings/columnviewsettingspage.cpp
@@ -0,0 +1,155 @@
+/***************************************************************************
+ * 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 "columnviewsettingspage.h"
+
+#include "dolphinfontrequester.h"
+#include "dolphinsettings.h"
+#include "dolphin_columnmodesettings.h"
+#include "iconsizegroupbox.h"
+#include "zoomlevelinfo.h"
+
+#include <kdialog.h>
+#include <klocale.h>
+#include <kcombobox.h>
+
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QSlider>
+#include <QRadioButton>
+
+ColumnViewSettingsPage::ColumnViewSettingsPage(QWidget* parent) :
+ ViewSettingsPageBase(parent),
+ m_iconSizeGroupBox(0),
+ m_fontRequester(0),
+ m_textWidthBox(0)
+{
+ const int spacing = KDialog::spacingHint();
+ const int margin = KDialog::marginHint();
+ const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+
+ setSpacing(spacing);
+ setMargin(margin);
+
+ // Create "Icon" properties
+ m_iconSizeGroupBox = new IconSizeGroupBox(this);
+ m_iconSizeGroupBox->setSizePolicy(sizePolicy);
+
+ const int min = ZoomLevelInfo::minimumLevel();
+ const int max = ZoomLevelInfo::maximumLevel();
+ m_iconSizeGroupBox->setDefaultSizeRange(min, max);
+ m_iconSizeGroupBox->setPreviewSizeRange(min, max);
+
+ connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)),
+ this, SIGNAL(changed()));
+ connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)),
+ this, SIGNAL(changed()));
+
+ // create "Text" properties
+ QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
+ textGroup->setSizePolicy(sizePolicy);
+
+ QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
+ m_fontRequester = new DolphinFontRequester(textGroup);
+ connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
+
+ QLabel* textWidthLabel = new QLabel(i18nc("@label:listbox", "Text width:"), textGroup);
+ m_textWidthBox = new KComboBox(textGroup);
+ m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Small"));
+ m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Medium"));
+ m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Large"));
+ connect(m_textWidthBox, SIGNAL(activated(int)), this, SIGNAL(changed()));
+
+ QGridLayout* textGroupLayout = new QGridLayout(textGroup);
+ textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight);
+ textGroupLayout->addWidget(m_fontRequester, 0, 1);
+ textGroupLayout->addWidget(textWidthLabel, 1, 0, Qt::AlignRight);
+ textGroupLayout->addWidget(m_textWidthBox, 1, 1);
+
+ // 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();
+}
+
+ColumnViewSettingsPage::~ColumnViewSettingsPage()
+{
+}
+
+void ColumnViewSettingsPage::applySettings()
+{
+ ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
+
+ const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue());
+ const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue());
+ settings->setIconSize(iconSize);
+ settings->setPreviewSize(previewSize);
+
+ const QFont font = m_fontRequester->font();
+ settings->setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
+ settings->setFontFamily(font.family());
+ settings->setFontSize(font.pointSize());
+ settings->setItalicFont(font.italic());
+ settings->setFontWeight(font.weight());
+
+ // TODO:
+ //const int columnWidth = 150 + (m_columnWidthSlider->value() * 50);
+ //settings->setColumnWidth(columnWidth);
+}
+
+void ColumnViewSettingsPage::restoreDefaults()
+{
+ ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
+ settings->setDefaults();
+ loadSettings();
+}
+
+void ColumnViewSettingsPage::loadSettings()
+{
+ ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
+
+ const QSize iconSize(settings->iconSize(), settings->iconSize());
+ const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
+ m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
+
+ const QSize previewSize(settings->previewSize(), settings->previewSize());
+ const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
+ m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
+
+ if (settings->useSystemFont()) {
+ m_fontRequester->setMode(DolphinFontRequester::SystemFont);
+ } else {
+ QFont font(settings->fontFamily(),
+ settings->fontSize());
+ font.setItalic(settings->italicFont());
+ font.setWeight(settings->fontWeight());
+ m_fontRequester->setMode(DolphinFontRequester::CustomFont);
+ m_fontRequester->setCustomFont(font);
+ }
+
+ // TODO:
+ //m_columnWidthSlider->setValue((settings->columnWidth() - 150) / 50);
+}
+
+#include "columnviewsettingspage.moc"
diff --git a/src/settings/columnviewsettingspage.h b/src/settings/columnviewsettingspage.h
new file mode 100644
index 000000000..c723ed635
--- /dev/null
+++ b/src/settings/columnviewsettingspage.h
@@ -0,0 +1,61 @@
+/***************************************************************************
+ * 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 COLUMNVIEWSETTINGSPAGE_H
+#define COLUMNVIEWSETTINGSPAGE_H
+
+#include <settings/viewsettingspagebase.h>
+
+class DolphinMainWindow;
+class DolphinFontRequester;
+class IconSizeGroupBox;
+class KComboBox;
+
+/**
+ * @brief Represents the page from the Dolphin Settings which allows
+ * to modify the settings for the details view.
+ */
+class ColumnViewSettingsPage : public ViewSettingsPageBase
+{
+ Q_OBJECT
+
+public:
+ ColumnViewSettingsPage(QWidget* parent);
+ virtual ~ColumnViewSettingsPage();
+
+ /**
+ * Applies the settings for the details view.
+ * The settings are persisted automatically when
+ * closing Dolphin.
+ */
+ virtual void applySettings();
+
+ /** Restores the settings to default values. */
+ virtual void restoreDefaults();
+
+private:
+ void loadSettings();
+
+private:
+ IconSizeGroupBox* m_iconSizeGroupBox;
+ DolphinFontRequester* m_fontRequester;
+ KComboBox* m_textWidthBox;
+};
+
+#endif
diff --git a/src/settings/detailsviewsettingspage.cpp b/src/settings/detailsviewsettingspage.cpp
new file mode 100644
index 000000000..0c47caf24
--- /dev/null
+++ b/src/settings/detailsviewsettingspage.cpp
@@ -0,0 +1,147 @@
+/***************************************************************************
+ * 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 "detailsviewsettingspage.h"
+
+#include "iconsizegroupbox.h"
+#include "dolphinfontrequester.h"
+#include "dolphinsettings.h"
+#include "dolphin_detailsmodesettings.h"
+#include "zoomlevelinfo.h"
+
+#include <kdialog.h>
+#include <klocale.h>
+
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QGridLayout>
+#include <QLabel>
+#include <QRadioButton>
+#include <QtGui/QSpinBox>
+
+DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget* parent) :
+ ViewSettingsPageBase(parent),
+ m_iconSizeGroupBox(0),
+ m_fontRequester(0),
+ m_expandableFolders(0)
+{
+ const int spacing = KDialog::spacingHint();
+ const int margin = KDialog::marginHint();
+ const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+
+ setSpacing(spacing);
+ setMargin(margin);
+
+ // Create "Icon" properties
+ m_iconSizeGroupBox = new IconSizeGroupBox(this);
+ m_iconSizeGroupBox->setSizePolicy(sizePolicy);
+
+ const int min = ZoomLevelInfo::minimumLevel();
+ const int max = ZoomLevelInfo::maximumLevel();
+ m_iconSizeGroupBox->setDefaultSizeRange(min, max);
+ m_iconSizeGroupBox->setPreviewSizeRange(min, max);
+
+ connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)),
+ this, SIGNAL(changed()));
+ connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)),
+ this, SIGNAL(changed()));
+
+ // create "Text" properties
+ QWidget* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
+ textGroup->setSizePolicy(sizePolicy);
+
+ QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
+ m_fontRequester = new DolphinFontRequester(textGroup);
+ connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
+
+ QHBoxLayout* textLayout = new QHBoxLayout(textGroup);
+ textLayout->addWidget(fontLabel, 0, Qt::AlignRight);
+ textLayout->addWidget(m_fontRequester);
+
+ // create "Expandable Folders" checkbox
+ m_expandableFolders = new QCheckBox(i18nc("@option:check", "Expandable folders"), this);
+ connect(m_expandableFolders, 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();
+}
+
+DetailsViewSettingsPage::~DetailsViewSettingsPage()
+{
+}
+
+void DetailsViewSettingsPage::applySettings()
+{
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+
+ const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue());
+ const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue());
+ settings->setIconSize(iconSize);
+ settings->setPreviewSize(previewSize);
+
+ const QFont font = m_fontRequester->font();
+ settings->setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
+ settings->setFontFamily(font.family());
+ settings->setFontSize(font.pointSize());
+ settings->setItalicFont(font.italic());
+ settings->setFontWeight(font.weight());
+
+ settings->setExpandableFolders(m_expandableFolders->isChecked());
+}
+
+void DetailsViewSettingsPage::restoreDefaults()
+{
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+ settings->setDefaults();
+ loadSettings();
+}
+
+void DetailsViewSettingsPage::loadSettings()
+{
+ DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+
+ const QSize iconSize(settings->iconSize(), settings->iconSize());
+ const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
+ m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
+
+ const QSize previewSize(settings->previewSize(), settings->previewSize());
+ const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
+ m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
+
+ if (settings->useSystemFont()) {
+ m_fontRequester->setMode(DolphinFontRequester::SystemFont);
+ } else {
+ QFont font(settings->fontFamily(),
+ settings->fontSize());
+ font.setItalic(settings->italicFont());
+ font.setWeight(settings->fontWeight());
+ m_fontRequester->setMode(DolphinFontRequester::CustomFont);
+ m_fontRequester->setCustomFont(font);
+ }
+
+ m_expandableFolders->setChecked(settings->expandableFolders());
+}
+
+#include "detailsviewsettingspage.moc"
diff --git a/src/settings/detailsviewsettingspage.h b/src/settings/detailsviewsettingspage.h
new file mode 100644
index 000000000..58e3fd905
--- /dev/null
+++ b/src/settings/detailsviewsettingspage.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * 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 DETAILSVIEWSETTINGSPAGE_H
+#define DETAILSVIEWSETTINGSPAGE_H
+
+#include <settings/viewsettingspagebase.h>
+
+class DolphinFontRequester;
+class IconSizeGroupBox;
+class QCheckBox;
+
+/**
+ * @brief Represents the page from the Dolphin Settings which allows
+ * to modify the settings for the details view.
+ */
+class DetailsViewSettingsPage : public ViewSettingsPageBase
+{
+ Q_OBJECT
+
+public:
+ DetailsViewSettingsPage(QWidget* parent);
+ virtual ~DetailsViewSettingsPage();
+
+ /**
+ * Applies the settings for the details view.
+ * The settings are persisted automatically when
+ * closing Dolphin.
+ */
+ virtual void applySettings();
+
+ /** Restores the settings to default values. */
+ virtual void restoreDefaults();
+
+private:
+ void loadSettings();
+
+private:
+ IconSizeGroupBox* m_iconSizeGroupBox;
+ DolphinFontRequester* m_fontRequester;
+ QCheckBox* m_expandableFolders;
+};
+
+#endif
diff --git a/src/settings/dolphin_columnmodesettings.kcfg b/src/settings/dolphin_columnmodesettings.kcfg
new file mode 100644
index 000000000..4fd5ecc6e
--- /dev/null
+++ b/src/settings/dolphin_columnmodesettings.kcfg
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
+<kcfg>
+ <kcfgfile name="dolphinrc"/>
+ <include>kiconloader.h</include>
+ <include>kglobalsettings.h</include>
+ <group name="ColumnMode">
+ <entry name="FontFamily" type="String">
+ <label context="@label">Font family</label>
+ <default code="true">KGlobalSettings::generalFont().family()</default>
+ </entry>
+ <entry name="UseSystemFont" type="Bool">
+ <label context="@label">Use system font</label>
+ <default>true</default>
+ </entry>
+ <entry name="FontSize" type="Int">
+ <label context="@label">Font size</label>
+ <default code="true">KGlobalSettings::generalFont().pointSize()</default>
+ </entry>
+ <entry name="ItalicFont" type="Bool">
+ <label context="@label Font style">Italic</label>
+ <default>false</default>
+ </entry>
+ <entry name="FontWeight" type="Int">
+ <label context="@label">Font weight</label>
+ <default>0</default>
+ </entry>
+ <entry name="IconSize" type="Int">
+ <label context="@label">Icon size</label>
+ <default code="true">KIconLoader::SizeSmall</default>
+ </entry>
+ <entry name="PreviewSize" type="Int">
+ <label context="@label">Preview size</label>
+ <default code="true">KIconLoader::SizeLarge</default>
+ </entry>
+ <entry name="ColumnWidth" type="Int">
+ <label context="@label">Column width</label>
+ <default>250</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/src/settings/dolphin_columnmodesettings.kcfgc b/src/settings/dolphin_columnmodesettings.kcfgc
new file mode 100644
index 000000000..55134335a
--- /dev/null
+++ b/src/settings/dolphin_columnmodesettings.kcfgc
@@ -0,0 +1,4 @@
+File=dolphin_columnmodesettings.kcfg
+ClassName=ColumnModeSettings
+Singleton=false
+Mutators=true
diff --git a/src/settings/dolphin_detailsmodesettings.kcfg b/src/settings/dolphin_detailsmodesettings.kcfg
new file mode 100644
index 000000000..780d70540
--- /dev/null
+++ b/src/settings/dolphin_detailsmodesettings.kcfg
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
+<kcfg>
+ <kcfgfile name="dolphinrc"/>
+ <include>kiconloader.h</include>
+ <include>kglobalsettings.h</include>
+ <group name="DetailsMode">
+ <entry name="FontFamily" type="String">
+ <label context="@label">Font family</label>
+ <default code="true">KGlobalSettings::generalFont().family()</default>
+ </entry>
+ <entry name="UseSystemFont" type="Bool">
+ <label context="@label">Use system font</label>
+ <default>true</default>
+ </entry>
+ <entry name="FontSize" type="Int">
+ <label context="@label">Font size</label>
+ <default code="true">KGlobalSettings::generalFont().pointSize()</default>
+ </entry>
+ <entry name="ItalicFont" type="Bool">
+ <label context="@label Font style">Italic</label>
+ <default>false</default>
+ </entry>
+ <entry name="FontWeight" type="Int">
+ <label context="@label">Font weight</label>
+ <default>0</default>
+ </entry>
+ <entry name="IconSize" type="Int">
+ <label context="@label">Icon size</label>
+ <default code="true">KIconLoader::SizeSmall</default>
+ </entry>
+ <entry name="PreviewSize" type="Int">
+ <label context="@label">Preview size</label>
+ <default code="true">KIconLoader::SizeLarge</default>
+ </entry>
+ <entry name="ExpandableFolders" type="Bool">
+ <label context="@label">Expandable folders</label>
+ <default>false</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/src/settings/dolphin_detailsmodesettings.kcfgc b/src/settings/dolphin_detailsmodesettings.kcfgc
new file mode 100644
index 000000000..06da2e9e0
--- /dev/null
+++ b/src/settings/dolphin_detailsmodesettings.kcfgc
@@ -0,0 +1,4 @@
+File=dolphin_detailsmodesettings.kcfg
+ClassName=DetailsModeSettings
+Singleton=false
+Mutators=true
diff --git a/src/settings/dolphin_directoryviewpropertysettings.kcfg b/src/settings/dolphin_directoryviewpropertysettings.kcfg
new file mode 100644
index 000000000..ead1325de
--- /dev/null
+++ b/src/settings/dolphin_directoryviewpropertysettings.kcfg
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <include>kfileitemdelegate.h</include>
+
+<kcfgfile arg="true" />
+ <group name="Settings">
+ <entry name="ShowHiddenFiles" key="ShowDotFiles" type="Bool" >
+ <label context="@label">Show hidden files</label>
+ <whatsthis context="@info:whatsthis">When this option is enabled hidden files, such as those starting with a '.', will be shown in the file view.</whatsthis>
+ <default>false</default>
+ </entry>
+ </group>
+
+ <group name="Dolphin">
+ <entry name="ViewMode" type="Int" >
+ <label context="@label">View Mode</label>
+ <whatsthis context="@info:whatsthis">This option controls the style of the view. Currently supported values include icons (0), details (1) and column (2) views.</whatsthis>
+ <default>DolphinView::IconsView</default>
+ <min>0</min>
+ <max code="true">DolphinView::MaxModeEnum</max>
+ </entry>
+
+ <entry name="ShowPreview" type="Bool" >
+ <label context="@label">Show preview</label>
+ <whatsthis context="@info:whatsthis">When this option is enabled, a preview of the file content is shown as an icon.</whatsthis>
+ <default>false</default>
+ </entry>
+
+ <entry name="CategorizedSorting" type="Bool" >
+ <label context="@label">Categorized Sorting</label>
+ <whatsthis context="@info:whatsthis">When this option is enabled, the sorted items are summarized by their category.</whatsthis>
+ <default>false</default>
+ </entry>
+
+ <entry name="Sorting" type="Int" >
+ <label context="@label">Sort files by</label>
+ <whatsthis context="@info:whatsthis">This option defines which attribute (name, size, date, etc.) sorting is performed on.</whatsthis>
+ <default code="true">DolphinView::SortByName</default>
+ <min>0</min>
+ <max code="true">DolphinView::MaxSortEnum</max>
+ </entry>
+
+ <entry name="SortOrder" type="Int" >
+ <label context="@label">Order in which to sort files</label>
+ <default code="true">Qt::AscendingOrder</default>
+ <min code="true">Qt::AscendingOrder</min>
+ <max code="true">Qt::DescendingOrder</max>
+ </entry>
+
+ <entry name="AdditionalInfo" type="Int">
+ <label context="@label">Additional information</label>
+ <default>0</default>
+ </entry>
+
+ <entry name="Timestamp" type="DateTime" >
+ <label context="@label">Properties last changed</label>
+ <whatsthis context="@info:whatsthis">The last time these properties were changed by the user.</whatsthis>
+ </entry>
+ </group>
+</kcfg>
+
+
diff --git a/src/settings/dolphin_directoryviewpropertysettings.kcfgc b/src/settings/dolphin_directoryviewpropertysettings.kcfgc
new file mode 100644
index 000000000..753642f8c
--- /dev/null
+++ b/src/settings/dolphin_directoryviewpropertysettings.kcfgc
@@ -0,0 +1,6 @@
+File=dolphin_directoryviewpropertysettings.kcfg
+Singleton=false
+ClassName=ViewPropertySettings
+Mutators=true
+GlobalEnums=true
+IncludeFiles=dolphinview.h,qnamespace.h
diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg
new file mode 100644
index 000000000..2f4defa92
--- /dev/null
+++ b/src/settings/dolphin_generalsettings.kcfg
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
+<kcfg>
+ <kcfgfile name="dolphinrc"/>
+ <include>QDir</include>
+ <group name="General">
+ <entry name="EditableUrl" type="Bool">
+ <label context="@label">Should the URL be editable for the user</label>
+ <default>false</default>
+ </entry>
+ <entry name="ShowFullPath" type="Bool">
+ <label context="@label">Should the full path be shown inside the location bar</label>
+ <default>false</default>
+ </entry>
+ <entry name="FirstRun" type="Bool">
+ <label context="@label">Is the application started the first time</label>
+ <default>true</default>
+ </entry>
+ <entry name="HomeUrl" type="String">
+ <label context="@label">Home URL</label>
+ <default code="true">QDir::homePath()</default>
+ </entry>
+ <entry name="SplitView" type="Bool">
+ <label context="@label">Split the view into two panes</label>
+ <default>false</default>
+ </entry>
+ <entry name="FilterBar" type="Bool">
+ <label context="@label">Should the filter bar be shown</label>
+ <default>false</default>
+ </entry>
+ <entry name="GlobalViewProps" type="Bool">
+ <label context="@label">Should the view properties be used for all directories</label>
+ <default>false</default>
+ </entry>
+ <entry name="BrowseThroughArchives" type="Bool">
+ <label context="@label">Browse through archives</label>
+ <default>false</default>
+ </entry>
+ <entry name="RenameInline" type="Bool">
+ <label context="@label">Rename inline</label>
+ <default>false</default>
+ </entry>
+ <entry name="ShowSelectionToggle" type="Bool">
+ <label context="@label">Show selection toggle</label>
+ <default>true</default>
+ </entry>
+ <entry name="ShowToolTips" type="Bool">
+ <label context="@label">Show tooltips</label>
+ <default>false</default>
+ </entry>
+ <entry name="ShowCopyMoveMenu" type="Bool">
+ <label context="@label">Show 'Copy To' and 'Move To' commands in context menu</label>
+ <default>false</default>
+ </entry>
+ <entry name="ViewPropsTimestamp" type="DateTime" >
+ <label context="@label">Timestamp since when the view properties are valid</label>
+ </entry>
+ <entry name="AutoExpandFolders" type="Bool">
+ <label context="@label">Use auto-expanding folders for all view types</label>
+ <default>false</default>
+ </entry>
+ <entry name="ShowZoomSlider" type="Bool">
+ <label context="@label">Show zoom slider in the statusbar</label>
+ <default>true</default>
+ </entry>
+ <entry name="ShowSpaceInfo" type="Bool">
+ <label context="@label">Show the space information in the statusbar</label>
+ <default>false</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/src/settings/dolphin_generalsettings.kcfgc b/src/settings/dolphin_generalsettings.kcfgc
new file mode 100644
index 000000000..91b1fee46
--- /dev/null
+++ b/src/settings/dolphin_generalsettings.kcfgc
@@ -0,0 +1,4 @@
+File=dolphin_generalsettings.kcfg
+ClassName=GeneralSettings
+Singleton=false
+Mutators=true
diff --git a/src/settings/dolphin_iconsmodesettings.kcfg b/src/settings/dolphin_iconsmodesettings.kcfg
new file mode 100644
index 000000000..1311f6d20
--- /dev/null
+++ b/src/settings/dolphin_iconsmodesettings.kcfg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
+<kcfg>
+ <kcfgfile name="dolphinrc"/>
+ <include>kglobalsettings.h</include>
+ <include>kiconloader.h</include>
+ <include>QListView</include>
+ <group name="IconsMode">
+ <entry name="Arrangement" type="Int">
+ <label context="@label">Arrangement</label>
+ <default code="true">QListView::TopToBottom</default>
+ </entry>
+ <entry name="UseSystemFont" type="Bool">
+ <label context="@label">Use system font</label>
+ <default>true</default>
+ </entry>
+ <entry name="FontFamily" type="String">
+ <label context="@label">Font family</label>
+ <default code="true">KGlobalSettings::generalFont().family()</default>
+ </entry>
+ <entry name="FontSize" type="Int">
+ <label context="@label">Font size</label>
+ <default code="true">KGlobalSettings::generalFont().pointSize()</default>
+ </entry>
+ <entry name="ItalicFont" type="Bool">
+ <label context="@label Font style">Italic</label>
+ <default>false</default>
+ </entry>
+ <entry name="FontWeight" type="Int">
+ <label context="@label">Font weight</label>
+ <default>0</default>
+ </entry>
+ <entry name="ItemHeight" type="Int">
+ <label context="@label">Item height</label>
+ <!--
+ check 'void IconsViewSettingsPage::applySettings()' as reference (iconsviewsettingspage.cpp):
+ itemHeight += fontHeight * numberOfTextlines + 10;
+ /-->
+ <default code="true">KIconLoader::SizeMedium + QFontMetrics(KGlobalSettings::generalFont()).height() * 2 + 10</default>
+ </entry>
+ <entry name="ItemWidth" type="Int">
+ <label context="@label">Item width</label>
+ <!--
+ check 'void IconsViewSettingsPage::applySettings()' as reference (iconsviewsettingspage.cpp):
+ itemWidth = TopToBottomBase + textSizeIndex * TopToBottomInc;
+ /-->
+ <default>96</default>
+ </entry>
+ <entry name="GridSpacing" type="Int">
+ <label context="@label">Grid spacing</label>
+ <default>8</default>
+ </entry>
+ <entry name="IconSize" type="Int">
+ <label context="@label">Icon size</label>
+ <default code="true">KIconLoader::SizeMedium</default>
+ </entry>
+ <entry name="NumberOfTextlines" type="Int">
+ <label context="@label">Number of textlines</label>
+ <!-- don't forget adjusting the "ItemHeight" too when changing this value /-->
+ <default>2</default>
+ </entry>
+ <entry name="PreviewSize" type="Int">
+ <label context="@label">Preview size</label>
+ <default code="true">KIconLoader::SizeHuge</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/src/settings/dolphin_iconsmodesettings.kcfgc b/src/settings/dolphin_iconsmodesettings.kcfgc
new file mode 100644
index 000000000..9987ce938
--- /dev/null
+++ b/src/settings/dolphin_iconsmodesettings.kcfgc
@@ -0,0 +1,4 @@
+File=dolphin_iconsmodesettings.kcfg
+ClassName=IconsModeSettings
+Singleton=false
+Mutators=true
diff --git a/src/settings/dolphinfontrequester.cpp b/src/settings/dolphinfontrequester.cpp
new file mode 100644
index 000000000..2fc444029
--- /dev/null
+++ b/src/settings/dolphinfontrequester.cpp
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 "dolphinfontrequester.h"
+
+#include <kfontdialog.h>
+#include <kglobalsettings.h>
+#include <klocale.h>
+#include <kcombobox.h>
+
+#include <QEvent>
+#include <QPushButton>
+
+DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
+ KHBox(parent),
+ m_modeCombo(0),
+ m_chooseFontButton(0),
+ m_mode(SystemFont),
+ m_customFont()
+{
+ setSpacing(KDialog::spacingHint());
+
+ m_modeCombo = new KComboBox(this);
+ m_modeCombo->addItem(i18nc("@item:inlistbox Font", "System Font"));
+ m_modeCombo->addItem(i18nc("@item:inlistbox Font", "Custom Font"));
+ connect(m_modeCombo, SIGNAL(activated(int)),
+ this, SLOT(changeMode(int)));
+
+ m_chooseFontButton = new QPushButton(i18nc("@action:button Choose font", "Choose..."), this);
+ connect(m_chooseFontButton, SIGNAL(clicked()),
+ this, SLOT(openFontDialog()));
+
+ changeMode(m_modeCombo->currentIndex());
+}
+
+DolphinFontRequester::~DolphinFontRequester()
+{
+}
+
+void DolphinFontRequester::setMode(Mode mode)
+{
+ m_mode = mode;
+ m_modeCombo->setCurrentIndex(m_mode);
+ m_modeCombo->setFont(font());
+ m_chooseFontButton->setEnabled(m_mode == CustomFont);
+}
+
+DolphinFontRequester::Mode DolphinFontRequester::mode() const
+{
+ return m_mode;
+}
+
+QFont DolphinFontRequester::font() const
+{
+ return (m_mode == CustomFont) ? m_customFont : KGlobalSettings::generalFont();
+}
+
+void DolphinFontRequester::setCustomFont(const QFont& font)
+{
+ m_customFont = font;
+}
+
+QFont DolphinFontRequester::customFont() const
+{
+ return m_customFont;
+}
+
+bool DolphinFontRequester::event(QEvent* event)
+{
+ if (event->type() == QEvent::Polish) {
+ m_modeCombo->setFont(font());
+ }
+ return KHBox::event(event);
+}
+
+void DolphinFontRequester::openFontDialog()
+{
+ QFont font;
+ const int result = KFontDialog::getFont(font,
+ KFontChooser::NoDisplayFlags,
+ this);
+ if (result == KFontDialog::Accepted) {
+ m_customFont = font;
+ m_modeCombo->setFont(m_customFont);
+ emit changed();
+ }
+}
+
+void DolphinFontRequester::changeMode(int index)
+{
+ setMode((index == CustomFont) ? CustomFont : SystemFont);
+ emit changed();
+}
+
+#include "dolphinfontrequester.moc"
diff --git a/src/settings/dolphinfontrequester.h b/src/settings/dolphinfontrequester.h
new file mode 100644
index 000000000..03a062b2e
--- /dev/null
+++ b/src/settings/dolphinfontrequester.h
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 DOLPHINFONTREQUESTER_H
+#define DOLPHINFONTREQUESTER_H
+
+#include <khbox.h>
+
+#include <QFont>
+
+class KComboBox;
+class QPushButton;
+
+/**
+ * @brief Allows to select between using the system font or a custom font.
+ */
+class DolphinFontRequester : public KHBox
+{
+ Q_OBJECT
+
+public:
+ enum Mode
+ {
+ SystemFont = 0,
+ CustomFont = 1
+ };
+
+ DolphinFontRequester(QWidget* parent);
+ virtual ~DolphinFontRequester();
+
+ void setMode(Mode mode);
+ Mode mode() const;
+
+ /**
+ * Returns the custom font (see DolphinFontRequester::customFont()),
+ * if the mode is \a CustomFont, otherwise the system font is
+ * returned.
+ */
+ QFont font() const;
+
+ void setCustomFont(const QFont& font);
+ QFont customFont() const;
+
+signals:
+ /** Is emitted, if the font has been changed. */
+ void changed();
+
+protected:
+ bool event(QEvent* event);
+
+private slots:
+ void openFontDialog();
+ void changeMode(int index);
+
+private:
+ KComboBox* m_modeCombo;
+ QPushButton* m_chooseFontButton;
+
+ Mode m_mode;
+ QFont m_customFont;
+};
+
+#endif
diff --git a/src/settings/dolphinsettings.cpp b/src/settings/dolphinsettings.cpp
new file mode 100644
index 000000000..5b91001ef
--- /dev/null
+++ b/src/settings/dolphinsettings.cpp
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz ([email protected]), *
+ * Cvetoslav Ludmiloff 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 "dolphinsettings.h"
+
+#include <kfileplacesmodel.h>
+#include <kcomponentdata.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+
+#include "dolphin_columnmodesettings.h"
+#include "dolphin_detailsmodesettings.h"
+#include "dolphin_generalsettings.h"
+#include "dolphin_iconsmodesettings.h"
+
+class DolphinSettingsSingleton
+{
+public:
+ DolphinSettings instance;
+};
+K_GLOBAL_STATIC(DolphinSettingsSingleton, s_settings)
+
+DolphinSettings& DolphinSettings::instance()
+{
+ return s_settings->instance;
+}
+
+void DolphinSettings::save()
+{
+ m_generalSettings->writeConfig();
+ m_iconsModeSettings->writeConfig();
+ m_detailsModeSettings->writeConfig();
+ m_columnModeSettings->writeConfig();
+}
+
+DolphinSettings::DolphinSettings()
+{
+ m_generalSettings = new GeneralSettings();
+ m_iconsModeSettings = new IconsModeSettings();
+ m_detailsModeSettings = new DetailsModeSettings();
+ m_columnModeSettings = new ColumnModeSettings();
+ m_placesModel = new KFilePlacesModel();
+}
+
+DolphinSettings::~DolphinSettings()
+{
+ delete m_generalSettings;
+ m_generalSettings = 0;
+
+ delete m_iconsModeSettings;
+ m_iconsModeSettings = 0;
+
+ delete m_detailsModeSettings;
+ m_detailsModeSettings = 0;
+
+ delete m_columnModeSettings;
+ m_columnModeSettings = 0;
+
+ delete m_placesModel;
+ m_placesModel = 0;
+}
diff --git a/src/settings/dolphinsettings.h b/src/settings/dolphinsettings.h
new file mode 100644
index 000000000..55fa327ef
--- /dev/null
+++ b/src/settings/dolphinsettings.h
@@ -0,0 +1,92 @@
+/***************************************************************************
+ * 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 DOLPHINSETTINGS_H
+#define DOLPHINSETTINGS_H
+
+#include <libdolphin_export.h>
+
+class ColumnModeSettings;
+class DetailsModeSettings;
+class GeneralSettings;
+class IconsModeSettings;
+class KFilePlacesModel;
+
+/**
+ * @brief Manages and stores all settings from Dolphin.
+ *
+ * The following properties are stored:
+ * - home URL
+ * - default view mode
+ * - URL navigator state (editable or not)
+ * - split view
+ * - properties for views
+ */
+class LIBDOLPHINPRIVATE_EXPORT DolphinSettings
+{
+public:
+ static DolphinSettings& instance();
+
+ GeneralSettings* generalSettings() const;
+ IconsModeSettings* iconsModeSettings() const;
+ DetailsModeSettings* detailsModeSettings() const;
+ ColumnModeSettings* columnModeSettings() const;
+ KFilePlacesModel* placesModel() const;
+ virtual void save();
+
+protected:
+ DolphinSettings();
+ virtual ~DolphinSettings();
+ friend class DolphinSettingsSingleton;
+
+private:
+ GeneralSettings* m_generalSettings;
+ IconsModeSettings* m_iconsModeSettings;
+ DetailsModeSettings* m_detailsModeSettings;
+ ColumnModeSettings* m_columnModeSettings;
+ KFilePlacesModel* m_placesModel;
+};
+
+inline GeneralSettings* DolphinSettings::generalSettings() const
+{
+ return m_generalSettings;
+}
+
+inline IconsModeSettings* DolphinSettings::iconsModeSettings() const
+{
+ return m_iconsModeSettings;
+}
+
+inline DetailsModeSettings* DolphinSettings::detailsModeSettings() const
+{
+ return m_detailsModeSettings;
+}
+
+inline ColumnModeSettings* DolphinSettings::columnModeSettings() const
+{
+ return m_columnModeSettings;
+}
+
+inline KFilePlacesModel* DolphinSettings::placesModel() const
+{
+ return m_placesModel;
+}
+
+#endif
diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp
new file mode 100644
index 000000000..54ac74bde
--- /dev/null
+++ b/src/settings/dolphinsettingsdialog.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ * 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 "dolphinsettingsdialog.h"
+
+#include <dolphinapplication.h>
+#include <dolphinmainwindow.h>
+#include "generalsettingspage.h"
+#include "startupsettingspage.h"
+#include "viewsettingspage.h"
+
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kicon.h>
+
+DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
+ KPageDialog(mainWindow),
+ m_pages()
+
+{
+ const QSize minSize = minimumSize();
+ setMinimumSize(QSize(512, minSize.height()));
+
+ setFaceType(List);
+ setCaption(i18nc("@title:window", "Dolphin Preferences"));
+ setButtons(Ok | Apply | Cancel | Default);
+ enableButtonApply(false);
+ setDefaultButton(Ok);
+
+ StartupSettingsPage* startupSettingsPage = new StartupSettingsPage(mainWindow, 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);
+ 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);
+ KPageWidgetItem* generalSettingsFrame = addPage(generalSettingsPage,
+ i18nc("@title:group General settings", "General"));
+ generalSettingsFrame->setIcon(KIcon("system-run"));
+ connect(generalSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
+
+ const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
+ restoreDialogSize(dialogConfig);
+
+ m_pages.append(startupSettingsPage);
+ m_pages.append(viewSettingsPage);
+ m_pages.append(generalSettingsPage);
+}
+
+DolphinSettingsDialog::~DolphinSettingsDialog()
+{
+ KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
+ saveDialogSize(dialogConfig);
+}
+
+void DolphinSettingsDialog::slotButtonClicked(int button)
+{
+ if ((button == Ok) || (button == Apply)) {
+ applySettings();
+ } else if (button == Default) {
+ const QString text(i18nc("@info", "All settings will be reset to default values. Do you want to continue?"));
+ if (KMessageBox::questionYesNo(this, text) == KMessageBox::Yes) {
+ restoreDefaults();
+ }
+ }
+
+ KPageDialog::slotButtonClicked(button);
+}
+
+void DolphinSettingsDialog::enableApply()
+{
+ enableButtonApply(true);
+}
+
+void DolphinSettingsDialog::applySettings()
+{
+ foreach (SettingsPageBase* page, m_pages) {
+ page->applySettings();
+ }
+ DolphinApplication::app()->refreshMainWindows();
+}
+
+void DolphinSettingsDialog::restoreDefaults()
+{
+ foreach (SettingsPageBase* page, m_pages) {
+ page->restoreDefaults();
+ }
+ DolphinApplication::app()->refreshMainWindows();
+}
+
+#include "dolphinsettingsdialog.moc"
diff --git a/src/settings/dolphinsettingsdialog.h b/src/settings/dolphinsettingsdialog.h
new file mode 100644
index 000000000..fc17b3774
--- /dev/null
+++ b/src/settings/dolphinsettingsdialog.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * 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 DOLPHINSETTINGSDIALOG_H
+#define DOLPHINSETTINGSDIALOG_H
+
+#include <kpagedialog.h>
+
+class DolphinMainWindow;
+class SettingsPageBase;
+
+/**
+ * @brief Settings dialog for Dolphin.
+ *
+ * Contains the pages for startup settings, general settings and view settings.
+ *
+ * @author Peter Penz <[email protected]>
+ */
+class DolphinSettingsDialog : public KPageDialog
+{
+ Q_OBJECT
+
+public:
+ explicit DolphinSettingsDialog(DolphinMainWindow* mainWindow);
+ virtual ~DolphinSettingsDialog();
+
+protected slots:
+ /** @see KDialog::slotButtonClicked() */
+ virtual void slotButtonClicked(int button);
+
+private slots:
+ /** Enables the Apply button. */
+ void enableApply();
+
+private:
+ void applySettings();
+ void restoreDefaults();
+
+private:
+ QList<SettingsPageBase*> m_pages;
+};
+
+#endif
diff --git a/src/settings/generalsettingspage.cpp b/src/settings/generalsettingspage.cpp
new file mode 100644
index 000000000..86b6f1939
--- /dev/null
+++ b/src/settings/generalsettingspage.cpp
@@ -0,0 +1,170 @@
+/***************************************************************************
+ * 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 "generalsettingspage.h"
+
+#include "settings/dolphinsettings.h"
+
+#include "dolphin_generalsettings.h"
+
+#include <kdialog.h>
+#include <klocale.h>
+#include <kvbox.h>
+
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QVBoxLayout>
+
+GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, 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)
+{
+ 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);
+
+ QGroupBox* statusBarBox = new QGroupBox(i18nc("@title:group", "Status Bar"), vBox);
+
+ m_showZoomSlider = new QCheckBox(i18nc("@option:check", "Show zoom slider"), statusBarBox);
+ connect(m_showZoomSlider, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+
+ m_showSpaceInfo = new QCheckBox(i18nc("@option:check", "Show space information"), statusBarBox);
+ connect(m_showSpaceInfo, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+
+ QVBoxLayout* statusBarBoxLayout = new QVBoxLayout(statusBarBox);
+ statusBarBoxLayout->addWidget(m_showZoomSlider);
+ statusBarBoxLayout->addWidget(m_showSpaceInfo);
+
+ m_browseThroughArchives = new QCheckBox(i18nc("@option:check", "Browse through archives"), vBox);
+ connect(m_browseThroughArchives, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+
+ m_renameInline = new QCheckBox(i18nc("@option:check", "Rename inline"), vBox);
+ connect(m_renameInline, 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();
+}
+
+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());
+}
+
+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());
+}
+
+#include "generalsettingspage.moc"
diff --git a/src/settings/generalsettingspage.h b/src/settings/generalsettingspage.h
new file mode 100644
index 000000000..4059dc3c6
--- /dev/null
+++ b/src/settings/generalsettingspage.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * 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 GENERALSETTINGSPAGE_H
+#define GENERALSETTINGSPAGE_H
+
+#include <settings/settingspagebase.h>
+
+class DolphinMainWindow;
+class QLineEdit;
+class QCheckBox;
+
+/**
+ * @brief Page for the 'General' settings of the Dolphin settings dialog.
+ */
+class GeneralSettingsPage : public SettingsPageBase
+{
+ Q_OBJECT
+
+public:
+ GeneralSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
+ virtual ~GeneralSettingsPage();
+
+ /** @see SettingsPageBase::applySettings() */
+ virtual void applySettings();
+
+ /** @see SettingsPageBase::restoreDefaults() */
+ 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;
+};
+
+#endif
diff --git a/src/settings/generalviewsettingspage.cpp b/src/settings/generalviewsettingspage.cpp
new file mode 100644
index 000000000..acea9649c
--- /dev/null
+++ b/src/settings/generalviewsettingspage.cpp
@@ -0,0 +1,201 @@
+/***************************************************************************
+ * 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 "generalviewsettingspage.h"
+#include "dolphinmainwindow.h"
+#include "settings/dolphinsettings.h"
+#include "dolphinviewcontainer.h"
+#include "viewproperties.h"
+
+#include "dolphin_generalsettings.h"
+
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QRadioButton>
+#include <QSlider>
+#include <QSpinBox>
+#include <QBoxLayout>
+
+#include <kconfiggroup.h>
+#include <kdialog.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <khbox.h>
+
+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
new file mode 100644
index 000000000..b0bd7e005
--- /dev/null
+++ b/src/settings/generalviewsettingspage.h
@@ -0,0 +1,73 @@
+/***************************************************************************
+ * 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 GENERALVIEWSETTINGSPAGE_H
+#define GENERALVIEWSETTINGSPAGE_H
+
+#include <kurl.h>
+#include <settings/viewsettingspagebase.h>
+
+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/iconsizegroupbox.cpp b/src/settings/iconsizegroupbox.cpp
new file mode 100644
index 000000000..82698e7b7
--- /dev/null
+++ b/src/settings/iconsizegroupbox.cpp
@@ -0,0 +1,116 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 "iconsizegroupbox.h"
+
+#include <klocale.h>
+
+#include <QApplication>
+#include <QGridLayout>
+#include <QHelpEvent>
+#include <QLabel>
+#include <QPoint>
+#include <QRect>
+#include <QSlider>
+
+#include "zoomlevelinfo.h"
+
+IconSizeGroupBox::IconSizeGroupBox(QWidget* parent) :
+ QGroupBox(i18nc("@title:group", "Icon Size"), parent),
+ m_defaultSizeSlider(0),
+ m_previewSizeSlider(0)
+{
+ QLabel* defaultLabel = new QLabel(i18nc("@label:listbox", "Default:"), this);
+ m_defaultSizeSlider = new QSlider(Qt::Horizontal, this);
+ m_defaultSizeSlider->setPageStep(1);
+ m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow);
+ connect(m_defaultSizeSlider, SIGNAL(sliderMoved(int)),
+ this, SLOT(slotDefaultSliderMoved(int)));
+
+ QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this);
+ m_previewSizeSlider = new QSlider(Qt::Horizontal, this);
+ m_previewSizeSlider->setPageStep(1);
+ m_previewSizeSlider->setTickPosition(QSlider::TicksBelow);
+ connect(m_previewSizeSlider, SIGNAL(sliderMoved(int)),
+ this, SLOT(slotPreviewSliderMoved(int)));
+
+ QGridLayout* layout = new QGridLayout(this);
+ layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight);
+ layout->addWidget(m_defaultSizeSlider, 0, 1);
+ layout->addWidget(previewLabel, 1, 0, Qt::AlignRight);
+ layout->addWidget(m_previewSizeSlider, 1, 1);
+}
+
+IconSizeGroupBox::~IconSizeGroupBox()
+{
+}
+
+void IconSizeGroupBox::setDefaultSizeRange(int min, int max)
+{
+ m_defaultSizeSlider->setRange(min, max);
+}
+
+void IconSizeGroupBox::setPreviewSizeRange(int min, int max)
+{
+ m_previewSizeSlider->setRange(min, max);
+}
+
+void IconSizeGroupBox::setDefaultSizeValue(int value)
+{
+ m_defaultSizeSlider->setValue(value);
+}
+
+int IconSizeGroupBox::defaultSizeValue() const
+{
+ return m_defaultSizeSlider->value();
+}
+
+void IconSizeGroupBox::setPreviewSizeValue(int value)
+{
+ m_previewSizeSlider->setValue(value);
+}
+
+int IconSizeGroupBox::previewSizeValue() const
+{
+ return m_previewSizeSlider->value();
+}
+
+void IconSizeGroupBox::slotDefaultSliderMoved(int value)
+{
+ showToolTip(m_defaultSizeSlider, value);
+ emit defaultSizeChanged(value);
+}
+
+void IconSizeGroupBox::slotPreviewSliderMoved(int value)
+{
+ showToolTip(m_previewSizeSlider, value);
+ emit previewSizeChanged(value);
+}
+
+void IconSizeGroupBox::showToolTip(QSlider* slider, int value)
+{
+ const int size = ZoomLevelInfo::iconSizeForZoomLevel(value);
+ slider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size));
+ QPoint global = slider->rect().topLeft();
+ global.ry() += slider->height() / 2;
+ QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), slider->mapToGlobal(global));
+ QApplication::sendEvent(slider, &toolTipEvent);
+}
+
+#include "iconsizegroupbox.moc"
diff --git a/src/settings/iconsizegroupbox.h b/src/settings/iconsizegroupbox.h
new file mode 100644
index 000000000..3ec51c3a5
--- /dev/null
+++ b/src/settings/iconsizegroupbox.h
@@ -0,0 +1,66 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 ICONSIZEGROUPBOX_H
+#define ICONSIZEGROUPBOX_H
+
+#include <QGroupBox>
+
+class QSlider;
+
+/**
+ * @short Provides a group box for adjusting the icon sizes.
+ *
+ * It is possible to adjust the default icon size and the icon
+ * size when previews are used.
+ */
+class IconSizeGroupBox : public QGroupBox
+{
+ Q_OBJECT
+
+public:
+ explicit IconSizeGroupBox(QWidget* parent);
+ virtual ~IconSizeGroupBox();
+
+ void setDefaultSizeRange(int min, int max);
+ void setPreviewSizeRange(int min, int max);
+
+ void setDefaultSizeValue(int value);
+ int defaultSizeValue() const;
+
+ void setPreviewSizeValue(int value);
+ int previewSizeValue() const;
+
+signals:
+ void defaultSizeChanged(int value);
+ void previewSizeChanged(int value);
+
+private slots:
+ void slotDefaultSliderMoved(int value);
+ void slotPreviewSliderMoved(int value);
+
+private:
+ void showToolTip(QSlider* slider, int value);
+
+private:
+ QSlider* m_defaultSizeSlider;
+ QSlider* m_previewSizeSlider;
+};
+
+#endif
diff --git a/src/settings/iconsviewsettingspage.cpp b/src/settings/iconsviewsettingspage.cpp
new file mode 100644
index 000000000..2acb4cd60
--- /dev/null
+++ b/src/settings/iconsviewsettingspage.cpp
@@ -0,0 +1,243 @@
+/***************************************************************************
+ * 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 "iconsviewsettingspage.h"
+
+#include "dolphinfontrequester.h"
+#include "settings/dolphinsettings.h"
+#include "iconsizegroupbox.h"
+#include "zoomlevelinfo.h"
+
+#include "dolphin_iconsmodesettings.h"
+
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <kglobalsettings.h>
+#include <klocale.h>
+#include <kcombobox.h>
+
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QListView>
+#include <QPushButton>
+#include <QSpinBox>
+#include <QGridLayout>
+#include <QVBoxLayout>
+
+IconsViewSettingsPage::IconsViewSettingsPage(QWidget* parent) :
+ ViewSettingsPageBase(parent),
+ m_iconSizeGroupBox(0),
+ m_textWidthBox(0),
+ m_fontRequester(0),
+ m_textlinesCountBox(0),
+ m_arrangementBox(0),
+ m_gridSpacingBox(0)
+{
+ const int spacing = KDialog::spacingHint();
+ const int margin = KDialog::marginHint();
+ const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+
+ setSpacing(spacing);
+ setMargin(margin);
+
+ // Create "Icon" properties
+ m_iconSizeGroupBox = new IconSizeGroupBox(this);
+ m_iconSizeGroupBox->setSizePolicy(sizePolicy);
+
+ const int min = ZoomLevelInfo::minimumLevel();
+ const int max = ZoomLevelInfo::maximumLevel();
+ m_iconSizeGroupBox->setDefaultSizeRange(min, max);
+ m_iconSizeGroupBox->setPreviewSizeRange(min, max);
+
+ connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)),
+ this, SIGNAL(changed()));
+ connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)),
+ this, SIGNAL(changed()));
+
+ // create 'Text' group for selecting the font, the number of lines
+ // and the text width
+ QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
+ textGroup->setSizePolicy(sizePolicy);
+
+ QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
+ m_fontRequester = new DolphinFontRequester(textGroup);
+ connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
+
+ QLabel* textlinesCountLabel = new QLabel(i18nc("@label:textbox", "Number of lines:"), textGroup);
+ m_textlinesCountBox = new QSpinBox(textGroup);
+ m_textlinesCountBox->setMinimum(1);
+ m_textlinesCountBox->setMaximum(5);
+ connect(m_textlinesCountBox, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
+
+ QLabel* textWidthLabel = new QLabel(i18nc("@label:listbox", "Text width:"), textGroup);
+ m_textWidthBox = new KComboBox(textGroup);
+ m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Small"));
+ m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Medium"));
+ m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Large"));
+ m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Huge"));
+ connect(m_textWidthBox, SIGNAL(activated(int)), this, SIGNAL(changed()));
+
+ QGridLayout* textGroupLayout = new QGridLayout(textGroup);
+ textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight);
+ textGroupLayout->addWidget(m_fontRequester, 0, 1);
+ textGroupLayout->addWidget(textlinesCountLabel, 1, 0, Qt::AlignRight);
+ textGroupLayout->addWidget(m_textlinesCountBox, 1, 1);
+ textGroupLayout->addWidget(textWidthLabel, 2, 0, Qt::AlignRight);
+ textGroupLayout->addWidget(m_textWidthBox, 2, 1);
+
+ // create the 'Grid' group for selecting the arrangement and the grid spacing
+ QGroupBox* gridGroup = new QGroupBox(i18nc("@title:group", "Grid"), this);
+ gridGroup->setSizePolicy(sizePolicy);
+
+ QLabel* arrangementLabel = new QLabel(i18nc("@label:listbox", "Arrangement:"), gridGroup);
+ m_arrangementBox = new KComboBox(gridGroup);
+ m_arrangementBox->addItem(i18nc("@item:inlistbox Arrangement", "Columns"));
+ m_arrangementBox->addItem(i18nc("@item:inlistbox Arrangement", "Rows"));
+ connect(m_arrangementBox, SIGNAL(activated(int)), this, SIGNAL(changed()));
+
+ QLabel* gridSpacingLabel = new QLabel(i18nc("@label:listbox", "Grid spacing:"), gridGroup);
+ m_gridSpacingBox = new KComboBox(gridGroup);
+ m_gridSpacingBox->addItem(i18nc("@item:inlistbox Grid spacing", "None"));
+ m_gridSpacingBox->addItem(i18nc("@item:inlistbox Grid spacing", "Small"));
+ m_gridSpacingBox->addItem(i18nc("@item:inlistbox Grid spacing", "Medium"));
+ m_gridSpacingBox->addItem(i18nc("@item:inlistbox Grid spacing", "Large"));
+ connect(m_gridSpacingBox, SIGNAL(activated(int)), this, SIGNAL(changed()));
+
+ QGridLayout* gridGroupLayout = new QGridLayout(gridGroup);
+ gridGroupLayout->addWidget(arrangementLabel, 0, 0, Qt::AlignRight);
+ gridGroupLayout->addWidget(m_arrangementBox, 0, 1);
+ gridGroupLayout->addWidget(gridSpacingLabel, 1, 0, Qt::AlignRight);
+ gridGroupLayout->addWidget(m_gridSpacingBox, 1, 1);
+
+ // 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();
+}
+
+IconsViewSettingsPage::~IconsViewSettingsPage()
+{
+}
+
+void IconsViewSettingsPage::applySettings()
+{
+ IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+
+ const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue());
+ const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue());
+ settings->setIconSize(iconSize);
+ settings->setPreviewSize(previewSize);
+
+ const QFont font = m_fontRequester->font();
+ const int fontHeight = QFontMetrics(font).height();
+
+ const int arrangement = (m_arrangementBox->currentIndex() == 0) ?
+ QListView::LeftToRight :
+ QListView::TopToBottom;
+ settings->setArrangement(arrangement);
+
+ const int numberOfTextlines = m_textlinesCountBox->value();
+
+ const int defaultSize = settings->iconSize();
+ int itemWidth = defaultSize;
+ int itemHeight = defaultSize;
+ const int textSizeIndex = m_textWidthBox->currentIndex();
+ if (arrangement == QListView::TopToBottom) {
+ itemWidth += TopToBottomBase + textSizeIndex * TopToBottomInc;
+ itemHeight += fontHeight * numberOfTextlines + 10;
+ } else {
+ itemWidth += LeftToRightBase + textSizeIndex * LeftToRightInc;
+ }
+
+ settings->setItemWidth(itemWidth);
+ settings->setItemHeight(itemHeight);
+
+ settings->setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
+ settings->setFontFamily(font.family());
+ settings->setFontSize(font.pointSize());
+ settings->setItalicFont(font.italic());
+ settings->setFontWeight(font.weight());
+
+ settings->setNumberOfTextlines(numberOfTextlines);
+
+ const int index = m_gridSpacingBox->currentIndex();
+ if (index == 0) {
+ // No grid spacing
+ settings->setGridSpacing(0);
+ } else {
+ settings->setGridSpacing(GridSpacingBase + (index - 1) * GridSpacingInc);
+ }
+}
+
+void IconsViewSettingsPage::restoreDefaults()
+{
+ IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+ settings->setDefaults();
+ loadSettings();
+}
+
+void IconsViewSettingsPage::loadSettings()
+{
+ IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+
+ const QSize iconSize(settings->iconSize(), settings->iconSize());
+ const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
+ m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
+
+ const QSize previewSize(settings->previewSize(), settings->previewSize());
+ const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
+ m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
+
+ if (settings->useSystemFont()) {
+ m_fontRequester->setMode(DolphinFontRequester::SystemFont);
+ } else {
+ QFont font(settings->fontFamily(),
+ settings->fontSize());
+ font.setItalic(settings->italicFont());
+ font.setWeight(settings->fontWeight());
+ m_fontRequester->setMode(DolphinFontRequester::CustomFont);
+ m_fontRequester->setCustomFont(font);
+ }
+
+ m_textlinesCountBox->setValue(settings->numberOfTextlines());
+
+ const bool leftToRightArrangement = (settings->arrangement() == QListView::LeftToRight);
+ int textWidthIndex = 0;
+ const int remainingWidth = settings->itemWidth() - settings->iconSize();
+ if (leftToRightArrangement) {
+ textWidthIndex = (remainingWidth - LeftToRightBase) / LeftToRightInc;
+ } else {
+ textWidthIndex = (remainingWidth - TopToBottomBase) / TopToBottomInc;
+ }
+ // ensure that chosen index is always valid
+ textWidthIndex = qMax(textWidthIndex, 0);
+ textWidthIndex = qMin(textWidthIndex, m_textWidthBox->count() - 1);
+
+ m_textWidthBox->setCurrentIndex(textWidthIndex);
+ m_arrangementBox->setCurrentIndex(leftToRightArrangement ? 0 : 1);
+
+ const int spacing = settings->gridSpacing();
+ const int index = (spacing <= 0) ? 0 : 1 + (spacing - GridSpacingBase) / GridSpacingInc;
+ m_gridSpacingBox->setCurrentIndex(index);
+}
+
+#include "iconsviewsettingspage.moc"
diff --git a/src/settings/iconsviewsettingspage.h b/src/settings/iconsviewsettingspage.h
new file mode 100644
index 000000000..c30ade673
--- /dev/null
+++ b/src/settings/iconsviewsettingspage.h
@@ -0,0 +1,88 @@
+/***************************************************************************
+ * 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 ICONSVIEWSETTINGSPAGE_H
+#define ICONSVIEWSETTINGSPAGE_H
+
+#include <dolphiniconsview.h>
+#include <settings/viewsettingspagebase.h>
+
+class DolphinFontRequester;
+class IconSizeGroupBox;
+class QCheckBox;
+class KComboBox;
+class QSpinBox;
+
+/**
+ * @brief Tab page for the 'Icons Mode' and 'Previews Mode' settings
+ * of the Dolphin settings dialog.
+ *
+ * Allows to set:
+ * - icon size
+ * - preview size
+ * - text width
+ * - grid spacing
+ * - font
+ * - number of text lines
+ * - arrangement
+ *
+ * @see DolphinIconsViewSettings
+ */
+class IconsViewSettingsPage : public ViewSettingsPageBase
+{
+ Q_OBJECT
+
+public:
+ IconsViewSettingsPage(QWidget* parent);
+ virtual ~IconsViewSettingsPage();
+
+ /**
+ * Applies the settings for the icons view.
+ * The settings are persisted automatically when
+ * closing Dolphin.
+ */
+ virtual void applySettings();
+
+ /** Restores the settings to default values. */
+ virtual void restoreDefaults();
+
+private:
+ void loadSettings();
+
+private:
+ enum
+ {
+ GridSpacingBase = 8,
+ GridSpacingInc = 12,
+ LeftToRightBase = 128,
+ LeftToRightInc = 64,
+ TopToBottomBase = 32,
+ TopToBottomInc = 32
+ };
+
+ IconSizeGroupBox* m_iconSizeGroupBox;
+ KComboBox* m_textWidthBox;
+ DolphinFontRequester* m_fontRequester;
+ QSpinBox* m_textlinesCountBox;
+
+ KComboBox* m_arrangementBox;
+ KComboBox* m_gridSpacingBox;
+};
+
+#endif
diff --git a/src/settings/settingspagebase.cpp b/src/settings/settingspagebase.cpp
new file mode 100644
index 000000000..6f8dcbfb6
--- /dev/null
+++ b/src/settings/settingspagebase.cpp
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * 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 "settingspagebase.h"
+
+SettingsPageBase::SettingsPageBase(QWidget* parent) :
+ QWidget(parent)
+{}
+
+SettingsPageBase::~SettingsPageBase()
+{}
+
+
+#include "settingspagebase.moc"
diff --git a/src/settings/settingspagebase.h b/src/settings/settingspagebase.h
new file mode 100644
index 000000000..19d4cf1f0
--- /dev/null
+++ b/src/settings/settingspagebase.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * 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 SETTINGSPAGEBASE_H
+#define SETTINGSPAGEBASE_H
+
+#include <QtGui/QWidget>
+
+/**
+ * @brief Base class for the settings pages of the Dolphin settings dialog.
+ *
+ * @author Peter Penz <[email protected]>
+ */
+class SettingsPageBase : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit SettingsPageBase(QWidget* parent);
+ virtual ~SettingsPageBase();
+
+ /**
+ * Must be implemented by a derived class to
+ * persistently store the settings.
+ */
+ virtual void applySettings() = 0;
+
+ /**
+ * Must be implemented by a derived class to
+ * restored the settings to default values.
+ */
+ virtual void restoreDefaults() = 0;
+
+signals:
+ /** Is emitted if a setting has been changed. */
+ void changed();
+};
+
+#endif
diff --git a/src/settings/startupsettingspage.cpp b/src/settings/startupsettingspage.cpp
new file mode 100644
index 000000000..767fcab66
--- /dev/null
+++ b/src/settings/startupsettingspage.cpp
@@ -0,0 +1,169 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 "startupsettingspage.h"
+
+#include "settings/dolphinsettings.h"
+#include "dolphinmainwindow.h"
+#include "dolphinview.h"
+#include "dolphinviewcontainer.h"
+
+#include "dolphin_generalsettings.h"
+
+#include <kdialog.h>
+#include <kfiledialog.h>
+#include <klocale.h>
+#include <klineedit.h>
+#include <kmessagebox.h>
+#include <kvbox.h>
+
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QPushButton>
+#include <QRadioButton>
+
+StartupSettingsPage::StartupSettingsPage(DolphinMainWindow* mainWin, QWidget* parent) :
+ SettingsPageBase(parent),
+ m_mainWindow(mainWin),
+ m_homeUrl(0),
+ m_splitView(0),
+ m_editableUrl(0),
+ m_showFullPath(0),
+ m_filterBar(0)
+{
+ const int spacing = KDialog::spacingHint();
+
+ QVBoxLayout* topLayout = new QVBoxLayout(this);
+ KVBox* vBox = new KVBox(this);
+ vBox->setSpacing(spacing);
+
+ // create 'Home URL' editor
+ QGroupBox* homeBox = new QGroupBox(i18nc("@title:group", "Home Folder"), vBox);
+
+ KHBox* homeUrlBox = new KHBox(homeBox);
+ homeUrlBox->setSpacing(spacing);
+
+ new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox);
+ m_homeUrl = new KLineEdit(homeUrlBox);
+ m_homeUrl->setClearButtonShown(true);
+
+ QPushButton* selectHomeUrlButton = new QPushButton(KIcon("folder-open"), QString(), homeUrlBox);
+ connect(selectHomeUrlButton, SIGNAL(clicked()),
+ this, SLOT(selectHomeUrl()));
+
+ KHBox* buttonBox = new KHBox(homeBox);
+ buttonBox->setSpacing(spacing);
+
+ QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"), buttonBox);
+ connect(useCurrentButton, SIGNAL(clicked()),
+ this, SLOT(useCurrentLocation()));
+ QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location"), buttonBox);
+ connect(useDefaultButton, SIGNAL(clicked()),
+ this, SLOT(useDefaultLocation()));
+
+ QVBoxLayout* homeBoxLayout = new QVBoxLayout(homeBox);
+ homeBoxLayout->addWidget(homeUrlBox);
+ homeBoxLayout->addWidget(buttonBox);
+
+ // create 'Split view', 'Editable location' and 'Filter bar' checkboxes
+ m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode"), vBox);
+ m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar"), vBox);
+ m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar"), vBox);
+ m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar"), vBox);
+ connect(m_splitView, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ connect(m_editableUrl, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ connect(m_showFullPath, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ connect(m_filterBar, 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();
+
+ // it's important connecting 'textChanged' after loadSettings(), as loadSettings()
+ // invokes m_homeUrl->setText()
+ connect(m_homeUrl, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed()));
+}
+
+StartupSettingsPage::~StartupSettingsPage()
+{
+}
+
+void StartupSettingsPage::applySettings()
+{
+ GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+
+ const KUrl url(m_homeUrl->text());
+ KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, url);
+ if (url.isValid() && fileItem.isDir()) {
+ settings->setHomeUrl(url.prettyUrl());
+ } else {
+ KMessageBox::error(this, i18nc("@info", "The location for the home folder is invalid and will not be applied."));
+ }
+
+ settings->setSplitView(m_splitView->isChecked());
+ settings->setEditableUrl(m_editableUrl->isChecked());
+ settings->setShowFullPath(m_showFullPath->isChecked());
+ settings->setFilterBar(m_filterBar->isChecked());
+}
+
+void StartupSettingsPage::restoreDefaults()
+{
+ GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+ settings->setDefaults();
+ loadSettings();
+}
+
+void StartupSettingsPage::selectHomeUrl()
+{
+ const QString homeUrl = m_homeUrl->text();
+ KUrl url = KFileDialog::getExistingDirectoryUrl(homeUrl, this);
+ if (!url.isEmpty()) {
+ m_homeUrl->setText(url.prettyUrl());
+ emit changed();
+ }
+}
+
+void StartupSettingsPage::useCurrentLocation()
+{
+ const DolphinView* view = m_mainWindow->activeViewContainer()->view();
+ m_homeUrl->setText(view->url().prettyUrl());
+}
+
+void StartupSettingsPage::useDefaultLocation()
+{
+ m_homeUrl->setText(QDir::homePath());
+}
+
+void StartupSettingsPage::loadSettings()
+{
+ GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+ m_homeUrl->setText(settings->homeUrl());
+ m_splitView->setChecked(settings->splitView());
+ m_editableUrl->setChecked(settings->editableUrl());
+ m_showFullPath->setChecked(settings->showFullPath());
+ m_filterBar->setChecked(settings->filterBar());
+}
+
+#include "startupsettingspage.moc"
diff --git a/src/settings/startupsettingspage.h b/src/settings/startupsettingspage.h
new file mode 100644
index 000000000..04844f00c
--- /dev/null
+++ b/src/settings/startupsettingspage.h
@@ -0,0 +1,66 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 STARTUPSETTINGSPAGE_H
+#define STARTUPSETTINGSPAGE_H
+
+#include <settings/settingspagebase.h>
+
+class DolphinMainWindow;
+class KLineEdit;
+class QCheckBox;
+
+/**
+ * @brief Page for the 'Startup' settings of the Dolphin settings dialog.
+ *
+ * The startup settings allow to set the home URL and to configure the
+ * state of the view mode, split mode and the filter bar when starting Dolphin.
+ */
+class StartupSettingsPage : public SettingsPageBase
+{
+ Q_OBJECT
+
+public:
+ StartupSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
+ virtual ~StartupSettingsPage();
+
+ /** @see SettingsPageBase::applySettings() */
+ virtual void applySettings();
+
+ /** @see SettingsPageBase::restoreDefaults() */
+ virtual void restoreDefaults();
+
+private slots:
+ void selectHomeUrl();
+ void useCurrentLocation();
+ void useDefaultLocation();
+
+private:
+ void loadSettings();
+
+private:
+ DolphinMainWindow* m_mainWindow;
+ KLineEdit* m_homeUrl;
+
+ QCheckBox* m_splitView;
+ QCheckBox* m_editableUrl;
+ QCheckBox* m_showFullPath;
+ QCheckBox* m_filterBar;
+};
+
+#endif
diff --git a/src/settings/viewpropertiesdialog.cpp b/src/settings/viewpropertiesdialog.cpp
new file mode 100644
index 000000000..700bdb90b
--- /dev/null
+++ b/src/settings/viewpropertiesdialog.cpp
@@ -0,0 +1,405 @@
+/***************************************************************************
+ * 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 "viewpropertiesdialog.h"
+
+#include "additionalinfodialog.h"
+#include "dolphinview.h"
+#include "settings/dolphinsettings.h"
+#include "dolphinsortfilterproxymodel.h"
+#include "dolphin_generalsettings.h"
+#include "dolphin_iconsmodesettings.h"
+#include "viewproperties.h"
+#include "viewpropsprogressinfo.h"
+
+#include <config-nepomuk.h>
+#ifdef HAVE_NEPOMUK
+#include <nepomuk/resourcemanager.h>
+#endif
+
+#include <kcomponentdata.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kio/netaccess.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+#include <kurl.h>
+#include <kcombobox.h>
+
+#include <QAction>
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QLabel>
+#include <QMenu>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QBoxLayout>
+
+ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
+ KDialog(dolphinView),
+ m_isDirty(false),
+ m_dolphinView(dolphinView),
+ m_viewProps(0),
+ m_viewMode(0),
+ m_sortOrder(0),
+ m_sorting(0),
+ m_showPreview(0),
+ m_showInGroups(0),
+ m_showHiddenFiles(0),
+ m_additionalInfo(0),
+ m_applyToCurrentFolder(0),
+ m_applyToSubFolders(0),
+ m_applyToAllFolders(0),
+ m_useAsDefault(0)
+{
+ Q_ASSERT(dolphinView != 0);
+ const bool useGlobalViewProps = DolphinSettings::instance().generalSettings()->globalViewProps();
+
+ setCaption(i18nc("@title:window", "View Properties"));
+ setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
+
+ const KUrl& url = dolphinView->url();
+ m_viewProps = new ViewProperties(url);
+ m_viewProps->setAutoSaveEnabled(false);
+
+ QWidget* main = new QWidget();
+ QVBoxLayout* topLayout = new QVBoxLayout();
+
+ // create 'Properties' group containing view mode, sorting, sort order and show hidden files
+ QWidget* propsBox = main;
+ if (!useGlobalViewProps) {
+ propsBox = new QGroupBox(i18nc("@title:group", "Properties"), main);
+ }
+
+ QWidget* propsGrid = new QWidget();
+
+ QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid);
+ m_viewMode = new KComboBox(propsGrid);
+ m_viewMode->addItem(KIcon("view-list-icons"), i18nc("@item:inlistbox", "Icons"));
+ m_viewMode->addItem(KIcon("view-list-details"), i18nc("@item:inlistbox", "Details"));
+ m_viewMode->addItem(KIcon("view-file-columns"), i18nc("@item:inlistbox", "Column"));
+
+ QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsGrid);
+ QWidget* sortingBox = new QWidget(propsGrid);
+
+ m_sortOrder = new KComboBox(sortingBox);
+ m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Ascending"));
+ m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Descending"));
+
+ m_sorting = new KComboBox(sortingBox);
+ m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Name"));
+ m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Size"));
+ m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Date"));
+ m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Permissions"));
+ m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Owner"));
+ m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Group"));
+ m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Type"));
+#ifdef HAVE_NEPOMUK
+ // TODO: Hided "sort by rating" and "sort by tags" as without caching the performance
+ // is too slow currently (Nepomuk will support caching in future releases).
+ //
+ // if (!Nepomuk::ResourceManager::instance()->init()) {
+ // m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Rating"));
+ // m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Tags"));
+ // }
+#endif
+ m_showPreview = new QCheckBox(i18nc("@option:check", "Show preview"), propsBox);
+ m_showInGroups = new QCheckBox(i18nc("@option:check", "Show in groups"), propsBox);
+ m_showHiddenFiles = new QCheckBox(i18nc("@option:check", "Show hidden files"), propsBox);
+
+ m_additionalInfo = new QPushButton(i18nc("@action:button", "Additional Information"), propsBox);
+
+ QHBoxLayout* sortingLayout = new QHBoxLayout();
+ sortingLayout->setMargin(0);
+ sortingLayout->addWidget(m_sortOrder);
+ sortingLayout->addWidget(m_sorting);
+ sortingBox->setLayout(sortingLayout);
+
+ QGridLayout* propsGridLayout = new QGridLayout(propsGrid);
+ propsGridLayout->addWidget(viewModeLabel, 0, 0, Qt::AlignRight);
+ propsGridLayout->addWidget(m_viewMode, 0, 1);
+ propsGridLayout->addWidget(sortingLabel, 1, 0, Qt::AlignRight);
+ propsGridLayout->addWidget(sortingBox, 1, 1);
+
+ QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox);
+ propsBoxLayout->addWidget(propsGrid);
+ propsBoxLayout->addWidget(m_showPreview);
+ propsBoxLayout->addWidget(m_showInGroups);
+ propsBoxLayout->addWidget(m_showHiddenFiles);
+ propsBoxLayout->addWidget(m_additionalInfo);
+
+ topLayout->addWidget(propsBox);
+
+ connect(m_viewMode, SIGNAL(activated(int)),
+ this, SLOT(slotViewModeChanged(int)));
+ connect(m_sorting, SIGNAL(activated(int)),
+ this, SLOT(slotSortingChanged(int)));
+ connect(m_sortOrder, SIGNAL(activated(int)),
+ this, SLOT(slotSortOrderChanged(int)));
+ connect(m_additionalInfo, SIGNAL(clicked()),
+ this, SLOT(configureAdditionalInfo()));
+ connect(m_showPreview, SIGNAL(clicked()),
+ this, SLOT(slotShowPreviewChanged()));
+ connect(m_showInGroups, SIGNAL(clicked()),
+ this, SLOT(slotCategorizedSortingChanged()));
+ connect(m_showHiddenFiles, SIGNAL(clicked()),
+ this, SLOT(slotShowHiddenFilesChanged()));
+
+ connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
+ connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
+
+ // Only show the following settings if the view properties are remembered
+ // for each directory:
+ if (!useGlobalViewProps) {
+ // create 'Apply View Properties To' group
+ QGroupBox* applyBox = new QGroupBox(i18nc("@title:group", "Apply View Properties To"), main);
+
+ m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To",
+ "Current folder"), applyBox);
+ m_applyToCurrentFolder->setChecked(true);
+ m_applyToSubFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To",
+ "Current folder including all sub folders"), applyBox);
+ m_applyToAllFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To",
+ "All folders"), applyBox);
+
+ QButtonGroup* applyGroup = new QButtonGroup(this);
+ applyGroup->addButton(m_applyToCurrentFolder);
+ applyGroup->addButton(m_applyToSubFolders);
+ applyGroup->addButton(m_applyToAllFolders);
+
+ QVBoxLayout* applyBoxLayout = new QVBoxLayout(applyBox);
+ applyBoxLayout->addWidget(m_applyToCurrentFolder);
+ applyBoxLayout->addWidget(m_applyToSubFolders);
+ applyBoxLayout->addWidget(m_applyToAllFolders);
+
+ m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use as default for new folders"), main);
+
+ topLayout->addWidget(applyBox);
+ topLayout->addWidget(m_useAsDefault);
+
+ connect(m_applyToCurrentFolder, SIGNAL(clicked()),
+ this, SLOT(markAsDirty()));
+ connect(m_applyToSubFolders, SIGNAL(clicked()),
+ this, SLOT(markAsDirty()));
+ connect(m_applyToAllFolders, SIGNAL(clicked()),
+ this, SLOT(markAsDirty()));
+ connect(m_useAsDefault, SIGNAL(clicked()),
+ this, SLOT(markAsDirty()));
+ }
+
+ main->setLayout(topLayout);
+ setMainWidget(main);
+
+ const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
+ "ViewPropertiesDialog");
+ restoreDialogSize(dialogConfig);
+
+ loadSettings();
+}
+
+ViewPropertiesDialog::~ViewPropertiesDialog()
+{
+ m_isDirty = false;
+ delete m_viewProps;
+ m_viewProps = 0;
+
+ KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
+ "ViewPropertiesDialog");
+ saveDialogSize(dialogConfig, KConfigBase::Persistent);
+}
+
+void ViewPropertiesDialog::slotOk()
+{
+ applyViewProperties();
+ accept();
+}
+
+void ViewPropertiesDialog::slotApply()
+{
+ applyViewProperties();
+}
+
+void ViewPropertiesDialog::slotViewModeChanged(int index)
+{
+ m_viewProps->setViewMode(static_cast<DolphinView::Mode>(index));
+ m_isDirty = true;
+
+ const DolphinView::Mode mode = m_viewProps->viewMode();
+ m_showInGroups->setEnabled(mode == DolphinView::IconsView);
+ m_additionalInfo->setEnabled(mode != DolphinView::ColumnView);
+}
+
+void ViewPropertiesDialog::slotSortingChanged(int index)
+{
+ const DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(index);
+ m_viewProps->setSorting(sorting);
+ m_isDirty = true;
+}
+
+void ViewPropertiesDialog::slotSortOrderChanged(int index)
+{
+ const Qt::SortOrder sortOrder = (index == 0) ? Qt::AscendingOrder : Qt::DescendingOrder;
+ m_viewProps->setSortOrder(sortOrder);
+ m_isDirty = true;
+}
+
+void ViewPropertiesDialog::slotCategorizedSortingChanged()
+{
+ m_viewProps->setCategorizedSorting(m_showInGroups->isChecked());
+ m_isDirty = true;
+}
+
+void ViewPropertiesDialog::slotShowPreviewChanged()
+{
+ const bool show = m_showPreview->isChecked();
+ m_viewProps->setShowPreview(show);
+ m_isDirty = true;
+}
+
+void ViewPropertiesDialog::slotShowHiddenFilesChanged()
+{
+ const bool show = m_showHiddenFiles->isChecked();
+ m_viewProps->setShowHiddenFiles(show);
+ m_isDirty = true;
+}
+
+void ViewPropertiesDialog::markAsDirty()
+{
+ m_isDirty = true;
+}
+
+void ViewPropertiesDialog::configureAdditionalInfo()
+{
+ KFileItemDelegate::InformationList info = m_viewProps->additionalInfo();
+ const bool useDefaultInfo = (m_viewProps->viewMode() == DolphinView::DetailsView) &&
+ (info.isEmpty() || info.contains(KFileItemDelegate::NoInformation));
+ if (useDefaultInfo) {
+ // Using the details view without any additional information (-> additional column)
+ // makes no sense and leads to a usability problem as no viewport area is available
+ // anymore. Hence as fallback provide at least a size and date column.
+ info.clear();
+ info.append(KFileItemDelegate::Size);
+ info.append(KFileItemDelegate::ModificationTime);
+ m_viewProps->setAdditionalInfo(info);
+ }
+
+ AdditionalInfoDialog dialog(this, info);
+ if (dialog.exec() == QDialog::Accepted) {
+ m_viewProps->setAdditionalInfo(dialog.additionalInfo());
+ m_isDirty = true;
+ }
+}
+
+void ViewPropertiesDialog::applyViewProperties()
+{
+ // if nothing changed in the dialog, we have nothing to apply
+ if (!m_isDirty) {
+ return;
+ }
+
+ const bool applyToSubFolders = (m_applyToSubFolders != 0) &&
+ m_applyToSubFolders->isChecked();
+ if (applyToSubFolders) {
+ const QString text(i18nc("@info", "The view properties of all sub folders will be changed. Do you want to continue?"));
+ if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) {
+ return;
+ }
+
+ ViewPropsProgressInfo* info = new ViewPropsProgressInfo(m_dolphinView,
+ m_dolphinView->url(),
+ *m_viewProps);
+ info->setAttribute(Qt::WA_DeleteOnClose);
+ info->setWindowModality(Qt::NonModal);
+ info->show();
+ }
+
+ const bool applyToAllFolders = (m_applyToAllFolders != 0) &&
+ m_applyToAllFolders->isChecked();
+
+ // If the user selected 'Apply To All Folders' the view properties implicitely
+ // are also used as default for new folders.
+ const bool useAsDefault = applyToAllFolders ||
+ ((m_useAsDefault != 0) && m_useAsDefault->isChecked());
+ if (useAsDefault) {
+ // For directories where no .directory file is available, the .directory
+ // file stored for the global view properties is used as fallback. To update
+ // this file we temporary turn on the global view properties mode.
+ GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+ Q_ASSERT(!settings->globalViewProps());
+
+ settings->setGlobalViewProps(true);
+ ViewProperties defaultProps(m_dolphinView->url());
+ defaultProps.setDirProperties(*m_viewProps);
+ defaultProps.save();
+ settings->setGlobalViewProps(false);
+ }
+
+ if (applyToAllFolders) {
+ const QString text(i18nc("@info", "The view properties of all folders will be changed. Do you want to continue?"));
+ if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) {
+ return;
+ }
+
+ // Updating the global view properties time stamp in the general settings makes
+ // all existing viewproperties invalid, as they have a smaller time stamp.
+ GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+ settings->setViewPropsTimestamp(QDateTime::currentDateTime());
+ }
+
+ m_dolphinView->setMode(m_viewProps->viewMode());
+ m_dolphinView->setSorting(m_viewProps->sorting());
+ m_dolphinView->setSortOrder(m_viewProps->sortOrder());
+ m_dolphinView->setCategorizedSorting(m_viewProps->categorizedSorting());
+ m_dolphinView->setAdditionalInfo(m_viewProps->additionalInfo());
+ m_dolphinView->setShowPreview(m_viewProps->showPreview());
+ m_dolphinView->setShowHiddenFiles(m_viewProps->showHiddenFiles());
+
+ m_viewProps->save();
+
+ m_isDirty = false;
+}
+
+void ViewPropertiesDialog::loadSettings()
+{
+ // load view mode
+ const int index = static_cast<int>(m_viewProps->viewMode());
+ m_viewMode->setCurrentIndex(index);
+
+ // load sort order and sorting
+ const int sortOrderIndex = (m_viewProps->sortOrder() == Qt::AscendingOrder) ? 0 : 1;
+ m_sortOrder->setCurrentIndex(sortOrderIndex);
+ m_sorting->setCurrentIndex(m_viewProps->sorting());
+
+ const bool enabled = (index == DolphinView::DetailsView) ||
+ (index == DolphinView::IconsView);
+ m_additionalInfo->setEnabled(enabled);
+
+ // load show preview, show in groups and show hidden files settings
+ m_showPreview->setChecked(m_viewProps->showPreview());
+
+ m_showInGroups->setChecked(m_viewProps->categorizedSorting());
+ m_showInGroups->setEnabled(index == DolphinView::IconsView); // only the icons view supports categorized sorting
+
+ m_showHiddenFiles->setChecked(m_viewProps->showHiddenFiles());
+}
+
+#include "viewpropertiesdialog.moc"
diff --git a/src/settings/viewpropertiesdialog.h b/src/settings/viewpropertiesdialog.h
new file mode 100644
index 000000000..320f8f115
--- /dev/null
+++ b/src/settings/viewpropertiesdialog.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+ * 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 VIEWPROPERTIESDIALOG_H
+#define VIEWPROPERTIESDIALOG_H
+
+#include "libdolphin_export.h"
+
+#include <kdialog.h>
+
+class QCheckBox;
+class KComboBox;
+class QPushButton;
+class QRadioButton;
+class ViewProperties;
+class DolphinView;
+
+/**
+ * @brief Dialog for changing the current view properties of a directory.
+ *
+ * It is possible to specify the view mode, the sorting order, whether hidden files
+ * and previews should be shown. The properties can be assigned to the current folder,
+ * or recursively to all sub folders.
+ */
+class LIBDOLPHINPRIVATE_EXPORT ViewPropertiesDialog : public KDialog
+{
+ Q_OBJECT
+
+public:
+ explicit ViewPropertiesDialog(DolphinView* dolphinView);
+ virtual ~ViewPropertiesDialog();
+
+private slots:
+ void slotOk();
+ void slotApply();
+ void slotViewModeChanged(int index);
+ void slotSortingChanged(int index);
+ void slotSortOrderChanged(int index);
+ void slotCategorizedSortingChanged();
+ void slotShowPreviewChanged();
+ void slotShowHiddenFilesChanged();
+ void markAsDirty();
+ void configureAdditionalInfo();
+
+private:
+ void applyViewProperties();
+ void loadSettings();
+
+private:
+ bool m_isDirty;
+ DolphinView* m_dolphinView;
+ ViewProperties* m_viewProps;
+
+ KComboBox* m_viewMode;
+ KComboBox* m_sortOrder;
+ KComboBox* m_sorting;
+ QCheckBox* m_showPreview;
+ QCheckBox* m_showInGroups;
+ QCheckBox* m_showHiddenFiles;
+ QPushButton* m_additionalInfo;
+ QRadioButton* m_applyToCurrentFolder;
+ QRadioButton* m_applyToSubFolders;
+ QRadioButton* m_applyToAllFolders;
+ QCheckBox* m_useAsDefault;
+};
+
+#endif
diff --git a/src/settings/viewpropsprogressinfo.cpp b/src/settings/viewpropsprogressinfo.cpp
new file mode 100644
index 000000000..c073d3d46
--- /dev/null
+++ b/src/settings/viewpropsprogressinfo.cpp
@@ -0,0 +1,148 @@
+/***************************************************************************
+ * 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 "viewpropsprogressinfo.h"
+#include "applyviewpropsjob.h"
+#include "viewproperties.h"
+
+#include <QtGui/QLabel>
+#include <QtGui/QProgressBar>
+#include <QtCore/QTimer>
+#include <QtGui/QBoxLayout>
+
+#include <assert.h>
+#include <klocale.h>
+#include <kio/jobclasses.h>
+
+ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
+ const KUrl& dir,
+ const ViewProperties& viewProps) :
+ KDialog(parent),
+ m_dir(dir),
+ m_viewProps(0),
+ m_label(0),
+ m_progressBar(0),
+ m_dirSizeJob(0),
+ m_applyViewPropsJob(0),
+ m_timer(0)
+{
+ const QSize minSize = minimumSize();
+ setMinimumSize(QSize(320, minSize.height()));
+
+ setCaption(i18nc("@title:window", "Applying View Properties"));
+ setButtons(KDialog::Cancel);
+
+ m_viewProps = new ViewProperties(dir);
+ m_viewProps->setDirProperties(viewProps);
+
+ // the view properties are stored by the ViewPropsApplierJob, so prevent
+ // that the view properties are saved twice:
+ m_viewProps->setAutoSaveEnabled(false);
+
+ QWidget* main = new QWidget();
+ QVBoxLayout* topLayout = new QVBoxLayout();
+
+ m_label = new QLabel(i18nc("@info:progress", "Counting folders: %1", 0), main);
+ m_progressBar = new QProgressBar(main);
+ m_progressBar->setMinimum(0);
+ m_progressBar->setMaximum(0);
+ m_progressBar->setValue(0);
+
+ topLayout->addWidget(m_label);
+ topLayout->addWidget(m_progressBar);
+
+ main->setLayout(topLayout);
+ setMainWidget(main);
+
+ // Use the directory size job to count the number of directories first. This
+ // allows to give a progress indication for the user when applying the view
+ // properties later.
+ m_dirSizeJob = KIO::directorySize(dir);
+ connect(m_dirSizeJob, SIGNAL(result(KJob*)),
+ this, SLOT(applyViewProperties()));
+
+ // The directory size job cannot emit any progress signal, as it is not aware
+ // about the total number of directories. Therefor a timer is triggered, which
+ // periodically updates the current directory count.
+ m_timer = new QTimer(this);
+ connect(m_timer, SIGNAL(timeout()),
+ this, SLOT(updateProgress()));
+ m_timer->start(300);
+
+ connect(this, SIGNAL(cancelClicked()), this, SLOT(cancelApplying()));
+}
+
+ViewPropsProgressInfo::~ViewPropsProgressInfo()
+{
+ delete m_viewProps;
+ m_viewProps = 0;
+}
+
+void ViewPropsProgressInfo::closeEvent(QCloseEvent* event)
+{
+ m_timer->stop();
+ m_applyViewPropsJob = 0;
+ KDialog::closeEvent(event);
+}
+
+void ViewPropsProgressInfo::updateProgress()
+{
+ if (m_dirSizeJob != 0) {
+ const int subdirs = m_dirSizeJob->totalSubdirs();
+ m_label->setText(i18nc("@info:progress", "Counting folders: %1", subdirs));
+ }
+
+ if (m_applyViewPropsJob != 0) {
+ const int progress = m_applyViewPropsJob->progress();
+ m_progressBar->setValue(progress);
+ }
+}
+
+void ViewPropsProgressInfo::applyViewProperties()
+{
+ if (m_dirSizeJob->error()) {
+ return;
+ }
+
+ const int subdirs = m_dirSizeJob->totalSubdirs();
+ m_label->setText(i18nc("@info:progress", "Folders: %1", subdirs));
+ m_progressBar->setMaximum(subdirs);
+
+ m_dirSizeJob = 0;
+
+ m_applyViewPropsJob = new ApplyViewPropsJob(m_dir, *m_viewProps);
+ connect(m_applyViewPropsJob, SIGNAL(result(KJob*)),
+ this, SLOT(close()));
+}
+
+void ViewPropsProgressInfo::cancelApplying()
+{
+ if (m_dirSizeJob != 0) {
+ m_dirSizeJob->kill();
+ m_dirSizeJob = 0;
+ }
+
+ if (m_applyViewPropsJob != 0) {
+ m_applyViewPropsJob->kill();
+ m_applyViewPropsJob = 0;
+ }
+}
+
+#include "viewpropsprogressinfo.moc"
diff --git a/src/settings/viewpropsprogressinfo.h b/src/settings/viewpropsprogressinfo.h
new file mode 100644
index 000000000..d07d16d67
--- /dev/null
+++ b/src/settings/viewpropsprogressinfo.h
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * 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 VIEWPROPSPROGRESSINFO_H
+#define VIEWPROPSPROGRESSINFO_H
+
+#include <kdialog.h>
+#include <kio/directorysizejob.h>
+#include <kurl.h>
+
+class ApplyViewPropsJob;
+class QLabel;
+class QProgressBar;
+class QTimer;
+class ViewProperties;
+
+/**
+ * @brief Shows the progress information when applying view properties
+ * recursively to a given directory.
+ *
+ * It is possible to cancel the applying. In this case the already applied
+ * view properties won't get reverted.
+ */
+class ViewPropsProgressInfo : public KDialog
+{
+ Q_OBJECT
+
+public:
+ /**
+ * @param parent Parent widget of the dialog.
+ * @param dir Directory where the view properties should be applied to
+ * (including sub directories).
+ * @param viewProps View properties for the directory \a dir including its
+ * sub directories.
+ */
+ ViewPropsProgressInfo(QWidget* parent,
+ const KUrl& dir,
+ const ViewProperties& viewProps);
+
+ virtual ~ViewPropsProgressInfo();
+
+protected:
+ virtual void closeEvent(QCloseEvent* event);
+
+private slots:
+ void updateProgress();
+ void applyViewProperties();
+ void cancelApplying();
+
+private:
+ KUrl m_dir;
+ ViewProperties* m_viewProps;
+
+ QLabel* m_label;
+ QProgressBar* m_progressBar;
+
+ KIO::DirectorySizeJob* m_dirSizeJob;
+ ApplyViewPropsJob* m_applyViewPropsJob;
+ QTimer* m_timer;
+};
+
+#endif
diff --git a/src/settings/viewsettingspage.cpp b/src/settings/viewsettingspage.cpp
new file mode 100644
index 000000000..44d32af81
--- /dev/null
+++ b/src/settings/viewsettingspage.cpp
@@ -0,0 +1,98 @@
+/***************************************************************************
+ * 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 "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 <QtGui/QBoxLayout>
+#include <QtGui/QLayout>
+#include <QtGui/QLabel>
+
+#include <kdialog.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <ktabwidget.h>
+
+
+ViewSettingsPage::ViewSettingsPage(DolphinMainWindow* mainWindow,
+ QWidget* parent) :
+ SettingsPageBase(parent),
+ m_pages()
+{
+ QVBoxLayout* topLayout = new QVBoxLayout(this);
+ topLayout->setMargin(0);
+ topLayout->setSpacing(KDialog::spacingHint());
+
+ 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"));
+ connect(iconsPage, SIGNAL(changed()), this, SIGNAL(changed()));
+
+ // initialize 'Details' tab
+ DetailsViewSettingsPage* detailsPage = new DetailsViewSettingsPage(tabWidget);
+ tabWidget->addTab(detailsPage, KIcon("view-list-details"), i18nc("@title:tab", "Details"));
+ connect(detailsPage, SIGNAL(changed()), this, SIGNAL(changed()));
+
+ // initialize 'Column' tab
+ ColumnViewSettingsPage* columnPage = new ColumnViewSettingsPage(tabWidget);
+ 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);
+
+ topLayout->addWidget(tabWidget, 0, 0);
+}
+
+ViewSettingsPage::~ViewSettingsPage()
+{
+}
+
+void ViewSettingsPage::applySettings()
+{
+ foreach (ViewSettingsPageBase* page, m_pages) {
+ page->applySettings();
+ }
+}
+
+void ViewSettingsPage::restoreDefaults()
+{
+ foreach (ViewSettingsPageBase* page, m_pages) {
+ page->restoreDefaults();
+ }
+}
+
+#include "viewsettingspage.moc"
diff --git a/src/settings/viewsettingspage.h b/src/settings/viewsettingspage.h
new file mode 100644
index 000000000..5e76b30d1
--- /dev/null
+++ b/src/settings/viewsettingspage.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * 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 VIEWSETTINGSPAGE_H
+#define VIEWSETTINGSPAGE_H
+
+#include <QtGui/QWidget>
+#include <settings/settingspagebase.h>
+
+class ViewSettingsPageBase;
+class DolphinMainWindow;
+
+/**
+ * @brief Page for the 'View' settings of the Dolphin settings dialog.
+ *
+ * The views settings allow to set the properties for the icons mode,
+ * the details mode and the column mode.
+ */
+class ViewSettingsPage : public SettingsPageBase
+{
+ Q_OBJECT
+
+public:
+ ViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
+ virtual ~ViewSettingsPage();
+
+ /** @see SettingsPageBase::applySettings() */
+ virtual void applySettings();
+
+ /** @see SettingsPageBase::restoreDefaults() */
+ virtual void restoreDefaults();
+
+private:
+ QList<ViewSettingsPageBase*> m_pages;
+};
+
+#endif
diff --git a/src/settings/viewsettingspagebase.cpp b/src/settings/viewsettingspagebase.cpp
new file mode 100644
index 000000000..b610bb0f5
--- /dev/null
+++ b/src/settings/viewsettingspagebase.cpp
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 "viewsettingspagebase.h"
+
+ViewSettingsPageBase::ViewSettingsPageBase(QWidget* parent) :
+ KVBox(parent)
+{
+}
+
+ViewSettingsPageBase::~ViewSettingsPageBase()
+{
+}
+
+#include "viewsettingspagebase.moc"
diff --git a/src/settings/viewsettingspagebase.h b/src/settings/viewsettingspagebase.h
new file mode 100644
index 000000000..3e85e25cb
--- /dev/null
+++ b/src/settings/viewsettingspagebase.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * Copyright (C) 2008 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 VIEWSETTINGSPAGEBASE_H
+#define VIEWSETTINGSPAGEBASE_H
+
+#include <kvbox.h>
+
+/**
+ * @brief Base class for view settings configuration pages.
+ *
+ * @see GeneralViewSettingsPage;
+ * @see IconViewSettingsPage
+ * @see DetailsViewSettingsPage
+ * @see ColumnViewSettingsPage
+ */
+class ViewSettingsPageBase : public KVBox
+{
+ Q_OBJECT
+
+public:
+ ViewSettingsPageBase(QWidget* parent);
+ virtual ~ViewSettingsPageBase();
+
+ /**
+ * Applies the settings for the view.
+ * The settings are persisted automatically when
+ * closing Dolphin.
+ */
+ virtual void applySettings() = 0;
+
+ /** Restores the settings to default values. */
+ virtual void restoreDefaults() = 0;
+
+signals:
+ void changed();
+};
+
+#endif