]> cloud.milkyroute.net Git - dolphin.git/commitdiff
provide a config module for the settings GUI of the Dolphin views, so that it can...
authorPeter Penz <peter.penz19@gmail.com>
Sun, 23 Mar 2008 15:54:07 +0000 (15:54 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 23 Mar 2008 15:54:07 +0000 (15:54 +0000)
CCMAIL: faure@kde.org

svn path=/trunk/KDE/kdebase/apps/; revision=789209

29 files changed:
src/CMakeLists.txt
src/columnviewsettingspage.cpp
src/columnviewsettingspage.h
src/detailsviewsettingspage.cpp
src/detailsviewsettingspage.h
src/dolphin_folderspanelsettings.kcfg [new file with mode: 0644]
src/dolphin_folderspanelsettings.kcfgc [new file with mode: 0644]
src/dolphin_generalsettings.kcfg
src/dolphinfontrequester.cpp
src/dolphinfontrequester.h
src/dolphiniconsview.cpp
src/dolphinsettingsdialog.cpp
src/dolphinsettingsdialog.h
src/generalsettingspage.cpp
src/generalsettingspage.h
src/generalviewsettingspage.cpp
src/generalviewsettingspage.h
src/iconsviewsettingspage.cpp
src/iconsviewsettingspage.h
src/kcmdolphin.cpp [new file with mode: 0644]
src/kcmdolphin.desktop [new file with mode: 0644]
src/kcmdolphin.h [moved from src/dolphinfileitemdelegate.h with 70% similarity]
src/settingspagebase.h
src/startupsettingspage.cpp
src/startupsettingspage.h
src/viewsettingspage.cpp
src/viewsettingspage.h
src/viewsettingspagebase.cpp [moved from src/dolphinfileitemdelegate.cpp with 59% similarity]
src/viewsettingspagebase.h [new file with mode: 0644]

index 0354f925de77d65482110e6f61b6d30fa2328489..7ec2b5c5673e5db7941684d31888ca659e92fc90 100644 (file)
@@ -19,7 +19,6 @@ set(dolphinprivate_LIB_SRCS
     dolphincolumnview.cpp
     dolphincolumnwidget.cpp
     dolphindropcontroller.cpp
-    dolphinfileitemdelegate.cpp
     dolphinsortfilterproxymodel.cpp
     draganddrophelper.cpp
     dolphinmodel.cpp
@@ -41,8 +40,6 @@ kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
     dolphin_iconsmodesettings.kcfgc
     dolphin_generalsettings.kcfgc)
 
-
-
 kde4_add_library(dolphinprivate SHARED ${dolphinprivate_LIB_SRCS})
 
 find_package(Nepomuk)
@@ -80,44 +77,48 @@ install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
 ##########################################
 
 set(dolphin_SRCS
-   additionalinfodialog.cpp
-   applyviewpropsjob.cpp
-   columnviewsettingspage.cpp
-   detailsviewsettingspage.cpp
-   dolphinapplication.cpp
-   dolphinfontrequester.cpp
-   dolphinmainwindow.cpp
-   dolphinnewmenu.cpp
-   dolphinviewcontainer.cpp
-   dolphinstatusbar.cpp
-   dolphindirlister.cpp
-   dolphincontextmenu.cpp
-   dolphinfileplacesview.cpp
-   dolphinsettingsdialog.cpp
-   draganddrophelper.cpp
-   filterbar.cpp
-   generalsettingspage.cpp
-   generalviewsettingspage.cpp
-   iconsizedialog.cpp
-   iconsviewsettingspage.cpp
-   infosidebarpage.cpp
-   main.cpp
-   metadatawidget.cpp
-   commentwidget.cpp
-   commenteditwidget.cpp
-   metatextlabel.cpp
-   pixmapviewer.cpp
-   settingspagebase.cpp
-   sidebarpage.cpp
-   startupsettingspage.cpp
-   statusbarspaceinfo.cpp
-   statusbarmessagelabel.cpp
-   treeviewcontextmenu.cpp
-   treeviewsidebarpage.cpp
-   sidebartreeview.cpp
-   viewpropertiesdialog.cpp
-   viewsettingspage.cpp
-   viewpropsprogressinfo.cpp )
+    additionalinfodialog.cpp
+    applyviewpropsjob.cpp
+    columnviewsettingspage.cpp
+    commentwidget.cpp
+    commenteditwidget.cpp
+    detailsviewsettingspage.cpp
+    dolphinapplication.cpp
+    dolphinfontrequester.cpp
+    dolphinmainwindow.cpp
+    dolphinnewmenu.cpp
+    dolphinviewcontainer.cpp
+    dolphinstatusbar.cpp
+    dolphindirlister.cpp
+    dolphincontextmenu.cpp
+    dolphinfileplacesview.cpp
+    dolphinsettingsdialog.cpp
+    draganddrophelper.cpp
+    filterbar.cpp
+    generalsettingspage.cpp
+    generalviewsettingspage.cpp
+    iconsizedialog.cpp
+    iconsviewsettingspage.cpp
+    infosidebarpage.cpp
+    main.cpp
+    metadatawidget.cpp
+    metatextlabel.cpp
+    pixmapviewer.cpp
+    settingspagebase.cpp
+    sidebarpage.cpp
+    startupsettingspage.cpp
+    statusbarspaceinfo.cpp
+    statusbarmessagelabel.cpp
+    treeviewcontextmenu.cpp
+    treeviewsidebarpage.cpp
+    sidebartreeview.cpp
+    viewpropertiesdialog.cpp
+    viewsettingspage.cpp
+    viewsettingspagebase.cpp
+    viewpropsprogressinfo.cpp)
+
+kde4_add_kcfg_files(dolphin_SRCS
+    dolphin_folderspanelsettings.kcfgc)
 
 if(Nepomuk_FOUND)
 set(dolphin_SRCS
@@ -152,9 +153,40 @@ endif (Nepomuk_FOUND)
 
 install(TARGETS dolphin DESTINATION ${BIN_INSTALL_DIR})
 
+##########################################
+
+set(kcm_dolphin_PART_SRCS
+    kcmdolphin.cpp
+    columnviewsettingspage.cpp
+    detailsviewsettingspage.cpp
+    dolphinfontrequester.cpp
+    dolphinsettings.cpp
+    generalviewsettingspage.cpp
+    iconsizedialog.cpp
+    iconsviewsettingspage.cpp
+    pixmapviewer.cpp
+    viewsettingspagebase.cpp
+    viewproperties.cpp)
+
+kde4_add_kcfg_files(kcm_dolphin_PART_SRCS
+    dolphin_columnmodesettings.kcfgc
+    dolphin_directoryviewpropertysettings.kcfgc
+    dolphin_detailsmodesettings.kcfgc
+    dolphin_iconsmodesettings.kcfgc
+    dolphin_generalsettings.kcfgc)
+
+kde4_add_plugin(kcm_dolphin ${kcm_dolphin_PART_SRCS})
+
+target_link_libraries(kcm_dolphin  ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} )
+if (Nepomuk_FOUND)
+  target_link_libraries(kcm_dolphin ${NEPOMUK_LIBRARIES})
+endif (Nepomuk_FOUND)
+
+install(TARGETS kcm_dolphin DESTINATION ${PLUGIN_INSTALL_DIR} )
 
 ########### install files ###############
 
 install( FILES  dolphin.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
 install( FILES  dolphin_directoryviewpropertysettings.kcfg dolphin_generalsettings.kcfg dolphin_columnmodesettings.kcfg dolphin_iconsmodesettings.kcfg dolphin_detailsmodesettings.kcfg DESTINATION ${KCFG_INSTALL_DIR} )
 install( FILES  dolphinui.rc DESTINATION ${DATA_INSTALL_DIR}/dolphin )
+install( FILES kcmdolphin.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
\ No newline at end of file
index 44d2a4127151c9450cdc21a2b62011c1be6932d2..aa84fc3985807be86785e52444a2266720c0abf3 100644 (file)
 #include <QSlider>
 #include <QRadioButton>
 
-ColumnViewSettingsPage::ColumnViewSettingsPage(DolphinMainWindow* mainWindow,
-                                               QWidget* parent) :
-    KVBox(parent),
-    m_mainWindow(mainWindow),
+ColumnViewSettingsPage::ColumnViewSettingsPage(QWidget* parent) :
+    ViewSettingsPageBase(parent),
     m_smallIconSize(0),
     m_mediumIconSize(0),
     m_largeIconSize(0),
@@ -63,6 +61,7 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(DolphinMainWindow* mainWindow,
     m_columnWidthSlider->setPageStep(1);
     m_columnWidthSlider->setTickPosition(QSlider::TicksBelow);
     QLabel* largeLabel = new QLabel(i18nc("@item:inrange Column Width", "Large"), columnWidthBox);
+    connect(m_columnWidthSlider, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
 
     QHBoxLayout* columnWidthLayout = new QHBoxLayout(columnWidthBox);
     columnWidthLayout->addWidget(smallLabel);
@@ -76,6 +75,9 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(DolphinMainWindow* mainWindow,
     m_smallIconSize  = new QRadioButton(i18nc("@option:radio Icon Size", "Small"), this);
     m_mediumIconSize = new QRadioButton(i18nc("@option:radio Icon Size", "Medium"), this);
     m_largeIconSize  = new QRadioButton(i18nc("@option:radio Icon Size", "Large"), this);
+    connect(m_smallIconSize,  SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+    connect(m_mediumIconSize, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+    connect(m_largeIconSize,  SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
     QButtonGroup* iconSizeGroup = new QButtonGroup(this);
     iconSizeGroup->addButton(m_smallIconSize);
@@ -93,6 +95,7 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(DolphinMainWindow* mainWindow,
 
     QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textBox);
     m_fontRequester = new DolphinFontRequester(textBox);
+    connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
 
     QHBoxLayout* textLayout = new QHBoxLayout(textBox);
     textLayout->addWidget(fontLabel);
index acf92e744847632603779ac9f244cd0fd6529977..8ab90efc36cc0141f1d868bd472ff43460f986de 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef COLUMNVIEWSETTINGSPAGE_H
 #define COLUMNVIEWSETTINGSPAGE_H
 
-#include <kvbox.h>
+#include <viewsettingspagebase.h>
 
 class DolphinMainWindow;
 class DolphinFontRequester;
@@ -31,12 +31,12 @@ class QRadioButton;
  * @brief Represents the page from the Dolphin Settings which allows
  *        to modify the settings for the details view.
  */
-class ColumnViewSettingsPage : public KVBox
+class ColumnViewSettingsPage : public ViewSettingsPageBase
 {
     Q_OBJECT
 
 public:
-    ColumnViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
+    ColumnViewSettingsPage(QWidget* parent);
     virtual ~ColumnViewSettingsPage();
 
     /**
@@ -44,16 +44,15 @@ public:
      * The settings are persisted automatically when
      * closing Dolphin.
      */
-    void applySettings();
+    virtual void applySettings();
 
     /** Restores the settings to default values. */
-    void restoreDefaults();
+    virtual void restoreDefaults();
 
 private:
     void loadSettings();
 
 private:
-    DolphinMainWindow* m_mainWindow;
     QRadioButton* m_smallIconSize;
     QRadioButton* m_mediumIconSize;
     QRadioButton* m_largeIconSize;
index 8838ee7ec784c361bf97c08c70a467fc8fbfa637..a51e121e9ec1c0af9db997c5049ed04ce1fd1b49 100644 (file)
 #include <QRadioButton>
 #include <QtGui/QSpinBox>
 
-DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
-                                                 QWidget* parent) :
-    KVBox(parent),
-    m_mainWindow(mainWindow),
+DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget* parent) :
+    ViewSettingsPageBase(parent),
     m_smallIconSize(0),
     m_mediumIconSize(0),
     m_largeIconSize(0),
@@ -59,6 +57,9 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
     m_smallIconSize  = new QRadioButton(i18nc("@option:radio Icon Size", "Small"), this);
     m_mediumIconSize = new QRadioButton(i18nc("@option:radio Icon Size", "Medium"), this);
     m_largeIconSize  = new QRadioButton(i18nc("@option:radio Icon Size", "Large"), this);
+    connect(m_smallIconSize,  SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+    connect(m_mediumIconSize, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+    connect(m_largeIconSize,  SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
     QButtonGroup* iconSizeGroup = new QButtonGroup(this);
     iconSizeGroup->addButton(m_smallIconSize);
@@ -76,6 +77,7 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
 
     QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textBox);
     m_fontRequester = new DolphinFontRequester(textBox);
+    connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
 
     QHBoxLayout* textLayout = new QHBoxLayout(textBox);
     textLayout->addWidget(fontLabel);
@@ -83,6 +85,7 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
 
     // 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
index b6622348c5e6d1b93b5be78052fd5e1d4e681ee3..d292a1aef5eb500a94400ca98a56366dd2942311 100644 (file)
@@ -20,9 +20,8 @@
 #ifndef DETAILSVIEWSETTINGSPAGE_H
 #define DETAILSVIEWSETTINGSPAGE_H
 
-#include <kvbox.h>
+#include <viewsettingspagebase.h>
 
-class DolphinMainWindow;
 class DolphinFontRequester;
 class QCheckBox;
 class QRadioButton;
@@ -31,12 +30,12 @@ class QRadioButton;
  * @brief Represents the page from the Dolphin Settings which allows
  *        to modify the settings for the details view.
  */
-class DetailsViewSettingsPage : public KVBox
+class DetailsViewSettingsPage : public ViewSettingsPageBase
 {
     Q_OBJECT
 
 public:
-    DetailsViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
+    DetailsViewSettingsPage(QWidget* parent);
     virtual ~DetailsViewSettingsPage();
 
     /**
@@ -44,16 +43,15 @@ public:
      * The settings are persisted automatically when
      * closing Dolphin.
      */
-    void applySettings();
+    virtual void applySettings();
 
     /** Restores the settings to default values. */
-    void restoreDefaults();
+    virtual void restoreDefaults();
 
 private:
     void loadSettings();
 
 private:
-    DolphinMainWindow* m_mainWindow;
     QRadioButton* m_smallIconSize;
     QRadioButton* m_mediumIconSize;
     QRadioButton* m_largeIconSize;
diff --git a/src/dolphin_folderspanelsettings.kcfg b/src/dolphin_folderspanelsettings.kcfg
new file mode 100644 (file)
index 0000000..816d783
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
+<kcfg>
+    <kcfgfile name="dolphinrc"/>
+    <group name="FoldersPanel">
+        <entry name="ShowHiddenFiles" type="Bool">
+            <label context="@label">Show hidden files</label>
+            <default>false</default>
+        </entry>
+    </group>
+</kcfg>
diff --git a/src/dolphin_folderspanelsettings.kcfgc b/src/dolphin_folderspanelsettings.kcfgc
new file mode 100644 (file)
index 0000000..f73e880
--- /dev/null
@@ -0,0 +1,4 @@
+File=dolphin_folderspanelsettings.kcfg
+ClassName=FoldersPanelSettings
+Singleton=true
+Mutators=true
index 840d8a42dea7d9daa0fcf33e7c7d8723abd1b1fd..b34407c666a800820bf265591eeb2f4d81e3d56b 100644 (file)
             <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>
index 8e27851e2f006164eda12e9414e62aa32e5b5864..e2cbad0d54a6eee9b5f20b2076712b9e8f2b5d61 100644 (file)
@@ -34,6 +34,8 @@ DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
     m_mode(SystemFont),
     m_customFont()
 {
+    setSpacing(KDialog::spacingHint());
+
     m_modeCombo = new QComboBox(this);
     m_modeCombo->addItem(i18nc("@item:inlistbox Font", "System Font"));
     m_modeCombo->addItem(i18nc("@item:inlistbox Font", "Custom Font"));
@@ -96,12 +98,14 @@ void DolphinFontRequester::openFontDialog()
     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"
index 83a478a30bf2a130ea5d1035ad247994355a2b90..34d69ad6152f967d438fced44e3d5d31de2a7aa2 100644 (file)
@@ -57,6 +57,10 @@ public:
     void setCustomFont(const QFont& font);
     QFont customFont() const;
 
+signals:
+    /** Is emitted, if the font has been changed. */
+    void changed();
+
 protected:
     bool event(QEvent* event);
 
index 9b9252857ef11aa03445ff3abcf9469cfcf4fe18..da1784c312f96622a2156c8a4d6f57da4010c4e2 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "dolphincategorydrawer.h"
 #include "dolphincontroller.h"
-#include "dolphinfileitemdelegate.h"
 #include "dolphinsettings.h"
 #include "dolphin_iconsmodesettings.h"
 #include "dolphin_generalsettings.h"
@@ -31,6 +30,7 @@
 #include <kcategorizedsortfilterproxymodel.h>
 #include <kdialog.h>
 #include <kdirmodel.h>
+#include <kfileitemdelegate.h>
 
 #include <QAbstractProxyModel>
 #include <QApplication>
@@ -257,8 +257,7 @@ void DolphinIconsView::wheelEvent(QWheelEvent* event)
 
 void DolphinIconsView::showEvent(QShowEvent* event)
 {
-    Q_ASSERT(qobject_cast<DolphinFileItemDelegate*>(itemDelegate()) != 0);
-    DolphinFileItemDelegate* delegate = static_cast<DolphinFileItemDelegate*>(itemDelegate());
+    KFileItemDelegate* delegate = dynamic_cast<KFileItemDelegate*>(itemDelegate());
     delegate->setMaximumSize(m_itemSize);
 
     KCategorizedView::showEvent(event);
@@ -428,7 +427,7 @@ void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
     m_controller->setZoomInPossible(isZoomInPossible());
     m_controller->setZoomOutPossible(isZoomOutPossible());
 
-    DolphinFileItemDelegate* delegate = qobject_cast<DolphinFileItemDelegate*>(itemDelegate());
+    KFileItemDelegate* delegate = dynamic_cast<KFileItemDelegate*>(itemDelegate());
     if (delegate != 0) {
         delegate->setMaximumSize(m_itemSize);
     }
index 8aa86df244f331d078a638b8557ff54d3d425273..7b1e2326635118439be005beaf03a38ba73e6da4 100644 (file)
@@ -32,9 +32,7 @@
 
 DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
     KPageDialog(mainWindow),
-    m_startupSettingsPage(0),
-    m_generalSettingsPage(0),
-    m_viewSettingsPage(0)
+    m_pages()
 
 {
     const QSize minSize = minimumSize();
@@ -43,25 +41,33 @@ DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
     setFaceType(List);
     setCaption(i18nc("@title:window", "Dolphin Preferences"));
     setButtons(Ok | Apply | Cancel | Default);
+    enableButtonApply(false);
     setDefaultButton(Ok);
 
-    m_startupSettingsPage = new StartupSettingsPage(mainWindow, this);
-    KPageWidgetItem* startupSettingsFrame = addPage(m_startupSettingsPage,
+    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()));
 
-    m_viewSettingsPage = new ViewSettingsPage(mainWindow, this);
-    KPageWidgetItem* viewSettingsFrame = addPage(m_viewSettingsPage,
+    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()));
 
-    m_generalSettingsPage = new GeneralSettingsPage(mainWindow, this);
-    KPageWidgetItem* generalSettingsFrame = addPage(m_generalSettingsPage,
+    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()
@@ -84,19 +90,24 @@ void DolphinSettingsDialog::slotButtonClicked(int button)
     KPageDialog::slotButtonClicked(button);
 }
 
+void DolphinSettingsDialog::enableApply()
+{
+    enableButtonApply(true);
+}
+
 void DolphinSettingsDialog::applySettings()
 {
-    m_startupSettingsPage->applySettings();
-    m_generalSettingsPage->applySettings();
-    m_viewSettingsPage->applySettings();
+    foreach (SettingsPageBase* page, m_pages) {
+        page->applySettings();
+    }
     DolphinApplication::app()->refreshMainWindows();
 }
 
 void DolphinSettingsDialog::restoreDefaults()
 {
-    m_startupSettingsPage->restoreDefaults();
-    m_generalSettingsPage->restoreDefaults();
-    m_viewSettingsPage->restoreDefaults();
+    foreach (SettingsPageBase* page, m_pages) {
+        page->restoreDefaults();
+    }
     DolphinApplication::app()->refreshMainWindows();
 }
 
index 2cb7fc78ebdbe34a97a19e706fdf5bea37898054..fc17b377403b4712208491f7759bd7ff73d7b4c5 100644 (file)
 
 #include <kpagedialog.h>
 
-class GeneralSettingsPage;
-class StartupSettingsPage;
-class ViewSettingsPage;
 class DolphinMainWindow;
+class SettingsPageBase;
 
 /**
  * @brief Settings dialog for Dolphin.
@@ -47,14 +45,16 @@ protected slots:
     /** @see KDialog::slotButtonClicked() */
     virtual void slotButtonClicked(int button);
 
+private slots:
+    /** Enables the Apply button. */
+    void enableApply();
+
 private:
     void applySettings();
     void restoreDefaults();
 
 private:
-    StartupSettingsPage* m_startupSettingsPage;
-    GeneralSettingsPage* m_generalSettingsPage;
-    ViewSettingsPage* m_viewSettingsPage;
+    QList<SettingsPageBase*> m_pages;
 };
 
 #endif
index 2b582e8008bae1218fc794e8bf887030ee6452fb..f976bbffa9416fd0d385b365034f7086acd547b1 100644 (file)
 
 GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* parent) :
     SettingsPageBase(parent),
-    m_showDeleteCommand(0),
     m_confirmMoveToTrash(0),
     m_confirmDelete(0),
-    m_browseThroughArchives(0)
+    m_showDeleteCommand(0),
+    m_browseThroughArchives(0),
+    m_renameInline(0)
 {
     Q_UNUSED(mainWin);
 
@@ -52,8 +53,10 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* pa
     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);
@@ -61,8 +64,13 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* pa
 
     // create 'Show the command 'Delete' in context menu' checkbox
     m_showDeleteCommand = new QCheckBox(i18nc("@option:check", "Show 'Delete' command in context menu"), vBox);
+    connect(m_showDeleteCommand, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
     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()));
 
     // Add a dummy widget with no restriction regarding
     // a vertical resizing. This assures that the dialog layout
@@ -93,6 +101,7 @@ void GeneralSettingsPage::applySettings()
     kdeConfig.sync();
 
     settings->setBrowseThroughArchives(m_browseThroughArchives->isChecked());
+    settings->setRenameInline(m_renameInline->isChecked());
 }
 
 void GeneralSettingsPage::restoreDefaults()
@@ -117,6 +126,7 @@ void GeneralSettingsPage::loadSettings()
 
     GeneralSettings* settings = DolphinSettings::instance().generalSettings();
     m_browseThroughArchives->setChecked(settings->browseThroughArchives());
+    m_renameInline->setChecked(settings->renameInline());
 }
 
 #include "generalsettingspage.moc"
index df713ad477ec6f8c446b1aaa3a13a09bf26915a9..42ea08185c59c1687115dd5f518dbd2c0ee273e1 100644 (file)
@@ -47,11 +47,12 @@ private:
     void loadSettings();
 
 private:
-    QCheckBox* m_showDeleteCommand;
     QCheckBox* m_confirmMoveToTrash;
     QCheckBox* m_confirmDelete;
 
+    QCheckBox* m_showDeleteCommand;
     QCheckBox* m_browseThroughArchives;
+    QCheckBox* m_renameInline;
 };
 
 #endif
index ed219db050b68379c51fecbdaa1c4c0671093a58..8fa50c47fa3a426c9177bf27e8401a681880de9c 100644 (file)
 #include <klocale.h>
 #include <khbox.h>
 
-GeneralViewSettingsPage::GeneralViewSettingsPage(DolphinMainWindow* mainWindow,
+GeneralViewSettingsPage::GeneralViewSettingsPage(const KUrl& url,
                                                  QWidget* parent) :
-    KVBox(parent),
-    m_mainWindow(mainWindow),
+    ViewSettingsPageBase(parent),
+    m_url(url),
     m_localProps(0),
     m_globalProps(0),
     m_maxPreviewSize(0),
@@ -60,7 +60,10 @@ GeneralViewSettingsPage::GeneralViewSettingsPage(DolphinMainWindow* mainWindow,
     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);
@@ -82,13 +85,20 @@ GeneralViewSettingsPage::GeneralViewSettingsPage(DolphinMainWindow* mainWindow,
     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 toggle"), this);
+    connect(m_showSelectionToggle, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
     // Add a dummy widget with no restriction regarding
     // a vertical resizing. This assures that the dialog layout
@@ -105,8 +115,7 @@ GeneralViewSettingsPage::~GeneralViewSettingsPage()
 
 void GeneralViewSettingsPage::applySettings()
 {
-    const KUrl& url = m_mainWindow->activeViewContainer()->url();
-    ViewProperties props(url);  // read current view properties
+    ViewProperties props(m_url);  // read current view properties
 
     const bool useGlobalProps = m_globalProps->isChecked();
 
@@ -118,7 +127,7 @@ void GeneralViewSettingsPage::applySettings()
         // 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(url);
+        ViewProperties globalProps(m_url);
         globalProps.setDirProperties(props);
     }
 
index c84335dc1e655011ab320820177e7c36d257c9ba..91128f4da46b659d9c93115713232f6625a700ee 100644 (file)
@@ -20,7 +20,8 @@
 #ifndef GENERALVIEWSETTINGSPAGE_H
 #define GENERALVIEWSETTINGSPAGE_H
 
-#include <kvbox.h>
+#include <kurl.h>
+#include <viewsettingspagebase.h>
 
 class DolphinMainWindow;
 class QCheckBox;
@@ -32,12 +33,17 @@ class QSpinBox;
  * @brief Represents the page from the Dolphin Settings which allows
  * to modify general settings for the view modes.
  */
-class GeneralViewSettingsPage : public KVBox
+class GeneralViewSettingsPage : public ViewSettingsPageBase
 {
     Q_OBJECT
 
 public:
-    GeneralViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
+    /**
+     * @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();
 
     /**
@@ -45,16 +51,16 @@ public:
      * The settings are persisted automatically when
      * closing Dolphin.
      */
-    void applySettings();
+    virtual void applySettings();
 
     /** Restores the settings to default values. */
-    void restoreDefaults();
+    virtual void restoreDefaults();
 
 private:
     void loadSettings();
 
 private:
-    DolphinMainWindow* m_mainWindow;
+    KUrl m_url;
     QRadioButton* m_localProps;
     QRadioButton* m_globalProps;
     QSlider* m_maxPreviewSize;
index 0a386c89c5e1fe23bd8f66db9a823a490984daf6..0c377d91b69d8a706185e2f07ee68b577ded9329 100644 (file)
 #include <QGridLayout>
 #include <QVBoxLayout>
 
-IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
-                                             QWidget* parent) :
-    KVBox(parent),
-    m_mainWindow(mainWindow),
+IconsViewSettingsPage::IconsViewSettingsPage(QWidget* parent) :
+    ViewSettingsPageBase(parent),
     m_iconSize(0),
     m_previewSize(0),
     m_iconSizeButton(0),
@@ -71,17 +69,20 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
 
     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 QComboBox(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);
@@ -99,12 +100,14 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
     m_arrangementBox = new QComboBox(gridGroup);
     m_arrangementBox->addItem(i18nc("@item:inlistbox Arrangement", "Left to Right"));
     m_arrangementBox->addItem(i18nc("@item:inlistbox Arrangement", "Top to Bottom"));
+    connect(m_arrangementBox, SIGNAL(activated(int)), this, SIGNAL(changed()));
 
     QLabel* gridSpacingLabel = new QLabel(i18nc("@label:listbox", "Grid spacing:"), gridGroup);
     m_gridSpacingBox = new QComboBox(gridGroup);
     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);
@@ -180,6 +183,7 @@ void IconsViewSettingsPage::openIconSizeDialog()
     if (dialog.exec() == QDialog::Accepted) {
         m_iconSize = dialog.iconSize();
         m_previewSize = dialog.previewSize();
+        emit changed();
     }
 }
 
index 1aa1c74bbb70a0aa470b28f3bf0390f71de16e1e..c7f3123abc8219fc92ad5535bdac0c76456e654a 100644 (file)
@@ -21,9 +21,8 @@
 #define ICONSVIEWSETTINGSPAGE_H
 
 #include <dolphiniconsview.h>
-#include <kvbox.h>
+#include <viewsettingspagebase.h>
 
-class DolphinMainWindow;
 class DolphinFontRequester;
 class QCheckBox;
 class QComboBox;
@@ -45,12 +44,12 @@ class QSpinBox;
  *
  * @see DolphinIconsViewSettings
  */
-class IconsViewSettingsPage : public KVBox
+class IconsViewSettingsPage : public ViewSettingsPageBase
 {
     Q_OBJECT
 
 public:
-    IconsViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
+    IconsViewSettingsPage(QWidget* parent);
     virtual ~IconsViewSettingsPage();
 
     /**
@@ -58,10 +57,10 @@ public:
      * The settings are persisted automatically when
      * closing Dolphin.
      */
-    void applySettings();
+    virtual void applySettings();
 
     /** Restores the settings to default values. */
-    void restoreDefaults();
+    virtual void restoreDefaults();
 
 private slots:
     void openIconSizeDialog();
@@ -80,7 +79,6 @@ private:
         TopToBottomInc  =  32
     };
 
-    DolphinMainWindow* m_mainWindow;
     int m_iconSize;
     int m_previewSize;
 
diff --git a/src/kcmdolphin.cpp b/src/kcmdolphin.cpp
new file mode 100644 (file)
index 0000000..0902cdb
--- /dev/null
@@ -0,0 +1,99 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "kcmdolphin.h"
+
+#include "columnviewsettingspage.h"
+#include "detailsviewsettingspage.h"
+#include "generalviewsettingspage.h"
+#include "iconsviewsettingspage.h"
+
+#include <kdialog.h>
+#include <klocale.h>
+#include <kpluginfactory.h>
+#include <kpluginloader.h>
+
+#include <QDir>
+#include <QPushButton>
+#include <QVBoxLayout>
+
+K_PLUGIN_FACTORY(KCMDolphinConfigFactory, registerPlugin<DolphinConfigModule>("dolphin");)
+K_EXPORT_PLUGIN(KCMDolphinConfigFactory("kcmdolphin"))
+
+DolphinConfigModule::DolphinConfigModule(QWidget* parent, const QVariantList& args) :
+    KCModule(KCMDolphinConfigFactory::componentData(), parent),
+    m_pages()
+{
+    Q_UNUSED(args);
+
+    setButtons(KCModule::Default | KCModule::Help);
+
+    QVBoxLayout* topLayout = new QVBoxLayout(this);
+    topLayout->setMargin(0);
+    topLayout->setSpacing(KDialog::spacingHint());
+
+    QTabWidget* tabWidget = new QTabWidget(this);
+
+    // initialize 'General' tab
+    GeneralViewSettingsPage* generalPage = new GeneralViewSettingsPage(QDir::homePath(), tabWidget);
+    tabWidget->addTab(generalPage, KIcon("view-choose"), i18nc("@title:tab General settings", "General"));
+    connect(generalPage, SIGNAL(changed()), this, SLOT(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, SLOT(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, SLOT(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, SLOT(changed()));
+
+    m_pages.append(generalPage);
+    m_pages.append(iconsPage);
+    m_pages.append(detailsPage);
+    m_pages.append(columnPage);
+
+    topLayout->addWidget(tabWidget, 0, 0);
+}
+
+DolphinConfigModule::~DolphinConfigModule()
+{
+}
+
+void DolphinConfigModule::save()
+{
+    foreach (ViewSettingsPageBase* page, m_pages) {
+        page->applySettings();
+    }
+}
+
+void DolphinConfigModule::defaults()
+{
+    foreach (ViewSettingsPageBase* page, m_pages) {
+        page->restoreDefaults();
+    }
+}
+
+#include "kcmdolphin.moc"
diff --git a/src/kcmdolphin.desktop b/src/kcmdolphin.desktop
new file mode 100644 (file)
index 0000000..3733d7a
--- /dev/null
@@ -0,0 +1,16 @@
+Name=Dolphin
+Comment=This service allows to configure the Dolphin views.
+
+[Desktop Entry]
+Icon=view-choose
+Type=Service
+X-KDE-ServiceTypes=KCModule
+Exec=kcmshell4 kcmdolphin
+
+X-KDE-Library=kcm_dolphin
+X-KDE-PluginKeyword=dolphin
+X-KDE-ParentApp=kcontrol
+
+Name=Views
+Comment=Configure file manager settings
+X-KDE-Keywords=file manager
\ No newline at end of file
similarity index 70%
rename from src/dolphinfileitemdelegate.h
rename to src/kcmdolphin.h
index 2f0167cd987878acb89aa1fec2d11d1bcd83973d..78f9277db815c0b60c508e5ce6bd58aa47fc037d 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#ifndef DOLPHINFILEITEMDELEGATE_H
-#define DOLPHINFILEITEMDELEGATE_H
+#ifndef DOLPHINCONFIGMODULE_H
+#define DOLPHINCONFIGMODULE_H
 
-#include <kfileitemdelegate.h>
+#include <kcmodule.h>
+
+class ViewSettingsPageBase;
 
 /**
- * @brief Extends KFileItemDelegate with the ability to set
- *        a maximum size.
+ * @brief Allow to configure the Dolphin views.
  */
-class DolphinFileItemDelegate : public KFileItemDelegate
+class DolphinConfigModule : public KCModule
 {
     Q_OBJECT
 
 public:
-    explicit DolphinFileItemDelegate(QObject* parent = 0);
-    virtual ~DolphinFileItemDelegate();
-
-    void setMaximumSize(const QSize& size);
-    QSize maximumSize() const;
+    DolphinConfigModule(QWidget* parent, const QVariantList& args);
+    virtual ~DolphinConfigModule();
 
-    /** @see QItemDelegate::sizeHint() */
-    virtual QSize sizeHint(const QStyleOptionViewItem& option,
-                           const QModelIndex& index) const;
+    virtual void save();
+    virtual void defaults();
 
 private:
-    QSize m_maxSize;
+    QList<ViewSettingsPageBase*> m_pages;
 };
 
 #endif
index d785e5dcdf14dbe96bd6457880a65e0df71ab8fb..19d4cf1f0f8182f4bc5ccae1fa6e0d2e595b8be1 100644 (file)
@@ -47,6 +47,10 @@ public:
      * restored the settings to default values.
      */
     virtual void restoreDefaults() = 0;
+
+signals:
+    /** Is emitted if a setting has been changed. */
+    void changed();
 };
 
 #endif
index 5d85b33d03f874a8284ac8cfba8a9fe8c6473b7a..a7ef58905118b06796e5c5288162a9c4610ab8c4 100644 (file)
 #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 <QLineEdit>
 #include <QPushButton>
 #include <QRadioButton>
 
@@ -60,7 +60,8 @@ StartupSettingsPage::StartupSettingsPage(DolphinMainWindow* mainWin, QWidget* pa
     homeUrlBox->setSpacing(spacing);
 
     new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox);
-    m_homeUrl = new QLineEdit(homeUrlBox);
+    m_homeUrl = new KLineEdit(homeUrlBox);
+    m_homeUrl->setClearButtonShown(true);
 
     QPushButton* selectHomeUrlButton = new QPushButton(KIcon("folder-open"), QString(), homeUrlBox);
     connect(selectHomeUrlButton, SIGNAL(clicked()),
@@ -84,6 +85,9 @@ StartupSettingsPage::StartupSettingsPage(DolphinMainWindow* mainWin, QWidget* pa
     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_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_filterBar,   SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
     // Add a dummy widget with no restriction regarding
     // a vertical resizing. This assures that the dialog layout
@@ -93,6 +97,10 @@ StartupSettingsPage::StartupSettingsPage(DolphinMainWindow* mainWin, QWidget* pa
     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()
@@ -129,6 +137,7 @@ void StartupSettingsPage::selectHomeUrl()
     KUrl url = KFileDialog::getExistingDirectoryUrl(homeUrl);
     if (!url.isEmpty()) {
         m_homeUrl->setText(url.prettyUrl());
+        emit changed();
     }
 }
 
index 14314c6c22087af8ea1246b4255c2ee458a8942d..bee24b15fcfa872c7cb23620d6a9e9e117adaef1 100644 (file)
@@ -22,7 +22,7 @@
 #include <settingspagebase.h>
 
 class DolphinMainWindow;
-class QLineEdit;
+class KLineEdit;
 class QCheckBox;
 
 /**
@@ -55,7 +55,7 @@ private:
 
 private:
     DolphinMainWindow* m_mainWindow;
-    QLineEdit* m_homeUrl;
+    KLineEdit* m_homeUrl;
 
     QCheckBox* m_splitView;
     QCheckBox* m_editableUrl;
index 1b99bc6219914eb77ece9f323f20ffe18834158f..32b893c90fe78b627661955c0ab7a8692ec4d16d 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "columnviewsettingspage.h"
 #include "detailsviewsettingspage.h"
+#include "dolphinmainwindow.h"
+#include "dolphinviewcontainer.h"
 #include "generalviewsettingspage.h"
 #include "iconsviewsettingspage.h"
 
 ViewSettingsPage::ViewSettingsPage(DolphinMainWindow* mainWindow,
                                    QWidget* parent) :
     SettingsPageBase(parent),
-    m_generalPage(0),
-    m_iconsPage(0),
-    m_detailsPage(0),
-    m_columnPage(0)
+    m_pages()
 {
     QVBoxLayout* topLayout = new QVBoxLayout(this);
     topLayout->setMargin(0);
@@ -49,20 +48,30 @@ ViewSettingsPage::ViewSettingsPage(DolphinMainWindow* mainWindow,
     QTabWidget* tabWidget = new QTabWidget(this);
 
     // initialize 'General' tab
-    m_generalPage = new GeneralViewSettingsPage(mainWindow, tabWidget);
-    tabWidget->addTab(m_generalPage, KIcon("view-choose"), i18nc("@title:tab General settings", "General"));
+    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
-    m_iconsPage = new IconsViewSettingsPage(mainWindow, tabWidget);
-    tabWidget->addTab(m_iconsPage, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
+    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
-    m_detailsPage = new DetailsViewSettingsPage(mainWindow, tabWidget);
-    tabWidget->addTab(m_detailsPage, KIcon("view-list-details"), i18nc("@title:tab", "Details"));
+    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
-    m_columnPage = new ColumnViewSettingsPage(mainWindow, tabWidget);
-    tabWidget->addTab(m_columnPage, KIcon("view-file-columns"), i18nc("@title:tab", "Column"));
+    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);
 }
@@ -73,18 +82,16 @@ ViewSettingsPage::~ViewSettingsPage()
 
 void ViewSettingsPage::applySettings()
 {
-    m_generalPage->applySettings();
-    m_iconsPage->applySettings();
-    m_detailsPage->applySettings();
-    m_columnPage->applySettings();
+    foreach (ViewSettingsPageBase* page, m_pages) {
+        page->applySettings();
+    }
 }
 
 void ViewSettingsPage::restoreDefaults()
 {
-    m_generalPage->restoreDefaults();
-    m_iconsPage->restoreDefaults();
-    m_detailsPage->restoreDefaults();
-    m_columnPage->restoreDefaults();
+    foreach (ViewSettingsPageBase* page, m_pages) {
+        page->restoreDefaults();
+    }
 }
 
 #include "viewsettingspage.moc"
index 46671cb0c3c43adb97a2ad111c230dc34918a741..21ce40039d40c8f673af3dafc41994a92446f389 100644 (file)
 #include <QtGui/QWidget>
 #include <settingspagebase.h>
 
-class ColumnViewSettingsPage;
+class ViewSettingsPageBase;
 class DolphinMainWindow;
-class GeneralViewSettingsPage;
-class IconsViewSettingsPage;
-class DetailsViewSettingsPage;
 
 /**
  * @brief Page for the 'View' settings of the Dolphin settings dialog.
@@ -50,10 +47,7 @@ public:
     virtual void restoreDefaults();
 
 private:
-    GeneralViewSettingsPage* m_generalPage;
-    IconsViewSettingsPage* m_iconsPage;
-    DetailsViewSettingsPage* m_detailsPage;
-    ColumnViewSettingsPage* m_columnPage;
+    QList<ViewSettingsPageBase*> m_pages;
 };
 
 #endif
similarity index 59%
rename from src/dolphinfileitemdelegate.cpp
rename to src/viewsettingspagebase.cpp
index a9ecc2a71d811f5618cbfaa7e04c133cac8c51c7..b610bb0f5954e7bff0321434df7a8d80a4f7e7f2 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#include "dolphinfileitemdelegate.h"
+#include "viewsettingspagebase.h"
 
-DolphinFileItemDelegate::DolphinFileItemDelegate(QObject* parent) :
-    KFileItemDelegate(parent),
-    m_maxSize(0, 0)
+ViewSettingsPageBase::ViewSettingsPageBase(QWidget* parent) :
+    KVBox(parent)
 {
 }
 
-DolphinFileItemDelegate::~DolphinFileItemDelegate()
+ViewSettingsPageBase::~ViewSettingsPageBase()
 {
 }
 
-void DolphinFileItemDelegate::setMaximumSize(const QSize& size)
-{
-    m_maxSize = size;
-}
-
-
-QSize DolphinFileItemDelegate::maximumSize() const
-{
-    return m_maxSize;
-}
-
-QSize DolphinFileItemDelegate::sizeHint(const QStyleOptionViewItem& option,
-                                        const QModelIndex& index) const
-{
-    QSize size = KFileItemDelegate::sizeHint(option, index);
-
-    const int maxWidth = m_maxSize.width();
-    if ((maxWidth > 0) && (size.width() > maxWidth)) {
-        size.setWidth(maxWidth);
-    }
-
-    const int maxHeight = m_maxSize.height();
-    if ((maxHeight > 0) && (size.height() > maxHeight)) {
-        size.setHeight(maxHeight);
-    }
-
-    return size;
-}
-
-#include "dolphinfileitemdelegate.moc"
+#include "viewsettingspagebase.moc"
diff --git a/src/viewsettingspagebase.h b/src/viewsettingspagebase.h
new file mode 100644 (file)
index 0000000..3e85e25
--- /dev/null
@@ -0,0 +1,55 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef 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