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

0001 /*
0002  * Copyright 2020 Han Young <hanyoung@protonmail.com>
0003  * Copyright 2020-2021 Devin Lin <devin@kde.org>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #pragma once
0009 
0010 #include <QObject>
0011 #include <QString>
0012 
0013 class UtilModel : public QObject
0014 {
0015     Q_OBJECT
0016 
0017     Q_PROPERTY(QString tzName READ getCurrentTimeZoneName CONSTANT)
0018     Q_PROPERTY(bool use24HourTime READ use24HourTime NOTIFY use24HourTimeChanged)
0019 
0020 public:
0021     UtilModel(QObject *parent = nullptr);
0022     static UtilModel *instance();
0023 
0024     Q_INVOKABLE QString getDefaultAlarmFileLocation();
0025 
0026     QString getCurrentTimeZoneName();
0027 
0028     long long calculateNextRingTime(int hours, int minutes, int daysOfWeek, int snooze = 0);
0029     QString timeToRingFormatted(const long long &timestamp);
0030 
0031     QString timeFormat() const;
0032     bool use24HourTime() const;
0033 
0034 private:
0035     bool isLocale24HourTime() const;
0036 
0037 Q_SIGNALS:
0038     void use24HourTimeChanged();
0039 };