]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewactionhandler.cpp
- Fix crash found while investigating https://bugs.kde.org/show_bug.cgi?id=170927
[dolphin.git] / src / dolphinviewactionhandler.cpp
index cd5880c794b7a776a751a2e7f69fc27d6c87460a..de99ec9bf1d4b82084494acc8f9548bd9ff0b406 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "viewpropertiesdialog.h"
 #include "dolphinview.h"
+#include "zoomlevelinfo.h"
 
 #include <konq_operations.h>
 
@@ -63,6 +64,8 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view)
             this, SLOT(slotShowHiddenFilesChanged()));
     connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
             this, SLOT(slotSortingChanged(DolphinView::Sorting)));
+    connect(view, SIGNAL(zoomLevelChanged(int)),
+            this, SLOT(slotZoomLevelChanged(int)));
 }
 
 void DolphinViewActionHandler::createActions()
@@ -157,7 +160,7 @@ void DolphinViewActionHandler::createActions()
 
     // Tools menu
 
-    QAction* findFile = m_actionCollection->addAction("find_file");
+    KAction* findFile = m_actionCollection->addAction("find_file");
     findFile->setText(i18nc("@action:inmenu Tools", "Find File..."));
     findFile->setShortcut(Qt::CTRL | Qt::Key_F);
     findFile->setIcon(KIcon("edit-find"));
@@ -341,16 +344,6 @@ void DolphinViewActionHandler::updateViewActions()
         viewModeAction->setChecked(true);
     }
 
-    QAction* zoomInAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomIn));
-    if (zoomInAction != 0) {
-        zoomInAction->setEnabled(m_currentView->isZoomInPossible());
-    }
-
-    QAction* zoomOutAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomOut));
-    if (zoomOutAction != 0) {
-        zoomOutAction->setEnabled(m_currentView->isZoomOutPossible());
-    }
-
     QAction* showPreviewAction = m_actionCollection->action("show_preview");
     showPreviewAction->setChecked(m_currentView->showPreview());
 
@@ -358,6 +351,7 @@ void DolphinViewActionHandler::updateViewActions()
     slotAdditionalInfoChanged();
     slotCategorizedSortingChanged();
     slotSortingChanged(m_currentView->sorting());
+    slotZoomLevelChanged(m_currentView->zoomLevel());
 
     QAction* showHiddenFilesAction = m_actionCollection->action("show_hidden_files");
     showHiddenFilesAction->setChecked(m_currentView->showHiddenFiles());
@@ -366,13 +360,15 @@ void DolphinViewActionHandler::updateViewActions()
 
 void DolphinViewActionHandler::zoomIn()
 {
-    m_currentView->zoomIn();
+    const int level = m_currentView->zoomLevel();
+    m_currentView->setZoomLevel(level + 1);
     updateViewActions();
 }
 
 void DolphinViewActionHandler::zoomOut()
 {
-    m_currentView->zoomOut();
+    const int level = m_currentView->zoomLevel();
+    m_currentView->setZoomLevel(level - 1);
     updateViewActions();
 }
 
@@ -496,6 +492,19 @@ void DolphinViewActionHandler::slotSortingChanged(DolphinView::Sorting sorting)
     }
 }
 
+void DolphinViewActionHandler::slotZoomLevelChanged(int level)
+{
+    QAction* zoomInAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomIn));
+    if (zoomInAction != 0) {
+        zoomInAction->setEnabled(level < ZoomLevelInfo::maximumLevel());
+    }
+
+    QAction* zoomOutAction = m_actionCollection->action(KStandardAction::name(KStandardAction::ZoomOut));
+    if (zoomOutAction != 0) {
+        zoomOutAction->setEnabled(level > ZoomLevelInfo::minimumLevel());
+    }
+}
+
 void DolphinViewActionHandler::slotSortTriggered(QAction* action)
 {
     const DolphinView::Sorting sorting = action->data().value<DolphinView::Sorting>();