From adc08cfd1dd143ae73fd34f74f480d0d0d862b16 Mon Sep 17 00:00:00 2001 From: mbudd02 Date: Tue, 30 Mar 2021 08:13:45 -0400 Subject: [PATCH] Added a set defaults button to Qt hot keys window. --- src/drivers/Qt/HotKeyConf.cpp | 60 +++++++++++++++++++---------------- src/drivers/Qt/HotKeyConf.h | 1 + src/drivers/Qt/config.h | 2 +- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/drivers/Qt/HotKeyConf.cpp b/src/drivers/Qt/HotKeyConf.cpp index 2bdb43b5..dac6d66c 100644 --- a/src/drivers/Qt/HotKeyConf.cpp +++ b/src/drivers/Qt/HotKeyConf.cpp @@ -42,7 +42,7 @@ HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent) { QVBoxLayout *mainLayout; QHBoxLayout *hbox; - QPushButton *closeButton; + QPushButton *closeButton, *resetDefaults; QTreeWidgetItem *item; std::string prefix = "SDL.Hotkeys."; @@ -95,11 +95,16 @@ HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent) mainLayout->addWidget(tree); + resetDefaults = new QPushButton( tr("Restore Defaults") ); + resetDefaults->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton)); + connect(resetDefaults, SIGNAL(clicked(void)), this, SLOT(resetDefaultsCB(void))); + closeButton = new QPushButton( tr("Close") ); closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); connect(closeButton, SIGNAL(clicked(void)), this, SLOT(closeWindow(void))); hbox = new QHBoxLayout(); + hbox->addWidget( resetDefaults, 1 ); hbox->addStretch(5); hbox->addWidget( closeButton, 1 ); mainLayout->addLayout( hbox ); @@ -127,6 +132,32 @@ void HotKeyConfDialog_t::closeWindow(void) deleteLater(); } //---------------------------------------------------------------------------- +void HotKeyConfDialog_t::resetDefaultsCB(void) +{ + QTreeWidgetItem *item; + std::string confName; + std::string prefix = "SDL.Hotkeys."; + const char *name, *keySeq; + + for (int i=0; isetOption( confName, keySeq ); + + item = tree->topLevelItem(i); + + if ( item ) + { + item->setText(1, tr(keySeq)); + } + } + setHotKeys(); + +} +//---------------------------------------------------------------------------- void HotKeyConfDialog_t::keyPressEvent(QKeyEvent *event) { //printf("Hotkey Window Key Press: 0x%x \n", event->key() ); @@ -170,36 +201,11 @@ HotKeyConfTree_t::~HotKeyConfTree_t(void) //---------------------------------------------------------------------------- void HotKeyConfTree_t::keyPressEvent(QKeyEvent *event) { - //if ( parent() ) - //{ - // static_cast(parent())->assignHotkey(event); - //} - //if ( event->key() == Qt::Key_Enter ) - //{ - // QTreeWidgetItem *item; - - // item = currentItem(); - - // event->accept(); - // if ( item ) - // { - // HotKeyConfSetDialog_t *win = new HotKeyConfSetDialog_t( indexOfTopLevelItem( item ), item, this ); - - // win->exec(); - // } - //} - //else - //{ - QTreeWidget::keyPressEvent(event); - //} + QTreeWidget::keyPressEvent(event); } //---------------------------------------------------------------------------- void HotKeyConfTree_t::keyReleaseEvent(QKeyEvent *event) { - //if ( parent() ) - //{ - // static_cast(parent())->assignHotkey(event); - //} QTreeWidget::keyReleaseEvent(event); } //---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/HotKeyConf.h b/src/drivers/Qt/HotKeyConf.h index 24a7a3dc..31af6128 100644 --- a/src/drivers/Qt/HotKeyConf.h +++ b/src/drivers/Qt/HotKeyConf.h @@ -77,6 +77,7 @@ private: public slots: void closeWindow(void); private slots: + void resetDefaultsCB(void); void hotKeyActivated(QTreeWidgetItem *item, int column); void hotKeyDoubleClicked(QTreeWidgetItem *item, int column); }; diff --git a/src/drivers/Qt/config.h b/src/drivers/Qt/config.h index 378543f4..74b4e420 100644 --- a/src/drivers/Qt/config.h +++ b/src/drivers/Qt/config.h @@ -51,7 +51,7 @@ enum HOTKEY { HK_FKB_ENABLE, HK_MAX}; -//const char *getHotkeyString( int i ); +int getHotKeyConfig( int i, const char **nameOut, const char **keySeqOut ); #endif