mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[ui] improvement -> refactoring table icons size to qss
This commit is contained in:
@@ -70,7 +70,7 @@ class UpgradeToggleButton(QToolButton):
|
|||||||
|
|
||||||
class PackagesTable(QTableWidget):
|
class PackagesTable(QTableWidget):
|
||||||
COL_NUMBER = 9
|
COL_NUMBER = 9
|
||||||
ICONS_SIZE = QSize(16, 16)
|
DEFAULT_ICON_SIZE = QSize(16, 16)
|
||||||
|
|
||||||
def __init__(self, parent: QWidget, icon_cache: MemoryCache, download_icons: bool):
|
def __init__(self, parent: QWidget, icon_cache: MemoryCache, download_icons: bool):
|
||||||
super(PackagesTable, self).__init__()
|
super(PackagesTable, self).__init__()
|
||||||
@@ -344,13 +344,13 @@ class PackagesTable(QTableWidget):
|
|||||||
icon_data = self.cache_type_icon.get(pkg.model.get_type())
|
icon_data = self.cache_type_icon.get(pkg.model.get_type())
|
||||||
|
|
||||||
if icon_data is None:
|
if icon_data is None:
|
||||||
pixmap = QIcon(pkg.model.get_type_icon_path()).pixmap(self.ICONS_SIZE)
|
icon = QIcon(pkg.model.get_type_icon_path())
|
||||||
|
pixmap = icon.pixmap(self._get_icon_size(icon))
|
||||||
icon_data = {'px': pixmap, 'tip': '{}: {}'.format(self.i18n['type'], pkg.get_type_label())}
|
icon_data = {'px': pixmap, 'tip': '{}: {}'.format(self.i18n['type'], pkg.get_type_label())}
|
||||||
self.cache_type_icon[pkg.model.get_type()] = icon_data
|
self.cache_type_icon[pkg.model.get_type()] = icon_data
|
||||||
|
|
||||||
col_type_icon = QLabel()
|
col_type_icon = QLabel()
|
||||||
col_type_icon.setCursor(QCursor(Qt.WhatsThisCursor))
|
col_type_icon.setCursor(QCursor(Qt.WhatsThisCursor))
|
||||||
col_type_icon.setObjectName('app_type')
|
|
||||||
col_type_icon.setProperty('icon', 'true')
|
col_type_icon.setProperty('icon', 'true')
|
||||||
col_type_icon.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
|
col_type_icon.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
|
||||||
col_type_icon.setPixmap(icon_data['px'])
|
col_type_icon.setPixmap(icon_data['px'])
|
||||||
@@ -420,7 +420,6 @@ class PackagesTable(QTableWidget):
|
|||||||
icon = icon_data['icon'] if icon_data else QIcon(pkg.model.get_default_icon_path())
|
icon = icon_data['icon'] if icon_data else QIcon(pkg.model.get_default_icon_path())
|
||||||
|
|
||||||
col_icon = QLabel()
|
col_icon = QLabel()
|
||||||
col_icon.setObjectName('app_icon')
|
|
||||||
col_icon.setProperty('icon', 'true')
|
col_icon.setProperty('icon', 'true')
|
||||||
col_icon.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
|
col_icon.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
|
||||||
self._update_icon(col_icon, icon)
|
self._update_icon(col_icon, icon)
|
||||||
@@ -449,7 +448,11 @@ class PackagesTable(QTableWidget):
|
|||||||
self.setCellWidget(pkg.table_index, col, col_name)
|
self.setCellWidget(pkg.table_index, col, col_name)
|
||||||
|
|
||||||
def _update_icon(self, label: QLabel, icon: QIcon):
|
def _update_icon(self, label: QLabel, icon: QIcon):
|
||||||
label.setPixmap(icon.pixmap(self.ICONS_SIZE))
|
label.setPixmap(icon.pixmap(self._get_icon_size(icon)))
|
||||||
|
|
||||||
|
def _get_icon_size(self, icon: QIcon) -> QSize:
|
||||||
|
sizes = icon.availableSizes()
|
||||||
|
return sizes[-1] if sizes else self.DEFAULT_ICON_SIZE
|
||||||
|
|
||||||
def _set_col_description(self, col: int, pkg: PackageView):
|
def _set_col_description(self, col: int, pkg: PackageView):
|
||||||
item = QLabel()
|
item = QLabel()
|
||||||
|
|||||||
@@ -268,7 +268,13 @@ PackagesTable QLabel#icon_publisher_verified {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackagesTable QLabel[icon = "true"] {
|
PackagesTable QLabel[icon = "true"] {
|
||||||
qproperty-alignment: AlignCenter;
|
qproperty-scaledContents: True;
|
||||||
|
min-height: 16;
|
||||||
|
max-height: 16;
|
||||||
|
min-width: 16;
|
||||||
|
max-width: 16;
|
||||||
|
margin-left: 12px;
|
||||||
|
margin-top: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
PackagesTable QToolButton#bt_install {
|
PackagesTable QToolButton#bt_install {
|
||||||
|
|||||||
Reference in New Issue
Block a user