0abcf56ce4f04f1e2206185ac177c800b61335a3
[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     void sendDesktopNotification(const QString &title, const QString &message);
58
59     virtual bool event(QEvent *event);
60
61   public slots:
62     void setTrayIconActivity(bool active = false);
63
64   protected:
65     void closeEvent(QCloseEvent *event);
66     virtual void changeEvent(QEvent *event);
67
68   protected slots:
69     void connectedToCore();
70     void setConnectedState();
71     void updateLagIndicator(int lag);
72     void securedConnection();
73     void disconnectedFromCore();
74     void setDisconnectedState();
75     void systrayActivated( QSystemTrayIcon::ActivationReason );
76
77   private slots:
78     void addBufferView(int bufferViewConfigId);
79     void removeBufferView(int bufferViewConfigId);
80     void receiveMessage(const Message &msg);
81     void showChannelList(NetworkId netId = NetworkId());
82     void showCoreInfoDlg();
83     void showSettingsDlg();
84     void on_actionEditNetworks_triggered();
85     void on_actionManageViews_triggered();
86     void on_actionLockDockPositions_toggled(bool lock);
87     void showAboutDlg();
88     void showDebugConsole();
89
90     void showCoreConnectionDlg(bool autoConnect = false);
91     void coreConnectionDlgFinished(int result);
92
93     void clientNetworkCreated(NetworkId);
94     void clientNetworkRemoved(NetworkId);
95     void clientNetworkUpdated();
96     void connectOrDisconnectFromNet();
97
98     void changeTopic(const QString &topic);
99     void makeTrayIconBlink();
100     void saveStatusBarStatus(bool enabled);
101
102     void loadLayout();
103     void saveLayout();
104
105   signals:
106     void connectToCore(const QVariantMap &connInfo);
107     void disconnectFromCore();
108     void requestBacklog(BufferInfo, QVariant, QVariant);
109
110   private:
111     Ui::MainWin ui;
112     QtUi *gui;
113
114     QMenu *systrayMenu;
115     QLabel *coreLagLabel;
116     QLabel *sslLabel;
117
118     TitleSetter _titleSetter;
119
120     void setupMenus();
121     void setupViews();
122     void setupNickWidget();
123     void setupChatMonitor();
124     void setupInputWidget();
125     void setupTopicWidget();
126     void setupStatusBar();
127     void setupSystray();
128
129     void setupSettingsDlg();
130
131     void toggleVisibility();
132
133     void enableMenus();
134
135     QSystemTrayIcon *systray;
136     QIcon activeTrayIcon;
137     QIcon onlineTrayIcon;
138     QIcon offlineTrayIcon;
139     bool trayIconActive;
140     QTimer *timer;
141
142     CoreConnectDlg *coreConnectDlg;
143     ChannelListDlg *channelListDlg;
144     SettingsDlg *settingsDlg;
145     DebugConsole *debugConsole;
146
147     BufferId currentBuffer;
148     QString currentProfile;
149
150     QList<QDockWidget *> _netViews;
151     NickListWidget *nickListWidget;
152
153     friend class QtUi;
154 };
155
156 #endif