mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Open new tab placement option
Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
parent
eb4b0fb480
commit
a73e81bf6a
|
@ -98,7 +98,7 @@ void DolphinBookmarkHandler::openFolderinTabs(const KBookmarkGroup& bookmarkGrou
|
|||
|
||||
void DolphinBookmarkHandler::openInNewTab(const KBookmark& bookmark)
|
||||
{
|
||||
m_mainWindow->openNewTabAfterCurrentTab(bookmark.url());
|
||||
m_mainWindow->openNewTab(bookmark.url());
|
||||
}
|
||||
|
||||
void DolphinBookmarkHandler::openInNewWindow(const KBookmark& bookmark)
|
||||
|
|
|
@ -393,7 +393,11 @@ void DolphinMainWindow::openNewMainWindow()
|
|||
|
||||
void DolphinMainWindow::openNewActivatedTab()
|
||||
{
|
||||
// keep browsers compatibility, new tab is always after last one
|
||||
auto openNewTabAfterLastTabConfigured = GeneralSettings::openNewTabAfterLastTab();
|
||||
GeneralSettings::setOpenNewTabAfterLastTab(true);
|
||||
m_tabWidget->openNewActivatedTab();
|
||||
GeneralSettings::setOpenNewTabAfterLastTab(openNewTabAfterLastTabConfigured);
|
||||
}
|
||||
|
||||
void DolphinMainWindow::addToPlaces()
|
||||
|
@ -422,19 +426,9 @@ void DolphinMainWindow::addToPlaces()
|
|||
}
|
||||
}
|
||||
|
||||
void DolphinMainWindow::openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement)
|
||||
void DolphinMainWindow::openNewTab(const QUrl& 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);
|
||||
m_tabWidget->openNewTab(url, QUrl());
|
||||
}
|
||||
|
||||
void DolphinMainWindow::openInNewTab()
|
||||
|
@ -445,7 +439,7 @@ void DolphinMainWindow::openInNewTab()
|
|||
for (const KFileItem& item : list) {
|
||||
const QUrl& url = DolphinView::openItemAsFolderUrl(item);
|
||||
if (!url.isEmpty()) {
|
||||
openNewTabAfterCurrentTab(url);
|
||||
openNewTab(url);
|
||||
tabCreated = true;
|
||||
}
|
||||
}
|
||||
|
@ -453,7 +447,7 @@ void DolphinMainWindow::openInNewTab()
|
|||
// if no new tab has been created from the selection
|
||||
// open the current directory in a new tab
|
||||
if (!tabCreated) {
|
||||
openNewTabAfterCurrentTab(m_activeViewContainer->url());
|
||||
openNewTab(m_activeViewContainer->url());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -755,7 +749,7 @@ void DolphinMainWindow::slotBackForwardActionMiddleClicked(QAction* action)
|
|||
{
|
||||
if (action) {
|
||||
const KUrlNavigator *urlNavigator = activeViewContainer()->urlNavigatorInternalWithHistory();
|
||||
openNewTabAfterCurrentTab(urlNavigator->locationUrl(action->data().value<int>()));
|
||||
openNewTab(urlNavigator->locationUrl(action->data().value<int>()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -934,25 +928,25 @@ void DolphinMainWindow::goBackInNewTab()
|
|||
{
|
||||
const KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigatorInternalWithHistory();
|
||||
const int index = urlNavigator->historyIndex() + 1;
|
||||
openNewTabAfterCurrentTab(urlNavigator->locationUrl(index));
|
||||
openNewTab(urlNavigator->locationUrl(index));
|
||||
}
|
||||
|
||||
void DolphinMainWindow::goForwardInNewTab()
|
||||
{
|
||||
const KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigatorInternalWithHistory();
|
||||
const int index = urlNavigator->historyIndex() - 1;
|
||||
openNewTabAfterCurrentTab(urlNavigator->locationUrl(index));
|
||||
openNewTab(urlNavigator->locationUrl(index));
|
||||
}
|
||||
|
||||
void DolphinMainWindow::goUpInNewTab()
|
||||
{
|
||||
const QUrl currentUrl = activeViewContainer()->urlNavigator()->locationUrl();
|
||||
openNewTabAfterCurrentTab(KIO::upUrl(currentUrl));
|
||||
openNewTab(KIO::upUrl(currentUrl));
|
||||
}
|
||||
|
||||
void DolphinMainWindow::goHomeInNewTab()
|
||||
{
|
||||
openNewTabAfterCurrentTab(Dolphin::homeUrl());
|
||||
openNewTab(Dolphin::homeUrl());
|
||||
}
|
||||
|
||||
void DolphinMainWindow::compareFiles()
|
||||
|
@ -1139,7 +1133,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos,
|
|||
break;
|
||||
|
||||
case DolphinContextMenu::OpenParentFolderInNewTab:
|
||||
openNewTabAfterLastTab(KIO::upUrl(item.url()));
|
||||
openNewTab(KIO::upUrl(item.url()));
|
||||
break;
|
||||
|
||||
case DolphinContextMenu::None:
|
||||
|
@ -1828,7 +1822,7 @@ void DolphinMainWindow::setupDockWidgets()
|
|||
connect(foldersPanel, &FoldersPanel::folderActivated,
|
||||
this, &DolphinMainWindow::changeUrl);
|
||||
connect(foldersPanel, &FoldersPanel::folderMiddleClicked,
|
||||
this, &DolphinMainWindow::openNewTabAfterCurrentTab);
|
||||
this, &DolphinMainWindow::openNewTab);
|
||||
connect(foldersPanel, &FoldersPanel::errorMessage,
|
||||
this, &DolphinMainWindow::showErrorMessage);
|
||||
|
||||
|
@ -1911,7 +1905,7 @@ void DolphinMainWindow::setupDockWidgets()
|
|||
connect(m_placesPanel, &PlacesPanel::placeActivated,
|
||||
this, &DolphinMainWindow::slotPlaceActivated);
|
||||
connect(m_placesPanel, &PlacesPanel::placeMiddleClicked,
|
||||
this, &DolphinMainWindow::openNewTabAfterCurrentTab);
|
||||
this, &DolphinMainWindow::openNewTab);
|
||||
connect(m_placesPanel, &PlacesPanel::errorMessage,
|
||||
this, &DolphinMainWindow::showErrorMessage);
|
||||
connect(this, &DolphinMainWindow::urlChanged,
|
||||
|
@ -2206,7 +2200,7 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
|
|||
connect(navigator, &KUrlNavigator::editableStateChanged,
|
||||
this, &DolphinMainWindow::slotEditableStateChanged);
|
||||
connect(navigator, &KUrlNavigator::tabRequested,
|
||||
this, &DolphinMainWindow::openNewTabAfterLastTab);
|
||||
this, &DolphinMainWindow::openNewTab);
|
||||
|
||||
disconnect(m_updateHistoryConnection);
|
||||
m_updateHistoryConnection = connect(
|
||||
|
|
|
@ -170,14 +170,9 @@ public slots:
|
|||
void quit();
|
||||
|
||||
/**
|
||||
* Opens a new tab and places it after the current tab
|
||||
* Opens a new tab in the background showing the URL \a url.
|
||||
*/
|
||||
void openNewTabAfterCurrentTab(const QUrl& url);
|
||||
|
||||
/**
|
||||
* Opens a new tab and places it as the last tab
|
||||
*/
|
||||
void openNewTabAfterLastTab(const QUrl& url);
|
||||
void openNewTab(const QUrl& url);
|
||||
|
||||
signals:
|
||||
/**
|
||||
|
@ -417,11 +412,6 @@ private slots:
|
|||
*/
|
||||
void addToPlaces();
|
||||
|
||||
/**
|
||||
* Opens a new tab in the background showing the URL \a url.
|
||||
*/
|
||||
void openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement);
|
||||
|
||||
/**
|
||||
* Opens the selected folder in a new tab.
|
||||
*/
|
||||
|
|
|
@ -152,10 +152,14 @@ void DolphinTabWidget::openNewActivatedTab()
|
|||
void DolphinTabWidget::openNewActivatedTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
|
||||
{
|
||||
openNewTab(primaryUrl, secondaryUrl);
|
||||
setCurrentIndex(count() - 1);
|
||||
if (GeneralSettings::openNewTabAfterLastTab()) {
|
||||
setCurrentIndex(count() - 1);
|
||||
} else {
|
||||
setCurrentIndex(currentIndex() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryUrl, TabPlacement tabPlacement)
|
||||
void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
|
||||
{
|
||||
QWidget* focusWidget = QApplication::focusWidget();
|
||||
|
||||
|
@ -166,7 +170,7 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
|
|||
connect(tabPage, &DolphinTabPage::activeViewUrlChanged,
|
||||
this, &DolphinTabWidget::tabUrlChanged);
|
||||
int newTabIndex = -1;
|
||||
if (tabPlacement == AfterCurrentTab) {
|
||||
if (!GeneralSettings::openNewTabAfterLastTab()) {
|
||||
newTabIndex = currentIndex() + 1;
|
||||
}
|
||||
insertTab(newTabIndex, tabPage, QIcon() /* loaded in tabInserted */, tabName(tabPage));
|
||||
|
|
|
@ -21,19 +21,6 @@ class DolphinTabWidget : public QTabWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Controls where tabs are placed
|
||||
*/
|
||||
enum TabPlacement {
|
||||
/**
|
||||
* The new tab is placed after the current tab
|
||||
*/
|
||||
AfterCurrentTab,
|
||||
/**
|
||||
* The new tab is placed after the last tab
|
||||
*/
|
||||
AfterLastTab
|
||||
};
|
||||
|
||||
/**
|
||||
* @param navigatorsWidget The navigatorsWidget which is always going to be connected
|
||||
|
@ -118,11 +105,9 @@ public slots:
|
|||
|
||||
/**
|
||||
* Opens a new tab in the background showing the URL \a primaryUrl and the
|
||||
* optional URL \a secondaryUrl. \a tabPlacement controls where the new tab
|
||||
* is placed.
|
||||
* optional URL \a secondaryUrl.
|
||||
*/
|
||||
void openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl = QUrl(),
|
||||
DolphinTabWidget::TabPlacement tabPlacement = AfterLastTab);
|
||||
void openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl = QUrl());
|
||||
|
||||
/**
|
||||
* Opens each directory in \p dirs in a separate tab. If \a splitView is set,
|
||||
|
|
|
@ -86,6 +86,10 @@
|
|||
<label>Close active pane when toggling off split view</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="OpenNewTabAfterLastTab" type="Bool">
|
||||
<label>New tab will be open after last one</label>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="ShowToolTips" type="Bool">
|
||||
<label>Show tooltips</label>
|
||||
<default>false</default>
|
||||
|
|
|
@ -6,36 +6,48 @@
|
|||
|
||||
#include "navigationsettingspage.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "dolphin_generalsettings.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QCheckBox>
|
||||
#include <QFormLayout>
|
||||
#include <QRadioButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) :
|
||||
SettingsPageBase(parent),
|
||||
m_openArchivesAsFolder(nullptr),
|
||||
m_autoExpandFolders(nullptr)
|
||||
m_autoExpandFolders(nullptr),
|
||||
m_openNewTabAfterLastTab(nullptr),
|
||||
m_openNewTabAfterCurrentTab(nullptr)
|
||||
{
|
||||
QVBoxLayout* topLayout = new QVBoxLayout(this);
|
||||
QWidget* vBox = new QWidget(this);
|
||||
QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox);
|
||||
vBoxLayout->setContentsMargins(0, 0, 0, 0);
|
||||
vBoxLayout->setAlignment(Qt::AlignTop);
|
||||
QFormLayout* topLayout = new QFormLayout(this);
|
||||
|
||||
m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder"), vBox);
|
||||
vBoxLayout->addWidget(m_openArchivesAsFolder);
|
||||
// Tabs properties
|
||||
m_openNewTabAfterCurrentTab = new QRadioButton(i18nc("option:radio", "After current tab"));
|
||||
m_openNewTabAfterLastTab = new QRadioButton(i18nc("option:radio", "At end of tab bar"));
|
||||
QButtonGroup* tabsBehaviorGroup = new QButtonGroup(this);
|
||||
tabsBehaviorGroup->addButton(m_openNewTabAfterCurrentTab);
|
||||
tabsBehaviorGroup->addButton(m_openNewTabAfterLastTab);
|
||||
topLayout->addRow(i18nc("@title:group", "Open new tabs: "), m_openNewTabAfterCurrentTab);
|
||||
topLayout->addRow(QString(), m_openNewTabAfterLastTab);
|
||||
|
||||
m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox);
|
||||
vBoxLayout->addWidget(m_autoExpandFolders);
|
||||
topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
|
||||
topLayout->addWidget(vBox);
|
||||
m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder"));
|
||||
m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"));
|
||||
topLayout->addRow(i18nc("@title:group", "General: "), m_openArchivesAsFolder);
|
||||
topLayout->addRow(QString(), m_autoExpandFolders);
|
||||
|
||||
loadSettings();
|
||||
|
||||
connect(m_openArchivesAsFolder, &QCheckBox::toggled, this, &NavigationSettingsPage::changed);
|
||||
connect(m_autoExpandFolders, &QCheckBox::toggled, this, &NavigationSettingsPage::changed);
|
||||
connect(m_openNewTabAfterCurrentTab, &QRadioButton::toggled, this, &NavigationSettingsPage::changed);
|
||||
connect(m_openNewTabAfterLastTab, &QRadioButton::toggled, this, &NavigationSettingsPage::changed);
|
||||
}
|
||||
|
||||
NavigationSettingsPage::~NavigationSettingsPage()
|
||||
|
@ -47,6 +59,7 @@ void NavigationSettingsPage::applySettings()
|
|||
GeneralSettings* settings = GeneralSettings::self();
|
||||
settings->setBrowseThroughArchives(m_openArchivesAsFolder->isChecked());
|
||||
settings->setAutoExpandFolders(m_autoExpandFolders->isChecked());
|
||||
settings->setOpenNewTabAfterLastTab(m_openNewTabAfterLastTab->isChecked());
|
||||
|
||||
settings->save();
|
||||
}
|
||||
|
@ -63,5 +76,7 @@ void NavigationSettingsPage::loadSettings()
|
|||
{
|
||||
m_openArchivesAsFolder->setChecked(GeneralSettings::browseThroughArchives());
|
||||
m_autoExpandFolders->setChecked(GeneralSettings::autoExpandFolders());
|
||||
m_openNewTabAfterLastTab->setChecked(GeneralSettings::openNewTabAfterLastTab());
|
||||
m_openNewTabAfterCurrentTab->setChecked(!m_openNewTabAfterLastTab->isChecked());
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "settings/settingspagebase.h"
|
||||
|
||||
class QCheckBox;
|
||||
class QRadioButton;
|
||||
|
||||
/**
|
||||
* @brief Page for the 'Navigation' settings of the Dolphin settings dialog.
|
||||
|
@ -33,6 +34,8 @@ private:
|
|||
private:
|
||||
QCheckBox* m_openArchivesAsFolder;
|
||||
QCheckBox* m_autoExpandFolders;
|
||||
QRadioButton* m_openNewTabAfterLastTab;
|
||||
QRadioButton* m_openNewTabAfterCurrentTab;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -945,7 +945,7 @@ void DolphinView::slotItemsActivated(const KItemSet& indexes)
|
|||
const QUrl& url = openItemAsFolderUrl(item);
|
||||
|
||||
if (!url.isEmpty()) { // Open folders in new tabs
|
||||
Q_EMIT tabRequested(url, DolphinTabWidget::AfterLastTab);
|
||||
Q_EMIT tabRequested(url);
|
||||
} else {
|
||||
items.append(item);
|
||||
}
|
||||
|
@ -963,9 +963,9 @@ void DolphinView::slotItemMiddleClicked(int index)
|
|||
const KFileItem& item = m_model->fileItem(index);
|
||||
const QUrl& url = openItemAsFolderUrl(item);
|
||||
if (!url.isEmpty()) {
|
||||
Q_EMIT tabRequested(url, DolphinTabWidget::AfterCurrentTab);
|
||||
Q_EMIT tabRequested(url);
|
||||
} else if (isTabsForFilesEnabled()) {
|
||||
Q_EMIT tabRequested(item.url(), DolphinTabWidget::AfterCurrentTab);
|
||||
Q_EMIT tabRequested(item.url());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -433,7 +433,7 @@ signals:
|
|||
/**
|
||||
* Is emitted if a new tab should be opened for the URL \a url.
|
||||
*/
|
||||
void tabRequested(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement);
|
||||
void tabRequested(const QUrl& url);
|
||||
|
||||
/**
|
||||
* Is emitted if the view mode (IconsView, DetailsView,
|
||||
|
|
Loading…
Reference in a new issue