diff --git a/assets/advanced-docking-system1.png b/assets/advanced-docking-system1.png new file mode 100644 index 0000000..a9a5f42 Binary files /dev/null and b/assets/advanced-docking-system1.png differ diff --git a/assets/advanced-docking-system2.png b/assets/advanced-docking-system2.png new file mode 100644 index 0000000..4ca9e66 Binary files /dev/null and b/assets/advanced-docking-system2.png differ diff --git a/assets/advanced-docking-system3.png b/assets/advanced-docking-system3.png new file mode 100644 index 0000000..d54e558 Binary files /dev/null and b/assets/advanced-docking-system3.png differ diff --git a/assets/advanced-docking-system4.png b/assets/advanced-docking-system4.png new file mode 100644 index 0000000..2902fc3 Binary files /dev/null and b/assets/advanced-docking-system4.png differ diff --git a/assets/dock_tooltips.png b/assets/dock_tooltips.png new file mode 100644 index 0000000..3291fb2 Binary files /dev/null and b/assets/dock_tooltips.png differ diff --git a/configure.py b/configure.py index 78758ad..3fad49c 100644 --- a/configure.py +++ b/configure.py @@ -65,7 +65,10 @@ def read_template_dir(directory): 'stylesheet': open(f'{directory}/stylesheet.qss.in').read(), 'icons': [], } - icon_data = load_json(f'{directory}/icons.json') + if os.path.exists(f'{directory}/icons.json'): + icon_data = load_json(f'{directory}/icons.json') + else: + icon_data = {} for file in glob.glob(f'{directory}/*.svg.in'): svg = open(file).read() name = os.path.splitext(os.path.splitext(os.path.basename(file))[0])[0] diff --git a/extension/README.md b/extension/README.md index 1daee4c..46a241d 100644 --- a/extension/README.md +++ b/extension/README.md @@ -3,25 +3,152 @@ extensions Extensions enable the creation of stylesheets using the same, customizable themes of the original stylesheet. This both allows refining the generated stylesheet and supporting third-party Qt plugins/widgets. -**TODO(ahuszagh)** +Extensions are optionally added to the generated stylesheets, allowing you to extend existing stylesheets to support third-party plugins and optional features. -- Describe stylesheet.qss.in -- Describe icons.json +Furthermore, this simplifies making local, application-specific changes, without having to deal with merge conflicts when fetching updates. -Document this... - -# Current Extensions +# Pre-Packaged Extensions **Advanced Docking System** -**TODO(ahuszagh)** Add description and image +This extension adds support for the [Advanced Docking System](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System). This comes with styles for the dock manager to create a consistent theme between the main stylesheet and the docking system. + +In order to use this extension, configure with: + +```bash +python configure.py --extensions=advanced-docking-system +``` + +And make sure to [disable](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/blob/master/doc/user-guide.md#disabling-the-internal-style-sheet) the internal stylesheet in the dock manager. + +

Linux

+
+ Advanced Docking System View 1 +
+ +

Linux

+
+ Advanced Docking System View 2 +
+ +

Linux

+
+ Advanced Docking System View 3 +
+ +

Linux

+
+ Advanced Docking System View 4 +
**QDockWidget Tooltips** -Adds tooltips to QDockWidget's float and close buttons. +This extension adds tooltips to QDockWidget's float and close buttons. -**TODO(ahuszagh)** Add image +In order to use this extension, configure with: + +```bash +python configure.py --extensions=dock-tooltips +``` + +

Linux

+
+ Dock Tooltips +
# Creating Extensions -**TODO(ahuszagh)** Document... +Creating extensions extends the existing stylesheet configurations, and adds custom rules to the stylesheet, which can then be configured for all themes. This supports custom icons, rules, and more. + +Each extension is added as a folder in [extension](/extension), with a template stylesheet file named `stylesheet.qss.in`. Additional icons can be added as SVG template files (with the extension `svg.in`), and icon styling rules in `icons.json`. + +**Simple Example** + +For example, to add tooltips to a `QDockWidget`, create a `stylesheet.qss.in` in the directory `extension/tooltips` with the following contents: + +```css +QAbstractButton#qt_dockwidget_closebutton +{ + qproperty-toolTip: "Close"; +} + +QAbstractButton#qt_dockwidget_floatbutton +{ + qproperty-toolTip: "Detach"; +} +``` + +To build the stylesheet with the extension, run: + +```bash +python configure.py --extensions=tooltips +``` + +**Icons Example** + +For a more complex example, let's consider a third-party extension of a `QPushButton` with the object name `customButton`, which has a configurable icon. First, create a directory named `extension/custom-button`. + +Next, let's create an SVG template for the icon, at `icon.svg.in`: + +```svg + + + + + + +``` + +Here, `^0^` signifies index-based replacement, so we must define an entry in +`icons.json` to specify how we should do the replacement. + +```json +{ + "icon": { + "default": ["foreground"], + "hover": ["highlight"] + } +} +``` + +Index-based replacement allows us to create more than 1 icon from a single template, with different colors. Here, this would create `icon.svg` with the theme's foreground color, and `icon_hover.svg` with the theme's highlight color. + +Next, we want to add the rules to use these icons in the stylesheet: + +```css +QPushButton#customButton +{ + qproperty-icon: url(:/dark/icon.svg); +} + +QPushButton#customButton:hover +{ + qproperty-icon: url(:/dark/icon_hover.svg); +} +``` + +To build the stylesheet with the extension, run: + +```bash +python configure.py --extensions=custom-button +``` diff --git a/extension/dock-tooltips/icons.json b/extension/dock-tooltips/icons.json deleted file mode 100644 index 6328bbb..0000000 --- a/extension/dock-tooltips/icons.json +++ /dev/null @@ -1,3 +0,0 @@ -// NOTE: This is a custom JSON file, where lines leading -// with `//` are removed. No other comments are valid. -{}