设置功能完成!
This commit is contained in:
parent
ecbd96455f
commit
95bc38cc39
8 changed files with 150 additions and 141 deletions
|
@ -7,13 +7,11 @@
|
|||
- [x] 待办事项列表布局实现
|
||||
- [x] 添加待办事项列表
|
||||
- [x] 待办事项列表功能实现
|
||||
- [ ] 待办事项列表右键功能实现
|
||||
- [x] 待办事项列表右键功能实现
|
||||
- [x] 右边`QStackLayout`布局
|
||||
- [x] “我的一天”和“重要”布局实现
|
||||
- [x] 添加的通用布局实现
|
||||
- [x] 更换主题功能
|
||||
- [ ] 登录`nextcloud`及其他`WebDav`和同步功能
|
||||
- [ ] 添加“设置”功能
|
||||
- [ ] 拖拽排序功能
|
||||
- [ ] 待办事项的笔记功能
|
||||
- [ ] 最小化到任务栏功能
|
||||
- [x] 最小化到任务栏功能
|
|
@ -6,6 +6,7 @@ from PyQt5.QtCore import Qt, pyqtSignal
|
|||
import configparser
|
||||
|
||||
from utils.BasicUtils import get_todo_list, remove_todo_list, change_value, read_ini, set_exit_status
|
||||
from utils.CreateConfigure import CreateConfigure
|
||||
from utils.CreateToDo import CreateToDo
|
||||
from utils.QSSLoader import QSSLoader
|
||||
from view.ImportantView import Important
|
||||
|
@ -23,6 +24,7 @@ class MainWidget(QWidget):
|
|||
def __init__(self):
|
||||
super(MainWidget, self).__init__()
|
||||
self.user_label = User()
|
||||
self.create_config = CreateConfigure()
|
||||
# 主布局,左右两侧
|
||||
layout = QHBoxLayout()
|
||||
# 子布局,左边的部分
|
||||
|
@ -88,8 +90,6 @@ class MainWidget(QWidget):
|
|||
self.load_item(load[0], load[1], load[3])
|
||||
# self.system_listWidget.addScrollBarWidget(False)
|
||||
|
||||
# todo 仔细研究右键菜单
|
||||
|
||||
def myListWidgetContext(self, position):
|
||||
if self.system_listWidget.currentRow() > 1:
|
||||
|
||||
|
@ -351,7 +351,6 @@ class MainWindow(QWidget):
|
|||
event.ignore()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
main = MainWindow()
|
||||
|
|
|
@ -1,13 +1,30 @@
|
|||
import configparser
|
||||
import platform
|
||||
import os
|
||||
from utils import BasicUtils
|
||||
|
||||
# todo : 用来创建软件的配置信息
|
||||
from utils.BasicUtils import return_work_dir
|
||||
|
||||
|
||||
class CreateConfigure:
|
||||
|
||||
def __init__(self):
|
||||
config_file = return_work_dir() + 'PyQtToDoList.ini'
|
||||
config = configparser.ConfigParser()
|
||||
if not os.path.exists(config_file):
|
||||
options = {
|
||||
'webdav_hostname': "None",
|
||||
'webdav_login': "None",
|
||||
'webdav_password': "None",
|
||||
'type': "None"
|
||||
}
|
||||
|
||||
config['Account'] = options
|
||||
# todo 解决保存配置文件的问题
|
||||
config['System'] = {'exitStatus': 'None'}
|
||||
|
||||
with open(config_file, 'w') as f:
|
||||
config.write(f)
|
||||
|
||||
"""
|
||||
:param login_type : 登录方式 有 NextCloud、JianGuoYun、WebDav
|
||||
:param webdav_login : 登录用户名
|
||||
|
@ -15,52 +32,40 @@ class CreateConfigure:
|
|||
:param webdav_hostname : 服务地址
|
||||
"""
|
||||
|
||||
def __init__(self, login_type, webdav_login, webdav_password, webdav_hostname=None):
|
||||
def login(self, login_type, webdav_login, webdav_password, webdav_hostname=None):
|
||||
config_file = return_work_dir() + 'PyQtToDoList.ini'
|
||||
config = configparser.ConfigParser()
|
||||
if not os.path.exists(config_file):
|
||||
# print(config_file)
|
||||
options = {}
|
||||
if login_type == 'NextCloud':
|
||||
webdav_hostname = webdav_hostname + '/' if webdav_hostname[-1] != '/' else webdav_hostname
|
||||
options = {
|
||||
'webdav_hostname': webdav_hostname + "remote.php/dav/files/admin/",
|
||||
'webdav_login': webdav_login,
|
||||
'webdav_password': webdav_password,
|
||||
'type': login_type
|
||||
}
|
||||
config.read(config_file)
|
||||
# if not os.path.exists(config_file):
|
||||
print(config['Account']['type'])
|
||||
if login_type == 'NextCloud':
|
||||
webdav_hostname = webdav_hostname + '/' if webdav_hostname[-1] != '/' else webdav_hostname
|
||||
|
||||
elif login_type == 'JianGuoYun':
|
||||
options = {
|
||||
'webdav_hostname': "https://dav.jianguoyun.com/dav/",
|
||||
'webdav_login': webdav_login,
|
||||
'webdav_password': webdav_password,
|
||||
'type': login_type
|
||||
config['Account']['webdav_hostname'] = webdav_hostname + "remote.php/dav/files/admin/"
|
||||
config['Account']['webdav_login'] = webdav_login
|
||||
config['Account']['webdav_password'] = webdav_password
|
||||
config['Account']['type'] = login_type
|
||||
|
||||
}
|
||||
elif login_type == 'WebDav':
|
||||
webdav_hostname = webdav_hostname + '/' if webdav_hostname[-1] != '/' else webdav_hostname
|
||||
options = {
|
||||
'webdav_hostname': webdav_hostname,
|
||||
'webdav_login': webdav_login,
|
||||
'webdav_password': webdav_password,
|
||||
'type': login_type
|
||||
elif login_type == 'JianGuoYun':
|
||||
config['Account']['webdav_hostname'] = "https://dav.jianguoyun.com/dav/"
|
||||
config['Account']['webdav_login'] = webdav_login
|
||||
config['Account']['webdav_password'] = webdav_password
|
||||
config['Account']['type'] = login_type
|
||||
|
||||
}
|
||||
config['Account'] = options
|
||||
config['System'] = {'exitStatus': 'None'}
|
||||
elif login_type == 'WebDav':
|
||||
|
||||
with open(config_file, 'w') as f:
|
||||
config.write(f)
|
||||
print('create complete!', config_file)
|
||||
webdav_hostname = webdav_hostname + '/' if webdav_hostname[-1] != '/' else webdav_hostname
|
||||
config['Account']['webdav_hostname'] = webdav_hostname
|
||||
config['Account']['webdav_login'] = webdav_login
|
||||
config['Account']['webdav_password'] = webdav_password
|
||||
config['Account']['type'] = login_type
|
||||
|
||||
# todo 解决保存配置文件的问题
|
||||
config['System'] = {'exitStatus': 'None'}
|
||||
print(config['System']['exitStatus'])
|
||||
|
||||
with open(config_file, 'w') as f:
|
||||
config.write(f)
|
||||
print('create complete!', config_file)
|
||||
|
||||
# def return_config_file(self):
|
||||
# if platform.system() == 'Linux':
|
||||
# work_path = os.path.expandvars('$HOME') + '/.config/PyQtToDoList'
|
||||
# if not os.path.exists(work_path):
|
||||
# os.mkdir(work_path)
|
||||
# return os.path.expandvars('$HOME') + '/.config/PyQtToDoList/PyQtToDoList.ini'
|
||||
# elif platform.system() == 'Windows':
|
||||
# return os.getcwd() + '/PyQtToDoList.ini'
|
||||
|
||||
# CreateConfigure('NextCloud', 'admin', '19990903@lyp', 'https://cloud.liyp.cc')
|
||||
|
|
|
@ -264,13 +264,15 @@ class Important(QWidget):
|
|||
self.dialog.close()
|
||||
|
||||
def mark_done(self, uid):
|
||||
print('mark done:', uid)
|
||||
# print('mark done:', uid)
|
||||
change_value(uid, 'done', True)
|
||||
time.sleep(0.5)
|
||||
self.refresh_action()
|
||||
self.update_signal.emit()
|
||||
|
||||
def mark_important(self, uid):
|
||||
print('mark important:', uid)
|
||||
change_value(uid, 'isImportant', True)
|
||||
# print('mark important:', uid)
|
||||
self.refresh_action()
|
||||
self.update_signal.emit()
|
||||
|
||||
pass
|
||||
|
|
35
view/SettingWidget.py
Normal file
35
view/SettingWidget.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
from PyQt5.QtCore import Qt, pyqtSignal
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
from utils.BasicUtils import read_ini, set_exit_status
|
||||
|
||||
|
||||
class SettingWidget(QWidget):
|
||||
update_signal = pyqtSignal()
|
||||
|
||||
def __init__(self):
|
||||
super(SettingWidget, self).__init__()
|
||||
self.setWindowTitle('设置')
|
||||
self.resize(400, 300)
|
||||
layout = QFormLayout()
|
||||
self.setLayout(layout)
|
||||
self.combo = QComboBox()
|
||||
exit_status = read_ini('System', 'exitstatus')
|
||||
|
||||
self.combo.addItem('最小化到托盘')
|
||||
self.combo.addItem('退出程序')
|
||||
index = 0
|
||||
if exit_status == 'Exit':
|
||||
index = 1
|
||||
self.combo.setCurrentIndex(index)
|
||||
self.combo.currentIndexChanged.connect(lambda: self.save_exit_status(self.combo.currentIndex()))
|
||||
|
||||
layout.addRow('关闭窗口时', self.combo)
|
||||
|
||||
# layout.addWidget(self.setting_widget)
|
||||
|
||||
def save_exit_status(self, index):
|
||||
print(index)
|
||||
status = ['Mix', 'Exit']
|
||||
set_exit_status(status[index])
|
|
@ -42,28 +42,28 @@ class ToDoItem(QListWidgetItem):
|
|||
layout.addWidget(self.todo_label, 6)
|
||||
layout.addWidget(self.important_button, 2)
|
||||
|
||||
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.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, uid):
|
||||
# # self.mark_icon.setIcon(QIcon(os.getcwd() + '/../images/finished.svg'))
|
||||
# # time.sleep(0.2)
|
||||
# change_value(uid, 'done', True)
|
||||
# pass
|
||||
|
||||
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):
|
||||
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
|
||||
# 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
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import os
|
||||
import time
|
||||
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import Qt, pyqtSignal, QPropertyAnimation, QRect, QEasingCurve
|
||||
|
@ -125,20 +127,22 @@ class ToDoList(QWidget):
|
|||
self.button_menu.addAction(label_action5)
|
||||
self.uid = uid
|
||||
|
||||
self.initUI()
|
||||
self.refresh_action()
|
||||
# 右键菜单
|
||||
self.todo_list.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
self.todo_list.customContextMenuRequested.connect(self.todo_list_context)
|
||||
|
||||
def initUI(self):
|
||||
# 读取配置文件添加Todo
|
||||
# thread_action = ThreadAction()
|
||||
self.load_theme()
|
||||
|
||||
load_todo = get_todo(self.uid)
|
||||
if load_todo:
|
||||
for load in load_todo:
|
||||
self.load_todo(load[0], load[1])
|
||||
#
|
||||
# def initUI(self):
|
||||
# # 读取配置文件添加Todo
|
||||
# # thread_action = ThreadAction()
|
||||
# self.todo_list.clear()
|
||||
#
|
||||
# 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):
|
||||
theme = str(load_value(self.uid, 'Theme'))
|
||||
|
@ -157,13 +161,12 @@ class ToDoList(QWidget):
|
|||
# print('选中:' + count)
|
||||
|
||||
def load_todo(self, name, uid):
|
||||
todo_item = ToDoItem(name, uid)
|
||||
todo_item.mark_icon.clicked.connect(lambda: self.mark_done(uid))
|
||||
todo_item.important_button.clicked.connect(lambda: self.mark_important(uid))
|
||||
# todo_item.mark_icon.trans_signal.connect(self.todo_list.clear())
|
||||
self.todo_item = ToDoItem(name, uid)
|
||||
self.todo_item.mark_icon.clicked.connect(lambda: self.mark_done(uid))
|
||||
self.todo_item.important_button.clicked.connect(lambda: self.mark_important(uid))
|
||||
|
||||
self.todo_list.addItem(todo_item)
|
||||
self.todo_list.setItemWidget(todo_item, todo_item.widget)
|
||||
self.todo_list.addItem(self.todo_item)
|
||||
self.todo_list.setItemWidget(self.todo_item, self.todo_item.widget)
|
||||
|
||||
def refresh_action(self):
|
||||
# self.my_day_list[]
|
||||
|
@ -186,6 +189,8 @@ class ToDoList(QWidget):
|
|||
self.todo_list.setItemWidget(todo_item, todo_item.widget)
|
||||
|
||||
self.add_todo.line_edit.clear()
|
||||
self.refresh_action()
|
||||
# self.initUI()
|
||||
|
||||
def todo_list_context(self, position):
|
||||
# 设置右键菜单
|
||||
|
@ -239,7 +244,7 @@ class ToDoList(QWidget):
|
|||
self.update_signal.emit()
|
||||
|
||||
# 重命名分组
|
||||
# todo : 复制重要代码
|
||||
|
||||
def rename_item(self):
|
||||
self.dialog = QDialog()
|
||||
self.dialog.setWindowTitle('重命名')
|
||||
|
@ -270,8 +275,15 @@ class ToDoList(QWidget):
|
|||
self.dialog.close()
|
||||
|
||||
def mark_done(self, uid):
|
||||
# print('uid:',uid)
|
||||
self.todo_item.mark_icon.setIcon(QIcon(os.getcwd() + '/../images/finished.svg'))
|
||||
print('mark done:', uid)
|
||||
|
||||
time.sleep(0.2)
|
||||
self.todo_list.takeItem(self.todo_list.currentRow())
|
||||
# self.refresh_action()
|
||||
self.update_signal.emit()
|
||||
self.refresh_action()
|
||||
|
||||
def mark_important(self, uid):
|
||||
self.update_signal.emit()
|
||||
|
|
|
@ -1,34 +1,15 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtCore import Qt, pyqtSignal
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
import configparser
|
||||
from utils.BasicUtils import *
|
||||
from view.LoginWidget import LoginWidget
|
||||
|
||||
|
||||
# class LoginWindow(QWidget):
|
||||
# def __init__(self):
|
||||
# super().__init__()
|
||||
# layout = QVBoxLayout()
|
||||
# self.setLayout(layout)
|
||||
# self.setWindowTitle('登录')
|
||||
# self.resize(500, 600)
|
||||
# self.tab_widget = QTabWidget()
|
||||
# self.tab_widget.setStyleSheet('background-color:#f3f3f3')
|
||||
# self.tab_widget.addTab(LoginWidget('NextCloud'), 'NextCloud')
|
||||
# self.tab_widget.addTab(LoginWidget('JianGuoYun'), '坚果云')
|
||||
# self.tab_widget.addTab(LoginWidget('WebDav'), 'WebDav')
|
||||
#
|
||||
# # print('open new window')
|
||||
# # self.stack_widget = QStackedWidget()
|
||||
# # self.show()
|
||||
# layout.addWidget(self.tab_widget)
|
||||
from view.SettingWidget import SettingWidget
|
||||
|
||||
|
||||
class User(QLabel):
|
||||
update_signal = pyqtSignal()
|
||||
|
||||
# 自定义信号, 注意信号必须为类属性
|
||||
# button_clicked_signal = pyqtSignal()
|
||||
|
||||
|
@ -58,31 +39,17 @@ class User(QLabel):
|
|||
self.user_mail.setText(self.account[3])
|
||||
# self.user_mail.setObjectName('user_mail')
|
||||
self.user_mail.setStyleSheet('font-size:14px')
|
||||
# self.menu_label = QLabel('')type
|
||||
# self.menu_label.setObjectName('menu')
|
||||
# self.menu_label.setPixmap(
|
||||
# QPixmap(os.path.abspath('../') + '/images/up-down.svg').scaled(20, 20, Qt.IgnoreAspectRatio,
|
||||
# Qt.SmoothTransformation))
|
||||
|
||||
info_layout.addWidget(self.user_name)
|
||||
info_layout.addWidget(self.user_mail)
|
||||
layout.addLayout(info_layout, 4)
|
||||
layout.addStretch(1)
|
||||
# layout.addWidget(self.menu_label, 1)
|
||||
|
||||
self.widget.setLayout(layout)
|
||||
# 设置右键菜单
|
||||
self.context_menu = QMenu(self)
|
||||
self.init_menu()
|
||||
|
||||
# def mouseReleaseEvent(self, QMouseEvent):
|
||||
# self.button_clicked_signal.emit()
|
||||
#
|
||||
|
||||
# 可在外部与槽函数连接 用处不大
|
||||
# def connect_customized_slot(self, func):
|
||||
# self.button_clicked_signal.connect(func)
|
||||
|
||||
def contextMenuEvent(self, event):
|
||||
self.context_menu.exec_(event.globalPos())
|
||||
|
||||
|
@ -104,6 +71,9 @@ class User(QLabel):
|
|||
# todo 设置右键点击事件
|
||||
|
||||
def setting(self):
|
||||
self.setting_widget = SettingWidget()
|
||||
self.setting_widget.show()
|
||||
|
||||
pass
|
||||
|
||||
def sync(self):
|
||||
|
@ -116,15 +86,3 @@ class User(QLabel):
|
|||
|
||||
self.login_window = LoginWidget()
|
||||
self.login_window.show()
|
||||
|
||||
# if __name__ == '__main__':
|
||||
# app = QApplication(sys.argv)
|
||||
# # 创建窗口
|
||||
# window = User()
|
||||
# # newWin = LoginWindow()
|
||||
#
|
||||
# # 显示窗口
|
||||
# window.show()
|
||||
# # window.collec_btn.clicked.connect(newWin.show)
|
||||
# # 运行应用,并监听事件
|
||||
# sys.exit(app.exec_())
|
||||
|
|
Loading…
Reference in a new issue