]> granicus.if.org Git - nethack/commitdiff
Qt: add tool tips to to extended command selector
authorPatR <rankin@nethack.org>
Thu, 3 Feb 2022 12:17:30 +0000 (04:17 -0800)
committerPatR <rankin@nethack.org>
Thu, 3 Feb 2022 12:17:30 +0000 (04:17 -0800)
For the grid of extended commands used to pick one after typing "#",
show a command's description if the mouse hovers over its button.
For once something with Qt was actually easy.

doc/fixes3-7-0.txt
win/Qt/qt_xcmd.cpp

index 4479ea456230203fde46601d9e04ba7800633b05..4f218ce5f775301fa54f3d68a7d587bf0c3ba2e5 100644 (file)
@@ -1408,6 +1408,8 @@ Qt: [later] augment extended command selection dialog's Filter to add a
        typically commands with no keystroke or only meta character keystroke;
        that makes Filter useful in normal mode (much shorter list of choices)
 Qt: add '#' as "Extended-commands" to the 'game' dropdown menu
+Qt: add tool tips to the extended command selector's buttons to show command
+       descriptions
 tiles: male and female variations in monsters.txt; tested only with tile2bmp
        conversion utility so far; also supported by tilemap utility to
        generate tile.c
index 1f61512dbae14d0a922bc2cb816f3ab9ee107db2..8755897a6e50f31b23f75a465f48e0d146ad44c5 100644 (file)
@@ -294,6 +294,7 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
             QString btn_lbl = extcmdlist[i].ef_txt;
             if (btn_lbl == "wait")
                 btn_lbl += " (rest)";
+            QString btn_tip = QString::asprintf(" %s ", extcmdlist[i].ef_desc);
             QPushButton *pb = new QPushButton(btn_lbl, grid);
             pb->setMinimumSize(butw, pb->sizeHint().height());
             // force the button to have fixed width or it can move around a
@@ -309,6 +310,8 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
             // come as much of a surprise
             if (btn_lbl == "repeat")
                 pb->setEnabled(false);
+            // show command description if mouse hovers over this button
+            pb->setToolTip(btn_tip); // extcmdlist[i].ef_desc
             /*
              * by column: xcmd_by_row==false, the default
              *  0..R-1 down first column, R..2*R-1 down second column, ...