实现几个简单功能,现在重要的重命名已经实现,还需要实现最小化、列表重命名时信号传递、重写点击done功能

This commit is contained in:
liyp 2022-04-24 22:29:42 +08:00
parent 179a8c59a4
commit bc7b983a5c
16 changed files with 983 additions and 178 deletions

View file

@ -5,7 +5,8 @@
- [x] 用户信息布局
- [ ] 用户信息右键及功能实现
- [x] 待办事项列表布局实现
- [ ] 待办事项列表功能实现
- [x] 添加待办事项列表
- [x] 待办事项列表功能实现
- [ ] 待办事项列表右键功能实现
- [x] 右边`QStackLayout`布局
- [x] “我的一天”和“重要”布局实现
@ -14,3 +15,5 @@
- [ ] 登录`nextcloud`及其他`WebDav`和同步功能
- [ ] 添加“设置”功能
- [ ] 拖拽排序功能
- [ ] 待办事项的笔记功能
- [ ] 最小化到任务栏功能

View file

@ -1 +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="1648731999752" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18312" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M512 32c265.088 0 480 214.912 480 480 0 265.088-214.912 480-480 480-265.088 0-480-214.912-480-480C32 246.912 246.912 32 512 32z m0 64C282.24 96 96 282.24 96 512s186.24 416 416 416 416-186.24 416-416S741.76 96 512 96z m254.4 257.6a32 32 0 0 1 0 45.248l-271.552 271.552a32 32 0 0 1-48.704-4.096 33.216 33.216 0 0 1-5.568-4.48l-158.4-158.4a32 32 0 1 1 45.248-45.248l144.576 144.576 249.152-249.152a32 32 0 0 1 45.248 0z" p-id="18313" fill="#e6e6e6"></path></svg>
<?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="1650792481486" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5910" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M511.905018 0.189965C229.187475 0.189965 0 229.37744 0 512.094982s229.187475 511.905018 511.905018 511.905018 511.905018-229.187475 511.905017-511.905018S794.62256 0.189965 511.905018 0.189965z m237.335963 429.350335l-255.952509 255.952509c-24.95537 24.815396-65.277888 24.815396-90.233258 0l-127.976254-127.976254c-25.095344-24.915377-25.245316-65.467853-0.329939-90.563197 24.915377-25.095344 65.467853-25.245316 90.563196-0.329939l82.554683 83.204562 210.530936-210.530937c26.805026-23.035726 67.20753-19.976293 90.233258 6.828733 20.606177 23.98555 20.606177 59.418975 0 83.404525h0.609887z" fill="#13C79B" p-id="5911"></path></svg>

Before

Width:  |  Height:  |  Size: 837 B

After

Width:  |  Height:  |  Size: 1,013 B

1
images/refresh.svg Normal file
View 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="1650772659942" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5102" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M832 512a32 32 0 0 0-32 32c0 158.784-129.216 288-288 288s-288-129.216-288-288 129.216-288 288-288c66.208 0 129.536 22.752 180.608 64H608a32 32 0 0 0 0 64h160a32 32 0 0 0 32-32V192a32 32 0 0 0-64 0v80.96A350.464 350.464 0 0 0 512 192C317.92 192 160 349.92 160 544s157.92 352 352 352 352-157.92 352-352a32 32 0 0 0-32-32" p-id="5103"></path></svg>

After

Width:  |  Height:  |  Size: 722 B

View file

@ -5,7 +5,7 @@ from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
import configparser
from utils.BasicUtils import get_todo_list, remove_todo_list
from utils.BasicUtils import get_todo_list, remove_todo_list, change_value
from utils.CreateToDo import CreateToDo
from utils.QSSLoader import QSSLoader
from view.ImportantView import Important
@ -17,60 +17,6 @@ from view.AddListLabel import AddListAction
from view.MyDayView import MyDay
#
#
# class SelfListWidgetItem(QListWidgetItem):
# """
# :param item_name: 列表名称
# :param uid: 当前列表的uuid
# :param todo_count: 设置剩余代办数量,默认为零
# :param show_icon: 设置显示的图标路径,默认为空
# """
#
# def __init__(self, item_name, todo_count=0, uid=None, show_icon=None):
# super(SelfListWidgetItem, self).__init__()
# layout = QHBoxLayout()
# # print(show_icon)
# self.item_name = item_name
#
# self.todo_count = todo_count
# self.show_icon = show_icon
# # 布局
# self.widget = QWidget()
# self.widget.setLayout(layout)
#
# # self.list_item = QLabel('')
#
# # 添加左边的图标和右边的气泡
# if self.show_icon:
# self.icon_label = QLabel('')
# self.icon_label.setPixmap(
# QPixmap(self.show_icon).scaled(30, 30, Qt.IgnoreAspectRatio, Qt.SmoothTransformation))
# layout.addWidget(self.icon_label, 1)
# # 添加
# self.item_name_label = QLabel(self.item_name)
# # print(self.item_name)
# self.item_name_label.setObjectName('item_name_label')
#
# layout.addWidget(self.item_name_label, 3)
#
# if self.todo_count:
# # 打印出代办数目
# print('todo_count:', self.todo_count)
# self.todo_count_label = QLabel(str(self.todo_count))
# self.todo_count_label.setFixedSize(16, 16)
# self.todo_count_label.setScaledContents(True)
# self.todo_count_label.setObjectName('todo_count_label')
# self.todo_count_label.setAlignment(Qt.AlignCenter)
# layout.addWidget(self.todo_count_label, 1)
# # 设置自定义的QListWidgetItem的sizeHint不然无法显示
# self.setSizeHint(self.widget.sizeHint())
# MainWidget().system_listWidget.change_list_name.connect(self.change_name)
#
# def change_name(self):
# pass
#
class MainWidget(QWidget):
def __init__(self):
super(MainWidget, self).__init__()
@ -122,6 +68,8 @@ class MainWidget(QWidget):
self.initUI()
def initUI(self):
# 先清除列表,方便后面调用
self.system_listWidget.clear()
# 系统默认的两个 item
self.system_listWidget.addItem(self.one_day)
self.system_listWidget.setItemWidget(self.one_day, self.one_day.widget)
@ -138,12 +86,6 @@ class MainWidget(QWidget):
self.load_item(load[0], load[1])
# self.system_listWidget.addScrollBarWidget(False)
# 测试添加下面的
# self.two_day = SelfListWidgetItem('我的一天', 1, os.getcwd() + '/../images/sun.svg')
# self.custom.addItem(self.two_day)
# self.custom.setItemWidget(self.two_day, self.two_day.widget)
# self.custom.
def change_list(self):
print(self.system_listWidget.currentItem().text())
# print(name)
@ -163,7 +105,7 @@ class MainWidget(QWidget):
rename_action = QAction(u'重命名', self)
copy_action = QAction("复制分组", self)
# copy_action = QAction("复制分组", self)
del_action = QAction("删除分组", self)
# 查看右键时是否在item上面,如果不在.就不显示删除和修改.
@ -173,10 +115,11 @@ class MainWidget(QWidget):
pop_menu.addAction(rename_action)
rename_action.triggered.connect(self.rename_item)
copy_action.triggered.connect(self.create_item)
# copy_action.triggered.connect(self.create_item)
del_action.triggered.connect(self.delete_item)
pop_menu.exec_(self.system_listWidget.mapToGlobal(position))
# 加载左侧列表
def load_item(self, list_name, uid):
item = SelfListWidgetItem(list_name, 0, uid)
item.setTextAlignment(Qt.AlignCenter)
@ -185,8 +128,9 @@ class MainWidget(QWidget):
self.system_listWidget.addItem(item)
todo_list = ToDoList(list_name, uid)
# 信号测试成功!!
# 更新重要内容
todo_list.update_signal.connect(self.important.refresh_action)
# 删除分组时可用
self.important.update_signal.connect(todo_list.refresh_action)
# 创建后就可以编辑item,用户自己起名字.
# self.system_listWidget.editItem(item)
@ -194,7 +138,7 @@ class MainWidget(QWidget):
self.system_listWidget.setItemWidget(item, item.widget)
# 创建新的分组
# 点击创建新的分组
def create_item(self, new_list='新建列表', uid=None):
# 创建一个没有名字的item
# new_list = '新建列表'
@ -207,7 +151,6 @@ class MainWidget(QWidget):
self.system_listWidget.addItem(item)
todo_list = ToDoList(new_list, create_todo_uid)
self.stackedWidget.addWidget(todo_list)
# 创建后就可以编辑item,用户自己起名字.
# self.system_listWidget.editItem(item)
@ -220,18 +163,57 @@ class MainWidget(QWidget):
self.system_listWidget.takeItem(self.system_listWidget.currentRow())
# 重命名分组
# todo : 重命名还没做好
def rename_item(self):
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))
dialog = QDialog()
dialog.setWindowTitle('重命名')
dialog_layout = QGridLayout()
dialog.resize(300, 200)
dialog.setLayout(dialog_layout)
line_edit = QLineEdit()
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)
# 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))
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()
class MainWindow(QWidget):
def __init__(self):

