diff --git a/containments/homescreen/applicationlistmodel.cpp b/containments/homescreen/applicationlistmodel.cpp index f0b37fdf..e43b0964 100644 --- a/containments/homescreen/applicationlistmodel.cpp +++ b/containments/homescreen/applicationlistmodel.cpp @@ -9,9 +9,9 @@ // Qt #include +#include #include #include -#include #include #include @@ -32,11 +32,10 @@ constexpr int MAX_FAVOURITES = 5; ApplicationListModel::ApplicationListModel(HomeScreen *parent) - : QAbstractListModel(parent), - m_applet(parent) + : QAbstractListModel(parent) + , m_applet(parent) { - connect(KSycoca::self(), qOverload(&KSycoca::databaseChanged), - this, &ApplicationListModel::sycocaDbChanged); + connect(KSycoca::self(), qOverload(&KSycoca::databaseChanged), this, &ApplicationListModel::sycocaDbChanged); loadSettings(); initWayland(); @@ -65,7 +64,7 @@ void ApplicationListModel::loadSettings() ++i; } - //loadApplications(); + // loadApplications(); } QHash ApplicationListModel::roleNames() const @@ -112,39 +111,36 @@ void ApplicationListModel::initWayland() } auto *registry = new Registry(this); registry->create(connection); - connect(registry, &Registry::plasmaWindowManagementAnnounced, this, - [this, registry] (quint32 name, quint32 version) { - m_windowManagement = registry->createPlasmaWindowManagement(name, version, this); - qRegisterMetaType >("QVector"); + connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [this, registry](quint32 name, quint32 version) { + m_windowManagement = registry->createPlasmaWindowManagement(name, version, this); + qRegisterMetaType>("QVector"); - connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated, - this, [this] (KWayland::Client::PlasmaWindow *window) { - if (window->appId() == QStringLiteral("org.kde.plasmashell")) { - return; - } - int idx = 0; - for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { - if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { - (*i).window = window; - emit dataChanged(index(idx, 0), index(idx, 0)); - connect(window, &KWayland::Client::PlasmaWindow::unmapped, this, [this, window] () { - int idx = 0; - for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { - if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { - (*i).window = nullptr; - emit dataChanged(index(idx, 0), index(idx, 0)); - break; - } - idx++; + connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated, this, [this](KWayland::Client::PlasmaWindow *window) { + if (window->appId() == QStringLiteral("org.kde.plasmashell")) { + return; + } + int idx = 0; + for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { + if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { + (*i).window = window; + emit dataChanged(index(idx, 0), index(idx, 0)); + connect(window, &KWayland::Client::PlasmaWindow::unmapped, this, [this, window]() { + int idx = 0; + for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { + if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { + (*i).window = nullptr; + emit dataChanged(index(idx, 0), index(idx, 0)); + break; } - }); - break; - } - idx++; + idx++; + } + }); + break; } - }); - } - ); + idx++; + } + }); + }); registry->setup(); connection->roundtrip(); @@ -162,7 +158,8 @@ void ApplicationListModel::loadApplications() m_applicationList.clear(); KServiceGroup::Ptr group = KServiceGroup::root(); - if (!group || !group->isValid()) return; + if (!group || !group->isValid()) + return; KServiceGroup::List subGroupList = group->entries(true); QMap orderedList; @@ -180,7 +177,7 @@ void ApplicationListModel::loadApplications() if (!serviceGroup->noDisplay()) { KServiceGroup::List entryGroupList = serviceGroup->entries(true); - for(KServiceGroup::List::ConstIterator it = entryGroupList.constBegin(); it != entryGroupList.constEnd(); it++) { + for (KServiceGroup::List::ConstIterator it = entryGroupList.constBegin(); it != entryGroupList.constEnd(); it++) { KSycocaEntry::Ptr entry = (*it); if (entry->isType(KST_KServiceGroup)) { @@ -283,7 +280,7 @@ Qt::ItemFlags ApplicationListModel::flags(const QModelIndex &index) const { if (!index.isValid()) return {}; - return Qt::ItemIsDragEnabled|QAbstractListModel::flags(index); + return Qt::ItemIsDragEnabled | QAbstractListModel::flags(index); } int ApplicationListModel::rowCount(const QModelIndex &parent) const @@ -295,7 +292,7 @@ int ApplicationListModel::rowCount(const QModelIndex &parent) const return m_applicationList.count(); } -void ApplicationListModel::moveRow(const QModelIndex& /* sourceParent */, int sourceRow, const QModelIndex& /* destinationParent */, int destinationChild) +void ApplicationListModel::moveRow(const QModelIndex & /* sourceParent */, int sourceRow, const QModelIndex & /* destinationParent */, int destinationChild) { moveItem(sourceRow, destinationChild); } @@ -314,8 +311,7 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) if (location == Favorites) { qWarning() << "favoriting" << row << data.name; // Deny favorites when full - if (row >= m_maxFavoriteCount || m_favorites.count() >= m_maxFavoriteCount || - m_favorites.contains(data.uniqueId)) { + if (row >= m_maxFavoriteCount || m_favorites.count() >= m_maxFavoriteCount || m_favorites.contains(data.uniqueId)) { return; } @@ -326,8 +322,8 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) } emit favoriteCountChanged(); - // Out of favorites - } else if (data.location == Favorites) { + // Out of favorites + } else if (data.location == Favorites) { m_favorites.removeAll(data.uniqueId); if (m_applet) { m_applet->config().writeEntry("Favorites", m_favorites); @@ -342,8 +338,8 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) m_applet->config().writeEntry("DesktopItems", m_desktopItems.values()); } - // Out of Desktop - } else if (data.location == Desktop) { + // Out of Desktop + } else if (data.location == Desktop) { m_desktopItems.remove(data.uniqueId); if (m_applet) { m_applet->config().writeEntry(QStringLiteral("DesktopItems"), m_desktopItems.values()); @@ -359,8 +355,7 @@ void ApplicationListModel::setLocation(int row, LauncherLocation location) void ApplicationListModel::moveItem(int row, int destination) { - if (row < 0 || destination < 0 || row >= m_applicationList.length() || - destination >= m_applicationList.length() || row == destination) { + if (row < 0 || destination < 0 || row >= m_applicationList.length() || destination >= m_applicationList.length() || row == destination) { return; } if (destination > row) { @@ -378,7 +373,6 @@ void ApplicationListModel::moveItem(int row, int destination) m_applicationList.insert(destination, data); } - m_appOrder.clear(); m_appPositions.clear(); int i = 0; @@ -483,7 +477,7 @@ void ApplicationListModel::setMinimizedDelegate(int row, QQuickItem *delegate) return; } - QRect rect = delegate->mapRectToScene(QRectF(0,0, delegate->width(), delegate->height())).toRect(); + QRect rect = delegate->mapRectToScene(QRectF(0, 0, delegate->width(), delegate->height())).toRect(); window->setMinimizedGeometry(surface, rect); } @@ -516,4 +510,3 @@ void ApplicationListModel::unsetMinimizedDelegate(int row, QQuickItem *delegate) } #include "moc_applicationlistmodel.cpp" - diff --git a/containments/homescreen/applicationlistmodel.h b/containments/homescreen/applicationlistmodel.h index fd067e6a..b9e39220 100644 --- a/containments/homescreen/applicationlistmodel.h +++ b/containments/homescreen/applicationlistmodel.h @@ -8,9 +8,9 @@ #define APPLICATIONLISTMODEL_H // Qt -#include #include #include +#include #include #include "homescreen.h" @@ -28,7 +28,8 @@ class PlasmaWindow; class ApplicationListModel; -class ApplicationListModel : public QAbstractListModel { +class ApplicationListModel : public QAbstractListModel +{ Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) @@ -75,8 +76,14 @@ public: void moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild); - int count() const { return m_applicationList.count(); } - int favoriteCount() const { return m_favorites.count();} + int count() const + { + return m_applicationList.count(); + } + int favoriteCount() const + { + return m_favorites.count(); + } int maxFavoriteCount() const; void setMaxFavoriteCount(int count); @@ -102,7 +109,7 @@ public: Q_INVOKABLE void unsetMinimizedDelegate(int row, QQuickItem *delegate); public Q_SLOTS: - void sycocaDbChanged(const QStringList &change); + void sycocaDbChanged(const QStringList &change); Q_SIGNALS: void countChanged(); diff --git a/containments/homescreen/favoritesmodel.cpp b/containments/homescreen/favoritesmodel.cpp index 551e3abc..541c32e4 100644 --- a/containments/homescreen/favoritesmodel.cpp +++ b/containments/homescreen/favoritesmodel.cpp @@ -9,14 +9,13 @@ // Qt #include -#include #include +#include // KDE #include #include - constexpr int MAX_FAVOURITES = 5; FavoritesModel::FavoritesModel(HomeScreen *parent) @@ -26,7 +25,6 @@ FavoritesModel::FavoritesModel(HomeScreen *parent) FavoritesModel::~FavoritesModel() = default; - QString FavoritesModel::storageToUniqueId(const QString &storageId) const { if (storageId.isEmpty()) { @@ -52,10 +50,8 @@ QString FavoritesModel::uniqueToStorageId(const QString &uniqueId) const return uniqueId.split(QLatin1Char('-')).first(); } - void FavoritesModel::loadApplications() { - beginResetModel(); m_applicationList.clear(); @@ -95,7 +91,7 @@ void FavoritesModel::loadApplications() } m_desktopItems.remove(uniqueId); } - + endResetModel(); emit countChanged(); @@ -183,4 +179,3 @@ void FavoritesModel::removeFavorite(int row) } #include "moc_favoritesmodel.cpp" - diff --git a/containments/homescreen/favoritesmodel.h b/containments/homescreen/favoritesmodel.h index 0a84edaf..98c71f1c 100644 --- a/containments/homescreen/favoritesmodel.h +++ b/containments/homescreen/favoritesmodel.h @@ -7,13 +7,13 @@ #pragma once // Qt -#include #include #include +#include #include -#include "homescreen.h" #include "applicationlistmodel.h" +#include "homescreen.h" class QString; @@ -28,14 +28,14 @@ class PlasmaWindow; class FavoritesModel; -class FavoritesModel : public ApplicationListModel { +class FavoritesModel : public ApplicationListModel +{ Q_OBJECT public: FavoritesModel(HomeScreen *parent = nullptr); ~FavoritesModel() override; - QString storageToUniqueId(const QString &storageId) const; QString uniqueToStorageId(const QString &uniqueId) const; @@ -43,7 +43,4 @@ public: Q_INVOKABLE void removeFavorite(int row); Q_INVOKABLE void loadApplications() override; - - }; - diff --git a/containments/homescreen/homescreen.cpp b/containments/homescreen/homescreen.cpp index fdd1131d..63c8c081 100644 --- a/containments/homescreen/homescreen.cpp +++ b/containments/homescreen/homescreen.cpp @@ -7,9 +7,9 @@ #include "applicationlistmodel.h" #include "favoritesmodel.h" -#include #include #include +#include HomeScreen::HomeScreen(QObject *parent, const QVariantList &args) : Plasma::Containment(parent, args) diff --git a/containments/homescreen/homescreen.h b/containments/homescreen/homescreen.h index 16dd62b3..d867a86b 100644 --- a/containments/homescreen/homescreen.h +++ b/containments/homescreen/homescreen.h @@ -7,7 +7,6 @@ #ifndef HOMESCREEN_H #define HOMESCREEN_H - #include class QQuickItem; @@ -20,7 +19,7 @@ class HomeScreen : public Plasma::Containment Q_PROPERTY(ApplicationListModel *applicationListModel READ applicationListModel CONSTANT) public: - HomeScreen( QObject *parent, const QVariantList &args ); + HomeScreen(QObject *parent, const QVariantList &args); ~HomeScreen() override; void configChanged() override; @@ -31,7 +30,7 @@ public: Q_INVOKABLE void stackAfter(QQuickItem *item1, QQuickItem *item2); protected: - // void configChanged() override; + // void configChanged() override; private: ApplicationListModel *m_applicationListModel = nullptr; diff --git a/containments/panel/phonepanel.cpp b/containments/panel/phonepanel.cpp index 2bc54992..06aab12f 100644 --- a/containments/panel/phonepanel.cpp +++ b/containments/panel/phonepanel.cpp @@ -7,22 +7,22 @@ #include "phonepanel.h" -#include #include +#include #include -#include -#include #include +#include +#include -#include #include -#include +#include #include -#include +#include #include -#include #include +#include +#include #define FORMAT24H "HH:mm:ss" @@ -33,8 +33,8 @@ constexpr int SCREENSHOT_DELAY = 200; static int readData(int theFile, QByteArray &theDataOut) { // implementation based on QtWayland file qwaylanddataoffer.cpp - char lBuffer[4096]; - int lRetryCount = 0; + char lBuffer[4096]; + int lRetryCount = 0; ssize_t lBytesRead = 0; do { @@ -73,22 +73,21 @@ static QImage readImage(int thePipeFd) PhonePanel::PhonePanel(QObject *parent, const QVariantList &args) : Plasma::Containment(parent, args) { - //setHasConfigurationInterface(true); + // setHasConfigurationInterface(true); m_kscreenInterface = new org::kde::KScreen(QStringLiteral("org.kde.kded5"), QStringLiteral("/modules/kscreen"), QDBusConnection::sessionBus(), this); m_screenshotInterface = new org::kde::kwin::Screenshot(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QDBusConnection::sessionBus(), this); - + m_localeConfig = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig); m_localeConfigWatcher = KConfigWatcher::create(m_localeConfig); - + // watch for changes to locale config, to update 12/24 hour time - connect(m_localeConfigWatcher.data(), &KConfigWatcher::configChanged, - this, [this](const KConfigGroup &group, const QByteArrayList &names) -> void { - if (group.name() == "Locale") { - // we have to reparse for new changes (from system settings) - m_localeConfig->reparseConfiguration(); - Q_EMIT isSystem24HourFormatChanged(); - } - }); + connect(m_localeConfigWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) -> void { + if (group.name() == "Locale") { + // we have to reparse for new changes (from system settings) + m_localeConfig->reparseConfiguration(); + Q_EMIT isSystem24HourFormatChanged(); + } + }); } PhonePanel::~PhonePanel() = default; @@ -152,9 +151,7 @@ void PhonePanel::takeScreenshot() } QDir picturesDir(filePath); if (!picturesDir.mkpath(QStringLiteral("Screenshots"))) { - qWarning() << "Couldn't create folder at" - << picturesDir.path() + QStringLiteral("/Screenshots") - << "to take screenshot."; + qWarning() << "Couldn't create folder at" << picturesDir.path() + QStringLiteral("/Screenshots") << "to take screenshot."; return; } filePath += QStringLiteral("/Screenshots/Screenshot_%1.png").arg(QDateTime::currentDateTime().toString(QStringLiteral("yyyyMMdd_hhmmss"))); @@ -162,14 +159,14 @@ void PhonePanel::takeScreenshot() // wait ~200 ms to wait for rest of animations QTimer::singleShot(SCREENSHOT_DELAY, [=]() { int lPipeFds[2]; - if (pipe2(lPipeFds, O_CLOEXEC|O_NONBLOCK) != 0) { + if (pipe2(lPipeFds, O_CLOEXEC | O_NONBLOCK) != 0) { qWarning() << "Could not take screenshot"; return; } // Take fullscreen screenshot, and no pointer QDBusPendingCall pcall = m_screenshotInterface->screenshotFullscreen(QDBusUnixFileDescriptor(lPipeFds[1]), false, true); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); - QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [](QDBusPendingCallWatcher* watcher) { + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [](QDBusPendingCallWatcher *watcher) { if (watcher->isError()) { const auto error = watcher->error(); qWarning() << "Error calling KWin DBus interface:" << error.name() << error.message(); @@ -177,23 +174,21 @@ void PhonePanel::takeScreenshot() watcher->deleteLater(); }); const auto lWatcher = new QFutureWatcher(this); - QObject::connect(lWatcher, &QFutureWatcher::finished, this, - [lWatcher, filePath] () { - lWatcher->deleteLater(); - const QImage lImage = lWatcher->result(); - qDebug() << lImage; - if(!lImage.save(filePath, "PNG")) { - qWarning() << "Failed to save screenshot to" << filePath; - } else { - KNotification *notif = new KNotification("captured"); - notif->setComponentName(QStringLiteral("plasma_phone_components")); - notif->setTitle(i18n("New Screenshot")); - notif->setUrls({filePath}); - notif->setText(i18n("New screenshot saved to %1", filePath)); - notif->sendEvent(); - } + QObject::connect(lWatcher, &QFutureWatcher::finished, this, [lWatcher, filePath]() { + lWatcher->deleteLater(); + const QImage lImage = lWatcher->result(); + qDebug() << lImage; + if (!lImage.save(filePath, "PNG")) { + qWarning() << "Failed to save screenshot to" << filePath; + } else { + KNotification *notif = new KNotification("captured"); + notif->setComponentName(QStringLiteral("plasma_phone_components")); + notif->setTitle(i18n("New Screenshot")); + notif->setUrls({filePath}); + notif->setText(i18n("New screenshot saved to %1", filePath)); + notif->sendEvent(); } - ); + }); lWatcher->setFuture(QtConcurrent::run(readImage, lPipeFds[0])); close(lPipeFds[1]); }); @@ -202,7 +197,7 @@ void PhonePanel::takeScreenshot() bool PhonePanel::isSystem24HourFormat() { KConfigGroup localeSettings = KConfigGroup(m_localeConfig, "Locale"); - + QString timeFormat = localeSettings.readEntry("TimeFormat", QStringLiteral(FORMAT24H)); return timeFormat == QStringLiteral(FORMAT24H); } diff --git a/containments/panel/phonepanel.h b/containments/panel/phonepanel.h index 65e0f623..59b9351c 100644 --- a/containments/panel/phonepanel.h +++ b/containments/panel/phonepanel.h @@ -7,11 +7,10 @@ #ifndef PHONEPANEL_H #define PHONEPANEL_H - #include -#include #include +#include #include "kscreeninterface.h" #include "screenshotinterface.h" @@ -22,8 +21,9 @@ class PhonePanel : public Plasma::Containment Q_PROPERTY(bool autoRotateEnabled READ autoRotate WRITE setAutoRotate NOTIFY autoRotateChanged); Q_PROPERTY(bool torchEnabled READ torchEnabled NOTIFY torchChanged); Q_PROPERTY(bool isSystem24HourFormat READ isSystem24HourFormat NOTIFY isSystem24HourFormatChanged); + public: - PhonePanel( QObject *parent, const QVariantList &args ); + PhonePanel(QObject *parent, const QVariantList &args); ~PhonePanel() override; public Q_SLOTS: @@ -33,9 +33,9 @@ public Q_SLOTS: bool autoRotate(); void setAutoRotate(bool value); - + bool torchEnabled() const; - + bool isSystem24HourFormat(); signals: @@ -45,7 +45,7 @@ signals: private: bool m_running = false; - + KConfigWatcher::Ptr m_localeConfigWatcher; KSharedConfig::Ptr m_localeConfig; diff --git a/containments/taskpanel/taskpanel.cpp b/containments/taskpanel/taskpanel.cpp index feef3e16..558b17ee 100644 --- a/containments/taskpanel/taskpanel.cpp +++ b/containments/taskpanel/taskpanel.cpp @@ -6,18 +6,18 @@ #include "taskpanel.h" -#include #include #include #include +#include -#include #include +#include #include #include -#include #include #include +#include #include @@ -31,9 +31,10 @@ class KwinVirtualKeyboardInterface : public OrgKdeKwinVirtualKeyboardInterface Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) public: - KwinVirtualKeyboardInterface() : - OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus()) - {} + KwinVirtualKeyboardInterface() + : OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus()) + { + } }; TaskPanel::TaskPanel(QObject *parent, const QVariantList &args) @@ -48,9 +49,13 @@ TaskPanel::TaskPanel(QObject *parent, const QVariantList &args) connect(m_activeTimer, &QTimer::timeout, this, &TaskPanel::updateActiveWindow); initWayland(); - qmlRegisterSingletonType("org.kde.plasma.phone.taskpanel", 1, 0, "KWinVirtualKeyboard", [](QQmlEngine *, QJSEngine *) -> QObject * { - return new KwinVirtualKeyboardInterface; - }); + qmlRegisterSingletonType("org.kde.plasma.phone.taskpanel", + 1, + 0, + "KWinVirtualKeyboard", + [](QQmlEngine *, QJSEngine *) -> QObject * { + return new KwinVirtualKeyboardInterface; + }); } TaskPanel::~TaskPanel() = default; @@ -76,44 +81,36 @@ void TaskPanel::initWayland() } auto *registry = new Registry(this); registry->create(connection); - connect(registry, &Registry::plasmaWindowManagementAnnounced, this, - [this, registry] (quint32 name, quint32 version) { - m_windowManagement = registry->createPlasmaWindowManagement(name, version, this); - qRegisterMetaType >("QVector"); - connect(m_windowManagement, &PlasmaWindowManagement::showingDesktopChanged, this, - [this] (bool showing) { - if (showing == m_showingDesktop) { - return; - } - m_showingDesktop = showing; - emit showingDesktopChanged(m_showingDesktop); - } - ); - //FIXME - //connect(m_windowManagement, &PlasmaWindowManagement::activeWindowChanged, this, &TaskPanel::updateActiveWindow, Qt::QueuedConnection); - - connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::activeWindowChanged, - m_activeTimer, qOverload<>(&QTimer::start)); - - m_activeTimer->start(); - } - ); - connect(registry, &Registry::plasmaShellAnnounced, this, - [this, registry] (quint32 name, quint32 version) { - - m_shellInterface = registry->createPlasmaShell(name, version, this); - - if (!m_panel) { + connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [this, registry](quint32 name, quint32 version) { + m_windowManagement = registry->createPlasmaWindowManagement(name, version, this); + qRegisterMetaType>("QVector"); + connect(m_windowManagement, &PlasmaWindowManagement::showingDesktopChanged, this, [this](bool showing) { + if (showing == m_showingDesktop) { return; } - Surface *s = Surface::fromWindow(m_panel); - if (!s) { - return; - } - m_shellSurface = m_shellInterface->createSurface(s, this); - m_shellSurface->setSkipTaskbar(true); + m_showingDesktop = showing; + emit showingDesktopChanged(m_showingDesktop); + }); + // FIXME + // connect(m_windowManagement, &PlasmaWindowManagement::activeWindowChanged, this, &TaskPanel::updateActiveWindow, Qt::QueuedConnection); + + connect(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::activeWindowChanged, m_activeTimer, qOverload<>(&QTimer::start)); + + m_activeTimer->start(); + }); + connect(registry, &Registry::plasmaShellAnnounced, this, [this, registry](quint32 name, quint32 version) { + m_shellInterface = registry->createPlasmaShell(name, version, this); + + if (!m_panel) { + return; } - ); + Surface *s = Surface::fromWindow(m_panel); + if (!s) { + return; + } + m_shellSurface = m_shellInterface->createSurface(s, this); + m_shellSurface->setSkipTaskbar(true); + }); registry->setup(); connection->roundtrip(); } @@ -164,15 +161,13 @@ void TaskPanel::updateActiveWindow() } if (m_activeWindow) { disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::closeableChanged, this, &TaskPanel::hasCloseableActiveWindowChanged); - disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped, - this, &TaskPanel::forgetActiveWindow); + disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped, this, &TaskPanel::forgetActiveWindow); } m_activeWindow = m_windowManagement->activeWindow(); if (m_activeWindow) { connect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::closeableChanged, this, &TaskPanel::hasCloseableActiveWindowChanged); - connect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped, - this, &TaskPanel::forgetActiveWindow); + connect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped, this, &TaskPanel::forgetActiveWindow); } bool newAllMinimized = true; @@ -199,18 +194,17 @@ void TaskPanel::forgetActiveWindow() { if (m_activeWindow) { disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::closeableChanged, this, &TaskPanel::hasCloseableActiveWindowChanged); - disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped, - this, &TaskPanel::forgetActiveWindow); + disconnect(m_activeWindow.data(), &KWayland::Client::PlasmaWindow::unmapped, this, &TaskPanel::forgetActiveWindow); } m_activeWindow.clear(); - emit hasCloseableActiveWindowChanged(); + emit hasCloseableActiveWindowChanged(); } void TaskPanel::closeActiveWindow() { if (m_activeWindow) { m_activeWindow->requestClose(); - } + } } K_EXPORT_PLASMA_APPLET_WITH_JSON(taskpanel, TaskPanel, "metadata.json") diff --git a/containments/taskpanel/taskpanel.h b/containments/taskpanel/taskpanel.h index 535adfbf..2354b312 100644 --- a/containments/taskpanel/taskpanel.h +++ b/containments/taskpanel/taskpanel.h @@ -33,7 +33,7 @@ class TaskPanel : public Plasma::Containment Q_PROPERTY(QWindow *panel READ panel WRITE setPanel NOTIFY panelChanged) public: - TaskPanel( QObject *parent, const QVariantList &args ); + TaskPanel(QObject *parent, const QVariantList &args); ~TaskPanel() override; QWindow *panel(); @@ -41,12 +41,14 @@ public: Q_INVOKABLE void closeActiveWindow(); - bool isShowingDesktop() const { + bool isShowingDesktop() const + { return m_showingDesktop; } void requestShowingDesktop(bool showingDesktop); - bool allMinimized() const { + bool allMinimized() const + { return m_allMinimized; } bool hasCloseableActiveWindow() const;