]> cloud.milkyroute.net Git - dolphin.git/commitdiff
The icons view and details view don't use hardcoded (test-) values anymore, instead...
authorPeter Penz <peter.penz19@gmail.com>
Tue, 27 Feb 2007 20:46:21 +0000 (20:46 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 27 Feb 2007 20:46:21 +0000 (20:46 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=637792

src/dolphin_iconsmodesettings.kcfg
src/dolphindetailsview.cpp
src/dolphindetailsview.h
src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/iconsviewsettingspage.cpp

index 23ee5ec9320e846e4045e32382b87e4a7bb317e8..b620dfe5d3e075079d9e876a007170ae78c763a1 100644 (file)
@@ -4,10 +4,11 @@
     <kcfgfile name="dolphinrc"/>
     <include>kiconloader.h</include>
     <include>kglobalsettings.h</include>
+    <include>QListView</include>
     <group name="IconsMode">
-        <entry name="Arrangement" type="String">
+        <entry name="Arrangement" type="Int">
             <label>Arrangement</label>
-            <default>LeftToRight</default>
+            <default code="true">QListView::TopToBottom</default>
         </entry>
         <entry name="FontFamily" type="String">
             <label>Font family</label>
         </entry>
         <entry name="GridHeight" type="Int">
             <label>Grid height</label>
-            <default code="true">K3Icon::SizeMedium</default>
+            <default code="true">96</default>
         </entry>
         <entry name="GridWidth" type="Int">
             <label>Grid width</label>
-            <default>0</default>
+            <default>128</default>
         </entry>
         <entry name="GridSpacing" type="Int">
             <label>Grid spacing</label>
index 0b350f8b2fb85d643c18b747ddd701a77180eb1b..f0d93425b6dab75407dfd908a530b08b44725b47 100644 (file)
 #include "dolphindetailsview.h"
 
 #include "dolphincontroller.h"
+#include "dolphinsettings.h"
 #include "dolphinsortfilterproxymodel.h"
 #include "viewproperties.h"
 
+#include "dolphin_detailsmodesettings.h"
+
 #include <assert.h>
 #include <kdirmodel.h>
 #include <QHeaderView>
@@ -53,6 +56,15 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
 
     connect(this, SIGNAL(clicked(const QModelIndex&)),
             controller, SLOT(triggerItem(const QModelIndex&)));
+
+   // apply the details mode settings to the widget
+    const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+    assert(settings != 0);
+
+    m_viewOptions = QTreeView::viewOptions();
+    m_viewOptions.font = QFont(settings->fontFamily(), settings->fontSize());
+    const int iconSize = settings->iconSize();
+    m_viewOptions.decorationSize = QSize(iconSize, iconSize);
 }
 
 DolphinDetailsView::~DolphinDetailsView()
@@ -75,17 +87,7 @@ bool DolphinDetailsView::event(QEvent* event)
 }
 QStyleOptionViewItem DolphinDetailsView::viewOptions() const
 {
-    return QTreeView::viewOptions();
-
-    // TODO: the view options should been read from the settings;
-    // the following code is just for testing...
-    //QStyleOptionViewItem options = QTreeView::viewOptions();
-    //options.decorationAlignment = Qt::AlignRight;
-    //options.decorationPosition = QStyleOptionViewItem::Right;
-    //options.decorationSize = QSize(100, 100);
-    //options.showDecorationSelected = true;
-    //options.state = QStyle::State_MouseOver;
-    //return options;
+    return m_viewOptions;
 }
 
 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
index e66adf5738bc34a7283eec3e6bfed2e4b9b02927..a1b4e39c48d693700c91d3005d064f8220ccfc6a 100644 (file)
@@ -22,6 +22,7 @@
 #define DOLPHINDETAILSVIEW_H
 
 #include <dolphinview.h>
+#include <QStyleOptionViewItem>
 #include <QTreeView>
 
 class DolphinController;
@@ -72,6 +73,7 @@ private slots:
 
 private:
     DolphinController* m_controller;
+    QStyleOptionViewItem m_viewOptions;
 };
 
 #endif
index 0f619ff301836192131a205543e91b904bb35065..71bf7c76fffd6637051eca11158be3a3b8bfd1c7 100644 (file)
@@ -20,6 +20,9 @@
 #include "dolphiniconsview.h"
 
 #include "dolphincontroller.h"
+#include "dolphinsettings.h"
+
+#include "dolphin_iconsmodesettings.h"
 
 #include <assert.h>
 #include <kdirmodel.h>
