-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Styling through QSS #10702
Allow Styling through QSS #10702
Conversation
fa0a605
to
732a9d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks a bit inconsistent. You've mixed style management "by name" and "by file path", so there may be conflicts (e.g. user can manually set style in config file outside of style directory).
If you want to have styles in a predefined directory, you should store the style name in the settings (this way require some simple "style manager" to be implemented to avoid duplicating the logic of mapping the style name in the file path).
Otherwise you should allow user to specify any arbitrary style file (then you have to change the GUI).
ok i took the "stylemanager" approach, i thought this may help in future |
4789cbf
to
eb19487
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I have no time to review it in detail now, so I make only general remarks.
- To make it easier to review your changes further, please learn the qBittorrent Coding Style (you can find it in the source tree) and apply it to your contributions to the project.
- Although your StyleManager doesn't depend directly on GUI classes/modules it's part of GUI in its essence (it has no essence outside GUI) so you should place it in qBittorrent GUI module.
Why not just let user select the qss file? Having to place qss file under a special directory is unintuitive IMO. BTW, qss works better than I thought! |
I have always been surprised by the attempts of some contributors to implement theme support in some custom way, although I initially pointed them to the built-in support... |
@Chocobo1 I can try that if you insist but i don't like that way |
How about changing the style folder to the install directory, this way it will be easier to find |
We can implement some kind of theme bundles (i.e. set of "stylename.qss" and appropriate "stylename" folder with resource files, probably zipped in single file). |
@glassez this can be done in follow up pr for icons, |
I really think showing style name/bundle name is redundant, user don't care about what name it is and it is just a file name.
Maybe stylemanager could still be useful, we'll see then.
I imagine we could let user select a .zip bundle (only .zip as we have zlib already, otherwise too many dependencies...) and qbt will extract it to ADDED: The "Custom" entry could also be named after the .zip bundle name, but there should be only one custom bundle at most as to cut down maintenance for novice users. @jagannatharjun |
I want a dark theme in the official repository because let's face it many users are lazy to google search and download files that's why bing is still out there. |
Do you pledge to maintain the dark theme for some time? I won't.
I'm not sure what you mean by don't know. |
May be have it in the official repo but mark it as unofficial just like cmake support, I like the style-name way and having multiple qss to choose from. Do you assert your method? @qbt-users opinions? |
Big difference! cmake will work or is suitable on many platforms while a single theme will not.
Multiple qss entry leads to the needs of removing it, you'll then have to introduce an UI element to delete the entries. Users will request it sooner or later.
:) So far, I can only speak for myself (I do not represent this project). And from my limited experiences shared my own opinion about a (feasible) way to realize it, if anyone have better ideas, they are welcome! |
I will do the delete and install button. how about that? |
No problem for me. Also what you are going to do when name collision occurs when importing? |
Ok then it doesn't make much sense if you will not have the dark theme in official repo. I can't maintain the theme myself. I am not a designer. Any designer up for it? |
Well I am sure some one someday will request to have multiple themes. and about the collision we can check in |
Hey, guys, stop, otherwise we'll be stuck with it, as has happened with other theme support implementations.
Just have multiple theme (bundle) files somewhere in filesystem. |
AFAIK, zlib isn't about ZIP, it's just about .gz. Of course, it can be used to compress files inside the ZIP archive... But then you have to implement the ZIP parser manually. In addition, it can only extract a subset of .zip files. Anyway we can just start with .qss only support until it died before it was born. |
|
@jagannatharjun, sorry, but as I stated in |
src/gui/uithememanager.cpp
Outdated
if (Preferences::instance()->useCustomUITheme() | ||
&& !QResource::registerResource(Preferences::instance()->customUIThemePath() | ||
, "/uitheme")) | ||
LogMsg(tr("Failed to load .qbtheme file - %1").arg(Preferences::instance()->customUIThemePath())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would write: "Failed to register .qbtheme file. Path: \"%1\""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would produce more user-friendly Log messages (unless some internals are required to be described there): Failed to load UI theme from file \"%1\"
. There is enough information to understand what we are talking about both for the user and for the developer.
src/gui/uithememanager.cpp
Outdated
qApp->setStyleSheet(qssFile.readAll()); | ||
return; | ||
} | ||
LogMsg(tr("Can't open :/uitheme/stylesheet.qss, error: %1").arg(qssFile.errorString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error: \"%1\"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't see the point in showing the application internals in this message...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe the creator miss spell the file and these are for the creator anyway, more information is always good 😜
any suggestions for another message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe the creator miss spell the file and these are for the creator anyway, more information is always good
Yes. But you still should print file path related to theme source root but not to the internal path used by qBittorrent.
any suggestions for another message
Couldn't apply theme stylesheet. stylesheet.qss couldn't be opened. Reason: %1
. IMO, the message like this is both user-friendly and informative for the theme creator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message should give the user a clear understanding of what is at stake. It should also contain a minimum of information for the developer, sufficient to match the problem with the application code, if necessary.
@Chocobo1 asked me to put the errors in quotes for other message and the previous message also. |
@jagannatharjun |
@Chocobo1, I think we shouldn't wait after this is done and commits are squashed. All sorts of unnoticed little things can be fixed later. In addition, it is assumed that this feature will be expanded further. |
What do you mean? This PR is still evolving or do you suggest merging it as-is? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of better name. XD
I think this PR is done within its scope and the feature can be expanded further without breaking its main interface. So it should be merged now (unless you find some critical flaws at the last moment). |
IMO the current state is very close to being finished judging by our standards, one last thing is squash the commits into the first one and I can approve. |
6702880
to
a24925c
Compare
@jagannatharjun, can you create appropriate wiki page with some info about theme format and creation instructions? You can attach your theme as an example there. |
for icons, I would replace all direct references of |
IMO, current icons layout not so good to support theming in a convenient way. So I would make changes on both sides - how the icons are handled by the app and how the theme will provide them. |
@jagannatharjun |
It was my first big PR to any repo, so thanks to you guys for bearing with me for 2 months XD |
@jagannatharjun, thank you for bringing this matter to an end, despite all the difficulties 👍 |
This feature will be used by so many more people if we bundle a dark mode theme in qBittorrent. #6434 has 293 👍 , the most of any issue (and 4x the number of the next highest issue). @jagannatharjun if you're willing to maintain the dark theme, I think we should bundle it with qBittorrent. |
Personally, I would not consider this possibility until the entire "Theme support" feature is fully implemented and tested. "Dark mode" theme can't be complete (to release it officially) without having the appropriate icons to match it in color. |
Completely agree regarding waiting for matching icons. We can use the wiki in the mean time. Once #10903 is resolved, we should bundle the dark theme with the app (assuming someone can support it). |
I would say "support" as in long-term support otherwise I think it would be wise to have contributors maintaining their own repo/forks. |
I think their stance is the only correct one- bundle a dark mode only if we’re able to support it long term. It would be a disservice to our users to provide a tool that breaks in future versions. |
Where would I put style.qss files so the client sees them? I tried |
@Stanzilla the method is changed in the course of PR (first post updated accordingly), I will try to write documents after #10948 or if 4.2 is released before that. Meanwhile, you can use any style file(*.qbtheme) from here with 4.2 alphas. |
EDIT: Following is my initial proposal, a lot has changed after that will update the docs soon
searches *.qss in {config-folder}/styles, and use those as style-sheet with mainwindow