68 lines
2.2 KiB
Python
68 lines
2.2 KiB
Python
import os
|
||
import time
|
||
|
||
from PyQt5 import QtGui
|
||
from PyQt5.QtCore import Qt, pyqtSignal
|
||
from PyQt5.QtGui import QPixmap, QIcon
|
||
from PyQt5.QtWidgets import *
|
||
from PyQt5.QtCore import Qt
|
||
|
||
from utils.BasicUtils import change_value
|
||
|
||
|
||
class ToDoItem(QListWidgetItem):
|
||
"""
|
||
:param todo_name : 新建的待办事项名称
|
||
:param uid : 待办事项的uid
|
||
"""
|
||
|
||
def __init__(self, todo_name, uid=None):
|
||
super(ToDoItem, self).__init__()
|
||
# print('<ToDoItem> 添加的新ToDo:' + todo_name)
|
||
|
||
self.widget = QWidget()
|
||
layout = QHBoxLayout()
|
||
|
||
# self.widget.setMinimumHeight(100)
|
||
self.widget.setLayout(layout)
|
||
self.widget.show()
|
||
self.mark_icon = QPushButton()
|
||
self.mark_icon.setObjectName('todo_mark_icon')
|
||
self.mark_icon.setIcon(
|
||
QIcon(QPixmap('../images/circle.svg').scaled(200, 200, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
|
||
self.todo_label = QLabel()
|
||
self.todo_label.setAlignment(Qt.AlignCenter)
|
||
if todo_name:
|
||
self.todo_label.setText(str(todo_name))
|
||
self.important_button = QPushButton()
|
||
self.important_button.setIcon(
|
||
QIcon(QPixmap('../images/star_list.svg').scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)))
|
||
self.important_button.setObjectName('mark_important')
|
||
layout.addWidget(self.mark_icon, 2)
|
||
layout.addWidget(self.todo_label, 6)
|
||
layout.addWidget(self.important_button, 2)
|
||
|
||
self.mark_icon.clicked.connect(self.set_done)
|
||
# print('<ToDoItem>', uid)
|
||
|
||
self.important_button.clicked.connect(lambda: self.set_important(uid))
|
||
# self.mark_icon.trans_signal.connect(self.set_done)
|
||
|
||
def set_done(self):
|
||
self.mark_icon.setIcon(QIcon(os.getcwd()+'/../images/finished.svg'))
|
||
# time.sleep(0.2)
|
||
pass
|
||
|
||
def set_myday(self, uid):
|
||
change_value(uid, 'done', True)
|
||
pass
|
||
|
||
def set_important(self, uid):
|
||
# important = Important()
|
||
# important.load_important.emit()
|
||
# self.action.emit()
|
||
print('<ToDoItem>',uid)
|
||
|
||
change_value(uid, 'isImportant', True)
|
||
# self.transaction.emit()
|
||
pass
|