ishovkun / SierraBreeze

OSX-like window decoration for KDE Plasma written in C++
355 stars 40 forks source link

I implemented an option to paint the title bar with the window color #40

Open Petross404 opened 6 years ago

Petross404 commented 6 years ago

I like very much when my decoration seems to "fit" visually with my window's colors. So I took the liberty to create an option where the user can choose to keep the default style or to match the colors.

It looks like this :

Alt text

and this :

Alt text

It's a click away to revert

Alt text

Ofcourse the konsole is respected (nice work btw with that!)

Alt text

I will open a PR for this. Your c&c are more than welcome.

Petross404 commented 6 years ago

Ok, one thing I noticed. It doesn't respect the color of the window if the user changes it inside the application - e.g. Krita has this functionality. It's titlebar color stays the same though.

Any ideas how to force a repaint event?

Petross404 commented 6 years ago

Ok, I made painter and repaintRegion private members of the class. This code snippet inside Decoration::init

connect(c, static_cast<void (KDecoration2::DecoratedClient::*)(const QPalette&)>(&KDecoration2::DecoratedClient::paletteChanged), this,
                [this]
        {
            this->paintTitleBar(&painter, repaintRegion);
        });

helped but for KDevelop, Krita still refuses to cooperate.

trmdi commented 6 years ago

The question is: what is wrong with changing the titlebar color from the KDE Color setting? It's much more customizable than this, users can choose any color they want.

Do you think this is necessary @ishovkun ?

System Setting > Color, it's the right place to change the color. Adding some code to SierraBreeze mean it will have to do an extra job, that is unnecessary.

Petross404 commented 6 years ago

@trmdi One can always deselect the matching checkbox and everything can run like before. I don't see the problem or the supposed overhead.

Some other users already liked that Sierrabeeeze takes care this for them with 50 more lines of code.

It's all about choice.

Petross404 commented 6 years ago

@ishovkun I am thinking if with kf5::plasma I can read the background colors of non qt applications as well. Also instead of qpallete signal I will try with void colorsChanged() signal to update the color of the title bar if a change occurs from within the application. For more look here https://api.kde.org/frameworks/plasma-framework/html/classColorScope.html

daruuro commented 5 years ago

Sorry to thread steal, but I can't seem to get SierraBreeze to match even Konsole's colors for the title bar. Any help? Also doesn't match for any darker themed application (IDEA).

screenshot_20181227_035224 screenshot_20181227_035258

Petross404 commented 5 years ago

Unchecking the box changes something? Is there any chance that there is a rule in systemsettings for some applications?

ghost commented 5 years ago

@Petross404 This error occurs to me as well. I just installed manjaro KDE and sierrabreeze, nothing else changed. I only get it working using this workaround.

Petross404 commented 5 years ago

@yaabdalla IDEA is a java IDE? This patch works only with Qt applications. Other than that, konsole title bar should work as it's shown in my post.

call0fcode commented 5 years ago

Hi @Petross404,

in my case the terminal looks pretty awesome with SierraBreeze as windows decoration:

imagen

It has rounded corners everywhere and the title bar adopts the color of the window's content.

It only happens with the terminal. For other apps is not the case (although I have checked the option "Match Title Bar's and Window's color" on the SierraBreeze options menu):

imagen

You can see that the title bar is not adjusting its color to the same as the window has as it occurs with the terminal window. It also has a black border on the bottom which obviously has the same color as the title bar. This is not desirable, but I don't wanted to set the borders to "no borders" cause if I do it so, the rounded bottom borders disappear and they give a nice "touch" to the whole.

By using Kvantum (A Linux SVG-based theme engine for Qt4/Qt5 and KDE), the Kvantum theme KvGlass and its windows decoration theme Aurorae Glass-Kv (modified by my with OSX buttons) the look&feel is as I would expect from the SierraBreeze's option mentioned above ("Match Title Bar's and Window's color"):

imagen

The problem with the windows decoration theme I modified is, that it has a fixed "blurred" color which in fact is the same blurred color set by Kvantum's theme (that's why it looks the same applied to Dolphin, both window and titlebar have the same background color). Here a clear example of inconsistency caused of non-adapting Aurorae themes, terminal's background differs from titlebar's one in this case. They are close to each other but not exactly the same:

imagen

It would be perfect if SierraBreeze could achieve the same results as the mentioned "Kvantum-mix" does.

Why is SierraBreeze adapting the titlebar's color (and thus bottom borders accordingly) on the first terminal screenshot but not working on other cases? Could anyone help me here or tell me if there is something that we can modify on SierraBreeze's code in order to get these results?

Thanks in advance =)

Petross404 commented 5 years ago

Is this using kvantum or breeze? Correct me if I am wrong but SierraBreeze (and this option) works with the breeze theme.

The titlebar get's it's color from the window's background color. As you can see in the code, the titlebar doesn't know anything about the window's opacity or blur.

There is a project on github called BreezeBlurred which can provide blurred titlebars with breeze theme, but AFAIK it doesn't help you by matching titlebar's color. Sure you can append a color per application basis but that's what I wanted to avoid and I implemented this option. Maybe Alex can help with this if you choose to go for his solution.

There is a chance that I missed something, so let me know if I haven't actually answered you. Have a nice day.

call0fcode commented 5 years ago

Hi! Thanks for you response.

In both the 1st and 2nd screenshots of my post I'm using Kvantum as theme (as widget style) and SierraBreeze.

My doubt was rather, how is it possible, that in the first screenshot the title bar has adopted the color of the terminal but not in the second one with Dolphin? Which are the criteria of matching a window's color? What does exactly mean "palette().color" that you reference me in the code and which color is taken as window's reference color?

Thanks a lot and I hope not to annoy you ;)

Petross404 commented 5 years ago

No, you don't annoy me. It's just that I may disappoint a user because I am not the best programmer. Anyway, I will try to help you.

Below auto c represents the window. After that, I construct the titlebar's color based on c's QPalette::Window which is a way to read the (Qt) window's color in computerish.

        const auto c = client().data();
        const QColor matchedTitleBarColor(c->palette().color(QPalette::Window));

So, there is that.

Which are the criteria of matching a window's color?

As long as it's a Qt app.

how is it possible, that in the first screenshot the title bar has adopted the color of the terminal but not in the second one with Dolphin?

I guess it's because here SierraBreeze reads the konsole config file, in order to find the correct colors to paint the titlebar. What confuses me is that it doesn't seem to do something about blurring. I don't know what to advise you. Maybe ask help from the original author and I will happily participate to help you with his guidance.