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