File indexing completed on 2024-06-23 05:45:43

0001 /*
0002     SPDX-FileCopyrightText: 2020 HanY <hanyoung@protonmail.com>
0003     SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <Plasma/Applet>
0010 #include <QLocale>
0011 #include <QProcess>
0012 #include <QTimer>
0013 
0014 class KClock_1x2 : public Plasma::Applet
0015 {
0016     Q_OBJECT
0017     Q_PROPERTY(QDateTime datetime READ datetime NOTIFY timeChanged)
0018     Q_PROPERTY(QString date READ date NOTIFY timeChanged)
0019     Q_PROPERTY(QString alarmTime READ alarmTime NOTIFY propertyChanged)
0020     Q_PROPERTY(bool hasAlarm READ hasAlarm NOTIFY propertyChanged)
0021 
0022 public:
0023     KClock_1x2(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args);
0024     ~KClock_1x2();
0025 
0026     QString date() const;
0027     QDateTime datetime() const;
0028     QString alarmTime();
0029     bool hasAlarm();
0030     Q_INVOKABLE void openKClock();
0031 
0032 Q_SIGNALS:
0033     void propertyChanged();
0034     void timeChanged();
0035 
0036 private Q_SLOTS:
0037     void updateAlarm(qulonglong time);
0038     void initialTimeUpdate(); // making sure time is update when minute changes
0039 
0040 private:
0041     QLocale m_locale = QLocale::system();
0042     bool m_hasAlarm = false;
0043     QString m_string;
0044     QTimer *m_timer;
0045     QProcess *m_process;
0046 };