first version of core info dialog
[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
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 showChannelList(NetworkId netId = NetworkId());
80     void showCoreInfoDlg();
81     void showSettingsDlg();
82     void on_actionEditNetworks_triggered();
83     void on_actionManageViews_triggered();
84     void on_actionLockDockPositions_toggled(bool lock);
85     void showAboutDlg();
86     void showDebugConsole();
87
88     void showCoreConnectionDlg(bool autoConnect = false);
89     void coreConnectionDlgFinished(int result);
90
91     void clientNetworkCreated(NetworkId);
92     void clientNetworkRemoved(NetworkId);
93     void clientNetworkUpdated();
94     void connectOrDisconnectFromNet();
95
96     void changeTopic(const QString &topic);
97     void makeTrayIconBlink();
98     void saveStatusBarStatus(bool enabled);
99
100     void loadLayout();
101     void saveLayout();
102   
103   signals:
104     void connectToCore(const QVariantMap &connInfo);
105     void disconnectFromCore();
106     void requestBacklog(BufferInfo, QVariant, QVariant);
107
108   private:
109     Ui::MainWin ui;
110     QtUi *gui;
111
112     QMenu *systrayMenu;
113     QLabel *sslLabel;
114
115     TitleSetter _titleSetter;
116
117     void setupMenus();
118     void setupViews();
119     void setupNickWidget();
120     void setupChatMonitor();
121     void setupInputWidget();
122     void setupTopicWidget();
123     void setupStatusBar();
124     void setupSystray();
125
126     void setupSettingsDlg();
127
128     void toggleVisibility();
129
130     void enableMenus();
131
132     QSystemTrayIcon *systray;
133     QIcon activeTrayIcon;
134     QIcon onlineTrayIcon;
135     QIcon offlineTrayIcon;
136     bool trayIconActive;
137     QTimer *timer;
138
139     CoreConnectDlg *coreConnectDlg;
140     ChannelListDlg *channelListDlg;
141     SettingsDlg *settingsDlg;
142     DebugConsole *debugConsole;
143
144     BufferId currentBuffer;
145     QString currentProfile;
146
147     QList<QDockWidget *> _netViews;
148     NickListWidget *nickListWidget;
149
150     friend class QtUi;
151 };
152
153 #endif