X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/5481709016a55bda94177217838318e4e3e7d370..41f7f4e4e89b97b5c7f31452774c37ce953dd125:/src/dolphinpart.cpp diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index c38625096..a4d7fdf78 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -18,50 +18,49 @@ */ #include "dolphinpart.h" -#include "dolphinremoveaction.h" -#include +#include "dolphindebug.h" +#include "dolphinnewfilemenu.h" +#include "dolphinpart_ext.h" +#include "dolphinremoveaction.h" +#include "kitemviews/kfileitemmodel.h" +#include "kitemviews/private/kfileitemmodeldirlister.h" +#include "views/dolphinnewfilemenuobserver.h" +#include "views/dolphinremoteencoding.h" +#include "views/dolphinview.h" +#include "views/dolphinviewactionhandler.h" #include #include -#include "dolphindebug.h" +#include +#include +#include #include +#include #include #include +#include #include #include -#include -#include -#include #include -#include -#include -#include - -#include "dolphinpart_ext.h" -#include "dolphinnewfilemenu.h" -#include "views/dolphinview.h" -#include "views/dolphinviewactionhandler.h" -#include "views/dolphinnewfilemenuobserver.h" -#include "views/dolphinremoteencoding.h" -#include "kitemviews/kfileitemmodel.h" -#include "kitemviews/private/kfileitemmodeldirlister.h" +#include -#include #include -#include #include #include #include -#include #include +#include +#include +#include +#include K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin();) 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); @@ -77,7 +76,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage, this, &DolphinPart::slotErrorMessage); - connect(m_view, &DolphinView::directoryLoadingCompleted, this, static_cast(&DolphinPart::completed)); + connect(m_view, &DolphinView::directoryLoadingCompleted, this, QOverload<>::of(&KParts::ReadOnlyPart::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); @@ -99,7 +98,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL connect(m_view, &DolphinView::requestContextMenu, this, &DolphinPart::slotOpenContextMenu); connect(m_view, &DolphinView::selectionChanged, - m_extension, static_cast(&DolphinPartBrowserExtension::selectionInfo)); + m_extension, QOverload::of(&KParts::BrowserExtension::selectionInfo)); connect(m_view, &DolphinView::selectionChanged, this, &DolphinPart::slotSelectionChanged); connect(m_view, &DolphinView::requestItemInfo, @@ -116,7 +115,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); m_actionHandler->setCurrentView(m_view); - connect(m_actionHandler, &DolphinViewActionHandler::createDirectory, this, &DolphinPart::createDirectory); + connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinPart::createDirectory); m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); connect(this, &DolphinPart::aboutToOpenURL, @@ -174,14 +173,14 @@ void DolphinPart::createActions() QAction* selectItemsMatching = actionCollection()->addAction(QStringLiteral("select_items_matching")); selectItemsMatching->setText(i18nc("@action:inmenu Edit", "Select Items Matching...")); - actionCollection()->setDefaultShortcut(selectItemsMatching, Qt::CTRL | Qt::Key_S); + actionCollection()->setDefaultShortcut(selectItemsMatching, Qt::CTRL + Qt::Key_S); connect(selectItemsMatching, &QAction::triggered, this, &DolphinPart::slotSelectItemsMatchingPattern); QAction* unselectItemsMatching = actionCollection()->addAction(QStringLiteral("unselect_items_matching")); unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching...")); connect(unselectItemsMatching, &QAction::triggered, this, &DolphinPart::slotUnselectItemsMatchingPattern); - actionCollection()->addAction(KStandardAction::SelectAll, QStringLiteral("select_all"), m_view, SLOT(selectAll())); + KStandardAction::selectAll(m_view, &DolphinView::selectAll, actionCollection()); QAction* unselectAll = actionCollection()->addAction(QStringLiteral("unselect_all")); unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All")); @@ -189,7 +188,7 @@ void DolphinPart::createActions() QAction* invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection")); invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection")); - actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL | Qt::SHIFT | Qt::Key_A); + actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL + Qt::SHIFT + Qt::Key_A); connect(invertSelection, &QAction::triggered, m_view, &DolphinView::invertSelection); // View menu: all done by DolphinViewActionHandler @@ -217,12 +216,10 @@ void DolphinPart::createActions() goActionGroup); // Tools menu - m_findFileAction = actionCollection()->addAction(QStringLiteral("find_file")); + m_findFileAction = KStandardAction::find(this, &DolphinPart::slotFindFile, actionCollection()); m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File...")); - actionCollection()->setDefaultShortcut(m_findFileAction, Qt::CTRL | Qt::Key_F); - 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 +227,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, @@ -316,7 +314,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(); @@ -431,7 +429,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos, if (showDeleteAction && showMoveToTrashAction) { delete m_removeAction; - m_removeAction = 0; + m_removeAction = nullptr; editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash))); editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile))); } else if (showDeleteAction && !showMoveToTrashAction) { @@ -597,6 +595,7 @@ void DolphinPart::setFilesToSelect(const QList& 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 +603,7 @@ bool DolphinPart::eventFilter(QObject* obj, QEvent* event) if (menu && menu->parent() == m_view) { QKeyEvent* ev = static_cast(event); if (ev->key() == Qt::Key_Shift) { - m_removeAction->update(); + m_removeAction->update(type == QEvent::KeyPress ? ShiftState::Pressed : ShiftState::Released); } } }