Changeset View
Changeset View
Standalone View
Standalone View
src/dolphinmainwindow.cpp
Show All 21 Lines | |||||
22 | #include "dolphinmainwindow.h" | 22 | #include "dolphinmainwindow.h" | ||
23 | 23 | | |||
24 | #include "config-terminal.h" | 24 | #include "config-terminal.h" | ||
25 | #include "global.h" | 25 | #include "global.h" | ||
26 | #include "dolphindockwidget.h" | 26 | #include "dolphindockwidget.h" | ||
27 | #include "dolphincontextmenu.h" | 27 | #include "dolphincontextmenu.h" | ||
28 | #include "dolphinnewfilemenu.h" | 28 | #include "dolphinnewfilemenu.h" | ||
29 | #include "dolphinrecenttabsmenu.h" | 29 | #include "dolphinrecenttabsmenu.h" | ||
30 | #include "dolphintabwidget.h" | | |||
31 | #include "dolphinviewcontainer.h" | 30 | #include "dolphinviewcontainer.h" | ||
32 | #include "dolphintabpage.h" | 31 | #include "dolphintabpage.h" | ||
33 | #include "middleclickactioneventfilter.h" | 32 | #include "middleclickactioneventfilter.h" | ||
34 | #include "panels/folders/folderspanel.h" | 33 | #include "panels/folders/folderspanel.h" | ||
35 | #include "panels/places/placespanel.h" | 34 | #include "panels/places/placespanel.h" | ||
36 | #include "panels/information/informationpanel.h" | 35 | #include "panels/information/informationpanel.h" | ||
37 | #include "panels/terminal/terminalpanel.h" | 36 | #include "panels/terminal/terminalpanel.h" | ||
38 | #include "settings/dolphinsettingsdialog.h" | 37 | #include "settings/dolphinsettingsdialog.h" | ||
▲ Show 20 Lines • Show All 271 Lines • ▼ Show 20 Line(s) | 308 | { | |||
310 | Dolphin::openNewWindow({m_activeViewContainer->url()}, this); | 309 | Dolphin::openNewWindow({m_activeViewContainer->url()}, this); | ||
311 | } | 310 | } | ||
312 | 311 | | |||
313 | void DolphinMainWindow::openNewActivatedTab() | 312 | void DolphinMainWindow::openNewActivatedTab() | ||
314 | { | 313 | { | ||
315 | m_tabWidget->openNewActivatedTab(); | 314 | m_tabWidget->openNewActivatedTab(); | ||
316 | } | 315 | } | ||
317 | 316 | | |||
318 | void DolphinMainWindow::openNewTab(const QUrl& url) | 317 | void DolphinMainWindow::openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement) | ||
319 | { | 318 | { | ||
320 | m_tabWidget->openNewTab(url); | 319 | m_tabWidget->openNewTab(url, QUrl(), tabPlacement); | ||
320 | } | ||||
321 | | ||||
322 | void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl& url) | ||||
323 | { | ||||
324 | m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab); | ||||
325 | } | ||||
326 | | ||||
327 | void DolphinMainWindow::openNewTabAfterLastTab(const QUrl& url) | ||||
328 | { | ||||
329 | m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterLastTab); | ||||
321 | } | 330 | } | ||
322 | 331 | | |||
323 | void DolphinMainWindow::openInNewTab() | 332 | void DolphinMainWindow::openInNewTab() | ||
324 | { | 333 | { | ||
325 | const KFileItemList& list = m_activeViewContainer->view()->selectedItems(); | 334 | const KFileItemList& list = m_activeViewContainer->view()->selectedItems(); | ||
326 | bool tabCreated = false; | 335 | bool tabCreated = false; | ||
327 | 336 | | |||
328 | foreach (const KFileItem& item, list) { | 337 | foreach (const KFileItem& item, list) { | ||
329 | const QUrl& url = DolphinView::openItemAsFolderUrl(item); | 338 | const QUrl& url = DolphinView::openItemAsFolderUrl(item); | ||
330 | if (!url.isEmpty()) { | 339 | if (!url.isEmpty()) { | ||
331 | m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab); | 340 | openNewTabAfterCurrentTab(url); | ||
332 | tabCreated = true; | 341 | tabCreated = true; | ||
333 | } | 342 | } | ||
334 | } | 343 | } | ||
335 | 344 | | |||
336 | // if no new tab has been created from the selection | 345 | // if no new tab has been created from the selection | ||
337 | // open the current directory in a new tab | 346 | // open the current directory in a new tab | ||
338 | if (!tabCreated) { | 347 | if (!tabCreated) { | ||
339 | m_tabWidget->openNewTab(m_activeViewContainer->url(), QUrl(), DolphinTabWidget::AfterCurrentTab); | 348 | openNewTabAfterCurrentTab(m_activeViewContainer->url()); | ||
340 | } | 349 | } | ||
341 | } | 350 | } | ||
342 | 351 | | |||
343 | void DolphinMainWindow::openInNewWindow() | 352 | void DolphinMainWindow::openInNewWindow() | ||
344 | { | 353 | { | ||
345 | QUrl newWindowUrl; | 354 | QUrl newWindowUrl; | ||
346 | 355 | | |||
347 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | 356 | const KFileItemList list = m_activeViewContainer->view()->selectedItems(); | ||
▲ Show 20 Lines • Show All 387 Lines • ▼ Show 20 Line(s) | |||||
735 | { | 744 | { | ||
736 | m_activeViewContainer->urlNavigator()->goHome(); | 745 | m_activeViewContainer->urlNavigator()->goHome(); | ||
737 | } | 746 | } | ||
738 | 747 | | |||
739 | void DolphinMainWindow::goBackInNewTab() | 748 | void DolphinMainWindow::goBackInNewTab() | ||
740 | { | 749 | { | ||
741 | KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); | 750 | KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); | ||
742 | const int index = urlNavigator->historyIndex() + 1; | 751 | const int index = urlNavigator->historyIndex() + 1; | ||
743 | openNewTab(urlNavigator->locationUrl(index)); | 752 | openNewTabAfterCurrentTab(urlNavigator->locationUrl(index)); | ||
744 | } | 753 | } | ||
745 | 754 | | |||
746 | void DolphinMainWindow::goForwardInNewTab() | 755 | void DolphinMainWindow::goForwardInNewTab() | ||
747 | { | 756 | { | ||
748 | KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); | 757 | KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); | ||
749 | const int index = urlNavigator->historyIndex() - 1; | 758 | const int index = urlNavigator->historyIndex() - 1; | ||
750 | openNewTab(urlNavigator->locationUrl(index)); | 759 | openNewTabAfterCurrentTab(urlNavigator->locationUrl(index)); | ||
751 | } | 760 | } | ||
752 | 761 | | |||
753 | void DolphinMainWindow::goUpInNewTab() | 762 | void DolphinMainWindow::goUpInNewTab() | ||
754 | { | 763 | { | ||
755 | const QUrl currentUrl = activeViewContainer()->urlNavigator()->locationUrl(); | 764 | const QUrl currentUrl = activeViewContainer()->urlNavigator()->locationUrl(); | ||
756 | openNewTab(KIO::upUrl(currentUrl)); | 765 | openNewTabAfterCurrentTab(KIO::upUrl(currentUrl)); | ||
757 | } | 766 | } | ||
758 | 767 | | |||
759 | void DolphinMainWindow::goHomeInNewTab() | 768 | void DolphinMainWindow::goHomeInNewTab() | ||
760 | { | 769 | { | ||
761 | openNewTab(Dolphin::homeUrl()); | 770 | openNewTabAfterCurrentTab(Dolphin::homeUrl()); | ||
762 | } | 771 | } | ||
763 | 772 | | |||
764 | void DolphinMainWindow::compareFiles() | 773 | void DolphinMainWindow::compareFiles() | ||
765 | { | 774 | { | ||
766 | const KFileItemList items = m_tabWidget->currentTabPage()->selectedItems(); | 775 | const KFileItemList items = m_tabWidget->currentTabPage()->selectedItems(); | ||
767 | if (items.count() != 2) { | 776 | if (items.count() != 2) { | ||
768 | // The action is disabled in this case, but it could have been triggered | 777 | // The action is disabled in this case, but it could have been triggered | ||
769 | // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517 | 778 | // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517 | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 890 | case DolphinContextMenu::OpenParentFolder: | |||
884 | m_activeViewContainer->view()->markUrlAsCurrent(item.url()); | 893 | m_activeViewContainer->view()->markUrlAsCurrent(item.url()); | ||
885 | break; | 894 | break; | ||
886 | 895 | | |||
887 | case DolphinContextMenu::OpenParentFolderInNewWindow: | 896 | case DolphinContextMenu::OpenParentFolderInNewWindow: | ||
888 | Dolphin::openNewWindow({item.url()}, this, Dolphin::OpenNewWindowFlag::Select); | 897 | Dolphin::openNewWindow({item.url()}, this, Dolphin::OpenNewWindowFlag::Select); | ||
889 | break; | 898 | break; | ||
890 | 899 | | |||
891 | case DolphinContextMenu::OpenParentFolderInNewTab: | 900 | case DolphinContextMenu::OpenParentFolderInNewTab: | ||
892 | openNewTab(KIO::upUrl(item.url())); | 901 | openNewTabAfterLastTab(KIO::upUrl(item.url())); | ||
893 | break; | 902 | break; | ||
894 | 903 | | |||
895 | case DolphinContextMenu::None: | 904 | case DolphinContextMenu::None: | ||
896 | default: | 905 | default: | ||
897 | break; | 906 | break; | ||
898 | } | 907 | } | ||
899 | 908 | | |||
900 | // Delete the menu, unless it has been deleted in its own nested event loop already. | 909 | // Delete the menu, unless it has been deleted in its own nested event loop already. | ||
▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Line(s) | 1320 | #endif | |||
1323 | createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7, foldersAction, QStringLiteral("show_folders_panel")); | 1332 | createPanelAction(QIcon::fromTheme(QStringLiteral("folder")), Qt::Key_F7, foldersAction, QStringLiteral("show_folders_panel")); | ||
1324 | 1333 | | |||
1325 | addDockWidget(Qt::LeftDockWidgetArea, foldersDock); | 1334 | addDockWidget(Qt::LeftDockWidgetArea, foldersDock); | ||
1326 | connect(this, &DolphinMainWindow::urlChanged, | 1335 | connect(this, &DolphinMainWindow::urlChanged, | ||
1327 | foldersPanel, &FoldersPanel::setUrl); | 1336 | foldersPanel, &FoldersPanel::setUrl); | ||
1328 | connect(foldersPanel, &FoldersPanel::folderActivated, | 1337 | connect(foldersPanel, &FoldersPanel::folderActivated, | ||
1329 | this, &DolphinMainWindow::changeUrl); | 1338 | this, &DolphinMainWindow::changeUrl); | ||
1330 | connect(foldersPanel, &FoldersPanel::folderMiddleClicked, | 1339 | connect(foldersPanel, &FoldersPanel::folderMiddleClicked, | ||
1331 | this, &DolphinMainWindow::openNewTab); | 1340 | this, &DolphinMainWindow::openNewTabAfterCurrentTab); | ||
elvisangelaccio: We are going to use this lambda in 3 different places. Maybe this calls for a new… | |||||
I have create dedicated functions for both cases and use them throughout this class. hallas: I have create dedicated functions for both cases and use them throughout this class. | |||||
1332 | connect(foldersPanel, &FoldersPanel::errorMessage, | 1341 | connect(foldersPanel, &FoldersPanel::errorMessage, | ||
1333 | this, &DolphinMainWindow::showErrorMessage); | 1342 | this, &DolphinMainWindow::showErrorMessage); | ||
1334 | 1343 | | |||
1335 | // Setup "Terminal" | 1344 | // Setup "Terminal" | ||
1336 | #ifdef HAVE_TERMINAL | 1345 | #ifdef HAVE_TERMINAL | ||
1337 | if (KAuthorized::authorize(QStringLiteral("shell_access"))) { | 1346 | if (KAuthorized::authorize(QStringLiteral("shell_access"))) { | ||
1338 | DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal")); | 1347 | DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal")); | ||
1339 | terminalDock->setLocked(lock); | 1348 | terminalDock->setLocked(lock); | ||
Show All 39 Lines | 1372 | #endif | |||
1379 | 1388 | | |||
1380 | QAction *placesAction = placesDock->toggleViewAction(); | 1389 | QAction *placesAction = placesDock->toggleViewAction(); | ||
1381 | createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9, placesAction, QStringLiteral("show_places_panel")); | 1390 | createPanelAction(QIcon::fromTheme(QStringLiteral("bookmarks")), Qt::Key_F9, placesAction, QStringLiteral("show_places_panel")); | ||
1382 | 1391 | | |||
1383 | addDockWidget(Qt::LeftDockWidgetArea, placesDock); | 1392 | addDockWidget(Qt::LeftDockWidgetArea, placesDock); | ||
1384 | connect(m_placesPanel, &PlacesPanel::placeActivated, | 1393 | connect(m_placesPanel, &PlacesPanel::placeActivated, | ||
1385 | this, &DolphinMainWindow::slotPlaceActivated); | 1394 | this, &DolphinMainWindow::slotPlaceActivated); | ||
1386 | connect(m_placesPanel, &PlacesPanel::placeMiddleClicked, | 1395 | connect(m_placesPanel, &PlacesPanel::placeMiddleClicked, | ||
1387 | this, &DolphinMainWindow::openNewTab); | 1396 | this, &DolphinMainWindow::openNewTabAfterCurrentTab); | ||
1388 | connect(m_placesPanel, &PlacesPanel::errorMessage, | 1397 | connect(m_placesPanel, &PlacesPanel::errorMessage, | ||
1389 | this, &DolphinMainWindow::showErrorMessage); | 1398 | this, &DolphinMainWindow::showErrorMessage); | ||
1390 | connect(this, &DolphinMainWindow::urlChanged, | 1399 | connect(this, &DolphinMainWindow::urlChanged, | ||
1391 | m_placesPanel, &PlacesPanel::setUrl); | 1400 | m_placesPanel, &PlacesPanel::setUrl); | ||
1392 | connect(placesDock, &DolphinDockWidget::visibilityChanged, | 1401 | connect(placesDock, &DolphinDockWidget::visibilityChanged, | ||
1393 | m_tabWidget, &DolphinTabWidget::slotPlacesPanelVisibilityChanged); | 1402 | m_tabWidget, &DolphinTabWidget::slotPlacesPanelVisibilityChanged); | ||
1394 | connect(this, &DolphinMainWindow::settingsChanged, | 1403 | connect(this, &DolphinMainWindow::settingsChanged, | ||
1395 | m_placesPanel, &PlacesPanel::readSettings); | 1404 | m_placesPanel, &PlacesPanel::readSettings); | ||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 1574 | { | |||
1593 | const KUrlNavigator* navigator = container->urlNavigator(); | 1602 | const KUrlNavigator* navigator = container->urlNavigator(); | ||
1594 | connect(navigator, &KUrlNavigator::urlChanged, | 1603 | connect(navigator, &KUrlNavigator::urlChanged, | ||
1595 | this, &DolphinMainWindow::changeUrl); | 1604 | this, &DolphinMainWindow::changeUrl); | ||
1596 | connect(navigator, &KUrlNavigator::historyChanged, | 1605 | connect(navigator, &KUrlNavigator::historyChanged, | ||
1597 | this, &DolphinMainWindow::updateHistory); | 1606 | this, &DolphinMainWindow::updateHistory); | ||
1598 | connect(navigator, &KUrlNavigator::editableStateChanged, | 1607 | connect(navigator, &KUrlNavigator::editableStateChanged, | ||
1599 | this, &DolphinMainWindow::slotEditableStateChanged); | 1608 | this, &DolphinMainWindow::slotEditableStateChanged); | ||
1600 | connect(navigator, &KUrlNavigator::tabRequested, | 1609 | connect(navigator, &KUrlNavigator::tabRequested, | ||
1601 | this, &DolphinMainWindow::openNewTab); | 1610 | this, &DolphinMainWindow::openNewTabAfterLastTab); | ||
1602 | } | 1611 | } | ||
1603 | 1612 | | |||
1604 | void DolphinMainWindow::updateSplitAction() | 1613 | void DolphinMainWindow::updateSplitAction() | ||
1605 | { | 1614 | { | ||
1606 | QAction* splitAction = actionCollection()->action(QStringLiteral("split_view")); | 1615 | QAction* splitAction = actionCollection()->action(QStringLiteral("split_view")); | ||
1607 | const DolphinTabPage* tabPage = m_tabWidget->currentTabPage(); | 1616 | const DolphinTabPage* tabPage = m_tabWidget->currentTabPage(); | ||
1608 | if (tabPage->splitViewEnabled()) { | 1617 | if (tabPage->splitViewEnabled()) { | ||
1609 | if (GeneralSettings::closeActiveSplitView() ? tabPage->primaryViewActive() : !tabPage->primaryViewActive()) { | 1618 | if (GeneralSettings::closeActiveSplitView() ? tabPage->primaryViewActive() : !tabPage->primaryViewActive()) { | ||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |
We are going to use this lambda in 3 different places. Maybe this calls for a new openNewTabAfterCurrentTab() private slot.