forked from MadFishTheOne/qtpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
panelapplication.h
98 lines (78 loc) · 2.58 KB
/
panelapplication.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef PANELAPPLICATION_H
#define PANELAPPLICATION_H
#include <QtCore/QSettings>
#include <QtCore/QTimer>
#if QT_VERSION >= 0x050000
#include <QApplication>
#include <QFont>
#include <QAbstractNativeEventFilter>
#include <xcb/xcb.h>
#else
#include <QtGui/QApplication>
#include <QtGui/QFont>
#endif
#include <QDebug>
#include "iconloader.h"
#include "dpisupport.h"
#include "desktopapplications.h"
#include "ui_panelapplicationsettings.h"
#include "panelwindow.h"
#include "x11support.h"
class IconLoader;
class X11Support;
class DesktopApplications;
#if QT_VERSION >= 0x050000
class MyXcbEventFilter : public QAbstractNativeEventFilter
{
public:
MyXcbEventFilter() :m_x11support(NULL) {}
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE
{
xcb_generic_event_t *ev = static_cast<xcb_generic_event_t *>(message);
if (m_x11support) m_x11support->onX11Event(ev);
return false;
}
void setX11Support(X11Support *x11support) { m_x11support = x11support; }
private:
X11Support *m_x11support;
};
#endif
class PanelApplication: public QApplication
{
Q_OBJECT
public:
PanelApplication(int& argc, char** argv);
~PanelApplication();
static PanelApplication* instance()
{
return m_instance;
}
#if QT_VERSION >= 0x050000
MyXcbEventFilter myXEv;
#endif
bool x11EventFilter(XEvent* event);
void init();
void reset();
void setFontName(const QString& fontName);
void setIconThemeName(const QString& iconThemeName);
const QFont& panelFont() const
{
return m_panelFont;
}
public slots:
void showConfigurationDialog();
private slots:
void reinit();
private:
static PanelApplication* m_instance;
IconLoader* m_iconLoader;
X11Support* m_x11support;
DesktopApplications* m_desktopApplications;
QString m_fontName;
QString m_iconThemeName;
PanelWindow::Anchor m_verticalAnchor;
QString m_defaultIconThemeName;
QFont m_panelFont;
QVector<PanelWindow*> m_panelWindows;
};
#endif