From: Peter Penz Date: Tue, 27 Feb 2007 20:46:21 +0000 (+0000) Subject: The icons view and details view don't use hardcoded (test-) values anymore, instead... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/f8dd060cadecd9f4c36b79d53dbae706dadf99f6 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 --- 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 @@ kiconloader.h kglobalsettings.h + QListView - + - LeftToRight + QListView::TopToBottom @@ -19,11 +20,11 @@ - K3Icon::SizeMedium + 96 - 0 + 128 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 #include #include @@ -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 +#include #include 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 #include @@ -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 +#include 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 #include +#include + #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);