diff --git a/CMakeLists.txt b/CMakeLists.txt index ca71715d..f803d562 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS PlasmaQuick Service Notifications + WindowSystem ) find_package(KF5Wayland CONFIG) set_package_properties(KF5Wayland PROPERTIES diff --git a/containments/homescreen/CMakeLists.txt b/containments/homescreen/CMakeLists.txt index 944cca6c..7d4cb998 100644 --- a/containments/homescreen/CMakeLists.txt +++ b/containments/homescreen/CMakeLists.txt @@ -1,7 +1,6 @@ set(homescreen_SRCS homescreen.cpp applicationlistmodel.cpp - colouraverage.cpp ) add_library(plasma_containment_phone_homescreen MODULE ${homescreen_SRCS}) @@ -17,6 +16,7 @@ target_link_libraries(plasma_containment_phone_homescreen KF5::Service KF5::KIOGui KF5::Notifications + KF5::WindowSystem ) diff --git a/containments/homescreen/applicationlistmodel.cpp b/containments/homescreen/applicationlistmodel.cpp index 6316558c..5f2bdfcf 100644 --- a/containments/homescreen/applicationlistmodel.cpp +++ b/containments/homescreen/applicationlistmodel.cpp @@ -39,12 +39,31 @@ constexpr int MAX_FAVOURITES = 5; ApplicationListModel::ApplicationListModel(HomeScreen *parent) : QAbstractListModel(parent), - m_homeScreen(parent) + m_homeScreen(parent), + m_startupInfo(new KStartupInfo(0, this)) { connect(KSycoca::self(), qOverload(&KSycoca::databaseChanged), this, &ApplicationListModel::sycocaDbChanged); + connect(m_startupInfo, &KStartupInfo::gotRemoveStartup, + this, &ApplicationListModel::applicationExited); + + connect(m_startupInfo, &KStartupInfo::gotNewStartup, + this, [=](const KStartupInfoId &, const KStartupInfoData &data) { + applicationStarted(data.name(), data.icon()); + }); + loadSettings(); + + // Debug + connect(this, &ApplicationListModel::applicationStarted, this, [=](const QString &name, const QString &icon) { + qDebug() << "Opening startup feedback for" << name << icon; + }); + + connect(this, &ApplicationListModel::applicationExited, this, []() { + qDebug() << "Removing startup feedback"; + }); + } ApplicationListModel::~ApplicationListModel() = default; @@ -116,7 +135,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; diff --git a/containments/homescreen/applicationlistmodel.h b/containments/homescreen/applicationlistmodel.h index f33d3fd3..12721eec 100644 --- a/containments/homescreen/applicationlistmodel.h +++ b/containments/homescreen/applicationlistmodel.h @@ -26,6 +26,9 @@ #include #include +// KDE +#include + #include "homescreen.h" class QString; @@ -102,6 +105,8 @@ Q_SIGNALS: void countChanged(); void favoriteCountChanged(); void maxFavoriteCountChanged(); + void applicationStarted(const QString &name, const QString &icon); + void applicationExited(); private: QList m_applicationList; @@ -112,6 +117,7 @@ private: QStringList m_favorites; QSet m_desktopItems; QHash m_appPositions; + KStartupInfo *m_startupInfo; }; #endif // APPLICATIONLISTMODEL_H diff --git a/containments/homescreen/colouraverage.cpp b/containments/homescreen/colouraverage.cpp deleted file mode 100644 index 1e269ed0..00000000 --- a/containments/homescreen/colouraverage.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2019 Carson Black * - * * - * 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 2 of the License, or * - * (at your option) 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, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -#include -#include -#include -#include - -#include "colouraverage.h" - -ColourAverage::ColourAverage(QObject *parent) : QObject(parent) -{ -} - -QColor ColourAverage::averageColour(const QImage &img) { - int r = 0; - int g = 0; - int b = 0; - int c = 0; - - for (int i = 0; i < img.width(); i++) { - for (int ii = 0; ii < img.height(); ii++) { - QRgb pix = img.pixel(i, ii); - if (pix == 0) - continue; - - c++; - r += qRed(pix); - g += qGreen(pix); - b += qBlue(pix); - } - } - r = r / c; - g = g / c; - b = b / c; - - QColor color = QColor::fromRgb(r,g,b); - - color.setHsv(color.hue(), color.saturation() / 4, color.value()); - - return color; -} diff --git a/containments/homescreen/colouraverage.h b/containments/homescreen/colouraverage.h deleted file mode 100644 index 0d15f53b..00000000 --- a/containments/homescreen/colouraverage.h +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2019 Carson Black * - * * - * 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 2 of the License, or * - * (at your option) 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, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ -#pragma once - -#include -#include -#include - -class ColourAverage : public QObject -{ - Q_OBJECT - -public: - explicit ColourAverage(QObject *parent = nullptr); - Q_INVOKABLE QColor averageColour(const QImage &img); -}; diff --git a/containments/homescreen/homescreen.cpp b/containments/homescreen/homescreen.cpp index 318b0e8c..343695fb 100644 --- a/containments/homescreen/homescreen.cpp +++ b/containments/homescreen/homescreen.cpp @@ -19,7 +19,6 @@ #include "homescreen.h" #include "applicationlistmodel.h" -#include "colouraverage.h" #include #include @@ -29,9 +28,6 @@ HomeScreen::HomeScreen(QObject *parent, const QVariantList &args) : Plasma::Containment(parent, args) { qmlRegisterUncreatableType("org.kde.phone.homescreen", 1, 0, "ApplicationListModel", QStringLiteral("Cannot create item of type ApplicationListModel")); - qmlRegisterSingletonType("org.kde.phone.homescreen", 1, 0, "ColourAverage", [](QQmlEngine *, QJSEngine *) -> QObject * { - return new ColourAverage(); - }); setHasConfigurationInterface(true); } diff --git a/containments/homescreen/package/contents/ui/launcher/Delegate.qml b/containments/homescreen/package/contents/ui/launcher/Delegate.qml index 85f39c12..9af9508e 100644 --- a/containments/homescreen/package/contents/ui/launcher/Delegate.qml +++ b/containments/homescreen/package/contents/ui/launcher/Delegate.qml @@ -92,11 +92,7 @@ ContainmentLayoutManager.ItemContainer { } contentItem: MouseArea { - onClicked: { - delegate.launch(delegate.x + (units.smallSpacing * 2), delegate.y + (units.smallSpacing * 2), icon.source, modelData.applicationName) - - plasmoid.nativeInterface.applicationListModel.runApplication(modelData.applicationStorageId); - } + onClicked: plasmoid.nativeInterface.applicationListModel.runApplication(modelData.applicationStorageId); //preventStealing: true ColumnLayout { diff --git a/containments/homescreen/package/contents/ui/launcher/LauncherGrid.qml b/containments/homescreen/package/contents/ui/launcher/LauncherGrid.qml index 4b751456..44035da7 100644 --- a/containments/homescreen/package/contents/ui/launcher/LauncherGrid.qml +++ b/containments/homescreen/package/contents/ui/launcher/LauncherGrid.qml @@ -24,7 +24,7 @@ import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 -import org.kde.kirigami 2.10 as Kirigami +import org.kde.kirigami 2.13 as Kirigami import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.nanoshell 2.0 as NanoShell @@ -41,6 +41,20 @@ LauncherContainer { frame.width: width + Connections { + target: plasmoid.nativeInterface.applicationListModel + onApplicationExited: NanoShell.StartupFeedback.close() + onApplicationStarted: (name, icon) => { + NanoShell.StartupFeedback.open( + icon, + name, + root.width * 0.5, + root.height * 0.5, + root.width * 0.2 + ); + } + } + Repeater { parent: root.flow model: plasmoid.nativeInterface.applicationListModel @@ -65,17 +79,6 @@ LauncherContainer { appletsLayout.restoreItem(delegate); } } - onLaunch: (x, y, icon, title) => { - delegate.grabToImage((img) => { - NanoShell.StartupFeedback.open( - icon, - title, - delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, - delegate.iconItem.Kirigami.ScenePosition.y + delegate.iconItem.height/2, - Math.min(delegate.iconItem.width, delegate.iconItem.height), - ColourAverage.averageColour(img.image)); - }); - } onParentFromLocationChanged: { if (!launcherDragManager.active && parent != parentFromLocation) { parent = parentFromLocation; diff --git a/containments/panel/package/contents/ui/quicksettings/Delegate.qml b/containments/panel/package/contents/ui/quicksettings/Delegate.qml index 339f5265..39cf2296 100644 --- a/containments/panel/package/contents/ui/quicksettings/Delegate.qml +++ b/containments/panel/package/contents/ui/quicksettings/Delegate.qml @@ -58,13 +58,6 @@ ColumnLayout { } else if (model.toggleFunction) { root[model.toggleFunction](); } else if (model.settingsCommand) { - NanoShell.StartupFeedback.open( - model.icon, - model.text, - icon.Kirigami.ScenePosition.x + icon.width/2, - icon.Kirigami.ScenePosition.y + icon.height/2, - Math.min(icon.width, icon.height), - theme.textColor); plasmoid.nativeInterface.executeCommand(model.settingsCommand); root.closeRequested(); } @@ -105,13 +98,6 @@ ColumnLayout { anchors.fill: parent onClicked: { if (model.settingsCommand) { - NanoShell.StartupFeedback.open( - model.icon, - model.text, - icon.Kirigami.ScenePosition.x + icon.width/2, - icon.Kirigami.ScenePosition.y + icon.height/2, - Math.min(icon.width, icon.height), - theme.textColor); //plasmoid.nativeInterface.executeCommand(model.settingsCommand); closeRequested(); } else if (model.toggleFunction) {