From b8101647595be63e7d7ddf7f3a13b998fbfc3995 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Wed, 24 Mar 2021 22:21:53 -0400 Subject: [PATCH] Added logic to allow for advanced key sequence options to be shown/hidden on game pad window. --- src/drivers/Qt/GamePadConf.cpp | 53 ++++++++++++++++++++++++++++++++-- src/drivers/Qt/GamePadConf.h | 5 ++++ src/drivers/Qt/input.cpp | 5 ++++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/drivers/Qt/GamePadConf.cpp b/src/drivers/Qt/GamePadConf.cpp index b7613ec9..2e84af19 100644 --- a/src/drivers/Qt/GamePadConf.cpp +++ b/src/drivers/Qt/GamePadConf.cpp @@ -115,7 +115,7 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) bool useScroll = false; int useNativeMenuBar; QMenuBar *menuBar; - QMenu *fileMenu; + QMenu *fileMenu, *extMenu; QAction *act; QTreeWidgetItem *item; @@ -162,6 +162,18 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) fileMenu->addAction(act); + // Extensions + extMenu = menuBar->addMenu(tr("&Extensions")); + + // Extensions -> Show Adv Bindings + act = new QAction(tr("&Show Adv Bindings"), this); + //act->setShortcut(QKeySequence::Close); + act->setStatusTip(tr("Show Adv Bindings")); + act->setCheckable(true); + connect(act, SIGNAL(triggered(bool)), this, SLOT(advBindingViewChanged(bool)) ); + + extMenu->addAction(act); + //----------------------------------------------------------------------- // Menu End //----------------------------------------------------------------------- @@ -377,6 +389,16 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) gpView = new GamePadView_t(this); advOptLayout = new QGroupBox( tr("Advanced Key Bindings") ); + advOptLayout->setMaximumWidth(0); + + advOptWidthAnimation = new QPropertyAnimation( advOptLayout, "maximumWidth"); + advOptWidthAnimation->setDuration(500); + advOptWidthAnimation->setStartValue(0); + advOptWidthAnimation->setEndValue(512); + advOptWidthAnimation->setEasingCurve( QEasingCurve::InOutCirc ); + + connect( advOptWidthAnimation, SIGNAL(valueChanged(const QVariant &)), this, SLOT(advOptWidthChange(const QVariant &))); + connect( advOptWidthAnimation, SIGNAL(finished(void)), this, SLOT(advOptResizeDone(void)) ); mainLayoutV->addLayout(vbox1); mainLayoutV->addWidget(gpView); @@ -418,7 +440,8 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent) keyBindTree->setHeaderItem(item); - keyBindTree->header()->setSectionResizeMode(QHeaderView::ResizeToContents); + keyBindTree->header()->setSectionResizeMode(QHeaderView::Interactive); + keyBindTree->setMinimumWidth( 256 ); hbox1->addWidget(keyBindTree); @@ -571,6 +594,32 @@ void GamePadConfDialog_t::loadMapList(void) } } //---------------------------------------------------- +void GamePadConfDialog_t::advBindingViewChanged(bool state) +{ + if ( state ) + { + advOptWidthAnimation->setStartValue(0); + advOptWidthAnimation->setEndValue(512); + advOptWidthAnimation->start(); + } + else + { + advOptWidthAnimation->setStartValue( advOptLayout->width() ); + advOptWidthAnimation->setEndValue(0); + advOptWidthAnimation->start(); + } +} +//---------------------------------------------------- +void GamePadConfDialog_t::advOptWidthChange(const QVariant &value) +{ + resize( minimumSizeHint() ); +} +//---------------------------------------------------- +void GamePadConfDialog_t::advOptResizeDone(void) +{ + resize( minimumSizeHint() ); +} +//---------------------------------------------------- void GamePadConfDialog_t::refreshKeyBindTree( bool reset ) { int i; diff --git a/src/drivers/Qt/GamePadConf.h b/src/drivers/Qt/GamePadConf.h index 395771a5..a13776e6 100644 --- a/src/drivers/Qt/GamePadConf.h +++ b/src/drivers/Qt/GamePadConf.h @@ -17,6 +17,7 @@ #include #include #include +#include #include "Qt/main.h" #include "Qt/input.h" @@ -138,6 +139,7 @@ protected: QComboBox *profSel; QCheckBox *efs_chkbox; QGroupBox *advOptLayout; + QPropertyAnimation *advOptWidthAnimation; QLabel *guidLbl; QLabel *mapMsg; QLabel *keyName[GAMEPAD_NUM_BUTTONS]; @@ -210,6 +212,9 @@ private slots: void newKeyBindingCallback(void); void editKeyBindingCallback(void); void delKeyBindingCallback(void); + void advBindingViewChanged(bool state); + void advOptResizeDone(void); + void advOptWidthChange(const QVariant &value); }; int openGamePadConfWindow(QWidget *parent); diff --git a/src/drivers/Qt/input.cpp b/src/drivers/Qt/input.cpp index a662cbf3..856d07a4 100644 --- a/src/drivers/Qt/input.cpp +++ b/src/drivers/Qt/input.cpp @@ -1450,6 +1450,11 @@ static void updateGamePadKeyMappings(void) { std::list ::iterator it; + if ( gpKeySeqList.size() == 0 ) + { + return; + } + for (it=gpKeySeqList.begin(); it!=gpKeySeqList.end(); it++) { (*it)->updateStatus();