Open KClock when the clock is tapped

This commit is contained in:
Aleix Pol 2021-07-14 18:21:31 +02:00 committed by Aleix Pol Gonzalez
parent 4942e0e369
commit 766fce50bd
4 changed files with 23 additions and 1 deletions

View file

@ -15,7 +15,10 @@ target_link_libraries(plasma_applet_phonepanel
Qt::DBus
KF5::Plasma
KF5::I18n
KF5::Notifications)
KF5::Notifications
KF5::KIOGui
KF5::Service
)
install(TARGETS plasma_applet_phonepanel DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets)
#install(FILES plasma-phonepanel-default.desktop DESTINATION ${SERVICES_INSTALL_DIR})

View file

@ -119,6 +119,12 @@ Item {
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pixelSize: height / 2
TapHandler {
onTapped: {
plasmoid.nativeInterface.launchApp("org.kde.kclock");
}
}
}
RowLayout {

View file

@ -12,6 +12,7 @@
#include <unistd.h>
#include <KConfigGroup>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KNotification>
@ -202,6 +203,17 @@ bool PhonePanel::isSystem24HourFormat()
return timeFormat == QStringLiteral(FORMAT24H);
}
void PhonePanel::launchApp(const QString &app)
{
const KService::Ptr appService = KService::serviceByDesktopName(app);
if (!appService) {
qWarning() << "Could not find" << app;
return;
}
auto job = new KIO::ApplicationLauncherJob(appService, this);
job->start();
}
K_PLUGIN_CLASS_WITH_JSON(PhonePanel, "metadata.json")
#include "phonepanel.moc"

View file

@ -28,6 +28,7 @@ public:
public Q_SLOTS:
void executeCommand(const QString &command);
void launchApp(const QString &app);
void toggleTorch();
void takeScreenshot();