forked from MX-Linux/mx-datetime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatetime.h
More file actions
108 lines (98 loc) · 3.49 KB
/
datetime.h
File metadata and controls
108 lines (98 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**********************************************************************
* MX Date/Time application.
**********************************************************************
* Copyright (C) 2019 by AK-47
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mx-datetime.
**********************************************************************/
#ifndef DATETIME_H
#define DATETIME_H
#include <QDialog>
#include <QString>
#include <QByteArray>
#include <QTimer>
#include <QDateTime>
#include <QTimeEdit>
#include <QTableWidgetItem>
// QTimeEdit subclassing just to stop the cursor and selection jumping every second.
class MTimeEdit : public QTimeEdit
{
Q_OBJECT
public:
MTimeEdit(QWidget *parent = nullptr);
void updateDateTime(const QDateTime &dateTime);
};
// This #include must come after the MTimeEdit class.
#include "ui_datetime.h"
class MXDateTime : public QDialog, private Ui::MXDateTime
{
Q_OBJECT
public:
explicit MXDateTime(QWidget *parent = nullptr);
~MXDateTime() = default;
private slots:
void on_tabsDateTime_currentChanged(int index);
void on_comboTimeArea_currentIndexChanged(int index);
void on_comboTimeZone_currentIndexChanged(int index);
void on_calendar_selectionChanged();
void on_timeEdit_dateTimeChanged(const QDateTime &dateTime);
void on_pushReadHardware_clicked();
void on_pushHardwareAdjust_clicked();
void on_pushSystemToHardware_clicked();
void on_pushHardwareToSystem_clicked();
void on_pushSyncNow_clicked();
void on_tableServers_itemSelectionChanged();
void on_pushServerAdd_clicked();
void on_pushServerRemove_clicked();
void on_pushServerMoveUp_clicked();
void on_pushServerMoveDown_clicked();
void on_pushApply_clicked();
void on_pushClose_clicked();
void on_pushAbout_clicked();
void on_pushHelp_clicked();
private:
QTimer updater;
bool clockLock = false;
unsigned int loadedTabs = 0;
int dateDelta = 0;
qint64 timeDelta = 0;
int zoneDelta = 0;
enum InitSystem {
SystemV,
OpenRC,
SystemD
} sysInit = SystemV;
bool userRoot = false;
QList<QByteArray> zones;
QByteArray confBaseNTP;
QByteArray confServers;
bool enabledNTP{};
bool isHardwareUTC{};
bool updating = false;
void startup();
void setClockLock(bool locked);
bool shell(const QString &cmd, QByteArray *output = nullptr);
bool execute(const QString &program, const QStringList &arguments = QStringList(), QByteArray *output = nullptr);
void update();
void loadDateTime();
void saveDateTime(const QDateTime &driftStart);
void transferTime(const QStringList ¶ms, const QString &from, const QString &to);
void saveHardwareClock();
QTableWidgetItem *addServerRow(bool enabled, const QString &type, const QString &address, const QString &options);
void moveServerRow(int movement);
bool validateServerList();
void loadNetworkTime();
void saveNetworkTime();
};
#endif // DATETIME_H