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