[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/apps/dolphin/src
From: Peter Penz <peter.penz () gmx ! at>
Date: 2007-03-01 19:36:43
Message-ID: 1172777803.895592.8432.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 638386 by ppenz:
Allow zooming in and zooming out in the icons view.
M +13 -1 dolphincontroller.cpp
M +16 -0 dolphincontroller.h
M +90 -3 dolphiniconsview.cpp
M +13 -0 dolphiniconsview.h
M +6 -5 dolphinmainwindow.cpp
M +1 -1 dolphinmainwindow.h
M +4 -4 dolphinview.cpp
--- trunk/KDE/kdebase/apps/dolphin/src/dolphincontroller.cpp #638385:638386
@@ -21,7 +21,9 @@
DolphinController::DolphinController(QObject* parent) :
QObject(parent),
- m_showPreview(false)
+ m_showPreview(false),
+ m_zoomInPossible(false),
+ m_zoomOutPossible(false)
{
}
@@ -65,6 +67,16 @@
}
}
+void DolphinController::triggerZoomIn()
+{
+ emit zoomIn();
+}
+
+void DolphinController::triggerZoomOut()
+{
+ emit zoomOut();
+}
+
void DolphinController::triggerItem(const QModelIndex& index)
{
emit itemTriggered(index);
--- trunk/KDE/kdebase/apps/dolphin/src/dolphincontroller.h #638385:638386
@@ -70,6 +70,14 @@
void setShowPreview(bool showPreview);
bool showPreview() const { return m_showPreview; }
+ void triggerZoomIn();
+ void setZoomInPossible(bool possible) { m_zoomInPossible = possible; }
+ bool isZoomInPossible() const { return m_zoomInPossible; }
+
+ void triggerZoomOut();
+ void setZoomOutPossible(bool possible) { m_zoomOutPossible = possible; }
+ bool isZoomOutPossible() const { return m_zoomOutPossible; }
+
public slots:
void triggerItem(const QModelIndex& index);
void indicateSelectionChange();
@@ -121,8 +129,16 @@
/** Is emitted if the selection has been changed by the user. */
void selectionChanged();
+ /** Is emitted if the view should zoom in. */
+ void zoomIn();
+
+ /** Is emitted if the view should zoom out. */
+ void zoomOut();
+
private:
bool m_showPreview;
+ bool m_zoomInPossible;
+ bool m_zoomOutPossible;
KUrl m_url;
};
--- trunk/KDE/kdebase/apps/dolphin/src/dolphiniconsview.cpp #638385:638386
@@ -24,7 +24,6 @@
#include "dolphin_iconsmodesettings.h"
-#include <assert.h>
#include <kdirmodel.h>
#include <kfileitem.h>
#include <kfileitemdelegate.h>
@@ -43,15 +42,18 @@
controller, SLOT(triggerItem(const QModelIndex&)));
connect(controller, SIGNAL(showPreviewChanged(bool)),
this, SLOT(updateGridSize(bool)));
+ connect(controller, SIGNAL(zoomIn()),
+ this, SLOT(zoomIn()));
+ connect(controller, SIGNAL(zoomOut()),
+ this, SLOT(zoomOut()));
// apply the icons mode settings to the widget
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
Q_ASSERT(settings != 0);
- setSpacing(settings->gridSpacing());
-
m_viewOptions = QListView::viewOptions();
m_viewOptions.font = QFont(settings->fontFamily(), settings->fontSize());
+
updateGridSize(controller->showPreview());
if (settings->arrangement() == QListView::TopToBottom) {
@@ -132,6 +134,91 @@
m_viewOptions.decorationSize = QSize(size, size);
setGridSize(QSize(gridWidth, gridHeight));
+
+ m_controller->setZoomInPossible(isZoomInPossible());
+ m_controller->setZoomOutPossible(isZoomOutPossible());
}
+void DolphinIconsView::zoomIn()
+{
+ if (isZoomInPossible()) {
+ IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+
+ 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);
+ }
+
+ updateGridSize(showPreview);
+ }
+}
+
+void DolphinIconsView::zoomOut()
+{
+ if (isZoomOutPossible()) {
+ IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+
+ const bool showPreview = m_controller->showPreview();
+ if (showPreview) {
+ const int previewSize = decreasedIconSize(settings->previewSize());
+ settings->setPreviewSize(previewSize);
+ }
+ else {
+ const int iconSize = decreasedIconSize(settings->iconSize());
+ settings->setIconSize(iconSize);
+ }
+
+ updateGridSize(showPreview);
+ }
+}
+
+bool DolphinIconsView::isZoomInPossible() const
+{
+ IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+ const int size = m_controller->showPreview() ? settings->previewSize() : settings->iconSize();
+ return size < K3Icon::SizeEnormous;
+}
+
+bool DolphinIconsView::isZoomOutPossible() const
+{
+ IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+ const int size = m_controller->showPreview() ? settings->previewSize() : settings->iconSize();
+ return size > K3Icon::SizeSmall;
+}
+
+int DolphinIconsView::increasedIconSize(int size) const
+{
+ // TODO: get rid of K3Icon sizes
+ int incSize = 0;
+ switch (size) {
+ case K3Icon::SizeSmall: incSize = K3Icon::SizeSmallMedium; break;
+ case K3Icon::SizeSmallMedium: incSize = K3Icon::SizeMedium; break;
+ case K3Icon::SizeMedium: incSize = K3Icon::SizeLarge; break;
+ case K3Icon::SizeLarge: incSize = K3Icon::SizeHuge; break;
+ case K3Icon::SizeHuge: incSize = K3Icon::SizeEnormous; break;
+ default: Q_ASSERT(false); break;
+ }
+ return incSize;
+}
+
+int DolphinIconsView::decreasedIconSize(int size) const
+{
+ // TODO: get rid of K3Icon sizes
+ int decSize = 0;
+ switch (size) {
+ case K3Icon::SizeSmallMedium: decSize = K3Icon::SizeSmall; break;
+ case K3Icon::SizeMedium: decSize = K3Icon::SizeSmallMedium; break;
+ case K3Icon::SizeLarge: decSize = K3Icon::SizeMedium; break;
+ case K3Icon::SizeHuge: decSize = K3Icon::SizeLarge; break;
+ case K3Icon::SizeEnormous: decSize = K3Icon::SizeHuge; break;
+ default: Q_ASSERT(false); break;
+ }
+ return decSize;
+}
+
#include "dolphiniconsview.moc"
--- trunk/KDE/kdebase/apps/dolphin/src/dolphiniconsview.h #638385:638386
@@ -54,7 +54,20 @@
*/
void updateGridSize(bool showPreview);
+ void zoomIn();
+ void zoomOut();
+
private:
+ bool isZoomInPossible() const;
+ bool isZoomOutPossible() const;
+
+ /** Returns the increased icon size for the size \a size. */
+ int increasedIconSize(int size) const;
+
+ /** Returns the decreased icon size for the size \a size. */
+ int decreasedIconSize(int size) const;
+
+private:
DolphinController* m_controller;
QStyleOptionViewItem m_viewOptions;
};
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinmainwindow.cpp #638385:638386
@@ -250,11 +250,11 @@
updateViewActions();
}
-void DolphinMainWindow::slowShowPreviewChanged()
+void DolphinMainWindow::slotShowPreviewChanged()
{
- KToggleAction* showPreviewAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
- showPreviewAction->setChecked(m_activeView->showPreview());
+ // It is not enough to update the 'Show Preview' action, also
+ // the 'Zoom In' and 'Zoom Out' actions must be adapted.
+ updateViewActions();
}
void DolphinMainWindow::slotShowHiddenFilesChanged()
@@ -329,6 +329,7 @@
void DolphinMainWindow::slotUrlChanged(const KUrl& url)
{
updateEditActions();
+ updateViewActions();
updateGoActions();
setCaption(url.fileName());
}
@@ -1349,7 +1350,7 @@
connect(view, SIGNAL(modeChanged()),
this, SLOT(slotViewModeChanged()));
connect(view, SIGNAL(showPreviewChanged()),
- this, SLOT(slowShowPreviewChanged()));
+ this, SLOT(slotShowPreviewChanged()));
connect(view, SIGNAL(showHiddenFilesChanged()),
this, SLOT(slotShowHiddenFilesChanged()));
connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinmainwindow.h #638385:638386
@@ -320,7 +320,7 @@
void slotViewModeChanged();
/** Updates the state of the 'Show preview' menu action. */
- void slowShowPreviewChanged();
+ void slotShowPreviewChanged();
/** Updates the state of the 'Show hidden files' menu action. */
void slotShowHiddenFilesChanged();
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinview.cpp #638385:638386
@@ -376,22 +376,22 @@
void DolphinView::zoomIn()
{
- //itemEffectsManager()->zoomIn();
+ m_controller->triggerZoomIn();
}
void DolphinView::zoomOut()
{
- //itemEffectsManager()->zoomOut();
+ m_controller->triggerZoomOut();
}
bool DolphinView::isZoomInPossible() const
{
- return false; //itemEffectsManager()->isZoomInPossible();
+ return m_controller->isZoomInPossible();
}
bool DolphinView::isZoomOutPossible() const
{
- return false; //itemEffectsManager()->isZoomOutPossible();
+ return m_controller->isZoomOutPossible();
}
void DolphinView::setSorting(Sorting sorting)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic