From fae20ad3e20fdbb82338dddc490154e9a53ea1fb Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 28 Aug 2020 17:31:33 -0700 Subject: [PATCH] Qt menu fix Menus have [ok], [cancel], [all], [none], [invert], and [search] buttons across their top but the [all], [none], and [invert] choices didn't redraw the menu after making changes to the pending selections so it seemed as if they weren't doing anything. Subsequently picking [ok] revealed otherwise. [search] is broken (instead of accepting a search string, the letters I type are being used to toggle individual entries as I type). This doesn't attempt to address that. --- doc/fixes37.0 | 4 +++- win/Qt/qt_menu.cpp | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index d4c1b2628..6336374f4 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.290 $ $NHDT-Date: 1598570054 2020/08/27 23:14:14 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.291 $ $NHDT-Date: 1598661087 2020/08/29 00:31:27 $ General Fixes and Modified Features ----------------------------------- @@ -390,6 +390,8 @@ Qt: when hero died, gold on tombstone only included gold in inventory, not Qt: tombstone showed newly constructed date instead of the value set up at time of death; it only shows year but that could be wrong if player stared at or ignored prior --More-- for long enough on 31 December +Qt: menu choices All, None, Invert were setting, unsetting, or toggling menu + entry checkboxes internally but didn't redraw the menu to show that Qt+QSX: fix control key Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's 'O' command to "Game->Run-time options" and entry "Game->Qt settings" diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index 817449ee7..a90cb7d9b 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -215,7 +215,7 @@ int NetHackQtMenuWindow::SelectMenu(int h, MENU_ITEM_P **menu_list) how=h; - ok->setEnabled(how!=PICK_ONE);ok->setDefault(how!=PICK_ONE); + ok->setEnabled(how!=PICK_ONE); ok->setDefault(how!=PICK_ONE); cancel->setEnabled(true); all->setEnabled(how==PICK_ANY); none->setEnabled(how==PICK_ANY); @@ -499,7 +499,8 @@ void NetHackQtMenuWindow::keyPressEvent(QKeyEvent* event) InputCount(key); else { for (int i=0; iitem(i, 0); if (count != NULL) count->setText(""); QCheckBox *cb = dynamic_cast(table->cellWidget(i, 1)); - if (cb != NULL) cb->setChecked(true); + if (cb != NULL) { + cb->setChecked(true); + didcheck = true; + } } + if (didcheck) + table->repaint(); } void NetHackQtMenuWindow::ChooseNone() { if (how != PICK_ANY) return; + bool diduncheck = false; for (int i=0; iitem(i, 0); if (count != NULL) count->setText(""); QCheckBox *cb = dynamic_cast(table->cellWidget(i, 1)); - if (cb != NULL) cb->setChecked(false); + if (cb != NULL) { + cb->setChecked(false); + diduncheck = true; + } } + if (diduncheck) + table->repaint(); } void NetHackQtMenuWindow::Invert() { if (how != PICK_ANY) return; + boolean didtoggle = false; for (int i=0; isetText(""); QCheckBox *cb = dynamic_cast(table->cellWidget(i, 1)); - if (cb != NULL) cb->setChecked(cb->checkState() == Qt::Unchecked); + if (cb != NULL) { + cb->setChecked(cb->checkState() == Qt::Unchecked); + didtoggle = true; + } } + if (didtoggle) + table->repaint(); } void NetHackQtMenuWindow::Search() { @@ -556,6 +575,7 @@ void NetHackQtMenuWindow::Search() NetHackQtStringRequestor requestor(this, "Search for:"); char line[256]; + line[0] = '\0'; /* for EDIT_GETLIN */ if (requestor.Get(line)) { for (int i=0; i(table->cellWidget(i, 1)); if (cb == NULL) return; - cb->setChecked((counting && !countstr.isEmpty()) - || cb->checkState() == Qt::Unchecked); + cb->setChecked((counting && !countstr.isEmpty()) + || cb->checkState() == Qt::Unchecked); QTableWidgetItem *count = table->item(i, 0); if (count != NULL) count->setText(countstr); @@ -579,7 +599,9 @@ void NetHackQtMenuWindow::ToggleSelect(int i) if (how==PICK_ONE) { accept(); - } + } else { + table->repaint(); + } } }