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