The test system is Slackware 14.2, which uses Qt 4.8.7.
* WANT_WIN_QT4 is defined, and has the expected meaning. Qt 5 is still
the default.
* The QT_NO_SOUND macro now excludes all headers and declarations
relating to sound; the multimedia package is not needed to build
(on any Qt 4, 5 or 6).
* A new function, nh_qsprintf, replaces QString::asprintf, for Qt
older than 5.5. These versions do not have QString::asprintf.
* DYNAMIC_STATUSLINES is disabled for Qt older than 5.9. These versions
do not have QSplitter::replaceWidget.
This replaces the old pushq/saveq arrays (which were used to save
the keys pressed by the user for repeating a previous command)
with a new command queue. This means there's no hard-coded limit
to the saved keys, and it can repeat extended commands which are
not bound to any key.
Fix '#repeat' for tty; both it and ^A can repeat an extended command.
Fix both for curses; they can repeat an extended command instead of
just repeating the initial '#' to start getting an extended command.
X11 (tested), Qt (tested), and probably Windows GUI (not tested)
behave the same as before: ^A (or #repeat) after an extended command
just repeats the # to run the dialog to get an extended command.
I hope this introduces fewer bugs than it fixes but I don't think I'd
bet on that....
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.
For Qt's extended command selector, gray out the button for "repeat"
because picking it just causes the '#' command that led to that to
be repeated, bringing the extended command selector up again.
It can be chosen by typing "rep" but at each keystroke the grayed
out button is visible so having that behave differently from what
was probably expected should not come as a surprise.
The substantial increase in extended commands has forced the grid of
commands to be expanded, otherwise the bottom of each column ends up
off the bottom of the screen.
The widget supporting the '#' command doesn't include scrollbars.
It really needs to be able to include those when needed but I don't
know how to do that.
Our C() macro conflicts with Qt6 usage, so #undef C has added. Move
that from nearly every qt_*.cpp into qt_pre.h where other similar
fixups are handled.
Mostly the warnings were about QString::sprintf and QFontMetrics::width.
sprintf replacement is asprintf, which annoyingly behaves differently
from sprintf - it seems to append to the string.
Not thoroughly tested, but seems to work.
When Qt's extended command selection dialog is set for all commands
or all normal mode commands, it displays the "#wait" command as
"wait (rest)". Picking by mouse is straightforward; the extra text
on the button has no effect. Picking by typing "#wa" will choose it;
there aren't any other choices matching that so the player never gets
as far as typing 'i'. This change allows the player to type "#rest"
as an alternate way to choose it. "#re" matches some other stuff
and the choice is left pending, adding 's' makes it unique but not
explicitly chosen (so still possible to back up), then adding 't'
chooses it. The core never knows the difference.
Simplify extended command selection under Qt by allowing the
autocomplete subset be one of the choices for its [filter]. That's
the same subset as X11 uses, where #q is unambiguous for #quit
instead of competing with #quaff and #quiver.
Unlike under X11, the player can use [filter] to switch to the full
command set and get access to a few commands which have no useable
key and aren't flagged to autocomplete. (Mostly obscure wizard mode
commands but #exploremode is in that situation.)
In normal and explore modes, the [filter] button just toggles between
two sets of commands (all normal mode commands vs autocomplete normal
mode commands). In wizard mode there are four choices and you might
need to click on [filter] up to three times to step through to the
target one among four sets (all commands, all normal mode commands,
autocomplete commands for both normal and wizard, full subset of just
the wizard mode commands).
Fix the popup versions of qt_yn_function() to handle control
characters by using the same key press event decoding routine
and menus and extended commands. Moves 'keyValue()' to
qt_key.cpp and its declaration to qt_key.h, requring several
files to start using #include "qt_key.h".
'make depend' update to follow.
Change qt_get_ext_cmd() to handle calling the extended command
selection menu again after player clicks on Filter/Layout/Reset
instead of relying on the core to do that. (In order to change
the menu, instead of attempting to reconfigure that on the fly
it returns to caller and then puts up a new menu with different
settings when called back. Initial checkin relied on the core
for the call back; this maintains full control for that within
the Qt interface code.)
For Qt's pick-an-exetended-command dialog, allow a player to
toggle the grid layout from column-oriented to row-oriented
and vice versa and when in wizard mode to cycle the set of
shown (and typable) commands from 'all' to 'normal mode-only'
to 'wizard mode-only' back to 'all'. The most recent values
are saved by Qt along with tile size, font size, and some other
stuff. The extended command dialog has a Reset button to force
them (the two extended command values) back to their defaults.
The dialog layout has a slight change to conserve screen space
as well as three additional control buttons:
Was Now
| [ Cancel ] | [Cancel] [Filter][Layout][Reset ]
|# |# Grid Title
| Grid title | [cmd 1] [cmd R+1] [cmd 2*R+1] ...
| [cmd 1] [cmd R+1] [cmd 2*R+1] ... | [cmd 2] [cmd R+2]
| [cmd 2] [cmd R+2] |...
|... | [cmd R] [cmd 2*R]
| [cmd R] [cmd 2*R]
'#' is the prompt where typed text gets echoed and 'R' is the
number of rows in the grid and varies by the set of commands
from the current filter. Grid dimensions have been adjusted:
'all' is 13x9, 'normal' is 13x7, and 'wizard' is 7x4 or 4x7
depending on layout orientation.
The wizard mode-only filter setting probably isn't very useful
because you can only type--or click on--commands which are
visible. So when set to wizard mode-only, you can't #quit for
instance. (Via extended command; there are still menu choices
for that particular action. And it's trivial to change filter.)
The #version command is a leading substring of the #versionshort
command and for Qt, it couldn't be executed by typing, only via
mouse click or one of the Qt-specific menus. #version<return>
or #version<space> now works for that.
The #versionshort command ought to be renamed to something else.
When responding to '#', the Qt interface puts up a grid of buttons
labelled with the names of commands. Then if the user types
instead of clicking on a button, buttons which can no longer match
are removed rather than grayed out. The remaining ones keep their
same relative positions. Once whole rows or whole columns were
gone, it looked awful. With rows gone, the size of the grid
shrank but the popup stayed the same size, so the one-line prompt
area expanded to fill up the vacated vertical space. That caused
the prompt and partial response to move as they stayed centered in
their growing area. With columns gone, the width of the buttons
in remaining columns expanded and they spread out to take up
vacated horizontal space. Once the candidate commands were all
in one column, the buttons spanned the width of the grid. (That's
mostly my fault due to changing the grid from being row-oriented
[a b c]
[d e ]
to column oriented
[a d]
[b e]
[c ]
which resulted in columns going away a lot faster and possibly down
to one when the old layout always had at least two. But old layout
could drop to one row; the current layout always has at least two.)
Also, accept ^[ as ESC. Typing ESC when partial input is present
kills that input but keeps prompting. Typing ESC when no input
is present (none entered yet or a second of two consecutive ESCs)
cancels the operation.
Allow ^U to kill partial input. If used when no input is present,
nothing happens, similar to backspace. Unlike tty and curses, it's
hardcoded here. That shouldn't be a problem because ESC can be
used as a substitute if ^U isn't what the player normally uses.
Move the nine #undef's common to all qt_*.cpp sources into qt_pre.h.
Make "hack.h" usage consistent; always enclose withing 'extern "C {'
and '}' even though only some of the sources care.
Qt's implementation of '#' puts up a rectangular grid of buttons
containing command names from the alphabetized extcmdlist[]:
| # ? adjust annotate
| apply attributes autopickup call
| cast ...
When 3.6 put all commands into that list, the hardcoded 4 columns
resulted in so many rows that the grid wouldn't fit on the screen
(at least not on my smallish laptop screen). There's no scrollbar
so the commands beyond "takeoff" were inaccessible off the bottom.
Warning messages from within Qt were issued to stderr complaining
about trying to render something off the screen (once each time the
'#' command grid was generated).
It was also including wizard mode commands when not in wizard mode.
Suppress those when they're not applicable, and change the grid to
use 6 columns then and 8 for wizard mode. The appropriate amount
ought to be calculated on the fly but these values work ok with the
current command list. (On my screen; if something smaller is used,
the original problem could come back, just not as severe as before.)
Having an alphabetized list go across rows instead of down columns
feels counter-intuitive so transpose the grid.
| # autopickup ...
| ? call
| adjust cast
| annotate ...
| apply
[Having another button next to <cancel> that lets the user switch
back and forth between the two orientations could be worthwhile.
A full-fledged wc/wc2 option for that doesn't seem warranted.]
The commands can be selected by typing their names as an alternative
to mouse click. The input widget supports <backspace> but lacked
handling for <delete> so add that.
When typing a command by its name, a new grid showing only matching
candidates gets displayed so that you can switch back to mouse input.
It looks pretty bad but does work as intended. I didn't touch that;
however, it looks different now due to the columns-vs-rows change.
The menu after picking "?" looks worse. It assumes a fixed width
font and tries to align things in two columns with spaces, but the
result when using a variable width font is ugly. This makes no
attempt to address that.
In file included from ../win/Qt/qt_bind.cpp:20:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:4:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qglobal.h:1302:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qflags.h:121:41: warning: declaration shadows a
variable in the global namespace [-Wshadow]
Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {}
^
[…]
../include/flag.h:390:29: note: previous declaration is here
extern NEARDATA struct flag flags;
^
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:36:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qcache.h:191:15: warning: declaration shadows a
variable in the global namespace [-Wshadow]
Node *u = n;
^
../include/decl.h:219:23: note: previous declaration is here
E NEARDATA struct you u;
^
[…]
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:45:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qtextlayout.h:47:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qcolor.h:44:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qrgb.h:66:46: warning: declaration shadows a
variable in the global namespace [-Wshadow]
inline Q_DECL_CONSTEXPR QRgb qRgb(int r, int g, int b)// set RGB value
^
../include/decl.h:1208:27: note: previous declaration is here
E struct instance_globals g;
^
[…]
In file included from ../win/Qt/qt_glyph.cpp:21:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:48:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qpalette.h:107:49: warning: declaration shadows a
variable in the global namespace [-Wshadow]
inline void setCurrentColorGroup(ColorGroup cg) { data.current_group = cg; }
^
../include/decl.h:1216:30: note: previous declaration is here
E const struct const_globals cg;
^