Skip to content

Commit b1251c5

Browse files
authored
Add missing standard icons (#206)
* Add missing standard icons * Update docs
1 parent ac84432 commit b1251c5

34 files changed

+400
-19
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ Check out the [complete documentation](https://pyqtdarktheme.readthedocs.io).
2121
- A flat dark and light theme
2222
- Support PySide and PyQt
2323
- Support PyInstaller
24+
- Sync with OS's theme (Mac, Windows, Linux)
2425
- Resolve the style differences between Qt versions
25-
- QPalette of dark and light theme
26+
- Provide dark/light theme QPalette
27+
- Override Qt old standard icons
2628

2729
## Themes
2830

docs/source/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@
3636
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3737
# ones.
3838
extensions = [
39+
"sphinx.ext.autosectionlabel",
3940
"sphinx.ext.viewcode",
4041
"sphinx.ext.napoleon",
4142
"sphinx.ext.todo",
4243
"sphinx_design",
4344
"sphinx_copybutton",
4445
]
4546

47+
autosectionlabel_prefix_document = True
48+
4649
# Add any paths that contain templates here, relative to this directory.
4750
templates_path = ["_build", "Thumbs.db", ".DS_Store"]
48-
49-
5051
# -- Options for HTML output -------------------------------------------------
5152

5253
# The theme to use for HTML and HTML Help pages. See the documentation for

docs/source/how_to_use.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,36 @@ Append your own stylesheets
162162
.. image:: ../../examples/customize_style/append_stylesheet.png
163163
:class: dark-light
164164

165+
Use overridden Qt default icons
166+
-------------------------------
167+
168+
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.
169+
170+
.. tab-set::
171+
172+
.. tab-item:: Source
173+
174+
.. code-block:: Python
175+
176+
save_pixmap = QStyle.StandardPixmap.SP_DialogSaveButton
177+
save_icon = win.style().standardIcon(save_pixmap)
178+
179+
push_button = QPushButton("Save")
180+
push_button.setIcon(save_icon)
181+
182+
.. tab-item:: Full source
183+
184+
.. literalinclude:: ../../examples/icons/use_standard_icons.py
185+
186+
.. tab-item:: Result
187+
188+
.. image:: ../../examples/icons/use_standard_icons.png
189+
190+
.. tab-item:: Gallery
191+
192+
.. image:: ../../images/standard_icons.png
193+
194+
165195
Use QPalette to your Qt Application
166196
-----------------------------------
167197

docs/source/index.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ PyQtDarkTheme applies a flat dark theme to QtWidgets application(PySide and PyQt
1818

1919
**Features:**
2020

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

2728
++++
2829

92.3 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sys
2+
3+
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QStyle
4+
5+
import qdarktheme
6+
7+
app = QApplication(sys.argv)
8+
qdarktheme.setup_theme()
9+
10+
main_win = QMainWindow()
11+
save_pixmap = QStyle.StandardPixmap.SP_DialogSaveButton
12+
save_icon = main_win.style().standardIcon(save_pixmap)
13+
14+
push_button = QPushButton("Save")
15+
push_button.setIcon(save_icon)
16+
main_win.setCentralWidget(push_button)
17+
18+
main_win.show()
19+
20+
app.exec()

images/standard_icons.png

336 KB
Loading

qdarktheme/_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def setup_theme(
9595
9696
This function doesn't only set the Qt stylesheet,
9797
it applies the complete style to your Qt application using QPalette etc.
98-
Also if theme is ``auto``, try to listen to changes to the OS's color scheme and switch to a
98+
Also if theme is ``auto``, try to listen to changes to the OS's theme and switch to a
9999
matching theme accordingly.
100100
101101
Args:

qdarktheme/_proxy_style.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import json
4+
import platform
45

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

30+
os_list = icon_info.get("os")
31+
if os_list is not None and platform.system() not in os_list:
32+
return super().standardIcon(standard_icon, option, widget)
33+
2934
rotate = icon_info.get("rotate", 0)
3035
svg = Svg(icon_info["id"]).rotate(rotate)
3136
icon_engine = SvgIconEngine(svg)

qdarktheme/_resources/_standard_icons.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,100 @@
2525
"SP_ArrowUp": {
2626
"id": "arrow_upward"
2727
},
28+
"SP_BrowserReload": {
29+
"id": "refresh"
30+
},
31+
"SP_BrowserStop": {
32+
"id": "close"
33+
},
2834
"SP_CommandLink": {
2935
"id": "east"
3036
},
37+
"SP_DialogAbortButton": {
38+
"id": "not_interested"
39+
},
40+
"SP_DialogApplyButton": {
41+
"id": "check_circle"
42+
},
43+
"SP_DialogCancelButton": {
44+
"id": "cancel"
45+
},
46+
"SP_DialogCloseButton": {
47+
"id": "close"
48+
},
3149
"SP_DialogDiscardButton": {
3250
"id": "delete"
3351
},
52+
"SP_DialogHelpButton": {
53+
"id": "help"
54+
},
55+
"SP_DialogIgnoreButton": {
56+
"id": "visibility_off"
57+
},
58+
"SP_DialogNoButton": {
59+
"id": "not_interested"
60+
},
61+
"SP_DialogNoToAllButton": {
62+
"id": "close"
63+
},
64+
"SP_DialogOkButton": {
65+
"id": "check"
66+
},
67+
"SP_DialogOpenButton": {
68+
"id": "launch"
69+
},
70+
"SP_DialogResetButton": {
71+
"id": "cleaning_services"
72+
},
73+
"SP_DialogSaveButton": {
74+
"id": "save"
75+
},
76+
"SP_DialogSaveAllButton": {
77+
"id": "save"
78+
},
79+
"SP_DialogYesButton": {
80+
"id": "circle"
81+
},
82+
"SP_DialogYesToAllButton": {
83+
"id": "done_all"
84+
},
85+
"SP_DirHomeIcon": {
86+
"id": "home"
87+
},
88+
"SP_DockWidgetCloseButton": {
89+
"id": "close"
90+
},
3491
"SP_FileDialogBack": {
3592
"id": "arrow_upward",
3693
"rotate": 270
3794
},
95+
"SP_FileDialogContentsView": {
96+
"id": "search"
97+
},
98+
"SP_FileDialogDetailedView": {
99+
"id": "list"
100+
},
101+
"SP_FileDialogEnd": {
102+
"id": "drive_file_move_rtl"
103+
},
104+
"SP_FileDialogInfoView": {
105+
"id": "info"
106+
},
107+
"SP_FileDialogListView": {
108+
"id": "grid_view"
109+
},
110+
"SP_FileDialogNewFolder": {
111+
"id": "create_new_folder"
112+
},
38113
"SP_FileDialogToParent": {
39114
"id": "arrow_upward"
40115
},
116+
"SP_FileDialogStart": {
117+
"id": "drive_file_move"
118+
},
119+
"SP_LineEditClearButton": {
120+
"id": "close"
121+
},
41122
"SP_MediaPlay": {
42123
"id": "play_arrow"
43124
},
@@ -65,18 +146,61 @@
65146
"SP_MediaVolumeMuted": {
66147
"id": "volume_mute"
67148
},
149+
"SP_MessageBoxQuestion": {
150+
"id": "help",
151+
"os": [
152+
"Darwin",
153+
"Linux"
154+
]
155+
},
156+
"SP_DialogRetryButton": {
157+
"id": "refresh"
158+
},
68159
"SP_TitleBarCloseButton": {
69160
"id": "close"
70161
},
162+
"SP_TabCloseButton": {
163+
"id": "close"
164+
},
165+
"SP_TitleBarContextHelpButton": {
166+
"id": "question_mark"
167+
},
168+
"SP_TitleBarMaxButton": {
169+
"id": "fullscreen"
170+
},
171+
"SP_TitleBarMinButton": {
172+
"id": "minimize"
173+
},
71174
"SP_TitleBarNormalButton": {
72175
"id": "flip_to_front"
73176
},
74177
"SP_ToolBarHorizontalExtensionButton": {
75178
"id": "double_arrow"
76179
},
180+
"SP_TitleBarShadeButton": {
181+
"id": "chevron_right",
182+
"rotate": "270"
183+
},
184+
"SP_TitleBarUnshadeButton": {
185+
"id": "chevron_right",
186+
"rotate": "90"
187+
},
77188
"SP_ToolBarVerticalExtensionButton": {
78189
"id": "double_arrow",
79190
"rotate": 90
191+
},
192+
"SP_TrashIcon": {
193+
"id": "delete",
194+
"os": [
195+
"Windows"
196+
]
197+
},
198+
"SP_VistaShield": {
199+
"id": "security",
200+
"os": [
201+
"Darwin",
202+
"Linux"
203+
]
80204
}
81205
}
82206
"""

0 commit comments

Comments
 (0)