Added a core lag indicator to the statusbar
[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 #include "ui_mainwin.h"
25
26 #include "qtui.h"
27 #include "titlesetter.h"
28
29 #include <QSystemTrayIcon>
30 #include <QTimer>
31
32
33 class ServerListDlg;
34 class ChannelListDlg;
35 class CoreConnectDlg;
36 class Buffer;
37 class BufferViewConfig;
38 class SettingsDlg;
39 class QtUi;
40 class Message;
41 class NickListWidget;
42 class DebugConsole;
43
44
45 //!\brief The main window of Quassel's QtUi.
46 class MainWin : public QMainWindow {
47   Q_OBJECT
48
49   public:
50     MainWin(QtUi *gui, QWidget *parent = 0);
51     virtual ~MainWin();
52
53     void init();
54     void addBufferView(BufferViewConfig *config = 0);
55
56     void displayTrayIconMessage(const QString &title, const QString &message);
57
58     virtual bool event(QEvent *event);
59
60   public slots:
61     void setTrayIconActivity(bool active = false);
62
63   protected:
64     void closeEvent(QCloseEvent *event);
65     virtual void changeEvent(QEvent *event);
66
67   protected slots:
68     void connectedToCore();
69     void setConnectedState();
70     void updateLagIndicator(float lag);
71     void securedConnection();
72     void disconnectedFromCore();
73     void setDisconnectedState();
74     void systrayActivated( QSystemTrayIcon::ActivationReason );
75
76   private slots:
77     void addBufferView(int bufferViewConfigId);
78     void removeBufferView(int bufferViewConfigId);
79     void receiveMessage(const Message &msg);
80     void showChannelList(NetworkId netId = NetworkId());
81     void showCoreInfoDlg();
82     void showSettingsDlg();
83     void on_actionEditNetworks_triggered();
84     void on_actionManageViews_triggered();
85     void on_actionLockDockPositions_toggled(bool lock);
86     void showAboutDlg();
87     void showDebugConsole();
88
89     void showCoreConnectionDlg(bool autoConnect = false);
90     void coreConnectionDlgFinished(int result);
91
92     void clientNetworkCreated(NetworkId);
93     void clientNetworkRemoved(NetworkId);
94     void clientNetworkUpdated();
95     void connectOrDisconnectFromNet();
96
97     void changeTopic(const QString &topic);
98     void makeTrayIconBlink();
99     void saveStatusBarStatus(bool enabled);
100
101     void loadLayout();
102     void saveLayout();
103   
104   signals:
105     void connectToCore(const QVariantMap &connInfo);
106     void disconnectFromCore();
107     void requestBacklog(BufferInfo, QVariant, QVariant);
108
109   private:
110     Ui::MainWin ui;
111     QtUi *gui;
112
113     QMenu *systrayMenu;
114     QLabel *coreLagLabel;
115     QLabel *sslLabel;
116
117     TitleSetter _titleSetter;
118
119     void setupMenus();
120     void setupViews();
121     void setupNickWidget();
122     void setupChatMonitor();
123     void setupInputWidget();
124     void setupTopicWidget();
125     void setupStatusBar();
126     void setupSystray();
127
128     void setupSettingsDlg();
129
130     void toggleVisibility();
131
132     void enableMenus();
133
134     QSystemTrayIcon *systray;
135     QIcon activeTrayIcon;
136     QIcon onlineTrayIcon;
137     QIcon offlineTrayIcon;
138     bool trayIconActive;
139     QTimer *timer;
140
141     CoreConnectDlg *coreConnectDlg;
142     ChannelListDlg *channelListDlg;
143     SettingsDlg *settingsDlg;
144     DebugConsole *debugConsole;
145
146     BufferId currentBuffer;
147     QString currentProfile;
148
149     QList<QDockWidget *> _netViews;
150     NickListWidget *nickListWidget;
151
152     friend class QtUi;
153 };
154
155 #endif