Skip to content

Commit

Permalink
docs: add developer guide
Browse files Browse the repository at this point in the history
- style guide

Signed-off-by: Andrei Popa <[email protected]>
  • Loading branch information
andrei47w committed Jan 29, 2025
1 parent 047adf3 commit 9e19cf6
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 37 deletions.
21 changes: 21 additions & 0 deletions docs/developer_guide/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. _developer_guide:

Scopy overview for developers
================================================================================

About
---------------------------------------------------------------------
Tutorials, coding guidelines and guides for developers.

.. note::

These guides are for Scopy v2.0.0 and future versions.
Follow the user guide for building Scopy an your local machine. Linux is recommended for development

Source code
---------------------------------------------------------------------

The source code for the entire application can be found on `github
<https://github.com/analogdevicesinc/scopy>`_


61 changes: 61 additions & 0 deletions docs/developer_guide/style.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.. _style:

Style Tutorial
==============

**Style previewer tool is located in the test plugin**

Create New Style Property
-------------------------

Before creating a new style, check if you can use an already existing one or combine multiple existing styles. Only create a new one if necessary.

Navigate to ``style/qss/properties`` and pick/create a folder that matches the widget type you want to create a property for. Inside the folder, create a ``.qss`` file.

- All style code must be surrounded by ``{}`` and have a set property ``*[&&property&&=true]{ }``. Do not replace the property name; keep it as ``&&property&&``.
- The property value can be changed from ``true``, but when using it in the application, you also need to specify the correct value.
- Use keys from the JSON files as much as possible. Example: ``&unit_1&``.

Run CMake, and the new property should appear in ``style_properties.h`` with the same name as the ``.qss`` file.

Add JSON Value
--------------

JSON files should rarely be altered in any way.

- **Global value:** Add a new key and value in ``style/json/global.json``.
- **Theme value:** Add a new key and value in ``style/json/dark.json`` and all other theme JSON files accordingly.

Run CMake, and you should find the new value in ``style_attributes.h``.

Add Theme
---------

Add a new ``.json`` file in ``style/json``.

- Add at least all the values from ``dark.json``.
- Other values from ``global.json`` can be overwritten in the new theme. Example:
"unit_1": "20" (where "unit_1":"16" is in global.json)

- Properties can also be overwritten. Example:
"qss_properties_button_borderButton": "qss_properties_button_basicButton"

Add Plugin Style
----------------

Create a ``style`` folder in your plugin and use the exact same file structure. Only the ``qss`` folder is relevant since the JSON files cannot be overwritten from other plugins. You may add a folder in your ``style/qss/properties`` folder with the name of your plugin to avoid overwriting other core ``.qss`` style files with the same name.

In your plugin ``CMakeLists.txt`` file, add the ``generate_style`` command.

**Arguments:** ``option, style_folder, header_folder`` (option should always be ``--plugin``).

Example:

.. code-block:: cmake
include(ScopyStyle)
generate_style("--plugin" ${CMAKE_CURRENT_SOURCE_DIR}/style ${CMAKE_CURRENT_SOURCE_DIR}/include/pluginName)
Run CMake, and you should see the new properties in ``header_folder/style_properties.h``.


3 changes: 3 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ Contents
user_guide/preferences
user_guide/bugReport
user_guide/troubleshooting


developer_guide/style
37 changes: 0 additions & 37 deletions gui/style/README.md

This file was deleted.

0 comments on commit 9e19cf6

Please sign in to comment.