Index: /home/wwwchrisde/svn/konversation/ChangeLog
===================================================================
--- /home/wwwchrisde/svn/konversation/ChangeLog	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/ChangeLog	(revision 573719)
@@ -104,7 +104,52 @@
 - Concat multiple ignores/unignores from the nick context menu into one operation
 - Add /kickban command with the same parameters as /ban + [reason]
 - Add "Add to Watched Nicks" nick context menu item
+- Implement a tree list as a vertical alternative to the tab bar.
+- Fix status bar not being reset correctly when the last view is closed.
+- Fix the status bar temp text not being cleared when the window loses focus or
+  the cursor leaves the window after a link is launched.
+- Don't set allow empty temp texts to be set in the status bar.
+- Fix the "No answer from server for ..." lag text interfering with the status
+  bar temp text mechanic by using the proper API to set it.
+- Improve consistency of status bar lag label updating to avoid the UI jumping
+  around too much.
+- Hide the info and lag status bar labels until text is set for the first time.
+- Fix the "DCC Status" and "Channel List" panels leaving the status bar info
+  label empty.
+- Reset the status bar properly when the last view is closed.
+- Tweak the grouping behavior for "Channel List" and "Raw Log" tabs.
+- Fix change of the general UI font not being propagated down to the various
+  types of tabs.
+- Fix changes of the iconset not being applied to tab bar close icons.
+- Fix the name of the "Watched Nicks Online" tab changing under certain circum-
+  stances.
+- Fix Reconnect action not being updated on /disconnect.
+- Fix Reconnect action not always working.
+- Fix "Hide Nicklist" action not being disabled when the current view doesn't
+  actually have a nick list.
+- Fix the menu bar shown/hidden state not being saved across sessions.
+- Show the "Show Menubar" action as the first item in the IRCView context
+  menu when the menu bar is hidden, as is established good practice among
+  KDE applications.
+- Distribute actions in the menus a little better.
+- Make the ban list and other channel settings easier to find by adding
+  an action to open the Channel Settings dialog to the "Window" menu as
+  well as the IRCView context menu of channel tabs.
+- Fix switching off notifications for a tab not unsetting active notification.
+- Fix server tabs not preserving their on/off notification state across sessions.
+- Change the names of various actions temporarily when the (modal) shortcuts
+  dialog is opened. Toggle actions are prefixed with "Toggle", since the list
+  lacks the context in which they're understood as toggle actions. The insert
+  actions are prefixed with "Insert". And the context-adaptive actions ("Open
+  Logfile for ...") are stripped of their context.
+- Disable the "Close All Open Queries" action when there are no open queries.
+- Fix the "Close All Open Queries" action not actually closing all open queries.
+- Don't focus Url Catcher when the "Open URL Catcher" action is triggered
+  the second time. A toggle action isn't tri-state.
+- Don't add bookmarks to the action collection (i.e. to the list of short-
+  cuts) when the bookmark menu is opened.
 
+
 Changes from 0.18 to 0.19
 We are extremely pleased to announce the immediate release of Konversation 0.19. The focus
 of this release is on extending and improving upon established functionality. Most notable
Index: /home/wwwchrisde/svn/konversation/src/tabbar_preferences.ui
===================================================================
--- /home/wwwchrisde/svn/konversation/src/tabbar_preferences.ui	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/tabbar_preferences.ui	(revision 573719)
@@ -1,124 +0,0 @@
-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
-<class>TabBar_Config</class>
-<comment>This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.</comment>
-<widget class="QWidget">
-    <property name="name">
-        <cstring>TabBar_Config</cstring>
-    </property>
-    <property name="geometry">
-        <rect>
-            <x>0</x>
-            <y>0</y>
-            <width>409</width>
-            <height>336</height>
-        </rect>
-    </property>
-    <grid>
-        <property name="name">
-            <cstring>unnamed</cstring>
-        </property>
-        <property name="margin">
-            <number>0</number>
-        </property>
-        <widget class="QGroupBox" row="0" column="0">
-            <property name="name">
-                <cstring>groupBox113</cstring>
-            </property>
-            <property name="title">
-                <string>Placement &amp;&amp; Focus</string>
-            </property>
-            <vbox>
-                <property name="name">
-                    <cstring>unnamed</cstring>
-                </property>
-                <widget class="QCheckBox">
-                    <property name="name">
-                        <cstring>kcfg_TabPlacement</cstring>
-                    </property>
-                    <property name="text">
-                        <string>Place tab bar at the top</string>
-                    </property>
-                    <property name="accel">
-                        <string></string>
-                    </property>
-                </widget>
-                <widget class="QCheckBox">
-                    <property name="name">
-                        <cstring>kcfg_BringToFront</cstring>
-                    </property>
-                    <property name="text">
-                        <string>&amp;Bring new tabs to front</string>
-                    </property>
-                </widget>
-                <widget class="QCheckBox">
-                    <property name="name">
-                        <cstring>kcfg_FocusNewQueries</cstring>
-                    </property>
-                    <property name="text">
-                        <string>When someone queries you, focus new &amp;query</string>
-                    </property>
-                </widget>
-                <widget class="QCheckBox">
-                    <property name="name">
-                        <cstring>kcfg_UseMaxSizedTabs</cstring>
-                    </property>
-                    <property name="text">
-                        <string>Limit the si&amp;ze of the tab labels to fit all on screen</string>
-                    </property>
-                </widget>
-            </vbox>
-        </widget>
-        <widget class="QGroupBox" row="1" column="0">
-            <property name="name">
-                <cstring>closeButtonGBox</cstring>
-            </property>
-            <property name="title">
-                <string>Close Button</string>
-            </property>
-            <vbox>
-                <property name="name">
-                    <cstring>unnamed</cstring>
-                </property>
-                <widget class="QCheckBox">
-                    <property name="name">
-                        <cstring>kcfg_CloseButtons</cstring>
-                    </property>
-                    <property name="text">
-                        <string>Show close b&amp;utton on tabs</string>
-                    </property>
-                </widget>
-                <widget class="QCheckBox">
-                    <property name="name">
-                        <cstring>kcfg_ShowTabBarCloseButton</cstring>
-                    </property>
-                    <property name="text">
-                        <string>Show a close button on the right si&amp;de of the tab bar</string>
-                    </property>
-                </widget>
-            </vbox>
-        </widget>
-        <spacer row="2" column="0">
-            <property name="name">
-                <cstring>spacer1</cstring>
-            </property>
-            <property name="orientation">
-                <enum>Vertical</enum>
-            </property>
-            <property name="sizeType">
-                <enum>Expanding</enum>
-            </property>
-            <property name="sizeHint">
-                <size>
-                    <width>20</width>
-                    <height>150</height>
-                </size>
-            </property>
-        </spacer>
-    </grid>
-</widget>
-<layoutdefaults spacing="6" margin="11"/>
-<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
-</UI>
Index: /home/wwwchrisde/svn/konversation/src/dcctransferhandler.h
===================================================================
--- /home/wwwchrisde/svn/konversation/src/dcctransferhandler.h	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/dcctransferhandler.h	(revision 573719)
@@ -1,33 +0,0 @@
-/*
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-*/
-
-/*
-  This class manages everything DCC transfer related
-  begin:     Mon Apr 21 2003
-  copyright: (C) 2003 by Dario Abatianni
-  email:     eisfuchs@tigress.com
-*/
-
-#ifndef DCCTRANSFERHANDLER_H
-#define DCCTRANSFERHANDLER_H
-
-#include <qobject.h>
-
-class KonversationMainWindow;
-
-class DccTransferHandler : public QObject
-{
-    Q_OBJECT
-
-        public:
-        DccTransferHandler(KonversationMainWindow* mainWindow);
-        ~DccTransferHandler();
-
-    protected:
-        KonversationMainWindow* mainWindow;
-};
-#endif
Index: /home/wwwchrisde/svn/konversation/src/konvisqueezedtextlabel.cpp
===================================================================
--- /home/wwwchrisde/svn/konversation/src/konvisqueezedtextlabel.cpp	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/konvisqueezedtextlabel.cpp	(revision 573719)
@@ -1,60 +0,0 @@
-/*
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-*/
-
-/*
-  Thin wrapper around KSqueezedTextLabel capable of showing a temporary
-  label text all the while storing any text set via the regular setText()
-  and reverting to it when the clearTempText() slot is called. Use case:
-  menu item and link hover updating the status bar across the app.
-  begin:     Fri Jan 15 2006
-  copyright: (C) 2006 by Eike Hein
-  email:     sho@eikehein.com
-*/
-
-#include <kdebug.h>
-
-#include "konvisqueezedtextlabel.h"
-
-/*
-  @author Eike Hein
-*/
-
-
-KonviSqueezedTextLabel::KonviSqueezedTextLabel(const QString &text, QWidget *parent, const char *name)
-    : KSqueezedTextLabel(text, parent, name)
-{
-}
-
-KonviSqueezedTextLabel::~KonviSqueezedTextLabel()
-{
-}
-
-void KonviSqueezedTextLabel::setText(const QString& text)
-{
-    m_oldText = text;
-
-    // Don't overwrite the temp text if there is any
-    if (m_tempText.isEmpty())
-        KSqueezedTextLabel::setText(text);
-}
-
-
-void KonviSqueezedTextLabel::setTempText(const QString& text)
-{
-    m_tempText = text;
-    KSqueezedTextLabel::setText(text);
-}
-
-void KonviSqueezedTextLabel::clearTempText()
-{
-    // Unset the temp text so the net setText won't fail
-    m_tempText = QString::null;
-
-    KSqueezedTextLabel::setText(m_oldText);
-}
-
-#include "konvisqueezedtextlabel.moc"
Index: /home/wwwchrisde/svn/konversation/src/dcctransferhandler.cpp
===================================================================
--- /home/wwwchrisde/svn/konversation/src/dcctransferhandler.cpp	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/dcctransferhandler.cpp	(revision 573719)
@@ -1,27 +0,0 @@
-/*
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-*/
-
-/*
-  This class manages everything DCC transfer related
-  begin:     Mon Apr 21 2003
-  copyright: (C) 2003 by Dario Abatianni
-  email:     eisfuchs@tigress.com
-*/
-
-#include "dcctransferhandler.h"
-#include "konversationmainwindow.h"
-
-DccTransferHandler::DccTransferHandler(KonversationMainWindow* newMainWindow)
-{
-    mainWindow=newMainWindow;
-}
-
-DccTransferHandler::~DccTransferHandler()
-{
-}
-
-#include "dcctransferhandler.moc"
Index: /home/wwwchrisde/svn/konversation/src/konvisqueezedtextlabel.h
===================================================================
--- /home/wwwchrisde/svn/konversation/src/konvisqueezedtextlabel.h	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/konvisqueezedtextlabel.h	(revision 573719)
@@ -1,45 +0,0 @@
-/*
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-*/
-
-/*
-  Thin wrapper around KSqueezedTextLabel capable of showing a temporary
-  label text all the while storing any text set via the regular setText()
-  and reverting to it when the clearTempText() slot is called. Use case:
-  menu item and link hover updating the status bar across the app.
-  begin:     Fri Jan 15 2006
-  copyright: (C) 2006 by Eike Hein
-  email:     sho@eikehein.com
-*/
-
-#ifndef KONVISQUEEZEDTEXTLABEL_H
-#define KONVISQUEEZEDTEXTLABEL_H
-
-#include <ksqueezedtextlabel.h>
-
-/*
-  @author Eike Hein
-*/
-
-class KonviSqueezedTextLabel : public KSqueezedTextLabel
-{
-    Q_OBJECT
-
-        public:
-        KonviSqueezedTextLabel(const QString &text, QWidget *parent, const char *name = 0);
-        ~KonviSqueezedTextLabel();
-
-        public slots:
-        void setText(const QString& text);
-        void setTempText(const QString& text);
-        void clearTempText();
-
-        private:
-        QString m_oldText;
-        QString m_tempText;
-};
-
-#endif
Index: /home/wwwchrisde/svn/konversation/src/popup.h
===================================================================
--- /home/wwwchrisde/svn/konversation/src/popup.h	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/popup.h	(revision 573719)
@@ -1,40 +0,0 @@
-/*
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-*/
-
-/*
-  begin:     Sun May 29 2005
-  copyright: (C) 2005 by Isaac Clerencia
-  email:     isaac@warp.es
-*/
-
-#ifndef POPUP_H
-#define POPUP_H
-
-#include <kpassivepopup.h>
-
-#include "chatwindow.h"
-#include "konversationmainwindow.h"
-/*
-  @author Isaac Clerencia
-*/
-
-class Popup: public KPassivePopup
-{
-    Q_OBJECT
-
-        public:
-        Popup(KonversationMainWindow* mainWindow, ChatWindow* view, const QString& message);
-        ~Popup();
-
-    private slots:
-        void focusTab();
-
-    private:
-        KonversationMainWindow* m_mainWindow;
-        ChatWindow* m_view;
-};
-#endif
Index: /home/wwwchrisde/svn/konversation/src/popup.cpp
===================================================================
--- /home/wwwchrisde/svn/konversation/src/popup.cpp	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/popup.cpp	(revision 573719)
@@ -1,68 +0,0 @@
-/*
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-*/
-
-/*
-  begin:     Sun May 29 2005
-  copyright: (C) 2005 by Isaac Clerencia
-  email:     isaac@warp.es
-*/
-
-#include <klocale.h>
-#include <kwin.h>
-#include <kiconloader.h>
-#include <kactivelabel.h>
-#include <qpixmap.h>
-#include <qvbox.h>
-
-#include "popup.h"
-#include "trayicon.h"
-
-Popup::Popup(KonversationMainWindow* mainWindow,ChatWindow* view, const QString& message)
-: KPassivePopup(mainWindow->systemTrayIcon()->winId()),m_mainWindow(mainWindow),
-m_view(view)
-{
-    QPixmap pix = KGlobal::iconLoader()->loadIcon("konversation",KIcon::Panel);
-    QVBox *vbox = standardView("Konversation",message,pix);
-
-    QString name = m_view->getName();
-    QString linktext;
-    if(name[0] == '#')
-    {
-        linktext = QString(i18n("<a href=\"Chat\">Chat in %1</a>")).arg(name);
-    }
-    else
-    {
-        linktext = QString(i18n("<a href=\"Chat\">Chat with %1</a>")).arg(name);
-    }
-    KActiveLabel *link = new KActiveLabel(linktext,vbox);
-    QObject::disconnect(link,SIGNAL(linkClicked(const QString &)),
-        link,SLOT(openLink(const QString &)));
-    QObject::connect(link,SIGNAL(linkClicked(const QString &)),
-        this,SLOT(focusTab()));
-    QObject::connect(link,SIGNAL(linkClicked(const QString &)),
-        this,SLOT(hide()));
-    setView(vbox);
-    setAutoDelete(true);
-    show();
-}
-
-Popup::~Popup()
-{
-}
-
-void Popup::focusTab()
-{
-    if(m_mainWindow->isHidden())
-        m_mainWindow->show();
-    m_mainWindow->showView(m_view);
-    KWin::WindowInfo winInfo = KWin::windowInfo(m_mainWindow->winId());
-    //  int desktop = winInfo.desktop();
-    KWin::setCurrentDesktop(winInfo.desktop());
-    KWin::activateWindow(m_mainWindow->winId());
-}
-
-#include "popup.moc"
Index: /home/wwwchrisde/svn/konversation/src/konversationui.rc
===================================================================
--- /home/wwwchrisde/svn/konversation/src/konversationui.rc	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/konversationui.rc	(revision 573719)
@@ -1,5 +1,5 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="konversation" version="35">
+<kpartgui name="konversation" version="37">
 
   <MenuBar>
     <Menu name="file">
@@ -15,6 +15,8 @@
     <Menu name="edit">
       <Action name="clear_window" />
       <Action name="clear_tabs" />
+      <Separator />
+      <Action name="hide_nicknamelist" />
     </Menu>
     <Menu name="insert">
       <Text>&amp;Insert</Text>
@@ -32,20 +34,20 @@
       <Text>&amp;Window</Text>
       <Action name="previous_tab" />
       <Action name="next_tab" />
-      <Action name="close_tab" />
-      <Action name="close_queries" />
-      <Action name="hide_nicknamelist" />
       <Separator />
       <Action name="move_tab_left" />
       <Action name="move_tab_right" />
+      <Action name="close_tab" />
+      <Action name="close_queries" />
       <Separator />
       <Action name="open_nicksonline_window" />
-      <Action name="open_channel_list" />
       <Action name="open_url_catcher" />
       <Action name="open_dccstatus_window" />
+      <Action name="open_konsole" />
       <Separator />
-      <Action name="open_konsole" />
+      <Action name="open_channel_list" />
       <Action name="open_logfile" />
+      <Action name="channel_settings" />
     </Menu>
   </MenuBar>
 
Index: /home/wwwchrisde/svn/konversation/src/statuspanel.cpp
===================================================================
--- /home/wwwchrisde/svn/konversation/src/statuspanel.cpp	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/statuspanel.cpp	(revision 573719)
@@ -80,9 +80,6 @@
     if(nicknameCombobox->lineEdit())
         connect(nicknameCombobox->lineEdit(), SIGNAL (lostFocus()),this,SLOT(nicknameComboboxChanged()));
 
-    connect(KonversationApplication::instance(), SIGNAL (appearanceChanged()),this,SLOT (updateAppearance()) );
-
-
     updateAppearance();
 }
 
@@ -199,6 +196,8 @@
 
     nicknameCombobox->setFont(Preferences::textFont());
     showNicknameBox(Preferences::showNicknameBox());
+
+    ChatWindow::updateAppearance();
 }
 
 void StatusPanel::updateName()
@@ -245,6 +244,12 @@
 bool StatusPanel::canBeFrontView()        { return true; }
 bool StatusPanel::searchView()       { return true; }
 
+void StatusPanel::setNotificationsEnabled(bool enable)
+{
+    m_server->serverGroupSettings()->setNotificationsEnabled(enable);
+    m_notificationsEnabled = enable;
+}
+
 bool StatusPanel::closeYourself()
 {
     int result=KMessageBox::warningContinueCancel(
Index: /home/wwwchrisde/svn/konversation/src/konvibookmarkhandler.cpp
===================================================================
--- /home/wwwchrisde/svn/konversation/src/konvibookmarkhandler.cpp	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/konvibookmarkhandler.cpp	(revision 573719)
@@ -51,7 +51,7 @@
 
     connect( manager, SIGNAL(changed(const QString &,const QString &)), SLOT(slotBookmarksChanged(const QString &,const QString &)));
 
-    m_bookmarkMenu = new KonviBookmarkMenu( manager, this, m_menu,  mainWindow->actionCollection(), true );
+    m_bookmarkMenu = new KonviBookmarkMenu( manager, this, m_menu, NULL, true );
 }
 
 KonviBookmarkHandler::~KonviBookmarkHandler()
Index: /home/wwwchrisde/svn/konversation/src/konversationmainwindow.cpp
===================================================================
--- /home/wwwchrisde/svn/konversation/src/konversationmainwindow.cpp	(revision 573718)
+++ /home/wwwchrisde/svn/konversation/src/konversationmainwindow.cpp	(revision 573719)
@@ -13,143 +13,113 @@
   Copyright (C) 2005 Eike Hein <sho@eikehein.com>
 */
 
-#include <qpainter.h>
 #include <qnamespace.h>
 #include <qwhatsthis.h>
 #include <qsignalmapper.h>
-#include <qpoint.h>
+#include <qobjectlist.h>
 
-#include <konvisettingsdialog.h>
 #include <kaccel.h>
+#include <kaccelmanager.h>
 #include <kstdaction.h>
 #include <kaction.h>
 #include <kdebug.h>
 #include <klocale.h>
 #include <kmessagebox.h>
-#include <kstatusbar.h>
 #include <kmenubar.h>
 #include <kkeydialog.h>
 #include <kdeversion.h>
 #include <kedittoolbar.h>
 #include <kpopupmenu.h>
-#include <kiconloader.h>
 #include <kwin.h>
 #include <kglobal.h>
 #include <kstandarddirs.h>
 #include <dcopclient.h>
 #include <scriptmanager.h>
-#include <ktabwidget.h>
-#include <kpushbutton.h>
 #include <kabc/addressbook.h>
 #include <kabc/errorhandler.h>
-#include <kaccelmanager.h>
 
 #include <config.h>
 #ifdef  USE_KNOTIFY
 #include <knotifydialog.h>
 #endif
 
-
 #include "linkaddressbook/addressbook.h"
 #include "konversationmainwindow.h"
+#include "konvisettingsdialog.h"
+#include "viewcontainer.h"
+#include "konversationstatusbar.h"
 #include "konvibookmarkhandler.h"
-#include "chatwindow.h"
 #include "konversationapplication.h"
-#include "ircview.h"
-#include "server.h"
-#include "statuspanel.h"
-#include "channel.h"
-#include "query.h"
-#include "rawlog.h"
-#include "channellistpanel.h"
-#include "dccpanel.h"
-#include "dcctransferhandler.h"
-#include "nicksonline.h"
-#include "konsolepanel.h"
-#include "urlcatcher.h"
-#include "irccolorchooser.h"
 #include "trayicon.h"
-#include "dccchat.h"
 #include "serverlistdialog.h"
-#include "insertchardialog.h"
-#include "logfilereader.h"
 #include "identitydialog.h"
 #include "joinchanneldialog.h"
 #include "notificationhandler.h"
-#include "common.h"
 #include "irccharsets.h"
 #include "konviiphelper.h"
-#include "images.h"
-#include "konvisqueezedtextlabel.h"
 
 KonversationMainWindow::KonversationMainWindow() : KMainWindow(0,"main_window", WStyle_ContextHelp | WType_TopLevel | WDestructiveClose)
 {
-    // Init variables before anything else can happen
     m_hasDirtySettings = false;
-    m_frontView=0;
-    previousFrontView=0;
-    searchView=0;
-    frontServer=0;
-    urlCatcherPanel=0;
-    dccPanel=0;
-    dccPanelOpen=false;
     m_closeApp = false;
-    m_insertCharDialog = 0;
     m_serverListDialog = 0;
-    m_popupTabIndex = -1;
     m_settingsDialog = NULL;
 
-    images = KonversationApplication::instance()->images();
+    m_viewContainer = new ViewContainer(this);
+    setCentralWidget(m_viewContainer->getWidget());
 
-    dccTransferHandler=new DccTransferHandler(this);
+    //used for event compression. See header file for resetHasDirtySettings()
+    connect(KonversationApplication::instance(), SIGNAL(appearanceChanged()), this, SLOT(resetHasDirtySettings()));
+    connect(KonversationApplication::instance(), SIGNAL(appearanceChanged()), this, SLOT(updateTrayIcon()));
 
-    nicksOnlinePanel=0;
 
-    viewContainer = new KTabWidget(this, "main_window_tab_widget");
-    viewContainer->setFont(Preferences::tabFont());
-    viewContainer->setTabReorderingEnabled(true);
-    viewContainer->setTabCloseActivatePrevious(true);
-    #if KDE_IS_VERSION(3,4,0)
-    viewContainer->setAutomaticResizeTabs(Preferences::useMaxSizedTabs());
-    #endif
-    //  viewContainer->setHoverCloseButtonDelayed(false);
-    setCentralWidget(viewContainer);
-    updateTabPlacement();
+    // Set up view container
+    connect(KonversationApplication::instance(), SIGNAL(appearanceChanged()), m_viewContainer, SLOT(updateAppearance()));
+    connect(KonversationApplication::instance(), SIGNAL(iconChanged(int)), m_viewContainer, SLOT(updateViewIcons()));
+    connect(m_viewContainer, SIGNAL(setWindowCaption(const QString&)), this, SLOT(setCaption(const QString&)));
+    connect(this, SIGNAL(serverStateChanged(Server*, Server::State)), m_viewContainer, SLOT(serverStateChanged(Server*, Server::State)));
+    connect(this, SIGNAL(insertRememberLine()), m_viewContainer, SLOT(insertRememberLine()));
+    connect(this, SIGNAL(insertRememberLine(Server*)), m_viewContainer, SLOT(insertRememberLine(Server*)));
 
-    viewContainer->setHoverCloseButton(Preferences::closeButtons());
 
-    viewContainer->hide();
-    KPushButton* closeBtn = new KPushButton(viewContainer);
-    closeBtn->setPixmap(KGlobal::iconLoader()->loadIcon("tab_remove", KIcon::Small));
-    closeBtn->resize(22, 22);
-    closeBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-    viewContainer->setCornerWidget(closeBtn);
-    closeBtn->hide();
-    connect(closeBtn, SIGNAL(clicked()), this, SLOT(closeTab()));
+    // Set up status bar
+    m_statusBar = new KonversationStatusBar(this);
+    connect(KonversationApplication::instance(), SIGNAL(appearanceChanged()), m_statusBar, SLOT(updateAppearance()));
 
+    createStandardStatusBarAction();
 
-    //used for event compression. See header file for resetHasDirtySettings()
-    connect(KonversationApplication::instance(), SIGNAL(appearanceChanged()), this, SLOT(resetHasDirtySettings()));
-    connect(KonversationApplication::instance(), SIGNAL(appearanceChanged()), this, SLOT(updateTrayIcon()));
-                                                  // file_quit
+    connect(actionCollection(), SIGNAL(actionStatusText(const QString&)), m_statusBar, SLOT(setMainLabelTempText(const QString&)));
+    connect(actionCollection(), SIGNAL(clearStatusText()), m_statusBar, SLOT(clearMainLabelTempText()));
+    actionCollection()->setHighlightingEnabled(true);
+
+    connect(m_viewContainer, SIGNAL(resetStatusBar()), m_statusBar, SLOT(resetStatusBar()));
+    connect(m_viewContainer, SIGNAL(setStatusBarTempText(const QString&)), m_statusBar, SLOT(setMainLabelTempText(const QString&)));
+    connect(m_viewContainer, SIGNAL(clearStatusBarTempText()), m_statusBar, SLOT(clearMainLabelTempText()));
+    connect(m_viewContainer, SIGNAL(setStatusBarInfoLabel(const QString&)), m_statusBar, SLOT(updateInfoLabel(const QString&)));
+    connect(m_viewContainer, SIGNAL(clearStatusBarInfoLabel()), m_statusBar, SLOT(clearInfoLabel()));
+    connect(m_viewContainer, SIGNAL(setStatusBarLagLabelShown(bool)), m_statusBar, SLOT(setLagLabelShown(bool)));
+    connect(m_viewContainer, SIGNAL(updateStatusBarLagLabel(Server*, int)), m_statusBar, SLOT(updateLagLabel(Server*, int)));
+    connect(m_viewContainer, SIGNAL(resetStatusBarLagLabel()), m_statusBar, SLOT(resetLagLabel()));
+    connect(m_viewContainer, SIGNAL(setStatusBarLagLabelTooLongLag(Server*, int)), m_statusBar, SLOT(setTooLongLag(Server*, int)));
+    connect(m_viewContainer, SIGNAL(updateStatusBarSSLLabel(Server*)), m_statusBar, SLOT(updateSSLLabel(Server*)));
+    connect(m_viewContainer, SIGNAL(removeStatusBarSSLLabel()), m_statusBar, SLOT(removeSSLLabel()));
+
+
+    // Actions
     KStdAction::quit(this,SLOT(quitProgram()),actionCollection());
 
-    setStandardToolBarMenuEnabled(true);
-    createStandardStatusBarAction();
+    hideMenuBarAction = KStdAction::showMenubar(this, SLOT(toggleMenubar()), actionCollection());
 
-    // options_show_menubar
-    showMenuBarAction=KStdAction::showMenubar(this,SLOT(showMenubar()),actionCollection());
+    setStandardToolBarMenuEnabled(true);
     KStdAction::configureToolbars(this, SLOT(configureToolbars()), actionCollection());
 
+    KStdAction::keyBindings(this, SLOT(openKeyBindings()), actionCollection());
+    KAction *preferencesAction = KStdAction::preferences(this, SLOT(openPrefsDialog()), actionCollection());
+
 #ifdef USE_KNOTIFY // options_configure_notifications
     KAction *configureNotificationsAction = KStdAction::configureNotifications(this,SLOT(openNotifications()), actionCollection());
 #endif
 
-    // options_configure_key_binding
-    KStdAction::keyBindings(this,SLOT(openKeyBindings()),actionCollection());
-    // options_configure
-    KAction *preferencesAction = KStdAction::preferences(this,SLOT(openPrefsDialog()),actionCollection());
-
     KAction* action;
 
     (new KAction(i18n("&Server List..."), "server", KShortcut("F2"), this, SLOT(openServerList()),
@@ -157,32 +127,35 @@
     (new KAction(i18n("Quick &Connect..."), "connect_creating", KShortcut("F7"), this, SLOT(openQuickConnectDialog()),
         actionCollection(), "quick_connect_dialog"))->setToolTip(i18n("Type in the address of a new IRC server to connect to"));
 
-    action = new KAction(i18n("&Reconnect"), "connect_creating", 0, this, SLOT(reconnectCurrentServer()), actionCollection(), "reconnect_server");
+    action = new KAction(i18n("&Reconnect"), "connect_creating", 0, m_viewContainer, SLOT(reconnectFrontServer()), actionCollection(), "reconnect_server");
     action->setEnabled(false);
     action->setToolTip("Reconnect to the current server.");
 
     (new KAction(i18n("&Identities..."), "identity", KShortcut("F8"), this, SLOT(openIdentitiesDialog()),
         actionCollection(), "identities_dialog"))->setToolTip(i18n("Manage your nick, away and other identity settings"));
 
-    new KToggleAction(i18n("&Watched Nicks Online"), 0, KShortcut("F4"), this, SLOT(openNicksOnlinePanel()), actionCollection(), "open_nicksonline_window");
-    new KToggleAction(i18n("&DCC Status"), 0, KShortcut("F9"), this, SLOT(toggleDccPanel()), actionCollection(), "open_dccstatus_window");
-    action = new KAction(i18n("&Open Logfile"), "history", KShortcut("Ctrl+O"), this, SLOT(openLogfile()), actionCollection(), "open_logfile");
+    new KToggleAction(i18n("&Watched Nicks Online"), 0, KShortcut("F4"), m_viewContainer, SLOT(openNicksOnlinePanel()), actionCollection(), "open_nicksonline_window");
+    new KToggleAction(i18n("&DCC Status"), 0, KShortcut("F9"), m_viewContainer, SLOT(toggleDccPanel()), actionCollection(), "open_dccstatus_window");
+    action = new KAction(i18n("&Open Logfile"), "history", KShortcut("Ctrl+O"), m_viewContainer, SLOT(openLogFile()), actionCollection(), "open_logfile");
     action->setEnabled(false);
     action->setToolTip(i18n("Open the known history for this channel in a new tab"));
 
-    action = new KAction(i18n("&Channel List"), 0, KShortcut("F5"), this, SLOT(openChannelList()), actionCollection(), "open_channel_list");
+    action = new KAction(i18n("&Channel Settings..."), "edit", m_viewContainer, SLOT(openChannelSettings()), actionCollection(), "channel_settings");
     action->setEnabled(false);
+    action->setToolTip(i18n("Open the channel settings dialog for this tab"));
+
+    action = new KAction(i18n("Channel &List"), 0, KShortcut("F5"), m_viewContainer, SLOT(openChannelList()), actionCollection(), "open_channel_list");
+    action->setEnabled(false);
     action->setToolTip(i18n("Show a list of all the known channels on this server"));
-    action = new KToggleAction(i18n("&URL Catcher"), 0, KShortcut("F6"), this, SLOT(addUrlCatcher()), actionCollection(), "open_url_catcher");
+    action = new KToggleAction(i18n("&URL Catcher"), 0, KShortcut("F6"), m_viewContainer, SLOT(addUrlCatcher()), actionCollection(), "open_url_catcher");
     action->setToolTip(i18n("List all URLs that have been mentioned recently in a new tab"));
 
     if (kapp->authorize("shell_access"))
     {
-        action = new KAction(i18n("New &Konsole"), "openterm", 0, this, SLOT(addKonsolePanel()), actionCollection(), "open_konsole");
+        action = new KAction(i18n("New &Konsole"), "openterm", 0, m_viewContainer, SLOT(addKonsolePanel()), actionCollection(), "open_konsole");
         action->setToolTip(i18n("Open a terminal in a new tab"));
     }
 
-
     // Actions to navigate through the different pages
     KShortcut nextShortcut = KStdAccel::tabNext();
     nextShortcut.setSeq(1, KKeySequence("Alt+Right"));
@@ -190,54 +163,67 @@
     prevShortcut.setSeq(1, KKeySequence("Alt+Left"));
     action = new KAction(i18n("&Next Tab"), QApplication::reverseLayout() ? "previous" : "next",
         QApplication::reverseLayout() ? prevShortcut : nextShortcut,
-        this,SLOT(nextTab()), actionCollection(), "next_tab");
+        m_viewContainer, SLOT(showNextView()), actionCollection(), "next_tab");
     action->setEnabled(false);
     action = new KAction(i18n("&Previous Tab"), QApplication::reverseLayout() ? "next" : "previous",
         QApplication::reverseLayout() ? nextShortcut : prevShortcut,
-        this,SLOT(previousTab()),actionCollection(),"previous_tab");
+        m_viewContainer, SLOT(showPreviousView()),actionCollection(),"previous_tab");
     action->setEnabled(false);
-    action = new KAction(i18n("Close &Tab"),"tab_remove",KShortcut("Ctrl+w"),this,SLOT(closeTab()),actionCollection(),"close_tab");
+    action = new KAction(i18n("Close &Tab"),"tab_remove",KShortcut("Ctrl+w"), m_viewContainer, SLOT(closeCurrentView()),actionCollection(),"close_tab");
     action->setEnabled(false);
 
-    action = new KAction(i18n("Move Tab Left"), "1leftarrow", KShortcut("Alt+Shift+Left"),
-        this, SLOT(moveTabLeft()), actionCollection(), "move_tab_left");
-    action->setEnabled(false);
-    action->setToolTip("Move the current tab");
-    action = new KAction(i18n("Move Tab Right"), "1rightarrow", KShortcut("Alt+Shift+Right"),
-        this, SLOT(moveTabRight()), actionCollection(), "move_tab_right");
-    action->setEnabled(false);
-    action->setToolTip("Move the current tab");
+    if (Preferences::showBacklog())
+    {
+        action = new KAction(i18n("Move Tab Up"), "1uparrow", KShortcut("Alt+Shift+Left"),
+            m_viewContainer, SLOT(moveViewLeft()), actionCollection(), "move_tab_left");
+        action->setEnabled(false);
+        action->setToolTip("Move this tab");
+        action = new KAction(i18n("Move Tab Down"), "1downarrow", KShortcut("Alt+Shift+Right"),
+            m_viewContainer, SLOT(moveViewRight()), actionCollection(), "move_tab_right");
+        action->setEnabled(false);
+        action->setToolTip("Move this tab");
+    }
+    else
+    {
+        action = new KAction(i18n("Move Tab Left"), "1leftarrow", KShortcut("Alt+Shift+Left"),
+            m_viewContainer, SLOT(moveViewLeft()), actionCollection(), "move_tab_left");
+        action->setEnabled(false);
+        action->setToolTip("Move this tab");
+        action = new KAction(i18n("Move Tab Right"), "1rightarrow", KShortcut("Alt+Shift+Right"),
+            m_viewContainer, SLOT(moveViewRight()), actionCollection(), "move_tab_right");
+        action->setEnabled(false);
+        action->setToolTip("Move this tab");
+    }
 
-    action = new KToggleAction(i18n("Enable Notifications"), 0, 0, this, SLOT(toggleTabNotifications()), actionCollection(), "tab_notifications");
+    action = new KToggleAction(i18n("Enable Notifications"), 0, 0, m_viewContainer, SLOT(toggleViewNotifications()), actionCollection(), "tab_notifications");
     action->setEnabled(false);
 
-
     KSelectAction* selectAction = new KSelectAction(i18n("Set Encoding"), "charset", 0, actionCollection(), "tab_encoding");
     selectAction->setEditable(false);
     QStringList encodingDescs = Konversation::IRCCharsets::self()->availableEncodingDescriptiveNames();
     encodingDescs.prepend(i18n("Default"));
     selectAction->setItems(encodingDescs);
     selectAction->setEnabled(false);
-    connect(selectAction, SIGNAL(activated(int)), this, SLOT(changeTabCharset(int)));
+    connect(selectAction, SIGNAL(activated(int)), m_viewContainer, SLOT(changeViewCharset(int)));
 
     selectAction = new KSelectAction(i18n("Switch To"), 0, 0, actionCollection(), "switch_to_tab");
     selectAction->setEditable(false);
-    connect(selectAction, SIGNAL(activated(int)), this, SLOT(goToTab(int)));
+    connect(selectAction, SIGNAL(activated(int)), m_viewContainer, SLOT(goToView(int)));
 
     QSignalMapper* tabSelectionMapper = new QSignalMapper(this);
-    connect(tabSelectionMapper, SIGNAL(mapped(int)), this, SLOT(goToTab(int)));
+    connect(tabSelectionMapper, SIGNAL(mapped(int)), m_viewContainer, SLOT(goToView(int)));
 
-    for(uint i = 1; i <= 10; ++i)
+    for (uint i = 1; i <= 10; ++i)
     {
         KAction* tabSelectionAction = new KAction(i18n("Go to Tab %1").arg(i), 0, KShortcut(QString("Alt+%1").arg(i%10)),
             tabSelectionMapper, SLOT(map()), actionCollection(), QString("go_to_tab_%1").arg(i).local8Bit());
         tabSelectionMapper->setMapping( tabSelectionAction, i-1);
     }
 
-    action = new KAction(i18n("&Clear Window"),0,KShortcut("Ctrl+L"),this,SLOT(clearWindow()),actionCollection(),"clear_window");
+    action = new KAction(i18n("&Clear Window"),0,KShortcut("Ctrl+L"), m_viewContainer, SLOT(clearView()),actionCollection(),"clear_window");
     action->setToolTip(i18n("Clear the contents of the current tab"));
     action->setEnabled(false);
-    action = new KAction(i18n("Clear &All Windows"),0,KShortcut("CTRL+SHIFT+L"),this,SLOT(clearTabs()),actionCollection(),"clear_tabs");
+    action = new KAction(i18n("Clear &All Windows"),0,KShortcut("CTRL+SHIFT+L"), m_viewContainer, SLOT(clearAllViews()),actionCollection(),"clear_tabs");
     action->setToolTip(i18n("Clear the contents of all open tabs"));
     action->setEnabled(false);
 
@@ -250,69 +236,34 @@
     action->setEnabled(false);
     action->setToolTip("Join a new channel on this server");
 
-    action = KStdAction::find(this, SLOT(findText()), actionCollection());
+    action = KStdAction::find(m_viewContainer, SLOT(findText()), actionCollection());
     action->setEnabled(false);
-    action = KStdAction::findNext(this, SLOT(findNextText()), actionCollection());
+    action = KStdAction::findNext(m_viewContainer, SLOT(findNextText()), actionCollection());
     action->setEnabled(false);
 
-    action = new KAction(i18n("&IRC Color..."), "colorize", CTRL+Key_K, this, SLOT(addIRCColor()), actionCollection(), "irc_colors");
+    action = new KAction(i18n("&IRC Color..."), "colorize", CTRL+Key_K, m_viewContainer, SLOT(insertIRCColor()), actionCollection(), "irc_colors");
     action->setToolTip(i18n("Set the color of your current IRC message"));
     action->setEnabled(false);
-    action = new KAction(i18n("&Remember Line"), 0,  KShortcut("Ctrl+R") , this, SLOT(insertRememberLine()), actionCollection(), "insert_remember_line");
+    action = new KAction(i18n("&Remember Line"), 0,  KShortcut("Ctrl+R") , m_viewContainer, SLOT(insertRememberLine()), actionCollection(), "insert_remember_line");
     action->setToolTip(i18n("Insert a horizontal line into the current tab that only you can see"));
     action->setEnabled(false);
-    action = new KAction(i18n("Special &Character..."), "char", KShortcut("Alt+Shift+C"), this, SLOT(insertCharacter()), actionCollection(), "insert_character");
+    action = new KAction(i18n("Special &Character..."), "char", KShortcut("Alt+Shift+C"), m_viewContainer, SLOT(insertCharacter()), actionCollection(), "insert_character");
     action->setToolTip(i18n("Insert any character into your current IRC message"));
     action->setEnabled(false);
 
-    new KAction(i18n("Close &All Open Queries"), 0, KShortcut("F11"), this, SLOT(closeQueries()), actionCollection(), "close_queries");
-    hideNicklistAction = new KToggleAction(i18n("Hide Nicklist"), 0, KShortcut("Ctrl+H"), this, SLOT(hideNicknameList()), actionCollection(), "hide_nicknamelist");
-    if(!Preferences::showNickList())
-        hideNicklistAction->setChecked(true);
+    action = new KAction(i18n("Close &All Open Queries"), 0, KShortcut("F11"), m_viewContainer, SLOT(closeQueries()), actionCollection(), "close_queries");
+    action->setEnabled(false);
 
+    KToggleAction* toggleChannelNickListsAction = new KToggleAction(i18n("Hide Nicklist"), 0,
+        KShortcut("Ctrl+H"), m_viewContainer, SLOT(toggleChannelNicklists()), actionCollection(), "hide_nicknamelist");
+    if (!Preferences::showNickList())
+        toggleChannelNickListsAction->setChecked(true);
 
-    // Initialize KMainWindow->statusBar()
-    statusBar();
-    m_sslLabel = new SSLLabel(statusBar(),"sslLabel");
-    m_sslLabel->setPixmap(SmallIcon("encrypted"));
-    m_sslLabel->hide();
-    QWhatsThis::add(m_sslLabel, i18n("All communication with the server is encrypted.  This makes it harder for someone to listen in on your communications."));
-
-    int statH = fontMetrics().height()+2;
-
-    m_generalInfoLabel = new KonviSqueezedTextLabel(i18n("Ready."), statusBar());
-    m_generalInfoLabel->setSizePolicy(QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ));
-    m_generalInfoLabel->setMinimumWidth( 0 );
-    m_generalInfoLabel->setFixedHeight( statH );
-
-    m_channelInfoLabel = new QLabel(statusBar(), "channelInfoLabel");
-    QWhatsThis::add(m_channelInfoLabel, i18n("<qt>This shows the number of users in the channel, and the number of those that are operators (ops).<p>A channel operator is a user that has special privileges, such as the ability to kick and ban users, change the channel modes, make other users operators</qt>"));
-
-    m_lagInfoLabel = new QLabel(i18n("Lag: Unknown"), statusBar(), "lagInfoLabel");
-
-    statusBar()->addWidget(m_generalInfoLabel, 1, false);
-    statusBar()->addWidget(m_channelInfoLabel, 0, true);
-    statusBar()->addWidget(m_lagInfoLabel, 0, true);
-
-    statusBar()->addWidget(m_sslLabel, 0, true);
-
-    QWhatsThis::add(statusBar(), i18n("<qt>The status bar shows various messages, including any problems connecting to the server.  On the far right the current delay to the server is shown.  The delay is the time it takes for messages from you to reach the server, and from the server back to you.</qt>"));
-
-    actionCollection()->setHighlightingEnabled(true);
-    connect(actionCollection(), SIGNAL( actionStatusText( const QString & ) ),
-        m_generalInfoLabel, SLOT( setTempText( const QString & ) ) );
-    connect(actionCollection(), SIGNAL( clearStatusText() ),
-        m_generalInfoLabel, SLOT( clearTempText() ) );
-
-    connect( viewContainer,SIGNAL (currentChanged(QWidget*)),this,SLOT (changeView(QWidget*)) );
-    connect( viewContainer, SIGNAL(closeRequest(QWidget*)), this, SLOT(closeView(QWidget*)));
-    connect( viewContainer, SIGNAL(contextMenu(QWidget*, const QPoint&)), this, SLOT(showTabContextMenu(QWidget*, const QPoint&)));
-
     // set up system tray
-    tray = new Konversation::TrayIcon(this);
-    connect(this, SIGNAL(endNotification()), tray, SLOT(endNotification()));
-    connect(tray, SIGNAL(quitSelected()), this, SLOT(quitProgram()));
-    KPopupMenu *trayMenu = tray->contextMenu();
+    m_trayIcon = new Konversation::TrayIcon(this);
+    connect(this, SIGNAL(endNotification()), m_trayIcon, SLOT(endNotification()));
+    connect(m_trayIcon, SIGNAL(quitSelected()), this, SLOT(quitProgram()));
+    KPopupMenu *trayMenu = m_trayIcon->contextMenu();
     #ifdef USE_KNOTIFY
     configureNotificationsAction->plug(trayMenu);
     #endif
@@ -324,1202 +275,230 @@
 
     createGUI();
 
+    resize(700, 500);                             // Give the app a sane default size
+    setAutoSaveSettings();
+
+    // Apply menubar show/hide pref
+    hideMenuBarAction->setChecked(Preferences::showMenuBar());
+    toggleMenubar(true);
+
     // Bookmarks
     m_bookmarkHandler = new KonviBookmarkHandler(this);
     connect(m_bookmarkHandler,SIGNAL(openURL(const QString&,const QString&)),this,SLOT(openURL(const QString&,const QString&)));
 
-    resize(700, 500);                             // Give the app a sane default size
-    setAutoSaveSettings();
-    showMenuBarAction->setChecked(Preferences::showMenuBar());
-    showMenubar(true);
-
     // set up KABC with a nice gui error dialog
     KABC::GuiErrorHandler *m_guiErrorHandler = new KABC::GuiErrorHandler(this);
     kapp->dcopClient()->setAcceptCalls( false );
     Konversation::Addressbook::self()->getAddressBook()->setErrorHandler(m_guiErrorHandler);
     kapp->dcopClient()->setAcceptCalls( true );
 
-    // demo how to add additional dock windows
-    //  QListView* dockList=new QListView(this);
-    //  addToolWindow(dockList,KDockWidget::DockLeft,getMainDockWidget());
+    if (Preferences::useNotify() && Preferences::openWatchedNicksAtStartup())
+        m_viewContainer->openNicksOnlinePanel();
 
-    if(Preferences::useNotify() && Preferences::openWatchedNicksAtStartup())
-    {
-        openNicksOnlinePanel();
-    }
 }
 
 KonversationMainWindow::~KonversationMainWindow()
 {
     Preferences::writeConfig();
-    deleteDccPanel();
-    delete dccTransferHandler;
 }
 
-void KonversationMainWindow::updateTabPlacement()
+void KonversationMainWindow::quitProgram()
 {
-    viewContainer->setTabPosition((Preferences::tabPlacement()==Preferences::Top) ?
-        QTabWidget::Top : QTabWidget::Bottom);
+    // will call queryClose()
+    m_closeApp = true;
+    close();
 }
 
-void KonversationMainWindow::openPrefsDialog()
+bool KonversationMainWindow::queryClose()
 {
-    //An instance of your dialog could be already created and could be cached,
-    //in which case you want to display the cached dialog instead of creating
-    //another one
-    if(!m_settingsDialog)
-    {
-        m_settingsDialog = new KonviSettingsDialog(this);
-        //User edited the configuration - update your local copies of the
-        //configuration data
-        connect(m_settingsDialog, SIGNAL(settingsChanged()), this, SLOT(settingsChangedSlot()));
-    }
-    m_settingsDialog->show();
-}
+    KonversationApplication* konv_app = static_cast<KonversationApplication*>(kapp);
 
-void KonversationMainWindow::settingsChangedSlot()
-{
-    // This is for compressing the events. m_hasDirtySettings is set to true
-    // when the settings have changed, then set to false when the app reacts to it
-    // via the appearanceChanged signal.  This prevents a series of settingsChanged signals
-    // causing the app expensively rereading its settings many times.
-    // The appearanceChanged signal is connected to resetHasDirtySettings to reset this bool
-    if(!m_hasDirtySettings) 
-    {
-        QTimer::singleShot(0, KonversationApplication::instance(), SIGNAL(appearanceChanged()));
-        m_hasDirtySettings = true;
-    }
-}
+    if (konv_app->sessionSaving() || sender() == m_trayIcon)
+        m_closeApp = true;
 
-void KonversationMainWindow::resetHasDirtySettings() 
-{
-    m_hasDirtySettings = false;
-}
-
-void KonversationMainWindow::openKeyBindings()
-{
-    KKeyDialog::configure(actionCollection());
-}
-
-void KonversationMainWindow::focusAndShowErrorMessage(const QString &errorMsg)
-{
-    show();
-    KWin::demandAttention(winId());
-    KWin::activateWindow(winId());
-    KMessageBox::error(this, errorMsg);
-}
-
-void KonversationMainWindow::showMenubar(bool dontShowWarning)
-{
-    if(showMenuBarAction->isChecked()) menuBar()->show();
-    else
+    if (Preferences::showTrayIcon() && !m_closeApp)
     {
-        if(!dontShowWarning)
-        {
-            QString accel=showMenuBarAction->shortcut().toString();
-            KMessageBox::information(this,i18n("<qt>This will hide the menu bar completely."
-                "You can show it again by typing %1.</qt>").arg(accel),
-                "Hide menu bar","HideMenuBarWarning");
-        }
-        menuBar()->hide();
-    }
+        KMessageBox::information( this,
+            i18n("<p>Closing the main window will keep Konversation running in the system tray. "
+            "Use <b>Quit</b> from the <b>Konversation</b> menu to quit the application.</p>"),
+            i18n( "Docking in System Tray" ),  "HideOnCloseInfo" );
+        hide();
 
-    Preferences::setShowMenuBar(showMenuBarAction->isChecked());
-}
-
-void KonversationMainWindow::showStatusbar()
-{
-}
-
-/** Call this when you have already put a message in the serverView window,
- *   and want a message in the front most window if it's on the same server, but not put the message twice.
- */
-void KonversationMainWindow::appendToFrontmostIfDifferent(const QString& type,const QString& message,ChatWindow* serverView)
-{
-    Q_ASSERT(serverView); if(!serverView) return;
-    updateFrontView();
-    if(m_frontView && (ChatWindow *)m_frontView != serverView &&
-        m_frontView->getServer()==serverView->getServer() &&
-        !Preferences::redirectServerAndAppMsgToStatusPane()
-        )
-        m_frontView->appendServerMessage(type,message);
-}
-
-void KonversationMainWindow::appendToFrontmost(const QString& type,const QString& message,ChatWindow* serverView)
-{
-    if( !serverView) serverView = m_frontView->getServer()->getStatusView();
-
-                                                  //if this fails, we need to fix frontServer
-    Q_ASSERT(m_frontView && m_frontView->getServer() == frontServer);
-
-    Q_ASSERT(serverView); if(!serverView) return;
-    updateFrontView();
-    if(!m_frontView ||                            // Check if the m_frontView can actually display text or ...
-                                                  // if it does not belong to this server or...
-        serverView->getServer()!=m_frontView->getServer() ||
-                                                  // if the user decided to force it.
-        Preferences::redirectServerAndAppMsgToStatusPane())
-    {
-        // if not, take server specified fallback view instead
-        serverView->appendServerMessage(type,message);
-        // FIXME: this signal should be sent from the status panel instead, so it
-        //        can be using the correct highlight color, would be more consistent
-        //        anyway!
-        // FIXME newText(serverView,QString::null,true);
+        return false;
     }
-    else
-        m_frontView->appendServerMessage(type,message);
-}
 
