修改部分布局
This commit is contained in:
parent
ca9c55ba91
commit
ff13cd521c
7 changed files with 71 additions and 97 deletions
1
images/exit.svg
Normal file
1
images/exit.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="1649331132545" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1269" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M918.4 489.6l-160-160c-12.8-12.8-32-12.8-44.8 0-12.8 12.8-12.8 32 0 44.8l105.6 105.6L512 480c-19.2 0-32 12.8-32 32s12.8 32 32 32l307.2 0-105.6 105.6c-12.8 12.8-12.8 32 0 44.8 6.4 6.4 12.8 9.6 22.4 9.6 9.6 0 16-3.2 22.4-9.6l160-163.2c0 0 0-3.2 3.2-3.2C931.2 518.4 931.2 499.2 918.4 489.6z" p-id="1270"></path><path d="M832 736c-19.2 0-32 12.8-32 32l0 64c0 19.2-12.8 32-32 32L224 864c-19.2 0-32-12.8-32-32L192 192c0-19.2 12.8-32 32-32l544 0c19.2 0 32 12.8 32 32l0 64c0 19.2 12.8 32 32 32s32-12.8 32-32L864 192c0-54.4-41.6-96-96-96L224 96C169.6 96 128 137.6 128 192l0 640c0 54.4 41.6 96 96 96l544 0c54.4 0 96-41.6 96-96l0-64C864 748.8 851.2 736 832 736z" p-id="1271"></path></svg>
|
After Width: | Height: | Size: 1 KiB |
58
main/main.py
58
main/main.py
|
@ -1,12 +1,12 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import Qt
|
||||
from utils.QSSLoader import QSSLoader
|
||||
from view.UserLabel import User
|
||||
from view.SelfListWidgetItem import SelfListWidgetItem
|
||||
from view.AddListLabel import AddListAction
|
||||
|
||||
|
||||
class MainWidget(QWidget):
|
||||
|
@ -18,29 +18,26 @@ class MainWidget(QWidget):
|
|||
# 子布局,左边的部分
|
||||
self.sub_layout = QVBoxLayout()
|
||||
self.sub_layout.spacing()
|
||||
self.sub_layout.addWidget(self.user_label, 1)
|
||||
self.sub_layout.addWidget(self.user_label, 2)
|
||||
# 左侧列表
|
||||
self.system_listWidget = QListWidget(self)
|
||||
self.sub_layout.addWidget(self.system_listWidget, 2)
|
||||
self.sub_layout.addWidget(self.system_listWidget, 15)
|
||||
|
||||
# 可自定义添加的listWidget
|
||||
self.self_listWidget = QListWidget(self)
|
||||
self.sub_layout.addWidget(self.self_listWidget, 7)
|
||||
# self.custom = QListWidget(self)
|
||||
# self.sub_layout.addWidget(self.custom, 7)
|
||||
|
||||
# todo
|
||||
# 需要把下面的重写QLabel解决问题,单个QLabel无法解决问题
|
||||
# todo : 需要把下面的重写QLabel解决问题,单个QLabel无法解决问题
|
||||
self.add_list_action = AddListAction()
|
||||
|
||||
self.add_item_label = QLabel('新建列表')
|
||||
self.add_item_label.setMaximumHeight(50)
|
||||
self.add_item_label.setObjectName('add_item_label')
|
||||
# self.add_item_label.setPixmap(QPixmap())
|
||||
self.sub_layout.addWidget(self.add_item_label, 1)
|
||||
self.sub_layout.addWidget(self.add_list_action, 1)
|
||||
# 禁止双击可编辑
|
||||
self.self_listWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
# self.custom.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
# 右键菜单
|
||||
self.self_listWidget.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
self.self_listWidget.setObjectName('self_listWidget')
|
||||
self.self_listWidget.customContextMenuRequested.connect(self.myListWidgetContext)
|
||||
# self.custom.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
# self.custom.setObjectName('custom')
|
||||
# self.custom.customContextMenuRequested.connect(self.myListWidgetContext)
|
||||
|
||||
# 右侧层叠窗口
|
||||
self.stackedWidget = QStackedWidget(self)
|
||||
|
@ -65,14 +62,13 @@ class MainWidget(QWidget):
|
|||
self.system_listWidget.addItem(self.important)
|
||||
self.system_listWidget.setItemWidget(self.important, self.important.widget)
|
||||
|
||||
self.two_day = SelfListWidgetItem('我的一天', 1, os.getcwd() + '/../images/sun.svg')
|
||||
self.self_listWidget.addItem(self.two_day)
|
||||
self.self_listWidget.setItemWidget(self.two_day, self.two_day.widget)
|
||||
# 测试添加下面的
|
||||
# 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.
|
||||
|
||||
pass
|
||||
|
||||
# todo
|
||||
# 仔细研究右键菜单
|
||||
# todo 仔细研究右键菜单
|
||||
|
||||
def myListWidgetContext(self, position):
|
||||
# 设置右键菜单
|
||||
|
@ -85,14 +81,14 @@ class MainWidget(QWidget):
|
|||
|
||||
# 查看右键时是否在item上面,如果不在.就不显示删除和修改.
|
||||
pop_menu.addAction(rename_action)
|
||||
if self.self_listWidget.itemAt(position):
|
||||
if self.custom.itemAt(position):
|
||||
pop_menu.addAction(del_action)
|
||||
pop_menu.addAction(rename_action)
|
||||
|
||||
rename_action.triggered.connect(self.RenameItem)
|
||||
copy_action.triggered.connect(self.CreateNewItem)
|
||||
del_action.triggered.connect(self.DeleteItem)
|
||||
pop_menu.exec_(self.self_listWidget.mapToGlobal(position))
|
||||
pop_menu.exec_(self.custom.mapToGlobal(position))
|
||||
|
||||
# 创建新的分组
|
||||
def CreateNewItem(self):
|
||||
|
@ -101,21 +97,21 @@ class MainWidget(QWidget):
|
|||
item.setTextAlignment(Qt.AlignCenter)
|
||||
# 使得item是可以编辑的.
|
||||
item.setFlags(item.flags() | Qt.ItemIsEditable)
|
||||
self.self_listWidget.addItem(item)
|
||||
self.custom.addItem(item)
|
||||
# 创建后就可以编辑item,用户自己起名字.
|
||||
self.self_listWidget.editItem(item)
|
||||
self.custom.editItem(item)
|
||||
|
||||
# 删除分组
|
||||
def DeleteItem(self):
|
||||
self.self_listWidget.takeItem(self.self_listWidget.currentRow())
|
||||
self.custom.takeItem(self.custom.currentRow())
|
||||
|
||||
# 重命名分组
|
||||
def RenameItem(self):
|
||||
curRow = self.self_listWidget.currentRow()
|
||||
item = self.self_listWidget.item(curRow)
|
||||
curRow = self.custom.currentRow()
|
||||
item = self.custom.item(curRow)
|
||||
item.setFlags(item.flags() | Qt.ItemIsEditable)
|
||||
self.self_listWidget.editItem(item)
|
||||
self.self_listWidget.itemChanged.connect(lambda: self.ChangeItem(item))
|
||||
self.custom.editItem(item)
|
||||
self.custom.itemChanged.connect(lambda: self.ChangeItem(item))
|
||||
|
||||
def ChangeItem(self, item):
|
||||
print("test")
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/*去掉item虚线边框*/
|
||||
* {
|
||||
/** {*/
|
||||
/* background: #f3f3f3;*/
|
||||
color: black ;
|
||||
}
|
||||
/* color: black ;*/
|
||||
/*}*/
|
||||
QListWidget, QListView, QTreeWidget, QTreeView {
|
||||
outline-style: 0px;
|
||||
|
||||
|
||||
}
|
||||
/*设置左侧选项的最小最大宽度,文字颜色和背景颜色*/
|
||||
QListWidget {
|
||||
|
@ -20,7 +19,8 @@ QListWidget {
|
|||
/*被选中时的背景颜色和左边框颜色*/
|
||||
QListWidget::item:selected {
|
||||
background: #eaeaea;
|
||||
border-left: 4px solid rgb(9, 187, 7);
|
||||
border-left: 5px solid rgb(9, 187, 7);
|
||||
/* border-left-width:10px;*/
|
||||
}
|
||||
|
||||
/*鼠标悬浮时的背景颜色*/
|
||||
|
@ -69,7 +69,7 @@ QListWidget::item {
|
|||
|
||||
/*右侧的层叠窗口的背景颜色*/
|
||||
QStackedWidget {
|
||||
color:snow;
|
||||
color:black;
|
||||
/* background: black;*/
|
||||
}
|
||||
/*todo_count_label 气泡效果*/
|
||||
|
@ -93,12 +93,12 @@ QLabel#menu{
|
|||
padding-right:10px;
|
||||
}
|
||||
/*主界面最下面的添加*/
|
||||
QLabel#add_item_label{
|
||||
text-align:right;
|
||||
background:url(../images/add.png) ;
|
||||
background-repeat:0;
|
||||
|
||||
QLabel#AddListAction::hover{
|
||||
/* text-align:center;*/
|
||||
background: #eaeaea;
|
||||
/* padding-right:25px;*/
|
||||
}
|
||||
|
||||
/*QLineEdit {*/
|
||||
/* border: 2px solid rgb(52,52,52);*/
|
||||
/* border-top-left-radius:10px; */
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import sys
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import (QApplication, QMainWindow, QStackedLayout, QWidget,
|
||||
QToolBar, QToolButton, QStyle, QColorDialog, QFontDialog,
|
||||
QVBoxLayout, QGroupBox, QRadioButton)
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
import os
|
||||
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
|
||||
class AddList(QLabel):
|
||||
class AddListAction(QLabel):
|
||||
def __init__(self):
|
||||
super(AddList, self).__init__()
|
||||
super(AddListAction, self).__init__()
|
||||
self.widget = QWidget(self)
|
||||
self.widget.setMaximumHeight(50)
|
||||
self.setObjectName('AddListAction')
|
||||
layout = QHBoxLayout()
|
||||
self.widget.setLayout(layout)
|
||||
self.add_image = QLabel()
|
||||
self.add_image.setPixmap(QPixmap(os.getcwd() + '/../images/add.png'))
|
||||
# self.add_image.setObjectName('pic_label')
|
||||
|
||||
self.add_text = QLabel("新建列表")
|
||||
layout.addWidget(self.add_image, 3)
|
||||
layout.addWidget(self.add_text, 4)
|
||||
# self.set
|
||||
|
|
|
@ -36,10 +36,7 @@ class SelfListWidgetItem(QListWidgetItem):
|
|||
self.item_name_label = QLabel(self.item_name)
|
||||
# print(self.item_name)
|
||||
self.item_name_label.setObjectName('item_name_label')
|
||||
# todo
|
||||
# 需要设置qss使字体靠中间一点
|
||||
# 如果有气泡使气泡靠右
|
||||
# done
|
||||
# todo 需要设置qss使字体靠中间一点,如果有气泡使气泡靠右 done
|
||||
|
||||
layout.addWidget(self.item_name_label, 3)
|
||||
|
||||
|
@ -55,4 +52,3 @@ class SelfListWidgetItem(QListWidgetItem):
|
|||
# 设置自定义的QListWidgetItem的sizeHint,不然无法显示
|
||||
self.setSizeHint(self.widget.sizeHint())
|
||||
|
||||
# 添加右键菜单
|
||||
|
|
|
@ -1,26 +1,8 @@
|
|||
import os
|
||||
import string
|
||||
import sys
|
||||
from random import randint, choice
|
||||
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import *
|
||||
from utils.QSSLoader import QSSLoader
|
||||
from PyQt5.QtCore import Qt, pyqtSignal
|
||||
|
||||
|
||||
# def get_icon():
|
||||
# # 测试模拟图标
|
||||
# pixmap = QPixmap(16, 16)
|
||||
# pixmap.fill(Qt.transparent)
|
||||
# painter = QPainter()
|
||||
# painter.begin(pixmap)
|
||||
# painter.setFont(QFont('Webdings', 11))
|
||||
# painter.setPen(Qt.GlobalColor(randint(4, 18)))
|
||||
# painter.drawText(0, 0, 16, 16, Qt.AlignCenter,
|
||||
# choice(string.ascii_letters))
|
||||
# painter.end()
|
||||
# return QIcon(pixmap)
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
|
||||
def about_qt():
|
||||
|
@ -36,12 +18,9 @@ class User(QLabel):
|
|||
super(User, self).__init__()
|
||||
self.widget = QWidget(self)
|
||||
self.widget.setMaximumWidth(300)
|
||||
# self.resize(200, 60)
|
||||
self.setObjectName('User')
|
||||
# todo
|
||||
# 修改布局使适合微软todo的样式
|
||||
# 设置点击事件,使用右键菜单的样式添加设置、同步、退出
|
||||
# 暂时就这样
|
||||
# todo:修改布局使适合微软todo的样式,设置点击事件,使用右键菜单的样式添加设置、同步、退出,暂时就这样
|
||||
|
||||
layout = QHBoxLayout()
|
||||
info_layout = QVBoxLayout()
|
||||
self.pic_label = QLabel('')
|
||||
|
@ -50,23 +29,22 @@ class User(QLabel):
|
|||
QPixmap(os.path.abspath('../') + '/images/user.svg').scaled(50, 50, Qt.IgnoreAspectRatio,
|
||||
Qt.SmoothTransformation))
|
||||
layout.addWidget(self.pic_label, 2)
|
||||
# layout.addStretch(2)
|
||||
self.user_name = QLabel("用户登录")
|
||||
self.user_name.setObjectName('user_name')
|
||||
self.user_mail = QLabel('794508986@qq.com')
|
||||
self.user_mail.setObjectName('user_mail')
|
||||
self.user_mail.setStyleSheet('font-size:16px')
|
||||
self.menu_label = QLabel('')
|
||||
self.menu_label.setObjectName('menu')
|
||||
self.menu_label.setPixmap(
|
||||
QPixmap(os.path.abspath('../') + '/images/up-down.svg').scaled(20, 20, Qt.IgnoreAspectRatio,
|
||||
Qt.SmoothTransformation))
|
||||
# self.menu_label = QLabel('')
|
||||
# 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)
|
||||
# layout.addWidget(self.menu_label, 1)
|
||||
|
||||
self.widget.setLayout(layout)
|
||||
# 设置右键菜单
|
||||
|
@ -94,10 +72,10 @@ class User(QLabel):
|
|||
self.context_menu.addAction(QIcon(os.getcwd() + '/../images/setting.svg'), '设置', self.setting)
|
||||
|
||||
self.context_menu.addAction(QIcon(os.getcwd() + '/../images/sync.svg'), '同步', self.sync)
|
||||
self.context_menu.addAction(QIcon(os.getcwd() + '/../images/sync.svg'), '退出', self.exit_account)
|
||||
self.context_menu.addAction(QIcon(os.getcwd() + '/../images/exit.svg'), '退出', self.exit_account)
|
||||
|
||||
# todo 设置右键点击事件
|
||||
|
||||
# todo
|
||||
# 设置右键点击事件
|
||||
def setting(self):
|
||||
pass
|
||||
|
||||
|
@ -108,13 +86,4 @@ class User(QLabel):
|
|||
pass
|
||||
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# app = QApplication(sys.argv)
|
||||
# main = User()
|
||||
# style_sheet = QSSLoader.read_qss_file('../resource/current.qss')
|
||||
# main.setStyleSheet(style_sheet)
|
||||
# # print(os.path.abspath('../'))
|
||||
#
|
||||
# app.setWindowIcon(QIcon(os.path.abspath('../') + '/images/todo.svg'))
|
||||
# main.show()
|
||||
# sys.exit(app.exec_())
|
||||
|
||||
|
|
Loading…
Reference in a new issue