Bug 207734 - when closing the last tab the new last tab gets marked as read
Summary: when closing the last tab the new last tab gets marked as read
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Konversation Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-18 00:27 UTC by Radu Benea
Modified: 2010-07-01 16:20 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Radu Benea 2009-09-18 00:27:40 UTC
Version:           Version 1.2-alpha6 (using KDE 4.3.1)
OS:                Linux
Installed from:    Gentoo Packages

visible tabs "#chan1" "$chan2" "user1"
from #chan1 I query user1
I talk with the person and at some point close the conversation with user1
konversation returns me to #chan1
but #chan2 is marked as read
although I never even got to see it
Comment 1 Eike Hein 2009-09-18 00:30:03 UTC
Bug confirmed, looking at it now.
Comment 2 Eike Hein 2009-09-18 01:57:21 UTC
SVN commit 1025089 by hein:

Fixed a bug with Qt 4.5 where after closing a tab a tab adjacent to it
would briefly be activated before subsequently activating the tab that
was active before the just closed one (i.e. only noticable when 'a tab
adjacent to the just closed tab' and 'the previously active tab' are not
the same).
BUG:207734


 M  +5 -0      ChangeLog  
 M  +17 -3     src/viewer/viewcontainer.cpp  
 M  +17 -4     src/viewer/viewcontainer.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1025089
Comment 3 Eike Hein 2010-07-01 16:20:43 UTC
commit 4c2bfcc96be4eb701115dcaaa538ef070bf5667b
Author: Eike Hein <hein@kde.org>
Date:   Thu Sep 17 23:57:18 2009 +0000

    Fixed a bug with Qt 4.5 where after closing a tab a tab adjacent to it
    would briefly be activated before subsequently activating the tab that
    was active before the just closed one (i.e. only noticable when 'a tab
    adjacent to the just closed tab' and 'the previously active tab' are not
    the same).
    BUG:207734
    
    svn path=/trunk/extragear/network/konversation/; revision=1025089

diff --git a/ChangeLog b/ChangeLog
index 9379e43..c440c93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -59,6 +59,11 @@ Changes since 1.2-alpha6:
   the expected way.
 * Various actions that operate on the active tab (e.g. those found in the
   "Insert" menu) are now properly disabled when the last tab is closed.
+* Fixed a bug with Qt 4.5 where after closing a tab a tab adjacent to it
+  would briefly be activated before subsequently activating the tab that
+  was active before the just closed one (i.e. only noticable when 'a tab
+  adjacent to the just closed tab' and 'the previously active tab' are not
+  the same).
 
 
 Changes from 1.2-alpha5 to 1.2-alpha6:
diff --git a/src/viewer/viewcontainer.cpp b/src/viewer/viewcontainer.cpp
index 3af953f..a4f85be 100644
--- a/src/viewer/viewcontainer.cpp
+++ b/src/viewer/viewcontainer.cpp
@@ -38,22 +38,29 @@
 #include <QList>
 #include <QSplitter>
 #include <QToolButton>
+#include <QTabBar>
 
 #include <KInputDialog>
-#include <KTabWidget>
 #include <KMessageBox>
 #include <KGlobalSettings>
 #include <KVBox>
 #include <KRun>
 #include <KUrl>
 #include <KXMLGUIFactory>
-
 #include <KActionCollection>
 #include <KToggleAction>
 #include <KSelectAction>
 
 using namespace Konversation;
 
+TabWidget::TabWidget(QWidget* parent) : KTabWidget(parent)
+{
+}
+
+TabWidget::~TabWidget()
+{
+}
+
 ViewContainer::ViewContainer(MainWindow* window):
         m_window(window)
         , m_tabWidget(0)
@@ -153,13 +160,16 @@ void ViewContainer::setupTabWidget()
     m_vbox = new KVBox(m_viewTreeSplitter);
     m_viewTreeSplitter->setStretchFactor(m_viewTreeSplitter->indexOf(m_vbox), 1);
     m_vbox->setObjectName("main_window_right_side");
-    m_tabWidget = new KTabWidget(m_vbox);
+    m_tabWidget = new TabWidget(m_vbox);
     m_tabWidget->setObjectName("main_window_tab_widget");
     m_queueTuner = new QueueTuner(m_vbox, this);
     m_queueTuner->hide();
 
     m_tabWidget->setTabReorderingEnabled(true);
     m_tabWidget->setTabCloseActivatePrevious(true);
+#if QT_VERSION >= 0x040500
+    m_tabWidget->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
+#endif
 
     m_vbox->hide();    //m_tabWidget->hide();
 
@@ -1378,6 +1388,8 @@ void ViewContainer::addView(ChatWindow* view, const QString& label, bool weiniti
 
 void ViewContainer::switchView(int newIndex)
 {
+    kDebug();
+
     ChatWindow* view = static_cast<ChatWindow*>(m_tabWidget->widget(newIndex));
     if (!view) return;
 
@@ -1429,6 +1441,8 @@ void ViewContainer::switchView(int newIndex)
 
 void ViewContainer::showView(ChatWindow* view)
 {
+    kDebug();
+
     // Don't bring Tab to front if TabWidget is hidden. Otherwise QT gets confused
     // and shows the Tab as active but will display the wrong pane
     if (m_tabWidget && m_tabWidget->isVisible())
diff --git a/src/viewer/viewcontainer.h b/src/viewer/viewcontainer.h
index 1b7c0cd..088ea08 100644
--- a/src/viewer/viewcontainer.h
+++ b/src/viewer/viewcontainer.h
@@ -20,10 +20,12 @@
 #include <QObject>
 #include <QPointer>
 
+#include <KTabWidget>
+
 
 class QSplitter;
+class QTabBar;
 
-class KTabWidget;
 class KActionCollection;
 class KVBox;
 
@@ -47,6 +49,17 @@ namespace Konversation
     }
 }
 
+class TabWidget : public KTabWidget
+{
+    Q_OBJECT
+
+    public:
+        TabWidget(QWidget* parent = 0);
+        ~TabWidget();
+
+    QTabBar* tabBar() { return KTabWidget::tabBar(); }
+};
+
 class ViewContainer : public QObject
 {
     Q_OBJECT
@@ -207,10 +220,10 @@ class ViewContainer : public QObject
         MainWindow* m_window;
 
         QSplitter* m_viewTreeSplitter;
-        KTabWidget* m_tabWidget;
+        TabWidget* m_tabWidget;
         ViewTree* m_viewTree;
-        KVBox *m_vbox;
-        QueueTuner *m_queueTuner;
+        KVBox* m_vbox;
+        QueueTuner* m_queueTuner;
 
         Images* images;