Changeset View
Changeset View
Standalone View
Standalone View
src/dolphinmainwindow.cpp
Show All 39 Lines | |||||
40 | #include "settings/dolphinsettingsdialog.h" | 40 | #include "settings/dolphinsettingsdialog.h" | ||
41 | #include "statusbar/dolphinstatusbar.h" | 41 | #include "statusbar/dolphinstatusbar.h" | ||
42 | #include "views/dolphinviewactionhandler.h" | 42 | #include "views/dolphinviewactionhandler.h" | ||
43 | #include "views/dolphinremoteencoding.h" | 43 | #include "views/dolphinremoteencoding.h" | ||
44 | #include "views/draganddrophelper.h" | 44 | #include "views/draganddrophelper.h" | ||
45 | #include "views/viewproperties.h" | 45 | #include "views/viewproperties.h" | ||
46 | #include "views/dolphinnewfilemenuobserver.h" | 46 | #include "views/dolphinnewfilemenuobserver.h" | ||
47 | #include "dolphin_generalsettings.h" | 47 | #include "dolphin_generalsettings.h" | ||
48 | #include "kitemviews/kitemlistselectionmanager.h" | ||||
49 | #include "kitemviews/kfileitemmodel.h" | ||||
50 | #include "kitemviews/kfileitemlistview.h" | ||||
48 | 51 | | |||
49 | #include <KActionCollection> | 52 | #include <KActionCollection> | ||
50 | #include <KActionMenu> | 53 | #include <KActionMenu> | ||
51 | #include <KAuthorized> | 54 | #include <KAuthorized> | ||
52 | #include <KConfig> | 55 | #include <KConfig> | ||
53 | #include <KDualAction> | 56 | #include <KDualAction> | ||
57 | #include <KFileItem> | ||||
54 | #include <KFileItemListProperties> | 58 | #include <KFileItemListProperties> | ||
55 | #include <KHelpMenu> | 59 | #include <KHelpMenu> | ||
56 | #include <KIO/CommandLauncherJob> | 60 | #include <KIO/CommandLauncherJob> | ||
57 | #include <KIO/JobUiDelegate> | 61 | #include <KIO/JobUiDelegate> | ||
58 | #include <KIO/OpenFileManagerWindowJob> | 62 | #include <KIO/OpenFileManagerWindowJob> | ||
59 | #include <KJobWidgets> | 63 | #include <KJobWidgets> | ||
60 | #include <KLocalizedString> | 64 | #include <KLocalizedString> | ||
61 | #include <KMessageBox> | 65 | #include <KMessageBox> | ||
62 | #include <KNS3/KMoreToolsMenuFactory> | 66 | #include <KNS3/KMoreToolsMenuFactory> | ||
63 | #include <KProtocolInfo> | 67 | #include <KProtocolInfo> | ||
64 | #include <KProtocolManager> | 68 | #include <KProtocolManager> | ||
65 | #include <KRun> | 69 | #include <KRun> | ||
66 | #include <KShell> | 70 | #include <KShell> | ||
67 | #include <KStandardAction> | 71 | #include <KStandardAction> | ||
68 | #include <KStartupInfo> | 72 | #include <KStartupInfo> | ||
69 | #include <KToggleAction> | 73 | #include <KToggleAction> | ||
70 | #include <KToolBar> | 74 | #include <KToolBar> | ||
71 | #include <KToolBarPopupAction> | 75 | #include <KToolBarPopupAction> | ||
72 | #include <KToolInvocation> | 76 | #include <KToolInvocation> | ||
73 | #include <KUrlComboBox> | 77 | #include <KUrlComboBox> | ||
74 | #include <KUrlNavigator> | 78 | #include <KUrlNavigator> | ||
75 | #include <KWindowSystem> | 79 | #include <KWindowSystem> | ||
80 | #include <KDirModel> | ||||
76 | 81 | | |||
77 | #include <QApplication> | 82 | #include <QApplication> | ||
78 | #include <QClipboard> | 83 | #include <QClipboard> | ||
79 | #include <QCloseEvent> | 84 | #include <QCloseEvent> | ||
80 | #include <QDesktopServices> | 85 | #include <QDesktopServices> | ||
81 | #include <QDialog> | 86 | #include <QDialog> | ||
82 | #include <QFileInfo> | 87 | #include <QFileInfo> | ||
83 | #include <QLineEdit> | 88 | #include <QLineEdit> | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 133 | #endif | |||
157 | connect(m_tabWidget, &DolphinTabWidget::activeViewChanged, | 162 | connect(m_tabWidget, &DolphinTabWidget::activeViewChanged, | ||
158 | this, &DolphinMainWindow::activeViewChanged); | 163 | this, &DolphinMainWindow::activeViewChanged); | ||
159 | connect(m_tabWidget, &DolphinTabWidget::tabCountChanged, | 164 | connect(m_tabWidget, &DolphinTabWidget::tabCountChanged, | ||
160 | this, &DolphinMainWindow::tabCountChanged); | 165 | this, &DolphinMainWindow::tabCountChanged); | ||
161 | connect(m_tabWidget, &DolphinTabWidget::currentUrlChanged, | 166 | connect(m_tabWidget, &DolphinTabWidget::currentUrlChanged, | ||
162 | this, &DolphinMainWindow::updateWindowTitle); | 167 | this, &DolphinMainWindow::updateWindowTitle); | ||
163 | setCentralWidget(m_tabWidget); | 168 | setCentralWidget(m_tabWidget); | ||
164 | 169 | | |||
165 | setupActions(); | | |||
166 | | ||||
167 | m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); | 170 | m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); | ||
168 | connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar); | 171 | connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar); | ||
169 | connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory); | 172 | connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory); | ||
170 | 173 | | |||
174 | setupActions(); | ||||
175 | | ||||
171 | m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); | 176 | m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); | ||
172 | connect(this, &DolphinMainWindow::urlChanged, | 177 | connect(this, &DolphinMainWindow::urlChanged, | ||
173 | m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl); | 178 | m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl); | ||
174 | 179 | | |||
175 | setupDockWidgets(); | 180 | setupDockWidgets(); | ||
176 | 181 | | |||
177 | setupGUI(Keys | Save | Create | ToolBar); | 182 | setupGUI(Keys | Save | Create | ToolBar); | ||
178 | stateChanged(QStringLiteral("new_file")); | 183 | stateChanged(QStringLiteral("new_file")); | ||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 257 | { | |||
274 | 279 | | |||
275 | default: | 280 | default: | ||
276 | break; | 281 | break; | ||
277 | } | 282 | } | ||
278 | } | 283 | } | ||
279 | 284 | | |||
280 | void DolphinMainWindow::pasteIntoFolder() | 285 | void DolphinMainWindow::pasteIntoFolder() | ||
281 | { | 286 | { | ||
282 | m_activeViewContainer->view()->pasteIntoFolder(); | 287 | m_actionHandler->pasteIntoFolder(); | ||
283 | } | 288 | } | ||
284 | 289 | | |||
285 | void DolphinMainWindow::changeUrl(const QUrl &url) | 290 | void DolphinMainWindow::changeUrl(const QUrl &url) | ||
286 | { | 291 | { | ||
287 | if (!KProtocolManager::supportsListing(url)) { | 292 | if (!KProtocolManager::supportsListing(url)) { | ||
288 | // The URL navigator only checks for validity, not | 293 | // The URL navigator only checks for validity, not | ||
289 | // if the URL can be listed. An error message is | 294 | // if the URL can be listed. An error message is | ||
290 | // shown due to DolphinViewContainer::restoreView(). | 295 | // shown due to DolphinViewContainer::restoreView(). | ||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | |||||
373 | } | 378 | } | ||
374 | 379 | | |||
375 | void DolphinMainWindow::addToPlaces() | 380 | void DolphinMainWindow::addToPlaces() | ||
376 | { | 381 | { | ||
377 | QUrl url; | 382 | QUrl url; | ||
378 | QString name; | 383 | QString name; | ||
379 | 384 | | |||
380 | // If nothing is selected, act on the current dir | 385 | // If nothing is selected, act on the current dir | ||
381 | if (m_activeViewContainer->view()->selectedItems().isEmpty()) { | 386 | if (selectedItems().isEmpty()) { | ||
382 | url = m_activeViewContainer->url(); | 387 | url = m_activeViewContainer->url(); | ||
383 | name = m_activeViewContainer->placesText(); | 388 | name = m_activeViewContainer->placesText(); | ||
384 | } else { | 389 | } else { | ||
385 | const auto dirToAdd = m_activeViewContainer->view()->selectedItems().first(); | 390 | const auto dirToAdd = selectedItems().first(); | ||
386 | url = dirToAdd.url(); | 391 | url = dirToAdd.url(); | ||
387 | name = dirToAdd.name(); | 392 | name = dirToAdd.name(); | ||
388 | } | 393 | } | ||
389 | if (url.isValid()) { | 394 | if (url.isValid()) { | ||
390 | PlacesItemModel model; | 395 | PlacesItemModel model; | ||
391 | QString icon; | 396 | QString icon; | ||
392 | if (m_activeViewContainer->isSearchModeEnabled()) { | 397 | if (m_activeViewContainer->isSearchModeEnabled()) { | ||
393 | icon = QStringLiteral("folder-saved-search-symbolic"); | 398 | icon = QStringLiteral("folder-saved-search-symbolic"); | ||
Show All 16 Lines | |||||
410 | 415 | | |||
411 | void DolphinMainWindow::openNewTabAfterLastTab(const QUrl& url) | 416 | void DolphinMainWindow::openNewTabAfterLastTab(const QUrl& url) | ||
412 | { | 417 | { | ||
413 | m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterLastTab); | 418 | m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterLastTab); | ||
414 | } | 419 | } | ||
415 | 420 | | |||
416 | void DolphinMainWindow::openInNewTab() | 421 | void DolphinMainWindow::openInNewTab() | ||
417 | { | 422 | { | ||
418 | const KFileItemList& list = m_activeViewContainer->view()->selectedItems(); | 423 | const KFileItemList& list = selectedItems(); | ||
419 | bool tabCreated = false; | 424 | bool tabCreated = false; | ||
420 | 425 | | |||
421 | foreach (const KFileItem& item, list) { | 426 | for (const KFileItem& item : list) { | ||
422 | const QUrl& url = DolphinView::openItemAsFolderUrl(item); | 427 | const QUrl& url = DolphinView::openItemAsFolderUrl(item); | ||
423 | if (!url.isEmpty()) { | 428 | if (!url.isEmpty()) { | ||
424 | openNewTabAfterCurrentTab(url); | 429 | openNewTabAfterCurrentTab(url); | ||
425 | tabCreated = true; | 430 | tabCreated = true; | ||
426 | } | 431 | } | ||
427 | } | 432 | } | ||
428 | 433 | | |||
429 | // if no new tab has been created from the selection | 434 | // if no new tab has been created from the selection | ||
430 | // open the current directory in a new tab | 435 | // open the current directory in a new tab | ||
431 | if (!tabCreated) { | 436 | if (!tabCreated) { | ||
432 | openNewTabAfterCurrentTab(m_activeViewContainer->url()); | 437 | openNewTabAfterCurrentTab(m_activeViewContainer->url()); | ||
433 | } | 438 | } | ||
434 | } | 439 | } | ||
435 | 440 | | |||
436 | void DolphinMainWindow::openInNewWindow() | 441 | void DolphinMainWindow::openInNewWindow() | ||
437 | { | 442 | { | ||
438 | QUrl newWindowUrl; | 443 | QUrl newWindowUrl; | ||
439 | 444 | | |||
440 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | 445 | const KFileItemList list = selectedItems(); | ||
441 | if (list.isEmpty()) { | 446 | if (list.isEmpty()) { | ||
442 | newWindowUrl = m_activeViewContainer->url(); | 447 | newWindowUrl = m_activeViewContainer->url(); | ||
443 | } else if (list.count() == 1) { | 448 | } else if (list.count() == 1) { | ||
444 | const KFileItem& item = list.first(); | 449 | const KFileItem& item = list.first(); | ||
445 | newWindowUrl = DolphinView::openItemAsFolderUrl(item); | 450 | newWindowUrl = DolphinView::openItemAsFolderUrl(item); | ||
446 | } | 451 | } | ||
447 | 452 | | |||
448 | if (!newWindowUrl.isEmpty()) { | 453 | if (!newWindowUrl.isEmpty()) { | ||
449 | Dolphin::openNewWindow({newWindowUrl}, this); | 454 | Dolphin::openNewWindow({newWindowUrl}, this); | ||
450 | } | 455 | } | ||
451 | } | 456 | } | ||
452 | 457 | | |||
453 | void DolphinMainWindow::showTarget() | 458 | void DolphinMainWindow::showTarget() | ||
454 | { | 459 | { | ||
455 | const auto link = m_activeViewContainer->view()->selectedItems().at(0); | 460 | const auto link = selectedItems().at(0); | ||
456 | const auto linkLocationDir = QFileInfo(link.localPath()).absoluteDir(); | 461 | const auto linkLocationDir = QFileInfo(link.localPath()).absoluteDir(); | ||
457 | auto linkDestination = link.linkDest(); | 462 | auto linkDestination = link.linkDest(); | ||
458 | if (QFileInfo(linkDestination).isRelative()) { | 463 | if (QFileInfo(linkDestination).isRelative()) { | ||
459 | linkDestination = linkLocationDir.filePath(linkDestination); | 464 | linkDestination = linkLocationDir.filePath(linkDestination); | ||
460 | } | 465 | } | ||
461 | if (QFileInfo::exists(linkDestination)) { | 466 | if (QFileInfo::exists(linkDestination)) { | ||
462 | KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination).adjusted(QUrl::StripTrailingSlash)}); | 467 | KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination).adjusted(QUrl::StripTrailingSlash)}); | ||
463 | } else { | 468 | } else { | ||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Line(s) | |||||
638 | 643 | | |||
639 | void DolphinMainWindow::undo() | 644 | void DolphinMainWindow::undo() | ||
640 | { | 645 | { | ||
641 | clearStatusBar(); | 646 | clearStatusBar(); | ||
642 | KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this); | 647 | KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this); | ||
643 | KIO::FileUndoManager::self()->undo(); | 648 | KIO::FileUndoManager::self()->undo(); | ||
644 | } | 649 | } | ||
645 | 650 | | |||
646 | void DolphinMainWindow::cut() | 651 | KItemSet DolphinMainWindow::selectedItemSet() | ||
647 | { | 652 | { | ||
648 | m_activeViewContainer->view()->cutSelectedItems(); | 653 | return m_currentSelectionManager->selectedItems(); | ||
649 | } | 654 | } | ||
650 | 655 | | |||
651 | void DolphinMainWindow::copy() | | |||
652 | { | | |||
653 | m_activeViewContainer->view()->copySelectedItems(); | | |||
654 | } | | |||
655 | 656 | | |||
656 | void DolphinMainWindow::paste() | 657 | KFileItemList DolphinMainWindow::selectedItems() | ||
657 | { | 658 | { | ||
658 | m_activeViewContainer->view()->paste(); | 659 | KFileItemList selectedItems; | ||
660 | const auto items = selectedItemSet(); | ||||
661 | const auto model = qobject_cast<KFileItemModel *>(m_currentSelectionManager->model()); | ||||
662 | | ||||
663 | selectedItems.reserve(items.count()); | ||||
664 | for (int index : items) { | ||||
665 | selectedItems.append(model->fileItem(index)); | ||||
666 | } | ||||
667 | return selectedItems; | ||||
659 | } | 668 | } | ||
660 | 669 | | |||
661 | void DolphinMainWindow::find() | 670 | void DolphinMainWindow::find() | ||
662 | { | 671 | { | ||
663 | m_activeViewContainer->setSearchModeEnabled(true); | 672 | m_activeViewContainer->setSearchModeEnabled(true); | ||
664 | } | 673 | } | ||
665 | 674 | | |||
666 | void DolphinMainWindow::updateSearchAction() | 675 | void DolphinMainWindow::updateSearchAction() | ||
▲ Show 20 Lines • Show All 418 Lines • ▼ Show 20 Line(s) | 1091 | { | |||
1085 | newFileMenu()->setEnabled(isFolderWritable && m_activeViewContainer->url().scheme() != QLatin1String("trash")); | 1094 | newFileMenu()->setEnabled(isFolderWritable && m_activeViewContainer->url().scheme() != QLatin1String("trash")); | ||
1086 | } | 1095 | } | ||
1087 | 1096 | | |||
1088 | void DolphinMainWindow::openContextMenu(const QPoint& pos, | 1097 | void DolphinMainWindow::openContextMenu(const QPoint& pos, | ||
1089 | const KFileItem& item, | 1098 | const KFileItem& item, | ||
1090 | const QUrl& url, | 1099 | const QUrl& url, | ||
1091 | const QList<QAction*>& customActions) | 1100 | const QList<QAction*>& customActions) | ||
1092 | { | 1101 | { | ||
1093 | QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url); | 1102 | openContextMenuWithSelection(pos, item, url, customActions, activeViewContainer()->view()->selectionManager()); | ||
1103 | } | ||||
1104 | | ||||
1105 | void DolphinMainWindow::openContextMenuWithSelection(const QPoint& pos, | ||||
1106 | const KFileItem& item, | ||||
1107 | const QUrl& url, | ||||
1108 | const QList<QAction*>& customActions, | ||||
1109 | KItemListSelectionManager* selectionManager, | ||||
1110 | KFileItemListView* view) | ||||
1111 | { | ||||
1112 | m_currentSelectionManager = selectionManager; | ||||
1113 | updateFileAndEditActions(); | ||||
1114 | m_actionHandler->setCurrentSelectionManager(m_currentSelectionManager); | ||||
1115 | m_actionHandler->setCurrentItemListView(view); | ||||
1116 | | ||||
1117 | auto* model = qobject_cast<KFileItemModel *>(m_currentSelectionManager->model()); | ||||
1118 | KFileItemList list; | ||||
1119 | for (auto i : selectionManager->selectedItems()) { | ||||
1120 | list.append(model->fileItem(i)); | ||||
1121 | } | ||||
1122 | | ||||
1123 | QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url, list); | ||||
1094 | contextMenu.data()->setCustomActions(customActions); | 1124 | contextMenu.data()->setCustomActions(customActions); | ||
1095 | const DolphinContextMenu::Command command = contextMenu.data()->open(); | 1125 | const DolphinContextMenu::Command command = contextMenu.data()->open(); | ||
1096 | 1126 | | |||
1097 | switch (command) { | 1127 | switch (command) { | ||
1098 | case DolphinContextMenu::OpenParentFolder: | 1128 | case DolphinContextMenu::OpenParentFolder: | ||
1099 | changeUrl(KIO::upUrl(item.url())); | 1129 | changeUrl(KIO::upUrl(item.url())); | ||
1100 | m_activeViewContainer->view()->markUrlsAsSelected({item.url()}); | 1130 | m_activeViewContainer->view()->markUrlsAsSelected({item.url()}); | ||
1101 | m_activeViewContainer->view()->markUrlAsCurrent(item.url()); | 1131 | m_activeViewContainer->view()->markUrlAsCurrent(item.url()); | ||
Show All 11 Lines | |||||
1113 | default: | 1143 | default: | ||
1114 | break; | 1144 | break; | ||
1115 | } | 1145 | } | ||
1116 | 1146 | | |||
1117 | // Delete the menu, unless it has been deleted in its own nested event loop already. | 1147 | // Delete the menu, unless it has been deleted in its own nested event loop already. | ||
1118 | if (contextMenu) { | 1148 | if (contextMenu) { | ||
1119 | contextMenu->deleteLater(); | 1149 | contextMenu->deleteLater(); | ||
1120 | } | 1150 | } | ||
1151 | | ||||
1152 | m_currentSelectionManager = activeViewContainer()->view()->selectionManager(); | ||||
1153 | m_actionHandler->setCurrentSelectionManager(m_currentSelectionManager); | ||||
1154 | m_actionHandler->setCurrentItemListView(nullptr); | ||||
1121 | } | 1155 | } | ||
1122 | 1156 | | |||
1123 | void DolphinMainWindow::updateControlMenu() | 1157 | void DolphinMainWindow::updateControlMenu() | ||
1124 | { | 1158 | { | ||
1125 | QMenu* menu = qobject_cast<QMenu*>(sender()); | 1159 | QMenu* menu = qobject_cast<QMenu*>(sender()); | ||
1126 | Q_ASSERT(menu); | 1160 | Q_ASSERT(menu); | ||
1127 | 1161 | | |||
1128 | // All actions get cleared by QMenu::clear(). This includes the sub-menus | 1162 | // All actions get cleared by QMenu::clear(). This includes the sub-menus | ||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | |||||
1220 | } | 1254 | } | ||
1221 | 1255 | | |||
1222 | void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer) | 1256 | void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer) | ||
1223 | { | 1257 | { | ||
1224 | DolphinViewContainer* oldViewContainer = m_activeViewContainer; | 1258 | DolphinViewContainer* oldViewContainer = m_activeViewContainer; | ||
1225 | Q_ASSERT(viewContainer); | 1259 | Q_ASSERT(viewContainer); | ||
1226 | 1260 | | |||
1227 | m_activeViewContainer = viewContainer; | 1261 | m_activeViewContainer = viewContainer; | ||
1262 | m_currentSelectionManager = viewContainer->view()->selectionManager(); | ||||
1228 | 1263 | | |||
1229 | if (oldViewContainer) { | 1264 | if (oldViewContainer) { | ||
1230 | const QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search")); | 1265 | const QAction* toggleSearchAction = actionCollection()->action(QStringLiteral("toggle_search")); | ||
1231 | toggleSearchAction->disconnect(oldViewContainer); | 1266 | toggleSearchAction->disconnect(oldViewContainer); | ||
1232 | 1267 | | |||
1233 | // Disconnect all signals between the old view container (container, | 1268 | // Disconnect all signals between the old view container (container, | ||
1234 | // view and url navigator) and main window. | 1269 | // view and url navigator) and main window. | ||
1235 | oldViewContainer->disconnect(this); | 1270 | oldViewContainer->disconnect(this); | ||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 1333 | { | |||
1347 | // i18n: This will be the last paragraph for the whatsthis for all three: | 1382 | // i18n: This will be the last paragraph for the whatsthis for all three: | ||
1348 | // Cut, Copy and Paste | 1383 | // Cut, Copy and Paste | ||
1349 | const QString cutCopyPastePara = xi18nc("@info:whatsthis", "<para><emphasis>Cut, " | 1384 | const QString cutCopyPastePara = xi18nc("@info:whatsthis", "<para><emphasis>Cut, " | ||
1350 | "Copy</emphasis> and <emphasis>Paste</emphasis> work between many " | 1385 | "Copy</emphasis> and <emphasis>Paste</emphasis> work between many " | ||
1351 | "applications and are among the most used commands. That's why their " | 1386 | "applications and are among the most used commands. That's why their " | ||
1352 | "<emphasis>keyboard shortcuts</emphasis> are prominently placed right " | 1387 | "<emphasis>keyboard shortcuts</emphasis> are prominently placed right " | ||
1353 | "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, " | 1388 | "next to each other on the keyboard: <shortcut>Ctrl+X</shortcut>, " | ||
1354 | "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>"); | 1389 | "<shortcut>Ctrl+C</shortcut> and <shortcut>Ctrl+V</shortcut>.</para>"); | ||
1355 | QAction* cutAction = KStandardAction::cut(this, &DolphinMainWindow::cut, actionCollection()); | 1390 | QAction* cutAction = KStandardAction::cut(m_actionHandler, &DolphinViewActionHandler::cut, actionCollection()); | ||
1356 | cutAction->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items " | 1391 | cutAction->setWhatsThis(xi18nc("@info:whatsthis cut", "This copies the items " | ||
1357 | "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>" | 1392 | "in your current selection to the <emphasis>clipboard</emphasis>.<nl/>" | ||
1358 | "Use the <emphasis>Paste</emphasis> action afterwards to copy them from " | 1393 | "Use the <emphasis>Paste</emphasis> action afterwards to copy them from " | ||
1359 | "the clipboard to a new location. The items will be removed from their " | 1394 | "the clipboard to a new location. The items will be removed from their " | ||
1360 | "initial location.") + cutCopyPastePara); | 1395 | "initial location.") + cutCopyPastePara); | ||
1361 | QAction* copyAction = KStandardAction::copy(this, &DolphinMainWindow::copy, actionCollection()); | 1396 | QAction* copyAction = KStandardAction::copy(m_actionHandler, &DolphinViewActionHandler::copy, actionCollection()); | ||
1362 | copyAction->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the " | 1397 | copyAction->setWhatsThis(xi18nc("@info:whatsthis copy", "This copies the " | ||
1363 | "items in your current selection to the <emphasis>clipboard</emphasis>." | 1398 | "items in your current selection to the <emphasis>clipboard</emphasis>." | ||
1364 | "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them " | 1399 | "<nl/>Use the <emphasis>Paste</emphasis> action afterwards to copy them " | ||
1365 | "from the clipboard to a new location.") + cutCopyPastePara); | 1400 | "from the clipboard to a new location.") + cutCopyPastePara); | ||
1366 | QAction* paste = KStandardAction::paste(this, &DolphinMainWindow::paste, actionCollection()); | 1401 | QAction* paste = KStandardAction::paste(m_actionHandler, &DolphinViewActionHandler::paste, actionCollection()); | ||
1367 | // The text of the paste-action is modified dynamically by Dolphin | 1402 | // The text of the paste-action is modified dynamically by Dolphin | ||
1368 | // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes | 1403 | // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes | ||
1369 | // due to the long text, the text "Paste" is used: | 1404 | // due to the long text, the text "Paste" is used: | ||
1370 | paste->setIconText(i18nc("@action:inmenu Edit", "Paste")); | 1405 | paste->setIconText(i18nc("@action:inmenu Edit", "Paste")); | ||
1371 | paste->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from " | 1406 | paste->setWhatsThis(xi18nc("@info:whatsthis paste", "This copies the items from " | ||
1372 | "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>" | 1407 | "your <emphasis>clipboard</emphasis> to the currently viewed folder.<nl/>" | ||
1373 | "If the items were added to the clipboard by the <emphasis>Cut</emphasis> " | 1408 | "If the items were added to the clipboard by the <emphasis>Cut</emphasis> " | ||
1374 | "action they are removed from their old location.") + cutCopyPastePara); | 1409 | "action they are removed from their old location.") + cutCopyPastePara); | ||
▲ Show 20 Lines • Show All 361 Lines • ▼ Show 20 Line(s) | 1750 | #endif | |||
1736 | connect(this, &DolphinMainWindow::urlChanged, | 1771 | connect(this, &DolphinMainWindow::urlChanged, | ||
1737 | foldersPanel, &FoldersPanel::setUrl); | 1772 | foldersPanel, &FoldersPanel::setUrl); | ||
1738 | connect(foldersPanel, &FoldersPanel::folderActivated, | 1773 | connect(foldersPanel, &FoldersPanel::folderActivated, | ||
1739 | this, &DolphinMainWindow::changeUrl); | 1774 | this, &DolphinMainWindow::changeUrl); | ||
1740 | connect(foldersPanel, &FoldersPanel::folderMiddleClicked, | 1775 | connect(foldersPanel, &FoldersPanel::folderMiddleClicked, | ||
1741 | this, &DolphinMainWindow::openNewTabAfterCurrentTab); | 1776 | this, &DolphinMainWindow::openNewTabAfterCurrentTab); | ||
1742 | connect(foldersPanel, &FoldersPanel::errorMessage, | 1777 | connect(foldersPanel, &FoldersPanel::errorMessage, | ||
1743 | this, &DolphinMainWindow::showErrorMessage); | 1778 | this, &DolphinMainWindow::showErrorMessage); | ||
1779 | connect(foldersPanel, &FoldersPanel::requestOpenContextMenu, | ||||
1780 | this, &DolphinMainWindow::openContextMenuWithSelection); | ||||
1781 | connect(foldersPanel, &FoldersPanel::focused, | ||||
1782 | this, [=] (){ | ||||
1783 | m_currentSelectionManager = foldersPanel->selectionManager(); | ||||
1784 | m_actionHandler->setCurrentSelectionManager(m_currentSelectionManager); | ||||
1785 | m_actionHandler->setCurrentItemListView(foldersPanel->view()); | ||||
1786 | }); | ||||
1787 | connect(foldersPanel, &FoldersPanel::focusedOut, | ||||
1788 | this, [=] (){ | ||||
1789 | m_currentSelectionManager = m_activeViewContainer->view()->selectionManager(); | ||||
1790 | m_actionHandler->setCurrentSelectionManager(m_currentSelectionManager); | ||||
1791 | m_actionHandler->setCurrentItemListView(nullptr); | ||||
1792 | }); | ||||
1744 | 1793 | | |||
1745 | actionCollection()->action(QStringLiteral("show_folders_panel")) | 1794 | actionCollection()->action(QStringLiteral("show_folders_panel")) | ||
1746 | ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the " | 1795 | ->setWhatsThis(xi18nc("@info:whatsthis", "This toggles the " | ||
1747 | "<emphasis>folders</emphasis> panel at the left side of the window." | 1796 | "<emphasis>folders</emphasis> panel at the left side of the window." | ||
1748 | "<nl/><nl/>It shows the folders of the <emphasis>file system" | 1797 | "<nl/><nl/>It shows the folders of the <emphasis>file system" | ||
1749 | "</emphasis> in a <emphasis>tree view</emphasis>.")); | 1798 | "</emphasis> in a <emphasis>tree view</emphasis>.")); | ||
1750 | foldersDock->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel " | 1799 | foldersDock->setWhatsThis(xi18nc("@info:whatsthis", "<para>This panel " | ||
1751 | "shows the folders of the <emphasis>file system</emphasis> in a " | 1800 | "shows the folders of the <emphasis>file system</emphasis> in a " | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 1933 | #endif | |||
1891 | connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{ | 1940 | connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{ | ||
1892 | actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount()); | 1941 | actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount()); | ||
1893 | }); | 1942 | }); | ||
1894 | } | 1943 | } | ||
1895 | 1944 | | |||
1896 | 1945 | | |||
1897 | void DolphinMainWindow::updateFileAndEditActions() | 1946 | void DolphinMainWindow::updateFileAndEditActions() | ||
1898 | { | 1947 | { | ||
1899 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | 1948 | const KFileItemList list = selectedItems(); | ||
1900 | const KActionCollection* col = actionCollection(); | 1949 | const KActionCollection* col = actionCollection(); | ||
1901 | QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places")); | 1950 | QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places")); | ||
1902 | 1951 | | |||
1903 | if (list.isEmpty()) { | 1952 | if (list.isEmpty()) { | ||
1904 | stateChanged(QStringLiteral("has_no_selection")); | 1953 | stateChanged(QStringLiteral("has_no_selection")); | ||
1905 | 1954 | | |||
1906 | addToPlacesAction->setEnabled(true); | 1955 | addToPlacesAction->setEnabled(true); | ||
1907 | } else { | 1956 | } else { | ||
▲ Show 20 Lines • Show All 455 Lines • Show Last 20 Lines |