mirror of
https://github.com/yuruotong1/autoMate.git
synced 2025-12-26 05:16:21 +08:00
完成功能列表
This commit is contained in:
parent
5f502e15d0
commit
13154bdbbb
@ -45,16 +45,19 @@ class ActionListView(QListWidget):
|
||||
func_list_pos_row: int
|
||||
func_list_pos_column: int
|
||||
func_name: str
|
||||
func_status: str
|
||||
func_description: str
|
||||
action_items: list[ActionListViewItem.ActionItem]
|
||||
|
||||
def __init__(self, func_list_pos_row, func_list_pos_column, *args, **kwargs):
|
||||
def __init__(self, func_status, func_list_pos_row, func_list_pos_column, *args, **kwargs):
|
||||
super().__init__()
|
||||
# 在func页面上的位置
|
||||
self.func_list_pos_row = func_list_pos_row
|
||||
self.func_list_pos_column = func_list_pos_column
|
||||
# 在func上的名称
|
||||
self.func_name = ""
|
||||
self.func_name = "默认名称"
|
||||
# 属于通用还是专属
|
||||
self.func_status = func_status
|
||||
self.func_description = ""
|
||||
self.setAcceptDrops(True)
|
||||
# 拖动到当前位置对应的元素序号
|
||||
@ -72,8 +75,10 @@ class ActionListView(QListWidget):
|
||||
|
||||
@classmethod
|
||||
def load(cls, action_list_view_json: ActionListViewJson):
|
||||
action_list_view = ActionListView(action_list_view_json.func_list_pos_row,
|
||||
action_list_view_json.func_list_pos_column)
|
||||
action_list_view = ActionListView(
|
||||
action_list_view_json.func_status,
|
||||
action_list_view_json.func_list_pos_row,
|
||||
action_list_view_json.func_list_pos_column)
|
||||
action_list_view.func_name = action_list_view_json.func_name
|
||||
action_list_view.func_description = action_list_view_json.func_description
|
||||
for item in action_list_view_json.action_items:
|
||||
@ -90,7 +95,9 @@ class ActionListView(QListWidget):
|
||||
func_list_pos_column=self.func_list_pos_column,
|
||||
func_name=self.func_name,
|
||||
func_description=self.func_description,
|
||||
action_items=action_items)
|
||||
func_status=self.func_status,
|
||||
action_items=action_items
|
||||
)
|
||||
|
||||
def init(self):
|
||||
self.setStyleSheet(
|
||||
@ -238,9 +245,10 @@ class GlobalUtil:
|
||||
current_action: ActionListView = None
|
||||
|
||||
@classmethod
|
||||
def get_list_view_by_position(cls, row, column):
|
||||
def get_list_view_by_position(cls, func_status, row, column):
|
||||
for i in cls.action_list_global:
|
||||
if i.func_list_pos_row == row and i.func_list_pos_column == column:
|
||||
if i.func_list_pos_row == row and i.func_list_pos_column == column \
|
||||
and i.func_status == func_status:
|
||||
return i
|
||||
return None
|
||||
|
||||
|
||||
@ -7,6 +7,8 @@ from utils.qt_util import QtUtil
|
||||
class EditPage(BasePage):
|
||||
def setup_up(self):
|
||||
self.ui = QtUtil.load_ui("edit_page.ui")
|
||||
self.ui.func_name_edit.setText(GlobalUtil.current_action.func_name)
|
||||
self.ui.func_description_edit.setText(GlobalUtil.current_action.func_description)
|
||||
function_list_view = FunctionListView()
|
||||
self.ui.function_list_layout.addWidget(function_list_view)
|
||||
self.ui.ListViewLayout.addWidget(GlobalUtil.current_action)
|
||||
@ -19,6 +21,8 @@ class EditPage(BasePage):
|
||||
self.ui.ListViewLayout.setStretch(2, 10)
|
||||
|
||||
def __save_button_click(self):
|
||||
GlobalUtil.current_action.func_name = self.ui.func_name_edit.text()
|
||||
GlobalUtil.current_action.func_description = self.ui.func_description_edit.text()
|
||||
GlobalUtil.save_to_local()
|
||||
self.ui.hide()
|
||||
from pages.func_list_page import FuncListPage
|
||||
@ -28,7 +32,8 @@ class EditPage(BasePage):
|
||||
def __cancel_button_click(self):
|
||||
GlobalUtil.delete_action_view(GlobalUtil.current_action)
|
||||
self.ui.hide()
|
||||
self.func = FunctionListView()
|
||||
from pages.func_list_page import FuncListPage
|
||||
self.func = FuncListPage()
|
||||
self.func.show()
|
||||
|
||||
@staticmethod
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<widget class="QLineEdit" name="func_name_edit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>860</x>
|
||||
@ -90,7 +90,7 @@
|
||||
<string>标题</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_2">
|
||||
<widget class="QLineEdit" name="func_description_edit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>860</x>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
from PyQt6.QtCore import QSize
|
||||
from PyQt6.QtCore import QSize, Qt
|
||||
from PyQt6.QtGui import QIcon
|
||||
from PyQt6.QtWidgets import QPushButton, QGraphicsOpacityEffect
|
||||
from PyQt6.QtWidgets import QGraphicsOpacityEffect, QToolButton
|
||||
|
||||
from pages.bse_page import BasePage
|
||||
from pages.edit_action_list_view import GlobalUtil, ActionListView
|
||||
@ -8,39 +8,50 @@ from pages.edit_page import EditPage
|
||||
from utils.qt_util import QtUtil
|
||||
|
||||
|
||||
class AddFuncButton(QPushButton):
|
||||
def __init__(self, func_list_pos_row, func_list_pos_column, func_list_page):
|
||||
class AddFuncButton(QToolButton):
|
||||
def __init__(self, func_status, func_list_pos_row, func_list_pos_column, func_list_page):
|
||||
super().__init__()
|
||||
# 专属按钮还是通用按钮
|
||||
self.func_status = func_status
|
||||
self.func_list_pos_row = func_list_pos_row
|
||||
self.func_list_pos_column = func_list_pos_column
|
||||
self.func_list_page = func_list_page
|
||||
self.setMouseTracking(True)
|
||||
self.clicked.connect(self.click)
|
||||
self.setIcon(QIcon(QtUtil.get_icon("添加.png")))
|
||||
self.setIconSize(QSize(50, 50))
|
||||
self.setFlat(True) # 删除按钮边框
|
||||
self.list_view = GlobalUtil.get_list_view_by_position(self.func_status, func_list_pos_row, func_list_pos_column)
|
||||
if self.list_view:
|
||||
self.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
|
||||
self.setIcon(QIcon(QtUtil.get_icon("功能.png")))
|
||||
self.setText(self.list_view.func_name)
|
||||
self.setIconSize(QSize(50, 50))
|
||||
else:
|
||||
self.setIcon(QIcon(QtUtil.get_icon("添加.png")))
|
||||
# 按钮消息
|
||||
self.opacity_effect = QGraphicsOpacityEffect(self)
|
||||
self.setGraphicsEffect(self.opacity_effect)
|
||||
self.opacity_effect.setOpacity(0)
|
||||
self.setIconSize(QSize(50, 50))
|
||||
self.setFixedSize(QSize(80, 80))
|
||||
# self.(True) # 删除按钮边框
|
||||
# 防止被垃圾回收,所以注册为实例变量
|
||||
self.edit_page = None
|
||||
# 按钮消息
|
||||
self.opacity_effect = QGraphicsOpacityEffect(self)
|
||||
self.setGraphicsEffect(self.opacity_effect)
|
||||
self.opacity_effect.setOpacity(0)
|
||||
|
||||
def click(self):
|
||||
self.func_list_page.hide()
|
||||
list_view = GlobalUtil.get_list_view_by_position(self.func_list_pos_row, self.func_list_pos_column)
|
||||
if not list_view:
|
||||
list_view = ActionListView(self.func_list_pos_row, self.func_list_pos_column)
|
||||
GlobalUtil.action_list_global.append(list_view)
|
||||
GlobalUtil.current_action = list_view
|
||||
if not self.list_view:
|
||||
self.list_view = ActionListView(self.func_status, self.func_list_pos_row, self.func_list_pos_column)
|
||||
GlobalUtil.action_list_global.append(self.list_view)
|
||||
GlobalUtil.current_action = self.list_view
|
||||
self.edit_page = EditPage()
|
||||
self.edit_page.show()
|
||||
|
||||
def enterEvent(self, event):
|
||||
self.opacity_effect.setOpacity(1)
|
||||
if not self.list_view:
|
||||
self.opacity_effect.setOpacity(1)
|
||||
|
||||
def leaveEvent(self, event):
|
||||
self.opacity_effect.setOpacity(0)
|
||||
if not self.list_view:
|
||||
self.opacity_effect.setOpacity(0)
|
||||
|
||||
|
||||
class FuncListPage(BasePage):
|
||||
@ -49,11 +60,11 @@ class FuncListPage(BasePage):
|
||||
# 四行三列,辅满通用应用列表布局
|
||||
for i in range(3): # 3行
|
||||
for j in range(4): # 4列
|
||||
add_button = AddFuncButton(i, j, self.ui)
|
||||
add_button = AddFuncButton("通用", i, j, self.ui)
|
||||
self.ui.general_layout.addWidget(add_button, i, j)
|
||||
|
||||
# 四行四列,辅满专属应用列表布局
|
||||
for i in range(3): # 4行
|
||||
for j in range(4): # 4列
|
||||
add_button = AddFuncButton(i, j, self.ui)
|
||||
add_button = AddFuncButton("专属", i, j, self.ui)
|
||||
self.ui.special_layout.addWidget(add_button, i, j)
|
||||
|
||||
@ -18,9 +18,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<y>20</y>
|
||||
<width>351</width>
|
||||
<height>241</height>
|
||||
<height>261</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="general_layout"/>
|
||||
@ -29,13 +29,39 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>270</y>
|
||||
<y>300</y>
|
||||
<width>351</width>
|
||||
<height>321</height>
|
||||
<height>291</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="special_layout"/>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>54</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>通用功能</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>280</y>
|
||||
<width>54</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>条件功能</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
|
||||
BIN
source/功能.png
Normal file
BIN
source/功能.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
Loading…
x
Reference in New Issue
Block a user