-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
DesktopPanel.cxx
103 lines (80 loc) · 2.89 KB
/
DesktopPanel.cxx
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
99
100
101
102
103
/*
This file is part of liquidshell.
SPDX-FileCopyrightText: 2017 - 2024 Martin Koller <kollix@aon.at>
SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <DesktopPanel.hxx>
#include <StartMenu.hxx>
#include <QuickLaunch.hxx>
#include <AppMenu.hxx>
#include <Pager.hxx>
#include <TaskBar.hxx>
#include <LockLogout.hxx>
#include <SysLoad.hxx>
#include <SysTray.hxx>
#include <ClockWidget.hxx>
#include <WindowList.hxx>
#include <KWinCompat.hxx>
#include <QHBoxLayout>
#include <QResizeEvent>
#include <QDBusConnection>
#include <QDebug>
//--------------------------------------------------------------------------------
DesktopPanel::DesktopPanel(QWidget *parent)
: QFrame(parent, Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus)
{
setAttribute(Qt::WA_AlwaysShowToolTips);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setWindowIcon(QIcon::fromTheme("liquidshell"));
KWinCompat::setState(winId(), NET::KeepAbove);
KWinCompat::setOnAllDesktops(winId(), true);
KWinCompat::setType(winId(), NET::Dock);
setFrameShape(QFrame::StyledPanel);
QHBoxLayout *hboxLayout = new QHBoxLayout(this);
hboxLayout->setContentsMargins(QMargins());
hboxLayout->setSpacing(2);
hboxLayout->addWidget(new StartMenu(this));
hboxLayout->addWidget(new QuickLaunch(this));
hboxLayout->addWidget(new AppMenu(this));
hboxLayout->addWidget(new Pager(this));
hboxLayout->addWidget(new WindowList(this));
hboxLayout->addWidget(new TaskBar(this));
hboxLayout->addWidget(new LockLogout(this));
hboxLayout->addWidget(new SysLoad(this));
hboxLayout->addWidget(new SysTray(this));
hboxLayout->addWidget(new ClockWidget(this));
// to get notified about num-of-rows changed
updateRowCount();
QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.connect(QString(), "/KWin", "org.kde.KWin", "reloadConfig", this, SLOT(updateRowCount()));
connect(KWinCompat::self(), &KWinCompat::numberOfDesktopsChanged, this, &DesktopPanel::updateRowCount);
}
//--------------------------------------------------------------------------------
void DesktopPanel::updateRowCount()
{
NETRootInfo ri(qApp->nativeInterface<QNativeInterface::QX11Application>()->connection(), NET::Property(), NET::WM2DesktopLayout);
int newRows = std::max(1, ri.desktopLayoutColumnsRows().height());
if ( newRows != rows )
{
rows = newRows;
emit rowsChanged(rows);
}
}
//--------------------------------------------------------------------------------
bool DesktopPanel::event(QEvent *ev)
{
bool ret = QFrame::event(ev);
if ( ev->type() == QEvent::LayoutRequest )
{
if ( sizeHint().height() != height() )
emit resized();
}
return ret;
}
//--------------------------------------------------------------------------------
void DesktopPanel::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
emit resized();
}
//--------------------------------------------------------------------------------