View file

@ -71,7 +71,7 @@ QPushButton#todo_mark_icon,#mark_important {
/* padding: 3px 20px;*/
/* text-align:center;*/
background-color:#f3f3f3;
border-radius:15px;
border-radius:20px;
min-width:40px;
max-width:40px;
min-height:40px;
@ -103,7 +103,7 @@ QLabel#add_todo_label{
background-color: rgba(211, 211, 211, 0.5);
}
QLineEdit#login_line{
QLineEdit#login_line,#rename_line{
border: none;
background:transparent;
min-width:400px;

77
test/Data/style.qss Normal file
View file

@ -0,0 +1,77 @@
/*左侧*/
#listWidget {
outline: 0px;
max-width: 165px;
background-color: rgb(240, 240, 240);
}
#listWidget::item {
min-height: 45px;
}
#listWidget::item:hover {
background-color: rgb(225, 230, 235);
}
#listWidget::item:selected {
color: black;
background-color: rgb(255, 255, 255);
}
/*右侧*/
#titleLabel1,#titleLabel2,#titleLabel3,#titleLabel4,#titleLabel5,#titleLabel6,#titleLabel7,#titleLabel8 {
min-width: 75px;
max-width: 75px;
}
#right1,#right2,#right3,#right4,#right5,#right6 {
margin-left: 25px;
color: rgb(128, 128, 128);
}
/*所有按钮*/
QPushButton {
max-width: 80px;
max-height: 24px;
min-height: 24px;
border-radius: 3px;
background-color: rgb(244, 244, 244);
border: 1px solid rgb(167, 167, 167);
}
QPushButton:hover {
background-color: rgb(190, 231, 253);
}
QPushButton:pressed {
background-color: rgb(244, 244, 244);
}
QComboBox {
max-width: 80px;
max-height: 20px;
min-height: 20px;
}
QComboBox {
border: 1px solid rgb(167, 167, 167);
border-radius: 3px;
}
#listWidgetUser {
min-width: 290px;
max-width: 290px;
max-height: 120px;
min-height: 120px;
border-radius: 2px;
border: 1px solid rgb(227, 236, 242);
background-color: rgb(244, 250, 253);
}
QScrollBar::vertical {
background: rgb(178, 178, 178);
border: -5px solid grey;
margin: 0px 0px 0px 0px;
width: 10px;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: white;
}

501
test/Lib/SettingUi.py Normal file
View file

