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