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