基本功能都已经实现,需要最后一个设置和同步,使用允许添加一个笔记功能和最小化
1
images/icon/学习.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1650871802217" class="icon" viewBox="0 0 1117 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="48554" xmlns:xlink="http://www.w3.org/1999/xlink" width="218.1640625" height="200"><defs><style type="text/css"></style></defs><path d="M1069.243707 862.981253h-403.349933L555.881316 982.153291l-119.172038-119.172038H33.354213V33.354213h403.349934l119.177169 119.172038L665.893774 33.354213h403.349933z" fill="#D8D8E8" p-id="48555"></path><path d="M132.652271 163.189336H357.24928v51.314174H132.652271zM132.652271 368.897597H357.24928v51.314174H132.652271zM132.652271 266.320563H357.24928v51.314174H132.652271z" fill="#6E6E96" opacity=".65" p-id="48556"></path><path d="M754.68782 163.189336h224.60214v51.314174h-224.60214zM754.68782 368.897597h224.60214v51.314174h-224.60214zM754.68782 266.320563h224.60214v51.314174h-224.60214z" fill="#6E6E96" opacity=".65" p-id="48557"></path><path d="M665.893774 33.354213v829.62704L555.881316 982.153291V152.526251z" fill="#6E6E96" opacity=".27" p-id="48558"></path><path d="M436.704147 33.354213l0.005131 829.62704 119.172038 119.172038V152.526251z" fill="#6E6E96" opacity=".6" p-id="48559"></path><path d="M1074.375125 837.324166h-403.349934a25.657087 25.657087 0 0 0-18.852827 8.251319l-110.012458 119.172038a25.641693 25.641693 0 0 1 36.997519-0.733792l-119.172038-119.172038a25.657087 25.657087 0 0 0-18.144691-7.517527H38.485631a25.657087 25.657087 0 0 1 25.657087 25.657087V33.354213a25.657087 25.657087 0 0 1-25.657087 25.657087h403.349933a25.677613 25.677613 0 0 1-18.144692-7.512395l119.177169 119.172038a25.657087 25.657087 0 0 0 36.99752-0.738924l110.007326-119.172038a25.657087 25.657087 0 0 1-18.852827 8.251319h403.349933a25.657087 25.657087 0 0 1-25.657087-25.657087v829.62704a25.657087 25.657087 0 0 1 25.662219-25.657087z m0-829.62704h-403.349934a25.657087 25.657087 0 0 0-18.852827 8.251319l-110.012458 119.172038a25.672481 25.672481 0 0 1 36.997519-0.738924L459.980256 15.214653A25.662218 25.662218 0 0 0 441.835564 7.697126H38.485631a25.657087 25.657087 0 0 0-25.657087 25.657087v829.62704a25.657087 25.657087 0 0 0 25.657087 25.657087h403.355065a25.641693 25.641693 0 0 1-18.144692-7.517526l119.172037 119.172038a25.646824 25.646824 0 0 0 36.99752-0.733793l110.007326-119.172038a25.657087 25.657087 0 0 1-18.852827 8.251319h403.349933a25.657087 25.657087 0 0 0 25.657087-25.657087V33.354213a25.651956 25.651956 0 0 0-25.651955-25.657087z" fill="#6E6E96" p-id="48560"></path><path d="M132.652271 475.025572H357.24928v51.314174H132.652271zM132.652271 680.728701H357.24928v51.314174H132.652271zM132.652271 578.151667H357.24928v51.314174H132.652271z" fill="#6E6E96" opacity=".65" p-id="48561"></path><path d="M754.68782 475.025572h224.60214v51.314174h-224.60214zM754.68782 680.728701h224.60214v51.314174h-224.60214zM754.68782 578.151667h224.60214v51.314174h-224.60214z" fill="#6E6E96" opacity=".65" p-id="48562"></path></svg>
|
After Width: | Height: | Size: 3 KiB |
1
images/icon/工作.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1650872008557" class="icon" viewBox="0 0 1272 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="48858" xmlns:xlink="http://www.w3.org/1999/xlink" width="248.4375" height="200"><defs><style type="text/css"></style></defs><path d="M494.36632 93.482621a25.760836 25.760836 0 0 1 25.733737-25.733736h237.744385a25.760836 25.760836 0 0 1 25.728317 25.733736v116.229986a25.760836 25.760836 0 0 1-25.728317 25.733736H520.100057a25.760836 25.760836 0 0 1-25.733737-25.733736V93.482621z m-54.199107 116.229986c0 44.074714 35.85813 79.932844 79.932844 79.932844h237.744385c44.074714 0 79.927424-35.85813 79.927424-79.932844V93.482621c0-44.074714-35.85271-79.932844-79.927424-79.932844H520.100057c-44.074714 0-79.932844 35.85813-79.932844 79.932844v116.229986z" fill="#6E6E96" p-id="48859"></path><path d="M1169.269868 891.239286c0 58.117703-47.548877 105.66116-105.66116 105.66116H224.904617c-58.117703 0-105.66658-47.543457-105.66658-105.66116V267.82489c0-58.112283 47.548877-105.66116 105.66658-105.66116h838.709511c58.112283 0 105.66116 47.548877 105.66116 105.66116v623.414396z" fill="#B1B1C7" p-id="48860"></path><path d="M1044.04283 156.743819H234.747175c-56.079817 0-101.959361 45.879545-101.959361 101.959361v70.599758c0-56.074397 45.879545-101.959361 101.959361-101.959361h809.295655c56.074397 0 101.959361 45.879545 101.959361 101.959361V258.697761c-0.00542-56.074397-45.884965-101.953941-101.959361-101.953942z" fill="#FFFFFF" opacity=".15" p-id="48861"></path><path d="M146.337591 328.332774h995.832723V475.597169H146.337591z" fill="#6E6E96" opacity=".15" p-id="48862"></path><path d="M1142.170314 891.239286c0 43.315927-35.24568 78.561606-78.561606 78.561606H224.904617c-43.321347 0-78.567026-35.24568-78.567026-78.561606V267.82489c0-43.321347 35.24568-78.561606 78.567026-78.561606h838.709511c43.315927 0 78.561606 35.24026 78.561606 78.561606v623.414396z m54.199108-623.414396c0-73.206735-59.553979-132.760714-132.760714-132.760714H224.904617C151.697882 135.064176 92.138483 194.618156 92.138483 267.82489v623.414396c0 73.206735 59.559399 132.760714 132.766134 132.760714h838.709511c73.206735 0 132.760714-59.553979 132.760714-132.760714V267.82489z" fill="#6E6E96" p-id="48863"></path><path d="M119.238037 363.562194h1050.031831v54.199108H119.238037z" fill="#6E6E96" p-id="48864"></path><path d="M261.223439 290.279581h105.66116v237.744385H261.223439z" fill="#DDDDF0" p-id="48865"></path><path d="M366.884599 500.924412H261.223439a27.099554 27.099554 0 0 1 27.099554 27.099554V290.279581a27.099554 27.099554 0 0 1-27.099554 27.099553h105.66116a27.099554 27.099554 0 0 1-27.099554-27.099553v237.744385a27.099554 27.099554 0 0 1 27.099554-27.099554z m0-237.744385H261.223439a27.099554 27.099554 0 0 0-27.099554 27.099554v237.744385a27.099554 27.099554 0 0 0 27.099554 27.099554h105.66116a27.099554 27.099554 0 0 0 27.099554-27.099554V290.279581a27.099554 27.099554 0 0 0-27.099554-27.099554z" fill="#6E6E96" p-id="48866"></path><path d="M948.039951 290.279581h105.66116v237.744385h-105.66116z" fill="#DDDDF0" p-id="48867"></path><path d="M194.439299 472.887214h235.766118v130.077858h-235.766118zM882.767965 472.887214h235.766119v130.077858h-235.766119z" fill="#6E6E96" opacity=".15" p-id="48868"></path><path d="M1053.701111 500.924412h-105.66116a27.099554 27.099554 0 0 1 27.099553 27.099554V290.279581a27.099554 27.099554 0 0 1-27.099553 27.099553h105.66116a27.099554 27.099554 0 0 1-27.099554-27.099553v237.744385a27.099554 27.099554 0 0 1 27.099554-27.099554z m0-237.744385h-105.66116a27.099554 27.099554 0 0 0-27.099554 27.099554v237.744385a27.099554 27.099554 0 0 0 27.099554 27.099554h105.66116a27.099554 27.099554 0 0 0 27.099554-27.099554V290.279581a27.099554 27.099554 0 0 0-27.099554-27.099554z" fill="#6E6E96" p-id="48869"></path><path d="M1047.598291 893.949241H247.17503c-55.461947 0-100.83744-45.370073-100.837439-100.83202v93.103228c0 55.461947 45.380913 100.83744 100.837439 100.837439h800.423261c55.451107 0 100.83202-45.375493 100.83202-100.837439v-93.103228c0.00542 55.461947-45.375493 100.83202-100.83202 100.83202z" fill="#6E6E96" opacity=".15" p-id="48870"></path></svg>
|
After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 6.9 KiB |
160
main/main.py
|
@ -2,7 +2,7 @@ import os
|
|||
import sys
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtCore import Qt, pyqtSignal
|
||||
import configparser
|
||||
|
||||
from utils.BasicUtils import get_todo_list, remove_todo_list, change_value
|
||||
|
@ -18,6 +18,8 @@ from view.MyDayView import MyDay
|
|||
|
||||
|
||||
class MainWidget(QWidget):
|
||||
update_signal = pyqtSignal()
|
||||
|
||||
def __init__(self):
|
||||
super(MainWidget, self).__init__()
|
||||
self.user_label = User()
|
||||
|
@ -57,11 +59,6 @@ class MainWidget(QWidget):
|
|||
|
||||
layout.addWidget(self.stackedWidget, 6)
|
||||
|
||||
self.one_day = SelfListWidgetItem('我的一天', 0, None, os.getcwd() + '/../images/sun.svg')
|
||||
self.system_listWidget.setCurrentRow(1)
|
||||
# self.one_day.setSelected(True)
|
||||
self.important_item = SelfListWidgetItem('重要', 0, None, os.getcwd() + '/../images/star.svg')
|
||||
|
||||
self.system_listWidget.currentRowChanged.connect(self.stackedWidget.setCurrentIndex)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
@ -71,25 +68,26 @@ class MainWidget(QWidget):
|
|||
# 先清除列表,方便后面调用
|
||||
self.system_listWidget.clear()
|
||||
# 系统默认的两个 item
|
||||
self.one_day = SelfListWidgetItem('我的一天', 0, None, os.getcwd() + '/../images/sun.svg')
|
||||
self.system_listWidget.setCurrentRow(1)
|
||||
# self.one_day.setSelected(True)
|
||||
self.important_item = SelfListWidgetItem('重要', 0, None, os.getcwd() + '/../images/star.svg')
|
||||
|
||||
self.system_listWidget.addItem(self.one_day)
|
||||
self.system_listWidget.setItemWidget(self.one_day, self.one_day.widget)
|
||||
|
||||
self.system_listWidget.addItem(self.important_item)
|
||||
self.system_listWidget.setItemWidget(self.important_item, self.important_item.widget)
|
||||
# todo : 通过信号修改显示的标题名字
|
||||
self.system_listWidget.change_list_name.connect(self.change_list)
|
||||
# self.system_listWidget.change_list_name.connect(self.change_list)
|
||||
# 加载列表
|
||||
self.load_list = get_todo_list()
|
||||
load_list = get_todo_list()
|
||||
# print(load_list)
|
||||
if self.load_list:
|
||||
for load in self.load_list:
|
||||
self.load_item(load[0], load[1])
|
||||
if load_list:
|
||||
for load in load_list:
|
||||
self.load_item(load[0], load[1], load[3])
|
||||
# self.system_listWidget.addScrollBarWidget(False)
|
||||
|
||||
def change_list(self):
|
||||
print(self.system_listWidget.currentItem().text())
|
||||
# print(name)
|
||||
|
||||
# todo 仔细研究右键菜单
|
||||
|
||||
def myListWidgetContext(self, position):
|
||||
|
@ -107,37 +105,83 @@ class MainWidget(QWidget):
|
|||
|
||||
# copy_action = QAction("复制分组", self)
|
||||
del_action = QAction("删除分组", self)
|
||||
change_icon = QMenu('修改图标', pop_menu)
|
||||
# 背景透明
|
||||
change_icon.setAttribute(Qt.WA_TranslucentBackground)
|
||||
# 无边框、去掉自带阴影
|
||||
change_icon.setWindowFlags(
|
||||
change_icon.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint)
|
||||
|
||||
# 二级菜单
|
||||
action1 = QAction(QIcon(os.getcwd() + '/../images/icon/星宿.svg'), "星宿", self)
|
||||
action2 = QAction(QIcon(os.getcwd() + '/../images/icon/度假.svg'), "度假", self)
|
||||
action3 = QAction(QIcon(os.getcwd() + '/../images/icon/冰淇淋.svg'), "冰淇淋", self)
|
||||
action4 = QAction(QIcon(os.getcwd() + '/../images/icon/学习.svg'), "学习", self)
|
||||
action5 = QAction(QIcon(os.getcwd() + '/../images/icon/工作.svg'), "工作", self)
|
||||
action6 = QAction(QIcon(os.getcwd() + '/../images/icon/购物.svg'), "购物", self)
|
||||
change_icon.addAction(action1)
|
||||
change_icon.addAction(action2)
|
||||
change_icon.addAction(action3)
|
||||
change_icon.addAction(action4)
|
||||
change_icon.addAction(action5)
|
||||
change_icon.addAction(action6)
|
||||
|
||||
action1.triggered.connect(lambda: self.change_icon('星宿'))
|
||||
action2.triggered.connect(lambda: self.change_icon('度假'))
|
||||
action3.triggered.connect(lambda: self.change_icon('冰淇淋'))
|
||||
action4.triggered.connect(lambda: self.change_icon('学习'))
|
||||
action5.triggered.connect(lambda: self.change_icon('工作'))
|
||||
action6.triggered.connect(lambda: self.change_icon('购物'))
|
||||
|
||||
# 查看右键时是否在item上面,如果不在.就不显示删除和修改.
|
||||
pop_menu.addAction(rename_action)
|
||||
|
||||
if self.system_listWidget.itemAt(position):
|
||||
pop_menu.addAction(del_action)
|
||||
pop_menu.addAction(rename_action)
|
||||
# pop_menu.addAction(change_icon)
|
||||
pop_menu.addMenu(change_icon)
|
||||
|
||||
rename_action.triggered.connect(self.rename_item)
|
||||
# copy_action.triggered.connect(self.create_item)
|
||||
del_action.triggered.connect(self.delete_item)
|
||||
pop_menu.exec_(self.system_listWidget.mapToGlobal(position))
|
||||
|
||||
def change_icon(self, icon):
|
||||
# print(icon)
|
||||
load_list = get_todo_list()
|
||||
change_value(load_list[self.system_listWidget.currentRow() - 2][1], 'icon', icon)
|
||||
self.initUI()
|
||||
|
||||
# 加载左侧列表
|
||||
def load_item(self, list_name, uid):
|
||||
item = SelfListWidgetItem(list_name, 0, uid)
|
||||
|
||||
def load_item(self, list_name, uid, icon=None):
|
||||
# print(icon)
|
||||
# self.stackedWidget.currentChanged.connect(self.change)
|
||||
item = SelfListWidgetItem(list_name, 0, uid, os.getcwd() + '/../images/icon/' + icon + '.svg')
|
||||
item.setTextAlignment(Qt.AlignCenter)
|
||||
# 使得item是可以编辑的.
|
||||
item.setFlags(item.flags() | Qt.ItemIsEditable)
|
||||
self.system_listWidget.addItem(item)
|
||||
todo_list = ToDoList(list_name, uid)
|
||||
# 信号测试成功!!
|
||||
# 更新重要内容
|
||||
# 更新 重要 内容
|
||||
todo_list.update_signal.connect(self.important.refresh_action)
|
||||
todo_list.update_signal.connect(self.my_day.refresh_action)
|
||||
|
||||
# 删除分组时可用
|
||||
self.important.update_signal.connect(todo_list.refresh_action)
|
||||
self.important.update_signal.connect(self.my_day.refresh_action)
|
||||
self.my_day.update_signal.connect(todo_list.refresh_action)
|
||||
self.my_day.update_signal.connect(self.important.refresh_action)
|
||||
|
||||
self.update_signal.connect(todo_list.refresh_action)
|
||||
# 创建后就可以编辑item,用户自己起名字.
|
||||
# self.system_listWidget.editItem(item)
|
||||
self.stackedWidget.addWidget(todo_list)
|
||||
|
||||
self.system_listWidget.setItemWidget(item, item.widget)
|
||||
|
||||
def change(self):
|
||||
print(1)
|
||||
# 点击创建新的分组
|
||||
def create_item(self, new_list='新建列表', uid=None):
|
||||
# 创建一个没有名字的item
|
||||
|
@ -152,67 +196,47 @@ class MainWidget(QWidget):
|
|||
todo_list = ToDoList(new_list, create_todo_uid)
|
||||
|
||||
self.stackedWidget.addWidget(todo_list)
|
||||
# 创建后就可以编辑item,用户自己起名字.
|
||||
# self.system_listWidget.editItem(item)
|
||||
self.system_listWidget.setItemWidget(item, item.widget)
|
||||
|
||||
# 删除分组
|
||||
def delete_item(self):
|
||||
# print(self.load_list[self.system_listWidget.currentRow() - 2][1])
|
||||
remove_todo_list(self.load_list[self.system_listWidget.currentRow() - 2][1])
|
||||
load_list = get_todo_list()
|
||||
remove_todo_list(load_list[self.system_listWidget.currentRow() - 2][1])
|
||||
self.system_listWidget.takeItem(self.system_listWidget.currentRow())
|
||||
|
||||
# 重命名分组
|
||||
# todo : 重命名还没做好
|
||||
def rename_item(self):
|
||||
dialog = QDialog()
|
||||
dialog.setWindowTitle('重命名')
|
||||
dialog_layout = QGridLayout()
|
||||
dialog.resize(300, 200)
|
||||
dialog.setLayout(dialog_layout)
|
||||
# curRow = self.todo_list.currentRow()
|
||||
# item = self.todo_list.item(curRow)
|
||||
|
||||
self.dialog = QDialog()
|
||||
self.dialog.setWindowTitle('重命名')
|
||||
self.dialog_layout = QVBoxLayout()
|
||||
self.dialog.resize(300, 200)
|
||||
self.dialog.setLayout(self.dialog_layout)
|
||||
line_edit = QLineEdit()
|
||||
# line_edit.setObjectName('rename_line')
|
||||
line_edit.setStyleSheet('border: 1px solid;background:transparent;min-width:400px;')
|
||||
line_edit.setPlaceholderText('请输入新的名字')
|
||||
dialog_layout.addWidget(line_edit, 0, 1, 1, 2)
|
||||
self.confirm_button = QPushButton('确认修改')
|
||||
dialog_layout.addWidget(self.confirm_button, 1, 1)
|
||||
# self.load_list = get_todo_list()
|
||||
line_edit.textChanged.connect(self.confirm_action)
|
||||
self.dialog_layout.addWidget(line_edit)
|
||||
confirm_button = QPushButton('确认修改')
|
||||
self.dialog_layout.addWidget(confirm_button)
|
||||
confirm_button.setStyleSheet('background-color:#bcbcbc;border-radius:5px;')
|
||||
confirm_button.clicked.connect(lambda: self.change_name(line_edit.text()))
|
||||
|
||||
# if line_edit.text() != '':
|
||||
# change_value(self.load_list[self.system_listWidget.currentRow() - 2][1], 'title', line_edit.text())
|
||||
# self.confirm_button.clicked.connect(self.initUI)
|
||||
dialog.exec_()
|
||||
#
|
||||
# curRow = self.system_listWidget.currentRow()
|
||||
# item = self.system_listWidget.item(curRow)
|
||||
# item.setFlags(item.flags() | Qt.ItemIsEditable)
|
||||
# self.system_listWidget.editItem(item)
|
||||
# self.system_listWidget.itemChanged.connect(lambda: self.ChangeItem(item))
|
||||
self.dialog.exec_()
|
||||
|
||||
def ChangeItem(self, item):
|
||||
print(item)
|
||||
|
||||
print("test")
|
||||
|
||||
def confirm_action(self, text):
|
||||
# print(text)
|
||||
self.load_list = get_todo_list()
|
||||
change_value(self.load_list[self.system_listWidget.currentRow() - 2][1], 'title', text)
|
||||
self.confirm_button.clicked.connect(self.load_ui)
|
||||
# self.system_listWidget.itemChanged.connect(lambda: self.ChangeItem(text))
|
||||
|
||||
pass
|
||||
|
||||
def load_ui(self):
|
||||
# 先清除列表,方便后面调用
|
||||
self.system_listWidget.clear()
|
||||
# 系统默认的两个 item
|
||||
self.system_listWidget.addItem(self.one_day)
|
||||
self.system_listWidget.setItemWidget(self.one_day, self.one_day.widget)
|
||||
|
||||
self.system_listWidget.addItem(self.important_item)
|
||||
self.system_listWidget.setItemWidget(self.important_item, self.important_item.widget)
|
||||
self.close()
|
||||
def change_name(self, item_name):
|
||||
# print(item_name)
|
||||
load_list = get_todo_list()
|
||||
change_value(load_list[self.system_listWidget.currentRow() - 2][1], 'title', item_name)
|
||||
self.update_signal.emit()
|
||||
# 重命名发送信号
|
||||
self.initUI()
|
||||
# self.update_signal.emit()
|
||||
self.dialog.close()
|
||||
|
||||
|
||||
class MainWindow(QWidget):
|
||||
|
@ -233,7 +257,7 @@ if __name__ == "__main__":
|
|||
main = MainWindow()
|
||||
main.setWindowTitle('PyQtToDoList')
|
||||
# print(os.path.abspath('../'))
|
||||
style_sheet = QSSLoader.read_qss_file('../resource/current.qss')
|
||||
style_sheet = QSSLoader.read_qss_file(os.getcwd() + '/../resource/current.qss')
|
||||
main.setStyleSheet(style_sheet)
|
||||
|
||||
app.setWindowIcon(QIcon(os.path.abspath('../') + '/images/todo.svg'))
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
|
||||
self.leftWidget =QListWidget()
|
||||
#禁止双击可编辑
|
||||
self.leftWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
#右键菜单
|
||||
self.leftWidget.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
self.leftWidget.customContextMenuRequested.connect(self.myListWidgetContext)
|
||||
|
||||
def myListWidgetContext(self,position):
|
||||
#弹出菜单
|
||||
popMenu = QMenu()
|
||||
creAct =QAction("新建分组",self)
|
||||
delAct =QAction("删除分组",self)
|
||||
renameAct =QAction(u'重命名', self)
|
||||
#查看右键时是否在item上面,如果不在.就不显示删除和修改.
|
||||
popMenu.addAction(creAct)
|
||||
if self.leftWidget.itemAt(position):
|
||||
popMenu.addAction(delAct)
|
||||
popMenu.addAction(renameAct)
|
||||
|
||||
creAct.triggered.connect(self.CreateNewItem)
|
||||
renameAct.triggered.connect(self.RenameItem)
|
||||
delAct.triggered.connect(self.DeleteItem)
|
||||
popMenu.exec_(self.leftWidget.mapToGlobal(position))
|
||||
|
||||
#创建新的分组
|
||||
def CreateNewItem(self):
|
||||
#创建一个没有名字的item
|
||||
item =QListWidgetItem("")
|
||||
item.setTextAlignment(Qt.AlignCenter)
|
||||
#使得item是可以编辑的.
|
||||
item.setFlags(item.flags() | Qt.ItemIsEditable)
|
||||
self.leftWidget.addItem(item)
|
||||
#创建后就可以编辑item,用户自己起名字.
|
||||
self.leftWidget.editItem(item)
|
||||
|
||||
|
||||
|
||||
#删除分组
|
||||
def DeleteItem(self):
|
||||
self.leftWidget.takeItem(self.leftWidget.currentRow())
|
||||
|
||||
#重命名分组
|
||||
def RenameItem(self):
|
||||
curRow =self.leftWidget.currentRow()
|
||||
item=self.leftWidget.item(curRow)
|
||||
item.setFlags(item.flags() | Qt.ItemIsEditable)
|
||||
self.leftWidget.editItem(item)
|
||||
self.leftWidget.itemChanged.connect(lambda :self.ChangeItem(item))
|
||||
|
||||
|
||||
def ChangeItem(self,item):
|
||||
print("test")
|
||||
|
|
@ -74,7 +74,8 @@ def get_todo_list():
|
|||
# try:
|
||||
if json_file['itemType'] == 'ToDoList':
|
||||
# print(json_file['title'], json_file['uid'], '列表')
|
||||
return_todo_list.append([json_file['title'], json_file['uid'], json_file['updatedAt']])
|
||||
return_todo_list.append(
|
||||
[json_file['title'], json_file['uid'], json_file['updatedAt'], json_file['icon']])
|
||||
|
||||
# print(return_todo_list)
|
||||
return_todo_list.sort(key=get_third)
|
||||
|
@ -188,7 +189,6 @@ def remove_todo_list(uid):
|
|||
# print(os.path.join(root, name))
|
||||
os.remove(os.path.join(root, name))
|
||||
|
||||
|
||||
# print(read_init_file())
|
||||
# webdav_hostname = read_init_file()
|
||||
# print(webdav_hostname[2])
|
||||
|
|
|
@ -28,7 +28,7 @@ def CreateToDo(item_type, name, todo_list_uid=None):
|
|||
if not os.path.exists(todo_list_path):
|
||||
os.mkdir(todo_list_path)
|
||||
default_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
print('<CreateToDo>'+uid)
|
||||
print('<CreateToDo>' + uid)
|
||||
if item_type == 'ToDoList':
|
||||
# print(item_type)
|
||||
try:
|
||||
|
@ -49,6 +49,7 @@ def CreateToDo(item_type, name, todo_list_uid=None):
|
|||
"title": name,
|
||||
"uid": uid,
|
||||
"Theme": '0',
|
||||
"icon": '星宿',
|
||||
"updatedAt": default_time
|
||||
}
|
||||
# library = {
|
||||
|
@ -82,10 +83,39 @@ def CreateToDo(item_type, name, todo_list_uid=None):
|
|||
with open(todo_list_path + '{' + uid + '}.otl', 'w') as f:
|
||||
f.write(json.dumps(out_config, indent=4, ensure_ascii=False))
|
||||
return uid
|
||||
|
||||
except IOError as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
|
||||
def create_myday_important(item_type, name):
|
||||
uid = str(uuid.uuid4())
|
||||
config_path = BasicUtils.return_work_dir()
|
||||
todo_list_path = config_path + 'ToDoList/'
|
||||
if not os.path.exists(todo_list_path):
|
||||
os.mkdir(todo_list_path)
|
||||
default_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
print('<create_myday_important>' + uid)
|
||||
out_config = {
|
||||
"createdAt": default_time,
|
||||
"done": False,
|
||||
"dueTo": '',
|
||||
"itemType": item_type,
|
||||
"notes": "",
|
||||
"isMyDay": False,
|
||||
"isImportant": False,
|
||||
"title": name,
|
||||
"uid": uid,
|
||||
"updatedAt": default_time
|
||||
}
|
||||
try:
|
||||
if item_type == 'MyDay':
|
||||
with open(todo_list_path + '{' + uid + '}.otl', 'w') as f:
|
||||
f.write(json.dumps(out_config, indent=4, ensure_ascii=False))
|
||||
return uid
|
||||
except IOError as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
#
|
||||
# CreateToDo('ToDo', 'test1', '3f1e033f-2051-4c04-b7f6-afd2eb1f54f4')
|
||||
|
|
|
@ -38,11 +38,3 @@ class AddToDoAction(QLabel):
|
|||
self.setLayout(layout)
|
||||
self.show()
|
||||
|
||||
# def line_edit_action(self):
|
||||
# print('click left button')
|
||||
|
||||
# # 回车添加事件
|
||||
# def line_edit_add(self, name):
|
||||
# self.todo_name.emit(name)
|
||||
# print(name)
|
||||
# self.line_edit.clear()
|
||||
|
|
|
@ -8,6 +8,7 @@ from PyQt5.QtCore import Qt, pyqtSignal
|
|||
|
||||
from utils.BasicUtils import load_myday_important, remove_todo_list, change_value, get_todo, get_myday_important_conf, \
|
||||
change_myday_important_conf
|
||||
from utils.CreateToDo import CreateToDo
|
||||
from view.AddToDoLabel import AddToDoAction
|
||||
from view.ToDoItem import ToDoItem
|
||||
|
||||
|
@ -36,6 +37,9 @@ class Important(QWidget):
|
|||
head_widget = QWidget(self)
|
||||
|
||||
self.todo_list = QListWidget()
|
||||
|
||||
# 关闭滚动条
|
||||
self.todo_list.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.todo_list.setObjectName('todo_list')
|
||||
|
||||
# 添加ToDo的标签
|
||||
|
@ -43,24 +47,14 @@ class Important(QWidget):
|
|||
self.add_todo.line_edit.returnPressed.connect(lambda: self.line_edit_add(self.add_todo.line_edit.text()))
|
||||
|
||||
self.add_todo.setAlignment(Qt.AlignCenter)
|
||||
# self.add_todo.setPlaceholderText('添加任务')
|
||||
|
||||
# head_widget.setMaximumHeight(100)
|
||||
# head_widget.
|
||||
# head_widget.setObjectName('head_widget')
|
||||
head_widget.setAttribute(Qt.WA_StyledBackground)
|
||||
# self.setStyleSheet('#head_widget{margin:50px}')
|
||||
|
||||
# head_widget.setPalette(palette)
|
||||
|
||||
head_widget.setLayout(head_layout)
|
||||
head_layout.setAlignment(Qt.AlignCenter)
|
||||
# head_left_layout = QVBoxLayout()
|
||||
# layout.addStretch(0)
|
||||
|
||||
layout.addWidget(head_widget, 2, Qt.AlignTop)
|
||||
# layout.addSpacing(1)
|
||||
# layout.addStretch(1)
|
||||
# layout.addStretch(0)
|
||||
|
||||
layout.addWidget(self.todo_list, 6, Qt.AlignCenter | Qt.AlignTop)
|
||||
head_label = QLabel("重要")
|
||||
head_label.setObjectName('head_label')
|
||||
|
@ -163,7 +157,6 @@ class Important(QWidget):
|
|||
self.todo_list.addItem(todo_item)
|
||||
self.todo_list.setItemWidget(todo_item, todo_item.widget)
|
||||
|
||||
# todo : 下面的方法实现点击更换主题的功能
|
||||
def menu_action(self, count):
|
||||
# 点击按钮
|
||||
count = str(count)
|
||||
|
@ -178,7 +171,9 @@ class Important(QWidget):
|
|||
if name:
|
||||
self.add_todo.todo_name.emit(name)
|
||||
# print('添加的新ToDo:' + name)
|
||||
todo_item = ToDoItem(name)
|
||||
create_todo = CreateToDo('Todo', name)
|
||||
change_value(create_todo, 'isImportant', True)
|
||||
todo_item = ToDoItem(name, create_todo)
|
||||
self.todo_list.addItem(todo_item)
|
||||
self.todo_list.setItemWidget(todo_item, todo_item.widget)
|
||||
self.add_todo.line_edit.clear()
|
||||
|
@ -200,28 +195,30 @@ class Important(QWidget):
|
|||
del_action = QAction("删除", self)
|
||||
|
||||
# 查看右键时是否在item上面,如果不在.就不显示删除和修改.
|
||||
pop_menu.addAction(rename_action)
|
||||
if self.todo_list.itemAt(position):
|
||||
pop_menu.addAction(mark_myday)
|
||||
pop_menu.addAction(mark_important)
|
||||
pop_menu.addAction(del_action)
|
||||
pop_menu.addAction(rename_action)
|
||||
|
||||
mark_myday.triggered.connect(lambda: self.make_action('MyDay'))
|
||||
rename_action.triggered.connect(self.rename_item)
|
||||
# copy_action.triggered.connect(self.create_item)
|
||||
del_action.triggered.connect(self.delete_item)
|
||||
mark_important.triggered.connect(self.make_important)
|
||||
mark_important.triggered.connect(lambda: self.make_action('Important'))
|
||||
pop_menu.exec_(self.todo_list.mapToGlobal(position))
|
||||
|
||||
def make_important(self):
|
||||
def make_action(self, make_type):
|
||||
# print(self.todo_list.currentRow())
|
||||
my_day_list = load_myday_important('Important')
|
||||
# load_todo = get_todo(my_day_list[self.todo_list.currentRow()][1])
|
||||
uid = my_day_list[self.todo_list.currentRow()][1]
|
||||
self.todo_list.takeItem(self.todo_list.currentRow())
|
||||
# print('<ToDoListView> uid:', uid)
|
||||
change_value(uid, 'isImportant', False)
|
||||
# 暂时不需要发送信号
|
||||
load_todo = load_myday_important('Important')
|
||||
print(load_todo)
|
||||
uid = load_todo[self.todo_list.currentRow()][1]
|
||||
if make_type == 'MyDay':
|
||||
change_value(uid, 'isMyDay', True)
|
||||
elif make_type == 'Important':
|
||||
change_value(uid, 'isImportant', False)
|
||||
self.todo_list.takeItem(self.todo_list.currentRow())
|
||||
self.refresh_action()
|
||||
|
||||
self.update_signal.emit()
|
||||
|
||||
# 删除分组
|
||||
|
@ -257,9 +254,6 @@ class Important(QWidget):
|
|||
|
||||
self.dialog.exec_()
|
||||
|
||||
# 重命名发送信号
|
||||
# self.update_signal.emit()
|
||||
|
||||
def change_name(self, item_name):
|
||||
print(item_name)
|
||||
my_day_list = load_myday_important('Important')
|
||||
|
|
|
@ -3,7 +3,7 @@ from PyQt5.QtGui import *
|
|||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import Qt, pyqtSignal
|
||||
|
||||
from utils.BasicUtils import load_myday_important, remove_todo_list, change_value
|
||||
from utils.BasicUtils import load_myday_important, remove_todo_list, change_value, change_myday_important_conf
|
||||
from utils.CreateToDo import CreateToDo
|
||||
from view.AddToDoLabel import AddToDoAction
|
||||
from view.MyDayHeadLabel import HeadLabel
|
||||
|
@ -41,6 +41,8 @@ class MyDay(QWidget):
|
|||
|
||||
head_widget.setAttribute(Qt.WA_StyledBackground)
|
||||
self.todo_list = QListWidget()
|
||||
# 关闭滚动条
|
||||
self.todo_list.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.todo_list.setFrameShape(QListWidget.NoFrame)
|
||||
self.todo_list.setObjectName('todo_list')
|
||||
|
||||
|
@ -86,6 +88,15 @@ class MyDay(QWidget):
|
|||
|
||||
self.menu_image.setMenu(self.button_menu)
|
||||
|
||||
refresh_label = QAction(self)
|
||||
refresh_label.setText('刷新')
|
||||
refresh_label.setIcon(QIcon('../images/refresh.svg'))
|
||||
# refresh_label.setDisabled(True)
|
||||
self.button_menu.addAction(refresh_label)
|
||||
self.button_menu.addSeparator()
|
||||
refresh_label.triggered.connect(self.refresh_action)
|
||||
self.menu_image.addAction(refresh_label)
|
||||
|
||||
theme_label = QAction(self)
|
||||
theme_label.setText('主题')
|
||||
theme_label.setDisabled(True)
|
||||
|
@ -121,12 +132,10 @@ class MyDay(QWidget):
|
|||
label_action5.setText('背景5')
|
||||
label_action5.triggered.connect(lambda: self.menu_action(5))
|
||||
self.button_menu.addAction(label_action5)
|
||||
# 右键菜单
|
||||
self.todo_list.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
self.todo_list.customContextMenuRequested.connect(self.todo_list_context)
|
||||
|
||||
# my_day_list = load_myday_important('MyDay')
|
||||
#
|
||||
# if my_day_list:
|
||||
# for my_day in my_day_list:
|
||||
# self.load_myday(my_day[0], my_day[1])
|
||||
self.refresh_action()
|
||||
|
||||
def refresh_action(self):
|
||||
|
@ -138,50 +147,28 @@ class MyDay(QWidget):
|
|||
for my_day in my_day_list:
|
||||
self.load_myday(my_day[0], my_day[1])
|
||||
|
||||
# def initUI(self):
|
||||
# print('<MyDayView>(initUI)')
|
||||
# # thread_action = ThreadAction()
|
||||
# # thread_action.change_value_action.connect()
|
||||
#
|
||||
# self.my_day_list = load_myday_important('Important')
|
||||
#
|
||||
# if self.my_day_list:
|
||||
# for my_day in self.my_day_list:
|
||||
# self.load_myday(my_day[0], my_day[1])
|
||||
|
||||
def load_myday(self, name, uid):
|
||||
todo_item = ToDoItem(name, uid)
|
||||
|
||||
self.todo_list.addItem(todo_item)
|
||||
self.todo_list.setItemWidget(todo_item, todo_item.widget)
|
||||
|
||||
|
||||
def menu_action(self, count):
|
||||
|
||||
count = str(count)
|
||||
# 点击按钮
|
||||
|
||||
change_myday_important_conf('MyDay', 'theme', count)
|
||||
self.setStyleSheet('#my_day{background-image:url("../images/' + count + '.jpg");'
|
||||
'background-position: center; border-radius: 10px;'
|
||||
'}')
|
||||
# self.head_label.show()
|
||||
|
||||
print('<MyDayView> 选中:' + count)
|
||||
|
||||
#
|
||||
# def add_todo_action(self, name):
|
||||
# print(name)
|
||||
# todo : 回车添加事件
|
||||
# 回车添加事件
|
||||
def line_edit_add(self, name):
|
||||
if name:
|
||||
self.add_todo.todo_name.emit(name)
|
||||
# print('添加的新ToDo:' + name)
|
||||
create_todo = CreateToDo('Todo', name, self.uid)
|
||||
todo_item = ToDoItem(name, create_todo)
|
||||
|
||||
todo_item = ToDoItem(name)
|
||||
self.todo_list.addItem(todo_item)
|
||||
self.todo_list.setItemWidget(todo_item, todo_item.widget)
|
||||
|
||||
self.add_todo.line_edit.clear()
|
||||
|
||||
def todo_list_context(self, position):
|
||||
|
@ -201,34 +188,42 @@ class MyDay(QWidget):
|
|||
del_action = QAction("删除", self)
|
||||
|
||||
# 查看右键时是否在item上面,如果不在.就不显示删除和修改.
|
||||
pop_menu.addAction(rename_action)
|
||||
if self.todo_list.itemAt(position):
|
||||
pop_menu.addAction(mark_myday)
|
||||
pop_menu.addAction(mark_important)
|
||||
pop_menu.addAction(del_action)
|
||||
pop_menu.addAction(rename_action)
|
||||
|
||||
mark_myday.triggered.connect(lambda: self.make_action('MyDay'))
|
||||
rename_action.triggered.connect(self.rename_item)
|
||||
# copy_action.triggered.connect(self.create_item)
|
||||
|
||||
del_action.triggered.connect(self.delete_item)
|
||||
mark_important.triggered.connect(self.make_important)
|
||||
mark_important.triggered.connect(lambda: self.make_action('Important'))
|
||||
|
||||
pop_menu.exec_(self.todo_list.mapToGlobal(position))
|
||||
|
||||
def make_important(self):
|
||||
# 设置右键点击事件
|
||||
def make_action(self, make_type):
|
||||
# print(self.todo_list.currentRow())
|
||||
my_day_list = load_myday_important('Important')
|
||||
# load_todo = get_todo(my_day_list[self.todo_list.currentRow()][1])
|
||||
uid = my_day_list[self.todo_list.currentRow()][1]
|
||||
self.todo_list.takeItem(self.todo_list.currentRow())
|
||||
# print('<ToDoListView> uid:', uid)
|
||||
change_value(uid, 'isImportant', True)
|
||||
# 暂时不需要发送信号
|
||||
load_todo = load_myday_important(make_type)
|
||||
uid = load_todo[self.todo_list.currentRow()][1]
|
||||
if make_type == 'MyDay':
|
||||
change_value(uid, 'isMyDay', False)
|
||||
self.todo_list.takeItem(self.todo_list.currentRow())
|
||||
elif make_type == 'Important':
|
||||
change_value(uid, 'isImportant', True)
|
||||
self.refresh_action()
|
||||
|
||||
#
|
||||
# load_todo = load_myday_important('MyDay')
|
||||
# uid = load_todo[self.todo_list.currentRow()][1]
|
||||
|
||||
self.update_signal.emit()
|
||||
|
||||
# 删除分组
|
||||
def delete_item(self):
|
||||
# print(self.load_list[self.system_listWidget.currentRow() - 2][1])
|
||||
my_day_list = load_myday_important('Important')
|
||||
my_day_list = load_myday_important('MyDay')
|
||||
# load_todo = get_todo(my_day_list[self.todo_list.currentRow()][1])
|
||||
uid = my_day_list[self.todo_list.currentRow()][1]
|
||||
remove_todo_list(uid)
|
||||
|
@ -236,16 +231,32 @@ class MyDay(QWidget):
|
|||
self.todo_list.takeItem(self.todo_list.currentRow())
|
||||
self.update_signal.emit()
|
||||
|
||||
# 重命名分组
|
||||
# 重命名分组
|
||||
|
||||
def rename_item(self):
|
||||
curRow = self.todo_list.currentRow()
|
||||
item = self.todo_list.item(curRow)
|
||||
item.setFlags(item.flags() | Qt.ItemIsEditable)
|
||||
self.todo_list.editItem(item)
|
||||
self.todo_list.itemChanged.connect(lambda: self.ChangeItem(item))
|
||||
|
||||
def ChangeItem(self, item):
|
||||
print(item)
|
||||
self.dialog = QDialog()
|
||||
self.dialog.setWindowTitle('重命名')
|
||||
self.dialog_layout = QVBoxLayout()
|
||||
self.dialog.resize(300, 200)
|
||||
self.dialog.setLayout(self.dialog_layout)
|
||||
line_edit = QLineEdit()
|
||||
# line_edit.setObjectName('rename_line')
|
||||
line_edit.setStyleSheet('border: 1px solid;background:transparent;min-width:400px;')
|
||||
line_edit.setPlaceholderText('请输入新的名字')
|
||||
self.dialog_layout.addWidget(line_edit)
|
||||
confirm_button = QPushButton('确认修改')
|
||||
self.dialog_layout.addWidget(confirm_button)
|
||||
confirm_button.setStyleSheet('background-color:#bcbcbc;border-radius:5px;')
|
||||
confirm_button.clicked.connect(lambda: self.change_name(line_edit.text()))
|
||||
|
||||
print("test")
|
||||
self.dialog.exec_()
|
||||
|
||||
def change_name(self, item_name):
|
||||
print(item_name)
|
||||
my_day_list = load_myday_important('Important')
|
||||
change_value(my_day_list[self.todo_list.currentRow()][1], 'title', item_name)
|
||||
# 重命名发送信号
|
||||
self.refresh_action()
|
||||
self.update_signal.emit()
|
||||
self.dialog.close()
|
||||
|
|
|
@ -26,8 +26,6 @@ class SelfListWidgetItem(QListWidgetItem):
|
|||
self.widget = QWidget()
|
||||
self.widget.setLayout(layout)
|
||||
|
||||
# self.list_item = QLabel('')
|
||||
|
||||
# 添加左边的图标和右边的气泡
|
||||
if self.show_icon:
|
||||
self.icon_label = QLabel('')
|
||||
|
|
|
@ -42,15 +42,16 @@ class ToDoItem(QListWidgetItem):
|
|||
layout.addWidget(self.todo_label, 6)
|
||||
layout.addWidget(self.important_button, 2)
|
||||
|
||||
self.mark_icon.clicked.connect(self.set_done)
|
||||
self.mark_icon.clicked.connect(lambda: self.set_done(uid))
|
||||
# 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)
|
||||
def set_done(self, uid):
|
||||
self.mark_icon.setIcon(QIcon(os.getcwd() + '/../images/finished.svg'))
|
||||
time.sleep(0.2)
|
||||
change_value(uid, 'done', True)
|
||||
pass
|
||||
|
||||
def set_myday(self, uid):
|
||||
|
@ -61,7 +62,7 @@ class ToDoItem(QListWidgetItem):
|
|||
# important = Important()
|
||||
# important.load_important.emit()
|
||||
# self.action.emit()
|
||||
print('<ToDoItem>',uid)
|
||||
print('<ToDoItem>', uid)
|
||||
|
||||
change_value(uid, 'isImportant', True)
|
||||
# self.transaction.emit()
|
||||
|
|
|
@ -36,6 +36,8 @@ class ToDoList(QWidget):
|
|||
# head_widget.setMinimumHeight(175)
|
||||
|
||||
self.todo_list = QListWidget()
|
||||
# 关闭滚动条
|
||||
self.todo_list.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.todo_list.setObjectName('todo_list')
|
||||
|
||||
# 添加ToDo的标签
|
||||
|
@ -43,24 +45,13 @@ class ToDoList(QWidget):
|
|||
self.add_todo.line_edit.returnPressed.connect(lambda: self.line_edit_add(self.add_todo.line_edit.text()))
|
||||
|
||||
self.add_todo.setAlignment(Qt.AlignCenter)
|
||||
# self.add_todo.setPlaceholderText('添加任务')
|
||||
|
||||
# head_widget.setMaximumHeight(100)
|
||||
# head_widget.
|
||||
# head_widget.setObjectName('head_widget')
|
||||
head_widget.setAttribute(Qt.WA_StyledBackground)
|
||||
# self.setStyleSheet('#head_widget{margin:50px}')
|
||||
|
||||
# head_widget.setPalette(palette)
|
||||
|
||||
head_widget.setLayout(head_layout)
|
||||
head_layout.setAlignment(Qt.AlignCenter)
|
||||
# head_left_layout = QVBoxLayout()
|
||||
# layout.addStretch(0)
|
||||
|
||||
layout.addWidget(head_widget, 2, Qt.AlignTop)
|
||||
# layout.addSpacing(1)
|
||||
# layout.addStretch(1)
|
||||
# layout.addStretch(0)
|
||||
|
||||
layout.addWidget(self.todo_list, 6, Qt.AlignCenter | Qt.AlignTop)
|
||||
head_label = QLabel(list_name)
|
||||
head_label.setObjectName('head_label')
|
||||
|
@ -102,15 +93,7 @@ class ToDoList(QWidget):
|
|||
theme_label.setDisabled(True)
|
||||
self.button_menu.addAction(theme_label)
|
||||
self.button_menu.addSeparator()
|
||||
#
|
||||
# for i in range(11):
|
||||
# label_action = QAction(self)
|
||||
# label_action.setIcon(QIcon('../images/' + str(i) + '.jpg'))
|
||||
# label_action.setText(str(i))
|
||||
# label_action.triggered.connect(lambda: self.menu_action(str(i)))
|
||||
# self.button_menu.addAction(label_action)
|
||||
|
||||
# for i in range(11):
|
||||
label_action1 = QAction(self)
|
||||
label_action1.setIcon(QIcon('../images/1.jpg'))
|
||||
label_action1.setText('背景1')
|
||||
|
@ -152,9 +135,9 @@ class ToDoList(QWidget):
|
|||
# thread_action = ThreadAction()
|
||||
self.load_theme()
|
||||
|
||||
self.loadtodo = get_todo(self.uid)
|
||||
if self.loadtodo:
|
||||
for load in self.loadtodo:
|
||||
load_todo = get_todo(self.uid)
|
||||
if load_todo:
|
||||
for load in load_todo:
|
||||
self.load_todo(load[0], load[1])
|
||||
|
||||
def load_theme(self):
|
||||
|
@ -186,15 +169,16 @@ class ToDoList(QWidget):
|
|||
# self.my_day_list[]
|
||||
self.todo_list.clear()
|
||||
# print(self.my_day_list)
|
||||
self.loadtodo = get_todo(self.uid)
|
||||
if self.loadtodo:
|
||||
for load in self.loadtodo:
|
||||
load_todo = get_todo(self.uid)
|
||||
if load_todo:
|
||||
for load in load_todo:
|
||||
self.load_todo(load[0], load[1])
|
||||
|
||||
def line_edit_add(self, name):
|
||||
if name:
|
||||
self.add_todo.todo_name.emit(name)
|
||||
# print('添加的新ToDo:' + name)
|
||||
|
||||
create_todo = CreateToDo('Todo', name, self.uid)
|
||||
todo_item = ToDoItem(name, create_todo)
|
||||
|
||||
|
@ -220,25 +204,28 @@ class ToDoList(QWidget):
|
|||
del_action = QAction("删除", self)
|
||||
|
||||
# 查看右键时是否在item上面,如果不在.就不显示删除和修改.
|
||||
pop_menu.addAction(rename_action)
|
||||
# pop_menu.addAction(rename_action)
|
||||
if self.todo_list.itemAt(position):
|
||||
pop_menu.addAction(mark_myday)
|
||||
pop_menu.addAction(mark_important)
|
||||
pop_menu.addAction(del_action)
|
||||
pop_menu.addAction(rename_action)
|
||||
|
||||
mark_myday.triggered.connect(lambda: self.make_action('MyDay'))
|
||||
rename_action.triggered.connect(self.rename_item)
|
||||
# copy_action.triggered.connect(self.create_item)
|
||||
del_action.triggered.connect(self.delete_item)
|
||||
mark_important.triggered.connect(self.make_important)
|
||||
mark_important.triggered.connect(lambda: self.make_action('Important'))
|
||||
pop_menu.exec_(self.todo_list.mapToGlobal(position))
|
||||
|
||||
def make_important(self):
|
||||
print(self.todo_list.currentRow())
|
||||
def make_action(self, make_type):
|
||||
# print(self.todo_list.currentRow())
|
||||
load_todo = get_todo(self.uid)
|
||||
uid = load_todo[self.todo_list.currentRow()][1]
|
||||
# print('<ToDoListView> uid:', uid)
|
||||
change_value(uid, 'isImportant', True)
|
||||
if make_type == 'MyDay':
|
||||
change_value(uid, 'isMyDay', True)
|
||||
elif make_type == 'Important':
|
||||
change_value(uid, 'isImportant', True)
|
||||
|
||||
self.update_signal.emit()
|
||||
|
||||
# 删除分组
|
||||
|
@ -254,21 +241,38 @@ class ToDoList(QWidget):
|
|||
# 重命名分组
|
||||
# todo : 复制重要代码
|
||||
def rename_item(self):
|
||||
curRow = self.todo_list.currentRow()
|
||||
item = self.todo_list.item(curRow)
|
||||
item.setFlags(item.flags() | Qt.ItemIsEditable)
|
||||
self.todo_list.editItem(item)
|
||||
self.todo_list.itemChanged.connect(lambda: self.ChangeItem(item))
|
||||
self.dialog = QDialog()
|
||||
self.dialog.setWindowTitle('重命名')
|
||||
self.dialog_layout = QVBoxLayout()
|
||||
self.dialog.resize(300, 200)
|
||||
self.dialog.setLayout(self.dialog_layout)
|
||||
line_edit = QLineEdit()
|
||||
# line_edit.setObjectName('rename_line')
|
||||
line_edit.setStyleSheet('border: 1px solid;background:transparent;min-width:400px;')
|
||||
line_edit.setPlaceholderText('请输入新的名字')
|
||||
self.dialog_layout.addWidget(line_edit)
|
||||
confirm_button = QPushButton('确认修改')
|
||||
self.dialog_layout.addWidget(confirm_button)
|
||||
confirm_button.setStyleSheet('background-color:#bcbcbc;border-radius:5px;')
|
||||
confirm_button.clicked.connect(lambda: self.change_name(line_edit.text()))
|
||||
|
||||
self.dialog.exec_()
|
||||
|
||||
def change_name(self, item_name):
|
||||
# print(item_name)
|
||||
load_todo = get_todo(self.uid)
|
||||
# load_todo = get_todo(my_day_list[self.todo_list.currentRow()][1])
|
||||
uid = load_todo[self.todo_list.currentRow()][1]
|
||||
change_value(uid, 'title', item_name)
|
||||
# 重命名发送信号
|
||||
self.refresh_action()
|
||||
self.update_signal.emit()
|
||||
|
||||
def ChangeItem(self, item):
|
||||
print(item)
|
||||
|
||||
print("test")
|
||||
self.dialog.close()
|
||||
|
||||
def mark_done(self, uid):
|
||||
print('mark done:', uid)
|
||||
|
||||
self.update_signal.emit()
|
||||
|
||||
def mark_important(self, uid):
|
||||
self.update_signal.emit()
|
||||
pass
|
||||
|
|