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