代码拉取完成,页面将自动刷新
# coding=utf-8
from functools import partial
from qtpy import QtWidgets, QtCore
from .ui.thumbnail_item_row_widget import Ui_thumbnail_item_row_widget
class ThumbnailItemBaseWidget(QtWidgets.QWidget):
def __init__(self, widget_factory, parent):
QtWidgets.QWidget.__init__(self, parent)
self._ui = widget_factory()
self._ui.setupUi(self)
self._ui.thumbnail.setScaledContents(False)
# self._ui.box.setProperty('item_type', 'thumbnail')
self._ui.box.setProperty('item_status', 'normal')
# 设置菜单
self._menu = QtWidgets.QMenu(self)
self._actions = []
# self._ui.action_btn.setMenu(self._menu)
self._ui.action_btn.setVisible(False)
# self._menu.setStyleSheet("""QMenu{
# color:rgb(200,200,200);
# font: 9pt \"Arial\";
# background:rgb(35,35,35);
# border: 1px solid rgb(0, 120, 215);
# }
# QMenu:item:disabled{
# color:rgba(50,50,50);
# }
# QMenu:item:disabled:selected{
# background:rgba(0, 120, 215, 30);
# color:rgba(50,50,50);
# }
# QMenu:item:selected{
# background:rgb(0, 120, 215);
# }
# """)
def menu_enable(self, status):
if status:
self._ui.action_btn.setMenu(self._menu)
else:
self._ui.action_btn.setMenu(None)
def set_actions(self, actions, hook, data):
"""
添加菜单
"""
self._actions = actions
name_list = self._actions.keys()
for name in name_list:
cmd = self._actions[name]
action = QtWidgets.QAction(name, self)
action.triggered.connect(partial(hook.main, cmd, data))
self._menu.addAction(action)
def set_border_radius(self, status):
self._ui.box.setProperty('border_radius', status)
def set_action_btn_visible(self, is_visible):
"""
菜单按钮的显示
"""
self._ui.action_btn.setVisible(is_visible)
def set_thumbnail(self, pixmap):
"""
设置预览图片
"""
self._ui.thumbnail.setPixmap(pixmap)
def set_status(self, status='normal'):
self._ui.box.setProperty('item_status', status)
self._ui.box.style().polish(self._ui.box)
self._ui.box.update()
@staticmethod
def calculate_size(width, height):
return QtCore.QSize(width, height)
def set_selected(self, value):
if value:
self.set_status('selected')
else:
self.set_status('normal')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。