]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphintabwidget.cpp
When filter bar is focused, switch to view when tab key is pressed
[dolphin.git] / src / dolphintabwidget.cpp
index 0cbe4529d6b49c4d12db753f35900287d1b621b8..e54ab5ada87cf0fb24082d6e10b6c55022840316 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "dolphintabwidget.h"
 
+#include "dolphin_generalsettings.h"
 #include "dolphintabbar.h"
 #include "dolphintabpage.h"
 #include "dolphinviewcontainer.h"
@@ -37,13 +38,13 @@ DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
     m_lastViewedTab(0)
 {
     connect(this, &DolphinTabWidget::tabCloseRequested,
-            this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::closeTab));
+            this, QOverload<int>::of(&DolphinTabWidget::closeTab));
     connect(this, &DolphinTabWidget::currentChanged,
             this, &DolphinTabWidget::currentTabChanged);
 
     DolphinTabBar* tabBar = new DolphinTabBar(this);
     connect(tabBar, &DolphinTabBar::openNewActivatedTab,
-            this,  static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::openNewActivatedTab));
+            this, QOverload<int>::of(&DolphinTabWidget::openNewActivatedTab));
     connect(tabBar, &DolphinTabBar::tabDropEvent,
             this, &DolphinTabWidget::tabDropEvent);
     connect(tabBar, &DolphinTabBar::tabDetachRequested,
@@ -114,6 +115,14 @@ void DolphinTabWidget::readProperties(const KConfigGroup& group)
 
 void DolphinTabWidget::refreshViews()
 {
+    // Left-elision is better when showing full paths, since you care most
+    // about the current directory which is on the right
+    if (GeneralSettings::showFullPathInTitlebar()) {
+        setElideMode(Qt::ElideLeft);
+    } else {
+        setElideMode(Qt::ElideRight);
+    }
+
     const int tabCount = count();
     for (int i = 0; i < tabCount; ++i) {
         tabBar()->setTabText(i, tabName(tabPageAt(i)));
@@ -135,14 +144,10 @@ void DolphinTabWidget::openNewActivatedTab()
 
     // The URL navigator of the new tab should have the same editable state
     // as the current tab
-    KUrlNavigator* navigator = newActiveViewContainer->urlNavigator();
-    navigator->setUrlEditable(isUrlEditable);
+    newActiveViewContainer->urlNavigator()->setUrlEditable(isUrlEditable);
 
-    if (isUrlEditable) {
-        // If a new tab is opened and the URL is editable, assure that
-        // the user can edit the URL without manually setting the focus
-        navigator->setFocus();
-    }
+    // Always focus the new tab's view
+    newActiveViewContainer->view()->setFocus();
 }
 
 void DolphinTabWidget::openNewActivatedTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
@@ -151,7 +156,7 @@ void DolphinTabWidget::openNewActivatedTab(const QUrl& primaryUrl, const QUrl& s
     setCurrentIndex(count() - 1);
 }
 
-void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
+void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryUrl, TabPlacement tabPlacement)
 {
     QWidget* focusWidget = QApplication::focusWidget();
 
@@ -161,7 +166,11 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
             this, &DolphinTabWidget::activeViewChanged);
     connect(tabPage, &DolphinTabPage::activeViewUrlChanged,
             this, &DolphinTabWidget::tabUrlChanged);
-    addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(tabPage));
+    int newTabIndex = -1;
+    if (tabPlacement == AfterCurrentTab) {
+        newTabIndex = currentIndex() + 1;
+    }
+    insertTab(newTabIndex, tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(tabPage));
 
     if (focusWidget) {
         // The DolphinViewContainer grabbed the keyboard focus. As the tab is opened