0f5e299ed862b20e128784212eaf750b689b0850
[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 disconnectedFromCore();
67     void systrayActivated( QSystemTrayIcon::ActivationReason );
68
69   private slots:
70     void receiveMessage(const Message &msg);
71     void showSettingsDlg();
72     void showNetworkDlg();
73     void showAboutDlg();
74     void showDebugConsole();
75
76     void showCoreConnectionDlg(bool autoConnect = false);
77     void coreConnectionDlgFinished(int result);
78
79     void clientNetworkCreated(NetworkId);
80     void clientNetworkRemoved(NetworkId);
81     void clientNetworkUpdated();
82     void connectOrDisconnectFromNet();
83
84     void changeTopic(const QString &topic);
85     void makeTrayIconBlink();
86
87   signals:
88     void connectToCore(const QVariantMap &connInfo);
89     void disconnectFromCore();
90     void requestBacklog(BufferInfo, QVariant, QVariant);
91
92   private:
93     Ui::MainWin ui;
94     QtUi *gui;
95
96     QMenu *systrayMenu;
97
98     void setupMenus();
99     void setupViews();
100     void setupNickWidget();
101     void setupChatMonitor();
102     void setupInputWidget();
103     void setupTopicWidget();
104     void setupSystray();
105
106     void setupSettingsDlg();
107
108     void toggleVisibility();
109
110     void enableMenus();
111
112     QSystemTrayIcon *systray;
113     QIcon activeTrayIcon;
114     QIcon inactiveTrayIcon;
115     bool trayIconActive;
116     QTimer *timer;
117
118     CoreConnectDlg *coreConnectDlg;
119     SettingsDlg *settingsDlg;
120     DebugConsole *debugConsole;
121
122     BufferId currentBuffer;
123     QString currentProfile;
124
125     QList<QDockWidget *> netViews;
126     NickListWidget *nickListWidget;
127
128     QAction *actionEditNetworks;
129     QList<QAction *> networkActions;
130
131     friend class QtUi;
132 };
133
134 #endif