aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2022-03-06 22:07:42 +0100
committerArisotura <thetotalworm@gmail.com>2022-03-07 21:08:54 +0100
commit532b1c967a683136f0bc29616109ff79aa2de099 (patch)
treec40e171bdcd6f4fb31788c718105d75213572e1a
parent9394dde67a03b86243fb718c33ed2fa338211036 (diff)
fix up the power management dialog
-rw-r--r--src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp30
-rw-r--r--src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h7
-rw-r--r--src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.ui3
3 files changed, 39 insertions, 1 deletions
diff --git a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp
index 0cd204d..49b1a55 100644
--- a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp
+++ b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp
@@ -31,14 +31,25 @@ PowerManagementDialog* PowerManagementDialog::currentDlg = nullptr;
PowerManagementDialog::PowerManagementDialog(QWidget* parent) : QDialog(parent), ui(new Ui::PowerManagementDialog)
{
+ inited = false;
+
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
- if (NDS::ConsoleType)
+ if (NDS::ConsoleType == 1)
+ {
ui->grpDSBattery->setEnabled(false);
+
+ oldDSiBatteryCharging = DSi_BPTWL::GetBatteryCharging();
+ oldDSiBatteryLevel = DSi_BPTWL::GetBatteryLevel();
+ }
else
+ {
ui->grpDSiBattery->setEnabled(false);
+ oldDSBatteryLevel = SPI_Powerman::GetBatteryLevelOkay();
+ }
+
updateDSBatteryLevelControls();
ui->cbDSiBatteryCharging->setChecked(DSi_BPTWL::GetBatteryCharging());
@@ -52,6 +63,8 @@ PowerManagementDialog::PowerManagementDialog(QWidget* parent) : QDialog(parent),
case DSi_BPTWL::batteryLevel_Full: dsiBatterySliderPos = 4; break;
}
ui->sliderDSiBatteryLevel->setValue(dsiBatterySliderPos);
+
+ inited = true;
}
PowerManagementDialog::~PowerManagementDialog()
@@ -61,6 +74,19 @@ PowerManagementDialog::~PowerManagementDialog()
void PowerManagementDialog::done(int r)
{
+ if (r != QDialog::Accepted)
+ {
+ if (NDS::ConsoleType == 1)
+ {
+ DSi_BPTWL::SetBatteryCharging(oldDSiBatteryCharging);
+ DSi_BPTWL::SetBatteryLevel(oldDSiBatteryLevel);
+ }
+ else
+ {
+ SPI_Powerman::SetBatteryLevelOkay(oldDSBatteryLevel);
+ }
+ }
+
QDialog::done(r);
closeDlg();
@@ -91,6 +117,8 @@ void PowerManagementDialog::on_cbDSiBatteryCharging_toggled()
void PowerManagementDialog::on_sliderDSiBatteryLevel_valueChanged(int value)
{
+ if (!inited) return;
+
u8 newBatteryLevel;
switch (value)
{
diff --git a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h
index 666bbd6..0c7b853 100644
--- a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h
+++ b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h
@@ -22,6 +22,8 @@
#include <QDialog>
#include <QAbstractButton>
+#include "types.h"
+
namespace Ui { class PowerManagementDialog; }
class PowerManagementDialog;
@@ -63,6 +65,11 @@ private slots:
private:
Ui::PowerManagementDialog* ui;
+ bool inited;
+ bool oldDSBatteryLevel;
+ bool oldDSiBatteryCharging;
+ u8 oldDSiBatteryLevel;
+
void updateDSBatteryLevelControls();
};
diff --git a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.ui b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.ui
index a2c1216..e0e7c6e 100644
--- a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.ui
+++ b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.ui
@@ -20,6 +20,9 @@
<string>Power management - melonDS</string>
</property>
<layout class="QGridLayout" name="gridLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetFixedSize</enum>
+ </property>
<item row="0" column="0">
<widget class="QGroupBox" name="grpDSBattery">
<property name="title">