[prev in list] [next in list] [prev in thread] [next in thread]
List: kopete-devel
Subject: [Kopete-devel] Bugfix patch for libkopete
From: Jason Keirstead <jason () keirstead ! org>
Date: 2003-01-31 22:41:36
[Download RAW message or body]
Bugfix patch posted for review
- Made it so that when you have it set to tabbing and emssage queue, that the
tab doesnt appear until you click the view msg bubble (follow window
behaviour)
- Finally traced down the point of origin of all the
saveOptions/writeDockConfig bugs, I was accessing a null pointer, because the
m_activeView variable was not being cleared when you closed a chat view.
Fixed.
--
Jason Keirstead, BCS
http://www.keirstead.org
["libkopete.diff" (text/x-diff)]
? libkopete.diff
Index: kopetemessagemanager.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetemessagemanager.cpp,v
retrieving revision 1.92
diff -u -p -r1.92 kopetemessagemanager.cpp
--- kopetemessagemanager.cpp 29 Jan 2003 20:30:13 -0000 1.92
+++ kopetemessagemanager.cpp 31 Jan 2003 22:40:03 -0000
@@ -384,7 +384,7 @@ void KopeteMessageManager::readMessages(
//Raise the tab if needed
if (d->mWidget == ChatWindow)
- static_cast<KopeteChatWindow*>(myWindow)->makeWidgetDockVisible(mainView);
+ static_cast<KopeteChatWindow*>(myWindow)->setActiveView( \
static_cast<ChatView*>(mainView)->dockWidget() );
//Only grab focus if we opened the chat ourselves
if ( queueEmpty )
Index: ui/chatview.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/ui/chatview.cpp,v
retrieving revision 1.96
diff -u -p -r1.96 chatview.cpp
--- ui/chatview.cpp 30 Jan 2003 00:16:39 -0000 1.96
+++ ui/chatview.cpp 31 Jan 2003 22:40:03 -0000
@@ -142,7 +142,7 @@ ChatView::ChatView( KopeteMessageManager
//Finalize
historyPos = -1;
- m_mainWindow = (KopeteChatWindow*)parent;
+ m_mainWindow = static_cast<KopeteChatWindow*>(parent);
membersDock = 0L;
m_manager = mgr;
backgroundFile = QString::null;
@@ -150,6 +150,7 @@ ChatView::ChatView( KopeteMessageManager
slotConfigChanged();
isModified = false;
isActive = false;
+ isDocked = false;
//Restore docking positions
readOptions();
@@ -162,7 +163,6 @@ ChatView::ChatView( KopeteMessageManager
ChatView::~ChatView()
{
kdDebug(14010) << k_funcinfo << "Destroying ChatView" << endl;
- m_mainWindow->chatViewList.remove( this );
emit Closing();
}
@@ -523,11 +523,13 @@ void ChatView::addChatMessage( KopeteMes
isModified = true;
if( m_dockWidget->parentDockTabGroup() )
m_dockWidget->parentDockTabGroup()->setTabLabel( m_dockWidget, m_captionText + \
QString::fromLatin1( "*" ) ); +
}
}
-void ChatView::setActive(bool value)
+void ChatView::setActive( bool value )
{
+
isActive = value;
if( isActive )
{
@@ -535,6 +537,15 @@ void ChatView::setActive(bool value)
if( m_dockWidget->parentDockTabGroup() )
m_dockWidget->parentDockTabGroup()->setTabLabel( m_dockWidget, m_captionText );
}
+ else
+ {
+ saveOptions();
+ }
+}
+
+void ChatView::setDocked( bool value )
+{
+ isDocked = value;
}
void ChatView::refreshView()
Index: ui/chatview.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/ui/chatview.h,v
retrieving revision 1.46
diff -u -p -r1.46 chatview.h
--- ui/chatview.h 29 Jan 2003 21:04:35 -0000 1.46
+++ ui/chatview.h 31 Jan 2003 22:40:03 -0000
@@ -117,6 +117,8 @@ namespace Kopete
*/
void setCurrentMessage( const KopeteMessage &newMessage );
+ void setDocked( bool value );
+
/**
* Sets the placement of the members contact list.
* DockLeft, DockRight, or DockNone.
@@ -160,6 +162,8 @@ namespace Kopete
* @return The contents of the view
*/
const QString viewsText() { return viewContents; }
+
+ const bool docked() { return isDocked; }
public slots:
@@ -313,6 +317,7 @@ namespace Kopete
bool bgOverride;
bool isModified;
bool isActive;
+ bool isDocked;
QString backgroundFile;
KRootPixmap *root;
Index: ui/kopetechatwindow.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/ui/kopetechatwindow.cpp,v
retrieving revision 1.108
diff -u -p -r1.108 kopetechatwindow.cpp
--- ui/kopetechatwindow.cpp 30 Jan 2003 00:16:39 -0000 1.108
+++ ui/kopetechatwindow.cpp 31 Jan 2003 22:40:03 -0000
@@ -60,13 +60,12 @@ KopeteChatWindow::KopeteChatWindow(QWidg
initActions();
readOptions();
backgroundFile = 0L;
- m_viewCount = 0;
+ chatViewList.setAutoDelete( false );
}
KopeteChatWindow::~KopeteChatWindow()
{
kdDebug(14010) << k_funcinfo << endl;
- m_viewCount = 0;
slotViewClosed();
if( m_activeView )
m_activeView->saveOptions();
@@ -203,9 +202,6 @@ ChatView *KopeteChatWindow::addChatView(
KDockWidget *mainView;
- if( m_activeView != 0L )
- m_activeView->saveOptions();
-
QString windowCaption = manager->chatName();
if( windowCaption.length() > 20 )
windowCaption = windowCaption.left( 20 ).append( QString::fromLatin1( "..." ) );
@@ -215,19 +211,23 @@ ChatView *KopeteChatWindow::addChatView(
mainView->setToolTipString( manager->chatName() );
mainView->setDockWindowType( NET::Normal );
- mainView->setDockSite(KDockWidget::DockCenter);
- mainView->setEnableDocking(KDockWidget::DockCenter);
+ mainView->setDockSite(KDockWidget::DockCenter | KDockWidget::DockNone);
+ mainView->setEnableDocking(KDockWidget::DockCenter | KDockWidget::DockNone);
//If there is only one chatview on the window, ensure he is the main dock widget \
before proceeding if( m_activeView && ( chatViewList.count() == 1) )
{
kdDebug(14010) << k_funcinfo << "setMainDockWidget called" << endl;
setMainDockWidget( m_activeView->dockWidget() );
- setView( m_activeView );
+ setView( m_activeView->dockWidget() );
+ m_activeView->setDocked( true );
}
- KDockWidget *currentMainView = getMainDockWidget();
- if( currentMainView == 0L )
+ m_activeView = new ChatView ( manager, mainView, this );
+ m_activeView->setCaptionText( windowCaption );
+ chatViewList.append( m_activeView );
+
+ if( getMainDockWidget() == 0L )
{
kdDebug(14010) << k_funcinfo << "Initial add, setMainDockWidget called" << endl;
setMainDockWidget( mainView );
@@ -236,39 +236,29 @@ ChatView *KopeteChatWindow::addChatView(
else
{
kdDebug(14010) << k_funcinfo << "Subsequent add, dock to main window" << endl;
- mainView->manualDock( currentMainView, KDockWidget::DockCenter );
+ mainView->hide();
+ mainView->manualDock( 0L, KDockWidget::DockNone );
}
-
- m_activeView = new ChatView ( manager, mainView, this );
- m_activeView->setCaptionText( windowCaption );
- chatViewList.append( m_activeView );
+
mainView->setWidget( m_activeView );
- //Lock this for now since re-parenting doesnt work, dont let them mess their view \
up
- mainView->setEnableDocking(KDockWidget::DockCenter);
-
KWin::setIcons( winId(), protocolIcon, protocolIcon );
setCaption( windowCaption, false );
connect( mainView, SIGNAL(headerCloseButtonClicked()), mainView, \
SLOT(deleteLater()) ); connect( m_activeView, SIGNAL(Closing()), this, \
SLOT(slotViewClosed()) );
-
- if( mainView->parentDockTabGroup() )
- {
- connect ( mainView->parentDockTabGroup(), SIGNAL(currentChanged(QWidget *)), this, \
SLOT(setActiveView(QWidget *)) );
- kdDebug(14010) << k_funcinfo << "Parent tab group exists" << endl;
- }
updateMembersActions();
- m_viewCount++;
return m_activeView;
}
void KopeteChatWindow::slotViewClosed()
{
- --m_viewCount;
- if( m_viewCount <= 0 )
+ chatViewList.remove( m_activeView );
+ m_activeView = 0L;
+
+ if( chatViewList.count() <= 0 )
{
if( backgroundFile != 0L )
{
@@ -295,13 +285,33 @@ void KopeteChatWindow::updateBackground(
void KopeteChatWindow::setActiveView( QWidget* active )
{
kdDebug(14010) << k_funcinfo << endl;
- m_activeView->setActive(false);
- m_activeView = (ChatView*)((KDockWidget*)active)->getWidget();
- m_activeView->setActive(true);
+
+ //If there is an active view, tell it isn't active anymore
+ if( m_activeView )
+ m_activeView->setActive( false );
+
+ //Get the view switched to
+ KDockWidget *activeDock = static_cast<KDockWidget*>(active);
+ m_activeView = static_cast<ChatView*>( activeDock->getWidget() );
+ if( !m_activeView->docked() )
+ {
+ kdDebug(14010) << k_funcinfo << "View is not docked, docking in now" << endl;
+ activeDock->manualDock( getMainDockWidget(), KDockWidget::DockCenter );
+ m_activeView->setDocked( true );
+ activeDock->setEnableDocking(KDockWidget::DockCenter);
+ connect ( activeDock->parentDockTabGroup(), SIGNAL(currentChanged(QWidget *)), \
this, SLOT(setActiveView(QWidget *)) ); + }
+
+ //Tell it it is active
+ m_activeView->setActive( true );
+ //Raise the tab
+ activeDock->makeDockVisible();
+ //Update window caption to match
setCaption( m_activeView->caption(), false );
+ //Update icons to match
protocolIcon = UserIcon( m_activeView->manager()->protocol()->protocolIcon() );
KWin::setIcons( winId(), protocolIcon, protocolIcon );
-
+ //Update chat members actions
updateMembersActions();
}
Index: ui/kopetechatwindow.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/ui/kopetechatwindow.h,v
retrieving revision 1.57
diff -u -p -r1.57 kopetechatwindow.h
--- ui/kopetechatwindow.h 30 Jan 2003 00:16:39 -0000 1.57
+++ ui/kopetechatwindow.h 31 Jan 2003 22:40:03 -0000
@@ -85,7 +85,6 @@ private:
ChatView *m_activeView;
bool widgetSet;
const KopeteContact *m_us;
- int m_viewCount;
KAction* editCut;
KAction* editCopy;
_______________________________________________
Kopete-devel mailing list
Kopete-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/kopete-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic