Use KCmdLineArgs, KApplication and KMainWindow
[quassel.git] / src / qtui / mainwin.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef MAINWIN_H_
22 #define MAINWIN_H_
23
24 #ifdef HAVE_KDE
25 #  include <KMainWindow>
26 #else
27 #  include <QMainWindow>
28 #endif
29
30 #include <QSystemTrayIcon>
31
32 #include "qtui.h"
33 #include "sessionsettings.h"
34 #include "titlesetter.h"
35
36 class ActionCollection;
37 class BufferView;
38 class BufferViewConfig;
39 class BufferViewDock;
40 class BufferWidget;
41 class MsgProcessorStatusWidget;
42 class NickListWidget;
43 class SystemTrayIcon;
44
45 class QMenu;
46 class QLabel;
47
48 //!\brief The main window of Quassel's QtUi.
49 class MainWin
50 #ifdef HAVE_KDE
51 : public KMainWindow {
52 #else
53 : public QMainWindow {
54 #endif
55   Q_OBJECT
56
57   public:
58     MainWin(QWidget *parent = 0);
59     virtual ~MainWin();
60
61     void init();
62
63     void addBufferView(BufferViewConfig *config = 0);
64     BufferView *allBuffersView() const;
65
66     inline QSystemTrayIcon *systemTrayIcon() const;
67
68     virtual bool event(QEvent *event);
69   public slots:
70     void saveStateToSession(const QString &sessionId);
71     void saveStateToSessionSettings(SessionSettings &s);
72     void showStatusBarMessage(const QString &message);
73
74   protected:
75     void closeEvent(QCloseEvent *event);
76     virtual void changeEvent(QEvent *event);
77
78   protected slots:
79     void connectedToCore();
80     void setConnectedState();
81     void updateLagIndicator(int lag);
82     void securedConnection();
83     void disconnectedFromCore();
84     void setDisconnectedState();
85     void systrayActivated(QSystemTrayIcon::ActivationReason);
86
87   private slots:
88     void addBufferView(int bufferViewConfigId);
89     void removeBufferView(int bufferViewConfigId);
90     void messagesInserted(const QModelIndex &parent, int start, int end);
91     void showAboutDlg();
92     void showChannelList(NetworkId netId = NetworkId());
93     void showCoreConnectionDlg(bool autoConnect = false);
94     void showCoreInfoDlg();
95     void showSettingsDlg();
96     void on_actionEditNetworks_triggered();
97     void on_actionManageViews_triggered();
98     void on_actionLockDockPositions_toggled(bool lock);
99     void on_actionDebugNetworkModel_triggered();
100     void on_actionDebugMessageModel_triggered();
101     void on_actionDebugLog_triggered();
102
103     void clientNetworkCreated(NetworkId);
104     void clientNetworkRemoved(NetworkId);
105     void clientNetworkUpdated();
106     void connectOrDisconnectFromNet();
107
108     void saveStatusBarStatus(bool enabled);
109
110     void loadLayout();
111     void saveLayout();
112
113   signals:
114     void connectToCore(const QVariantMap &connInfo);
115     void disconnectFromCore();
116
117   private:
118
119     QMenu *systrayMenu;
120     QLabel *coreLagLabel;
121     QLabel *sslLabel;
122     MsgProcessorStatusWidget *msgProcessorStatusWidget;
123
124     TitleSetter _titleSetter;
125
126     void setupActions();
127     void setupBufferWidget();
128     void setupMenus();
129     void setupViews();
130     void setupNickWidget();
131     void setupChatMonitor();
132     void setupInputWidget();
133     void setupTopicWidget();
134     void setupStatusBar();
135     void setupSystray();
136     void setupTitleSetter();
137
138     void updateIcon();
139     void toggleVisibility();
140     void enableMenus();
141
142     QSystemTrayIcon *_trayIcon;
143
144     QList<BufferViewDock *> _bufferViews;
145     BufferWidget *_bufferWidget;
146     NickListWidget *_nickListWidget;
147
148     QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
149
150     friend class QtUi;
151 };
152
153 QSystemTrayIcon *MainWin::systemTrayIcon() const {
154   return _trayIcon;
155 }
156
157 #endif