Use better icons for the examples and tests.
parent
db1019ddd8
commit
047d5cc984
|
@ -115,7 +115,7 @@ if args.pyqt6:
|
||||||
ReadOnly = QtCore.QFile.OpenModeFlag.ReadOnly
|
ReadOnly = QtCore.QFile.OpenModeFlag.ReadOnly
|
||||||
Text = QtCore.QFile.OpenModeFlag.Text
|
Text = QtCore.QFile.OpenModeFlag.Text
|
||||||
East = QtWidgets.QTabWidget.TabPosition.East
|
East = QtWidgets.QTabWidget.TabPosition.East
|
||||||
SP_DialogResetButton = QtWidgets.QStyle.StandardPixmap.SP_DialogResetButton
|
SP_DockWidgetCloseButton = QtWidgets.QStyle.StandardPixmap.SP_DockWidgetCloseButton
|
||||||
else:
|
else:
|
||||||
QAction = QtWidgets.QAction
|
QAction = QtWidgets.QAction
|
||||||
Horizontal = QtCore.Qt.Horizontal
|
Horizontal = QtCore.Qt.Horizontal
|
||||||
|
@ -137,7 +137,7 @@ else:
|
||||||
ReadOnly = QtCore.QFile.ReadOnly
|
ReadOnly = QtCore.QFile.ReadOnly
|
||||||
Text = QtCore.QFile.Text
|
Text = QtCore.QFile.Text
|
||||||
East = QtWidgets.QTabWidget.East
|
East = QtWidgets.QTabWidget.East
|
||||||
SP_DialogResetButton = QtWidgets.QStyle.SP_DialogResetButton
|
SP_DockWidgetCloseButton = QtWidgets.QStyle.SP_DockWidgetCloseButton
|
||||||
|
|
||||||
# Need to fix an issue on Wayland on Linux:
|
# Need to fix an issue on Wayland on Linux:
|
||||||
# conda-forge does not support Wayland, for who knows what reason.
|
# conda-forge does not support Wayland, for who knows what reason.
|
||||||
|
@ -147,6 +147,14 @@ if sys.platform.lower().startswith('linux') and 'CONDA_PREFIX' in os.environ:
|
||||||
if args.use_x11:
|
if args.use_x11:
|
||||||
os.environ['XDG_SESSION_TYPE'] = 'x11'
|
os.environ['XDG_SESSION_TYPE'] = 'x11'
|
||||||
|
|
||||||
|
def close_icon(widget):
|
||||||
|
'''Get the close icon depending on the stylesheet.'''
|
||||||
|
|
||||||
|
if args.stylesheet == 'native':
|
||||||
|
return widget.style().standardIcon(SP_DockWidgetCloseButton)
|
||||||
|
return QtGui.QIcon(f'{resource_format}close.svg')
|
||||||
|
|
||||||
|
|
||||||
class Ui:
|
class Ui:
|
||||||
'''Main class for the user interface.'''
|
'''Main class for the user interface.'''
|
||||||
|
|
||||||
|
@ -366,8 +374,7 @@ class Ui:
|
||||||
self.horizontalLayout.addWidget(self.bt_menu_button_popup)
|
self.horizontalLayout.addWidget(self.bt_menu_button_popup)
|
||||||
self.bt_auto_raise = QtWidgets.QToolButton(self.centralwidget)
|
self.bt_auto_raise = QtWidgets.QToolButton(self.centralwidget)
|
||||||
self.bt_auto_raise.setAutoRaise(True)
|
self.bt_auto_raise.setAutoRaise(True)
|
||||||
auto_raise_icon = self.bt_auto_raise.style().standardIcon(SP_DialogResetButton)
|
self.bt_auto_raise.setIcon(close_icon(self.bt_auto_raise))
|
||||||
self.bt_auto_raise.setIcon(auto_raise_icon)
|
|
||||||
self.bt_auto_raise.setObjectName('bt_auto_raise')
|
self.bt_auto_raise.setObjectName('bt_auto_raise')
|
||||||
self.horizontalLayout.addWidget(self.bt_auto_raise)
|
self.horizontalLayout.addWidget(self.bt_auto_raise)
|
||||||
self.line_2 = QtWidgets.QFrame(self.centralwidget)
|
self.line_2 = QtWidgets.QFrame(self.centralwidget)
|
||||||
|
|
21
test/ui.py
21
test/ui.py
|
@ -471,6 +471,13 @@ def execute(obj):
|
||||||
else:
|
else:
|
||||||
return obj.exec_()
|
return obj.exec_()
|
||||||
|
|
||||||
|
def close_icon(widget):
|
||||||
|
'''Get the close icon depending on the stylesheet.'''
|
||||||
|
|
||||||
|
if args.stylesheet == 'native':
|
||||||
|
return widget.style().standardIcon(SP_DockWidgetCloseButton)
|
||||||
|
return QtGui.QIcon(f'{resource_format}close.svg')
|
||||||
|
|
||||||
def test_progressbar_horizontal(widget, *_):
|
def test_progressbar_horizontal(widget, *_):
|
||||||
child = []
|
child = []
|
||||||
bar1 = QtWidgets.QProgressBar(widget)
|
bar1 = QtWidgets.QProgressBar(widget)
|
||||||
|
@ -561,7 +568,7 @@ def test_menu(widget, window, font, width, *_):
|
||||||
action3 = QAction('&Action 6', window)
|
action3 = QAction('&Action 6', window)
|
||||||
action3.setCheckable(True)
|
action3.setCheckable(True)
|
||||||
menu.addAction(action3)
|
menu.addAction(action3)
|
||||||
icon = menu.style().standardIcon(SP_DockWidgetCloseButton)
|
icon = close_icon(menu)
|
||||||
menu.addAction(QAction(icon, '&Action 7', window))
|
menu.addAction(QAction(icon, '&Action 7', window))
|
||||||
menu.addAction(QAction(icon, '&Action 8', window))
|
menu.addAction(QAction(icon, '&Action 8', window))
|
||||||
submenu.addAction(QAction(icon, '&Action 9', window))
|
submenu.addAction(QAction(icon, '&Action 9', window))
|
||||||
|
@ -723,7 +730,7 @@ def test_list(widget, *_):
|
||||||
item = QtWidgets.QListWidgetItem(f'Item {index + 1}')
|
item = QtWidgets.QListWidgetItem(f'Item {index + 1}')
|
||||||
item.setTextAlignment(random.choice(alignments))
|
item.setTextAlignment(random.choice(alignments))
|
||||||
child.addItem(item)
|
child.addItem(item)
|
||||||
icon = menu.style().standardIcon(SP_DockWidgetCloseButton)
|
icon = close_icon(child)
|
||||||
for index in range(10):
|
for index in range(10):
|
||||||
item = QtWidgets.QListWidgetItem(icon, f'Item {index + 1}')
|
item = QtWidgets.QListWidgetItem(icon, f'Item {index + 1}')
|
||||||
item.setTextAlignment(random.choice(alignments))
|
item.setTextAlignment(random.choice(alignments))
|
||||||
|
@ -757,7 +764,7 @@ def test_toolbar(_, window, *__):
|
||||||
toolbar1.addSeparator()
|
toolbar1.addSeparator()
|
||||||
toolbar1.addAction('&Action 3')
|
toolbar1.addAction('&Action 3')
|
||||||
toolbar1.addAction('&Action 3 Really Long Name')
|
toolbar1.addAction('&Action 3 Really Long Name')
|
||||||
icon = menu.style().standardIcon(SP_DockWidgetCloseButton)
|
icon = close_icon(toolbar1)
|
||||||
toolbar1.addAction(icon, '&Action 4')
|
toolbar1.addAction(icon, '&Action 4')
|
||||||
window.addToolBar(TopToolBarArea, toolbar1)
|
window.addToolBar(TopToolBarArea, toolbar1)
|
||||||
|
|
||||||
|
@ -768,7 +775,7 @@ def test_toolbar(_, window, *__):
|
||||||
toolbar2.addSeparator()
|
toolbar2.addSeparator()
|
||||||
toolbar2.addAction('&Action 3')
|
toolbar2.addAction('&Action 3')
|
||||||
toolbar2.addAction('&Action 3 Really Long Name')
|
toolbar2.addAction('&Action 3 Really Long Name')
|
||||||
icon = menu.style().standardIcon(SP_DockWidgetCloseButton)
|
icon = close_icon(toolbar2)
|
||||||
toolbar2.addAction(icon, '&Action 4')
|
toolbar2.addAction(icon, '&Action 4')
|
||||||
window.addToolBar(LeftToolBarArea, toolbar2)
|
window.addToolBar(LeftToolBarArea, toolbar2)
|
||||||
|
|
||||||
|
@ -816,7 +823,7 @@ def test_toolbutton(widget, window, *_):
|
||||||
child[5].setArrowType(RightArrow)
|
child[5].setArrowType(RightArrow)
|
||||||
child[6].setArrowType(UpArrow)
|
child[6].setArrowType(UpArrow)
|
||||||
child[7].setArrowType(DownArrow)
|
child[7].setArrowType(DownArrow)
|
||||||
icon = menu.style().standardIcon(SP_DockWidgetCloseButton)
|
icon = close_icon(widget)
|
||||||
child[8].setIcon(icon)
|
child[8].setIcon(icon)
|
||||||
|
|
||||||
return child, layout_type
|
return child, layout_type
|
||||||
|
@ -828,7 +835,7 @@ def test_pushbutton(widget, *_):
|
||||||
child.append(abstract_button(widget_type, widget, 'Button 1', checked=True))
|
child.append(abstract_button(widget_type, widget, 'Button 1', checked=True))
|
||||||
child.append(abstract_button(widget_type, widget, 'Button 2', enabled=False))
|
child.append(abstract_button(widget_type, widget, 'Button 2', enabled=False))
|
||||||
child.append(abstract_button(widget_type, widget, 'Button 3', checkable=False))
|
child.append(abstract_button(widget_type, widget, 'Button 3', checkable=False))
|
||||||
icon = menu.style().standardIcon(SP_DockWidgetCloseButton)
|
icon = close_icon(widget)
|
||||||
child.append(abstract_button(widget_type, widget, icon, 'Button 4', checkable=False))
|
child.append(abstract_button(widget_type, widget, icon, 'Button 4', checkable=False))
|
||||||
|
|
||||||
return child, layout_type
|
return child, layout_type
|
||||||
|
@ -1079,7 +1086,7 @@ def test_disabled_menu(widget, window, font, width, *_):
|
||||||
action3 = QAction('&Action 6', window)
|
action3 = QAction('&Action 6', window)
|
||||||
action3.setCheckable(True)
|
action3.setCheckable(True)
|
||||||
menu.addAction(action3)
|
menu.addAction(action3)
|
||||||
icon = menu.style().standardIcon(SP_DockWidgetCloseButton)
|
icon = close_icon(menu)
|
||||||
menu.addAction(QAction(icon, '&Action 7', window))
|
menu.addAction(QAction(icon, '&Action 7', window))
|
||||||
menu.addAction(QAction(icon, '&Action 8', window))
|
menu.addAction(QAction(icon, '&Action 8', window))
|
||||||
menu.actions()[2].setEnabled(False)
|
menu.actions()[2].setEnabled(False)
|
||||||
|
|
Loading…
Reference in New Issue