Commit 770e9ab7 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Add button to add events

parent 01db509f
......@@ -25,6 +25,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.calendar 2.0 as PlasmaCalendar
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.private.digitalclock 1.0
// Top-level layout containing:
// - Left column with world clock and agenda view
......@@ -80,18 +81,27 @@ PlasmaExtras.Representation {
text: monthView.currentDate.toLocaleDateString(Qt.locale(), Locale.LongFormat)
}
}
// Heading text
PlasmaExtras.Heading {
visible: agenda.visible
RowLayout {
// Heading text
PlasmaExtras.Heading {
visible: agenda.visible
Layout.fillWidth: true
Layout.leftMargin: calendar.paddings
Layout.fillWidth: true
Layout.leftMargin: calendar.paddings
level: 2
level: 2
text: i18n("Events")
maximumLineCount: 1
elide: Text.ElideRight
text: i18n("Events")
maximumLineCount: 1
elide: Text.ElideRight
}
PlasmaComponents3.ToolButton {
visible: agenda.visible && ApplicationIntegration.korganizerInstalled
text: i18nc("@action:button Add event", "Add...")
Layout.rightMargin: calendar.paddings
icon.name: "list-add"
onClicked: ApplicationIntegration.launchKorganizer()
}
}
}
......
......@@ -12,14 +12,18 @@ set(digitalclockplugin_SRCS
timezonesi18n.cpp
digitalclockplugin.cpp
clipboardmenu.cpp
applicationintegration.cpp
)
add_library(digitalclockplugin SHARED ${digitalclockplugin_SRCS})
target_link_libraries(digitalclockplugin Qt::Core
Qt::Qml
Qt::Widgets # for QAction...
KF5::CoreAddons
KF5::I18n)
target_link_libraries(digitalclockplugin
PRIVATE
Qt::Core
Qt::Qml
Qt::Widgets # for QAction...
KF5::CoreAddons
KF5::KIOGui
KF5::I18n)
install(TARGETS digitalclockplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/digitalclock)
......
// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
// SPDX-Licence-Identifier: SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
#include "applicationintegration.h"
#include <KIO/ApplicationLauncherJob>
ApplicationIntegration::ApplicationIntegration(QObject *parent)
: QObject(parent)
, m_korganizerService(KService::serviceByDesktopName(QStringLiteral("org.kde.korganizer")))
{
}
bool ApplicationIntegration::korganizerInstalled() const
{
return m_korganizerService != nullptr;
}
void ApplicationIntegration::launchKorganizer() const
{
Q_ASSERT(m_korganizerService);
auto job = new KIO::ApplicationLauncherJob(m_korganizerService);
job->start();
}
// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
// SPDX-Licence-Identifier: SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
#pragma once
#include <KService>
#include <QObject>
class ApplicationIntegration : public QObject
{
Q_OBJECT
Q_PROPERTY(bool korganizerInstalled READ korganizerInstalled CONSTANT)
public:
explicit ApplicationIntegration(QObject *parent = nullptr);
~ApplicationIntegration() = default;
bool korganizerInstalled() const;
Q_INVOKABLE void launchKorganizer() const;
private:
KService::Ptr m_korganizerService;
};
......@@ -17,6 +17,7 @@
*/
#include "digitalclockplugin.h"
#include "applicationintegration.h"
#include "clipboardmenu.h"
#include "timezonemodel.h"
#include "timezonesi18n.h"
......@@ -48,4 +49,10 @@ void DigitalClockPlugin::registerTypes(const char *uri)
qmlRegisterSingletonType<TimezonesI18n>(uri, 1, 0, "TimezonesI18n", timezonesi18n_singletontype_provider);
qmlRegisterSingletonType<ClipboardMenu>(uri, 1, 0, "ClipboardMenu", clipboardMenu_singletontype_provider);
qmlRegisterSingletonType<ClipboardMenu>(uri, 1, 0, "ApplicationIntegration", [](QQmlEngine *engine, QJSEngine *scriptEngine) {
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);
return new ApplicationIntegration();
});
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment