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 | const auto dirToAdd = m_activeViewContainer->view()->selectedItems().first(); | ||||
359 | const QUrl url = dirToAdd.url(); | ||||
360 | const QString name = dirToAdd.name(); | ||||
361 | if (url.isValid()) { | ||||
362 | PlacesItemModel model; | ||||
363 | QString icon; | ||||
364 | if (m_activeViewContainer->isSearchModeEnabled()) { | ||||
365 | icon = QStringLiteral("folder-saved-search-symbolic"); | ||||
366 | } else { | ||||
367 | icon = KIO::iconNameForUrl(url); | ||||
368 | } | ||||
369 | model.createPlacesItem(name, url, icon); | ||||
370 | } | ||||
371 | } | ||||
372 | | ||||
355 | void DolphinMainWindow::openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement) | 373 | void DolphinMainWindow::openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement) | ||
356 | { | 374 | { | ||
357 | m_tabWidget->openNewTab(url, QUrl(), tabPlacement); | 375 | m_tabWidget->openNewTab(url, QUrl(), tabPlacement); | ||
358 | } | 376 | } | ||
359 | 377 | | |||
360 | void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl& url) | 378 | void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl& url) | ||
361 | { | 379 | { | ||
362 | m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab); | 380 | m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab); | ||
▲ Show 20 Lines • Show All 732 Lines • ▼ Show 20 Line(s) | 1112 | connect(oldViewContainer->view(), &DolphinView::requestItemInfo, | |||
1095 | this, &DolphinMainWindow::requestItemInfo); | 1113 | this, &DolphinMainWindow::requestItemInfo); | ||
1096 | } | 1114 | } | ||
1097 | 1115 | | |||
1098 | connectViewSignals(viewContainer); | 1116 | connectViewSignals(viewContainer); | ||
1099 | 1117 | | |||
1100 | m_actionHandler->setCurrentView(viewContainer->view()); | 1118 | m_actionHandler->setCurrentView(viewContainer->view()); | ||
1101 | 1119 | | |||
1102 | updateHistory(); | 1120 | updateHistory(); | ||
1103 | updateEditActions(); | 1121 | updateFileAndEditActions(); | ||
1104 | updatePasteAction(); | 1122 | updatePasteAction(); | ||
1105 | updateViewActions(); | 1123 | updateViewActions(); | ||
1106 | updateGoActions(); | 1124 | updateGoActions(); | ||
1107 | 1125 | | |||
1108 | const QUrl url = viewContainer->url(); | 1126 | const QUrl url = viewContainer->url(); | ||
1109 | emit urlChanged(url); | 1127 | emit urlChanged(url); | ||
1110 | } | 1128 | } | ||
1111 | 1129 | | |||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 1165 | { | |||
1166 | newTab->setText(i18nc("@action:inmenu File", "New Tab")); | 1184 | newTab->setText(i18nc("@action:inmenu File", "New Tab")); | ||
1167 | newTab->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new " | 1185 | newTab->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new " | ||
1168 | "<emphasis>Tab</emphasis> with the current location and view.<nl/>" | 1186 | "<emphasis>Tab</emphasis> with the current location and view.<nl/>" | ||
1169 | "A tab is an additional view within this window. " | 1187 | "A tab is an additional view within this window. " | ||
1170 | "You can drag and drop items between tabs.")); | 1188 | "You can drag and drop items between tabs.")); | ||
1171 | actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N}); | 1189 | actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N}); | ||
1172 | connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab); | 1190 | connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab); | ||
1173 | 1191 | | |||
1192 | QAction* addToPlaces = actionCollection()->addAction(QStringLiteral("add_to_places")); | ||||
1193 | addToPlaces->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new"))); | ||||
1194 | addToPlaces->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places")); | ||||
1195 | addToPlaces->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder" | ||||
1196 | "to the Places panel.")); | ||||
1197 | addToPlaces->setEnabled(false); // will be conditionally enabled later | ||||
1198 | connect(addToPlaces, &QAction::triggered, this, &DolphinMainWindow::addToPlaces); | ||||
1199 | | ||||
1174 | QAction* closeTab = KStandardAction::close(m_tabWidget, QOverload<>::of(&DolphinTabWidget::closeTab), actionCollection()); | 1200 | QAction* closeTab = KStandardAction::close(m_tabWidget, QOverload<>::of(&DolphinTabWidget::closeTab), actionCollection()); | ||
1175 | closeTab->setText(i18nc("@action:inmenu File", "Close Tab")); | 1201 | closeTab->setText(i18nc("@action:inmenu File", "Close Tab")); | ||
1176 | closeTab->setWhatsThis(i18nc("@info:whatsthis", "This closes the " | 1202 | closeTab->setWhatsThis(i18nc("@info:whatsthis", "This closes the " | ||
1177 | "currently viewed tab. If no more tabs are left this window " | 1203 | "currently viewed tab. If no more tabs are left this window " | ||
1178 | "will close instead.")); | 1204 | "will close instead.")); | ||
1179 | 1205 | | |||
1180 | QAction* quitAction = KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection()); | 1206 | QAction* quitAction = KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection()); | ||
1181 | quitAction->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window.")); | 1207 | quitAction->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window.")); | ||
▲ Show 20 Lines • Show All 472 Lines • ▼ Show 20 Line(s) | 1676 | #endif | |||
1654 | panelsMenu->addAction(actionShowAllPlaces); | 1680 | panelsMenu->addAction(actionShowAllPlaces); | ||
1655 | panelsMenu->addAction(lockLayoutAction); | 1681 | panelsMenu->addAction(lockLayoutAction); | ||
1656 | 1682 | | |||
1657 | connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{ | 1683 | connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{ | ||
1658 | actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount()); | 1684 | actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount()); | ||
1659 | }); | 1685 | }); | ||
1660 | } | 1686 | } | ||
1661 | 1687 | | |||
1662 | void DolphinMainWindow::updateEditActions() | 1688 | | ||
1689 | void DolphinMainWindow::updateFileAndEditActions() | ||||
1663 | { | 1690 | { | ||
1664 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | 1691 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | ||
1665 | if (list.isEmpty()) { | 1692 | if (list.isEmpty()) { | ||
1666 | stateChanged(QStringLiteral("has_no_selection")); | 1693 | stateChanged(QStringLiteral("has_no_selection")); | ||
1667 | } else { | 1694 | } else { | ||
1668 | stateChanged(QStringLiteral("has_selection")); | 1695 | stateChanged(QStringLiteral("has_selection")); | ||
1669 | 1696 | | |||
1670 | KActionCollection* col = actionCollection(); | 1697 | KActionCollection* col = actionCollection(); | ||
1671 | QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile)); | 1698 | QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile)); | ||
1672 | QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash)); | 1699 | QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash)); | ||
1673 | QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile)); | 1700 | QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile)); | ||
1674 | QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut)); | 1701 | QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut)); | ||
1675 | QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler | 1702 | QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler | ||
1676 | QAction* showTarget = col->action(QStringLiteral("show_target")); | 1703 | QAction* showTarget = col->action(QStringLiteral("show_target")); | ||
1704 | QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places")); | ||||
1677 | 1705 | | |||
1678 | KFileItemListProperties capabilities(list); | 1706 | KFileItemListProperties capabilities(list); | ||
1679 | const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); | 1707 | const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); | ||
1680 | 1708 | | |||
1681 | renameAction->setEnabled(capabilities.supportsMoving()); | 1709 | renameAction->setEnabled(capabilities.supportsMoving()); | ||
1682 | moveToTrashAction->setEnabled(enableMoveToTrash); | 1710 | moveToTrashAction->setEnabled(enableMoveToTrash); | ||
1683 | deleteAction->setEnabled(capabilities.supportsDeleting()); | 1711 | deleteAction->setEnabled(capabilities.supportsDeleting()); | ||
1684 | deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash); | 1712 | deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash); | ||
1685 | cutAction->setEnabled(capabilities.supportsMoving()); | 1713 | cutAction->setEnabled(capabilities.supportsMoving()); | ||
1686 | showTarget->setEnabled(list.length() == 1 && list.at(0).isLink()); | 1714 | showTarget->setEnabled(list.length() == 1 && list.at(0).isLink()); | ||
1715 | addToPlacesAction->setEnabled(list.length() == 1 && list.at(0).isDir()); | ||||
1687 | } | 1716 | } | ||
1688 | } | 1717 | } | ||
1689 | 1718 | | |||
1690 | void DolphinMainWindow::updateViewActions() | 1719 | void DolphinMainWindow::updateViewActions() | ||
1691 | { | 1720 | { | ||
1692 | m_actionHandler->updateViewActions(); | 1721 | m_actionHandler->updateViewActions(); | ||
1693 | 1722 | | |||
1694 | QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar")); | 1723 | QAction* showFilterBarAction = actionCollection()->action(QStringLiteral("show_filter_bar")); | ||
▲ Show 20 Lines • Show All 404 Lines • Show Last 20 Lines |