diff options
| author | David Hallas <[email protected]> | 2019-02-21 15:45:27 +0100 |
|---|---|---|
| committer | David Hallas <[email protected]> | 2019-03-09 12:11:58 +0100 |
| commit | e602e532c0f7c023db097d0eac50a9d7a652b2d1 (patch) | |
| tree | 6d3319db2859d94b4b69dc48111d35053076724f | |
| parent | 4ae68e844502a64d2cfcce1ea349803f6313fd27 (diff) | |
New tab placed after current tab when middle-clicking
Summary:
New tabs should be placed after the currently active tab when using
middle click.
Test Plan:
Open new tab from the places panel using middle click, verify that the
Open new tab from the folders panel using middle click, verify that the
tab is opened after the current tab
Open new tab by middle clicking on the Back button, verify that the tab
is opened after the current tab
Open new tab by middle clicking on the Forward button, verify that the tab
is opened after the current tab
FEATURE: 403690
Reviewers: #dolphin, ngraham, elvisangelaccio
Reviewed By: #dolphin, ngraham, elvisangelaccio
Subscribers: kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D19201
| -rw-r--r-- | src/dolphinmainwindow.cpp | 35 | ||||
| -rw-r--r-- | src/dolphinmainwindow.h | 13 | ||||
| -rw-r--r-- | src/views/dolphinview.cpp | 6 | ||||
| -rw-r--r-- | src/views/dolphinview.h | 3 |
4 files changed, 39 insertions, 18 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 3e4a60571..bcadcdb80 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -27,7 +27,6 @@ #include "dolphincontextmenu.h" #include "dolphinnewfilemenu.h" #include "dolphinrecenttabsmenu.h" -#include "dolphintabwidget.h" #include "dolphinviewcontainer.h" #include "dolphintabpage.h" #include "middleclickactioneventfilter.h" @@ -315,9 +314,19 @@ void DolphinMainWindow::openNewActivatedTab() m_tabWidget->openNewActivatedTab(); } -void DolphinMainWindow::openNewTab(const QUrl& url) +void DolphinMainWindow::openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement) { - m_tabWidget->openNewTab(url); + m_tabWidget->openNewTab(url, QUrl(), tabPlacement); +} + +void DolphinMainWindow::openNewTabAfterCurrentTab(const QUrl& url) +{ + m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab); +} + +void DolphinMainWindow::openNewTabAfterLastTab(const QUrl& url) +{ + m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterLastTab); } void DolphinMainWindow::openInNewTab() @@ -328,7 +337,7 @@ void DolphinMainWindow::openInNewTab() foreach (const KFileItem& item, list) { const QUrl& url = DolphinView::openItemAsFolderUrl(item); if (!url.isEmpty()) { - m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab); + openNewTabAfterCurrentTab(url); tabCreated = true; } } @@ -336,7 +345,7 @@ void DolphinMainWindow::openInNewTab() // if no new tab has been created from the selection // open the current directory in a new tab if (!tabCreated) { - m_tabWidget->openNewTab(m_activeViewContainer->url(), QUrl(), DolphinTabWidget::AfterCurrentTab); + openNewTabAfterCurrentTab(m_activeViewContainer->url()); } } @@ -740,25 +749,25 @@ void DolphinMainWindow::goBackInNewTab() { KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); const int index = urlNavigator->historyIndex() + 1; - openNewTab(urlNavigator->locationUrl(index)); + openNewTabAfterCurrentTab(urlNavigator->locationUrl(index)); } void DolphinMainWindow::goForwardInNewTab() { KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); const int index = urlNavigator->historyIndex() - 1; - openNewTab(urlNavigator->locationUrl(index)); + openNewTabAfterCurrentTab(urlNavigator->locationUrl(index)); } void DolphinMainWindow::goUpInNewTab() { const QUrl currentUrl = activeViewContainer()->urlNavigator()->locationUrl(); - openNewTab(KIO::upUrl(currentUrl)); + openNewTabAfterCurrentTab(KIO::upUrl(currentUrl)); } void DolphinMainWindow::goHomeInNewTab() { - openNewTab(Dolphin::homeUrl()); + openNewTabAfterCurrentTab(Dolphin::homeUrl()); } void DolphinMainWindow::compareFiles() @@ -889,7 +898,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos, break; case DolphinContextMenu::OpenParentFolderInNewTab: - openNewTab(KIO::upUrl(item.url())); + openNewTabAfterLastTab(KIO::upUrl(item.url())); break; case DolphinContextMenu::None: @@ -1328,7 +1337,7 @@ void DolphinMainWindow::setupDockWidgets() connect(foldersPanel, &FoldersPanel::folderActivated, this, &DolphinMainWindow::changeUrl); connect(foldersPanel, &FoldersPanel::folderMiddleClicked, - this, &DolphinMainWindow::openNewTab); + this, &DolphinMainWindow::openNewTabAfterCurrentTab); connect(foldersPanel, &FoldersPanel::errorMessage, this, &DolphinMainWindow::showErrorMessage); @@ -1384,7 +1393,7 @@ void DolphinMainWindow::setupDockWidgets() connect(m_placesPanel, &PlacesPanel::placeActivated, this, &DolphinMainWindow::slotPlaceActivated); connect(m_placesPanel, &PlacesPanel::placeMiddleClicked, - this, &DolphinMainWindow::openNewTab); + this, &DolphinMainWindow::openNewTabAfterCurrentTab); connect(m_placesPanel, &PlacesPanel::errorMessage, this, &DolphinMainWindow::showErrorMessage); connect(this, &DolphinMainWindow::urlChanged, @@ -1598,7 +1607,7 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) connect(navigator, &KUrlNavigator::editableStateChanged, this, &DolphinMainWindow::slotEditableStateChanged); connect(navigator, &KUrlNavigator::tabRequested, - this, &DolphinMainWindow::openNewTab); + this, &DolphinMainWindow::openNewTabAfterLastTab); } void DolphinMainWindow::updateSplitAction() diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index f2876a877..1734d4ad4 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -22,6 +22,7 @@ #ifndef DOLPHIN_MAINWINDOW_H #define DOLPHIN_MAINWINDOW_H +#include "dolphintabwidget.h" #include <config-baloo.h> #include <kio/fileundomanager.h> #include <ksortablelist.h> @@ -327,7 +328,17 @@ private slots: /** * Opens a new tab in the background showing the URL \a url. */ - void openNewTab(const QUrl& url); + void openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement); + + /** + * Opens a new tab and places it after the current tab + */ + void openNewTabAfterCurrentTab(const QUrl& url); + + /** + * Opens a new tab and places it as the last tab + */ + void openNewTabAfterLastTab(const QUrl& url); /** * Opens the selected folder in a new tab. diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index d79b7cd08..5b00fa36d 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -853,7 +853,7 @@ void DolphinView::slotItemsActivated(const KItemSet& indexes) const QUrl& url = openItemAsFolderUrl(item); if (!url.isEmpty()) { // Open folders in new tabs - emit tabRequested(url); + emit tabRequested(url, DolphinTabWidget::AfterLastTab); } else { items.append(item); } @@ -871,9 +871,9 @@ void DolphinView::slotItemMiddleClicked(int index) const KFileItem& item = m_model->fileItem(index); const QUrl& url = openItemAsFolderUrl(item); if (!url.isEmpty()) { - emit tabRequested(url); + emit tabRequested(url, DolphinTabWidget::AfterCurrentTab); } else if (isTabsForFilesEnabled()) { - emit tabRequested(item.url()); + emit tabRequested(item.url(), DolphinTabWidget::AfterCurrentTab); } } diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index a618b2ce3..7be2eed2d 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -21,6 +21,7 @@ #ifndef DOLPHINVIEW_H #define DOLPHINVIEW_H +#include "dolphintabwidget.h" #include "dolphin_export.h" #include <KFileItem> @@ -400,7 +401,7 @@ signals: /** * Is emitted if a new tab should be opened for the URL \a url. */ - void tabRequested(const QUrl& url); + void tabRequested(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement); /** * Is emitted if the view mode (IconsView, DetailsView, |
