Changeset View
Changeset View
Standalone View
Standalone View
src/dolphinmainwindow.cpp
Show All 26 Lines | |||||
27 | #include "dolphindockwidget.h" | 27 | #include "dolphindockwidget.h" | ||
28 | #include "dolphincontextmenu.h" | 28 | #include "dolphincontextmenu.h" | ||
29 | #include "dolphinnewfilemenu.h" | 29 | #include "dolphinnewfilemenu.h" | ||
30 | #include "dolphinrecenttabsmenu.h" | 30 | #include "dolphinrecenttabsmenu.h" | ||
31 | #include "dolphinviewcontainer.h" | 31 | #include "dolphinviewcontainer.h" | ||
32 | #include "dolphintabpage.h" | 32 | #include "dolphintabpage.h" | ||
33 | #include "middleclickactioneventfilter.h" | 33 | #include "middleclickactioneventfilter.h" | ||
34 | #include "panels/folders/folderspanel.h" | 34 | #include "panels/folders/folderspanel.h" | ||
35 | #include "panels/places/placesitemmodel.h" | ||||
35 | #include "panels/places/placespanel.h" | 36 | #include "panels/places/placespanel.h" | ||
36 | #include "panels/information/informationpanel.h" | 37 | #include "panels/information/informationpanel.h" | ||
37 | #include "panels/terminal/terminalpanel.h" | 38 | #include "panels/terminal/terminalpanel.h" | ||
38 | #include "settings/dolphinsettingsdialog.h" | 39 | #include "settings/dolphinsettingsdialog.h" | ||
39 | #include "statusbar/dolphinstatusbar.h" | 40 | #include "statusbar/dolphinstatusbar.h" | ||
40 | #include "views/dolphinviewactionhandler.h" | 41 | #include "views/dolphinviewactionhandler.h" | ||
41 | #include "views/dolphinremoteencoding.h" | 42 | #include "views/dolphinremoteencoding.h" | ||
42 | #include "views/draganddrophelper.h" | 43 | #include "views/draganddrophelper.h" | ||
▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Line(s) | 267 | { | |||
267 | if (!KProtocolManager::supportsListing(url)) { | 268 | if (!KProtocolManager::supportsListing(url)) { | ||
268 | // The URL navigator only checks for validity, not | 269 | // The URL navigator only checks for validity, not | ||
269 | // if the URL can be listed. An error message is | 270 | // if the URL can be listed. An error message is | ||
270 | // shown due to DolphinViewContainer::restoreView(). | 271 | // shown due to DolphinViewContainer::restoreView(). | ||
271 | return; | 272 | return; | ||
272 | } | 273 | } | ||
273 | 274 | | |||
274 | m_activeViewContainer->setUrl(url); | 275 | m_activeViewContainer->setUrl(url); | ||
275 | updateEditActions(); | 276 | updateFileAndEditActions(); | ||
276 | updatePasteAction(); | 277 | updatePasteAction(); | ||
277 | updateViewActions(); | 278 | updateViewActions(); | ||
278 | updateGoActions(); | 279 | updateGoActions(); | ||
279 | 280 | | |||
280 | emit urlChanged(url); | 281 | emit urlChanged(url); | ||
281 | } | 282 | } | ||
282 | 283 | | |||
283 | void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url) | 284 | void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url) | ||
Show All 12 Lines | |||||
296 | { | 297 | { | ||
297 | KToggleAction* editableLocationAction = | 298 | KToggleAction* editableLocationAction = | ||
298 | static_cast<KToggleAction*>(actionCollection()->action(QStringLiteral("editable_location"))); | 299 | static_cast<KToggleAction*>(actionCollection()->action(QStringLiteral("editable_location"))); | ||
299 | editableLocationAction->setChecked(editable); | 300 | editableLocationAction->setChecked(editable); | ||
300 | } | 301 | } | ||
301 | 302 | | |||
302 | void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) | 303 | void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) | ||
303 | { | 304 | { | ||
304 | updateEditActions(); | 305 | updateFileAndEditActions(); | ||
305 | 306 | | |||
306 | const int selectedUrlsCount = m_tabWidget->currentTabPage()->selectedItemsCount(); | 307 | const int selectedUrlsCount = m_tabWidget->currentTabPage()->selectedItemsCount(); | ||
307 | 308 | | |||
308 | QAction* compareFilesAction = actionCollection()->action(QStringLiteral("compare_files")); | 309 | QAction* compareFilesAction = actionCollection()->action(QStringLiteral("compare_files")); | ||
309 | if (selectedUrlsCount == 2) { | 310 | if (selectedUrlsCount == 2) { | ||
310 | compareFilesAction->setEnabled(isKompareInstalled()); | 311 | compareFilesAction->setEnabled(isKompareInstalled()); | ||
311 | } else { | 312 | } else { | ||
312 | compareFilesAction->setEnabled(false); | 313 | compareFilesAction->setEnabled(false); | ||
Show All 34 Lines | 347 | { | |||
347 | Dolphin::openNewWindow({m_activeViewContainer->url()}, this); | 348 | Dolphin::openNewWindow({m_activeViewContainer->url()}, this); | ||
348 | } | 349 | } | ||
349 | 350 | | |||
350 | void DolphinMainWindow::openNewActivatedTab() | 351 | void DolphinMainWindow::openNewActivatedTab() | ||
351 | { | 352 | { | ||
352 | m_tabWidget->openNewActivatedTab(); | 353 | m_tabWidget->openNewActivatedTab(); | ||
353 | } | 354 | } | ||
354 | 355 | | |||
356 | void DolphinMainWindow::addToPlaces() | ||||
357 | { | ||||
358 | QUrl url; | ||||
359 | QString name; | ||||
360 | | ||||
361 | // If nothing is selected, act on the current dir | ||||
362 | if (m_activeViewContainer->view()->selectedItems().count() == 0) { | ||||
363 | url = m_activeViewContainer->url(); | ||||
364 | name = m_activeViewContainer->placesText(); | ||||
365 | } else { | ||||
366 | const auto dirToAdd = m_activeViewContainer->view()->selectedItems().first(); | ||||
367 | url = dirToAdd.url(); | ||||
368 | name = dirToAdd.name(); | ||||
369 | } | ||||
370 | if (url.isValid()) { | ||||
371 | PlacesItemModel model; | ||||
372 | QString icon; | ||||
373 | if (m_activeViewContainer->isSearchModeEnabled()) { | ||||
374 | icon = QStringLiteral("folder-saved-search-symbolic"); | ||||
375 | } else { | ||||
376 | icon = KIO::iconNameForUrl(url); | ||||
377 | } | ||||
378 | model.createPlacesItem(name, url, icon); | ||||
379 | } | ||||
380 | } | ||||
381 | | ||||
355 | void DolphinMainWindow::openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement) | 382 | void DolphinMainWindow::openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement) | ||
356 | { | 383 | { | ||
357 | m_tabWidget->openNewTab(url, QUrl(), tabPlacement); | 384 | m_tabWidget->openNewTab(url, QUrl(), tabPlacement); | ||
358 | } | 385 | } | ||
359 | 386 | | |||
360 | void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl& url) | 387 | void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl& url) | ||
361 | { | 388 | { | ||
362 | m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab); | 389 | m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab); | ||
▲ Show 20 Lines • Show All 732 Lines • ▼ Show 20 Line(s) | 1121 | connect(oldViewContainer->view(), &DolphinView::requestItemInfo, | |||
1095 | this, &DolphinMainWindow::requestItemInfo); | 1122 | this, &DolphinMainWindow::requestItemInfo); | ||
1096 | } | 1123 | } | ||
1097 | 1124 | | |||
1098 | connectViewSignals(viewContainer); | 1125 | connectViewSignals(viewContainer); | ||
1099 | 1126 | | |||
1100 | m_actionHandler->setCurrentView(viewContainer->view()); | 1127 | m_actionHandler->setCurrentView(viewContainer->view()); | ||
1101 | 1128 | | |||
1102 | updateHistory(); | 1129 | updateHistory(); | ||
1103 | updateEditActions(); | 1130 | updateFileAndEditActions(); | ||
1104 | updatePasteAction(); | 1131 | updatePasteAction(); | ||
1105 | updateViewActions(); | 1132 | updateViewActions(); | ||
1106 | updateGoActions(); | 1133 | updateGoActions(); | ||
1107 | 1134 | | |||
1108 | const QUrl url = viewContainer->url(); | 1135 | const QUrl url = viewContainer->url(); | ||
1109 | emit urlChanged(url); | 1136 | emit urlChanged(url); | ||
1110 | } | 1137 | } | ||
1111 | 1138 | | |||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 1174 | { | |||
1166 | newTab->setText(i18nc("@action:inmenu File", "New Tab")); | 1193 | newTab->setText(i18nc("@action:inmenu File", "New Tab")); | ||
1167 | newTab->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new " | 1194 | newTab->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new " | ||
1168 | "<emphasis>Tab</emphasis> with the current location and view.<nl/>" | 1195 | "<emphasis>Tab</emphasis> with the current location and view.<nl/>" | ||
1169 | "A tab is an additional view within this window. " | 1196 | "A tab is an additional view within this window. " | ||
1170 | "You can drag and drop items between tabs.")); | 1197 | "You can drag and drop items between tabs.")); | ||
1171 | actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N}); | 1198 | actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N}); | ||
1172 | connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab); | 1199 | connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab); | ||
1173 | 1200 | | |||
1201 | QAction* addToPlaces = actionCollection()->addAction(QStringLiteral("add_to_places")); | ||||
1202 | addToPlaces->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new"))); | ||||
1203 | addToPlaces->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder" | ||||
1204 | "to the Places panel.")); | ||||
1205 | connect(addToPlaces, &QAction::triggered, this, &DolphinMainWindow::addToPlaces); | ||||
1206 | | ||||
1174 | QAction* closeTab = KStandardAction::close(m_tabWidget, QOverload<>::of(&DolphinTabWidget::closeTab), actionCollection()); | 1207 | QAction* closeTab = KStandardAction::close(m_tabWidget, QOverload<>::of(&DolphinTabWidget::closeTab), actionCollection()); | ||
1175 | closeTab->setText(i18nc("@action:inmenu File", "Close Tab")); | 1208 | closeTab->setText(i18nc("@action:inmenu File", "Close Tab")); | ||
1176 | closeTab->setWhatsThis(i18nc("@info:whatsthis", "This closes the " | 1209 | closeTab->setWhatsThis(i18nc("@info:whatsthis", "This closes the " | ||
1177 | "currently viewed tab. If no more tabs are left this window " | 1210 | "currently viewed tab. If no more tabs are left this window " | ||
1178 | "will close instead.")); | 1211 | "will close instead.")); | ||
1179 | 1212 | | |||
1180 | QAction* quitAction = KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection()); | 1213 | QAction* quitAction = KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection()); | ||
1181 | quitAction->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window.")); | 1214 | quitAction->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window.")); | ||
▲ Show 20 Lines • Show All 472 Lines • ▼ Show 20 Line(s) | 1683 | #endif | |||
1654 | panelsMenu->addAction(actionShowAllPlaces); | 1687 | panelsMenu->addAction(actionShowAllPlaces); | ||
1655 | panelsMenu->addAction(lockLayoutAction); | 1688 | panelsMenu->addAction(lockLayoutAction); | ||
1656 | 1689 | | |||
1657 | connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{ | 1690 | connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{ | ||
1658 | actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount()); | 1691 | actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount()); | ||
1659 | }); | 1692 | }); | ||
1660 | } | 1693 | } | ||
1661 | 1694 | | |||
1662 | void DolphinMainWindow::updateEditActions() | 1695 | | ||
1696 | void DolphinMainWindow::updateFileAndEditActions() | ||||
1663 | { | 1697 | { | ||
1664 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | 1698 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | ||
1699 | const KActionCollection* col = actionCollection(); | ||||
1700 | QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places")); | ||||
1701 | | ||||
1665 | if (list.isEmpty()) { | 1702 | if (list.isEmpty()) { | ||
1666 | stateChanged(QStringLiteral("has_no_selection")); | 1703 | stateChanged(QStringLiteral("has_no_selection")); | ||
1704 | | ||||
1705 | addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", m_activeViewContainer->placesText())); | ||||
1667 | } else { | 1706 | } else { | ||
1668 | stateChanged(QStringLiteral("has_selection")); | 1707 | stateChanged(QStringLiteral("has_selection")); | ||
1669 | 1708 | | |||
1670 | KActionCollection* col = actionCollection(); | | |||
1671 | QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile)); | 1709 | QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile)); | ||
1672 | QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash)); | 1710 | QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash)); | ||
1673 | QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile)); | 1711 | QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile)); | ||
1674 | QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut)); | 1712 | QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut)); | ||
1675 | QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler | 1713 | QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler | ||
1676 | QAction* showTarget = col->action(QStringLiteral("show_target")); | 1714 | QAction* showTarget = col->action(QStringLiteral("show_target")); | ||
1677 | 1715 | | |||
1716 | if (list.length() == 1 && list.first().isDir()) { | ||||
1717 | addToPlacesAction->setEnabled(true); | ||||
1718 | addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", list.first().name())); | ||||
1719 | } else { | ||||
1720 | addToPlacesAction->setEnabled(false); | ||||
1721 | addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places")); | ||||
1722 | } | ||||
1723 | | ||||
1678 | KFileItemListProperties capabilities(list); | 1724 | KFileItemListProperties capabilities(list); | ||
1679 | const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); | 1725 | const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); | ||
1680 | 1726 | | |||
1681 | renameAction->setEnabled(capabilities.supportsMoving()); | 1727 | renameAction->setEnabled(capabilities.supportsMoving()); | ||
1682 | moveToTrashAction->setEnabled(enableMoveToTrash); | 1728 | moveToTrashAction->setEnabled(enableMoveToTrash); | ||
1683 | deleteAction->setEnabled(capabilities.supportsDeleting()); | 1729 | deleteAction->setEnabled(capabilities.supportsDeleting()); | ||
1684 | deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash); | 1730 | deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash); | ||
1685 | cutAction->setEnabled(capabilities.supportsMoving()); | 1731 | cutAction->setEnabled(capabilities.supportsMoving()); | ||
▲ Show 20 Lines • Show All 413 Lines • Show Last 20 Lines |