aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2020-05-17 18:33:03 +0200
committerArisotura <thetotalworm@gmail.com>2020-05-17 18:33:03 +0200
commit19566178ba7ee1fcd4207139286707cc3896493a (patch)
tree2eba56536766ccfa2a2c0c04f928d156ee0a7818 /src/frontend
parentc9a76edf210410dbf95d100690bad9c86aa5bd84 (diff)
begin adding input dialog
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/qt_sdl/CMakeLists.txt1
-rw-r--r--src/frontend/qt_sdl/EmuSettingsDialog.h5
-rw-r--r--src/frontend/qt_sdl/InputConfigDialog.cpp53
-rw-r--r--src/frontend/qt_sdl/InputConfigDialog.h63
-rw-r--r--src/frontend/qt_sdl/InputConfigDialog.ui126
-rw-r--r--src/frontend/qt_sdl/main.cpp21
-rw-r--r--src/frontend/qt_sdl/main.h3
7 files changed, 268 insertions, 4 deletions
diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt
index a6aeb0e..da3bb1d 100644
--- a/src/frontend/qt_sdl/CMakeLists.txt
+++ b/src/frontend/qt_sdl/CMakeLists.txt
@@ -3,6 +3,7 @@ project(qt_sdl)
SET(SOURCES_QT_SDL
main.cpp
EmuSettingsDialog.cpp
+ InputConfigDialog.cpp
Platform.cpp
PlatformConfig.cpp
diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.h b/src/frontend/qt_sdl/EmuSettingsDialog.h
index ce64145..7378641 100644
--- a/src/frontend/qt_sdl/EmuSettingsDialog.h
+++ b/src/frontend/qt_sdl/EmuSettingsDialog.h
@@ -33,16 +33,17 @@ public:
~EmuSettingsDialog();
static EmuSettingsDialog* currentDlg;
- static void openDlg(QWidget* parent)
+ static EmuSettingsDialog* openDlg(QWidget* parent)
{
if (currentDlg)
{
currentDlg->activateWindow();
- return;
+ return currentDlg;
}
currentDlg = new EmuSettingsDialog(parent);
currentDlg->show();
+ return currentDlg;
}
static void closeDlg()
{
diff --git a/src/frontend/qt_sdl/InputConfigDialog.cpp b/src/frontend/qt_sdl/InputConfigDialog.cpp
new file mode 100644
index 0000000..f7c0ab2
--- /dev/null
+++ b/src/frontend/qt_sdl/InputConfigDialog.cpp
@@ -0,0 +1,53 @@
+/*
+ Copyright 2016-2020 Arisotura
+
+ 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 "types.h"
+#include "Config.h"
+#include "PlatformConfig.h"
+
+#include "InputConfigDialog.h"
+#include "ui_InputConfigDialog.h"
+
+
+InputConfigDialog* InputConfigDialog::currentDlg = nullptr;
+
+
+InputConfigDialog::InputConfigDialog(QWidget* parent) : QDialog(parent), ui(new Ui::InputConfigDialog)
+{
+ ui->setupUi(this);
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ //
+}
+
+InputConfigDialog::~InputConfigDialog()
+{
+ delete ui;
+}
+
+void InputConfigDialog::on_InputConfigDialog_accepted()
+{
+ closeDlg();
+}
+
+void InputConfigDialog::on_InputConfigDialog_rejected()
+{
+ closeDlg();
+}
diff --git a/src/frontend/qt_sdl/InputConfigDialog.h b/src/frontend/qt_sdl/InputConfigDialog.h
new file mode 100644
index 0000000..2af73db
--- /dev/null
+++ b/src/frontend/qt_sdl/InputConfigDialog.h
@@ -0,0 +1,63 @@
+/*
+ Copyright 2016-2020 Arisotura
+
+ 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/.
+*/
+
+#ifndef INPUTCONFIGDIALOG_H
+#define INPUTCONFIGDIALOG_H
+
+#include <QDialog>
+
+namespace Ui { class InputConfigDialog; }
+class InputConfigDialog;
+
+class InputConfigDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit InputConfigDialog(QWidget* parent);
+ ~InputConfigDialog();
+
+ static InputConfigDialog* currentDlg;
+ static InputConfigDialog* openDlg(QWidget* parent)
+ {
+ if (currentDlg)
+ {
+ currentDlg->activateWindow();
+ return currentDlg;
+ }
+
+ currentDlg = new InputConfigDialog(parent);
+ currentDlg->open();
+ return currentDlg;
+ }
+ static void closeDlg()
+ {
+ currentDlg = nullptr;
+ }
+
+private slots:
+ void on_InputConfigDialog_accepted();
+ void on_InputConfigDialog_rejected();
+
+ //
+
+private:
+ Ui::InputConfigDialog* ui;
+};
+
+#endif // INPUTCONFIGDIALOG_H
diff --git a/src/frontend/qt_sdl/InputConfigDialog.ui b/src/frontend/qt_sdl/InputConfigDialog.ui
new file mode 100644
index 0000000..c1422e9
--- /dev/null
+++ b/src/frontend/qt_sdl/InputConfigDialog.ui
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>InputConfigDialog</class>
+ <widget class="QDialog" name="InputConfigDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>488</width>
+ <height>365</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>TDAH</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetFixedSize</enum>
+ </property>
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>1</number>
+ </property>
+ <widget class="QWidget" name="tabInput">
+ <attribute name="title">
+ <string>DS input</string>
+ </attribute>
+ </widget>
+ <widget class="QWidget" name="tabHotkeysGeneral">
+ <attribute name="title">
+ <string>General hotkeys</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Joystick:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cbxJoystick">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="whatsThis">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Selects which joystick will be used for joystick input, if any is present.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>InputConfigDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>InputConfigDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp
index a7388a0..cd7849d 100644
--- a/src/frontend/qt_sdl/main.cpp
+++ b/src/frontend/qt_sdl/main.cpp
@@ -32,6 +32,7 @@
#include "main.h"
#include "EmuSettingsDialog.h"
+#include "InputConfigDialog.h"
#include "types.h"
#include "version.h"
@@ -551,6 +552,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
actEmuSettings = menu->addAction("Emu settings");
connect(actEmuSettings, &QAction::triggered, this, &MainWindow::onOpenEmuSettings);
+
+ actInputConfig = menu->addAction("Input and hotkeys");
+ connect(actInputConfig, &QAction::triggered, this, &MainWindow::onOpenInputConfig);
}
setMenuBar(menubar);
@@ -850,6 +854,19 @@ void MainWindow::onOpenEmuSettings()
EmuSettingsDialog::openDlg(this);
}
+void MainWindow::onOpenInputConfig()
+{
+ emuThread->emuPause(true);
+
+ InputConfigDialog* dlg = InputConfigDialog::openDlg(this);
+ connect(dlg, &InputConfigDialog::finished, this, &MainWindow::onInputConfigFinished);
+}
+
+void MainWindow::onInputConfigFinished()
+{printf("FARTO\n");
+ emuThread->emuUnpause();
+}
+
int main(int argc, char** argv)
{
@@ -915,8 +932,8 @@ int main(int argc, char** argv)
Config::Load();
- //if (Config::AudioVolume < 0) Config::AudioVolume = 0;
- //else if (Config::AudioVolume > 256) Config::AudioVolume = 256;
+ if (Config::AudioVolume < 0) Config::AudioVolume = 0;
+ else if (Config::AudioVolume > 256) Config::AudioVolume = 256;
// TODO: this should be checked before running anything
#if 0
diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h
index ee0094f..0324ecf 100644
--- a/src/frontend/qt_sdl/main.h
+++ b/src/frontend/qt_sdl/main.h
@@ -108,6 +108,8 @@ private slots:
void onEmuUnpause();
void onOpenEmuSettings();
+ void onOpenInputConfig();
+ void onInputConfigFinished();
private:
QString loadErrorStr(int error);
@@ -126,6 +128,7 @@ private:
QAction* actStop;
QAction* actEmuSettings;
+ QAction* actInputConfig;
};
#endif // MAIN_H