@ -0,0 +1,501 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'setting.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!
try:
from PyQt5 import QtCore, QtWidgets
except ImportError:
from PySide2 import QtCore, QtWidgets
class Ui_Setting(object):
def setupUi(self, Setting):
Setting.setObjectName("Setting")
Setting.resize(498, 498)
self.horizontalLayout = QtWidgets.QHBoxLayout(Setting)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.listWidget = QtWidgets.QListWidget(Setting)
self.listWidget.setFrameShape(QtWidgets.QFrame.NoFrame)
self.listWidget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.listWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.listWidget.setObjectName("listWidget")
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
self.listWidget.addItem(item)
self.horizontalLayout.addWidget(self.listWidget)
self.scrollArea = QtWidgets.QScrollArea(Setting)
self.scrollArea.setFrameShape(QtWidgets.QFrame.NoFrame)
self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -810, 460, 1308))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout.setContentsMargins(35, 20, 35, 20)
self.verticalLayout.setSpacing(20)
self.verticalLayout.setObjectName("verticalLayout")
self.widget_0 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_0.setObjectName("widget_0")
self.formLayout = QtWidgets.QFormLayout(self.widget_0)
self.formLayout.setContentsMargins(0, 0, 0, 0)
self.formLayout.setObjectName("formLayout")
self.titleLabel1 = QtWidgets.QLabel(self.widget_0)
self.titleLabel1.setObjectName("titleLabel1")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel1)
self.CheckBox = QtWidgets.QCheckBox(self.widget_0)
self.CheckBox.setObjectName("CheckBox")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.CheckBox)
self.checkBox = QtWidgets.QCheckBox(self.widget_0)
self.checkBox.setChecked(True)
self.checkBox.setObjectName("checkBox")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox)
self.checkBox_2 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_2.setChecked(True)
self.checkBox_2.setObjectName("checkBox_2")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_2)
self.checkBox_3 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_3.setObjectName("checkBox_3")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_3)
self.checkBox_4 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_4.setObjectName("checkBox_4")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_4)
self.checkBox_5 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_5.setObjectName("checkBox_5")
self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.checkBox_5)
self.checkBox_6 = QtWidgets.QCheckBox(self.widget_0)
self.checkBox_6.setObjectName("checkBox_6")
self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.checkBox_6)
self.verticalLayout.addWidget(self.widget_0)
self.widget_1 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_1.setObjectName("widget_1")
self.formLayout_8 = QtWidgets.QFormLayout(self.widget_1)
self.formLayout_8.setContentsMargins(0, 0, 0, 0)
self.formLayout_8.setObjectName("formLayout_8")
self.titleLabel2 = QtWidgets.QLabel(self.widget_1)
self.titleLabel2.setObjectName("titleLabel2")
self.formLayout_8.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel2)
self.checkBox_26 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_26.setObjectName("checkBox_26")
self.formLayout_8.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_26)
self.checkBox_27 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_27.setObjectName("checkBox_27")
self.formLayout_8.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_27)
self.checkBox_28 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_28.setObjectName("checkBox_28")
self.formLayout_8.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_28)
self.checkBox_29 = QtWidgets.QCheckBox(self.widget_1)
self.checkBox_29.setObjectName("checkBox_29")
self.formLayout_8.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_29)
self.label_10 = QtWidgets.QLabel(self.widget_1)
self.label_10.setObjectName("label_10")
self.formLayout_8.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.label_10)
self.right1 = QtWidgets.QRadioButton(self.widget_1)
self.right1.setObjectName("right1")
self.formLayout_8.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.right1)
self.right2 = QtWidgets.QRadioButton(self.widget_1)
self.right2.setChecked(True)
self.right2.setObjectName("right2")
self.formLayout_8.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.right2)
self.label_11 = QtWidgets.QLabel(self.widget_1)
self.label_11.setObjectName("label_11")
self.formLayout_8.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.label_11)
self.right3 = QtWidgets.QPushButton(self.widget_1)
self.right3.setObjectName("right3")
self.formLayout_8.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.right3)
self.verticalLayout.addWidget(self.widget_1)
self.widget_2 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_2.setObjectName("widget_2")
self.formLayout_9 = QtWidgets.QFormLayout(self.widget_2)
self.formLayout_9.setContentsMargins(0, 0, 0, 0)
self.formLayout_9.setObjectName("formLayout_9")
self.titleLabel3 = QtWidgets.QLabel(self.widget_2)
self.titleLabel3.setObjectName("titleLabel3")
self.formLayout_9.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel3)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label_13 = QtWidgets.QLabel(self.widget_2)
self.label_13.setObjectName("label_13")
self.horizontalLayout_2.addWidget(self.label_13)
self.comboBox = QtWidgets.QComboBox(self.widget_2)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.horizontalLayout_2.addWidget(self.comboBox)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.formLayout_9.setLayout(0, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout_2)
self.checkBox_30 = QtWidgets.QCheckBox(self.widget_2)
self.checkBox_30.setObjectName("checkBox_30")
self.formLayout_9.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_30)
self.right4 = QtWidgets.QLabel(self.widget_2)
self.right4.setObjectName("right4")
self.formLayout_9.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.right4)
self.checkBox_31 = QtWidgets.QCheckBox(self.widget_2)
self.checkBox_31.setObjectName("checkBox_31")
self.formLayout_9.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_31)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.pushButton_5 = QtWidgets.QPushButton(self.widget_2)
self.pushButton_5.setObjectName("pushButton_5")
self.horizontalLayout_3.addWidget(self.pushButton_5)
self.pushButton_4 = QtWidgets.QPushButton(self.widget_2)
self.pushButton_4.setObjectName("pushButton_4")
self.horizontalLayout_3.addWidget(self.pushButton_4)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem1)
self.formLayout_9.setLayout(4, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout_3)
self.verticalLayout.addWidget(self.widget_2)
self.widget_3 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_3.setObjectName("widget_3")
self.formLayout_2 = QtWidgets.QFormLayout(self.widget_3)
self.formLayout_2.setContentsMargins(0, 0, 0, 0)
self.formLayout_2.setObjectName("formLayout_2")
self.titleLabel4 = QtWidgets.QLabel(self.widget_3)
self.titleLabel4.setObjectName("titleLabel4")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel4)
self.CheckBox_2 = QtWidgets.QCheckBox(self.widget_3)
self.CheckBox_2.setChecked(True)
self.CheckBox_2.setObjectName("CheckBox_2")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.CheckBox_2)
self.checkBox_7 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_7.setObjectName("checkBox_7")
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_7)
self.checkBox_8 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_8.setObjectName("checkBox_8")
self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_8)
self.checkBox_9 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_9.setChecked(True)
self.checkBox_9.setObjectName("checkBox_9")
self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_9)
self.checkBox_10 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_10.setChecked(True)
self.checkBox_10.setObjectName("checkBox_10")
self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_10)
self.checkBox_11 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_11.setChecked(True)
self.checkBox_11.setObjectName("checkBox_11")
self.formLayout_2.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.checkBox_11)
self.checkBox_12 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_12.setChecked(True)
self.checkBox_12.setObjectName("checkBox_12")
self.formLayout_2.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.checkBox_12)
self.checkBox_13 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_13.setChecked(True)
self.checkBox_13.setObjectName("checkBox_13")
self.formLayout_2.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.checkBox_13)
self.checkBox_14 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_14.setChecked(True)
self.checkBox_14.setObjectName("checkBox_14")
self.formLayout_2.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.checkBox_14)
self.checkBox_15 = QtWidgets.QCheckBox(self.widget_3)
self.checkBox_15.setChecked(True)
self.checkBox_15.setObjectName("checkBox_15")
self.formLayout_2.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.checkBox_15)
self.verticalLayout.addWidget(self.widget_3)
self.widget_4 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_4.setObjectName("widget_4")
self.formLayout_3 = QtWidgets.QFormLayout(self.widget_4)
self.formLayout_3.setContentsMargins(0, 0, 0, 0)
self.formLayout_3.setObjectName("formLayout_3")
self.titleLabel5 = QtWidgets.QLabel(self.widget_4)
self.titleLabel5.setObjectName("titleLabel5")
self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel5)
self.checkBox_16 = QtWidgets.QCheckBox(self.widget_4)
self.checkBox_16.setChecked(True)
self.checkBox_16.setObjectName("checkBox_16")
self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_16)
self.checkBox_17 = QtWidgets.QCheckBox(self.widget_4)
self.checkBox_17.setChecked(True)
self.checkBox_17.setObjectName("checkBox_17")
self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_17)
self.checkBox_18 = QtWidgets.QCheckBox(self.widget_4)
self.checkBox_18.setChecked(True)
self.checkBox_18.setObjectName("checkBox_18")
self.formLayout_3.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_18)
self.checkBox_19 = QtWidgets.QCheckBox(self.widget_4)
self.checkBox_19.setChecked(True)
self.checkBox_19.setObjectName("checkBox_19")
self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_19)
self.verticalLayout.addWidget(self.widget_4)
self.widget_5 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_5.setObjectName("widget_5")
self.formLayout_4 = QtWidgets.QFormLayout(self.widget_5)
self.formLayout_4.setContentsMargins(0, 0, 0, 0)
self.formLayout_4.setObjectName("formLayout_4")
self.titleLabel6 = QtWidgets.QLabel(self.widget_5)
self.titleLabel6.setObjectName("titleLabel6")
self.formLayout_4.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel6)
self.checkBox_20 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_20.setObjectName("checkBox_20")
self.formLayout_4.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_20)
self.checkBox_21 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_21.setObjectName("checkBox_21")
self.formLayout_4.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.checkBox_21)
self.checkBox_22 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_22.setObjectName("checkBox_22")
self.formLayout_4.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.checkBox_22)
self.checkBox_23 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_23.setObjectName("checkBox_23")
self.formLayout_4.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.checkBox_23)
self.checkBox_24 = QtWidgets.QCheckBox(self.widget_5)
self.checkBox_24.setObjectName("checkBox_24")
self.formLayout_4.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.checkBox_24)
self.right5 = QtWidgets.QLabel(self.widget_5)
self.right5.setObjectName("right5")
self.formLayout_4.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.right5)
self.label_3 = QtWidgets.QLabel(self.widget_5)
self.label_3.setObjectName("label_3")
self.formLayout_4.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.label_3)
self.label_4 = QtWidgets.QLabel(self.widget_5)
self.label_4.setObjectName("label_4")
self.formLayout_4.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.label_4)
self.radioButton = QtWidgets.QRadioButton(self.widget_5)
self.radioButton.setObjectName("radioButton")
self.formLayout_4.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.radioButton)
self.radioButton_2 = QtWidgets.QRadioButton(self.widget_5)
self.radioButton_2.setObjectName("radioButton_2")
self.formLayout_4.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.radioButton_2)
self.radioButton_3 = QtWidgets.QRadioButton(self.widget_5)
self.radioButton_3.setChecked(True)
self.radioButton_3.setObjectName("radioButton_3")
self.formLayout_4.setWidget(10, QtWidgets.QFormLayout.FieldRole, self.radioButton_3)
self.formLayout_5 = QtWidgets.QFormLayout()
self.formLayout_5.setObjectName("formLayout_5")
self.listWidgetUser = QtWidgets.QListWidget(self.widget_5)
self.listWidgetUser.setFrameShape(QtWidgets.QFrame.NoFrame)
self.listWidgetUser.setObjectName("listWidgetUser")
self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.listWidgetUser)
self.pushButton = QtWidgets.QPushButton(self.widget_5)
self.pushButton.setObjectName("pushButton")
self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.pushButton)
self.formLayout_4.setLayout(11, QtWidgets.QFormLayout.FieldRole, self.formLayout_5)
self.verticalLayout.addWidget(self.widget_5)
self.widget_6 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_6.setObjectName("widget_6")
self.formLayout_6 = QtWidgets.QFormLayout(self.widget_6)
self.formLayout_6.setContentsMargins(0, 0, 0, 0)
self.formLayout_6.setObjectName("formLayout_6")
self.titleLabel7 = QtWidgets.QLabel(self.widget_6)
self.titleLabel7.setObjectName("titleLabel7")
self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel7)
self.label_6 = QtWidgets.QLabel(self.widget_6)
self.label_6.setObjectName("label_6")
self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.label_6)
self.pushButton_2 = QtWidgets.QPushButton(self.widget_6)
self.pushButton_2.setObjectName("pushButton_2")
self.formLayout_6.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.pushButton_2)
self.verticalLayout.addWidget(self.widget_6)
self.widget_7 = QtWidgets.QWidget(self.scrollAreaWidgetContents)
self.widget_7.setObjectName("widget_7")
self.formLayout_7 = QtWidgets.QFormLayout(self.widget_7)
self.formLayout_7.setContentsMargins(0, 0, 0, 0)
self.formLayout_7.setObjectName("formLayout_7")
self.titleLabel8 = QtWidgets.QLabel(self.widget_7)
self.titleLabel8.setObjectName("titleLabel8")
self.formLayout_7.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.titleLabel8)
self.checkBox_25 = QtWidgets.QCheckBox(self.widget_7)
self.checkBox_25.setObjectName("checkBox_25")
self.formLayout_7.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.checkBox_25)
self.right6 = QtWidgets.QLabel(self.widget_7)
self.right6.setObjectName("right6")
self.formLayout_7.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.right6)
self.verticalLayout.addWidget(self.widget_7)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.horizontalLayout.addWidget(self.scrollArea)
self.retranslateUi(Setting)
self.listWidget.setCurrentRow(0)
QtCore.QMetaObject.connectSlotsByName(Setting)
Setting.setTabOrder(self.listWidget, self.scrollArea)
Setting.setTabOrder(self.scrollArea, self.CheckBox)
Setting.setTabOrder(self.CheckBox, self.checkBox)
Setting.setTabOrder(self.checkBox, self.checkBox_2)
Setting.setTabOrder(self.checkBox_2, self.checkBox_3)
Setting.setTabOrder(self.checkBox_3, self.checkBox_4)
Setting.setTabOrder(self.checkBox_4, self.checkBox_5)
Setting.setTabOrder(self.checkBox_5, self.checkBox_6)
Setting.setTabOrder(self.checkBox_6, self.checkBox_26)
Setting.setTabOrder(self.checkBox_26, self.checkBox_27)
Setting.setTabOrder(self.checkBox_27, self.checkBox_28)
Setting.setTabOrder(self.checkBox_28, self.checkBox_29)
Setting.setTabOrder(self.checkBox_29, self.right1)
Setting.setTabOrder(self.right1, self.right2)
Setting.setTabOrder(self.right2, self.right3)
Setting.setTabOrder(self.right3, self.comboBox)
Setting.setTabOrder(self.comboBox, self.checkBox_30)
Setting.setTabOrder(self.checkBox_30, self.checkBox_31)
Setting.setTabOrder(self.checkBox_31, self.pushButton_5)
Setting.setTabOrder(self.pushButton_5, self.pushButton_4)
Setting.setTabOrder(self.pushButton_4, self.CheckBox_2)
Setting.setTabOrder(self.CheckBox_2, self.checkBox_7)
Setting.setTabOrder(self.checkBox_7, self.checkBox_8)
Setting.setTabOrder(self.checkBox_8, self.checkBox_9)
Setting.setTabOrder(self.checkBox_9, self.checkBox_10)
Setting.setTabOrder(self.checkBox_10, self.checkBox_11)
Setting.setTabOrder(self.checkBox_11, self.checkBox_12)
Setting.setTabOrder(self.checkBox_12, self.checkBox_13)
Setting.setTabOrder(self.checkBox_13, self.checkBox_14)
Setting.setTabOrder(self.checkBox_14, self.checkBox_15)
Setting.setTabOrder(self.checkBox_15, self.checkBox_16)
Setting.setTabOrder(self.checkBox_16, self.checkBox_17)
Setting.setTabOrder(self.checkBox_17, self.checkBox_18)
Setting.setTabOrder(self.checkBox_18, self.checkBox_19)
Setting.setTabOrder(self.checkBox_19, self.checkBox_20)
Setting.setTabOrder(self.checkBox_20, self.checkBox_21)
Setting.setTabOrder(self.checkBox_21, self.checkBox_22)
Setting.setTabOrder(self.checkBox_22, self.checkBox_23)
Setting.setTabOrder(self.checkBox_23, self.checkBox_24)
Setting.setTabOrder(self.checkBox_24, self.radioButton)
Setting.setTabOrder(self.radioButton, self.radioButton_2)
Setting.setTabOrder(self.radioButton_2, self.radioButton_3)
Setting.setTabOrder(self.radioButton_3, self.listWidgetUser)
Setting.setTabOrder(self.listWidgetUser, self.pushButton)
Setting.setTabOrder(self.pushButton, self.pushButton_2)
Setting.setTabOrder(self.pushButton_2, self.checkBox_25)
def retranslateUi(self, Setting):
_translate = QtCore.QCoreApplication.translate
Setting.setWindowTitle(_translate("Setting", "仿QQ设置面板"))
__sortingEnabled = self.listWidget.isSortingEnabled()
self.listWidget.setSortingEnabled(False)
item = self.listWidget.item(0)
item.setText(_translate("Setting", "登录"))
item = self.listWidget.item(1)
item.setText(_translate("Setting", "主面板"))
item = self.listWidget.item(2)
item.setText(_translate("Setting", "状态"))
item = self.listWidget.item(3)
item.setText(_translate("Setting", "会话窗口"))
item = self.listWidget.item(4)
item.setText(_translate("Setting", "信息展示"))
item = self.listWidget.item(5)
item.setText(_translate("Setting", "提醒"))
item = self.listWidget.item(6)
item.setText(_translate("Setting", "热键"))
item = self.listWidget.item(7)
item.setText(_translate("Setting", "显示"))
item = self.listWidget.item(8)
item.setText(_translate("Setting", "声音"))
item = self.listWidget.item(9)
item.setText(_translate("Setting", "软件更新"))
item = self.listWidget.item(10)
item.setText(_translate("Setting", "文件管理"))
item = self.listWidget.item(11)
item.setText(_translate("Setting", "文件共享"))
item = self.listWidget.item(12)
item.setText(_translate("Setting", "音视频通话"))
self.listWidget.setSortingEnabled(__sortingEnabled)
self.titleLabel1.setText(_translate("Setting", "登录:"))
self.CheckBox.setText(_translate("Setting", "开机时自动启动QQ"))
self.checkBox.setText(_translate("Setting", "启动QQ时为我自动登录"))
self.checkBox_2.setText(_translate("Setting", "总是打开登录提示"))
self.checkBox_3.setText(_translate("Setting", "离线自动启动QQ手机版仅支持Android"))
self.checkBox_4.setText(_translate("Setting", "登录后自动运行QQ宠物"))
self.checkBox_5.setText(_translate("Setting", "订阅“腾讯视频”,获取量身定制视频资讯"))
self.checkBox_6.setText(_translate("Setting", "订阅“每日精选”,了解最新商品资讯"))
self.titleLabel2.setText(_translate("Setting", "主面板:"))
self.checkBox_26.setText(_translate("Setting", "始终保持在其他窗口前端"))
self.checkBox_27.setText(_translate("Setting", "停靠在桌面边缘时自动隐藏"))
self.checkBox_28.setText(_translate("Setting", "在任务栏通知区域显示QQ图标"))
self.checkBox_29.setText(_translate("Setting", "显示天气"))
self.label_10.setText(_translate("Setting", "关闭主面板时:"))
self.right1.setText(_translate("Setting", "隐藏到任务栏通知区域,不退出程序"))
self.right2.setText(_translate("Setting", "退出程序"))
self.label_11.setText(_translate("Setting", "您可以自由定制适合您的面板和功能使用QQ更有效率"))
self.right3.setText(_translate("Setting", "界面管理器"))
self.titleLabel3.setText(_translate("Setting", "状态:"))
self.label_13.setText(_translate("Setting", "登陆后状态为:"))
self.comboBox.setItemText(0, _translate("Setting", "我在线上"))
self.comboBox.setItemText(1, _translate("Setting", "Q我吧"))
self.comboBox.setItemText(2, _translate("Setting", "离开"))
self.comboBox.setItemText(3, _translate("Setting", "忙碌"))
self.comboBox.setItemText(4, _translate("Setting", "请勿打扰"))
self.comboBox.setItemText(5, _translate("Setting", "隐身"))
self.checkBox_30.setText(_translate("Setting", "运行全屏程序时切换至“忙碌“状态””"))
self.right4.setText(_translate("Setting", "仅在“Q我吧”和“我在线上”状态下生效"))
self.checkBox_31.setText(_translate("Setting", "离开、忙碌、请勿打扰时自动回复100字以内"))
self.pushButton_5.setText(_translate("Setting", "自动回复设置"))
self.pushButton_4.setText(_translate("Setting", "快捷回复设置"))
self.titleLabel4.setText(_translate("Setting", "会话窗口:"))
self.CheckBox_2.setText(_translate("Setting", "使用多彩气泡聊天"))
self.checkBox_7.setText(_translate("Setting", "不显示广告(会员设置项)"))
self.checkBox_8.setText(_translate("Setting", "允许来消息时自动弹出窗口"))
self.checkBox_9.setText(_translate("Setting", "默认使用腾讯视频播放视频文件"))
self.checkBox_10.setText(_translate("Setting", "允许自动播放魔法表情和超级表情"))
self.checkBox_11.setText(_translate("Setting", "允许使用QQ秀聊天随动表情"))
self.checkBox_12.setText(_translate("Setting", "总是显示好友聊天窗口侧边栏"))
self.checkBox_13.setText(_translate("Setting", "允许接收窗口抖动"))
self.checkBox_14.setText(_translate("Setting", "显示热词搜索提示"))
self.checkBox_15.setText(_translate("Setting", "显示历史消息记录"))
self.titleLabel5.setText(_translate("Setting", "信息展示:"))
self.checkBox_16.setText(_translate("Setting", "在资料卡和迷你信息卡上显示等级图标"))
self.checkBox_17.setText(_translate("Setting", "在资料卡和迷你卡上显示更新搜索"))
self.checkBox_18.setText(_translate("Setting", "在聊天窗口内展示好友的更新摘要"))
self.checkBox_19.setText(_translate("Setting", "在聊天窗口内展示好友互动标识"))
self.titleLabel6.setText(_translate("Setting", "提醒:"))
self.checkBox_20.setText(_translate("Setting", "会话消息提醒"))
self.checkBox_21.setText(_translate("Setting", "新邮件提醒"))
self.checkBox_22.setText(_translate("Setting", "启用QQ看点消息"))
self.checkBox_23.setText(_translate("Setting", "启用一声问候消息"))
self.checkBox_24.setText(_translate("Setting", "启用设备连接提醒"))
self.right5.setText(_translate("Setting", "当插入安卓设备时提示安装或者更新QQ手机版"))
self.label_3.setText(_translate("Setting",
"<html><head/><body><p>您可以设置是否在屏幕右下角收到来自QQ空间的通知<a href=\"#\"><span style=\" text-decoration: none; color:#00aaff;\">进入设置</span></a>。</p></body></html>"))
self.label_4.setText(_translate("Setting", "好友上线提醒"))
self.radioButton.setText(_translate("Setting", "关闭好友上线提醒"))
self.radioButton_2.setText(_translate("Setting", "全部好友上线提醒"))
self.radioButton_3.setText(_translate("Setting", "以下好友上线提醒"))
self.pushButton.setText(_translate("Setting", "添加"))
self.titleLabel7.setText(_translate("Setting", "热键:"))
self.label_6.setText(_translate("Setting", "您可以通过点击选择要更改的热键"))
self.pushButton_2.setText(_translate("Setting", "设置热键"))
self.titleLabel8.setText(_translate("Setting", "显示:"))
self.checkBox_25.setText(_translate("Setting", "开启QQ适配屏幕DPI"))
self.right6.setText(_translate("Setting", "关闭选项后QQ将保持默认大小设置后需要重新登录才能生效"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Setting = QtWidgets.QWidget()
ui = Ui_Setting()
ui.setupUi(Setting)
Setting.show()
sys.exit(app.exec_())

63
test/MenuAnimation.py Normal file
View file

@ -0,0 +1,63 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2018年8月22日
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: MenuAnimation
@description:
"""
from PyQt5.QtCore import QPropertyAnimation, QEasingCurve, QRect
from PyQt5.QtWidgets import QWidget, QMenu, QApplication
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.resize(800, 600)
self.initMenu()
self.initAnimation()
def contextMenuEvent(self, event):
pos = event.globalPos()
size = self._contextMenu.sizeHint()
x, y, w, h = pos.x(), pos.y(), size.width(), size.height()
self._animation.stop()
self._animation.setStartValue(QRect(x, y, 0, 0))
self._animation.setEndValue(QRect(x, y, w, h))
self._animation.start()
self._contextMenu.exec_(event.globalPos())
def hello(self):
QApplication.instance().aboutQt()
def initAnimation(self):
# 按钮动画
self._animation = QPropertyAnimation(
self._contextMenu, b'geometry', self,
easingCurve=QEasingCurve.Linear, duration=300)
# easingCurve 修改该变量可以实现不同的效果
def initMenu(self):
self._contextMenu = QMenu(self)
self._contextMenu.addAction('菜单1', self.hello)
self._contextMenu.addAction('菜单2', self.hello)
self._contextMenu.addAction('菜单3', self.hello)
self._contextMenu.addAction('菜单4', self.hello)
self._contextMenu.addAction('菜单5', self.hello)
self._contextMenu.addAction('菜单6', self.hello)
if __name__ == '__main__':
import sys
import cgitb
cgitb.enable(format='text')
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())

66
test/QQSettingPanel.py Normal file
View file

@ -0,0 +1,66 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2018年3月28日
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: QQSettingPanel
@description:
"""
try:
from PyQt5.QtWidgets import QApplication, QWidget
except ImportError:
from PySide2.QtWidgets import QApplication, QWidget
from Lib.SettingUi import Ui_Setting # @UnresolvedImport
class Window(QWidget, Ui_Setting):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
self.setupUi(self)
self.resize(700, 435)
self._blockSignals = False
# 绑定滚动条和左侧item事件
self.scrollArea.verticalScrollBar().valueChanged.connect(
self.onValueChanged)
self.listWidget.itemClicked.connect(self.onItemClicked)
def onValueChanged(self, value):
"""滚动条"""
if self._blockSignals:
# 防止item点击时改变滚动条会触发这里
return
for i in range(8): # 因为这里右侧有8个widget
widget = getattr(self, 'widget_%d' % i, None)
# widget不为空且在可视范围内
if widget and not widget.visibleRegion().isEmpty():
self.listWidget.setCurrentRow(i) # 设置item的选中
return
def onItemClicked(self, item):
"""左侧item"""
row = self.listWidget.row(item) # 获取点击的item的索引
# 由于右侧的widget是按照命名widget_0 widget_1这样比较规范的方法,可以通过getattr找到
widget = getattr(self, 'widget_%d' % row, None)
if not widget:
return
# 定位右侧位置并滚动
self._blockSignals = True
self.scrollArea.verticalScrollBar().setSliderPosition(widget.pos().y())
self._blockSignals = False
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
app.setStyleSheet(open('Data/style.qss', 'rb').read().decode('utf-8'))
w = Window()
w.show()
sys.exit(app.exec_())

View file

@ -31,6 +31,34 @@ def read_init_file():
return False
def change_myday_important_conf(change_type, key, value):
value = str(value)
config = configparser.ConfigParser()
config_path = return_work_dir()
todo_file = config_path + 'PyQtToDoList.conf'
if not os.path.exists(todo_file):
# print(True)
myday = {"Theme": "0"}
important = {"Theme": "0"}
config['MyDay'] = myday
config['Important'] = important
with open(todo_file, 'w') as f:
config.write(f)
config.read(todo_file)
config[change_type][key] = value
with open(todo_file, 'w') as f:
config.write(f)
def get_myday_important_conf(get_type, key):
config = configparser.ConfigParser()
config_path = return_work_dir()
todo_file = config_path + 'PyQtToDoList.conf'
config.read(todo_file)
return config[get_type][key]
def get_todo_list():
config_path = return_work_dir()
todo_path = config_path + 'ToDoList/'
@ -148,6 +176,18 @@ def remove_todo_list(uid):
config_path = return_work_dir()
todo_path = config_path + 'ToDoList/'
os.remove(todo_path + '{' + uid + '}.otl')
for root, dirs, files in os.walk(todo_path, topdown=False):
for name in files:
# print(os.path.join(root, name))
with open(os.path.join(root, name), 'r') as f:
# print(f.read())
json_file = json.load(f)
# print(json_file['itemType'])
if json_file['itemType'] == 'Todo' and json_file['todoListUid'] == uid:
# print(os.path.join(root, name))
os.remove(os.path.join(root, name))
# print(read_init_file())
# webdav_hostname = read_init_file()
@ -155,3 +195,5 @@ def remove_todo_list(uid):
# change_value('4f52f02b-4450-405a-9fd1-2005a03006e0', 'isMyDay', False)
# print(get_todo('3f1e033f-2051-4c04-b7f6-afd2eb1f54f4'))
# print(load_myday_important('Important'))
# change_myday_important_conf('Important', 'theme', 2)
# print(get_myday_important_conf('Important','Theme'))

View file

@ -1,12 +1,15 @@
import os
import sys
import time
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, get_todo
from utils.BasicUtils import load_myday_important, remove_todo_list, change_value, get_todo, get_myday_important_conf, \
change_myday_important_conf
from view.AddToDoLabel import AddToDoAction
from view.ToDoItem import ToDoItem, Button
from view.ToDoItem import ToDoItem
class Important(QWidget):
@ -20,7 +23,9 @@ class Important(QWidget):
self.setObjectName('important')
self.setAttribute(Qt.WA_StyledBackground)
self.setStyleSheet('#important{background-image:url("../images/10.jpg");border-radius: 10px;}')
background = get_myday_important_conf('Important', 'Theme')
self.setStyleSheet('#important{background-image:url("../images/' + background + '.jpg");border-radius: 10px;}')
# 布局样式:最外面一个大的垂直布局,里面的最上面标题是一个水平布局,水平布局显示的是一个垂直布局和一个右边的选项,用来更换背景
# 布局样式继承QWidget,里面一个垂直布局最上面一个QWidget用来设置头部布局
@ -93,6 +98,7 @@ class Important(QWidget):
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()
@ -103,15 +109,7 @@ class Important(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')
@ -146,7 +144,7 @@ class Important(QWidget):
self.todo_list.customContextMenuRequested.connect(self.todo_list_context)
# todolist = ToDoList()
self.initUI()
self.refresh_action()
def refresh_action(self):
# self.my_day_list[]
@ -157,35 +155,19 @@ class Important(QWidget):
for my_day in my_day_list:
self.load_important(my_day[0], my_day[1])
def initUI(self):
print('<ImportantView>')
# 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_important(my_day[0], my_day[1])
def load_important(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))
self.todo_list.addItem(todo_item)
self.todo_list.setItemWidget(todo_item, todo_item.widget)
# button_menu
# 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)))
# button_menu.addAction(label_action)
# todo : 下面的方法实现点击更换主题的功能
# todo : 下面的方法实现点击更换主题的功能
def menu_action(self, count):
# 点击按钮
count = str(count)
change_myday_important_conf('Important', 'theme', count)
# self.menu_label = ChangeTheme()
self.setStyleSheet('#important{background-image:url("../images/' + count + '.jpg");'
'background-position: center; border-radius: 10px;'
@ -255,13 +237,46 @@ class Important(QWidget):
# 重命名分组
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))
# curRow = self.todo_list.currentRow()
# item = self.todo_list.item(curRow)
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_()
# 重命名发送信号
# self.update_signal.emit()
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()
def mark_done(self, 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)
pass

View file

@ -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
from utils.BasicUtils import load_myday_important, remove_todo_list, change_value
from utils.CreateToDo import CreateToDo
from view.AddToDoLabel import AddToDoAction
from view.MyDayHeadLabel import HeadLabel
@ -20,7 +20,7 @@ class Menu(QMenu):
class MyDay(QWidget):
transaction = pyqtSignal()
update_signal = pyqtSignal()
def __init__(self, parent=None):
super(MyDay, self).__init__()
@ -30,11 +30,6 @@ class MyDay(QWidget):
self.setAttribute(Qt.WA_StyledBackground)
# 下面这一句有问题,需要修复修改主题的实现方法
# self.setStyleSheet('#my_day{background-image:url("../images/2.jpg");')
# 无效
# palette = QPalette()
# palette.setBrush(QPalette.Background,
# QBrush(QPixmap(os.getcwd() + "/../images/0.jpg").scaled(self.width(), self.height())))
# self.setPalette(palette)
# 布局样式:最外面一个大的垂直布局,里面的最上面标题是一个水平布局,水平布局显示的是一个垂直布局和一个右边的选项,用来更换背景
# 布局样式继承QWidget,里面一个垂直布局最上面一个QWidget用来设置头部布局
@ -43,10 +38,6 @@ class MyDay(QWidget):
head_layout = QHBoxLayout() # 头部总布局
head_widget = QWidget(self)
# head_widget.setStyleSheet('background-color:gray')
# head_widget.setMinimumHeight(175)
# head_widget.setMaximumHeight(180)
head_widget.setAttribute(Qt.WA_StyledBackground)
self.todo_list = QListWidget()
@ -59,8 +50,6 @@ class MyDay(QWidget):
self.add_todo.setAlignment(Qt.AlignCenter)
# self.add_todo.todo_name.connect(self.add_todo_action)
# head_widget.setPalette(palette)
head_widget.setLayout(head_layout)
head_layout.setAlignment(Qt.AlignCenter)
# head_left_layout = QVBoxLayout()
@ -72,7 +61,7 @@ class MyDay(QWidget):
self.head_label = HeadLabel()
layout.addWidget(self.todo_list, 6, Qt.AlignCenter | Qt.AlignTop)
head_layout.addWidget(self.head_label, 8)
# todo : 修改布局
layout.addWidget(self.add_todo, 2, Qt.AlignHCenter)
self.menu_image = QPushButton()
@ -102,15 +91,7 @@ class MyDay(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')
@ -141,29 +122,49 @@ class MyDay(QWidget):
label_action5.triggered.connect(lambda: self.menu_action(5))
self.button_menu.addAction(label_action5)
my_day_list = load_myday_important('MyDay')
# 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):
# self.my_day_list[]
self.todo_list.clear()
# print(self.my_day_list)
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])
# 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)
pass
# todo : 下面的方法实现点击更换主题的功能
def menu_action(self, count):
count = str(count)
# 点击按钮
self.setStyleSheet('#my_day{background-image:url("../images/' + count + '.jpg");'
'background-position: center; border-radius: 10px;'
'}')
self.head_label.show()
# self.head_label.show()
print('<MyDayView> 选中:' + count)
@ -182,3 +183,69 @@ class MyDay(QWidget):
self.todo_list.setItemWidget(todo_item, todo_item.widget)
self.add_todo.line_edit.clear()
def todo_list_context(self, position):
# 设置右键菜单
pop_menu = QMenu(self)
pop_menu.setObjectName('lift_menu')
pop_menu.setAttribute(Qt.WA_TranslucentBackground)
# 无边框、去掉自带阴影
pop_menu.setWindowFlags(
pop_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint)
rename_action = QAction(u'重命名', self)
mark_myday = QAction(QIcon(QPixmap(os.getcwd() + '/../images/make_sun.svg')), u"取消设置为我的一天", self)
mark_important = QAction(QIcon(QPixmap(os.getcwd() + '/../images/star.svg')), u"设置为重要", self)
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)
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)
pop_menu.exec_(self.todo_list.mapToGlobal(position))
def make_important(self):
# 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)
# 暂时不需要发送信号
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')
# 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)
# change_value(uid,'isImportant',False)
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)
print("test")

