Qt: Split out sensor editor from override view
@@ -51,6 +51,7 @@ KeyEditor.cpp
LoadSaveState.cpp LogView.cpp SavestateButton.cpp + SensorView.cpp SettingsView.cpp ShortcutController.cpp ShortcutView.cpp@@ -63,6 +64,7 @@ GIFView.ui
GamePakView.ui LoadSaveState.ui LogView.ui + SensorView.ui SettingsView.ui ShortcutView.ui VideoView.ui)
@@ -23,22 +23,6 @@ m_ui.setupUi(this);
connect(controller, SIGNAL(gameStarted(GBAThread*)), this, SLOT(gameStarted(GBAThread*))); connect(controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(gameStopped())); - connect(m_ui.lightSpin, SIGNAL(valueChanged(int)), this, SLOT(setLuminanceValue(int))); - connect(m_ui.lightSlide, SIGNAL(valueChanged(int)), this, SLOT(setLuminanceValue(int))); - - connect(m_ui.timeNoOverride, SIGNAL(clicked()), controller, SLOT(setRealTime())); - connect(m_ui.timeFixed, &QRadioButton::clicked, [controller, this] () { - controller->setFixedTime(m_ui.time->dateTime()); - }); - connect(m_ui.timeFakeEpoch, &QRadioButton::clicked, [controller, this] () { - controller->setFakeEpoch(m_ui.time->dateTime()); - }); - connect(m_ui.time, &QDateTimeEdit::dateTimeChanged, [controller, this] (const QDateTime&) { - m_ui.timeButtons->checkedButton()->clicked(); - }); - connect(m_ui.timeNow, &QPushButton::clicked, [controller, this] () { - m_ui.time->setDateTime(QDateTime::currentDateTime()); - }); connect(m_ui.hwAutodetect, &QAbstractButton::toggled, [this] (bool enabled) { m_ui.hwRTC->setEnabled(!enabled);@@ -151,18 +135,3 @@ m_ui.hwRumble->setChecked(false);
m_ui.save->setEnabled(false); } - -void GamePakView::setLuminanceValue(int value) { - bool oldState; - value = std::max(0, std::min(value, 255)); - - oldState = m_ui.lightSpin->blockSignals(true); - m_ui.lightSpin->setValue(value); - m_ui.lightSpin->blockSignals(oldState); - - oldState = m_ui.lightSlide->blockSignals(true); - m_ui.lightSlide->setValue(value); - m_ui.lightSlide->blockSignals(oldState); - - m_controller->setLuminanceValue(value); -}
@@ -34,7 +34,6 @@ private slots:
void updateOverrides(); void gameStarted(GBAThread*); void gameStopped(); - void setLuminanceValue(int); private: Ui::GamePakView m_ui;
@@ -6,8 +6,8 @@ <property name="geometry">
<rect> <x>0</x> <y>0</y> - <width>251</width> - <height>433</height> + <width>409</width> + <height>198</height> </rect> </property> <property name="sizePolicy">@@ -19,15 +19,15 @@ </property>
<property name="windowTitle"> <string>Game Pak Overrides</string> </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QGroupBox" name="groupBox"> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="1"> + <widget class="QGroupBox" name="groupBox_2"> <property name="title"> <string/> </property> - <layout class="QFormLayout" name="formLayout"> + <layout class="QFormLayout" name="formLayout_5"> <property name="fieldGrowthPolicy"> - <enum>QFormLayout::FieldsStayAtSizeHint</enum> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> </property> <item row="0" column="0"> <widget class="QLabel" name="label">@@ -70,6 +70,35 @@ </property>
</item> </widget> </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Idle loop</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="idleOptimization"> + <item> + <property name="text"> + <string>Run</string> + </property> + </item> + <item> + <property name="text"> + <string>Optimize</string> + </property> + </item> + <item> + <property name="text"> + <string>Detect</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="idleLoop"/> + </item> <item row="1" column="0" colspan="2"> <widget class="Line" name="line"> <property name="orientation">@@ -77,14 +106,16 @@ <enum>Qt::Horizontal</enum>
</property> </widget> </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Hardware</string> - </property> - </widget> - </item> - <item row="2" column="1"> + </layout> + </widget> + </item> + <item row="0" column="0" rowspan="2"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string/> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> <widget class="QCheckBox" name="hwAutodetect"> <property name="text"> <string>Autodetect</string>@@ -94,17 +125,17 @@ <bool>true</bool>
</property> </widget> </item> - <item row="3" column="1"> + <item> <widget class="QCheckBox" name="hwRTC"> <property name="enabled"> <bool>false</bool> </property> <property name="text"> - <string>Realtime Clock</string> + <string>Realtime clock</string> </property> </widget> </item> - <item row="4" column="1"> + <item> <widget class="QCheckBox" name="hwGyro"> <property name="enabled"> <bool>false</bool>@@ -114,7 +145,7 @@ <string>Gyroscope</string>
</property> </widget> </item> - <item row="5" column="1"> + <item> <widget class="QCheckBox" name="hwTilt"> <property name="enabled"> <bool>false</bool>@@ -124,7 +155,7 @@ <string>Tilt</string>
</property> </widget> </item> - <item row="6" column="1"> + <item> <widget class="QCheckBox" name="hwLight"> <property name="enabled"> <bool>false</bool>@@ -134,7 +165,7 @@ <string>Light sensor</string>
</property> </widget> </item> - <item row="7" column="1"> + <item> <widget class="QCheckBox" name="hwRumble"> <property name="enabled"> <bool>false</bool>@@ -144,175 +175,38 @@ <string>Rumble</string>
</property> </widget> </item> - <item row="8" column="0" colspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="save"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Save overrides</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> </layout> </widget> </item> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab_3"> - <attribute name="title"> - <string>RTC</string> - </attribute> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="2" column="0"> - <widget class="QRadioButton" name="timeFakeEpoch"> - <property name="text"> - <string>Start time at</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">timeButtons</string> - </attribute> - </widget> - </item> - <item row="0" column="0"> - <widget class="QRadioButton" name="timeNoOverride"> - <property name="text"> - <string>System time</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">timeButtons</string> - </attribute> - </widget> - </item> - <item row="1" column="0"> - <widget class="QRadioButton" name="timeFixed"> - <property name="text"> - <string>Fixed time</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">timeButtons</string> - </attribute> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QDateTimeEdit" name="time"> - <property name="wrapping"> - <bool>true</bool> - </property> - <property name="maximumDate"> - <date> - <year>2099</year> - <month>12</month> - <day>31</day> - </date> - </property> - <property name="minimumDate"> - <date> - <year>2000</year> - <month>1</month> - <day>1</day> - </date> - </property> - <property name="currentSection"> - <enum>QDateTimeEdit::MonthSection</enum> - </property> - <property name="displayFormat"> - <string>MM/dd/yy hh:mm:ss AP</string> - </property> - <property name="timeSpec"> - <enum>Qt::UTC</enum> - </property> - </widget> - </item> - <item row="0" column="1" rowspan="3" alignment="Qt::AlignBottom"> - <widget class="QPushButton" name="timeNow"> - <property name="text"> - <string>Now</string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="tab_6"> - <attribute name="title"> - <string>Light</string> - </attribute> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="1"> - <widget class="QSpinBox" name="lightSpin"> - <property name="maximum"> - <number>255</number> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Brightness</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QSlider" name="lightSlide"> - <property name="maximum"> - <number>255</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="tickPosition"> - <enum>QSlider::TicksBelow</enum> - </property> - <property name="tickInterval"> - <number>16</number> - </property> - </widget> - </item> - </layout> - </widget> - </widget> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="save"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Save overrides</string> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> <resources/> <connections/> - <buttongroups> - <buttongroup name="timeButtons"/> - </buttongroups> </ui>
@@ -0,0 +1,49 @@
+/* Copyright (c) 2013-2015 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "SensorView.h" + +#include "GameController.h" + +using namespace QGBA; + +SensorView::SensorView(GameController* controller, QWidget* parent) + : QWidget(parent) + , m_controller(controller) + { + m_ui.setupUi(this); + + connect(m_ui.lightSpin, SIGNAL(valueChanged(int)), this, SLOT(setLuminanceValue(int))); + connect(m_ui.lightSlide, SIGNAL(valueChanged(int)), this, SLOT(setLuminanceValue(int))); + + connect(m_ui.timeNoOverride, SIGNAL(clicked()), controller, SLOT(setRealTime())); + connect(m_ui.timeFixed, &QRadioButton::clicked, [controller, this] () { + controller->setFixedTime(m_ui.time->dateTime()); + }); + connect(m_ui.timeFakeEpoch, &QRadioButton::clicked, [controller, this] () { + controller->setFakeEpoch(m_ui.time->dateTime()); + }); + connect(m_ui.time, &QDateTimeEdit::dateTimeChanged, [controller, this] (const QDateTime&) { + m_ui.timeButtons->checkedButton()->clicked(); + }); + connect(m_ui.timeNow, &QPushButton::clicked, [controller, this] () { + m_ui.time->setDateTime(QDateTime::currentDateTime()); + }); + } + +void SensorView::setLuminanceValue(int value) { + bool oldState; + value = std::max(0, std::min(value, 255)); + + oldState = m_ui.lightSpin->blockSignals(true); + m_ui.lightSpin->setValue(value); + m_ui.lightSpin->blockSignals(oldState); + + oldState = m_ui.lightSlide->blockSignals(true); + m_ui.lightSlide->setValue(value); + m_ui.lightSlide->blockSignals(oldState); + + m_controller->setLuminanceValue(value); +}
@@ -0,0 +1,35 @@
+/* Copyright (c) 2013-2015 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef QGBA_SENSOR_VIEW +#define QGBA_SENSOR_VIEW + +#include <QWidget> + +#include "ui_SensorView.h" + +namespace QGBA { + +class ConfigController; +class GameController; + +class SensorView : public QWidget { +Q_OBJECT + +public: + SensorView(GameController* controller, QWidget* parent = nullptr); + +private slots: + void setLuminanceValue(int); + +private: + Ui::SensorView m_ui; + + GameController* m_controller; +}; + +} + +#endif
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SensorView</class> + <widget class="QWidget" name="SensorView"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>411</width> + <height>170</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>Sensors</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>RTC</string> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="2" column="0"> + <widget class="QRadioButton" name="timeFakeEpoch"> + <property name="text"> + <string>Start time at</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">timeButtons</string> + </attribute> + </widget> + </item> + <item row="1" column="0"> + <widget class="QRadioButton" name="timeFixed"> + <property name="text"> + <string>Fixed time</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">timeButtons</string> + </attribute> + </widget> + </item> + <item row="0" column="0"> + <widget class="QRadioButton" name="timeNoOverride"> + <property name="text"> + <string>System time</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">timeButtons</string> + </attribute> + </widget> + </item> + <item row="3" column="0" colspan="2"> + <widget class="QDateTimeEdit" name="time"> + <property name="wrapping"> + <bool>true</bool> + </property> + <property name="maximumDate"> + <date> + <year>2100</year> + <month>1</month> + <day>2</day> + </date> + </property> + <property name="minimumDate"> + <date> + <year>2000</year> + <month>1</month> + <day>1</day> + </date> + </property> + <property name="currentSection"> + <enum>QDateTimeEdit::MonthSection</enum> + </property> + <property name="displayFormat"> + <string>MM/dd/yy hh:mm:ss AP</string> + </property> + <property name="timeSpec"> + <enum>Qt::UTC</enum> + </property> + </widget> + </item> + <item row="0" column="1" rowspan="3"> + <widget class="QPushButton" name="timeNow"> + <property name="text"> + <string>Now</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Light sensor</string> + </property> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="0" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Brightness</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="lightSpin"> + <property name="maximum"> + <number>255</number> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QSlider" name="lightSlide"> + <property name="maximum"> + <number>255</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>16</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> + <buttongroups> + <buttongroup name="timeButtons"/> + </buttongroups> +</ui>
@@ -23,6 +23,7 @@ #include "GIFView.h"
#include "GamePakView.h" #include "LoadSaveState.h" #include "LogView.h" +#include "SensorView.h" #include "SettingsView.h" #include "ShortcutController.h" #include "ShortcutView.h"@@ -233,6 +234,12 @@ GamePakView* gamePakWindow = new GamePakView(m_controller, m_config);
connect(this, SIGNAL(shutdown()), gamePakWindow, SLOT(close())); gamePakWindow->setAttribute(Qt::WA_DeleteOnClose); gamePakWindow->show(); +} +void Window::openSensorWindow() { + SensorView* sensorWindow = new SensorView(m_controller); + connect(this, SIGNAL(shutdown()), sensorWindow, SLOT(close())); + sensorWindow->setAttribute(Qt::WA_DeleteOnClose); + sensorWindow->show(); } #ifdef BUILD_SDL@@ -675,6 +682,10 @@
QAction* gamePak = new QAction(tr("Game &Pak overrides..."), toolsMenu); connect(gamePak, SIGNAL(triggered()), this, SLOT(openGamePakWindow())); addControlledAction(toolsMenu, gamePak, "gamePakOverrides"); + + QAction* gamePakSensors = new QAction(tr("Game &Pak sensors..."), toolsMenu); + connect(gamePakSensors, SIGNAL(triggered()), this, SLOT(openSensorWindow())); + addControlledAction(toolsMenu, gamePakSensors, "gamePakSensors"); #ifdef USE_GDB_STUB QAction* gdbWindow = new QAction(tr("Start &GDB server..."), toolsMenu);
@@ -68,6 +68,7 @@ void openSettingsWindow();
void openShortcutWindow(); void openGamePakWindow(); + void openSensorWindow(); #ifdef BUILD_SDL void openGamepadWindow();