Skip to content
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

Add missing standard icons #206

Merged
merged 2 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ Check out the [complete documentation](https://pyqtdarktheme.readthedocs.io).
- A flat dark and light theme
- Support PySide and PyQt
- Support PyInstaller
- Sync with OS's theme (Mac, Windows, Linux)
- Resolve the style differences between Qt versions
- QPalette of dark and light theme
- Provide dark/light theme QPalette
- Override Qt old standard icons

## Themes

Expand Down
5 changes: 3 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autosectionlabel",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx_design",
"sphinx_copybutton",
]

autosectionlabel_prefix_document = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down
30 changes: 30 additions & 0 deletions docs/source/how_to_use.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,36 @@ Append your own stylesheets
.. image:: ../../examples/customize_style/append_stylesheet.png
:class: dark-light

Use overridden Qt default icons
-------------------------------

If you setup theme with ``qdarktheme.setup_theme``, qdarktheme override ``QStyle.standardIcon()``. So you can easily use some `Google Material Design Icons <https://fonts.google.com/icons>`_. And these icons change color that adjust to theme when theme is changed.

.. tab-set::

.. tab-item:: Source

.. code-block:: Python
save_pixmap = QStyle.StandardPixmap.SP_DialogSaveButton
save_icon = win.style().standardIcon(save_pixmap)
push_button = QPushButton("Save")
push_button.setIcon(save_icon)
.. tab-item:: Full source

.. literalinclude:: ../../examples/icons/use_standard_icons.py

.. tab-item:: Result

.. image:: ../../examples/icons/use_standard_icons.png

.. tab-item:: Gallery

.. image:: ../../images/standard_icons.png


Use QPalette to your Qt Application
-----------------------------------

