修复bug

This commit is contained in:
liyp 2022-05-03 18:59:06 +08:00
parent e3bf7cd01d
commit bf5cf254d8
3 changed files with 22 additions and 30 deletions

View file

@ -17,5 +17,5 @@
- [x] 最小化到任务栏功能 - [x] 最小化到任务栏功能
### 已知 bug ### 已知 bug
- 列表右键重命名导致堆栈布局更新失败 - ~~列表右键重命名导致堆栈布局更新失败~~
- 不能及时更新堆栈布局的title - ~~不能及时更新堆栈布局的title~~

View file

@ -18,6 +18,8 @@ from view.MyDayView import MyDay
class MainWidget(QWidget): class MainWidget(QWidget):
update_signal = pyqtSignal() update_signal = pyqtSignal()
# 重载UI信号
reload_signal = pyqtSignal()
def __init__(self): def __init__(self):
super(MainWidget, self).__init__() super(MainWidget, self).__init__()
@ -63,8 +65,10 @@ class MainWidget(QWidget):
self.load_list = get_todo_list() self.load_list = get_todo_list()
self.setLayout(layout) self.setLayout(layout)
self.user_label.sync_signal.connect(self.initUI) self.user_label.sync_signal.connect(self.refresh_action)
self.reload_signal.connect(self.refresh_action)
self.initUI() self.initUI()
# self.update_signal.connect(self.initUI)
def initUI(self): def initUI(self):
self.important.update_signal.connect(self.my_day.refresh_action) self.important.update_signal.connect(self.my_day.refresh_action)
@ -85,12 +89,14 @@ class MainWidget(QWidget):
# todo 通过信号修改显示的标题名字 # todo 通过信号修改显示的标题名字
# self.system_listWidget.change_list_name.connect(self.change_list) # self.system_listWidget.change_list_name.connect(self.change_list)
# 加载列表 # 加载列表
# print(load_list)
# todobug 第一个为空会导致无法添加 # todobug 第一个为空会导致无法添加
if self.load_list: if self.load_list:
for load in self.load_list: for load in self.load_list:
self.load_item(load[0], load[1], load[3]) self.load_item(load[0], load[1], load[3])
# self.system_listWidget.addScrollBarWidget(False)
def refresh_action(self):
self.load_list = get_todo_list()
self.initUI()
def myListWidgetContext(self, position): def myListWidgetContext(self, position):
if self.system_listWidget.currentRow() > 1: if self.system_listWidget.currentRow() > 1:
@ -160,7 +166,7 @@ class MainWidget(QWidget):
# 加载左侧列表 # 加载左侧列表
def load_item(self, list_name, uid, icon=None): def load_item(self, list_name, uid, icon=None):
# print(icon) # print('加载列表')
# self.stackedWidget.currentChanged.connect(self.change) # self.stackedWidget.currentChanged.connect(self.change)
item = SelfListWidgetItem(list_name, 0, uid, os.getcwd() + '/../images/icon/' + icon + '.svg') item = SelfListWidgetItem(list_name, 0, uid, os.getcwd() + '/../images/icon/' + icon + '.svg')
item.setTextAlignment(Qt.AlignCenter) item.setTextAlignment(Qt.AlignCenter)
@ -172,6 +178,7 @@ class MainWidget(QWidget):
# 更新 重要 内容 # 更新 重要 内容
todo_list.update_signal.connect(self.important.refresh_action) todo_list.update_signal.connect(self.important.refresh_action)
todo_list.update_signal.connect(self.my_day.refresh_action) todo_list.update_signal.connect(self.my_day.refresh_action)
# todo_list.update_signal.connect(self.initUI)
# 删除分组时可用 # 删除分组时可用
self.important.update_signal.connect(todo_list.refresh_action) self.important.update_signal.connect(todo_list.refresh_action)
@ -188,22 +195,11 @@ class MainWidget(QWidget):
# 点击创建新的分组 # 点击创建新的分组
def create_item(self, new_list='新建列表', uid=None): def create_item(self, new_list='新建列表', uid=None):
# 创建一个没有名字的item
# new_list = '新建列表'
print('<main>(create_item)', self.stackedWidget.currentIndex())
if not uid: if not uid:
create_todo = CreateToDo('ToDoList', new_list) create_todo = CreateToDo('ToDoList', new_list)
self.load_list.append(create_todo) self.load_list.append(create_todo)
item = SelfListWidgetItem(new_list, 0, create_todo[1]) self.load_item(self.load_list[-1][0],self.load_list[-1][1],self.load_list[-1][3])
item.setTextAlignment(Qt.AlignCenter)
# 使得item是可以编辑的.
item.setFlags(item.flags() | Qt.ItemIsEditable)
self.system_listWidget.addItem(item)
todo_list = ToDoList(new_list, create_todo[1])
self.stackedWidget.addWidget(todo_list)
self.system_listWidget.setItemWidget(item, item.widget)
# 删除分组 # 删除分组
def delete_item(self): def delete_item(self):
@ -215,7 +211,7 @@ class MainWidget(QWidget):
remove_todo_list(self.load_list[index][1]) remove_todo_list(self.load_list[index][1])
del self.load_list[index] del self.load_list[index]
# print('result:', self.load_list) # print('result:', self.load_list)
# print('<main>(delete_item)', self.stackedWidget.indexOf(self.stackedWidget.currentWidget())) print('<main>(delete_item)', self.stackedWidget.indexOf(self.stackedWidget.currentWidget()))
self.stackedWidget.removeWidget(self.stackedWidget.currentWidget()) self.stackedWidget.removeWidget(self.stackedWidget.currentWidget())
self.system_listWidget.takeItem(self.system_listWidget.currentRow()) self.system_listWidget.takeItem(self.system_listWidget.currentRow())

