]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Merge branch 'Applications/17.12'
[dolphin.git] / src / dolphinpart.cpp
index b55bcabb25e9eeb1315eabf5dbe314f4f26397ff..6f8e20489ace4d37372706c35ac1022e5c77c4bc 100644 (file)
@@ -60,8 +60,8 @@ K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
 
 DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args)
     : KParts::ReadOnlyPart(parent)
-      ,m_openTerminalAction(0)
-      ,m_removeAction(0)
+      ,m_openTerminalAction(nullptr)
+      ,m_removeAction(nullptr)
 {
     Q_UNUSED(args)
     setComponentData(*createAboutData(), false);
@@ -223,6 +223,7 @@ void DolphinPart::createActions()
     m_findFileAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-find")));
     connect(m_findFileAction, &QAction::triggered, this, &DolphinPart::slotFindFile);
 
+#ifndef Q_OS_WIN
     if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
         m_openTerminalAction = actionCollection()->addAction(QStringLiteral("open_terminal"));
         m_openTerminalAction->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
@@ -230,6 +231,7 @@ void DolphinPart::createActions()
         connect(m_openTerminalAction, &QAction::triggered, this, &DolphinPart::slotOpenTerminal);
         actionCollection()->setDefaultShortcut(m_openTerminalAction, Qt::Key_F4);
     }
+#endif
 }
 
 void DolphinPart::createGoAction(const char* name, const char* iconName,
@@ -253,9 +255,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
@@ -316,7 +318,7 @@ bool DolphinPart::openUrl(const QUrl &url)
     QString prettyUrl = visibleUrl.toDisplayString(QUrl::PreferLocalFile);
     emit setWindowCaption(prettyUrl);
     emit m_extension->setLocationBarUrl(prettyUrl);
-    emit started(0); // get the wheel to spin
+    emit started(nullptr); // get the wheel to spin
     m_view->setNameFilter(m_nameFilter);
     m_view->setUrl(url);
     updatePasteAction();
@@ -352,7 +354,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));
     }
 }
 
@@ -431,11 +433,11 @@ 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")));
+                m_removeAction = nullptr;
+                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 +449,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 +577,7 @@ void DolphinPart::updateStatusBar()
 
 void DolphinPart::updateProgress(int percent)
 {
-    m_extension->loadingProgress(percent);
+    emit m_extension->loadingProgress(percent);
 }
 
 void DolphinPart::createDirectory()
@@ -597,6 +599,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 +607,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);
             }
         }
     }