]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Fix scrolling during inline renaming causes rename of wrong file
[dolphin.git] / src / dolphinpart.cpp
index 332f8e9b9316eece22c48e3d623ba14cc4a5fcff..b3b47304e1b211e32bca7424331e27575870f63b 100644 (file)
@@ -78,6 +78,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
             this, &DolphinPart::slotErrorMessage);
 
     connect(m_view, &DolphinView::directoryLoadingCompleted, this, static_cast<void(DolphinPart::*)()>(&DolphinPart::completed));
+    connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinPart::updatePasteAction);
     connect(m_view, &DolphinView::directoryLoadingProgress, this, &DolphinPart::updateProgress);
     connect(m_view, &DolphinView::errorMessage, this, &DolphinPart::slotErrorMessage);
 
@@ -252,9 +253,9 @@ void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
 {
     const bool hasSelection = !selection.isEmpty();
 
-    QAction* renameAction  = actionCollection()->action(QStringLiteral("rename"));
-    QAction* moveToTrashAction = actionCollection()->action(QStringLiteral("move_to_trash"));
-    QAction* deleteAction = actionCollection()->action(QStringLiteral("delete"));
+    QAction* renameAction  = actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile));
+    QAction* moveToTrashAction = actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash));
+    QAction* deleteAction = actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile));
     QAction* editMimeTypeAction = actionCollection()->action(QStringLiteral("editMimeType"));
     QAction* propertiesAction = actionCollection()->action(QStringLiteral("properties"));
     QAction* deleteWithTrashShortcut = actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
@@ -351,7 +352,7 @@ void DolphinPart::slotRequestItemInfo(const KFileItem& item)
         updateStatusBar();
     } else {
         const QString escapedText = Qt::convertFromPlainText(item.getStatusBarInfo());
-        ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText));
+        emit ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText));
     }
 }
 
@@ -397,7 +398,6 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
     KFileItem item(_item);
 
     if (item.isNull()) { // viewport context menu
-        popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
         item = m_view->rootItem();
         if (item.isNull())
             item = KFileItem(url());
@@ -432,10 +432,10 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
             if (showDeleteAction && showMoveToTrashAction) {
                 delete m_removeAction;
                 m_removeAction = 0;
-                editActions.append(actionCollection()->action(QStringLiteral("move_to_trash")));
-                editActions.append(actionCollection()->action(QStringLiteral("delete")));
+                editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash)));
+                editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
             } else if (showDeleteAction && !showMoveToTrashAction) {
-                editActions.append(actionCollection()->action(QStringLiteral("delete")));
+                editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
             } else {
                 if (!m_removeAction)
                     m_removeAction = new DolphinRemoveAction(this, actionCollection());
@@ -447,7 +447,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
         }
 
         if (supportsMoving) {
-            editActions.append(actionCollection()->action(QStringLiteral("rename")));
+            editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile)));
         }
 
         // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
@@ -575,7 +575,7 @@ void DolphinPart::updateStatusBar()
 
 void DolphinPart::updateProgress(int percent)
 {
-    m_extension->loadingProgress(percent);
+    emit m_extension->loadingProgress(percent);
 }
 
 void DolphinPart::createDirectory()
@@ -597,6 +597,7 @@ void DolphinPart::setFilesToSelect(const QList<QUrl>& files)
 
 bool DolphinPart::eventFilter(QObject* obj, QEvent* event)
 {
+    using ShiftState = DolphinRemoveAction::ShiftState;
     const int type = event->type();
 
     if ((type == QEvent::KeyPress || type == QEvent::KeyRelease) && m_removeAction) {
@@ -604,7 +605,7 @@ bool DolphinPart::eventFilter(QObject* obj, QEvent* event)
         if (menu && menu->parent() == m_view) {
             QKeyEvent* ev = static_cast<QKeyEvent*>(event);
             if (ev->key() == Qt::Key_Shift) {
-                m_removeAction->update();
+                m_removeAction->update(type == QEvent::KeyPress ? ShiftState::Pressed : ShiftState::Released);
             }
         }
     }