View file

@ -5,31 +5,27 @@ from PyQt5.QtGui import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt, pyqtSignal from PyQt5.QtCore import Qt, pyqtSignal
from utils.BasicUtils import load_myday_important, remove_todo_list, change_value, change_myday_important_conf from utils.BasicUtils import load_myday_important, remove_todo_list, change_value, change_myday_important_conf, \
get_myday_important_conf
from utils.CreateToDo import CreateToDo, create_myday_important from utils.CreateToDo import CreateToDo, create_myday_important
from view.AddToDoLabel import AddToDoAction from view.AddToDoLabel import AddToDoAction
from view.MyDayHeadLabel import HeadLabel from view.MyDayHeadLabel import HeadLabel
from view.ToDoItem import ToDoItem from view.ToDoItem import ToDoItem
class Menu(QMenu):
def __init__(self, *__args):
super(Menu, self).__init__()
self.index = None
def set_index(self, index):
self.index = index
class MyDay(QWidget): class MyDay(QWidget):
update_signal = pyqtSignal() update_signal = pyqtSignal()
def __init__(self, parent=None): def __init__(self, parent=None):
super(MyDay, self).__init__() super(MyDay, self).__init__()
self.setObjectName('my_day') self.setObjectName('my_day')
self.setStyleSheet('#my_day{background-image:url("../images/0.jpg");border-radius: 10px;}')
self.setAttribute(Qt.WA_StyledBackground) self.setAttribute(Qt.WA_StyledBackground)
background = get_myday_important_conf('MyDay', 'Theme')
if not background:
background = '0'
else:
self.setStyleSheet('#my_day{background-image:url("../images/' + background + '.jpg");border-radius: 10px;}')
# 下面这一句有问题,需要修复修改主题的实现方法 # 下面这一句有问题,需要修复修改主题的实现方法
# self.setStyleSheet('#my_day{background-image:url("../images/2.jpg");') # self.setStyleSheet('#my_day{background-image:url("../images/2.jpg");')