Submitted proof of concept for a presenter plugin
Will show a cursor so we can point at interesting things on the screen during presentations.
This commit is contained in:
parent
f044384c15
commit
a40c6e8101
8 changed files with 303 additions and 1 deletions
|
@ -41,6 +41,11 @@ if(SAILFISHOS OR EXPERIMENTALAPP_ENABLED)
|
||||||
add_subdirectory(remotesystemvolume)
|
add_subdirectory(remotesystemvolume)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# If we split notifications per plugin, in several notifyrc files, they won't
|
option(EXPERIMENTAL_PRESENTER "Enables building the experimental on-screen pointer for presentations" OFF)
|
||||||
|
if(EXPERIMENTAL_PRESENTER)
|
||||||
|
add_subdirectory(presenter)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# If we split notifications per plugin, in several notifyrc files, they won't
|
||||||
# appear in the same group in the Notifications KCM
|
# appear in the same group in the Notifications KCM
|
||||||
install(FILES kdeconnect.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
install(FILES kdeconnect.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
||||||
|
|
9
plugins/presenter/CMakeLists.txt
Normal file
9
plugins/presenter/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
qt5_add_resources(presenter_SRCS assets.qrc)
|
||||||
|
|
||||||
|
kdeconnect_add_plugin(kdeconnect_presenter JSON kdeconnect_presenter.json SOURCES presenterplugin.cpp ${presenter_SRCS})
|
||||||
|
target_link_libraries(kdeconnect_presenter
|
||||||
|
kdeconnectcore
|
||||||
|
Qt5::DBus
|
||||||
|
Qt5::Quick
|
||||||
|
KF5::I18n
|
||||||
|
)
|
94
plugins/presenter/Presenter.qml
Normal file
94
plugins/presenter/Presenter.qml
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||||
|
*
|
||||||
|
* 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) version 3 or any later version
|
||||||
|
* accepted by the membership of KDE e.V. (or its successor approved
|
||||||
|
* by the membership of KDE e.V.), which shall act as a proxy
|
||||||
|
* defined in Section 14 of version 3 of the license.
|
||||||
|
*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Window 2.5
|
||||||
|
import QtQuick.Particles 2.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
property real xPos: 0.5
|
||||||
|
property real yPos: 0.5
|
||||||
|
|
||||||
|
ParticleSystem {
|
||||||
|
id: particles
|
||||||
|
width: parent.width/20
|
||||||
|
height: width
|
||||||
|
|
||||||
|
x: root.width * root.xPos - width/2
|
||||||
|
y: root.height * root.yPos - height/2
|
||||||
|
|
||||||
|
ImageParticle {
|
||||||
|
groups: ["center", "edge"]
|
||||||
|
anchors.fill: parent
|
||||||
|
source: "qrc:///particleresources/glowdot.png"
|
||||||
|
colorVariation: 0.1
|
||||||
|
color: "#000099FF"
|
||||||
|
}
|
||||||
|
|
||||||
|
Emitter {
|
||||||
|
anchors.fill: parent
|
||||||
|
group: "center"
|
||||||
|
emitRate: 400
|
||||||
|
lifeSpan: 200
|
||||||
|
size: 20
|
||||||
|
sizeVariation: 2
|
||||||
|
endSize: 0
|
||||||
|
//! [0]
|
||||||
|
shape: EllipseShape {fill: false}
|
||||||
|
velocity: TargetDirection {
|
||||||
|
targetX: particles.width/2
|
||||||
|
targetY: particles.height/2
|
||||||
|
proportionalMagnitude: true
|
||||||
|
magnitude: 0.5
|
||||||
|
}
|
||||||
|
//! [0]
|
||||||
|
}
|
||||||
|
|
||||||
|
Emitter {
|
||||||
|
anchors.fill: parent
|
||||||
|
group: "edge"
|
||||||
|
startTime: 200
|
||||||
|
emitRate: 200
|
||||||
|
lifeSpan: 20
|
||||||
|
size: 28
|
||||||
|
sizeVariation: 2
|
||||||
|
endSize: 16
|
||||||
|
shape: EllipseShape {fill: false}
|
||||||
|
velocity: TargetDirection {
|
||||||
|
targetX: particles.width/2
|
||||||
|
targetY: particles.height/2
|
||||||
|
proportionalMagnitude: true
|
||||||
|
magnitude: 0.1
|
||||||
|
magnitudeVariation: 0.1
|
||||||
|
}
|
||||||
|
acceleration: TargetDirection {
|
||||||
|
targetX: particles.width/2
|
||||||
|
targetY: particles.height/2
|
||||||
|
targetVariation: 200
|
||||||
|
proportionalMagnitude: true
|
||||||
|
magnitude: 0.1
|
||||||
|
magnitudeVariation: 0.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
plugins/presenter/assets.qrc
Normal file
7
plugins/presenter/assets.qrc
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<!DOCTYPE RCC>
|
||||||
|
|
||||||
|
<RCC version="1.0">
|
||||||
|
<qresource prefix="/presenter">
|
||||||
|
<file>Presenter.qml</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
21
plugins/presenter/kdeconnect_presenter.json
Normal file
21
plugins/presenter/kdeconnect_presenter.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"KPlugin": {
|
||||||
|
"Authors": [
|
||||||
|
{
|
||||||
|
"Email": "aleixpol@kde.org",
|
||||||
|
"Name": "Aleix Pol"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Description": "",
|
||||||
|
"EnabledByDefault": true,
|
||||||
|
"Icon": "view-presentation",
|
||||||
|
"Id": "kdeconnect_presenter",
|
||||||
|
"License": "GPL",
|
||||||
|
"Name": "Presenter",
|
||||||
|
"ServiceTypes": [ "KdeConnect/Plugin" ]
|
||||||
|
},
|
||||||
|
"X-KdeConnect-OutgoingPacketType": [],
|
||||||
|
"X-KdeConnect-SupportedPacketType": [
|
||||||
|
"kdeconnect.presenter"
|
||||||
|
]
|
||||||
|
}
|
93
plugins/presenter/presenterplugin.cpp
Normal file
93
plugins/presenter/presenterplugin.cpp
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||||
|
*
|
||||||
|
* 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) version 3 or any later version
|
||||||
|
* accepted by the membership of KDE e.V. (or its successor approved
|
||||||
|
* by the membership of KDE e.V.), which shall act as a proxy
|
||||||
|
* defined in Section 14 of version 3 of the license.
|
||||||
|
*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "presenterplugin.h"
|
||||||
|
|
||||||
|
#include <KLocalizedString>
|
||||||
|
#include <KPluginFactory>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
#include <QQuickView>
|
||||||
|
#include <QQmlError>
|
||||||
|
#include <QQuickItem>
|
||||||
|
|
||||||
|
#include <core/device.h>
|
||||||
|
#include <core/daemon.h>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
K_PLUGIN_CLASS_WITH_JSON(PresenterPlugin, "kdeconnect_presenter.json")
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_PRESENT, "kdeconnect.plugin.presenter")
|
||||||
|
|
||||||
|
class PresenterView : public QQuickView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PresenterView() {
|
||||||
|
setFlags(flags() | Qt::WindowFlags(Qt::WA_TranslucentBackground));
|
||||||
|
setClearBeforeRendering(true);
|
||||||
|
setColor(QColor(Qt::transparent));
|
||||||
|
|
||||||
|
setResizeMode(QQuickView::SizeViewToRootObject);
|
||||||
|
setSource(QUrl(QStringLiteral("qrc:/presenter/Presenter.qml")));
|
||||||
|
|
||||||
|
const auto ourErrors = errors();
|
||||||
|
for (const auto &error : ourErrors) {
|
||||||
|
qCWarning(KDECONNECT_PLUGIN_PRESENT) << "error" << error.description() << error.url() << error.line() << error.column();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
PresenterPlugin::PresenterPlugin(QObject* parent, const QVariantList& args)
|
||||||
|
: KdeConnectPlugin(parent, args)
|
||||||
|
, m_view(nullptr)
|
||||||
|
, m_timer(new QTimer(this))
|
||||||
|
{
|
||||||
|
m_timer->setInterval(2000);
|
||||||
|
m_timer->setSingleShot(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
PresenterPlugin::~PresenterPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PresenterPlugin::receivePacket(const NetworkPacket& np)
|
||||||
|
{
|
||||||
|
if (!m_view) {
|
||||||
|
m_view = new PresenterView;
|
||||||
|
m_view->showFullScreen();
|
||||||
|
connect(this, &QObject::destroyed, m_view, &QObject::deleteLater);
|
||||||
|
connect(m_timer, &QTimer::timeout, m_view, &QObject::deleteLater);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto screenSize = m_view->screen()->size();
|
||||||
|
auto ratio = screenSize.width()/screenSize.height();
|
||||||
|
|
||||||
|
m_timer->start();
|
||||||
|
|
||||||
|
auto object = m_view->rootObject();
|
||||||
|
object->setProperty("xPos", np.get<qreal>(QStringLiteral("px"))/2 + 0.5);
|
||||||
|
object->setProperty("yPos", np.get<qreal>(QStringLiteral("py"))/2 + 0.5);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "presenterplugin.moc"
|
||||||
|
|
52
plugins/presenter/presenterplugin.h
Normal file
52
plugins/presenter/presenterplugin.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||||
|
*
|
||||||
|
* 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) version 3 or any later version
|
||||||
|
* accepted by the membership of KDE e.V. (or its successor approved
|
||||||
|
* by the membership of KDE e.V.), which shall act as a proxy
|
||||||
|
* defined in Section 14 of version 3 of the license.
|
||||||
|
*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PRESENTERPLUGIN_H
|
||||||
|
#define PRESENTERPLUGIN_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <core/kdeconnectplugin.h>
|
||||||
|
|
||||||
|
#define PACKET_TYPE_PRESENTER QStringLiteral("kdeconnect.presenter")
|
||||||
|
|
||||||
|
class PresenterView;
|
||||||
|
|
||||||
|
class Q_DECL_EXPORT PresenterPlugin
|
||||||
|
: public KdeConnectPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.presenter")
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PresenterPlugin(QObject* parent, const QVariantList& args);
|
||||||
|
~PresenterPlugin() override;
|
||||||
|
|
||||||
|
bool receivePacket(const NetworkPacket& np) override;
|
||||||
|
void connected() override {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<PresenterView> m_view;
|
||||||
|
QTimer* m_timer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
21
plugins/presenter/test.qml
Normal file
21
plugins/presenter/test.qml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import QtQuick 2.10
|
||||||
|
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
|
color: "red"
|
||||||
|
width: 500
|
||||||
|
height: 500
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: mouse
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Presenter {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
xPos: mouse.mouseX/width
|
||||||
|
yPos: mouse.mouseY/height
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue