mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
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
This commit is contained in:
parent
6c4e3aee2a
commit
f8dd060cad
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user