]> granicus.if.org Git - nethack/commitdiff
Qt menu tweak
authorPatR <rankin@nethack.org>
Mon, 10 Aug 2020 23:39:30 +0000 (16:39 -0700)
committerPatR <rankin@nethack.org>
Mon, 10 Aug 2020 23:39:30 +0000 (16:39 -0700)
An earlier tweak worked to prevent unnecessary line wrapping
for ^X output in a menu, but #enhance and '+' both had problems
with their last column.  This seems to work better but is still
based on thrashing about rather than knowledge of how things are
supposed to operate.

win/Qt/qt_menu.cpp

index aad4d5885f5840fec4a8cb7d8e02f13f83da0f0b..53b09d6ff3a5e6a7c849250b3de7d8d4e3c75d2c 100644 (file)
@@ -242,6 +242,7 @@ int NetHackQtMenuWindow::SelectMenu(int h, MENU_ITEM_P **menu_list)
        AddRow(i, itemlist[i]);
     }
 
+#define MENU_WIDTH_SLOP 10 /* this should not be necessary */
     // Determine column widths
     std::vector<int> col_widths;
     for (std::size_t i = 0; i < (size_t) itemlist.size(); ++i) {
@@ -255,8 +256,7 @@ int NetHackQtMenuWindow::SelectMenu(int h, MENU_ITEM_P **menu_list)
             QTableWidgetItem *twi = table->item(i, 4);
             if (twi) {
                 QString text = twi->text();
-#define MENU_WIDTH_SLOP 20 /* this should not be necessary */
-                WidenColumn(4, fm.width(text) + MENU_WIDTH_SLOP);
+                WidenColumn(4, fm.width(text));
             }
             continue;
         }
@@ -285,7 +285,7 @@ int NetHackQtMenuWindow::SelectMenu(int h, MENU_ITEM_P **menu_list)
        }
        text = columns.join("");
        twi->setText(text);
-       WidenColumn(4, fm.width(text));
+       WidenColumn(4, fm.width(text) + MENU_WIDTH_SLOP);
     }
 
     // FIXME:  size for compact mode