]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontroller.cpp
Provide a common iconsize-widget for the settings dialog of the icons-, details-...
[dolphin.git] / src / dolphincontroller.cpp
index b00ca71605dc10a4224b461dc6b06bb652233c47..abbae6ec790c567eb0c05e41bf4869c2ac77d522 100644 (file)
@@ -18,6 +18,7 @@
  ***************************************************************************/
 
 #include "dolphincontroller.h"
+#include "zoomlevelinfo.h"
 
 #include <kdirmodel.h>
 #include <QAbstractProxyModel>
@@ -27,8 +28,7 @@
 
 DolphinController::DolphinController(DolphinView* dolphinView) :
     QObject(dolphinView),
-    m_zoomInPossible(false),
-    m_zoomOutPossible(false),
+    m_zoomLevel(0),
     m_openTab(false),
     m_url(),
     m_dolphinView(dolphinView),
@@ -57,9 +57,13 @@ void DolphinController::setItemView(QAbstractItemView* view)
 
     m_itemView = view;
 
-    // TODO: this is a workaround until  Qt-issue 176832 has been fixed
-    connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
-            this, SLOT(updateOpenTabState()));
+    if (m_itemView != 0) {
+        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&)),
+                this, SLOT(updateOpenTabState()));
+    }
 }
 
 void DolphinController::triggerUrlChangeRequest(const KUrl& url)
@@ -108,14 +112,14 @@ void DolphinController::indicateActivationChange(bool active)
     emit activationChanged(active);
 }
 
-void DolphinController::triggerZoomIn()
-{
-    emit zoomIn();
-}
-
-void DolphinController::triggerZoomOut()
+void DolphinController::setZoomLevel(int level)
 {
-    emit zoomOut();
+    Q_ASSERT(level >= ZoomLevelInfo::minimumLevel());
+    Q_ASSERT(level <= ZoomLevelInfo::maximumLevel());
+    if (level != m_zoomLevel) {
+        m_zoomLevel = level;
+        emit zoomLevelChanged(m_zoomLevel);
+    }
 }
 
 void DolphinController::handleKeyPressEvent(QKeyEvent* event)