┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-02-27 20:46:21 +0000
committerPeter Penz <[email protected]>2007-02-27 20:46:21 +0000
commitf8dd060cadecd9f4c36b79d53dbae706dadf99f6 (patch)
treeecc4dbc1066658782ead831fae94b6b8ccde1c36
parent6c4e3aee2a65969d25813d9809bffca23fbe18d3 (diff)
The icons view and details view don't use hardcoded (test-) values anymore, instead the settings for fonts, grid size, ... are read out. The settings dialogs itself will be reworked later if it is clear what should be configurable in which manner. At least the current settings dialog allows to play with the new capabilities we got by KFileItemDelegate, just lets see what we can improve later on...
svn path=/trunk/KDE/kdebase/apps/; revision=637792
-rw-r--r--src/dolphin_iconsmodesettings.kcfg9
-rw-r--r--src/dolphindetailsview.cpp24
-rw-r--r--src/dolphindetailsview.h2
-rw-r--r--src/dolphiniconsview.cpp39
-rw-r--r--src/dolphiniconsview.h2
-rw-r--r--src/iconsviewsettingspage.cpp29
6 files changed, 68 insertions, 37 deletions
diff --git a/src/dolphin_iconsmodesettings.kcfg b/src/dolphin_iconsmodesettings.kcfg
index 23ee5ec93..b620dfe5d 100644
--- a/src/dolphin_iconsmodesettings.kcfg
+++ b/src/dolphin_iconsmodesettings.kcfg
@@ -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>
@@ -19,11 +20,11 @@
</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>
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index 0b350f8b2..f0d93425b 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -21,9 +21,12 @@
#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)
diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h
index e66adf573..a1b4e39c4 100644
--- a/src/dolphindetailsview.h
+++ b/src/dolphindetailsview.h
@@ -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
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index 0f619ff30..71bf7c76f 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -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)
diff --git a/src/dolphiniconsview.h b/src/dolphiniconsview.h
index 68efbbd91..91faf344a 100644
--- a/src/dolphiniconsview.h
+++ b/src/dolphiniconsview.h
@@ -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
diff --git a/src/iconsviewsettingspage.cpp b/src/iconsviewsettingspage.cpp
index 3433e8532..f4c8de577 100644
--- a/src/iconsviewsettingspage.cpp
+++ b/src/iconsviewsettingspage.cpp
@@ -38,8 +38,10 @@
#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);