Test our newly acquired shortcut capabilities by finally allowing Ctrl+F to trigger...
[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 #include "sessionsettings.h"
29
30 #include <QSystemTrayIcon>
31 #include <QTimer>
32
33 class ActionCollection;
34 class Buffer;
35 class BufferViewConfig;
36 class MsgProcessorStatusWidget;
37 class Message;
38 class NickListWidget;
39
40 #ifdef HAVE_DBUS
41 #  include "desktopnotifications.h"
42 #endif
43
44 //!\brief The main window of Quassel's QtUi.
45 class MainWin : public QMainWindow {
46   Q_OBJECT
47
48   public:
49     MainWin(QWidget *parent = 0);
50     virtual ~MainWin();
51
52     void init();
53
54     void addBufferView(BufferViewConfig *config = 0);
55
56     void displayTrayIconMessage(const QString &title, const QString &message);
57
58 #ifdef HAVE_DBUS
59     void sendDesktopNotification(const QString &title, const QString &message);
60 #endif
61
62     virtual bool event(QEvent *event);
63   public slots:
64     void setTrayIconActivity(bool active = false);
65     void saveStateToSession(const QString &sessionId);
66     void saveStateToSessionSettings(SessionSettings &s);
67
68   protected:
69     void closeEvent(QCloseEvent *event);
70     virtual void changeEvent(QEvent *event);
71
72   protected slots:
73     void connectedToCore();
74     void setConnectedState();
75     void updateLagIndicator(int lag);
76     void securedConnection();
77     void disconnectedFromCore();
78     void setDisconnectedState();
79     void systrayActivated( QSystemTrayIcon::ActivationReason );
80
81   private slots:
82     void addBufferView(int bufferViewConfigId);
83     void removeBufferView(int bufferViewConfigId);
84     void messagesInserted(const QModelIndex &parent, int start, int end);
85     void showChannelList(NetworkId netId = NetworkId());
86     void showCoreInfoDlg();
87     void showSettingsDlg();
88     void on_actionEditNetworks_triggered();
89     void on_actionManageViews_triggered();
90     void on_actionLockDockPositions_toggled(bool lock);
91     void showAboutDlg();
92     void on_actionDebugNetworkModel_triggered(bool);
93
94     void showCoreConnectionDlg(bool autoConnect = false);
95
96     void clientNetworkCreated(NetworkId);
97     void clientNetworkRemoved(NetworkId);
98     void clientNetworkUpdated();
99     void connectOrDisconnectFromNet();
100
101     void makeTrayIconBlink();
102     void saveStatusBarStatus(bool enabled);
103
104     void loadLayout();
105     void saveLayout();
106
107 #ifdef HAVE_DBUS
108     void desktopNotificationClosed(uint id, uint reason);
109     void desktopNotificationInvoked(uint id, const QString & action);
110 #endif
111
112   signals:
113     void connectToCore(const QVariantMap &connInfo);
114     void disconnectFromCore();
115
116   private:
117     Ui::MainWin ui;
118
119     QMenu *systrayMenu;
120     QLabel *coreLagLabel;
121     QLabel *sslLabel;
122     MsgProcessorStatusWidget *msgProcessorStatusWidget;
123
124     TitleSetter _titleSetter;
125
126     void setupActions();
127     void setupMenus();
128     void setupViews();
129     void setupNickWidget();
130     void setupChatMonitor();
131     void setupInputWidget();
132     void setupTopicWidget();
133     void setupStatusBar();
134     void setupSystray();
135
136     void toggleVisibility();
137     void enableMenus();
138
139     QSystemTrayIcon *systray;
140     QIcon activeTrayIcon;
141     QIcon onlineTrayIcon;
142     QIcon offlineTrayIcon;
143     bool trayIconActive;
144     QTimer *timer;
145
146     BufferId currentBuffer;
147     QString currentProfile;
148
149     QList<QDockWidget *> _netViews;
150     NickListWidget *nickListWidget;
151
152     ActionCollection *_actionCollection;
153
154 #ifdef HAVE_DBUS
155     org::freedesktop::Notifications *desktopNotifications;
156     quint32 notificationId;
157 #endif
158
159     friend class QtUi;
160 };
161
162 #endif