View file

@ -21,7 +21,7 @@ class MyListWidget(QListWidget):
# 双击可编辑
self.edited_item = self.currentItem()
self.close_flag = True
self.doubleClicked.connect(self.item_double_clicked)
# self.doubleClicked.connect(self.item_double_clicked)
self.currentItemChanged.connect(self.close_edit)
def keyPressEvent(self, e: QKeyEvent) -> None:

View file

@ -1,3 +1,5 @@
import os
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import Qt, pyqtSignal
@ -12,7 +14,7 @@ class SelfListWidgetItem(QListWidgetItem):
"""
update_action = pyqtSignal()
def __init__(self, item_name, todo_count=0, uid=None, show_icon=None):
def __init__(self, item_name, todo_count=0, uid=None, show_icon=os.getcwd()+'/../images/icon/星宿.svg'):
super(SelfListWidgetItem, self).__init__()
layout = QHBoxLayout()
# print(show_icon)

View file

@ -1,3 +1,6 @@
import os
import time
from PyQt5 import QtGui
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QPixmap, QIcon
@ -7,32 +10,12 @@ from PyQt5.QtCore import Qt
from utils.BasicUtils import change_value
class Button(QPushButton):
trans_signal = pyqtSignal()
def __init__(self):
super(Button, self).__init__()
def mouseReleaseEvent(self, e: QtGui.QMouseEvent) -> None:
self.trans_signal.emit()
# def mousePressEvent(self, QMouseEvent):
# print('haha')
# def clicked(self, checked: bool = ...):
# self.trans_signal.emit()
class ToDoItem(QListWidgetItem):
transaction = pyqtSignal()
"""
:param todo_name : 新建的待办事项名称
:param uid : 待办事项的uid
"""
# todo : 设置点击事件信号传递
def __init__(self, todo_name, uid=None):
super(ToDoItem, self).__init__()
# print('<ToDoItem> 添加的新ToDo' + todo_name)
@ -60,13 +43,14 @@ class ToDoItem(QListWidgetItem):
layout.addWidget(self.important_button, 2)
self.mark_icon.clicked.connect(self.set_done)
print('<ToDoItem>', 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):
print('<ToDoItem>hello')
self.mark_icon.setIcon(QIcon(os.getcwd()+'/../images/finished.svg'))
# time.sleep(0.2)
pass
def set_myday(self, uid):

View file

@ -1,7 +1,7 @@
import os
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtCore import Qt, pyqtSignal, QPropertyAnimation, QRect, QEasingCurve
from utils.BasicUtils import get_todo, change_value, load_value, remove_todo_list
from utils.CreateToDo import CreateToDo
@ -9,15 +9,6 @@ from view.AddToDoLabel import AddToDoAction
from view.ToDoItem import ToDoItem
class Menu(QMenu):
def __init__(self):
super(Menu, self).__init__()
self.index = None
def set_index(self, index):
self.index = index
class ToDoList(QWidget):
"""
:param list_name: 列表名用于显示标题
@ -184,6 +175,8 @@ class ToDoList(QWidget):
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_list.addItem(todo_item)
@ -259,14 +252,23 @@ class ToDoList(QWidget):
self.update_signal.emit()
# 重命名分组
# 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.update_signal.emit()
def ChangeItem(self, item):
print(item)
print("test")
def mark_done(self, uid):
print('mark done:', uid)
def mark_important(self, uid):
pass