-void KonversationMainWindow::updateAppearance()
-{
-    updateTabPlacement();
-    setShowTabBarCloseButton(Preferences::showTabBarCloseButton());
-    #if KDE_IS_VERSION(3,4,0)
-    viewContainer->setAutomaticResizeTabs(Preferences::useMaxSizedTabs());
-    #endif
-    viewContainer->setFont(Preferences::tabFont());
-    int statH = fontMetrics().height()+2;
-    m_generalInfoLabel->setFixedHeight( statH );
+    // send quit to all servers
+    emit quitServer();
 
-    hideNicklistAction->setChecked(!Preferences::showNickList());
+    return true;
 }
 
-void KonversationMainWindow::addView(ChatWindow* view, const QString& label, bool weinitiated)
+void KonversationMainWindow::hideEvent(QHideEvent *e)
 {
-    // TODO: Make sure to add DCC status tab at the end of the list and all others
-    // before the DCC tab. Maybe we should also make sure to order Channels
-    // Queries and DCC chats in groups
-    ChatWindow *tmp_ChatWindow;
-    int placement = -1;
-    ChatWindow::WindowType wtype;
-    QIconSet iconSet;
+    if (Preferences::autoInsertRememberLineAfterMinimizing())
+        emit insertRememberLine();
 
-    connect(view, SIGNAL( actionStatusText( const QString & ) ),
-            m_generalInfoLabel, SLOT( setTempText( const QString & ) ) );
-    connect(view, SIGNAL( clearStatusText() ),
-            m_generalInfoLabel, SLOT( clearTempText() ) );
+    m_statusBar->clearMainLabelTempText();
 
-    switch (view->getType())
-    {
-        case ChatWindow::Channel:
-            if (Preferences::tabNotificationsLeds())
-                iconSet = images->getMsgsLed(false);
-            else if (Preferences::closeButtons())
-                iconSet = images->getCloseIcon();
-
-            for (int sindex = 0; sindex < viewContainer->count(); sindex++)
-            {
-                tmp_ChatWindow = static_cast<ChatWindow *>(viewContainer->page(sindex));
-
-                if (tmp_ChatWindow->getType() == ChatWindow::Status && tmp_ChatWindow->getServer() == view->getServer())
-                {
-                    for (int index = sindex + 1; index < viewContainer->count(); index++)
-                    {
-                        tmp_ChatWindow = static_cast<ChatWindow *>(viewContainer->page(index));
-                        wtype = tmp_ChatWindow->getType();
-
-                        if (wtype != ChatWindow::Channel)
-                        {
-                            placement = index;
-                            break;
-                        }
-                    }
-
-                    break;
-                }
-            }
-
-            break;
-
-        case ChatWindow::RawLog:
-            if (Preferences::closeButtons())
-                iconSet = images->getCloseIcon();
-
-            for (int sindex = 0; sindex < viewContainer->count(); sindex++)
-            {
-                tmp_ChatWindow = static_cast<ChatWindow *>(viewContainer->page(sindex));
-
-                if (tmp_ChatWindow->getType() == ChatWindow::Status && tmp_ChatWindow->getServer() == view->getServer())
-                {
-                    placement = sindex;
-                    break;
-                }
-            }
-
-            break;
-
-        case ChatWindow::Query:
-            if(Preferences::tabNotificationsLeds())
-                iconSet = images->getMsgsLed(false);
-            else if (Preferences::closeButtons())
-                iconSet = images->getCloseIcon();
-
-            for (int sindex = 0; sindex < viewContainer->count(); sindex++)
-            {
-                tmp_ChatWindow = static_cast<ChatWindow *>(viewContainer->page(sindex));
-
-                if (tmp_ChatWindow->getType() == ChatWindow::Status && tmp_ChatWindow->getServer() == view->getServer())
-                {
-                    for (int index = sindex + 1; index < viewContainer->count(); index++)
-                    {
-                        tmp_ChatWindow = static_cast<ChatWindow *>(viewContainer->page(index));
-                        wtype = tmp_ChatWindow->getType();
-
-                        if (wtype != ChatWindow::Channel && wtype != ChatWindow::RawLog && wtype != ChatWindow::Query)
-                        {
-                            placement = index;
-                            break;
-                        }
-                    }
-
-                    break;
-                }
-            }
-
-            break;
-
-        case ChatWindow::DccChat:
-            if(Preferences::tabNotificationsLeds())
-                iconSet = images->getMsgsLed(false);
-            else if (Preferences::closeButtons())
-                iconSet = images->getCloseIcon();
-
-            for (int sindex = 0; sindex < viewContainer->count(); sindex++)
-            {
-                tmp_ChatWindow = static_cast<ChatWindow *>(viewContainer->page(sindex));
-
-                if (tmp_ChatWindow->getType() == ChatWindow::Status && tmp_ChatWindow->getServer() == view->getServer())
-                {
-                    for (int index = sindex + 1; index < viewContainer->count(); index++)
-                    {
-                        tmp_ChatWindow = static_cast<ChatWindow *>(viewContainer->page(index));
-                        wtype = tmp_ChatWindow->getType();
-
-                        if (wtype != ChatWindow::Channel && wtype != ChatWindow::RawLog &&
-                            wtype != ChatWindow::Query && wtype != ChatWindow::DccChat)
-                        {
-                            placement = index;
-                            break;
-                        }
-                    }
-
-                    break;
-                }
-            }
-        case ChatWindow::Status:
-            if(Preferences::tabNotificationsLeds())
-                iconSet = images->getServerLed(false);
-            else if (Preferences::closeButtons())
-                iconSet = images->getCloseIcon();
-            break;
-
-        default:
-            if(Preferences::tabNotificationsLeds())
-                iconSet = images->getSystemLed(false);
-            else if (Preferences::closeButtons())
-                iconSet = images->getCloseIcon();
-            break;
-    }
-
-    viewContainer->insertTab(view, iconSet, label, placement);
-    viewContainer->show();
-
-    // Check, if user was typing in old input line
-    bool doBringToFront=false;
-
-    if(Preferences::focusNewQueries() && view->getType()==ChatWindow::Query && !weinitiated)
-        doBringToFront = true;
-
-    if(Preferences::bringToFront() && view->getType()!=ChatWindow::RawLog)
-        doBringToFront = true;
-
-    // make sure that bring to front only works when the user wasn't typing something
-    if(m_frontView && view->getType() != ChatWindow::UrlCatcher && view->getType() != ChatWindow::Konsole)
-    {
-        if(!m_frontView->getTextInLine().isEmpty())
-            doBringToFront=false;
-    }
-
-    if(doBringToFront)
-        showView(view);
-
-    updateTabMoveActions(getViewContainer()->currentPageIndex());
-    updateSwitchTabAction();
-
-    // FIXME  connect(view,SIGNAL (online(ChatWindow*,bool)),viewContainer,SLOT (setTabOnline(ChatWindow*,bool)) );
+    KMainWindow::hideEvent(e);
 }
 
