Enhance: change exit status indication in room exits dialogue#5308
Enhance: change exit status indication in room exits dialogue#5308SlySven wants to merge 4 commits intoMudlet:developmentfrom
Conversation
It has been pointed out that using colours to indicate whether an exit room id number is valid or not in the room exits dialogue is not always helpful when the end-user wants to apply styling to Mudlet - or for those with some visual impairments. This commit is intended to improve the situation by instead applying an icon to indicate the exit status with one of three icons indicating an invalid exit room id number, a valid number in the same area or a valid number in another area. This is shown as an icon in the `QLineEdit` on the right side (after the number) for *normal* exits and as an icon in a separate column to the right of the field used to enter and display the exit room id for *special* exits. This replaces the previous code that only showed valid or invalid numbers with blue or red text respectively. As these changes needed some reorganisation of the individual columns used for the special exits in the room exit dialogue I converted all the column numbers into constants that are defined at the top of the `dlgRoomExit.cpp` file - this means it is more easy to readjust them in the future if that should prove necessary (and reduces the chance of missing out or mixing up those index numbers in the event of further editing...!) During development I discovered how to use custom *item delegates*, e.g. like described in: https://doc.qt.io/qt-5/model-view-programming.html#a-simple-delegate for both: * the special exit weight - during editing the `QLineEdit` that was used for special exit weights is replaced with a `QSpinBox` that acts in the same manner as those for the normal exits. * the special exit room ID - during editing a replacement `QLineEdit` is used which gains an icon in the same manner as the ones used for the normal exits. Outside of that editing a separate column holds the same icon except that it also considers the status of the exit command/script so as to show an "invalid" exit if there isn't one. Tooltips for both the exit room ID and status columns are also updated during and after editing of the exit room ID. Also: * refactored the initialisation process for the room exits dialogue so that it is no longer necessary to explicitly call an `init(...)` method after instantiating the dialogue - that is now done from the constructor itself - which takes the additional argument (the room that the exits are to be displayed for) that was originally needed from that method. * reordered the items in the `QGridLayout`s in the `room_exits.ui` form XML file so that they are back in ascending order again. * refactored out some highly repetitive (one for each normal exit direction) code to some separate methods that take pointers to all the individual widgets involved in that exit: * `normalExitEdited(...)` * `normalStubExitChanged(...)` * similarly for special exits: * `setIconAndToolTipsOnSpecialExit(QTreeWidgetItem*)` * also for the tooltips for normal exits - which now also include the area involved for exits that go to other areas: * `generateToolTip(...)` * and to put an icon (as an `QAction` with no action) into the `QLineEdit`s for normal exits: * `setActionOnExit(QLineEdit*, QAction*)` * refactored out some translated `QString`s that are used programmatically for special exits - so that they are only specified in one place - thereby making the code more robust so that each usage can be revised by only editing one string instead of six or seven instances in one case. * added in a slot method connected to the special exits' `QTreeWidget::itemChanged` signal so that it updates better during editing of special exits (after moving to or from the exit room id or command fields to others within the same special exit instead of only when moving to a *different* special exit completely). Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
The tool-tips for the normal exit room IDs in the room exits dialogue were being made by dropping a translated exit direction into a longer sentence. This is not considered good practice and, indeed as it was, it didn't even work so well for the non XY-plane normal exits in English: it resulted in texts like: "Set the number of the room up of this one." Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
|
@SlySven you slipped into a mega PR again... it doesn't look like anyone has the energy to review all of these changes in bulk. |
|
It got significantly bigger when I learned about custom item delegates. How about just doing a black-box review of it. I.e. don't worry about what is inside but instead do a side-by-side comparison with the current code? |
|
Could you update this PR now that all the other bits have been pruned out? Thanks for doing that work by the way, it made a big difference in helping to review and approve them. Let's stick to the small, scoped PRs like that. |
This removes the need for the code that uses the `dlgRoomExits` class from having to also call that class's `init()` method - the room ID for which the dialogue is being used is now to be provided in the constructor rather than in the now made private method. As a side-effect it become obvious that there is no need to provide the room ID as an argument to the `dlgRoomExit::initExit(...)` method as the value is already available in the class's member `(int) mRoomID`! This PR is a part that has been extracted from the draft (and to be replaced) PR Mudlet#5308 - that is to be broken up into smaller, easier to digest, chunks! 8-) Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This removes the need for the code that uses the `dlgRoomExits` class from having to also call that class's `init()` method - the room ID for which the dialogue is being used is now to be provided in the constructor rather than in the now made private method. As a side-effect it become obvious that there is no need to provide the room ID as an argument to the `dlgRoomExit::initExit(...)` method as the value is already available in the class's member `(int) mRoomID`! This PR is a part that has been extracted from the draft (and to be replaced) PR #5308 - that is to be broken up into smaller, easier to digest, chunks! 8-) Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
…olumns This will make changing/adding the columns easier as part of what was created as the draft (and to be replaced) PR Mudlet#5308 - that is to be broken up into smaller, easier to digest, chunks! 8-) Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
…xits (#5505) This will make changing/adding the columns easier as part of what was created as the draft (and to be replaced) PR #5308 - that is to be broken up into smaller, easier to digest, chunks! 8-) There is a single set of constants which are defined in the `exitstreewidget` class but used also by the `dlgRoomExit` one by virtue of making it a friend of the former. As it happens I spotted the need for both classes to have these constants when I reviewed `(void) ExitsTreeWidget::keyPressEvent(QKeyEvent*)` and spotted that I had not revised it to close the correct persistent editors in the merge commit 83db9f9 (part of PR #439) seven years ago! This will make changing/adding the columns easier as part of what was Revised slightly (converted an empty switch "default:" case from a `;` to a `{}`) to placate the CodeFactor god/daemon...! Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This reorders the elements of two (nested as it happens) `QGridLayout`s so that their elements are in ascending row then column order. It also converts another one that only contains a single element to a `QVBoxLayout`. This is so that a change to be made by another PR that will also be extracted from the draft PR Mudlet#5308 is easier to review. This PR should not produce any functional changes. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This reorders the elements of two (nested as it happens) `QGridLayout`s so that their elements are in ascending row then column order. It also converts another one that only contains a single element to a `QVBoxLayout`. This is so that a change to be made by another PR that will also be extracted from the draft PR #5308 is easier to review. This PR should not produce any functional changes. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
The original effects of this PR have now been performed by a series of other smaller PRs so this is no longer needed to be kept as a reminder. One further enhancement would be to apply the technique that:
to the This has been noted as Issue #5761 . |
NOT TO BE MERGED
See bottom of this mesage
It has been pointed out that using colours to indicate whether an exit room id number is valid or not in the room exits dialogue is not always helpful when the end-user wants to apply styling to Mudlet - or for those with some visual impairments. This commit is intended to improve the situation by instead applying an icon to indicate the exit status with one of three icons indicating an invalid exit room id number, a valid number in the same area or a valid number in another area. This is shown as an icon in the
QLineEditon the right side (after the number) for normal exits and as an icon in a separate column to the right of the field used to enter and display the exit room id for special exits. This replaces the previous code that only showed valid or invalid numbers with blue or red text respectively.As these changes needed some reorganisation of the individual columns used for the special exits in the room exit dialogue I converted all the column numbers into constants that are defined at the top of the
dlgRoomExit.cppfile - this means it is more easy to readjust them in the future if that should prove necessary (and reduces the chance of missing out or mixing up those index numbers in the event of further editing...!)During development I discovered how to use custom item delegates, e.g. like described in:
https://doc.qt.io/qt-5/model-view-programming.html#a-simple-delegate
for both:
QLineEditthat was used for special exit weights is replaced with aQSpinBoxthat acts in the same manner as those for the normal exits.QLineEditis used which gains an icon in the same manner as the ones used for the normal exits. Outside of that editing a separate column holds the same icon except that it also considers the status of the exit command/script so as to show an "invalid" exit if there isn't one. Tooltips for both the exit room ID and status columns are also updated during and after editing of the exit room ID.Also:
init(...)method after instantiating the dialogue - that is now done from the constructor itself - which takes the additional argument (the room that the exits are to be displayed for) that was originally needed from that method.QGridLayouts in theroom_exits.uiform XML file so that they are back in ascending order again.normalExitEdited(...)normalStubExitChanged(...)setIconAndToolTipsOnSpecialExit(QTreeWidgetItem*)generateToolTip(...)QActionwith no action) into theQLineEdits for normal exits:setActionOnExit(QLineEdit*, QAction*)QStrings that are used programmatically for special exits - so that they are only specified in one place - thereby making the code more robust so that each usage can be revised by only editing one string instead of six or seven instances in one case.QTreeWidget::itemChangedsignal so that it updates better during editing of special exits (after moving to or from the exit room id or command fields to others within the same special exit instead of only when moving to a different special exit completely).Signed-off-by: Stephen Lyons slysven@virginmedia.com
Release post highlight
Room exits dialogue enhanced to use icons instead of colours to indicate the status of the value entered. This is extended into the special exits part as well which also now uses spin-box widgets to allow the exit weight to be set by mouse clicks as well as the previous typing in of a numeric value.
This PR is to be broken up into smaller chunks to make it easier to resolve, so far they are:
0to7) used to identify particular columns in the special exitsQListWidgetin the dialogue used for room exit manipulation in the 2D Mapper toconst ints so that reading the code and reordering them can be done consistently and correctly (avoiding weirdness if one or more usages are missed when revising them),Improve: use constants to index into special exit columns in dlgRoomExits #5505
dlgRoomExits::init(....),Improve: simplify dlgRoomExits() invocation #5498
QLineEdits used for normal room exit IDs to show icons instead of having coloured text to indicate validity of exit,Improve: icons not coloured status text for normal exits in exits dialog #5513
./src/us/room_exits.uiXML form/dialogue design file so thatQGridLayoutcomponents contain items in {a|an} (predictable and an) ordered way,Improve: cleanup room_exits.ui file #5512
QListWidget) to show icons instead of having coloured text to indicate validity of exit,Improve: icons not coloured status text for special exits in exits dialog #5543
QListWidget) to show a spin box instead of being a pure text entry widget,Improve: add a QSpinWidget for adjusting special exit weight in exit dialogue #5758