@@ -32,15 +35,29 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     m_controller(controller)
 {
     assert(controller != 0);
-
     setResizeMode(QListView::Adjust);
 
-    // TODO: read out settings
-    setViewMode(QListView::IconMode);
-    setGridSize(QSize(128, 96));
-
     connect(this, SIGNAL(clicked(const QModelIndex&)),
             controller, SLOT(triggerItem(const QModelIndex&)));
+
+    // apply the icons mode settings to the widget
+    const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+    assert(settings != 0);
+
+    if (settings->arrangement() == QListView::TopToBottom) {
+        setViewMode(QListView::IconMode);
+    }
+    else {
+        setViewMode(QListView::ListMode);
+    }
+
+    setGridSize(QSize(settings->gridWidth(), settings->gridHeight()));
+    setSpacing(settings->gridSpacing());
+
+    m_viewOptions = QListView::viewOptions();
+    m_viewOptions.font = QFont(settings->fontFamily(), settings->fontSize());
+    const int iconSize = settings->iconSize();
+    m_viewOptions.decorationSize = QSize(iconSize, iconSize);
 }
 
 DolphinIconsView::~DolphinIconsView()
@@ -49,17 +66,7 @@ DolphinIconsView::~DolphinIconsView()
 
 QStyleOptionViewItem DolphinIconsView::viewOptions() const
 {
-    return QListView::viewOptions();
-
-    // TODO: the view options should been read from the settings;
-    // the following code is just for testing...
-    //QStyleOptionViewItem options = QListView::viewOptions();
-    //options.decorationAlignment = Qt::AlignRight;
-    //options.decorationPosition = QStyleOptionViewItem::Right;
-    //options.decorationSize = QSize(100, 100);
-    //options.showDecorationSelected = true;
-    //options.state = QStyle::State_MouseOver;
-    //return options;
+    return m_viewOptions;
 }
 
 void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
index 68efbbd9119c6adff42d542adf30e62a393be514..91faf344a412894728bc43acac0f25f128e2aaa2 100644 (file)
@@ -21,6 +21,7 @@
 #define DOLPHINICONSVIEW_H
 
 #include <QListView>
+#include <QStyleOptionViewItem>
 
 class DolphinController;
 class DolphinView;
@@ -48,6 +49,7 @@ protected:
 
 private:
     DolphinController* m_controller;
+    QStyleOptionViewItem m_viewOptions;
 };
 
 #endif
index 3433e8532187117eda68819d700ee46bb583df55..f4c8de577a0d5ee7803ecfc749f48335c42e7e6d 100644 (file)
 #include <klocale.h>
 #include <kvbox.h>
 
+#include <QListView>
+
 #define GRID_SPACING_BASE 8
-#define GRID_SPACING_INC 12
+#define GRID_SPACING_INC 24
 
 IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
                                              QWidget* parent) :
@@ -148,7 +150,7 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
     gridGroup->setSizePolicy(sizePolicy);
     gridGroup->setMargin(margin);
 
-    const bool leftToRightArrangement = (settings->arrangement() == "LeftToRight");
+    const bool leftToRightArrangement = (settings->arrangement() == QListView::LeftToRight);
     new QLabel(i18n("Arrangement:"), gridGroup);
     m_arrangementBox = new QComboBox(gridGroup);
     m_arrangementBox->addItem(i18n("Left to right"));
@@ -193,11 +195,26 @@ void IconsViewSettingsPage::applySettings()
 
     const int fontSize = m_fontSizeBox->value();
 
-    QString arrangement = (m_arrangementBox->currentIndex() == 0) ?
-                          "LeftToRight" :
-                          "TopToBottom";
+    const int arrangement = (m_arrangementBox->currentIndex() == 0) ?
+                            QListView::LeftToRight :
+                            QListView::TopToBottom;
+
     settings->setArrangement(arrangement);
-    //DolphinSettings::instance().calculateGridSize(m_textWidthBox->currentIndex());
+
+    // TODO: this is just a very rough testing code to calculate the grid
+    // width and height
+    int gridWidth = defaultSize;
+    int gridHeight = defaultSize;
+    if (arrangement == QListView::TopToBottom) {
+        gridWidth += 96;
+        gridHeight += 64;
+    }
+    else {
+        gridWidth += 256;
+    }
+
+    settings->setGridWidth(gridWidth);
+    settings->setGridHeight(gridHeight);
 
     settings->setFontFamily(m_fontFamilyBox->currentFont().family());
     settings->setFontSize(fontSize);