From 13de6086d23ce4126e6461324b92ad952c085b9d Mon Sep 17 00:00:00 2001 From: Prince Gupta <34717789+jagannatharjun@users.noreply.github.com> Date: Sat, 9 May 2020 13:02:06 +0530 Subject: [PATCH] Updated Create custom themes for qBittorrent (markdown) --- Create-custom-themes-for-qBittorrent.md | 81 ++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/Create-custom-themes-for-qBittorrent.md b/Create-custom-themes-for-qBittorrent.md index b14e8c3..82e8de8 100644 --- a/Create-custom-themes-for-qBittorrent.md +++ b/Create-custom-themes-for-qBittorrent.md @@ -7,15 +7,88 @@ This page contains the necessary information to get started developing custom th These are theme bundles for qBittorrent. They should contain all files required to support theming in qBittorrent and are packed using [Qt's Resource Compiler](https://doc.qt.io/qt-5/rcc.html). qBittorrent accesses files inside `.qbttheme` using [Qt's Resource System](https://doc.qt.io/qt-5/resources.html). -Currently, qBittorrent only searches for a `stylesheet.qss` file inside a `.qbttheme` file. +Currently, qBittorrent only searches for a `stylesheet.qss` and `config.json` inside a `.qbttheme` file but you can also add your own custom resources. # How to create your own theme bundles? You can check out this Python script([here](https://github.com/jagannatharjun/qbt-theme/blob/master/Builds/make-resource.py)) for the easy creation of `.qbttheme` files. -At runtime, qBittorrent loads the `stylesheet.qss` file to support theming. `stylesheet.qss` is a [Qt stylesheet](https://doc.qt.io/qt-5/stylesheet.html), which is basically custom CSS for Qt. +At runtime, qBittorrent loads only `stylesheet.qss` to support theming and `config.json` which currently only manages GUI colors. You can include custom resources with your bundle files to use it with `stylesheet.qss` + +# Managing overall feel of GUI +`stylesheet.qss` is a [Qt stylesheet](https://doc.qt.io/qt-5/stylesheet.html), which is basically custom CSS for Qt. You can read more about Qt stylesheet syntax [here](https://doc.qt.io/Qt-5/stylesheet-syntax.html). A reference is also available [here](https://doc.qt.io/qt-5/stylesheet.html). -qBittorrent uses [QResources::registerResource](https://doc.qt.io/qt-5/qresource.html#registerResource) to use the bundle file, you can imagine it like QBittorrent extracts bundle file in a special path which is `:/uitheme`, so every file should be referenced accordingly f.e let's see we have to change the image QRadiaButtons indicator, so to reference a `light/radio_button.svg` that we had it inside our bundle file, we should reference it something like this + +# Changing QBittorrent specific colors +for changing GUI specific colors for your theme, you have to use config.json +The following are all keys that are currently supported. + +```json +{ + "colors": { + "Palette.Window": "", + "Palette.WindowText": "", + "Palette.Base": "", + "Palette.AlternateBase": "", + "Palette.Text": "", + "Palette.ToolTipBase": "", + "Palette.ToolTipText": "", + "Palette.BrightText": "", + "Palette.Highlight": "", + "Palette.HighlightedText": "", + "Palette.Button": "", + "Palette.ButtonText": "", + "Palette.Link": "", + "Palette.LinkVisited": "", + "Palette.Light": "", + "Palette.Midlight": "", + "Palette.Mid": "", + "Palette.Dark": "", + "Palette.Shadow": "", + "Palette.WindowTextDisabled": "", + "Palette.TextDisabled": "", + "Palette.ToolTipTextDisabled": "", + "Palette.BrightTextDisabled": "", + "Palette.HighlightedTextDisabled": "", + "Palette.ButtonTextDisabled": "", + + "Log.Time": "", + "Log.Normal": "", + "Log.Info": "", + "Log.Warning": "", + "Log.Critical": "", + "Log.BannedPeer": "", + + "TransferList.Downloading": "", + "TransferList.StalledDownloading": "", + "TransferList.DownloadingMetadata": "", + "TransferList.ForcedDownloading": "", + "TransferList.Allocating": "", + "TransferList.Uploading": "", + "TransferList.StalledUploading": "", + "TransferList.ForcedUploading": "", + "TransferList.QueuedDownloading": "", + "TransferList.QueuedUploading": "", + "TransferList.CheckingDownloading": "", + "TransferList.CheckingUploading": "", + "TransferList.CheckingResumeData": "", + "TransferList.PausedDownloading": "", + "TransferList.PausedUploading": "", + "TransferList.Moving": "", + "TransferList.MissingFiles": "", + "TransferList.Error": "" + } +} +``` +Here +1. Palette referes to [QPalette](https://doc.qt.io/qt-5/qpalette.html), and following string(after .) denotes [Color roles](https://doc.qt.io/qt-5/qpalette.html#ColorRole-enum) +2. Log refers to log messages and following string (after .) denotes type of messages +3. Transfer List refers to view containing all of your torrents and following string(after .) denotes torrent state on which based on which row colors would be decided. + +`` value supports normal rgb values(#rrggbb) or svg color names, basically it follows [Qt's named color convention](https://doc.qt.io/qt-5/qcolor.html#setNamedColor) convention + +# Using custom resources with bundles +qBittorrent uses [QResources::registerResource](https://doc.qt.io/qt-5/qresource.html#registerResource) to use the bundle file, you can imagine it like QBittorrent extracts bundle file in a special path which is `:/uitheme`, so every file should be referenced accordingly f.e let's see we have to change the image QRadiaButtons indicator, so to reference a `light/radio_button.svg` inside our bundle file, we should do something like this ``` QRadioButton::indicator:unchecked, QRadioButton::indicator:unchecked:focus @@ -24,6 +97,8 @@ QRadioButton::indicator:unchecked:focus } ``` +reserved files and their structure in bundle files are - `stylesheet.qss` and `config.json` both should occur at the root of your bundle file. + # Examples - To change Transfer List row colors based on the torrent state, one can add the following to their `stylesheet.qss`.