-void KonversationMainWindow::showView(ChatWindow* view)
+void KonversationMainWindow::focusOutEvent(QFocusEvent* e)
 {
-    // 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(viewContainer->isVisible())
-    {
-        // TODO: add adjustFocus() here?
-        viewContainer->showPage(view);            //This does will changeView(view) via slots
-    }
-}
+    m_statusBar->clearMainLabelTempText();
 
-void KonversationMainWindow::closeView(QWidget* viewToClose)
-{
-    ChatWindow* view=static_cast<ChatWindow*>(viewToClose);
-    if(view)
-    {
-
-        ChatWindow::WindowType viewType=view->getType();
-
-        // the views should know by themselves how to close
-
-        bool confirmClose = true;
-        if(viewType==ChatWindow::Status)            confirmClose = view->closeYourself();
-        else if(viewType==ChatWindow::Channel)      confirmClose = view->closeYourself();
-        else if(viewType==ChatWindow::ChannelList)  confirmClose = view->closeYourself();
-        else if(viewType==ChatWindow::Query)        confirmClose = view->closeYourself();
-        else if(viewType==ChatWindow::RawLog)       confirmClose = view->closeYourself();
-        else if(viewType==ChatWindow::DccChat)      confirmClose = view->closeYourself();
-
-        else if(viewType==ChatWindow::DccPanel)     closeDccPanel();
-        else if(viewType==ChatWindow::Konsole)      closeKonsolePanel(view);
-        else if(viewType==ChatWindow::UrlCatcher)   closeUrlCatcher();
-        else if(viewType==ChatWindow::NicksOnline)  closeNicksOnlinePanel();
-        else if(viewType == ChatWindow::LogFileReader) view->closeYourself();
-
-        if(!confirmClose)
-            return;                               //We haven't done anything yet, so safe to return
-
-        // if this view was the front view, delete the pointer
-        if(view==previousFrontView) previousFrontView=0;
-        if(view==m_frontView) m_frontView=previousFrontView;
-
-        viewContainer->removePage(view);
-
-        if(viewContainer->count() <= 0)
-        {
-            viewContainer->hide();
-        }
-    }
-
-    updateTabMoveActions(getViewContainer()->currentPageIndex());
-    updateSwitchTabAction();
+    KMainWindow::focusOutEvent(e);
 }
 
-void KonversationMainWindow::openLogfile()
+void KonversationMainWindow::leaveEvent(QEvent* e)
 {
-    if(m_frontView)
-    {
-        ChatWindow* view=static_cast<ChatWindow*>(m_frontView);
-        ChatWindow::WindowType viewType=view->getType();
-        if(viewType==ChatWindow::Channel ||
-            viewType==ChatWindow::Query ||
-            viewType==ChatWindow::Status)
-        {
-            openLogFile(view->getName(), view->logFileName());
-        }
-    }
-}
+    m_statusBar->clearMainLabelTempText();
 
-void KonversationMainWindow::openLogFile(const QString& caption, const QString& file)
-{
-    if(!file.isEmpty())
-    {
-        LogfileReader* logReader = new LogfileReader(getViewContainer(), file);
-        addView(logReader, i18n("Logfile of %1").arg(caption));
-        logReader->setServer(0);
-    }
+    KMainWindow::leaveEvent(e);
 }
 
-void KonversationMainWindow::addKonsolePanel()
+bool KonversationMainWindow::event(QEvent* e)
 {
-    KonsolePanel* panel=new KonsolePanel(getViewContainer());
-    panel->setName(i18n("Konsole"));
-    addView(panel, i18n("Konsole"));
-    connect(panel, SIGNAL(updateTabNotification(ChatWindow*,const Konversation::TabNotifyType&)), this, SLOT(setTabNotification(ChatWindow*,const Konversation::TabNotifyType&)));
-    connect(panel,SIGNAL (deleted(ChatWindow*)),this,SLOT (closeKonsolePanel(ChatWindow*)) );
-    panel->setMainWindow(this);
-}
+    if (e->type() == QEvent::WindowActivate) emit endNotification();
 
-void KonversationMainWindow::closeKonsolePanel(ChatWindow* konsolePanel)
-{
-    getViewContainer()->removePage(konsolePanel);
-    // tell QT to delete the panel during the next event loop since we are inside a signal here
-    konsolePanel->deleteLater();
+    return KMainWindow::event(e);
 }
 
-void KonversationMainWindow::openChannelList(const QString& filter, bool getList)
+void KonversationMainWindow::settingsChangedSlot()
 {
-    if(frontServer)
+    // This is for compressing the events. m_hasDirtySettings is set to true
+    // when the settings have changed, then set to false when the app reacts to it
+    // via the appearanceChanged signal.  This prevents a series of settingsChanged signals
+    // causing the app expensively rereading its settings many times.
+    // The appearanceChanged signal is connected to resetHasDirtySettings to reset this bool
+    if (!m_hasDirtySettings) 
     {
-        ChannelListPanel* panel = frontServer->getChannelListPanel();
-
-        if(panel)
-        {
-            getViewContainer()->showPage(panel);
-        }
-        else
-        {
-            int ret = KMessageBox::Continue;
-
-            if(filter.isEmpty())
-            {
-                ret = KMessageBox::warningContinueCancel(this,i18n("Using this function may result in a lot "
-                      "of network traffic. If your connection is not fast "
-                      "enough, it is possible that your client will be "
-                      "disconnected by the server."), i18n("Channel List Warning"),
-                      KStdGuiItem::cont(), "ChannelListWarning");
-            }
-
-            if(ret != KMessageBox::Continue)
-            {
-                return;
-            }
-
-            panel = frontServer->addChannelListPanel();
-        }
-
-        panel->setFilter(filter);
-
-        if(getList)
-        {
-            panel->applyFilterClicked();
-        }
+        QTimer::singleShot(0, KonversationApplication::instance(), SIGNAL(appearanceChanged()));
+        m_hasDirtySettings = true;
     }
-    else
-    {
-        KMessageBox::information(this,
-            i18n(
-            "The channel list can only be opened from a "
-            "query, channel or status window to find out, "
-            "which server this list belongs to."
-            ),
-            i18n("Channel List"),
-            "ChannelListNoServerSelected");
-    }
 }
 
-void KonversationMainWindow::addUrlCatcher()
+void KonversationMainWindow::resetHasDirtySettings()
 {
-    // if the panel wasn't open yet
-    if(urlCatcherPanel==0)
-    {
-        urlCatcherPanel=new UrlCatcher(getViewContainer());
-        addView(urlCatcherPanel, i18n("URL Catcher"));
-        urlCatcherPanel->setMainWindow(this);
-        KonversationApplication *konvApp=static_cast<KonversationApplication *>(KApplication::kApplication());
-        connect(konvApp,SIGNAL (catchUrl(const QString&,const QString&)),
-            urlCatcherPanel,SLOT (addUrl(const QString&,const QString&)) );
-        connect(urlCatcherPanel,SIGNAL (deleteUrl(const QString&,const QString&)),
-            konvApp,SLOT (deleteUrl(const QString&,const QString&)) );
-        connect(urlCatcherPanel,SIGNAL (clearUrlList()),
-            konvApp,SLOT (clearUrlList()) );
-
-        QStringList urlList=konvApp->getUrlList();
-        for(unsigned int i