┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-03-14 20:56:16 +0000
committerPeter Penz <[email protected]>2007-03-14 20:56:16 +0000
commit4dcb9b7a487ff1280fa4fd7a0d6566331ba31637 (patch)
tree1b9afa08f19acc3171c24fa711a00e47a5206f3d /src
parentffcd3ed51435668b203ce58d34d2d625e9a7889d (diff)
Cleanup of iconview-settings dialog (no obsolete Q3 classes, ...) and fix broken zooming in icons view.
svn path=/trunk/KDE/kdebase/apps/; revision=642610
Diffstat (limited to 'src')
-rw-r--r--src/dolphin_iconsmodesettings.kcfg5
-rw-r--r--src/dolphiniconsview.cpp36
-rw-r--r--src/iconsviewsettingspage.cpp93
-rw-r--r--src/iconsviewsettingspage.h17
4 files changed, 88 insertions, 63 deletions
diff --git a/src/dolphin_iconsmodesettings.kcfg b/src/dolphin_iconsmodesettings.kcfg
index b146d4eff..4915ef58b 100644
--- a/src/dolphin_iconsmodesettings.kcfg
+++ b/src/dolphin_iconsmodesettings.kcfg
@@ -28,7 +28,7 @@
</entry>
<entry name="GridHeight" type="Int">
<label>Grid height</label>
- <default code="true">96</default>
+ <default code="true">K3Icon::SizeMedium + (KGlobalSettings::generalFont().pointSize() * 6)</default>
</entry>
<entry name="GridWidth" type="Int">
<label>Grid width</label>
@@ -36,6 +36,7 @@
</entry>
<entry name="GridSpacing" type="Int">
<label>Grid spacing</label>
+ <default>8</default>
</entry>
<entry name="IconSize" type="Int">
<label>Icon size</label>
@@ -51,7 +52,7 @@
</entry>
<entry name="PreviewSize" type="Int">
<label>Preview size</label>
- <default code="true">K3Icon::SizeLarge</default>
+ <default code="true">K3Icon::SizeHuge</default>
</entry>
</group>
</kcfg> \ No newline at end of file
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index fff636c89..0b9b1e6fa 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -128,12 +128,11 @@ void DolphinIconsView::updateGridSize(bool showPreview)
const int previewSize = settings->previewSize();
const int diff = previewSize - size;
Q_ASSERT(diff >= 0);
- gridWidth += diff;
+ gridWidth += diff;
gridHeight += diff;
size = previewSize;
- }
-
+ }
m_viewOptions.decorationSize = QSize(size, size);
setGridSize(QSize(gridWidth, gridHeight));
@@ -147,20 +146,28 @@ void DolphinIconsView::zoomIn()
if (isZoomInPossible()) {
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+ const int oldIconSize = settings->iconSize();
+ int newIconSize = oldIconSize;
+
const bool showPreview = m_controller->showPreview();
if (showPreview) {
const int previewSize = increasedIconSize(settings->previewSize());
settings->setPreviewSize(previewSize);
}
else {
- const int iconSize = increasedIconSize(settings->iconSize());
- settings->setIconSize(iconSize);
- if (settings->previewSize() < iconSize) {
+ newIconSize = increasedIconSize(oldIconSize);
+ settings->setIconSize(newIconSize);
+ if (settings->previewSize() < newIconSize) {
// assure that the preview size is always >= the icon size
- settings->setPreviewSize(iconSize);
+ settings->setPreviewSize(newIconSize);
}
}
+ // increase also the grid size
+ const int diff = newIconSize - oldIconSize;
+ settings->setGridWidth(settings->gridWidth() + diff);
+ settings->setGridHeight(settings->gridHeight() + diff);
+
updateGridSize(showPreview);
}
}
@@ -170,20 +177,29 @@ void DolphinIconsView::zoomOut()
if (isZoomOutPossible()) {
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+ const int oldIconSize = settings->iconSize();
+ int newIconSize = oldIconSize;
+
const bool showPreview = m_controller->showPreview();
if (showPreview) {
const int previewSize = decreasedIconSize(settings->previewSize());
settings->setPreviewSize(previewSize);
if (settings->iconSize() > previewSize) {
// assure that the icon size is always <= the preview size
- settings->setIconSize(previewSize);
+ newIconSize = previewSize;
+ settings->setIconSize(newIconSize);
}
}
else {
- const int iconSize = decreasedIconSize(settings->iconSize());
- settings->setIconSize(iconSize);
+ newIconSize = decreasedIconSize(settings->iconSize());
+ settings->setIconSize(newIconSize);
}
+ // decrease also the grid size
+ const int diff = oldIconSize - newIconSize;
+ settings->setGridWidth(settings->gridWidth() - diff);
+ settings->setGridHeight(settings->gridHeight() - diff);
+
updateGridSize(showPreview);
}
}
diff --git a/src/iconsviewsettingspage.cpp b/src/iconsviewsettingspage.cpp
index 1fecc2065..5142cb647 100644
--- a/src/iconsviewsettingspage.cpp
+++ b/src/iconsviewsettingspage.cpp
@@ -21,29 +21,22 @@
#include "dolphinsettings.h"
#include "iconsizedialog.h"
-#include "pixmapviewer.h"
#include "dolphin_iconsmodesettings.h"
-#include <qlabel.h>
-#include <qslider.h>
-#include <q3buttongroup.h>
-#include <qradiobutton.h>
-#include <qspinbox.h>
-#include <qfontcombobox.h>
-
+#include <kdialog.h>
#include <kfontrequester.h>
#include <kiconloader.h>
-#include <kdialog.h>
#include <kglobalsettings.h>
#include <klocale.h>
-#include <kvbox.h>
-#include <QPushButton>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
#include <QListView>
-
-#define GRID_SPACING_BASE 8
-#define GRID_SPACING_INC 24
+#include <QPushButton>
+#include <QSpinBox>
+#include <QGridLayout>
IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
QWidget* parent) :
@@ -78,11 +71,12 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
connect(m_iconSizeButton, SIGNAL(clicked()),
this, SLOT(openIconSizeDialog()));
- Q3GroupBox* textGroup = new Q3GroupBox(2, Qt::Horizontal, i18n("Text"), this);
+ // create 'Text' group for selecting the font, the number of lines
+ // and the text width
+ QGroupBox* textGroup = new QGroupBox(i18n("Text"), this);
textGroup->setSizePolicy(sizePolicy);
- textGroup->setMargin(margin);
- new QLabel(i18n("Font:"), textGroup);
+ QLabel* fontLabel = new QLabel(i18n("Font:"), textGroup);
m_fontRequester = new KFontRequester(textGroup);
QFont font(settings->fontFamily(),
settings->fontSize());
@@ -90,40 +84,63 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
font.setBold(settings->boldFont());
m_fontRequester->setFont(font);
- new QLabel(i18n("Number of lines:"), textGroup);
+ QLabel* textlinesCountLabel = new QLabel(i18n("Number of lines:"), textGroup);
m_textlinesCountBox = new QSpinBox(1, 5, 1, textGroup);
m_textlinesCountBox->setValue(settings->numberOfTextlines());
- new QLabel(i18n("Text width:"), textGroup);
+ QLabel* textWidthLabel = new QLabel(i18n("Text width:"), textGroup);
m_textWidthBox = new QComboBox(textGroup);
m_textWidthBox->addItem(i18n("Small"));
m_textWidthBox->addItem(i18n("Medium"));
m_textWidthBox->addItem(i18n("Large"));
- Q3GroupBox* gridGroup = new Q3GroupBox(2, Qt::Horizontal, i18n("Grid"), this);
+ const bool leftToRightArrangement = (settings->arrangement() == QListView::LeftToRight);
+ int textWidthIndex = 0;
+ const int remainingWidth = settings->gridWidth() - settings->iconSize();
+ if (leftToRightArrangement) {
+ textWidthIndex = (remainingWidth - LeftToRightBase) / LeftToRightInc;
+ }
+ else {
+ textWidthIndex = (remainingWidth - TopToBottomBase) / TopToBottomInc;
+ }
+
+ m_textWidthBox->setCurrentIndex(textWidthIndex);
+
+ QGridLayout* textGroupLayout = new QGridLayout(textGroup);
+ textGroupLayout->addWidget(fontLabel, 0, 0);
+ textGroupLayout->addWidget(m_fontRequester, 0, 1);
+ textGroupLayout->addWidget(textlinesCountLabel, 1, 0);
+ textGroupLayout->addWidget(m_textlinesCountBox, 1, 1);
+ textGroupLayout->addWidget(textWidthLabel, 2, 0);
+ textGroupLayout->addWidget(m_textWidthBox, 2, 1);
+
+ // create the 'Grid' group for selecting the arrangement and the grid spacing
+ QGroupBox* gridGroup = new QGroupBox(i18n("Grid"), this);
gridGroup->setSizePolicy(sizePolicy);
- gridGroup->setMargin(margin);
- const bool leftToRightArrangement = (settings->arrangement() == QListView::LeftToRight);
- new QLabel(i18n("Arrangement:"), gridGroup);
+ QLabel* arrangementLabel = new QLabel(i18n("Arrangement:"), gridGroup);
m_arrangementBox = new QComboBox(gridGroup);
m_arrangementBox->addItem(i18n("Left to right"));
m_arrangementBox->addItem(i18n("Top to bottom"));
m_arrangementBox->setCurrentIndex(leftToRightArrangement ? 0 : 1);
- new QLabel(i18n("Grid spacing:"), gridGroup);
+ QLabel* gridSpacingLabel = new QLabel(i18n("Grid spacing:"), gridGroup);
m_gridSpacingBox = new QComboBox(gridGroup);
m_gridSpacingBox->addItem(i18n("Small"));
m_gridSpacingBox->addItem(i18n("Medium"));
m_gridSpacingBox->addItem(i18n("Large"));
- m_gridSpacingBox->setCurrentIndex((settings->gridSpacing() - GRID_SPACING_BASE) / GRID_SPACING_INC);
+ m_gridSpacingBox->setCurrentIndex((settings->gridSpacing() - GridSpacingBase) / GridSpacingInc);
+
+ QGridLayout* gridGroupLayout = new QGridLayout(gridGroup);
+ gridGroupLayout->addWidget(arrangementLabel, 0, 0);
+ gridGroupLayout->addWidget(m_arrangementBox, 0, 1);
+ gridGroupLayout->addWidget(gridSpacingLabel, 1, 0);
+ gridGroupLayout->addWidget(m_gridSpacingBox, 1, 1);
// Add a dummy widget with no restriction regarding
// a vertical resizing. This assures that the dialog layout
// is not stretched vertically.
new QWidget(this);
-
- adjustTextWidthSelection();
}
IconsViewSettingsPage::~IconsViewSettingsPage()
@@ -144,21 +161,18 @@ void IconsViewSettingsPage::applySettings()
const int arrangement = (m_arrangementBox->currentIndex() == 0) ?
QListView::LeftToRight :
QListView::TopToBottom;
-
settings->setArrangement(arrangement);
- // TODO: this is just a very rough testing code to calculate the grid
- // width and height
const int defaultSize = settings->iconSize();
int gridWidth = defaultSize;
int gridHeight = defaultSize;
const int textSizeIndex = m_textWidthBox->currentIndex();
if (arrangement == QListView::TopToBottom) {
- gridWidth += 96 + textSizeIndex * 32;
- gridHeight += 64;
+ gridWidth += TopToBottomBase + textSizeIndex * TopToBottomInc;
+ gridHeight += fontSize * 6;
}
else {
- gridWidth += 128 + textSizeIndex * 64;
+ gridWidth += LeftToRightBase + textSizeIndex * LeftToRightInc;
}
settings->setGridWidth(gridWidth);
@@ -171,8 +185,8 @@ void IconsViewSettingsPage::applySettings()
settings->setNumberOfTextlines(m_textlinesCountBox->value());
- settings->setGridSpacing(GRID_SPACING_BASE +
- m_gridSpacingBox->currentIndex() * GRID_SPACING_INC);
+ settings->setGridSpacing(GridSpacingBase +
+ m_gridSpacingBox->currentIndex() * GridSpacingInc);
}
void IconsViewSettingsPage::openIconSizeDialog()
@@ -184,13 +198,4 @@ void IconsViewSettingsPage::openIconSizeDialog()
}
}
-
-
-void IconsViewSettingsPage::adjustTextWidthSelection()
-{
- IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
- Q_ASSERT(settings != 0);
- //m_textWidthBox->setCurrentIndex(DolphinSettings::instance().textWidthHint());
-}
-
#include "iconsviewsettingspage.moc"
diff --git a/src/iconsviewsettingspage.h b/src/iconsviewsettingspage.h
index ccf0bb7f7..61e1bb900 100644
--- a/src/iconsviewsettingspage.h
+++ b/src/iconsviewsettingspage.h
@@ -25,10 +25,10 @@
class DolphinMainWindow;
class KFontRequester;
-class QSlider;
class QComboBox;
class QCheckBox;
class QPushButton;
+class QSlider;
class QSpinBox;
/**
@@ -65,13 +65,16 @@ private slots:
void openIconSizeDialog();
private:
- /**
- * Adjusts the selection of the text width combo box dependant
- * from the grid width and grid height settings.
- */
- void adjustTextWidthSelection();
+ enum
+ {
+ GridSpacingBase = 8,
+ GridSpacingInc = 24,
+ LeftToRightBase = 128,
+ LeftToRightInc = 64,
+ TopToBottomBase = 96,
+ TopToBottomInc = 32
+ };
-private:
DolphinMainWindow* m_mainWindow;
int m_iconSize;
int m_previewSize;