|
|
|
@ -20,24 +20,37 @@
|
|
|
|
#include "controlcenterdialog.h"
|
|
|
|
#include "controlcenterdialog.h"
|
|
|
|
#include <KWindowSystem>
|
|
|
|
#include <KWindowSystem>
|
|
|
|
|
|
|
|
|
|
|
|
ControlCenterDialog::ControlCenterDialog(QQuickView *parent)
|
|
|
|
ControlCenterDialog::ControlCenterDialog(QQuickWindow *parent)
|
|
|
|
: QQuickView(parent)
|
|
|
|
: QQuickWindow(parent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
|
|
|
setFlags(Qt::Popup);
|
|
|
|
|
|
|
|
setColor(Qt::transparent);
|
|
|
|
connect(this, &QQuickView::activeChanged, this, [=] {
|
|
|
|
installEventFilter(this);
|
|
|
|
if (!isActive())
|
|
|
|
|
|
|
|
hide();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlCenterDialog::showEvent(QShowEvent *event)
|
|
|
|
void ControlCenterDialog::open()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager | NET::SkipSwitcher);
|
|
|
|
setVisible(true);
|
|
|
|
QQuickView::showEvent(event);
|
|
|
|
setMouseGrabEnabled(true);
|
|
|
|
|
|
|
|
setKeyboardGrabEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ControlCenterDialog::hideEvent(QHideEvent *event)
|
|
|
|
bool ControlCenterDialog::eventFilter(QObject *object, QEvent *event)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QQuickView::hideEvent(event);
|
|
|
|
if (event->type() == QEvent::MouseButtonPress) {
|
|
|
|
|
|
|
|
if (QWindow *w = qobject_cast<QWindow*>(object)) {
|
|
|
|
|
|
|
|
if (!w->geometry().contains(static_cast<QMouseEvent*>(event)->globalPos())) {
|
|
|
|
|
|
|
|
ControlCenterDialog::setVisible(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (event->type() == QEvent::KeyPress) {
|
|
|
|
|
|
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
|
|
|
|
|
|
|
if (keyEvent->key() == Qt::Key_Escape) {
|
|
|
|
|
|
|
|
ControlCenterDialog::setVisible(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (event->type() == QEvent::Show) {
|
|
|
|
|
|
|
|
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager | NET::SkipSwitcher);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return QObject::eventFilter(object, event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|