-statusbar can now be hidden (you can find it in views at the bottom)
[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     void saveStatusBarStatus(bool enabled);
88
89   signals:
90     void connectToCore(const QVariantMap &connInfo);
91     void disconnectFromCore();
92     void requestBacklog(BufferInfo, QVariant, QVariant);
93
94   private:
95     Ui::MainWin ui;
96     QtUi *gui;
97
98     QMenu *systrayMenu;
99     QLabel *sslLabel;
100
101     void setupMenus();
102     void setupViews();
103     void setupNickWidget();
104     void setupChatMonitor();
105     void setupInputWidget();
106     void setupTopicWidget();
107     void setupStatusBar();
108     void setupSystray();
109
110     void setupSettingsDlg();
111
112     void toggleVisibility();
113
114     void enableMenus();
115
116     QSystemTrayIcon *systray;
117     QIcon activeTrayIcon;
118     QIcon onlineTrayIcon;
119     QIcon offlineTrayIcon;
120     bool trayIconActive;
121     QTimer *timer;
122
123     CoreConnectDlg *coreConnectDlg;
124     SettingsDlg *settingsDlg;
125     DebugConsole *debugConsole;
126
127     BufferId currentBuffer;
128     QString currentProfile;
129
130     QList<QDockWidget *> netViews;
131     NickListWidget *nickListWidget;
132
133     QAction *actionEditNetworks;
134     QList<QAction *> networkActions;
135
136     friend class QtUi;
137 };
138
139 #endif