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