blob: 88ae69421ac3bd28234aeea79dd3c402655fcb4f (
plain)
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
|
/*
Copyright 2016-2023 melonDS team
This file is part of melonDS.
melonDS is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with melonDS. If not, see http://www.gnu.org/licenses/.
*/
#include <stdio.h>
#include "types.h"
#include "Config.h"
#include "DateTimeDialog.h"
#include "ui_DateTimeDialog.h"
DateTimeDialog* DateTimeDialog::currentDlg = nullptr;
DateTimeDialog::DateTimeDialog(QWidget* parent) : QDialog(parent), ui(new Ui::DateTimeDialog)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
QDateTime now = QDateTime::currentDateTime();
customTime = now.addSecs(Config::RTCOffset);
ui->chkChangeTime->setChecked(false);
ui->chkResetTime->setChecked(false);
ui->lblCustomTime->setText(customTime.toString(ui->txtNewCustomTime->displayFormat()));
startTimer(1000);
ui->txtNewCustomTime->setEnabled(ui->chkChangeTime->isChecked());
}
DateTimeDialog::~DateTimeDialog()
{
delete ui;
}
void DateTimeDialog::timerEvent(QTimerEvent* event)
{
customTime = customTime.addSecs(1);
ui->lblCustomTime->setText(customTime.toString(ui->txtNewCustomTime->displayFormat()));
}
void DateTimeDialog::done(int r)
{
if (r == QDialog::Accepted)
{
if (ui->chkChangeTime->isChecked())
{
QDateTime now = QDateTime::currentDateTime();
Config::RTCOffset = now.secsTo(ui->txtNewCustomTime->dateTime());
}
else if (ui->chkResetTime->isChecked())
Config::RTCOffset = 0;
Config::Save();
}
QDialog::done(r);
closeDlg();
}
void DateTimeDialog::on_chkChangeTime_clicked(bool checked)
{
if (checked) ui->chkResetTime->setChecked(false);
ui->txtNewCustomTime->setEnabled(checked);
}
void DateTimeDialog::on_chkResetTime_clicked(bool checked)
{
if (checked)
{
ui->chkChangeTime->setChecked(false);
ui->txtNewCustomTime->setEnabled(false);
}
}
|