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 741 Lines • ▼ Show 20 Line(s) | 1130 | connect(oldViewContainer->view(), &DolphinView::requestItemInfo, | |||
1104 | this, &DolphinMainWindow::requestItemInfo); | 1131 | this, &DolphinMainWindow::requestItemInfo); | ||
1105 | } | 1132 | } | ||
1106 | 1133 | | |||
1107 | connectViewSignals(viewContainer); | 1134 | connectViewSignals(viewContainer); | ||
1108 | 1135 | | |||
1109 | m_actionHandler->setCurrentView(viewContainer->view()); | 1136 | m_actionHandler->setCurrentView(viewContainer->view()); | ||
1110 | 1137 | | |||
1111 | updateHistory(); | 1138 | updateHistory(); | ||
1112 | updateEditActions(); | 1139 | updateFileAndEditActions(); | ||
1113 | updatePasteAction(); | 1140 | updatePasteAction(); | ||
1114 | updateViewActions(); | 1141 | updateViewActions(); | ||
1115 | updateGoActions(); | 1142 | updateGoActions(); | ||
1116 | updateSearchAction(); | 1143 | updateSearchAction(); | ||
1117 | 1144 | | |||
1118 | const QUrl url = viewContainer->url(); | 1145 | const QUrl url = viewContainer->url(); | ||
1119 | emit urlChanged(url); | 1146 | emit urlChanged(url); | ||
1120 | } | 1147 | } | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 1184 | { | |||
1177 | newTab->setText(i18nc("@action:inmenu File", "New Tab")); | 1204 | newTab->setText(i18nc("@action:inmenu File", "New Tab")); | ||
1178 | newTab->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new " | 1205 | newTab->setWhatsThis(xi18nc("@info:whatsthis", "This opens a new " | ||
1179 | "<emphasis>Tab</emphasis> with the current location and view.<nl/>" | 1206 | "<emphasis>Tab</emphasis> with the current location and view.<nl/>" | ||
1180 | "A tab is an additional view within this window. " | 1207 | "A tab is an additional view within this window. " | ||
1181 | "You can drag and drop items between tabs.")); | 1208 | "You can drag and drop items between tabs.")); | ||
1182 | actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N}); | 1209 | actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N}); | ||
1183 | connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab); | 1210 | connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab); | ||
1184 | 1211 | | |||
1212 | QAction* addToPlaces = actionCollection()->addAction(QStringLiteral("add_to_places")); | ||||
1213 | addToPlaces->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new"))); | ||||
1214 | addToPlaces->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder" | ||||
1215 | "to the Places panel.")); | ||||
1216 | connect(addToPlaces, &QAction::triggered, this, &DolphinMainWindow::addToPlaces); | ||||
1217 | | ||||
1185 | QAction* closeTab = KStandardAction::close(m_tabWidget, QOverload<>::of(&DolphinTabWidget::closeTab), actionCollection()); | 1218 | QAction* closeTab = KStandardAction::close(m_tabWidget, QOverload<>::of(&DolphinTabWidget::closeTab), actionCollection()); | ||
1186 | closeTab->setText(i18nc("@action:inmenu File", "Close Tab")); | 1219 | closeTab->setText(i18nc("@action:inmenu File", "Close Tab")); | ||
1187 | closeTab->setWhatsThis(i18nc("@info:whatsthis", "This closes the " | 1220 | closeTab->setWhatsThis(i18nc("@info:whatsthis", "This closes the " | ||
1188 | "currently viewed tab. If no more tabs are left this window " | 1221 | "currently viewed tab. If no more tabs are left this window " | ||
1189 | "will close instead.")); | 1222 | "will close instead.")); | ||
1190 | 1223 | | |||
1191 | QAction* quitAction = KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection()); | 1224 | QAction* quitAction = KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection()); | ||
1192 | quitAction->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window.")); | 1225 | quitAction->setWhatsThis(i18nc("@info:whatsthis quit", "This closes this window.")); | ||
▲ Show 20 Lines • Show All 483 Lines • ▼ Show 20 Line(s) | 1705 | #endif | |||
1676 | panelsMenu->addAction(actionShowAllPlaces); | 1709 | panelsMenu->addAction(actionShowAllPlaces); | ||
1677 | panelsMenu->addAction(lockLayoutAction); | 1710 | panelsMenu->addAction(lockLayoutAction); | ||
1678 | 1711 | | |||
1679 | connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{ | 1712 | connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{ | ||
1680 | actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount()); | 1713 | actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount()); | ||
1681 | }); | 1714 | }); | ||
1682 | } | 1715 | } | ||
1683 | 1716 | | |||
1684 | void DolphinMainWindow::updateEditActions() | 1717 | | ||
1718 | void DolphinMainWindow::updateFileAndEditActions() | ||||
1685 | { | 1719 | { | ||
1686 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | 1720 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | ||
1721 | const KActionCollection* col = actionCollection(); | ||||
1722 | QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places")); | ||||
1723 | | ||||
1687 | if (list.isEmpty()) { | 1724 | if (list.isEmpty()) { | ||
1688 | stateChanged(QStringLiteral("has_no_selection")); | 1725 | stateChanged(QStringLiteral("has_no_selection")); | ||
1726 | | ||||
1727 | addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", m_activeViewContainer->placesText())); | ||||
1689 | } else { | 1728 | } else { | ||
1690 | stateChanged(QStringLiteral("has_selection")); | 1729 | stateChanged(QStringLiteral("has_selection")); | ||
1691 | 1730 | | |||
1692 | KActionCollection* col = actionCollection(); | | |||
1693 | QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile)); | 1731 | QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile)); | ||
1694 | QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash)); | 1732 | QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash)); | ||
1695 | QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile)); | 1733 | QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile)); | ||
1696 | QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut)); | 1734 | QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut)); | ||
1697 | QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler | 1735 | QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler | ||
1698 | QAction* showTarget = col->action(QStringLiteral("show_target")); | 1736 | QAction* showTarget = col->action(QStringLiteral("show_target")); | ||
1699 | 1737 | | |||
1738 | if (list.length() == 1 && list.first().isDir()) { | ||||
1739 | addToPlacesAction->setEnabled(true); | ||||
1740 | addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", list.first().name())); | ||||
1741 | } else { | ||||
1742 | addToPlacesAction->setEnabled(false); | ||||
1743 | addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places")); | ||||
1744 | } | ||||
1745 | | ||||
1700 | KFileItemListProperties capabilities(list); | 1746 | KFileItemListProperties capabilities(list); | ||
1701 | const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); | 1747 | const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); | ||
1702 | 1748 | | |||
1703 | renameAction->setEnabled(capabilities.supportsMoving()); | 1749 | renameAction->setEnabled(capabilities.supportsMoving()); | ||
1704 | moveToTrashAction->setEnabled(enableMoveToTrash); | 1750 | moveToTrashAction->setEnabled(enableMoveToTrash); | ||
1705 | deleteAction->setEnabled(capabilities.supportsDeleting()); | 1751 | deleteAction->setEnabled(capabilities.supportsDeleting()); | ||
1706 | deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash); | 1752 | deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash); | ||
1707 | cutAction->setEnabled(capabilities.supportsMoving()); | 1753 | cutAction->setEnabled(capabilities.supportsMoving()); | ||
▲ Show 20 Lines • Show All 415 Lines • Show Last 20 Lines |