Revert "Open and close StartupFeedback using KStartupInfo"

This reverts commit b856b78790.

Unfortunately it turned out not to work on Wayland yet.
This commit is contained in:
Jonah Brüchert 2020-05-28 15:58:27 +02:00
parent 881f7c7a96
commit 3f4915d426
No known key found for this signature in database
GPG key ID: A81E075ABEC80A7E
10 changed files with 128 additions and 46 deletions

View file

@ -34,7 +34,6 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
PlasmaQuick
Service
Notifications
WindowSystem
)
find_package(KF5Wayland CONFIG)
set_package_properties(KF5Wayland PROPERTIES

View file

@ -1,6 +1,7 @@
set(homescreen_SRCS
homescreen.cpp
applicationlistmodel.cpp
colouraverage.cpp
)
add_library(plasma_containment_phone_homescreen MODULE ${homescreen_SRCS})
@ -16,7 +17,6 @@ target_link_libraries(plasma_containment_phone_homescreen
KF5::Service
KF5::KIOGui
KF5::Notifications
KF5::WindowSystem
)

View file

@ -39,31 +39,12 @@ constexpr int MAX_FAVOURITES = 5;
ApplicationListModel::ApplicationListModel(HomeScreen *parent)
: QAbstractListModel(parent),
m_homeScreen(parent),
m_startupInfo(new KStartupInfo(0, this))
m_homeScreen(parent)
{
connect(KSycoca::self(), qOverload<const QStringList &>(&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;
@ -135,8 +116,7 @@ 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<int, ApplicationData> orderedList;

View file

@ -26,9 +26,6 @@
#include <QList>
#include <QSet>
// KDE
#include <KStartupInfo>
#include "homescreen.h"
class QString;
@ -105,8 +102,6 @@ Q_SIGNALS:
void countChanged();
void favoriteCountChanged();
void maxFavoriteCountChanged();
void applicationStarted(const QString &name, const QString &icon);
void applicationExited();
private:
QList<ApplicationData> m_applicationList;
@ -117,7 +112,6 @@ private:
QStringList m_favorites;
QSet<QString> m_desktopItems;
QHash<QString, int> m_appPositions;
KStartupInfo *m_startupInfo;
};
#endif // APPLICATIONLISTMODEL_H

View file

@ -0,0 +1,58 @@
/***************************************************************************
* Copyright (C) 2019 Carson Black <uhhadd@gmail.com> *
* *
* 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 <QObject>
#include <QColor>
#include <QImage>
#include <QDebug>
#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;
}

View file

@ -0,0 +1,32 @@
/***************************************************************************
* Copyright (C) 2019 Carson Black <uhhadd@gmail.com> *
* *
* 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 <QObject>
#include <QColor>
#include <QImage>
class ColourAverage : public QObject
{
Q_OBJECT
public:
explicit ColourAverage(QObject *parent = nullptr);
Q_INVOKABLE QColor averageColour(const QImage &img);
};

View file

@ -19,6 +19,7 @@
#include "homescreen.h"
#include "applicationlistmodel.h"
#include "colouraverage.h"
#include <QtQml>
#include <QDebug>
@ -28,6 +29,9 @@ HomeScreen::HomeScreen(QObject *parent, const QVariantList &args)
: Plasma::Containment(parent, args)
{
qmlRegisterUncreatableType<ApplicationListModel>("org.kde.phone.homescreen", 1, 0, "ApplicationListModel", QStringLiteral("Cannot create item of type ApplicationListModel"));
qmlRegisterSingletonType<ColourAverage>("org.kde.phone.homescreen", 1, 0, "ColourAverage", [](QQmlEngine *, QJSEngine *) -> QObject * {
return new ColourAverage();
});
setHasConfigurationInterface(true);
}

View file

@ -92,7 +92,11 @@ ContainmentLayoutManager.ItemContainer {
}
contentItem: MouseArea {
onClicked: plasmoid.nativeInterface.applicationListModel.runApplication(modelData.applicationStorageId);
onClicked: {
delegate.launch(delegate.x + (units.smallSpacing * 2), delegate.y + (units.smallSpacing * 2), icon.source, modelData.applicationName)
plasmoid.nativeInterface.applicationListModel.runApplication(modelData.applicationStorageId);
}
//preventStealing: true
ColumnLayout {

View file

@ -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.13 as Kirigami
import org.kde.kirigami 2.10 as Kirigami
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
@ -41,20 +41,6 @@ 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
@ -79,6 +65,17 @@ 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;

View file

@ -58,6 +58,13 @@ 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();
}
@ -98,6 +105,13 @@ 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) {