]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewactionhandler.cpp
reset the information panel if an item is shown that got deleted
[dolphin.git] / src / dolphinviewactionhandler.cpp
index 420db5404d66598aba7850e1a98e12a605dde92c..2c83c9bda926df93fc53490037a0bba527c6f08b 100644 (file)
 
 #include "dolphinviewactionhandler.h"
 
-#include "viewpropertiesdialog.h"
+#include "settings/viewpropertiesdialog.h"
 #include "dolphinview.h"
+#include "zoomlevelinfo.h"
 
 #include <konq_operations.h>
 
 #include <kaction.h>
 #include <kactioncollection.h>
-#include <kdebug.h>
 #include <klocale.h>
 #include <ktoggleaction.h>
+#include <krun.h>
+#include <kpropertiesdialog.h>
 
 DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent)
     : QObject(parent),
@@ -62,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()
@@ -71,6 +75,7 @@ void DolphinViewActionHandler::createActions()
     KAction* newDirAction = m_actionCollection->addAction("create_dir");
     newDirAction->setText(i18nc("@action", "Create Folder..."));
     newDirAction->setShortcut(Qt::Key_F10);
+    newDirAction->setIcon(KIcon("folder-new"));
     connect(newDirAction, SIGNAL(triggered()), SLOT(slotCreateDir()));
 
     // Edit menu
@@ -78,6 +83,7 @@ void DolphinViewActionHandler::createActions()
     KAction* rename = m_actionCollection->addAction("rename");
     rename->setText(i18nc("@action:inmenu File", "Rename..."));
     rename->setShortcut(Qt::Key_F2);
+    rename->setIcon(KIcon("edit-rename"));
     connect(rename, SIGNAL(triggered()), this, SLOT(slotRename()));
 
     KAction* moveToTrash = m_actionCollection->addAction("move_to_trash");
@@ -98,12 +104,18 @@ void DolphinViewActionHandler::createActions()
     // can be used for deleting the file (#76016). It needs to be a separate action
     // so that the Edit menu isn't affected.
     KAction* deleteWithTrashShortcut = m_actionCollection->addAction("delete_shortcut");
-    // TODO after message freeze, a more descriptive text, for the shortcuts editor.
-    deleteWithTrashShortcut->setText(i18nc("@action:inmenu File", "Delete"));
+    // The descriptive text is just for the shortcuts editor.
+    deleteWithTrashShortcut->setText(i18nc("@action:inmenu File", "Delete (using shortcut for Trash)"));
     deleteWithTrashShortcut->setShortcut(QKeySequence::Delete);
     deleteWithTrashShortcut->setEnabled(false);
     connect(deleteWithTrashShortcut, SIGNAL(triggered()), this, SLOT(slotDeleteItems()));
 
+    KAction *propertiesAction = m_actionCollection->addAction( "properties" );
+    // Well, it's the File menu in dolphinmainwindow and the Edit menu in dolphinpart... :)
+    propertiesAction->setText( i18nc("@action:inmenu File", "Properties") );
+    propertiesAction->setShortcut(Qt::ALT | Qt::Key_Return);
+    connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties()));
+
     // View menu
 
     QActionGroup* viewModeActions = new QActionGroup(this);
@@ -147,6 +159,14 @@ void DolphinViewActionHandler::createActions()
     KAction* adjustViewProps = m_actionCollection->addAction("view_properties");
     adjustViewProps->setText(i18nc("@action:inmenu View", "Adjust View Properties..."));
     connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(slotAdjustViewProperties()));
+
+    // Tools menu
+
+    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"));
+    connect(findFile, SIGNAL(triggered()), this, SLOT(slotFindFile()));
 }
 
 QActionGroup* DolphinViewActionHandler::createAdditionalInformationActionGroup()
@@ -326,16 +346,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());
 
@@ -343,6 +353,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());
@@ -351,13 +362,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();
 }
 
@@ -481,6 +494,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>();
@@ -493,3 +519,25 @@ void DolphinViewActionHandler::slotAdjustViewProperties()
     ViewPropertiesDialog dlg(m_currentView);
     dlg.exec();
 }
+
+void DolphinViewActionHandler::slotFindFile()
+{
+    KRun::run("kfind %u", m_currentView->url(), m_currentView->window());
+}
+
+void DolphinViewActionHandler::slotProperties()
+{
+    KPropertiesDialog* dialog = 0;
+    const KFileItemList list = m_currentView->selectedItems();
+    if (list.isEmpty()) {
+        const KUrl url = m_currentView->url();
+        dialog = new KPropertiesDialog(url, m_currentView);
+    } else {
+        dialog = new KPropertiesDialog(list, m_currentView);
+    }
+
+    dialog->setAttribute(Qt::WA_DeleteOnClose);
+    dialog->show();
+    dialog->raise();
+    dialog->activateWindow();
+}