From 704f0e3e1b44042f139863f739183fea7f1d503b Mon Sep 17 00:00:00 2001 From: kate Date: Tue, 11 Jan 2022 21:19:46 +0800 Subject: [PATCH] fix: notification popup window flags --- notificationd/CMakeLists.txt | 1 + notificationd/application.cpp | 2 + notificationd/notificationpopup.cpp | 43 +++++++++++++++++++ notificationd/notificationpopup.h | 35 +++++++++++++++ notificationd/notificationwindow.cpp | 19 ++++++++ notificationd/notificationwindow.h | 19 ++++++++ ...tionPopup.qml => QmlNotificationPopup.qml} | 4 +- notificationd/qml/main.qml | 2 +- notificationd/resources.qrc | 2 +- 9 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 notificationd/notificationpopup.cpp create mode 100644 notificationd/notificationpopup.h rename notificationd/qml/{NotificationPopup.qml => QmlNotificationPopup.qml} (99%) diff --git a/notificationd/CMakeLists.txt b/notificationd/CMakeLists.txt index ac334d1..6e7f6d0 100644 --- a/notificationd/CMakeLists.txt +++ b/notificationd/CMakeLists.txt @@ -5,6 +5,7 @@ set(SRCS main.cpp notificationsmodel.cpp notificationserver.cpp notification.cpp + notificationpopup.cpp notificationwindow.cpp historymodel.cpp settings.cpp diff --git a/notificationd/application.cpp b/notificationd/application.cpp index 4507c70..7b9335b 100644 --- a/notificationd/application.cpp +++ b/notificationd/application.cpp @@ -22,6 +22,7 @@ #include "screenhelper.h" #include "notificationadaptor.h" #include "historymodel.h" +#include "notificationpopup.h" #include #include @@ -67,6 +68,7 @@ Application::Application(int& argc, char** argv) qmlRegisterType("Cutefish.Notification", 1, 0, "NotificationsModel"); qmlRegisterType("Cutefish.Notification", 1, 0, "HistoryModel"); qmlRegisterType("Cutefish.Notification", 1, 0, "ScreenHelper"); + qmlRegisterType("Cutefish.Notification", 1, 0, "NotificationPopup"); m_instance = true; } diff --git a/notificationd/notificationpopup.cpp b/notificationd/notificationpopup.cpp new file mode 100644 index 0000000..05e7c84 --- /dev/null +++ b/notificationd/notificationpopup.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Kate Leet + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "notificationpopup.h" + +#include + +#include +#include + +NotificationPopup::NotificationPopup(QQuickView *parent) + : QQuickView(parent) +{ + installEventFilter(this); + + setResizeMode(QQuickView::SizeRootObjectToView); + setColor(Qt::transparent); +} + +bool NotificationPopup::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::Show) { + KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager | NET::SkipSwitcher); + } + + return QObject::eventFilter(object, event); +} diff --git a/notificationd/notificationpopup.h b/notificationd/notificationpopup.h new file mode 100644 index 0000000..4b684e5 --- /dev/null +++ b/notificationd/notificationpopup.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Kate Leet + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef NOTIFICATIONPOPUP_H +#define NOTIFICATIONPOPUP_H + +#include + +class NotificationPopup : public QQuickView +{ + Q_OBJECT + +public: + explicit NotificationPopup(QQuickView *parent = nullptr); + + bool eventFilter(QObject *object, QEvent *event) override; +}; + +#endif // NOTIFICATIONPOPUP_H diff --git a/notificationd/notificationwindow.cpp b/notificationd/notificationwindow.cpp index c4e5221..08d7bc4 100644 --- a/notificationd/notificationwindow.cpp +++ b/notificationd/notificationwindow.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Kate Leet + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "notificationwindow.h" #include "notificationsmodel.h" #include "historymodel.h" diff --git a/notificationd/notificationwindow.h b/notificationd/notificationwindow.h index f0380c1..8ded38c 100644 --- a/notificationd/notificationwindow.h +++ b/notificationd/notificationwindow.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Kate Leet + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef NOTIFICATIONWINDOW_H #define NOTIFICATIONWINDOW_H diff --git a/notificationd/qml/NotificationPopup.qml b/notificationd/qml/QmlNotificationPopup.qml similarity index 99% rename from notificationd/qml/NotificationPopup.qml rename to notificationd/qml/QmlNotificationPopup.qml index 62bde48..85984af 100644 --- a/notificationd/qml/NotificationPopup.qml +++ b/notificationd/qml/QmlNotificationPopup.qml @@ -25,9 +25,9 @@ import QtGraphicalEffects 1.0 import FishUI 1.0 as FishUI import Cutefish.Notification 1.0 -Window { +NotificationPopup { id: control - flags: Qt.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup + flags: Qt.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint width: 400 height: 70 color: "transparent" diff --git a/notificationd/qml/main.qml b/notificationd/qml/main.qml index 84c48ab..18fa5cf 100644 --- a/notificationd/qml/main.qml +++ b/notificationd/qml/main.qml @@ -36,7 +36,7 @@ Item { property Instantiator popupInstantiator: Instantiator { model: notificationsModel - delegate: NotificationPopup {} + delegate: QmlNotificationPopup {} onObjectAdded: { positionPopups() diff --git a/notificationd/resources.qrc b/notificationd/resources.qrc index 23edb7d..e585cac 100644 --- a/notificationd/resources.qrc +++ b/notificationd/resources.qrc @@ -1,7 +1,7 @@ qml/main.qml - qml/NotificationPopup.qml + qml/QmlNotificationPopup.qml images/dark/close.svg images/light/close.svg qml/NotificationWindow.qml