]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Correct searchbox, split view transitions between tabs
authorAnthony Fieroni <bvbfan@abv.bg>
Mon, 22 May 2017 17:35:29 +0000 (20:35 +0300)
committerAnthony Fieroni <bvbfan@abv.bg>
Mon, 22 May 2017 17:35:29 +0000 (20:35 +0300)
Differential Revision: https://phabricator.kde.org/D5864

BUG: 379135
BUG: 380032
FIXED-IN: 17.04.2

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
src/dolphintabpage.cpp
src/dolphintabpage.h
src/dolphintabwidget.cpp
src/search/dolphinsearchbox.cpp

index 5c42d41ec7c2e97236542a7923e55b919813bbbb..1d3a6f08c91af5b26345ee5c5fd2e16e20787367 100644 (file)
@@ -28,7 +28,8 @@
 DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) :
     QWidget(parent),
     m_primaryViewActive(true),
 DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) :
     QWidget(parent),
     m_primaryViewActive(true),
-    m_splitViewEnabled(false)
+    m_splitViewEnabled(false),
+    m_active(true)
 {
     QVBoxLayout* layout = new QVBoxLayout(this);
     layout->setSpacing(0);
 {
     QVBoxLayout* layout = new QVBoxLayout(this);
     layout->setSpacing(0);
@@ -286,17 +287,31 @@ void DolphinTabPage::restoreStateV1(const QByteArray& state)
     m_splitter->restoreState(splitterState);
 }
 
     m_splitter->restoreState(splitterState);
 }
 
+void DolphinTabPage::setActive(bool active)
+{
+    if (active) {
+        m_active = active;
+    } else {
+        // we should bypass changing active view in split mode
+        m_active = !m_splitViewEnabled;
+    }
+    // we want view to fire activated when goes from false to true
+    activeViewContainer()->setActive(active);
+}
+
 void DolphinTabPage::slotViewActivated()
 {
     const DolphinView* oldActiveView = activeViewContainer()->view();
 
     // Set the view, which was active before, to inactive
 void DolphinTabPage::slotViewActivated()
 {
     const DolphinView* oldActiveView = activeViewContainer()->view();
 
     // Set the view, which was active before, to inactive
-    // and update the active view type.
-    if (m_splitViewEnabled) {
-        activeViewContainer()->setActive(false);
-        m_primaryViewActive = !m_primaryViewActive;
-    } else {
-        m_primaryViewActive = true;
+    // and update the active view type, if tab is active
+    if (m_active) {
+        if (m_splitViewEnabled) {
+            activeViewContainer()->setActive(false);
+            m_primaryViewActive = !m_primaryViewActive;
+        } else {
+            m_primaryViewActive = true;
+        }
     }
 
     const DolphinView* newActiveView = activeViewContainer()->view();
     }
 
     const DolphinView* newActiveView = activeViewContainer()->view();
index 1a97ea45738bf88851f57593bb7fa7c3dfbf565c..45c540775fe127c73dc3d2c61b90862367d9901f 100644 (file)
@@ -129,6 +129,12 @@ public:
      */
     void restoreStateV1(const QByteArray& state);
 
      */
     void restoreStateV1(const QByteArray& state);
 
+    /**
+     * Set whether the tab page is active
+     *
+     */
+    void setActive(bool active);
+
 signals:
     void activeViewChanged(DolphinViewContainer* viewContainer);
     void activeViewUrlChanged(const QUrl& url);
 signals:
     void activeViewChanged(DolphinViewContainer* viewContainer);
     void activeViewUrlChanged(const QUrl& url);
@@ -165,6 +171,7 @@ private:
 
     bool m_primaryViewActive;
     bool m_splitViewEnabled;
 
     bool m_primaryViewActive;
     bool m_splitViewEnabled;
+    bool m_active;
 };
 
 #endif // DOLPHIN_TAB_PAGE_H
 };
 
 #endif // DOLPHIN_TAB_PAGE_H
index bcd4a49fdfea89df84cedf27131b875d54f5291b..94b7a0144ccb2540b36787a5a256b9a11243e90b 100644 (file)
@@ -33,7 +33,7 @@
 DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
     QTabWidget(parent),
     m_placesSelectorVisible(true),
 DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
     QTabWidget(parent),
     m_placesSelectorVisible(true),
-    m_previousTab(-1)
+    m_previousTab(0)
 {
     connect(this, &DolphinTabWidget::tabCloseRequested,
             this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::closeTab));
 {
     connect(this, &DolphinTabWidget::tabCloseRequested,
             this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::closeTab));
@@ -304,15 +304,15 @@ void DolphinTabWidget::tabUrlChanged(const QUrl& url)
 
 void DolphinTabWidget::currentTabChanged(int index)
 {
 
 void DolphinTabWidget::currentTabChanged(int index)
 {
-    DolphinViewContainer* viewContainer = tabPageAt(index)->activeViewContainer();
-    viewContainer->setActive(true);
+    // previous tab deactivation
+    if (DolphinTabPage* tabPage = tabPageAt(m_previousTab)) {
+        tabPage->setActive(false);
+    }
+    DolphinTabPage* tabPage = tabPageAt(index);
+    DolphinViewContainer* viewContainer = tabPage->activeViewContainer();
     emit activeViewChanged(viewContainer);
     emit currentUrlChanged(viewContainer->url());
     emit activeViewChanged(viewContainer);
     emit currentUrlChanged(viewContainer->url());
-    viewContainer->view()->setFocus();
-
-    if (tabPageAt(m_previousTab)) {
-        tabPageAt(m_previousTab)->activeViewContainer()->setActive(false);
-    }
+    tabPage->setActive(true);
     m_previousTab = index;
 }
 
     m_previousTab = index;
 }
 
index 5d5906b789579d033153187101c291bc681e82c2..c6943c60881c6dcfe8fc6c5bf2b3729e318d3742 100644 (file)
@@ -230,8 +230,13 @@ bool DolphinSearchBox::eventFilter(QObject* obj, QEvent* event)
 {
     switch (event->type()) {
     case QEvent::FocusIn:
 {
     switch (event->type()) {
     case QEvent::FocusIn:
-        setActive(true);
-        setFocus();
+        // #379135: we get the FocusIn event when we close a tab but we don't want to emit
+        // the activated() signal before the removeTab() call in DolphinTabWidget::closeTab() returns.
+        // To avoid this issue, we delay the activation of the search box.
+        QTimer::singleShot(0, this, [this] {
+            setActive(true);
+            setFocus();
+        });
         break;
 
     default:
         break;
 
     default: