diff --git a/simple64-gui/CMakeLists.txt b/simple64-gui/CMakeLists.txt index 5e5ce35..6c0257b 100644 --- a/simple64-gui/CMakeLists.txt +++ b/simple64-gui/CMakeLists.txt @@ -43,6 +43,7 @@ add_executable(simple64-gui vidext.cpp settingsdialog.cpp interface/common.cpp + hotkeydialog.cpp plugindialog.cpp vkwindow.cpp workerthread.cpp diff --git a/simple64-gui/hotkeydialog.cpp b/simple64-gui/hotkeydialog.cpp new file mode 100644 index 0000000..715ab58 --- /dev/null +++ b/simple64-gui/hotkeydialog.cpp @@ -0,0 +1,159 @@ +#include "hotkeydialog.h" +#include "mainwindow.h" +#include "interface/core_commands.h" +#include "interface/sdl_key_converter.h" + +#include +#include +#include +#include + +static void paramListCallback(void *context, const char *ParamName, m64p_type ParamType) +{ + HotkeyDialog* dialog = (HotkeyDialog*)context; + + if (strcmp((char*)ParamName, "Version") == 0) return; + else if (strncmp((char*)ParamName, "Joy Mapping", 11) == 0) return; + + int l_ParamInt; + bool l_ParamBool; + float l_ParamFloat; + QString l_ParamString; + QString helper = (*ConfigGetParameterHelp)(dialog->getHandle(), ParamName); + QLabel *desc = new QLabel(ParamName, dialog->getLayout()->parentWidget()); + if (!helper.isEmpty()) { + helper.prepend(""); + helper.append(""); + desc->setToolTip(helper); + } + desc->setStyleSheet("border: 1px solid; padding: 10px"); + dialog->getLayout()->addWidget(desc, *dialog->getLayoutRow(), 0); + CustomButton *my_Widget = new CustomButton(dialog->getLayout()->parentWidget()); + dialog->getButtonList()->append(my_Widget); + my_Widget->setConfigHandle(dialog->getHandle()); + my_Widget->setParamType(ParamType); + my_Widget->setParamName(ParamName); + my_Widget->setDialog(dialog); + l_ParamInt = (*ConfigGetParamInt)(dialog->getHandle(), ParamName); + my_Widget->setText(QKeySequence(SDL22QT(sdl_keysym2scancode(l_ParamInt))).toString()); + + dialog->getLayout()->addWidget((QWidget*)my_Widget, *dialog->getLayoutRow(), 1); + + ClearButton* clear_Widget = new ClearButton(dialog->getLayout()->parentWidget()); + clear_Widget->setConfigHandle(dialog->getHandle()); + clear_Widget->setParamType(ParamType); + clear_Widget->setParamName(ParamName); + clear_Widget->setDialog(dialog); + clear_Widget->setMainButton(my_Widget); + l_ParamInt = (*ConfigGetParamInt)(dialog->getHandle(), ParamName); + clear_Widget->setText("Clear"); + + dialog->getLayout()->addWidget((QWidget*)clear_Widget, *dialog->getLayoutRow(), 2); + ++*dialog->getLayoutRow(); +} + +void HotkeyDialog::handleResetButton() +{ + int value; + (*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_EMU_STATE, &value); + if (value == M64EMU_STOPPED) { + (*ConfigDeleteSection)("CoreEvents"); + (*ConfigSaveFile)(); + w->resetCore(); + this->close(); + } + else { + QMessageBox msgBox; + msgBox.setText("Emulator must be stopped."); + msgBox.exec(); + } +} + +HotkeyDialog::HotkeyDialog(QWidget *parent) + : QDialog(parent) +{ + m64p_error res; + + m_activeButton = nullptr; + + m_layoutRow = 0; + QVBoxLayout *mainLayout = new QVBoxLayout(this); + + QWidget *coreEventsSettings = new QWidget(this); + m_layout = new QGridLayout(coreEventsSettings); + coreEventsSettings->setLayout(m_layout); + res = (*ConfigOpenSection)("CoreEvents", &m_configHandle); + if (res == M64ERR_SUCCESS) + (*ConfigListParameters)(m_configHandle, this, paramListCallback); + QScrollArea *coreEventsScroll = new QScrollArea(this); + coreEventsScroll->setWidget(coreEventsSettings); + coreEventsScroll->setMinimumWidth(coreEventsSettings->sizeHint().width() + 20); + coreEventsScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + QLabel *myLabel = new QLabel("Hover your mouse over the configuration item name for a description.\n", this); + myLabel->setStyleSheet("font-weight: bold"); + mainLayout->addWidget(myLabel); + mainLayout->addWidget(coreEventsScroll); + QPushButton *resetButton = new QPushButton("Reset All Settings", this); + resetButton->setAutoDefault(false); + connect(resetButton, SIGNAL (released()),this, SLOT (handleResetButton())); + mainLayout->addWidget(resetButton); + setLayout(mainLayout); +} + +void HotkeyDialog::keyReleaseEvent(QKeyEvent *event) +{ + int keyValue = sdl_scancode2keysym(QT2SDL2(event->key())); + if (m_activeButton != nullptr) { + killTimer(m_timer); + (*ConfigSetParameter)(m_configHandle, m_activeButton->getParamName(), m_activeButton->getParamType(), &keyValue); + (*ConfigSaveFile)(); + m_activeButton->setText(QKeySequence(event->key()).toString()); + m_activeButton = nullptr; + for (int i = 0; i < m_coreEventsButtonList.size(); ++i) + m_coreEventsButtonList.at(i)->setDisabled(0); + } +} + +void HotkeyDialog::timerEvent(QTimerEvent *) +{ + if (m_buttonTimer == 0) { + killTimer(m_timer); + m_activeButton->setText(m_activeButton->getOrigText()); + m_activeButton = nullptr; + for (int i = 0; i < m_coreEventsButtonList.size(); ++i) { + m_coreEventsButtonList.at(i)->setDisabled(0); + } + return; + } + --m_buttonTimer; + m_activeButton->setText(QString::number(ceil(m_buttonTimer/10.0))); +} + +CustomButton::CustomButton(QWidget *parent) + : QPushButton(parent) +{ + connect(this, &QPushButton::released, [=]{ + int buttonTimer = 50; + for (int i = 0; i < ((HotkeyDialog*)m_dialog)->getButtonList()->size(); ++i) + ((HotkeyDialog*)m_dialog)->getButtonList()->at(i)->setDisabled(1); + ((HotkeyDialog*)m_dialog)->setActiveButton(this); + ((HotkeyDialog*)m_dialog)->setButtonTimer(buttonTimer); + origText = text(); + setText(QString::number(buttonTimer/10)); + ((HotkeyDialog*)m_dialog)->setTimer(100); + }); +} + +ClearButton::ClearButton(QWidget *parent) + : QPushButton(parent) +{ + connect(this, &QPushButton::released, [=]{ + if (((HotkeyDialog*)m_dialog)->getActiveButton() == m_MainButton) + return; + int value = 0; + (*ConfigSetParameter)(m_CurrentHandle, m_ParamName.toUtf8().constData(), m_ParamType, &value); + (*ConfigSaveFile)(); + m_MainButton->setText(""); + }); +} diff --git a/simple64-gui/hotkeydialog.h b/simple64-gui/hotkeydialog.h new file mode 100644 index 0000000..7c71c94 --- /dev/null +++ b/simple64-gui/hotkeydialog.h @@ -0,0 +1,115 @@ +#ifndef HOTKEYDIALOG_H +#define HOTKEYDIALOG_H + +#include +#include +#include +#include "m64p_types.h" + +class CustomButton : public QPushButton +{ +public: + explicit CustomButton(QWidget *parent = 0); + void setParamName(const char* ParamName) { + m_ParamName = ParamName; + } + void setParamType(m64p_type ParamType) { + m_ParamType = ParamType; + } + void setConfigHandle(m64p_handle CurrentHandle) { + m_CurrentHandle = CurrentHandle; + } + void setDialog(void* Dialog) { + m_dialog = Dialog; + } + QString getOrigText() { + return origText; + } + const char * getParamName() { + return m_ParamName.toUtf8().constData(); + } + m64p_type getParamType() { + return m_ParamType; + } +private: + m64p_type m_ParamType; + QString m_ParamName; + m64p_handle m_CurrentHandle; + void* m_dialog; + QString origText; +}; + +class ClearButton : public QPushButton +{ +public: + explicit ClearButton(QWidget *parent = 0); + void setParamName(const char* ParamName) { + m_ParamName = ParamName; + } + void setParamType(m64p_type ParamType) { + m_ParamType = ParamType; + } + void setConfigHandle(m64p_handle CurrentHandle) { + m_CurrentHandle = CurrentHandle; + } + void setMainButton(CustomButton* MainButton) { + m_MainButton = MainButton; + } + void setDialog(void* Dialog) { + m_dialog = Dialog; + } + +private: + m64p_type m_ParamType; + QString m_ParamName; + m64p_handle m_CurrentHandle; + CustomButton* m_MainButton; + void* m_dialog; +}; + +class HotkeyDialog : public QDialog +{ + Q_OBJECT +public: + HotkeyDialog(QWidget *parent = nullptr); + QList* getButtonList(){ + return &m_coreEventsButtonList; + } + m64p_handle getHandle(){ + return m_configHandle; + } + QGridLayout* getLayout(){ + return m_layout; + } + int* getLayoutRow(){ + return &m_layoutRow; + } + void setTimer(int timer){ + m_timer = startTimer(timer); + } + void setButtonTimer(int timer){ + m_buttonTimer = timer; + } + void setActiveButton(CustomButton* button){ + m_activeButton = button; + } + CustomButton* getActiveButton() + { + return m_activeButton; + } +protected: + void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; +private slots: + void handleResetButton(); +private: + QList m_coreEventsButtonList; + m64p_handle m_configHandle; + QGridLayout *m_layout; + int m_layoutRow; + CustomButton* m_activeButton; + int m_timer; + int m_buttonTimer; +}; + +#endif // HOTKEYDIALOG_H diff --git a/simple64-gui/interface/common.cpp b/simple64-gui/interface/common.cpp index 5faf7ed..236f984 100644 --- a/simple64-gui/interface/common.cpp +++ b/simple64-gui/interface/common.cpp @@ -615,3 +615,311 @@ int QT2SDL2(int qtKey) return returnValue; } + +int SDL22QT(int scanCode) +{ + int returnValue; + switch (scanCode) { + case SDL_SCANCODE_ESCAPE: + returnValue = Qt::Key_Escape; + break; + case SDL_SCANCODE_TAB: + returnValue = Qt::Key_Tab; + break; + case SDL_SCANCODE_BACKSPACE: + returnValue = Qt::Key_Backspace; + break; + case SDL_SCANCODE_RETURN: + returnValue = Qt::Key_Return; + break; + case SDL_SCANCODE_KP_ENTER: + returnValue = Qt::Key_Enter; + break; + case SDL_SCANCODE_INSERT: + returnValue = Qt::Key_Insert; + break; + case SDL_SCANCODE_DELETE: + returnValue = Qt::Key_Delete; + break; + case SDL_SCANCODE_PAUSE: + returnValue = Qt::Key_Pause; + break; + case SDL_SCANCODE_PRINTSCREEN: + returnValue = Qt::Key_Print; + break; + case SDL_SCANCODE_SYSREQ: + returnValue = Qt::Key_SysReq; + break; + case SDL_SCANCODE_CLEAR: + returnValue = Qt::Key_Clear; + break; + case SDL_SCANCODE_HOME: + returnValue = Qt::Key_Home; + break; + case SDL_SCANCODE_END: + returnValue = Qt::Key_End; + break; + case SDL_SCANCODE_LEFT: + returnValue = Qt::Key_Left; + break; + case SDL_SCANCODE_RIGHT: + returnValue = Qt::Key_Right; + break; + case SDL_SCANCODE_UP: + returnValue = Qt::Key_Up; + break; + case SDL_SCANCODE_DOWN: + returnValue = Qt::Key_Down; + break; + case SDL_SCANCODE_PAGEUP: + returnValue = Qt::Key_PageUp; + break; + case SDL_SCANCODE_PAGEDOWN: + returnValue = Qt::Key_PageDown; + break; + case SDL_SCANCODE_LSHIFT: + returnValue = Qt::Key_Shift; + break; + case SDL_SCANCODE_LCTRL: + returnValue = Qt::Key_Control; + break; + case SDL_SCANCODE_LGUI: + returnValue = Qt::Key_Meta; + break; + case SDL_SCANCODE_LALT: + returnValue = Qt::Key_Alt; + break; + case SDL_SCANCODE_RALT: + returnValue = Qt::Key_AltGr; + break; + case SDL_SCANCODE_CAPSLOCK: + returnValue = Qt::Key_CapsLock; + break; + case SDL_SCANCODE_NUMLOCKCLEAR: + returnValue = Qt::Key_NumLock; + break; + case SDL_SCANCODE_SCROLLLOCK: + returnValue = Qt::Key_ScrollLock; + break; + case SDL_SCANCODE_F1: + returnValue = Qt::Key_F1; + break; + case SDL_SCANCODE_F2: + returnValue = Qt::Key_F2; + break; + case SDL_SCANCODE_F3: + returnValue = Qt::Key_F3; + break; + case SDL_SCANCODE_F4: + returnValue = Qt::Key_F4; + break; + case SDL_SCANCODE_F5: + returnValue = Qt::Key_F5; + break; + case SDL_SCANCODE_F6: + returnValue = Qt::Key_F6; + break; + case SDL_SCANCODE_F7: + returnValue = Qt::Key_F7; + break; + case SDL_SCANCODE_F8: + returnValue = Qt::Key_F8; + break; + case SDL_SCANCODE_F9: + returnValue = Qt::Key_F9; + break; + case SDL_SCANCODE_F10: + returnValue = Qt::Key_F10; + break; + case SDL_SCANCODE_F11: + returnValue = Qt::Key_F11; + break; + case SDL_SCANCODE_F12: + returnValue = Qt::Key_F12; + break; + case SDL_SCANCODE_F13: + returnValue = Qt::Key_F13; + break; + case SDL_SCANCODE_F14: + returnValue = Qt::Key_F14; + break; + case SDL_SCANCODE_F15: + returnValue = Qt::Key_F15; + break; + case SDL_SCANCODE_F16: + returnValue = Qt::Key_F16; + break; + case SDL_SCANCODE_F17: + returnValue = Qt::Key_F17; + break; + case SDL_SCANCODE_F18: + returnValue = Qt::Key_F18; + break; + case SDL_SCANCODE_F19: + returnValue = Qt::Key_F19; + break; + case SDL_SCANCODE_F20: + returnValue = Qt::Key_F20; + break; + case SDL_SCANCODE_F21: + returnValue = Qt::Key_F21; + break; + case SDL_SCANCODE_F22: + returnValue = Qt::Key_F22; + break; + case SDL_SCANCODE_F23: + returnValue = Qt::Key_F23; + break; + case SDL_SCANCODE_F24: + returnValue = Qt::Key_F24; + break; + case SDL_SCANCODE_SPACE: + returnValue = Qt::Key_Space; + break; + case SDL_SCANCODE_0: + returnValue = Qt::Key_0; + break; + case SDL_SCANCODE_1: + returnValue = Qt::Key_1; + break; + case SDL_SCANCODE_2: + returnValue = Qt::Key_2; + break; + case SDL_SCANCODE_3: + returnValue = Qt::Key_3; + break; + case SDL_SCANCODE_4: + returnValue = Qt::Key_4; + break; + case SDL_SCANCODE_5: + returnValue = Qt::Key_5; + break; + case SDL_SCANCODE_6: + returnValue = Qt::Key_6; + break; + case SDL_SCANCODE_7: + returnValue = Qt::Key_7; + break; + case SDL_SCANCODE_8: + returnValue = Qt::Key_8; + break; + case SDL_SCANCODE_9: + returnValue = Qt::Key_9; + break; + case SDL_SCANCODE_A: + returnValue = Qt::Key_A; + break; + case SDL_SCANCODE_B: + returnValue = Qt::Key_B; + break; + case SDL_SCANCODE_C: + returnValue = Qt::Key_C; + break; + case SDL_SCANCODE_D: + returnValue = Qt::Key_D; + break; + case SDL_SCANCODE_E: + returnValue = Qt::Key_E; + break; + case SDL_SCANCODE_F: + returnValue = Qt::Key_F; + break; + case SDL_SCANCODE_G: + returnValue = Qt::Key_G; + break; + case SDL_SCANCODE_H: + returnValue = Qt::Key_H; + break; + case SDL_SCANCODE_I: + returnValue = Qt::Key_I; + break; + case SDL_SCANCODE_J: + returnValue = Qt::Key_J; + break; + case SDL_SCANCODE_K: + returnValue = Qt::Key_K; + break; + case SDL_SCANCODE_L: + returnValue = Qt::Key_L; + break; + case SDL_SCANCODE_M: + returnValue = Qt::Key_M; + break; + case SDL_SCANCODE_N: + returnValue = Qt::Key_N; + break; + case SDL_SCANCODE_O: + returnValue = Qt::Key_O; + break; + case SDL_SCANCODE_P: + returnValue = Qt::Key_P; + break; + case SDL_SCANCODE_Q: + returnValue = Qt::Key_Q; + break; + case SDL_SCANCODE_R: + returnValue = Qt::Key_R; + break; + case SDL_SCANCODE_S: + returnValue = Qt::Key_S; + break; + case SDL_SCANCODE_T: + returnValue = Qt::Key_T; + break; + case SDL_SCANCODE_U: + returnValue = Qt::Key_U; + break; + case SDL_SCANCODE_V: + returnValue = Qt::Key_V; + break; + case SDL_SCANCODE_W: + returnValue = Qt::Key_W; + break; + case SDL_SCANCODE_X: + returnValue = Qt::Key_X; + break; + case SDL_SCANCODE_Y: + returnValue = Qt::Key_Y; + break; + case SDL_SCANCODE_Z: + returnValue = Qt::Key_Z; + break; + case SDL_SCANCODE_LEFTBRACKET: + returnValue = Qt::Key_BracketLeft; + break; + case SDL_SCANCODE_RIGHTBRACKET: + returnValue = Qt::Key_BracketRight; + break; + case SDL_SCANCODE_MINUS: + returnValue = Qt::Key_Minus; + break; + case SDL_SCANCODE_SEMICOLON: + returnValue = Qt::Key_Semicolon; + break; + case SDL_SCANCODE_SLASH: + returnValue = Qt::Key_Slash; + break; + case SDL_SCANCODE_BACKSLASH: + returnValue = Qt::Key_Backslash; + break; + case SDL_SCANCODE_APOSTROPHE: + returnValue = Qt::Key_Apostrophe; + break; + case SDL_SCANCODE_COMMA: + returnValue = Qt::Key_Comma; + break; + case SDL_SCANCODE_PERIOD: + returnValue = Qt::Key_Period; + break; + case SDL_SCANCODE_EQUALS: + returnValue = Qt::Key_Equal; + break; + case SDL_SCANCODE_GRAVE: + returnValue = Qt::Key_QuoteLeft; + break; + default: + returnValue = Qt::Key_unknown; + break; + } + return returnValue; +} diff --git a/simple64-gui/interface/common.h b/simple64-gui/interface/common.h index 13c5d31..b34dccd 100644 --- a/simple64-gui/interface/common.h +++ b/simple64-gui/interface/common.h @@ -35,6 +35,7 @@ extern "C" { void DebugMessage(int level, const char *message, ...); void DebugCallback(void *Context, int level, const char *message); int QT2SDL2(int qtKey); +int SDL22QT(int scanCode); #ifdef __cplusplus } #endif diff --git a/simple64-gui/mainwindow.cpp b/simple64-gui/mainwindow.cpp index 07e13c8..b711ad7 100644 --- a/simple64-gui/mainwindow.cpp +++ b/simple64-gui/mainwindow.cpp @@ -5,6 +5,7 @@ #include #include "settingsdialog.h" #include "plugindialog.h" +#include "hotkeydialog.h" #include "mainwindow.h" #include "ui_mainwindow.h" #include "interface/common.h" @@ -795,6 +796,12 @@ void MainWindow::on_actionController_Configuration_triggered() PluginConfig(); } +void MainWindow::on_actionHotkey_Configuration_triggered() +{ + HotkeyDialog *settings = new HotkeyDialog(this); + settings->show(); +} + void MainWindow::on_actionToggle_Speed_Limiter_triggered() { int value; diff --git a/simple64-gui/mainwindow.h b/simple64-gui/mainwindow.h index f214f3b..da76e3e 100644 --- a/simple64-gui/mainwindow.h +++ b/simple64-gui/mainwindow.h @@ -113,6 +113,8 @@ private slots: void on_actionController_Configuration_triggered(); + void on_actionHotkey_Configuration_triggered(); + void on_actionToggle_Speed_Limiter_triggered(); void on_actionView_Log_triggered(); diff --git a/simple64-gui/mainwindow.ui b/simple64-gui/mainwindow.ui index 73a81b5..4f8cf97 100644 --- a/simple64-gui/mainwindow.ui +++ b/simple64-gui/mainwindow.ui @@ -47,6 +47,7 @@ + @@ -103,7 +104,7 @@ - Stop Emulation (Escape) + Stop Emulation @@ -118,12 +119,12 @@ - Save State (F5) + Save State - Load State (F7) + Load State @@ -143,17 +144,17 @@ - Take Screenshot (F12) + Take Screenshot - Pause/Resume Game (p) + Pause/Resume Game - Mute/Unmute (m) + Mute/Unmute @@ -163,7 +164,7 @@ - Soft Reset (F9) + Soft Reset @@ -176,9 +177,14 @@ Controller Configuration + + + Hotkey Configuration + + - Toggle Speed Limiter (y) + Toggle Speed Limiter diff --git a/simple64-gui/plugindialog.cpp b/simple64-gui/plugindialog.cpp index 55c4fe0..28254a5 100644 --- a/simple64-gui/plugindialog.cpp +++ b/simple64-gui/plugindialog.cpp @@ -6,21 +6,14 @@ #include #include #include -#include #include #include -#include "settingclasses.h" - -m64p_handle coreConfigHandle; -m64p_handle videoConfigHandle; -QGridLayout *coreLayout; -int coreLayoutRow; -QGridLayout *videoLayout; -int videoRow; static void paramListCallback(void *context, const char *ParamName, m64p_type ParamType) { - if (strcmp((char*)context, "Core") == 0) { + PluginDialog* dialog = (PluginDialog*)context; + + if (dialog->getSection() == "Core") { if (strcmp((char*)ParamName, "Version") == 0) return; else if (strcmp((char*)ParamName, "OnScreenDisplay") == 0) return; else if (strcmp((char*)ParamName, "NoCompiledJump") == 0) return; @@ -33,14 +26,14 @@ static void paramListCallback(void *context, const char *ParamName, m64p_type Pa QGridLayout *my_layout = nullptr; int * my_row = nullptr; m64p_handle current_handle = nullptr; - if (strcmp((char*)context, "Core") == 0) { - my_layout = coreLayout; - my_row = &coreLayoutRow; - current_handle = coreConfigHandle; - } else if (strcmp((char*)context, "Video") == 0) { - my_layout = videoLayout; - my_row = &videoRow; - current_handle = videoConfigHandle; + if (dialog->getSection() == "Core") { + my_layout = dialog->getCoreLayout(); + my_row = dialog->getCoreLayoutRow(); + current_handle = dialog->getCoreHandle(); + } else if (dialog->getSection() == "Video") { + my_layout = dialog->getVideoLayout(); + my_row = dialog->getVideoLayoutRow(); + current_handle = dialog->getVideoHandle(); } int l_ParamInt; bool l_ParamBool; @@ -123,20 +116,22 @@ PluginDialog::PluginDialog(QWidget *parent) : QDialog(parent) { m64p_error res; - int value; - (*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_EMU_STATE, &value); - coreLayoutRow = 0; + m_coreLayoutRow = 0; + m_videoLayoutRow = 0; QVBoxLayout *mainLayout = new QVBoxLayout(this); QTabWidget *tabWidget = new QTabWidget(this); tabWidget->setUsesScrollButtons(false); QWidget *coreSettings = new QWidget(this); - coreLayout = new QGridLayout(coreSettings); - coreSettings->setLayout(coreLayout); - res = (*ConfigOpenSection)("Core", &coreConfigHandle); + m_coreLayout = new QGridLayout(coreSettings); + coreSettings->setLayout(m_coreLayout); + res = (*ConfigOpenSection)("Core", &m_coreConfigHandle); if (res == M64ERR_SUCCESS) - (*ConfigListParameters)(coreConfigHandle, (char*)"Core", paramListCallback); + { + this->m_section = "Core"; + (*ConfigListParameters)(m_coreConfigHandle, this, paramListCallback); + } QScrollArea *coreScroll = new QScrollArea(this); coreScroll->setWidget(coreSettings); coreScroll->setMinimumWidth(coreSettings->sizeHint().width() + 20); @@ -144,11 +139,14 @@ PluginDialog::PluginDialog(QWidget *parent) tabWidget->addTab(coreScroll, tr("Core")); QWidget *videoSettings = new QWidget(this); - videoLayout = new QGridLayout(videoSettings); - videoSettings->setLayout(videoLayout); - res = (*ConfigOpenSection)("Video-Parallel", &videoConfigHandle); + m_videoLayout = new QGridLayout(videoSettings); + videoSettings->setLayout(m_videoLayout); + res = (*ConfigOpenSection)("Video-Parallel", &m_videoConfigHandle); if (res == M64ERR_SUCCESS) - (*ConfigListParameters)(videoConfigHandle, (char*)"Video", paramListCallback); + { + this->m_section = "Video"; + (*ConfigListParameters)(m_videoConfigHandle, this, paramListCallback); + } QScrollArea *videoScroll = new QScrollArea(this); videoScroll->setWidget(videoSettings); videoScroll->setMinimumWidth(videoSettings->sizeHint().width() + 20); @@ -165,3 +163,38 @@ PluginDialog::PluginDialog(QWidget *parent) mainLayout->addWidget(resetButton); setLayout(mainLayout); } + +QString PluginDialog::getSection() +{ + return m_section; +} + +m64p_handle PluginDialog::getCoreHandle() +{ + return m_coreConfigHandle; +} + +m64p_handle PluginDialog::getVideoHandle() +{ + return m_videoConfigHandle; +} + +QGridLayout * PluginDialog::getCoreLayout() +{ + return m_coreLayout; +} + +QGridLayout * PluginDialog::getVideoLayout() +{ + return m_videoLayout; +} + +int * PluginDialog::getCoreLayoutRow() +{ + return &m_coreLayoutRow; +} + +int * PluginDialog::getVideoLayoutRow() +{ + return &m_videoLayoutRow; +} diff --git a/simple64-gui/plugindialog.h b/simple64-gui/plugindialog.h index 1a81a8e..ef77d27 100644 --- a/simple64-gui/plugindialog.h +++ b/simple64-gui/plugindialog.h @@ -2,16 +2,31 @@ #define PLUGINDIALOG_H #include +#include +#include "settingclasses.h" class PluginDialog : public QDialog { Q_OBJECT public: PluginDialog(QWidget *parent = nullptr); + QString getSection(); + m64p_handle getCoreHandle(); + m64p_handle getVideoHandle(); + QGridLayout * getCoreLayout(); + QGridLayout * getVideoLayout(); + int * getCoreLayoutRow(); + int * getVideoLayoutRow(); private slots: void handleResetButton(); private: - QString AudioName; + m64p_handle m_coreConfigHandle; + m64p_handle m_videoConfigHandle; + QGridLayout *m_coreLayout; + int m_coreLayoutRow; + QGridLayout *m_videoLayout; + int m_videoLayoutRow; + QString m_section; }; #endif // PLUGINDIALOG_H