mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-27 00:00:07 -06:00
RTC revamp (#1867)
* get this started * implement DSi RTC commands * set up RTC clock timer. lay down basic idea of a clock. * make the date/time registers writable * move RTC state to its own structure, to make it easier to deal with * more RTC work lay base for date/time dialog * get the bulk of the RTC functionality going * much simpler design for RTC stuff * aha, that is what it is * start working on the RTC IRQ * implement all types of RTC IRQ * start refining sleep mode. code still kinda sucks. * implement keypad IRQ * refine it some more * shut the fuck uuuuuupppppppppppppp
This commit is contained in:
91
src/frontend/qt_sdl/DateTimeDialog.cpp
Normal file
91
src/frontend/qt_sdl/DateTimeDialog.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright 2016-2022 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user