From ca7aaecbdbddb27f7442e69d2770b97b4307f338 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Tue, 26 Aug 2008 22:21:50 +0000 Subject: [PATCH] Provide a common iconsize-widget for the settings dialog of the icons-, details- and column-view. The current version still requires some improvements (Labels on the left + right, preview, ...). svn path=/trunk/KDE/kdebase/apps/; revision=852961 --- src/CMakeLists.txt | 11 +- src/columnviewsettingspage.cpp | 94 ++++------ src/columnviewsettingspage.h | 6 +- src/detailsviewsettingspage.cpp | 68 +++---- src/detailsviewsettingspage.h | 6 +- src/dolphincolumnview.cpp | 3 +- src/dolphincontroller.cpp | 41 +---- src/dolphincontroller.h | 27 --- src/dolphindetailsview.cpp | 3 +- src/dolphiniconsview.cpp | 5 +- src/dolphinview.cpp | 21 +-- src/dolphinview.h | 11 +- src/dolphinviewactionhandler.cpp | 5 +- src/iconsizedialog.cpp | 184 ------------------- src/iconsizegroupbox.cpp | 88 +++++++++ src/{iconsizedialog.h => iconsizegroupbox.h} | 75 +++----- src/iconsviewsettingspage.cpp | 50 ++--- src/iconsviewsettingspage.h | 10 +- src/zoomlevelinfo.cpp | 66 +++++++ src/zoomlevelinfo.h | 51 +++++ 20 files changed, 361 insertions(+), 464 deletions(-) delete mode 100644 src/iconsizedialog.cpp create mode 100644 src/iconsizegroupbox.cpp rename src/{iconsizedialog.h => iconsizegroupbox.h} (50%) create mode 100644 src/zoomlevelinfo.cpp create mode 100644 src/zoomlevelinfo.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 96941803bb..9b188a183a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,8 @@ endif (Nepomuk_FOUND) ########### next target ############### set(dolphinprivate_LIB_SRCS + additionalinfodialog.cpp + applyviewpropsjob.cpp dolphincontroller.cpp dolphindetailsview.cpp dolphiniconsview.cpp @@ -44,8 +46,7 @@ set(dolphinprivate_LIB_SRCS viewproperties.cpp viewpropertiesdialog.cpp viewpropsprogressinfo.cpp - additionalinfodialog.cpp - applyviewpropsjob.cpp + zoomlevelinfo.cpp ) kde4_add_kcfg_files(dolphinprivate_LIB_SRCS @@ -107,7 +108,7 @@ set(dolphin_SRCS filterbar.cpp generalsettingspage.cpp generalviewsettingspage.cpp - iconsizedialog.cpp + iconsizegroupbox.cpp iconsviewsettingspage.cpp infosidebarpage.cpp ktreeview.cpp @@ -125,6 +126,7 @@ set(dolphin_SRCS sidebartreeview.cpp viewsettingspage.cpp viewsettingspagebase.cpp + zoomlevelinfo.cpp ) kde4_add_kcfg_files(dolphin_SRCS @@ -175,11 +177,12 @@ set(kcm_dolphin_PART_SRCS dolphinfontrequester.cpp # dolphinsettings.cpp generalviewsettingspage.cpp - iconsizedialog.cpp + iconsizegroupbox.cpp iconsviewsettingspage.cpp pixmapviewer.cpp viewsettingspagebase.cpp # viewproperties.cpp + zoomlevelinfo.cpp ) kde4_add_kcfg_files(kcm_dolphin_PART_SRCS diff --git a/src/columnviewsettingspage.cpp b/src/columnviewsettingspage.cpp index aa84fc3985..e59492a927 100644 --- a/src/columnviewsettingspage.cpp +++ b/src/columnviewsettingspage.cpp @@ -22,6 +22,8 @@ #include "dolphinfontrequester.h" #include "dolphinsettings.h" #include "dolphin_columnmodesettings.h" +#include "iconsizegroupbox.h" +#include "zoomlevelinfo.h" #include #include @@ -37,9 +39,7 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(QWidget* parent) : ViewSettingsPageBase(parent), - m_smallIconSize(0), - m_mediumIconSize(0), - m_largeIconSize(0), + m_iconSizeGroupBox(0), m_fontRequester(0), m_columnWidthSlider(0) { @@ -49,6 +49,32 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(QWidget* parent) : setSpacing(spacing); setMargin(margin); + + // Create "Icon" properties + m_iconSizeGroupBox = new IconSizeGroupBox(this); + m_iconSizeGroupBox->setSizePolicy(sizePolicy); + + const int min = ZoomLevelInfo::minimumLevel(); + const int max = ZoomLevelInfo::maximumLevel(); + m_iconSizeGroupBox->setDefaultSizeRange(min, max); + m_iconSizeGroupBox->setPreviewSizeRange(min, max); + + connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)), + this, SIGNAL(changed())); + connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)), + this, SIGNAL(changed())); + + // create "Text" properties + QGroupBox* textBox = new QGroupBox(i18nc("@title:group", "Text"), this); + textBox->setSizePolicy(sizePolicy); + + QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textBox); + m_fontRequester = new DolphinFontRequester(textBox); + connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed())); + + QHBoxLayout* textLayout = new QHBoxLayout(textBox); + textLayout->addWidget(fontLabel); + textLayout->addWidget(m_fontRequester); // create "Column Width" properties QGroupBox* columnWidthBox = new QGroupBox(i18nc("@title:group", "Column Width"), this); @@ -68,39 +94,6 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(QWidget* parent) : columnWidthLayout->addWidget(m_columnWidthSlider); columnWidthLayout->addWidget(largeLabel); - // Create 'Icon' properties - QGroupBox* iconSizeBox = new QGroupBox(i18nc("@title:group", "Icon Size"), this); - iconSizeBox->setSizePolicy(sizePolicy); - - m_smallIconSize = new QRadioButton(i18nc("@option:radio Icon Size", "Small"), this); - m_mediumIconSize = new QRadioButton(i18nc("@option:radio Icon Size", "Medium"), this); - m_largeIconSize = new QRadioButton(i18nc("@option:radio Icon Size", "Large"), this); - connect(m_smallIconSize, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - connect(m_mediumIconSize, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - connect(m_largeIconSize, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - QButtonGroup* iconSizeGroup = new QButtonGroup(this); - iconSizeGroup->addButton(m_smallIconSize); - iconSizeGroup->addButton(m_mediumIconSize); - iconSizeGroup->addButton(m_largeIconSize); - - QHBoxLayout* iconSizeLayout = new QHBoxLayout(iconSizeBox); - iconSizeLayout->addWidget(m_smallIconSize); - iconSizeLayout->addWidget(m_mediumIconSize); - iconSizeLayout->addWidget(m_largeIconSize); - - // create "Text" properties - QGroupBox* textBox = new QGroupBox(i18nc("@title:group", "Text"), this); - textBox->setSizePolicy(sizePolicy); - - QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textBox); - m_fontRequester = new DolphinFontRequester(textBox); - connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed())); - - QHBoxLayout* textLayout = new QHBoxLayout(textBox); - textLayout->addWidget(fontLabel); - textLayout->addWidget(m_fontRequester); - // Add a dummy widget with no restriction regarding // a vertical resizing. This assures that the dialog layout // is not stretched vertically. @@ -117,13 +110,10 @@ void ColumnViewSettingsPage::applySettings() { ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings(); - int iconSize = KIconLoader::SizeSmall; - if (m_mediumIconSize->isChecked()) { - iconSize = KIconLoader::SizeMedium; - } else if (m_largeIconSize->isChecked()) { - iconSize = KIconLoader::SizeLarge; - } + const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue()); + const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue()); settings->setIconSize(iconSize); + settings->setPreviewSize(previewSize); const QFont font = m_fontRequester->font(); settings->setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont); @@ -147,19 +137,13 @@ void ColumnViewSettingsPage::loadSettings() { ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings(); - switch (settings->iconSize()) { - case KIconLoader::SizeLarge: - m_largeIconSize->setChecked(true); - break; - - case KIconLoader::SizeMedium: - m_mediumIconSize->setChecked(true); - break; - - case KIconLoader::SizeSmall: - default: - m_smallIconSize->setChecked(true); - } + const QSize iconSize(settings->iconSize(), settings->iconSize()); + const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize); + m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue); + + const QSize previewSize(settings->previewSize(), settings->previewSize()); + const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize); + m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue); if (settings->useSystemFont()) { m_fontRequester->setMode(DolphinFontRequester::SystemFont); diff --git a/src/columnviewsettingspage.h b/src/columnviewsettingspage.h index 8ab90efc36..2cc96b2031 100644 --- a/src/columnviewsettingspage.h +++ b/src/columnviewsettingspage.h @@ -24,8 +24,8 @@ class DolphinMainWindow; class DolphinFontRequester; +class IconSizeGroupBox; class QSlider; -class QRadioButton; /** * @brief Represents the page from the Dolphin Settings which allows @@ -53,9 +53,7 @@ private: void loadSettings(); private: - QRadioButton* m_smallIconSize; - QRadioButton* m_mediumIconSize; - QRadioButton* m_largeIconSize; + IconSizeGroupBox* m_iconSizeGroupBox; DolphinFontRequester* m_fontRequester; QSlider* m_columnWidthSlider; }; diff --git a/src/detailsviewsettingspage.cpp b/src/detailsviewsettingspage.cpp index a51e121e9e..74fc3567d2 100644 --- a/src/detailsviewsettingspage.cpp +++ b/src/detailsviewsettingspage.cpp @@ -19,8 +19,10 @@ #include "detailsviewsettingspage.h" +#include "iconsizegroupbox.h" #include "dolphinsettings.h" #include "dolphin_detailsmodesettings.h" +#include "zoomlevelinfo.h" #include #include @@ -37,9 +39,7 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget* parent) : ViewSettingsPageBase(parent), - m_smallIconSize(0), - m_mediumIconSize(0), - m_largeIconSize(0), + m_iconSizeGroupBox(0), m_fontRequester(0), m_expandableFolders(0) { @@ -51,25 +51,18 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget* parent) : setMargin(margin); // Create "Icon" properties - QGroupBox* iconSizeBox = new QGroupBox(i18nc("@title:group", "Icon Size"), this); - iconSizeBox->setSizePolicy(sizePolicy); - - m_smallIconSize = new QRadioButton(i18nc("@option:radio Icon Size", "Small"), this); - m_mediumIconSize = new QRadioButton(i18nc("@option:radio Icon Size", "Medium"), this); - m_largeIconSize = new QRadioButton(i18nc("@option:radio Icon Size", "Large"), this); - connect(m_smallIconSize, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - connect(m_mediumIconSize, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - connect(m_largeIconSize, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - - QButtonGroup* iconSizeGroup = new QButtonGroup(this); - iconSizeGroup->addButton(m_smallIconSize); - iconSizeGroup->addButton(m_mediumIconSize); - iconSizeGroup->addButton(m_largeIconSize); - - QHBoxLayout* iconSizeLayout = new QHBoxLayout(iconSizeBox); - iconSizeLayout->addWidget(m_smallIconSize); - iconSizeLayout->addWidget(m_mediumIconSize); - iconSizeLayout->addWidget(m_largeIconSize); + m_iconSizeGroupBox = new IconSizeGroupBox(this); + m_iconSizeGroupBox->setSizePolicy(sizePolicy); + + const int min = ZoomLevelInfo::minimumLevel(); + const int max = ZoomLevelInfo::maximumLevel(); + m_iconSizeGroupBox->setDefaultSizeRange(min, max); + m_iconSizeGroupBox->setPreviewSizeRange(min, max); + + connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)), + this, SIGNAL(changed())); + connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)), + this, SIGNAL(changed())); // create "Text" properties QGroupBox* textBox = new QGroupBox(i18nc("@title:group", "Text"), this); @@ -103,13 +96,10 @@ void DetailsViewSettingsPage::applySettings() { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - int iconSize = KIconLoader::SizeSmall; - if (m_mediumIconSize->isChecked()) { - iconSize = KIconLoader::SizeMedium; - } else if (m_largeIconSize->isChecked()) { - iconSize = KIconLoader::SizeLarge; - } + const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue()); + const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue()); settings->setIconSize(iconSize); + settings->setPreviewSize(previewSize); const QFont font = m_fontRequester->font(); settings->setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont); @@ -132,20 +122,14 @@ void DetailsViewSettingsPage::loadSettings() { DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); - switch (settings->iconSize()) { - case KIconLoader::SizeLarge: - m_largeIconSize->setChecked(true); - break; - - case KIconLoader::SizeMedium: - m_mediumIconSize->setChecked(true); - break; - - case KIconLoader::SizeSmall: - default: - m_smallIconSize->setChecked(true); - } - + const QSize iconSize(settings->iconSize(), settings->iconSize()); + const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize); + m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue); + + const QSize previewSize(settings->previewSize(), settings->previewSize()); + const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize); + m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue); + if (settings->useSystemFont()) { m_fontRequester->setMode(DolphinFontRequester::SystemFont); } else { diff --git a/src/detailsviewsettingspage.h b/src/detailsviewsettingspage.h index d292a1aef5..587d422448 100644 --- a/src/detailsviewsettingspage.h +++ b/src/detailsviewsettingspage.h @@ -23,8 +23,8 @@ #include class DolphinFontRequester; +class IconSizeGroupBox; class QCheckBox; -class QRadioButton; /** * @brief Represents the page from the Dolphin Settings which allows @@ -52,9 +52,7 @@ private: void loadSettings(); private: - QRadioButton* m_smallIconSize; - QRadioButton* m_mediumIconSize; - QRadioButton* m_largeIconSize; + IconSizeGroupBox* m_iconSizeGroupBox; DolphinFontRequester* m_fontRequester; QCheckBox* m_expandableFolders; }; diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp index 7de261dab4..40a579f5a6 100644 --- a/src/dolphincolumnview.cpp +++ b/src/dolphincolumnview.cpp @@ -22,6 +22,7 @@ #include "dolphincolumnwidget.h" #include "dolphincontroller.h" #include "dolphinsettings.h" +#include "zoomlevelinfo.h" #include "dolphin_columnmodesettings.h" @@ -368,7 +369,7 @@ void DolphinColumnView::wheelEvent(QWheelEvent* event) void DolphinColumnView::setZoomLevel(int level) { - const int size = DolphinController::iconSizeForZoomLevel(level); + const int size = ZoomLevelInfo::iconSizeForZoomLevel(level); ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings(); const bool showPreview = m_controller->dolphinView()->showPreview(); diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp index a23ecbe4a5..abbae6ec79 100644 --- a/src/dolphincontroller.cpp +++ b/src/dolphincontroller.cpp @@ -18,6 +18,7 @@ ***************************************************************************/ #include "dolphincontroller.h" +#include "zoomlevelinfo.h" #include #include @@ -57,7 +58,7 @@ void DolphinController::setItemView(QAbstractItemView* view) m_itemView = view; if (m_itemView != 0) { - m_zoomLevel = zoomLevelForIconSize(m_itemView->iconSize()); + m_zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_itemView->iconSize()); // TODO: this is a workaround until Qt-issue 176832 has been fixed connect(m_itemView, SIGNAL(pressed(const QModelIndex&)), @@ -113,48 +114,14 @@ void DolphinController::indicateActivationChange(bool active) void DolphinController::setZoomLevel(int level) { - Q_ASSERT(level >= zoomLevelMinimum()); - Q_ASSERT(level <= zoomLevelMaximum()); + Q_ASSERT(level >= ZoomLevelInfo::minimumLevel()); + Q_ASSERT(level <= ZoomLevelInfo::maximumLevel()); if (level != m_zoomLevel) { m_zoomLevel = level; emit zoomLevelChanged(m_zoomLevel); } } -int DolphinController::iconSizeForZoomLevel(int level) -{ - int size = KIconLoader::SizeMedium; - switch (level) { - case 0: size = KIconLoader::SizeSmall; break; - case 1: size = KIconLoader::SizeSmallMedium; break; - case 2: size = KIconLoader::SizeMedium; break; - case 3: size = KIconLoader::SizeLarge; break; - case 4: size = KIconLoader::SizeHuge; break; - case 5: size = KIconLoader::SizeEnormous; break; - case 6: size = KIconLoader::SizeEnormous * 3 / 2; break; - case 7: size = KIconLoader::SizeEnormous * 2; break; - default: Q_ASSERT(false); break; - } - return size; -} - -int DolphinController::zoomLevelForIconSize(const QSize& size) -{ - int level = 0; - switch (size.height()) { - case KIconLoader::SizeSmall: level = 0; break; - case KIconLoader::SizeSmallMedium: level = 1; break; - case KIconLoader::SizeMedium: level = 2; break; - case KIconLoader::SizeLarge: level = 3; break; - case KIconLoader::SizeHuge: level = 4; break; - case KIconLoader::SizeEnormous: level = 5; break; - case KIconLoader::SizeEnormous * 3 / 2: level = 6; break; - case KIconLoader::SizeEnormous * 2: level = 7; break; - default: Q_ASSERT(false); level = 3; break; - } - return level; -} - void DolphinController::handleKeyPressEvent(QKeyEvent* event) { Q_ASSERT(m_itemView != 0); diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h index e8ca55e19a..51099ff7a1 100644 --- a/src/dolphincontroller.h +++ b/src/dolphincontroller.h @@ -185,23 +185,6 @@ public: void setZoomLevel(int level); int zoomLevel() const; - int zoomLevelMinimum() const; - int zoomLevelMaximum() const; - - /** - * Helper method for the view implementation to get - * the icon size for the zoom level \a level - * (see DolphinController::zoomLevel()). - */ - static int iconSizeForZoomLevel(int level); - - /** - * Helper method for the view implementation to get - * the zoom level for the icon size \a size - * (see DolphinController::zoomLevel()). - */ - static int zoomLevelForIconSize(const QSize& size); - /** * Tells the view implementation to zoom out by emitting the signal zoomOut() * and is invoked by the abstract Dolphin view. @@ -383,14 +366,4 @@ inline int DolphinController::zoomLevel() const return m_zoomLevel; } -inline int DolphinController::zoomLevelMinimum() const -{ - return 0; -} - -inline int DolphinController::zoomLevelMaximum() const -{ - return 7; -} - #endif diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 86ad71ad72..61cb0df76f 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -27,6 +27,7 @@ #include "draganddrophelper.h" #include "selectionmanager.h" #include "viewproperties.h" +#include "zoomlevelinfo.h" #include "dolphin_detailsmodesettings.h" #include "dolphin_generalsettings.h" @@ -496,7 +497,7 @@ QRect DolphinDetailsView::elasticBandRect() const void DolphinDetailsView::setZoomLevel(int level) { - const int size = DolphinController::iconSizeForZoomLevel(level); + const int size = ZoomLevelInfo::iconSizeForZoomLevel(level); DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings(); const bool showPreview = m_controller->dolphinView()->showPreview(); diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index db916747e9..9947a27551 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -26,6 +26,7 @@ #include "dolphin_generalsettings.h" #include "draganddrophelper.h" #include "selectionmanager.h" +#include "zoomlevelinfo.h" #include #include @@ -339,10 +340,10 @@ void DolphinIconsView::setZoomLevel(int level) const bool showPreview = m_controller->dolphinView()->showPreview(); if (showPreview) { - const int previewSize = DolphinController::iconSizeForZoomLevel(level); + const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(level); settings->setPreviewSize(previewSize); } else { - newIconSize = DolphinController::iconSizeForZoomLevel(level); + newIconSize = ZoomLevelInfo::iconSizeForZoomLevel(level); settings->setIconSize(newIconSize); } diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 6f5aa8d6f6..45fdfebaf8 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -62,6 +62,7 @@ #include "renamedialog.h" #include "tooltipmanager.h" #include "viewproperties.h" +#include "zoomlevelinfo.h" DolphinView::DolphinView(QWidget* parent, const KUrl& url, @@ -364,10 +365,10 @@ QPoint DolphinView::contentsPosition() const void DolphinView::setZoomLevel(int level) { - if (level < zoomLevelMinimum()) { - level = zoomLevelMinimum(); - } else if (level > zoomLevelMaximum()) { - level = zoomLevelMaximum(); + if (level < ZoomLevelInfo::minimumLevel()) { + level = ZoomLevelInfo::minimumLevel(); + } else if (level > ZoomLevelInfo::maximumLevel()) { + level = ZoomLevelInfo::maximumLevel(); } if (level != zoomLevel()) { @@ -382,16 +383,6 @@ int DolphinView::zoomLevel() const return m_controller->zoomLevel(); } -int DolphinView::zoomLevelMinimum() const -{ - return m_controller->zoomLevelMinimum(); -} - -int DolphinView::zoomLevelMaximum() const -{ - return m_controller->zoomLevelMaximum(); -} - void DolphinView::setSorting(Sorting sorting) { if (sorting != this->sorting()) { @@ -1276,7 +1267,7 @@ void DolphinView::pasteToUrl(const KUrl& url) void DolphinView::updateZoomLevel(int oldZoomLevel) { - const int newZoomLevel = DolphinController::zoomLevelForIconSize(itemView()->iconSize()); + const int newZoomLevel = ZoomLevelInfo::zoomLevelForIconSize(itemView()->iconSize()); if (oldZoomLevel != newZoomLevel) { m_controller->setZoomLevel(newZoomLevel); emit zoomLevelChanged(newZoomLevel); diff --git a/src/dolphinview.h b/src/dolphinview.h index 6131415356..acc9ba3635 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -236,24 +236,21 @@ public: /** * Sets the zoom level to \a level. It is assured that the used - * level is adjusted to be inside the range DolphinView::zoomLevelMinimum() and - * DolphinView::zoomLevelMaximum(). + * level is adjusted to be inside the range ZoomLevelInfo::minimumLevel() and + * ZoomLevelInfo::maximumLevel(). */ void setZoomLevel(int level); int zoomLevel() const; - int zoomLevelMinimum() const; - int zoomLevelMaximum() const; - /** * Returns true, if zooming in is possible. If false is returned, - * the minimal zoom size is possible. + * the maximimum zooming level has been reached. */ bool isZoomInPossible() const; /** * Returns true, if zooming out is possible. If false is returned, - * the maximum zoom size is possible. + * the minimum zooming level has been reached. */ bool isZoomOutPossible() const; diff --git a/src/dolphinviewactionhandler.cpp b/src/dolphinviewactionhandler.cpp index 6d735b587c..99054387af 100644 --- a/src/dolphinviewactionhandler.cpp +++ b/src/dolphinviewactionhandler.cpp @@ -21,6 +21,7 @@ #include "viewpropertiesdialog.h" #include "dolphinview.h" +#include "zoomlevelinfo.h" #include @@ -495,12 +496,12 @@ void DolphinViewActionHandler::slotZoomLevelChanged(int level) { QAction* zoomInAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomIn)); if (zoomInAction != 0) { - zoomInAction->setEnabled(level < m_currentView->zoomLevelMaximum()); + zoomInAction->setEnabled(level < ZoomLevelInfo::maximumLevel()); } QAction* zoomOutAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomOut)); if (zoomOutAction != 0) { - zoomOutAction->setEnabled(level > m_currentView->zoomLevelMinimum()); + zoomOutAction->setEnabled(level > ZoomLevelInfo::minimumLevel()); } } diff --git a/src/iconsizedialog.cpp b/src/iconsizedialog.cpp deleted file mode 100644 index 00f1c7b2eb..0000000000 --- a/src/iconsizedialog.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "iconsizedialog.h" - -#include "dolphinsettings.h" -#include "pixmapviewer.h" - -#include "dolphin_iconsmodesettings.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -IconSizeDialog::IconSizeDialog(QWidget* parent) : - KDialog(parent), - m_iconSize(0), - m_previewSize(0), - m_iconSizeSlider(0), - m_iconSizeViewer(0), - m_previewSizeSlider(0), - m_previewSizeViewer(0) -{ - IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); - Q_ASSERT(settings != 0); - m_iconSize = settings->iconSize(); - m_previewSize = settings->previewSize(); - - const int spacing = KDialog::spacingHint(); - - setCaption(i18nc("@title:window", "Change Icon & Preview Size")); - setButtons(Ok | Cancel); - setDefaultButton(Ok); - - QWidget* main = new QWidget(); - QHBoxLayout* topLayout = new QHBoxLayout(); - - // create 'Icon Size' group including slider and preview - QGroupBox* iconSizeBox = new QGroupBox(i18nc("@title:group", "Icon Size"), main); - - const QColor iconBackgroundColor = KColorScheme(QPalette::Active, KColorScheme::View).background().color(); - - KHBox* iconSizeHBox = new KHBox(iconSizeBox); - iconSizeHBox->setSpacing(spacing); - new QLabel(i18nc("@item:inrange Icon Size", "Small"), iconSizeHBox); - m_iconSizeSlider = new QSlider(Qt::Horizontal, iconSizeHBox); - m_iconSizeSlider->setMinimum(0); - m_iconSizeSlider->setMaximum(5); - m_iconSizeSlider->setPageStep(1); - m_iconSizeSlider->setValue(sliderValue(settings->iconSize())); - m_iconSizeSlider->setTickPosition(QSlider::TicksBelow); - connect(m_iconSizeSlider, SIGNAL(valueChanged(int)), - this, SLOT(updateIconSize(int))); - new QLabel(i18nc("@item:inrange Icon Size", "Large"), iconSizeHBox); - - m_iconSizeViewer = new PixmapViewer(iconSizeBox, PixmapViewer::SizeTransition); - m_iconSizeViewer->setMinimumWidth(KIconLoader::SizeEnormous); - m_iconSizeViewer->setFixedHeight(KIconLoader::SizeEnormous); - QPalette p = m_iconSizeViewer->palette(); - p.setColor(m_iconSizeViewer->backgroundRole(), iconBackgroundColor); - m_iconSizeViewer->setPalette(p); - updateIconSize(m_iconSizeSlider->value()); - - QVBoxLayout* iconSizeLayout = new QVBoxLayout(iconSizeBox); - iconSizeLayout->addWidget(iconSizeHBox); - iconSizeLayout->addWidget(m_iconSizeViewer); - - // create 'Preview Size' group including slider and preview - QGroupBox* previewSizeBox = new QGroupBox(i18nc("@title:group", "Preview Size"), main); - - KHBox* previewSizeHBox = new KHBox(previewSizeBox); - previewSizeHBox->setSpacing(spacing); - new QLabel(i18nc("@item:inrange Preview Size", "Small"), previewSizeHBox); - m_previewSizeSlider = new QSlider(Qt::Horizontal, previewSizeHBox); - m_previewSizeSlider->setMinimum(0); - m_previewSizeSlider->setMaximum(5); - m_previewSizeSlider->setPageStep(1); - m_previewSizeSlider->setValue(sliderValue(settings->previewSize())); - m_previewSizeSlider->setTickPosition(QSlider::TicksBelow); - connect(m_previewSizeSlider, SIGNAL(valueChanged(int)), - this, SLOT(updatePreviewSize(int))); - new QLabel(i18nc("@item:inrange Preview Size", "Large"), previewSizeHBox); - - m_previewSizeViewer = new PixmapViewer(previewSizeBox, PixmapViewer::SizeTransition); - m_previewSizeViewer->setMinimumWidth(KIconLoader::SizeEnormous); - m_previewSizeViewer->setFixedHeight(KIconLoader::SizeEnormous); - p = m_previewSizeViewer->palette(); - p.setColor(m_previewSizeViewer->backgroundRole(), iconBackgroundColor); - m_previewSizeViewer->setPalette(p); - updatePreviewSize(m_previewSizeSlider->value()); - - QVBoxLayout* previewSizeLayout = new QVBoxLayout(previewSizeBox); - previewSizeLayout->addWidget(previewSizeHBox); - previewSizeLayout->addWidget(m_previewSizeViewer); - - topLayout->addWidget(iconSizeBox); - topLayout->addWidget(previewSizeBox); - main->setLayout(topLayout); - setMainWidget(main); - - const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), - "IconSizeDialog"); - restoreDialogSize(dialogConfig); -} - -IconSizeDialog::~IconSizeDialog() -{ - KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), - "IconSizeDialog"); - saveDialogSize(dialogConfig, KConfigBase::Persistent); -} - -void IconSizeDialog::slotButtonClicked(int button) -{ - if (button == Ok) { - m_iconSize = iconSize(m_iconSizeSlider->value()); - m_previewSize = iconSize(m_previewSizeSlider->value()); - } - - KDialog::slotButtonClicked(button); -} - -void IconSizeDialog::updateIconSize(int value) -{ - m_iconSizeViewer->setPixmap(KIconLoader::global()->loadIcon("folder", KIconLoader::Desktop, iconSize(value))); -} - -void IconSizeDialog::updatePreviewSize(int value) -{ - m_previewSizeViewer->setPixmap(KIconLoader::global()->loadIcon("preview", KIconLoader::Desktop, iconSize(value))); -} - -int IconSizeDialog::iconSize(int sliderValue) const -{ - int size = KIconLoader::SizeMedium; - switch (sliderValue) { - case 0: size = KIconLoader::SizeSmall; break; - case 1: size = KIconLoader::SizeSmallMedium; break; - case 2: size = KIconLoader::SizeMedium; break; - case 3: size = KIconLoader::SizeLarge; break; - case 4: size = KIconLoader::SizeHuge; break; - case 5: size = KIconLoader::SizeEnormous; break; - } - return size; -} - -int IconSizeDialog::sliderValue(int iconSize) const -{ - int value = 0; - switch (iconSize) { - case KIconLoader::SizeSmall: value = 0; break; - case KIconLoader::SizeSmallMedium: value = 1; break; - case KIconLoader::SizeMedium: value = 2; break; - case KIconLoader::SizeLarge: value = 3; break; - case KIconLoader::SizeHuge: value = 4; break; - case KIconLoader::SizeEnormous: value = 5; break; - default: break; - } - return value; -} - -#include "iconsizedialog.moc" diff --git a/src/iconsizegroupbox.cpp b/src/iconsizegroupbox.cpp new file mode 100644 index 0000000000..8f6c240865 --- /dev/null +++ b/src/iconsizegroupbox.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** + * Copyright (C) 2008 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "iconsizegroupbox.h" + +#include + +#include +#include +#include + +IconSizeGroupBox::IconSizeGroupBox(QWidget* parent) : + QGroupBox(i18nc("@title:group", "Icon Size"), parent), + m_defaultSizeSlider(0), + m_previewSizeSlider(0) +{ + QLabel* defaultLabel = new QLabel(i18nc("@label:listbox", "Default:"), this); + m_defaultSizeSlider = new QSlider(Qt::Horizontal, this); + m_defaultSizeSlider->setPageStep(1); + m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow); + connect(m_defaultSizeSlider, SIGNAL(sliderMoved(int)), + this, SIGNAL(defaultSizeChanged(int))); + + QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this); + m_previewSizeSlider = new QSlider(Qt::Horizontal, this); + m_previewSizeSlider->setPageStep(1); + m_previewSizeSlider->setTickPosition(QSlider::TicksBelow); + connect(m_previewSizeSlider, SIGNAL(sliderMoved(int)), + this, SIGNAL(defaultSizeChanged(int))); + + QGridLayout* layout = new QGridLayout(this); + layout->addWidget(defaultLabel, 0, 0); + layout->addWidget(m_defaultSizeSlider, 0, 1); + layout->addWidget(previewLabel, 1, 0); + layout->addWidget(m_previewSizeSlider, 1, 1); +} + +IconSizeGroupBox::~IconSizeGroupBox() +{ +} + +void IconSizeGroupBox::setDefaultSizeRange(int min, int max) +{ + m_defaultSizeSlider->setRange(min, max); +} + +void IconSizeGroupBox::setPreviewSizeRange(int min, int max) +{ + m_previewSizeSlider->setRange(min, max); +} + +void IconSizeGroupBox::setDefaultSizeValue(int value) +{ + m_defaultSizeSlider->setValue(value); +} + +int IconSizeGroupBox::defaultSizeValue() const +{ + return m_defaultSizeSlider->value(); +} + +void IconSizeGroupBox::setPreviewSizeValue(int value) +{ + m_previewSizeSlider->setValue(value); +} + +int IconSizeGroupBox::previewSizeValue() const +{ + return m_previewSizeSlider->value(); +} + +#include "iconsizegroupbox.moc" diff --git a/src/iconsizedialog.h b/src/iconsizegroupbox.h similarity index 50% rename from src/iconsizedialog.h rename to src/iconsizegroupbox.h index 33cd83725a..5f05862d6b 100644 --- a/src/iconsizedialog.h +++ b/src/iconsizegroupbox.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz * + * Copyright (C) 2008 by Peter Penz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -14,69 +14,46 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#ifndef ICONSIZEDIALOG_H -#define ICONSIZEDIALOG_H +#ifndef ICONSIZEGROUPBOX_H +#define ICONSIZEGROUPBOX_H -#include +#include class QSlider; -class PixmapViewer; /** - * @brief Allows to adjust the size for icons and previews. + * @short Provides a group box for adjusting the icon sizes. * - * Default usage: - * \code - * IconSizeDialog dialog(this); - * if (dialog.exec() == QDialog::Accepted) { - * const int iconSize = dialog.iconSize(); - * const int previewSize = dialog.previewSize(); - * // ... - * } - * \endcode + * It is possible to adjust the default icon size and the icon + * size when previews are used. */ -class IconSizeDialog : public KDialog +class IconSizeGroupBox : public QGroupBox { Q_OBJECT public: - explicit IconSizeDialog(QWidget* parent); - virtual ~IconSizeDialog(); - - int iconSize() const - { - return m_iconSize; - } - int previewSize() const - { - return m_previewSize; - } - -protected slots: - virtual void slotButtonClicked(int button); - -private slots: - void updateIconSize(int value); - void updatePreviewSize(int value); - + explicit IconSizeGroupBox(QWidget* parent); + virtual ~IconSizeGroupBox(); + + void setDefaultSizeRange(int min, int max); + void setPreviewSizeRange(int min, int max); + + void setDefaultSizeValue(int value); + int defaultSizeValue() const; + + void setPreviewSizeValue(int value); + int previewSizeValue() const; + +signals: + void defaultSizeChanged(int value); + void previewSizeChanged(int value); + private: - /** Returns the icon size for the given slider value. */ - int iconSize(int sliderValue) const; - - /** Returns the slider value for the given icon size. */ - int sliderValue(int iconSize) const; - -private: - int m_iconSize; - int m_previewSize; - - QSlider* m_iconSizeSlider; - PixmapViewer* m_iconSizeViewer; + QSlider* m_defaultSizeSlider; QSlider* m_previewSizeSlider; - PixmapViewer* m_previewSizeViewer; }; #endif diff --git a/src/iconsviewsettingspage.cpp b/src/iconsviewsettingspage.cpp index 0c377d91b6..91208e2c76 100644 --- a/src/iconsviewsettingspage.cpp +++ b/src/iconsviewsettingspage.cpp @@ -21,7 +21,8 @@ #include "dolphinfontrequester.h" #include "dolphinsettings.h" -#include "iconsizedialog.h" +#include "iconsizegroupbox.h" +#include "zoomlevelinfo.h" #include "dolphin_iconsmodesettings.h" @@ -42,9 +43,7 @@ IconsViewSettingsPage::IconsViewSettingsPage(QWidget* parent) : ViewSettingsPageBase(parent), - m_iconSize(0), - m_previewSize(0), - m_iconSizeButton(0), + m_iconSizeGroupBox(0), m_textWidthBox(0), m_fontRequester(0), m_textlinesCountBox(0), @@ -58,10 +57,20 @@ IconsViewSettingsPage::IconsViewSettingsPage(QWidget* parent) : setSpacing(spacing); setMargin(margin); - m_iconSizeButton = new QPushButton(i18nc("@action:button", "Change Icon && Preview Size..."), this); - connect(m_iconSizeButton, SIGNAL(clicked()), - this, SLOT(openIconSizeDialog())); - + // Create "Icon" properties + m_iconSizeGroupBox = new IconSizeGroupBox(this); + m_iconSizeGroupBox->setSizePolicy(sizePolicy); + + const int min = ZoomLevelInfo::minimumLevel(); + const int max = ZoomLevelInfo::maximumLevel(); + m_iconSizeGroupBox->setDefaultSizeRange(min, max); + m_iconSizeGroupBox->setPreviewSizeRange(min, max); + + connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)), + this, SIGNAL(changed())); + connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)), + this, SIGNAL(changed())); + // create 'Text' group for selecting the font, the number of lines // and the text width QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this); @@ -131,8 +140,10 @@ void IconsViewSettingsPage::applySettings() { IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); - settings->setIconSize(m_iconSize); - settings->setPreviewSize(m_previewSize); + const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue()); + const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue()); + settings->setIconSize(iconSize); + settings->setPreviewSize(previewSize); const QFont font = m_fontRequester->font(); const int fontHeight = QFontMetrics(font).height(); @@ -177,22 +188,17 @@ void IconsViewSettingsPage::restoreDefaults() loadSettings(); } -void IconsViewSettingsPage::openIconSizeDialog() -{ - IconSizeDialog dialog(this); - if (dialog.exec() == QDialog::Accepted) { - m_iconSize = dialog.iconSize(); - m_previewSize = dialog.previewSize(); - emit changed(); - } -} - void IconsViewSettingsPage::loadSettings() { IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings(); - m_iconSize = settings->iconSize(); - m_previewSize = settings->previewSize(); + const QSize iconSize(settings->iconSize(), settings->iconSize()); + const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize); + m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue); + + const QSize previewSize(settings->previewSize(), settings->previewSize()); + const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize); + m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue); if (settings->useSystemFont()) { m_fontRequester->setMode(DolphinFontRequester::SystemFont); diff --git a/src/iconsviewsettingspage.h b/src/iconsviewsettingspage.h index c7f3123abc..07446aa744 100644 --- a/src/iconsviewsettingspage.h +++ b/src/iconsviewsettingspage.h @@ -24,9 +24,9 @@ #include class DolphinFontRequester; +class IconSizeGroupBox; class QCheckBox; class QComboBox; -class QPushButton; class QSpinBox; /** @@ -62,9 +62,6 @@ public: /** Restores the settings to default values. */ virtual void restoreDefaults(); -private slots: - void openIconSizeDialog(); - private: void loadSettings(); @@ -79,10 +76,7 @@ private: TopToBottomInc = 32 }; - int m_iconSize; - int m_previewSize; - - QPushButton* m_iconSizeButton; + IconSizeGroupBox* m_iconSizeGroupBox; QComboBox* m_textWidthBox; DolphinFontRequester* m_fontRequester; QSpinBox* m_textlinesCountBox; diff --git a/src/zoomlevelinfo.cpp b/src/zoomlevelinfo.cpp new file mode 100644 index 0000000000..174a910d65 --- /dev/null +++ b/src/zoomlevelinfo.cpp @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2008 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "zoomlevelinfo.h" +#include +#include + +int ZoomLevelInfo::minimumLevel() +{ + return 0; +} + +int ZoomLevelInfo::maximumLevel() +{ + return 7; +} + +int ZoomLevelInfo::iconSizeForZoomLevel(int level) +{ + int size = KIconLoader::SizeMedium; + switch (level) { + case 0: size = KIconLoader::SizeSmall; break; + case 1: size = KIconLoader::SizeSmallMedium; break; + case 2: size = KIconLoader::SizeMedium; break; + case 3: size = KIconLoader::SizeLarge; break; + case 4: size = KIconLoader::SizeHuge; break; + case 5: size = KIconLoader::SizeEnormous; break; + case 6: size = KIconLoader::SizeEnormous * 3 / 2; break; + case 7: size = KIconLoader::SizeEnormous * 2; break; + default: Q_ASSERT(false); break; + } + return size; +} + +int ZoomLevelInfo::zoomLevelForIconSize(const QSize& size) +{ + int level = 0; + switch (size.height()) { + case KIconLoader::SizeSmall: level = 0; break; + case KIconLoader::SizeSmallMedium: level = 1; break; + case KIconLoader::SizeMedium: level = 2; break; + case KIconLoader::SizeLarge: level = 3; break; + case KIconLoader::SizeHuge: level = 4; break; + case KIconLoader::SizeEnormous: level = 5; break; + case KIconLoader::SizeEnormous * 3 / 2: level = 6; break; + case KIconLoader::SizeEnormous * 2: level = 7; break; + default: Q_ASSERT(false); level = 3; break; + } + return level; +} diff --git a/src/zoomlevelinfo.h b/src/zoomlevelinfo.h new file mode 100644 index 0000000000..a6e92e6531 --- /dev/null +++ b/src/zoomlevelinfo.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2008 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef ZOOMLEVELINFO_H +#define ZOOMLEVELINFO_H + +class QSize; + +/** + * @short Helper class for getting information about the zooming + * capabilities. + */ +class ZoomLevelInfo { +public: + static int minimumLevel(); + static int maximumLevel(); + + /** + * Helper method for the view implementation to get + * the icon size for the zoom level \a level that + * is between the range ZoomLevelInfo::minimumLevel() and + * ZoomLevelInfo::maximumLevel(). + */ + static int iconSizeForZoomLevel(int level); + + /** + * Helper method for the view implementation to get + * the zoom level for the icon size \a size that + * is between the range ZoomLevelInfo::minimumLevel() and + * ZoomLevelInfo::maximumLevel(). + */ + static int zoomLevelForIconSize(const QSize& size); +}; + +#endif