Expand Down
9 changes: 5 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ PyQtDarkTheme applies a flat dark theme to QtWidgets application(PySide and PyQt

**Features:**

* A flat Dark and Light theme
* Support PySide and PyQt
* Support PyInstaller
* A flat dark/light theme
* Support PySide, PyQt and PyInstaller
* Sync with OS's theme (Mac, Windows, Linux)
* Resolve the style differences between Qt versions
* QPalette of dark and light theme
* Provide dark/light theme QPalette
* :ref:`Override Qt old standard icons <how_to_use:Use overridden Qt default icons>`.

++++

Expand Down
Binary file added examples/icons/use_standard_icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions examples/icons/use_standard_icons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys

from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QStyle

import qdarktheme

app = QApplication(sys.argv)
qdarktheme.setup_theme()

main_win = QMainWindow()
save_pixmap = QStyle.StandardPixmap.SP_DialogSaveButton
save_icon = main_win.style().standardIcon(save_pixmap)

push_button = QPushButton("Save")
push_button.setIcon(save_icon)
main_win.setCentralWidget(push_button)

main_win.show()

app.exec()
Binary file added images/standard_icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion qdarktheme/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def setup_theme(
This function doesn't only set the Qt stylesheet,
it applies the complete style to your Qt application using QPalette etc.
Also if theme is ``auto``, try to listen to changes to the OS's color scheme and switch to a
Also if theme is ``auto``, try to listen to changes to the OS's theme and switch to a
matching theme accordingly.
Args:
Expand Down
5 changes: 5 additions & 0 deletions qdarktheme/_proxy_style.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import json
import platform

from qdarktheme._icon.icon_engine import SvgIconEngine
from qdarktheme._icon.svg import Svg
Expand All @@ -26,6 +27,10 @@ def standardIcon( # noqa: N802
if icon_info is None:
return super().standardIcon(standard_icon, option, widget)

os_list = icon_info.get("os")
if os_list is not None and platform.system() not in os_list:
return super().standardIcon(standard_icon, option, widget)

rotate = icon_info.get("rotate", 0)
svg = Svg(icon_info["id"]).rotate(rotate)
icon_engine = SvgIconEngine(svg)
Expand Down
124 changes: 124 additions & 0 deletions qdarktheme/_resources/_standard_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,100 @@
"SP_ArrowUp": {
"id": "arrow_upward"
},
"SP_BrowserReload": {
"id": "refresh"
},
"SP_BrowserStop": {
"id": "close"
},
"SP_CommandLink": {
"id": "east"
},
"SP_DialogAbortButton": {
"id": "not_interested"
},
"SP_DialogApplyButton": {
"id": "check_circle"
},
"SP_DialogCancelButton": {
"id": "cancel"
},
"SP_DialogCloseButton": {
"id": "close"
},
"SP_DialogDiscardButton": {
"id": "delete"
},
"SP_DialogHelpButton": {
"id": "help"
},
"SP_DialogIgnoreButton": {
"id": "visibility_off"
},
"SP_DialogNoButton": {
"id": "not_interested"
},
"SP_DialogNoToAllButton": {
"id": "close"
},
"SP_DialogOkButton": {
"id": "check"
},
"SP_DialogOpenButton": {
"id": "launch"
},
"SP_DialogResetButton": {
"id": "cleaning_services"
},
"SP_DialogSaveButton": {
"id": "save"
},
"SP_DialogSaveAllButton": {
"id": "save"
},
"SP_DialogYesButton": {
"id": "circle"
},
"SP_DialogYesToAllButton": {
"id": "done_all"
},
"SP_DirHomeIcon": {
"id": "home"
},
"SP_DockWidgetCloseButton": {
"id": "close"
},
"SP_FileDialogBack": {
"id": "arrow_upward",
"rotate": 270
},
"SP_FileDialogContentsView": {
"id": "search"
},
"SP_FileDialogDetailedView": {
"id": "list"
},
"SP_FileDialogEnd": {
"id": "drive_file_move_rtl"
},
"SP_FileDialogInfoView": {
"id": "info"
},
"SP_FileDialogListView": {
"id": "grid_view"
},
"SP_FileDialogNewFolder": {
"id": "create_new_folder"
},
"SP_FileDialogToParent": {
"id": "arrow_upward"
},
"SP_FileDialogStart": {
"id": "drive_file_move"
},
"SP_LineEditClearButton": {
"id": "close"
},
"SP_MediaPlay": {
"id": "play_arrow"
},
Expand Down Expand Up @@ -65,18 +146,61 @@
"SP_MediaVolumeMuted": {
"id": "volume_mute"
},
"SP_MessageBoxQuestion": {
"id": "help",
"os": [
"Darwin",
"Linux"
]
},
"SP_DialogRetryButton": {
"id": "refresh"
},
"SP_TitleBarCloseButton": {
"id": "close"
},
"SP_TabCloseButton": {
"id": "close"
},
"SP_TitleBarContextHelpButton": {
"id": "question_mark"
},
"SP_TitleBarMaxButton": {
"id": "fullscreen"
},
"SP_TitleBarMinButton": {
"id": "minimize"
},
"SP_TitleBarNormalButton": {
"id": "flip_to_front"
},
"SP_ToolBarHorizontalExtensionButton": {
"id": "double_arrow"
},
"SP_TitleBarShadeButton": {
"id": "chevron_right",
"rotate": "270"
},
"SP_TitleBarUnshadeButton": {
"id": "chevron_right",
"rotate": "90"
},
"SP_ToolBarVerticalExtensionButton": {
"id": "double_arrow",
"rotate": 90
},
"SP_TrashIcon": {
"id": "delete",
"os": [
"Windows"
]
},
"SP_VistaShield": {
"id": "security",
"os": [
"Darwin",
"Linux"
]
}
}
"""
2 changes: 1 addition & 1 deletion qdarktheme/_resources/_svg.py

Large diffs are not rendered by default.

26 changes: 22 additions & 4 deletions qdarktheme/_resources/_template_stylesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,39 @@
forward-icon: {{ foreground|color(state="icon")|url(id="arrow_upward", rotate=90) }};
leftarrow-icon: {{ foreground|color(state="icon")|url(id="arrow_upward", rotate=270) }};
rightarrow-icon: {{ foreground|color(state="icon")|url(id="arrow_upward", rotate=90) }};
downarrow-icon: {{ foreground|color(state="icon")|url(id="arrow_upward", rotate=180) }};
uparrow-icon: {{ foreground|color(state="icon")|url(id="arrow_upward") }};
dockwidget-close-icon: {{ foreground|color(state="icon")|url(id="close") }};
lineedit-clear-button-icon: {{ foreground|color(state="icon")|url(id="close") }};
home-icon: {{ foreground|color(state="icon")|url(id="home") }};
trash-icon: {{ foreground|color(state="icon")|url(id="delete") }};
dialog-ok-icon: {{ foreground|color(state="icon")|url(id="check") }};
dialog-cancel-icon: {{ foreground|color(state="icon")|url(id="close") }};
dialog-yes-icon: {{ foreground|color(state="icon")|url(id="check_circle") }};
dialog-no-icon: {{ foreground|color(state="icon")|url(id="cancel") }};
dialog-apply-icon: {{ foreground|color(state="icon")|url(id="check") }};
dialog-yes-icon: {{ foreground|color(state="icon")|url(id="circle") }};
dialog-no-icon: {{ foreground|color(state="icon")|url(id="not_interested") }};
dialog-apply-icon: {{ foreground|color(state="icon")|url(id="check_circle") }};
dialog-reset-icon: {{ foreground|color(state="icon")|url(id="restart_alt") }};
dialog-save-icon: {{ foreground|color(state="icon")|url(id="save") }};
dialog-discard-icon: {{ foreground|color(state="icon")|url(id="delete") }};
dialog-close-icon: {{ foreground|color(state="icon")|url(id="close") }};
dialog-open-icon: {{ foreground|color(state="icon")|url(id="folder_open") }};
dialog-open-icon: {{ foreground|color(state="icon")|url(id="launch") }};
dialog-help-icon: {{ foreground|color(state="icon")|url(id="help") }};
dialog-reset-icon: {{ foreground|color(state="icon")|url(id="cleaning_services") }};
filedialog-parent-directory-icon: {{ foreground|color(state="icon")|url(id="arrow_upward") }};
filedialog-new-directory-icon: {{ foreground|color(state="icon")|url(id="create_new_folder") }};
filedialog-detailedview-icon: {{ foreground|color(state="icon")|url(id="list") }};
filedialog-listview-icon: {{ foreground|color(state="icon")|url(id="grid_view") }};
filedialog-infoview-icon: {{ foreground|color(state="icon")|url(id="info") }};
filedialog-start-icon: {{ foreground|color(state="icon")|url(id="drive_file_move") }};
filedialog-end-icon: {{ foreground|color(state="icon")|url(id="drive_file_move_rtl") }};
filedialog-contentsview-icon: {{ foreground|color(state="icon")|url(id="search") }};
titlebar-close-icon: {{ foreground|color(state="icon")|url(id="close") }};
titlebar-normal-icon: {{ foreground|color(state="icon")|url(id="flip_to_front") }};
titlebar-maximize-icon: {{ foreground|color(state="icon")|url(id="fullscreen") }};
titlebar-minimize-icon: {{ foreground|color(state="icon")|url(id="minimize") }};
titlebar-contexthelp-icon: {{ foreground|color(state="icon")|url(id="question_mark") }};
titlebar-shade-icon: {{ foreground|color(state="icon")|url(id="chevron_right", rotate=270) }};
titlebar-unshade-icon: {{ foreground|color(state="icon")|url(id="chevron_right", rotate=90) }};
}
QCommandLinkButton {
qproperty-icon: {{ primary|color|url(id="east") }};
Expand Down
30 changes: 26 additions & 4 deletions style/base.qss
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,45 @@ QWidget {
forward-icon: {{ foreground|color(state="icon")|url(id="arrow_upward", rotate=90) }};
leftarrow-icon: {{ foreground|color(state="icon")|url(id="arrow_upward", rotate=270) }};
rightarrow-icon: {{ foreground|color(state="icon")|url(id="arrow_upward", rotate=90) }};
downarrow-icon: {{ foreground|color(state="icon")|url(id="arrow_upward", rotate=180) }};
uparrow-icon: {{ foreground|color(state="icon")|url(id="arrow_upward") }};

dockwidget-close-icon: {{ foreground|color(state="icon")|url(id="close") }};

lineedit-clear-button-icon: {{ foreground|color(state="icon")|url(id="close") }};

home-icon: {{ foreground|color(state="icon")|url(id="home") }};
trash-icon: {{ foreground|color(state="icon")|url(id="delete") }};

dialog-ok-icon: {{ foreground|color(state="icon")|url(id="check") }};
dialog-cancel-icon: {{ foreground|color(state="icon")|url(id="close") }};
dialog-yes-icon: {{ foreground|color(state="icon")|url(id="check_circle") }};
dialog-no-icon: {{ foreground|color(state="icon")|url(id="cancel") }};
dialog-apply-icon: {{ foreground|color(state="icon")|url(id="check") }};
dialog-yes-icon: {{ foreground|color(state="icon")|url(id="circle") }};
dialog-no-icon: {{ foreground|color(state="icon")|url(id="not_interested") }};
dialog-apply-icon: {{ foreground|color(state="icon")|url(id="check_circle") }};
dialog-reset-icon: {{ foreground|color(state="icon")|url(id="restart_alt") }};
dialog-save-icon: {{ foreground|color(state="icon")|url(id="save") }};
dialog-discard-icon: {{ foreground|color(state="icon")|url(id="delete") }};
dialog-close-icon: {{ foreground|color(state="icon")|url(id="close") }};
dialog-open-icon: {{ foreground|color(state="icon")|url(id="folder_open") }};
dialog-open-icon: {{ foreground|color(state="icon")|url(id="launch") }};
dialog-help-icon: {{ foreground|color(state="icon")|url(id="help") }};
dialog-reset-icon: {{ foreground|color(state="icon")|url(id="cleaning_services") }};

filedialog-parent-directory-icon: {{ foreground|color(state="icon")|url(id="arrow_upward") }};
filedialog-new-directory-icon: {{ foreground|color(state="icon")|url(id="create_new_folder") }};
filedialog-detailedview-icon: {{ foreground|color(state="icon")|url(id="list") }};
filedialog-listview-icon: {{ foreground|color(state="icon")|url(id="grid_view") }};
filedialog-infoview-icon: {{ foreground|color(state="icon")|url(id="info") }};
filedialog-start-icon: {{ foreground|color(state="icon")|url(id="drive_file_move") }};
filedialog-end-icon: {{ foreground|color(state="icon")|url(id="drive_file_move_rtl") }};
filedialog-contentsview-icon: {{ foreground|color(state="icon")|url(id="search") }};

titlebar-close-icon: {{ foreground|color(state="icon")|url(id="close") }};
titlebar-normal-icon: {{ foreground|color(state="icon")|url(id="flip_to_front") }};
titlebar-maximize-icon: {{ foreground|color(state="icon")|url(id="fullscreen") }};
titlebar-minimize-icon: {{ foreground|color(state="icon")|url(id="minimize") }};
titlebar-contexthelp-icon: {{ foreground|color(state="icon")|url(id="question_mark") }};
titlebar-shade-icon: {{ foreground|color(state="icon")|url(id="chevron_right", rotate=270) }};
titlebar-unshade-icon: {{ foreground|color(state="icon")|url(id="chevron_right", rotate=90) }};
}

QCommandLinkButton {
Expand Down
1 change: 1 addition & 0 deletions style/svg/material/circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions style/svg/material/cleaning_services.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading