use painter event instead of proxystyle for tab style change#5482
use painter event instead of proxystyle for tab style change#5482vadi2 merged 6 commits intoMudlet:developmentfrom
Conversation
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
src/TTabBar.h
Outdated
| #include "post_guard.h" | ||
|
|
||
| class TStyle : public QProxyStyle | ||
| class TStyle |
There was a problem hiding this comment.
warning: class TStyle defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
class TStyle
^There was a problem hiding this comment.
This doesn't derive from QProxyStyle anymore, intended? Should it be a stand-alone C++ class?
There was a problem hiding this comment.
It looks like setting the operators it's talking about to =delete should do the trick: http://linuxkiss.com/qt-question/968.html
There was a problem hiding this comment.
as I looked at it again I realized that the TStyle class is not needed anymore
|
@SlySven could you review this as well please? |
There was a problem hiding this comment.
This might sound strange but have you tested that the bold/italic/underline effects can still be applied to a tab (they happen when multi-playing and new text/data is output to a profile that is not the currently active one - originally this was to help indicate activity in other tabs before I got the multi-view working properly when only one tab reliably showed at a time...)?
FYI The original PR that introduced that (and included the use of a style proxy to do it) was #1589 ...
src/TTabBar.h
Outdated
|
|
||
| void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; | ||
| public: | ||
| TTabBar(QWidget* parent) : QTabBar(parent) {} |
There was a problem hiding this comment.
I agree with CodeFactor on this - we should be (using) explicit here! 😀
src/TTabBar.cpp
Outdated
| for (int i = 0; i < count(); i++) | ||
| { |
There was a problem hiding this comment.
There is a Qt standard refactor that it will offer for this construct which makes sense - to only call count() once - and also the standard recommendation to pre rather than post increment a variable where possible (a half decent compiler will probably do it auto-magically these days!) - and finally, for our coding style, the opening brace should be on the previous line:
| for (int i = 0; i < count(); i++) | |
| { | |
| for (int i = 0, total = count(); i < total; ++i) { |
🤓


Brief overview of PR changes/additions
This uses the painter event instead of the previously used proxystyle to change font styles of single tabs.
Motivation for adding to Mudlet
There were some issues with the new Darktheme.
Tabs weren't dark (especially on windows)
Other info (issues closed, discussion etc)
I got the idea from https://stackoverflow.com/questions/47094871/how-to-custom-qtabwidget-tab
Release post highlight