Skip to content

use painter event instead of proxystyle for tab style change#5482

Merged
vadi2 merged 6 commits intoMudlet:developmentfrom
Edru2:painter-instead-of-proxy-for-tab-style
Oct 8, 2021
Merged

use painter event instead of proxystyle for tab style change#5482
vadi2 merged 6 commits intoMudlet:developmentfrom
Edru2:painter-instead-of-proxy-for-tab-style

Conversation

@Edru2
Copy link
Copy Markdown
Member

@Edru2 Edru2 commented Oct 3, 2021

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

@Edru2 Edru2 requested a review from a team as a code owner October 3, 2021 13:58
@Edru2 Edru2 requested a review from a team October 3, 2021 13:58
@add-deployment-links
Copy link
Copy Markdown

add-deployment-links bot commented Oct 3, 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

src/TTabBar.h Outdated
#include "post_guard.h"

class TStyle : public QProxyStyle
class TStyle
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
      ^

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't derive from QProxyStyle anymore, intended? Should it be a stand-alone C++ class?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like setting the operators it's talking about to =delete should do the trick: http://linuxkiss.com/qt-question/968.html

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

as I looked at it again I realized that the TStyle class is not needed anymore

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

Copy link
Copy Markdown
Contributor

@Kebap Kebap left a comment

Choose a reason for hiding this comment

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

Works as expected and improves the situation indeed, as tab is now shown in dark color like the rest of the theme.
image

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Oct 3, 2021

@SlySven could you review this as well please?

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

Copy link
Copy Markdown
Member

@SlySven SlySven left a comment

Choose a reason for hiding this comment

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

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) {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with CodeFactor on this - we should be (using) explicit here! 😀

src/TTabBar.cpp Outdated
Comment on lines +191 to +192
for (int i = 0; i < count(); i++)
{
Copy link
Copy Markdown
Member

@SlySven SlySven Oct 5, 2021

Choose a reason for hiding this comment

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

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:

Suggested change
for (int i = 0; i < count(); i++)
{
for (int i = 0, total = count(); i < total; ++i) {

🤓

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Oct 8, 2021

It still works:

image

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Oct 8, 2021

@Kebap or @Eraene could you help test that tabs are now dark on windows?

edit: kebap already did, missed the reply.

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.

4 participants