]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Cleanup of iconview-settings dialog (no obsolete Q3 classes, ...) and fix broken...
authorPeter Penz <peter.penz19@gmail.com>
Wed, 14 Mar 2007 20:56:16 +0000 (20:56 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 14 Mar 2007 20:56:16 +0000 (20:56 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=642610

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

index b146d4eff5b3036a3f58ef175734ddee6523f94d..4915ef58b78aab48496fc262a05f280c93605ffe 100644 (file)
@@ -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
index fff636c8972f7599b2b8b73338713cd21291b52b..0b9b1e6fa3c768d6e203ff39fb48a76110df7f7b 100644 (file)
@@ -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);
     }
 }
index 1fecc20657ed92e6e2e18db29a9f45cdabe5b5b2..5142cb6473cc0ce0abf4f4e853f753f4ed1c22ab 100644 (file)
 
 #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"
index ccf0bb7f788f9b2871a931b006082f162a5ded92..61e1bb9006bcbde97ff730a9c6dc9cfe01ea484a 100644 (file)
 
 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;