Debian Codegraph @

qtawesome/styles.py

raw symbols SCIP
1 """
2 QT MODERN
3
4 MIT License
5
6 Copyright (c) 2017 Gerard Marull-Paretas <[email protected]>
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in all
16 copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25 """
26
27 from qtpy.QtGui import QPalette, QColor
28
29 # Constant to reference default themes
30 DEFAULT_DARK_PALETTE = "Dark"
31 DEFAULT_LIGHT_PALETTE = "Light"
32
33
34 def dark(app):
35 """
36 Apply dark theme to the Qt application instance.
37
38 Args:
39 app (QApplication): QApplication instance.
40 """
41
42 dark_palette = QPalette()
43
44 # base
45 dark_palette.setColor(QPalette.WindowText, QColor(180, 180, 180))
46 dark_palette.setColor(QPalette.Button, QColor(53, 53, 53))
47 dark_palette.setColor(QPalette.Light, QColor(180, 180, 180))
48 dark_palette.setColor(QPalette.Midlight, QColor(90, 90, 90))
49 dark_palette.setColor(QPalette.Dark, QColor(35, 35, 35))
50 dark_palette.setColor(QPalette.Text, QColor(180, 180, 180))
51 dark_palette.setColor(QPalette.BrightText, QColor(180, 180, 180))
52 dark_palette.setColor(QPalette.ButtonText, QColor(180, 180, 180))
53 dark_palette.setColor(QPalette.Base, QColor(42, 42, 42))
54 dark_palette.setColor(QPalette.Window, QColor(53, 53, 53))
55 dark_palette.setColor(QPalette.Shadow, QColor(20, 20, 20))
56 dark_palette.setColor(QPalette.Highlight, QColor(42, 130, 218))
57 dark_palette.setColor(QPalette.HighlightedText, QColor(180, 180, 180))
58 dark_palette.setColor(QPalette.Link, QColor(56, 252, 196))
59 dark_palette.setColor(QPalette.AlternateBase, QColor(66, 66, 66))
60 dark_palette.setColor(QPalette.ToolTipBase, QColor(53, 53, 53))
61 dark_palette.setColor(QPalette.ToolTipText, QColor(180, 180, 180))
62 dark_palette.setColor(QPalette.LinkVisited, QColor(80, 80, 80))
63
64 # disabled
65 dark_palette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(127, 127, 127))
66 dark_palette.setColor(QPalette.Disabled, QPalette.Text, QColor(127, 127, 127))
67 dark_palette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(127, 127, 127))
68 dark_palette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(80, 80, 80))
69 dark_palette.setColor(
70 QPalette.Disabled, QPalette.HighlightedText, QColor(127, 127, 127)
71 )
72
73 app.style().unpolish(app)
74 app.setPalette(dark_palette)
75
76 app.setStyle("Fusion")
77
78
79 def light(app):
80 """
81 Apply light theme to the Qt application instance.
82
83 Args:
84 app (QApplication): QApplication instance.
85 """
86
87 light_palette = QPalette()
88
89 # base
90 light_palette.setColor(QPalette.WindowText, QColor(0, 0, 0))
91 light_palette.setColor(QPalette.Button, QColor(240, 240, 240))
92 light_palette.setColor(QPalette.Light, QColor(180, 180, 180))
93 light_palette.setColor(QPalette.Midlight, QColor(200, 200, 200))
94 light_palette.setColor(QPalette.Dark, QColor(225, 225, 225))
95 light_palette.setColor(QPalette.Text, QColor(0, 0, 0))
96 light_palette.setColor(QPalette.BrightText, QColor(0, 0, 0))
97 light_palette.setColor(QPalette.ButtonText, QColor(0, 0, 0))
98 light_palette.setColor(QPalette.Base, QColor(237, 237, 237))
99 light_palette.setColor(QPalette.Window, QColor(240, 240, 240))
100 light_palette.setColor(QPalette.Shadow, QColor(20, 20, 20))
101 light_palette.setColor(QPalette.Highlight, QColor(76, 163, 224))
102 light_palette.setColor(QPalette.HighlightedText, QColor(0, 0, 0))
103 light_palette.setColor(QPalette.Link, QColor(0, 162, 232))
104 light_palette.setColor(QPalette.AlternateBase, QColor(225, 225, 225))
105 light_palette.setColor(QPalette.ToolTipBase, QColor(240, 240, 240))
106 light_palette.setColor(QPalette.ToolTipText, QColor(0, 0, 0))
107 light_palette.setColor(QPalette.LinkVisited, QColor(222, 222, 222))
108
109 # disabled
110 light_palette.setColor(
111 QPalette.Disabled, QPalette.WindowText, QColor(115, 115, 115)
112 )
113 light_palette.setColor(QPalette.Disabled, QPalette.Text, QColor(115, 115, 115))
114 light_palette.setColor(
115 QPalette.Disabled, QPalette.ButtonText, QColor(115, 115, 115)
116 )
117 light_palette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(190, 190, 190))
118 light_palette.setColor(
119 QPalette.Disabled, QPalette.HighlightedText, QColor(115, 115, 115)
120 )
121
122 app.style().unpolish(app)
123 app.setPalette(light_palette)
124
125 app.setStyle("Fusion")