Skip to content

Enhance: change exit status indication in room exits dialogue#5308

Closed
SlySven wants to merge 4 commits intoMudlet:developmentfrom
SlySven:Enhance_changeExitStatusIndicationInRoomExitsDialogue
Closed

Enhance: change exit status indication in room exits dialogue#5308
SlySven wants to merge 4 commits intoMudlet:developmentfrom
SlySven:Enhance_changeExitStatusIndicationInRoomExitsDialogue

Conversation

@SlySven
Copy link
Copy Markdown
Member

@SlySven SlySven commented Jul 4, 2021

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 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 QGridLayouts 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 QLineEdits for normal exits:
    • setActionOnExit(QLineEdit*, QAction*)
  • refactored out some translated 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.
  • 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

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:

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>
@SlySven SlySven requested a review from a team as a code owner July 4, 2021 19:26
@SlySven SlySven requested a review from a team July 4, 2021 19:26
@add-deployment-links
Copy link
Copy Markdown

add-deployment-links bot commented Jul 4, 2021

Hey there! Thanks for helping Mudlet improve. 🌟

Test versions

You can directly test the changes here:

No need to install anything - just unzip and run.
Let us know if it works well, and if it doesn't, please give details.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

SlySven added 2 commits July 4, 2021 20:58
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>
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jul 5, 2021

clang-tidy review says "All clean, LGTM! 👍"

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Jul 31, 2021

@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.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Jul 31, 2021

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?

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Aug 14, 2021

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.

@Kebap Kebap assigned SlySven and unassigned vadi2 and Kebap Aug 31, 2021
@Kebap Kebap marked this pull request as draft August 31, 2021 09:05
SlySven added a commit to SlySven/Mudlet that referenced this pull request Oct 9, 2021
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>
SlySven added a commit that referenced this pull request Oct 9, 2021
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>
SlySven added a commit to SlySven/Mudlet that referenced this pull request Oct 11, 2021
…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>
SlySven added a commit that referenced this pull request Oct 13, 2021
…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>
SlySven added a commit to SlySven/Mudlet that referenced this pull request Oct 13, 2021
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>
SlySven added a commit that referenced this pull request Oct 14, 2021
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>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Dec 14, 2021

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:

replaced the "placeholder" text as real text in the QLineEdit for the Special Exits' RoomID with proper "placeholder" text during the period that it is being edited - so that clicking on a supposedly "null" RoomID field does not need the user to delete the placeholder text with the number they want.

to the QLineEdit that is used for the Special Exit "name/command" field.

This has been noted as Issue #5761 .

@SlySven SlySven closed this Dec 14, 2021
@SlySven SlySven deleted the Enhance_changeExitStatusIndicationInRoomExitsDialogue branch April 2, 2022 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants