mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 10:54:16 +02:00
[refactoring][ui] styles simple refactoring
This commit is contained in:
@@ -27,6 +27,9 @@ PUBLISHER_MAX_SIZE = 25
|
|||||||
|
|
||||||
class UpdateToggleButton(QWidget):
|
class UpdateToggleButton(QWidget):
|
||||||
|
|
||||||
|
STYLE_DEFAULT = 'QToolButton { background: ' + GREEN + ' } QToolButton:checked { background: gray } '
|
||||||
|
STYLE_UNCHECKED = 'QToolButton:disabled { background: #d69003 }'
|
||||||
|
|
||||||
def __init__(self, pkg: PackageView, root: QWidget, i18n: I18n, checked: bool = True, clickable: bool = True):
|
def __init__(self, pkg: PackageView, root: QWidget, i18n: I18n, checked: bool = True, clickable: bool = True):
|
||||||
super(UpdateToggleButton, self).__init__()
|
super(UpdateToggleButton, self).__init__()
|
||||||
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
||||||
@@ -46,9 +49,7 @@ class UpdateToggleButton(QWidget):
|
|||||||
if clickable:
|
if clickable:
|
||||||
self.bt.clicked.connect(self.change_state)
|
self.bt.clicked.connect(self.change_state)
|
||||||
|
|
||||||
self.bt.setStyleSheet('QToolButton { background: ' + GREEN + ' }' +
|
self.bt.setStyleSheet(self.STYLE_DEFAULT + (self.STYLE_UNCHECKED if not clickable and not checked else ''))
|
||||||
'QToolButton:checked { background: gray } ' +
|
|
||||||
('QToolButton:disabled { background: #d69003 }' if not clickable and not checked else ''))
|
|
||||||
|
|
||||||
layout.addWidget(self.bt)
|
layout.addWidget(self.bt)
|
||||||
|
|
||||||
@@ -83,6 +84,8 @@ class UpdateToggleButton(QWidget):
|
|||||||
class AppsTable(QTableWidget):
|
class AppsTable(QTableWidget):
|
||||||
|
|
||||||
COL_NUMBER = 8
|
COL_NUMBER = 8
|
||||||
|
STYLE_BT_INSTALL = 'background: {b}; color: white; font-size: 10px; font-weight: bold'.format(b=GREEN)
|
||||||
|
STYLE_BT_UNINSTALL = 'color: {c}; font-size: 10px; font-weight: bold;'.format(c=BROWN)
|
||||||
|
|
||||||
def __init__(self, parent: QWidget, icon_cache: MemoryCache, download_icons: bool):
|
def __init__(self, parent: QWidget, icon_cache: MemoryCache, download_icons: bool):
|
||||||
super(AppsTable, self).__init__()
|
super(AppsTable, self).__init__()
|
||||||
@@ -325,19 +328,15 @@ class AppsTable(QTableWidget):
|
|||||||
def uninstall():
|
def uninstall():
|
||||||
self._uninstall(pkg)
|
self._uninstall(pkg)
|
||||||
|
|
||||||
style = 'color: {c}; font-size: 10px; font-weight: bold;'.format(c=BROWN)
|
item = self._gen_row_button(self.i18n['uninstall'].capitalize(), self.STYLE_BT_UNINSTALL, uninstall)
|
||||||
item = self._gen_row_button(self.i18n['uninstall'].capitalize(), style, uninstall)
|
|
||||||
else:
|
else:
|
||||||
item = QLabel()
|
item = None
|
||||||
item.setPixmap((QPixmap(resource.get_path('img/checked.svg'))))
|
|
||||||
item.setAlignment(Qt.AlignCenter)
|
|
||||||
item.setToolTip(self.i18n['installed'])
|
|
||||||
elif pkg.model.can_be_installed():
|
elif pkg.model.can_be_installed():
|
||||||
def install():
|
def install():
|
||||||
self._install_app(pkg)
|
self._install_app(pkg)
|
||||||
|
|
||||||
style = 'background: {b}; color: white; font-size: 10px; font-weight: bold'.format(b=GREEN)
|
item = self._gen_row_button(self.i18n['install'].capitalize(), self.STYLE_BT_INSTALL, install)
|
||||||
item = self._gen_row_button(self.i18n['install'].capitalize(), style, install)
|
|
||||||
else:
|
else:
|
||||||
item = None
|
item = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user