Skip to content

Enhance: indicate other profile with new data when multi-playing#1589

Merged
SlySven merged 11 commits intoMudlet:developmentfrom
SlySven:Enhance_highlightTabOnNewData
Apr 7, 2018
Merged

Enhance: indicate other profile with new data when multi-playing#1589
SlySven merged 11 commits intoMudlet:developmentfrom
SlySven:Enhance_highlightTabOnNewData

Conversation

@SlySven
Copy link
Copy Markdown
Member

@SlySven SlySven commented Mar 28, 2018

Following a discussion on Discord on the Help channel I realised that if more than one profile is open and Multi-View mode is not selected then any profile which is not the currently selected one will be hidden from view - and if any data comes in from the MUD server it will not be obvious to the user.

This commit turns the text on the tab of the "other" profile red when new data arrives - which is reset back to the standard colour when the user switches to that profile to see the new stuff.

Signed-off-by: Stephen Lyons slysven@virginmedia.com

If more than one profile is open and multiView mode is not selected then
any profile which is not the currently selected one will be hidden from
view - and if any data comes in from the MUD server it will not be obvious.

This commit turns the text on the tab of the "other" profile red when new
data arrives - which is reset when the user switches to that profile to see
what has come in.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven SlySven requested a review from a team March 28, 2018 20:04
@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Mar 29, 2018

This looks great, but red is hard to see. How about making it bold instead?

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 29, 2018

Unfortunately there isn't an obvious control for that (I'm using QTabBar::setTabTextColor(int index, QColor color)) - OTOH: whether it is something that can be hacked around with via style-sheets is another matter (with the QTabBar::tab selector but it is not obvious how to index into the particular tab and whether it would require specify all the styling attributes for the whole QTabBar instance - which could be nasty depending on whether it is possible to get what the current system applied style is)...

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 29, 2018

Of course a modified marker - a * appended temporarily to the tab name - is another possibility, but since the text is used programmatically it would have to be disregarded where it is used!

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Mar 29, 2018

I think we can make it bold! I prefer that over an asterisk. If we give the tabs object names, we could address them in css:

ID Selector QPushButton#okButton Matches all QPushButton instances whose object name is okButton.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 30, 2018

🤕 I can't get style sheets to work on tab widgets using the #tab-text selection mechanism as in trying to used QTabBar::setStylesheet(...) with something like:

QTabBar::tab#profile2Name { background-color: red } QTabBar::tab#profile1Name { background-color: green }

I can style the tabs with other QSS(?) selection mechanisms, e.g. :selected / :!selected / :hover but the only way to pick out particular tabs is the #TabText one and I cannot get it to work. Given that the text that gets shown is automatically made into a short-cut if it contains a & I think it would be informative to see how the tabs are identified when run under gammaray - but I do not currently have a build of that to hand.

Sadly there is another problem with using StyleSheets on Tab-bars in Qt 5.9.2 - 10.0 beta1 (at least) - see QTBUG-63696: {macOS} Regression: setting stylesheet on QTabWidget::pane hides the close graphic on tab - which says that the close button (that we use!) on the tabs disappears on macOs platforms when a style-sheet is applied...!

Oh, we cannot give the tabs object names, they are not exposed in a suitable manner from the QTabBar container...

This attempts to detect some local initiated things that change the
contents as well as incoming data from the Mud Server, in the former case
a blue-which info icon is added to the tab for the affected, "other"
non-active profile, which also turns the title text blue to match.  For
data coming in from the Mud Server an orange warning triangle is placed
there together with the red text.  This has priority over the local case.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 30, 2018

The above commit might help - it adds an icon as well as changing the colour and it does so for some local actions that change the contents of the main console as well as for when text comes in from the Mud Server. The latter does have priority though...

I have made the tab text a little larger - so the tabs are a little bigger which is okay I think as it stops the icons from being too small!

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 31, 2018

I've research it further (even build a small test case application) and I am pretty much convinced that it is not possible to apply styling to specific tabs based on their index or text. 👎

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 1, 2018 via email

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 1, 2018

That won't work - having read Dynamic Properties and Stylesheets and looking at the 5.10.0 source code I can see that the individual tabs are not Q_OBJECTs and thus can not have dynamic properties added to them. 🙁

However that code has suggested checking trying QMovableTabWidget as an identifier in the style sheet QString...

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 2, 2018

... nope, that doesn't work.

I just tried to inspect a QTabBar with dumbObjectTree() and that confirmed that the only sub-objects it contains is the two QToolButtons used to scroll the tabs if they overflow the width available to them - no trace of the tabs themselves.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 3, 2018

I had a look at the latest - still not a fan. Trying out various things myself too.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 3, 2018

Given the current state of things I'd be tempted to drop the colour and rely solely on icons...

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 4, 2018

This solution seems to work: http://lists.qt-project.org/pipermail/interest/2018-April/029734.html

Could you adapt it?

Some code was suggested and modified to sub-class the QTabBar class into
one (TTabBar) with the ability to set individual tabs to have bold text on
a per tab (selected by text OR index). This also required the derivation of
a TStyle from QProxyStyle to perform the actual drawing of tabs so
modified.

I have removed the previous use of icons and changed the red on data from
the MUD server to magenta.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 5, 2018

Yes - but it took me a while to get my head around it as it targeted QTabWidget whereas we need/use QTabBar. Anyhow it is now in and I have taken the icons out. I've changed the use of red to magenta for those profiles that have received text from the MUD servers (but retained blue for the lower priority of text that has been generated by a local source - I don't know if I have caught all cases of the latter, I probably haven't) - but both cases use the bold effect now....

SF is becoming increasingly unreliable as a host for source code and this
project has moved to Github some time ago but we had not spotted this.

There are later versions that the 2012 0.13.62 version that we are
currently using but that is an exercise for a new PR instead of a hot-fix
repair to the system for this one.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven SlySven requested a review from a team April 5, 2018 15:26
Might help with build failures (and it might not).

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

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

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

The bolding seems to work well... could TTabBar be in a separate class file though - separation of concerns, mudlet.cpp should not worry about custom widgets?

The colour doesn't really look that good, I'd prefer it to be just a normal bolding

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 5, 2018

I would like to differentiate between the two cases though (local and remote) and cover the corner case where all the tabs are bolded by an application or user's system wide style settings - do you have an alternative (am I going to have to include provisions to underline or italicize as well)? I mean blue works well for me but red is not so, um, hot - so I thought magenta seemed a reasonable choice as it seems more urgent than blue (do you want a user choice?)

@keneanung
Copy link
Copy Markdown
Member

I think that's overengineering. Let's keep it simple for the first pass and if people request that feature, we can still add it in.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 5, 2018

Ah @keneanung - just the person I ought to drag into this - do you have any advice on (and do you still have those steel-lined rubber gauntlets 😉 to work with) the current AppVeyor troubles? I have located the newer home for zziplib on Github (which downloads much more reliably) but although the source tarball for the 0.13.62 version is almost the same as the SF one (some extra ancillaries to do with MSVC and a symbian port) that I have changed to herein it is not building and even updating to the current version 0.13.68 is failing in the same manner with a:

Error executing command: mingw32-make
At C:\projects\mudlet\CI\appveyor.install.ps1:50 char:5
+     throw $errorMessage
+     ~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : OperationStopped: (Error executing command: mingw32-make:String) [], RuntimeException
   + FullyQualifiedErrorId : Error executing command: mingw32-make

Command exited with code 1

Help!

SlySven added 2 commits April 6, 2018 00:38
I have revised the new code to support italic and underline effects as well
as bold.  I have wired up changes originating locally to cause the title on
the non-active tabs to become italicised and removed all colour changes. In
both cases the tabs are also underlined which helps to draw attention to
tabs showing either change.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
I forgot to include the new TTabBar .cpp and .h in the project files for
CMake - so the CI builds using it broke.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
To see if more verbose messages help to explain what is going wrong.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 6, 2018

I agree with #1589 (comment)

Tweaks to try and get AppVeyor to work have been reverted (even if they
may be wanted to be done in the future).

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 6, 2018

So, apart from the AppVeyor support changes that haven't worked (and which I have just reverted) is there anything wrong with this now? Actually - once the changes have been pushed out to a new class the changes in the existing code looks quite clean to me now - I guess I start to see the advantages to encapsulation/inheritance/what-have-you in C++ with dropping in a TTabBar where there was a QTabBar and which appears to just add some extra public methods in, i.e. setTab{Bold|Italic|Underline(const {QString&|int}, const bool) and tab{Bold|Italic|Underline(const {QString&|int}) compared to the existing ones like setTabText(int, const QString&), setTabTextColor(int, const QColor&), tabText(int) and tabTextColor(int) ...! 🤓

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 6, 2018

Yes - #1589 (comment) please 😃

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 7, 2018

vadi2 I'm not sure I understand - are you saying that it is not suitable as it is now because you think it is still too complicated? 😕

I think it is okay - there may be methods that are not currently used (some of the state getters) but together there is a complete set of getters and setters for three separate but related font effects (bold, italic and underline) that are based on tab index (how the underlying Qt methods do other aspects of individual tab configuration) and on tab text (i.e. context - which is more reliable when the texts are not changeable - which matches our current usage - but the tabs may be reordered by the user - which I got the idea was the case or was requested - ah, it is still the subject of recent issue #1456).

Oh, as a side effect of increasing the tab text font size from 6 to 8, I think this PR will also address another recent issue and closes #1542 ! Edited so that GitHub will spot the linkage and auto-close the linked to issue when this is merged!

It may be that not all local things that change the contents of the main console for a non-active profile are yet detected but that is one thing I am happy to fix later as things show up (it would likely just need an emit signal_newDataAlert(profile name, false); at a point where it is missing - which I suppose could be something that you want/are happy to defer to another PR - and in that I would agree.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 7, 2018

About using colours and differentiating local vs server changes - me & keneanung gravitate towards just bold, no colouring, and no differentiation.

We can add the differentiation later on if people are keen but I don't think it's a feature that'll really be appreciated and adding colours is problematic for aesthetic reasons.

This actually makes the TConsole code a tiny bit more complex as it has
to filter whether to emit a SIGNAL depending on where the input to
TConsole::printOnDisplay(...) comes from!

I was also able to simplify the mudlet::slot_newDataOnHost(...) method
because I had forgotten to use the methods to change the tab text
formatting that identifies the tab by its text as an argument rather than
an index number. (The same for(...) loop construct is used but it is hidden
in the new TTabBar class...)

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Apr 7, 2018

👍 will test

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Apr 7, 2018

I had already taken out the colouration!

I must confess bolding the tab text does not catch my eye so much as it might for some - but I have removed the underline (which did work for me).

Ah - I may have miss-interpreted the removal of differentiation of the source of the change - so try this commit instead....

Copy link
Copy Markdown
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

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

Exactly! Thanks!

@SlySven SlySven merged commit 247fe11 into Mudlet:development Apr 7, 2018
@SlySven SlySven deleted the Enhance_highlightTabOnNewData branch April 7, 2018 16:18
@SlySven SlySven restored the Enhance_highlightTabOnNewData branch June 22, 2020 18:05
@SlySven SlySven deleted the Enhance_highlightTabOnNewData branch June 22, 2020 18:22
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