/* SPDX-FileCopyrightText: 2018 Kai Uwe Broulik SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ #include "notificationapplet.h" #include #include #include #include #include #include #include "draghelper.h" #include "fileinfo.h" #include "filemenu.h" #include "globalshortcuts.h" #include "jobaggregator.h" #include "texteditclickhandler.h" #include "thumbnailer.h" NotificationApplet::NotificationApplet(QObject *parent, const KPluginMetaData &data, const QVariantList &args) : Plasma::Applet(parent, data, args) { static bool s_typesRegistered = false; if (!s_typesRegistered) { const char uri[] = "org.kde.plasma.private.notifications"; qmlRegisterSingletonType(uri, 2, 0, "DragHelper", [](QQmlEngine *, QJSEngine *) -> QObject * { return new DragHelper(); }); qmlRegisterType(uri, 2, 0, "FileInfo"); qmlRegisterType(uri, 2, 0, "FileMenu"); qmlRegisterType(uri, 2, 0, "GlobalShortcuts"); qmlRegisterType(uri, 2, 0, "JobAggregator"); qmlRegisterType(uri, 2, 0, "TextEditClickHandler"); qmlRegisterType(uri, 2, 0, "Thumbnailer"); qmlProtectModule(uri, 2); s_typesRegistered = true; } connect(qApp, &QGuiApplication::focusWindowChanged, this, &NotificationApplet::focussedPlasmaDialogChanged); } NotificationApplet::~NotificationApplet() = default; void NotificationApplet::init() { } void NotificationApplet::configChanged() { } QWindow *NotificationApplet::focussedPlasmaDialog() const { auto *focusWindow = qApp->focusWindow(); if (qobject_cast(focusWindow)) { return focusWindow; } if (focusWindow) { return qobject_cast(focusWindow->transientParent()); } return nullptr; } QQuickItem *NotificationApplet::systemTrayRepresentation() const { auto *c = containment(); if (!c) { return nullptr; } if (strcmp(c->metaObject()->className(), "SystemTray") != 0) { return nullptr; } return c->property("_plasma_graphicObject").value(); } bool NotificationApplet::isPrimaryScreen(const QRect &rect) const { QScreen *screen = QGuiApplication::primaryScreen(); if (!screen) { return false; } // HACK return rect == screen->geometry(); } void NotificationApplet::forceActivateWindow(QWindow *window) { if (window && window->winId()) { KWindowSystem::forceActiveWindow(window->winId()); } } K_PLUGIN_CLASS(NotificationApplet) #include "notificationapplet.moc"