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