diff --git a/images/0.jpg b/images/0.jpg index de84a46..d1fd93e 100644 Binary files a/images/0.jpg and b/images/0.jpg differ diff --git a/images/10.jpg b/images/10.jpg deleted file mode 100644 index c620cf9..0000000 Binary files a/images/10.jpg and /dev/null differ diff --git a/images/11.jpg b/images/11.jpg deleted file mode 100644 index 3c8889b..0000000 Binary files a/images/11.jpg and /dev/null differ diff --git a/images/2.jpg b/images/2.jpg index d1fd93e..de84a46 100644 Binary files a/images/2.jpg and b/images/2.jpg differ diff --git a/images/4.jpg b/images/4.jpg index c64a5c0..8af802b 100644 Binary files a/images/4.jpg and b/images/4.jpg differ diff --git a/images/40.jpg b/images/40.jpg new file mode 100644 index 0000000..c64a5c0 Binary files /dev/null and b/images/40.jpg differ diff --git a/images/5.jpg b/images/5.jpg index 7f670e6..9b16c04 100644 Binary files a/images/5.jpg and b/images/5.jpg differ diff --git a/images/50.jpg b/images/50.jpg new file mode 100644 index 0000000..7f670e6 Binary files /dev/null and b/images/50.jpg differ diff --git a/images/8.jpg b/images/8.jpg index 8af802b..c620cf9 100644 Binary files a/images/8.jpg and b/images/8.jpg differ diff --git a/images/9.jpg b/images/9.jpg index 9b16c04..3c8889b 100644 Binary files a/images/9.jpg and b/images/9.jpg differ diff --git a/images/login.svg b/images/login.svg new file mode 100644 index 0000000..67f037a --- /dev/null +++ b/images/login.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/todo_info.svg b/images/todo_info.svg new file mode 100644 index 0000000..0b07e5d --- /dev/null +++ b/images/todo_info.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/main/main.py b/main/main.py index 5017b73..6ee8c1f 100644 --- a/main/main.py +++ b/main/main.py @@ -3,7 +3,7 @@ import sys from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtCore import Qt - +import configparser from utils.CreateToDo import CreateToDo from utils.QSSLoader import QSSLoader from view.ImportantView import Important @@ -149,6 +149,7 @@ class MainWindow(QWidget): if __name__ == "__main__": app = QApplication(sys.argv) main = MainWindow() + main.setWindowTitle('PyQtToDoList') # print(os.path.abspath('../')) style_sheet = QSSLoader.read_qss_file('../resource/current.qss') main.setStyleSheet(style_sheet) diff --git a/resource/current.qss b/resource/current.qss index 16d6789..c31d506 100644 --- a/resource/current.qss +++ b/resource/current.qss @@ -102,6 +102,13 @@ QLabel#add_todo_label{ border-bottom-right-radius:3px; background-color: rgba(211, 211, 211, 0.5); } + +QLineEdit#login_line{ + border: none; + background:transparent; + min-width:400px; +} + QLineEdit#add_line_edit { border: none; background:transparent; @@ -112,24 +119,27 @@ QLineEdit#add_line_edit { min-width:700px; } -/*QPushButton {*/ +QTabWidget{ + border-style:inset; +} +/*QPushButton#login_button {*/ /* max-width: 120px;*/ /* color: white;*/ -/* border-top-left-radius:10px; */ +/* border-top-left-radius:10px;*/ /* border-top-right-radius:10px;*/ /* border-bottom-left-radius:10px;*/ /* border-bottom-right-radius:10px;*/ /* background: pink;*/ /*}*/ -/*QPushButton:pressed,*/ -/*QPushButton:pressed:focus {*/ +QPushButton#login_button:pressed, +QPushButton#login_button:pressed:focus { /* 改变背景色*/ -/* background-color: #f50057;*/ + background-color: #f50057; /* 改变边框风格*/ -/* border-style:inset;*/ + border-style:inset; /* 改变边框风格*/ -/* border-style:inset;*/ -/*}*/ + border-style:inset; +} /*设置堆栈按钮样式*/ QPushButton#menu_image { @@ -174,6 +184,10 @@ QLabel#todo_count_label { border:1px solid black; font-size:10px; } + +QLabel#user_name{ + font-weight:bold; +} /*设置用户名金和用户邮箱样式*/ QLabel#pic_label{ diff --git a/test/NewWindow.py b/test/NewWindow.py new file mode 100644 index 0000000..e951294 --- /dev/null +++ b/test/NewWindow.py @@ -0,0 +1,42 @@ +from PyQt5.QtWidgets import * +import sys + + +class MainWindow(QWidget): + def __init__(self): + super().__init__() + self.initUI() + + def initUI(self): + # 设置窗口标题和大小 + self.setWindowTitle('TestWindow') + self.resize(400, 300) + + self.collec_btn = QPushButton('打开新窗口', self) + + layout = QVBoxLayout() + layout.addWidget(self.collec_btn) + self.setLayout(layout) + + self.show() + + +class NewWindow(QWidget): + def __init__(self): + super().__init__() + self.setWindowTitle('新窗口') + self.resize(280, 230) + + +if __name__ == '__main__': + + app = QApplication(sys.argv) + # 创建窗口 + window = MainWindow() + newWin = NewWindow() + + # 显示窗口 + window.show() + window.collec_btn.clicked.connect(newWin.show) + # 运行应用,并监听事件 + sys.exit(app.exec_()) \ No newline at end of file diff --git a/utils/CreateConfigure.py b/utils/CreateConfigure.py index b1adbc9..a3adc27 100644 --- a/utils/CreateConfigure.py +++ b/utils/CreateConfigure.py @@ -1,6 +1,7 @@ import configparser import platform import os +from utils import ReturnWorkDir # todo : 用来创建软件的配置信息 @@ -13,7 +14,7 @@ class CreateConfigure: """ def __init__(self, login_type, webdav_login, webdav_password, webdav_hostname=None): - config_file = self.return_config_file() + config_file = ReturnWorkDir.return_work_dir() + 'PyQtToDoList.ini' config = configparser.ConfigParser() if not os.path.exists(config_file): # print(config_file) @@ -51,14 +52,14 @@ class CreateConfigure: 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' + # 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') +# CreateConfigure('NextCloud', 'admin', '19990903@lyp', 'https://cloud.liyp.cc') diff --git a/utils/CreateToDo.py b/utils/CreateToDo.py index b8a75e5..5506f58 100644 --- a/utils/CreateToDo.py +++ b/utils/CreateToDo.py @@ -1,9 +1,10 @@ import os -import platform import uuid import json from datetime import datetime +from utils import ReturnWorkDir + """ todo : 暂时创建单个文件存储该列表下所有待办事项,文件命名为 {uuid}.otl 同级还有 library.json 存储该列表信息 @@ -22,8 +23,8 @@ class CreateToDo: def __init__(self, item_type, name, todo_list_uid=None): uid = str(uuid.uuid4()) - config_path = self.get_config_path() - todo_list_path = config_path + '/{' + uid + '}' + config_path = ReturnWorkDir.return_work_dir() + todo_list_path = config_path + '{' + uid + '}' # if not os.path.exists(todo_list_path): # os.mkdir(todo_list_path) default_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') @@ -76,14 +77,14 @@ class CreateToDo: except IOError as e: print(e) - def get_config_path(self): - - # print(platform.system()) - if platform.system() == 'Linux': - # print(os.environ['HOME'] + '/.config/PyQtToDoList') - # print(os.path.expandvars('~')) - # print(os.path.expandvars('$HOME') + '.config/PyQtToDoList') - return os.path.expandvars('$HOME') + '/.config/PyQtToDoList' - elif platform.system() == 'Windows': - print(os.getcwd() + 'config') - return os.getcwd() + 'config' + # def get_config_path(self): + # + # # print(platform.system()) + # if platform.system() == 'Linux': + # # print(os.environ['HOME'] + '/.config/PyQtToDoList') + # # print(os.path.expandvars('~')) + # # print(os.path.expandvars('$HOME') + '.config/PyQtToDoList') + # return os.path.expandvars('$HOME') + '/.config/PyQtToDoList' + # elif platform.system() == 'Windows': + # print(os.getcwd() + 'config') + # return os.getcwd() + 'config' diff --git a/utils/ReturnWorkDir.py b/utils/ReturnWorkDir.py new file mode 100644 index 0000000..385a827 --- /dev/null +++ b/utils/ReturnWorkDir.py @@ -0,0 +1,36 @@ +import os +import platform + + +def return_work_dir(): + if platform.system() == 'Linux': + work_path = os.path.expandvars('$HOME') + '/.config/' + if not os.path.exists(work_path): + os.mkdir(work_path) + return os.path.expandvars('$HOME') + '/.config/PyQtToDoList/' + elif platform.system() == 'Windows': + work_path = os.getcwd() + '/config/' + if not os.path.exists(work_path): + os.mkdir(work_path) + return work_path + + +import configparser + + +def read_init_file(): + config = configparser.ConfigParser() + try: + config.read(return_work_dir() + 'PyQtToDoList.ini') + account = config['Account'] + if account: + return [account['webdav_hostname'], account['webdav_login'], account['webdav_password'], account['type']] + except KeyError as e: + return False + + +# +# +# print(read_init_file()) +# webdav_hostname = read_init_file() +# print(webdav_hostname[2]) diff --git a/utils/TabWidgetTest.py b/utils/TabWidgetTest.py new file mode 100644 index 0000000..1a7ab9c --- /dev/null +++ b/utils/TabWidgetTest.py @@ -0,0 +1,68 @@ +import sys +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * + +class TabDemo(QTabWidget): + def __init__(self,parent=None): + super(TabDemo, self).__init__(parent) + + #创建3个选项卡小控件窗口 + self.tab1=QWidget() + self.tab2=QWidget() + self.tab3=QWidget() + + #将三个选项卡添加到顶层窗口中 + self.addTab(self.tab1, "Tab 1") + self.addTab(self.tab2, "Tab 2") + self.addTab(self.tab3, "Tab 3") + + #每个选项卡自定义的内容 + self.tab1UI() + self.tab2UI() + self.tab3UI() + + def tab1UI(self): + #表单布局 + layout=QFormLayout() + #添加姓名,地址的单行文本输入框 + layout.addRow('姓名',QLineEdit()) + layout.addRow('地址',QLineEdit()) + #设置选项卡的小标题与布局方式 + self.setTabText(0,'联系方式') + self.tab1.setLayout(layout) + + def tab2UI(self): + #zhu表单布局,次水平布局 + layout=QFormLayout() + sex=QHBoxLayout() + + #水平布局添加单选按钮 + sex.addWidget(QRadioButton('男')) + sex.addWidget(QRadioButton('女')) + + #表单布局添加控件 + layout.addRow(QLabel('性别'),sex) + layout.addRow('生日',QLineEdit()) + + #设置标题与布局 + self.setTabText(1,'个人详细信息') + self.tab2.setLayout(layout) + + def tab3UI(self): + #水平布局 + layout=QHBoxLayout() + + #添加控件到布局中 + layout.addWidget(QLabel('科目')) + layout.addWidget(QCheckBox('物理')) + layout.addWidget(QCheckBox('高数')) + + #设置小标题与布局方式 + self.setTabText(2,'教育程度') + self.tab3.setLayout(layout) +if __name__ == '__main__': + app=QApplication(sys.argv) + demo=TabDemo() + demo.show() + sys.exit(app.exec_()) \ No newline at end of file diff --git a/view/AddListLabel.py b/view/AddListLabel.py index e521057..ac11157 100644 --- a/view/AddListLabel.py +++ b/view/AddListLabel.py @@ -1,6 +1,5 @@ import os - -from PyQt5.QtCore import pyqtSignal +from PyQt5.QtCore import pyqtSignal, Qt from PyQt5.QtGui import * from PyQt5.QtWidgets import * @@ -24,11 +23,15 @@ class AddListAction(QLabel): layout.addWidget(self.add_image, 3) layout.addWidget(self.add_text, 4) - # def mousePressEvent(self, QMouseEvent): - # print('按下QLabel') - # self.setStyleSheet('background-color:#9f9f9f;') + def mousePressEvent(self, QMouseEvent): + if QMouseEvent.buttons() == Qt.LeftButton: + print('点击QLabel') - def mouseReleaseEvent(self, QMouseEvent): - print('释放QLabel') - self.create_todo_list.emit() - self.setStyleSheet('background-color:#eaeaea;') + self.create_todo_list.emit() + self.setStyleSheet('background-color:#eaeaea;') + + # def mouseReleaseEvent(self, QMouseEvent): + # if QMouseEvent.buttons == Qt.LeftButton: + # print('点击QLabel') + # self.create_todo_list.emit() + # self.setStyleSheet('background-color:#eaeaea;') diff --git a/view/ImportantView.py b/view/ImportantView.py index 2ff7178..19148f5 100644 --- a/view/ImportantView.py +++ b/view/ImportantView.py @@ -5,6 +5,7 @@ from PyQt5.QtWidgets import * from PyQt5.QtCore import Qt from view.AddToDoLabel import AddToDoAction +from view.ToDoItem import ToDoItem class Important(QWidget): @@ -12,7 +13,7 @@ class Important(QWidget): super(Important, self).__init__() self.setObjectName('important') self.setAttribute(Qt.WA_StyledBackground) - # todo : 使用网格布局设置背景图 + self.setStyleSheet('#important{background-image:url("../images/10.jpg");border-radius: 10px;}') # 布局样式:最外面一个大的垂直布局,里面的最上面标题是一个水平布局,水平布局显示的是一个垂直布局和一个右边的选项,用来更换背景 @@ -22,7 +23,7 @@ class Important(QWidget): head_layout = QHBoxLayout() head_widget = QWidget(self) - head_widget.setStyleSheet('background-color:gray') + # head_widget.setStyleSheet('background-color:gray') # todo : # head_widget.setMinimumHeight(175) @@ -70,41 +71,89 @@ class Important(QWidget): # self.menu_image.setScaledContents(True) pic_btn = QPixmap(os.getcwd() + "/../images/menu.png") self.menu_image.setIcon(QIcon(pic_btn)) - # self.menu_image.setFixedSize(QPixmap(os.getcwd() + "/../images/menu.png").size()) - # head_layout.addLayout(head_left_layout) + head_layout.addWidget(self.menu_image, 2) head_layout.addStretch(1) self.setLayout(layout) # self.menu_image.clicked.connect(self.menu_action) - button_menu = QMenu(self) + self.button_menu = QMenu(self) # 背景透明 - button_menu.setAttribute(Qt.WA_TranslucentBackground) + self.button_menu.setAttribute(Qt.WA_TranslucentBackground) # 无边框、去掉自带阴影 - button_menu.setWindowFlags( - button_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint) + self.button_menu.setWindowFlags( + self.button_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint) - self.menu_image.setMenu(button_menu) + self.menu_image.setMenu(self.button_menu) theme_label = QAction(self) theme_label.setText('主题') theme_label.setDisabled(True) - button_menu.addAction(theme_label) - button_menu.addSeparator() + 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') + label_action1.triggered.connect(lambda: self.menu_action(1)) + self.button_menu.addAction(label_action1) + + label_action2 = QAction(self) + label_action2.setIcon(QIcon('../images/2.jpg')) + label_action2.setText('渐变2') + label_action2.triggered.connect(lambda: self.menu_action(2)) + self.button_menu.addAction(label_action2) + + label_action3 = QAction(self) + label_action3.setIcon(QIcon('../images/3.jpg')) + label_action3.setText('渐变3') + label_action3.triggered.connect(lambda: self.menu_action(3)) + self.button_menu.addAction(label_action3) + + label_action4 = QAction(self) + label_action4.setIcon(QIcon('../images/4.jpg')) + label_action4.setText('渐变4') + label_action4.triggered.connect(lambda: self.menu_action(4)) + self.button_menu.addAction(label_action4) + + label_action5 = QAction(self) + label_action5.setIcon(QIcon('../images/5.jpg')) + label_action5.setText('渐变5') + label_action5.triggered.connect(lambda: self.menu_action(5)) + self.button_menu.addAction(label_action5) # 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) + # 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 : 下面的方法实现点击更换主题的功能 def menu_action(self, count): # 点击按钮 + count = str(count) # self.menu_label = ChangeTheme() - self.setStyleSheet('#important{background-image:url("../images/4.jpg");' - 'background-position: center; border-radius: 10px;' - '}') + self.setStyleSheet('#important{background-image:url("../images/' + count + '.jpg");' + 'background-position: center; border-radius: 10px;' + '}') print('选中:' + count) + + def line_edit_add(self, name): + self.add_todo.todo_name.emit(name) + # print('添加的新ToDo:' + name) + 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() diff --git a/view/LoginWidget.py b/view/LoginWidget.py new file mode 100644 index 0000000..77961b8 --- /dev/null +++ b/view/LoginWidget.py @@ -0,0 +1,200 @@ +from PyQt5.QtCore import Qt +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +import configparser +from utils.ReturnWorkDir import * + + +# +# +# class LoginWindow(QWidget): +# def __init__(self): +# super().__init__() +# self.setStyleSheet('QPushButton#login_button {max-width: 120px;color: white;' +# 'border-top-left-radius:10px;border-top-right-radius:10px;' +# 'border-bottom-left-radius:10px;border-bottom-right-radius:10px;background: #74d4ec;}' +# 'QPushButton#login_button:pressed,QPushButton#login_button:pressed:focus {' +# 'background-color: #f50057;border-style:inset;border-style:inset;' +# '}') +# layout = QVBoxLayout() +# self.setLayout(layout) +# self.setWindowTitle('登录') +# self.resize(500, 600) +# self.tab_widget = QTabWidget() +# self.tab_widget.setStyleSheet('border:none;background-color:#f3f3f3') +# nextcloud_widget = LoginWidget('NextCloud') +# self.tab_widget.addTab(nextcloud_widget, '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) +# button_layout = QHBoxLayout() +# self.test_link = QPushButton('测试连接') +# self.test_link.setObjectName('login_button') +# self.link = QPushButton('保存配置') +# self.link.setObjectName('login_button') +# button_layout.addWidget(self.test_link) +# button_layout.addWidget(self.link) +# +# layout.addLayout(button_layout) +# self.link.clicked.connect(self.close) + + +class LoginWidget(QTabWidget): + # todo : 添加一个信号,等点击保存后在 main 里面更新未登录的信息 + """ + :param login_type 登录账号类型 + """ + + def __init__(self): + super(LoginWidget, self).__init__() + self.resize(500, 300) + self.setStyleSheet('QLineEdit#lineedit{border: 1px solid gray;background:#f3f3f3;min-width:300px;' + 'border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-left-radius:5px;' + 'border-bottom-right-radius:5px;}' + 'QPushButton#login_button {max-width: 120px;color: white;' + 'border-top-left-radius:10px;border-top-right-radius:10px;' + 'border-bottom-left-radius:10px;border-bottom-right-radius:10px;background: #74d4ec;}' + 'QPushButton#login_button:pressed,QPushButton#login_button:pressed:focus {' + 'background-color: #f50057;border-style:inset;border-style:inset;' + '}') + # layout = QVBoxLayout() + self.setWindowTitle('登录') + + # host_name_layout = QHBoxLayout() + + # self.host_address = QLabel('服务器地址:') + # form_layout = QFormLayout() + self.nextcloud_address_lineedit = QLineEdit() + self.nextcloud_address_lineedit.setObjectName('lineedit') + self.nextcloud_address_lineedit.setPlaceholderText('https://nextcloud.example.com') + # host_name_layout.addWidget(self.host_address, 3) + # host_name_layout.addWidget(self.host_address_lineedit, 6) + + # host_name_layout = QHBoxLayout() + # self.host_address = QLabel('服务器地址:') + self.dav_address_lineedit = QLineEdit() + self.dav_address_lineedit.setObjectName('lineedit') + self.dav_address_lineedit.setPlaceholderText('https://webdav.example.com/dav') + + self.nextcloud_name_lineedit = QLineEdit() + self.nextcloud_name_lineedit.setPlaceholderText('用户名') + self.nextcloud_name_lineedit.setObjectName('lineedit') + # form_layout.addRow('用户:', self.name_lineedit) + self.dav_name_lineedit = QLineEdit() + self.dav_name_lineedit.setPlaceholderText('用户名') + self.dav_name_lineedit.setObjectName('lineedit') + + self.nextcloud_password_lineedit = QLineEdit() + self.nextcloud_password_lineedit.setEchoMode(QLineEdit.Password) + self.nextcloud_password_lineedit.setPlaceholderText('密码') + self.nextcloud_password_lineedit.setObjectName('lineedit') + # form_layout.addRow('密码:', self.password_lineedit) + self.dav_password_lineedit = QLineEdit() + self.dav_password_lineedit.setEchoMode(QLineEdit.Password) + self.dav_password_lineedit.setPlaceholderText('密码') + self.dav_password_lineedit.setObjectName('lineedit') + + self.jianguoyun_name_lineedit = QLineEdit() + self.jianguoyun_name_lineedit.setPlaceholderText('用户名') + self.jianguoyun_name_lineedit.setObjectName('lineedit') + + self.jianguoyun_password_lineedit = QLineEdit() + self.jianguoyun_password_lineedit.setEchoMode(QLineEdit.Password) + self.jianguoyun_password_lineedit.setPlaceholderText('密码') + self.jianguoyun_password_lineedit.setObjectName('lineedit') + + button_layout = QHBoxLayout() + self.test_link = QPushButton('测试连接') + self.test_link.setObjectName('login_button') + self.link = QPushButton('保存配置') + self.link.setObjectName('login_button') + button_layout.addWidget(self.test_link) + button_layout.addWidget(self.link) + # form_layout.addRow(self.test_link, self.link) + + # layout.addLayout(form_layout) + # self.setLayout(layout) + # self.show() + + self.test_link.clicked.connect(self.link_test) + self.link.clicked.connect(self.close) + self.nextcloud_tab = QWidget() + self.jianguoyun_tab = QWidget() + self.webdav_tab = QWidget() + + self.addTab(self.nextcloud_tab, 'NextCloud') + self.addTab(self.jianguoyun_tab, '坚果云') + self.addTab(self.webdav_tab, 'WebDav') + + self.initUI1() + self.initUI2() + self.initUI3() + + # todo : 方向不对,这样设计极其不好,需要更换方式 + + def initUI1(self): + form_layout = QFormLayout() + form_layout.addRow('服务器地址:', self.nextcloud_address_lineedit) + form_layout.addRow('用户:', self.nextcloud_name_lineedit) + form_layout.addRow('密码:', self.nextcloud_password_lineedit) + form_layout.addRow(self.test_link, self.link) + self.nextcloud_tab.setLayout(form_layout) + + def initUI2(self): + form_layout = QFormLayout() + form_layout.addRow('服务器地址:', self.dav_address_lineedit) + form_layout.addRow('用户:', self.dav_name_lineedit) + form_layout.addRow('密码:', self.dav_password_lineedit) + form_layout.addRow(self.test_link, self.link) + self.webdav_tab.setLayout(form_layout) + pass + + def initUI3(self): + form_layout = QFormLayout() + form_layout.addRow('用户:', self.jianguoyun_name_lineedit) + form_layout.addRow('密码:', self.jianguoyun_password_lineedit) + form_layout.addRow(self.test_link, self.link) + self.jianguoyun_tab.setLayout(form_layout) + pass + + def initUI(self, login_type): + form_layout = QFormLayout() + + if login_type == 'NextCloud': + print(login_type) + form_layout.addRow('服务器地址:', self.nextcloud_address_lineedit) + form_layout.addRow('用户:', self.name_lineedit) + form_layout.addRow('密码:', self.password_lineedit) + form_layout.addRow(self.test_link, self.link) + self.nextcloud_tab.setLayout(form_layout) + elif login_type == 'WebDav': + print(login_type) + form_layout.addRow('服务器地址:', self.dav_address_lineedit) + + form_layout.addRow('用户:', self.name_lineedit) + form_layout.addRow('密码:', self.password_lineedit) + form_layout.addRow(self.test_link, self.link) + self.webdav_tab.setLayout(form_layout) + else: + print(login_type) + form_layout.addRow('用户:', self.name_lineedit) + form_layout.addRow('密码:', self.password_lineedit) + form_layout.addRow(self.test_link, self.link) + self.jianguoyun_tab.setLayout(form_layout) + # if login_type == 'NextCloud': + # self.nextcloud_tab.setLayout(form_layout) + # elif login_type == 'WebDav': + # self.webdav_tab.setLayout(form_layout) + # else: + # self.jianguoyun_tab.setLayout(form_layout) + + def link_test(self): + pass + + def save_link(self): + self.close() + pass diff --git a/view/LoginWidget1.py b/view/LoginWidget1.py new file mode 100644 index 0000000..fc257f3 --- /dev/null +++ b/view/LoginWidget1.py @@ -0,0 +1,116 @@ +from PyQt5.QtCore import Qt +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +import configparser +from utils.ReturnWorkDir import * + + +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) + + +class LoginWidget(QWidget): + """ + :param login_type 登录账号类型 + """ + + def __init__(self): + super(LoginWidget, self).__init__() + self.setStyleSheet('QLineEdit#lineedit{border: 1px solid gray;background:#f3f3f3;min-width:300px;' + 'border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-left-radius:5px;' + 'border-bottom-right-radius:5px;}' + 'QPushButton#login_button {max-width: 120px;color: white;' + 'border-top-left-radius:10px;border-top-right-radius:10px;' + 'border-bottom-left-radius:10px;border-bottom-right-radius:10px;background: #74d4ec;}' + 'QPushButton#login_button:pressed,QPushButton#login_button:pressed:focus {' + 'background-color: #f50057;border-style:inset;border-style:inset;' + '}') + + self.setWindowTitle('登录') + self.resize(500, 600) + self.tab_widget = QTabWidget() + layout = QVBoxLayout() + + sub_widget = QWidget() + self.sub_layout = QVBoxLayout() + sub_widget.setLayout(self.sub_layout) + + self.host_name_layout = QHBoxLayout() + + self.host_address = QLabel('服务器地址:') + self.host_address_lineedit = QLineEdit() + self.host_address_lineedit.setObjectName('lineedit') + self.host_address_lineedit.setPlaceholderText('https://nextcloud.example.com') + self.host_name_layout.addWidget(self.host_address, 3) + self.host_name_layout.addWidget(self.host_address_lineedit, 6) + + self.host_name_layout = QHBoxLayout() + self.host_address = QLabel('服务器地址:') + self.host_address_lineedit = QLineEdit() + self.host_address_lineedit.setObjectName('lineedit') + self.host_address_lineedit.setPlaceholderText('https://webdav.example.com/dav') + self.host_name_layout.addWidget(self.host_address, 3) + self.host_name_layout.addWidget(self.host_address_lineedit, 6) + + name_layout = QHBoxLayout() + self.name = QLabel('用户:') + self.name_lineedit = QLineEdit() + self.name_lineedit.setPlaceholderText('用户名') + self.name_lineedit.setObjectName('lineedit') + name_layout.addWidget(self.name, 3) + name_layout.addWidget(self.name_lineedit) + self.sub_layout.addLayout(name_layout) + + password_layout = QHBoxLayout() + self.password = QLabel('密码:') + self.password_lineedit = QLineEdit() + self.password_lineedit.setEchoMode(QLineEdit.Password) + self.password_lineedit.setPlaceholderText('密码') + self.password_lineedit.setObjectName('lineedit') + password_layout.addWidget(self.password, 3) + password_layout.addWidget(self.password_lineedit, 6) + self.sub_layout.addLayout(password_layout) + + button_layout = QHBoxLayout() + self.test_link = QPushButton('测试连接') + self.test_link.setObjectName('login_button') + self.link = QPushButton('保存配置') + self.link.setObjectName('login_button') + button_layout.addWidget(self.test_link) + button_layout.addWidget(self.link) + layout.addLayout(button_layout) + self.setLayout(layout) + self.sub_widget.show() + + self.test_link.clicked.connect(self.link_test) + self.link.clicked.connect(self.close) + + def link_test(self): + pass + + def save_link(self): + self.close() + pass + + def initUI(self, login_type): + if login_type == 'NextCloud': + print(login_type) + self.sub_layout.addLayout(self.host_name_layout) + elif login_type == 'WebDav': + print(login_type) + self.sub_layout.addLayout(self.host_name_layout) diff --git a/view/MyDayView.py b/view/MyDayView.py index a542c87..5cea3cb 100644 --- a/view/MyDayView.py +++ b/view/MyDayView.py @@ -8,11 +8,20 @@ from view.MyDayHeadLabel import HeadLabel from view.ToDoItem import ToDoItem +class Menu(QMenu): + def __init__(self, *__args): + super(Menu, self).__init__() + self.index = None + + def set_index(self, index): + self.index = index + + class MyDay(QWidget): def __init__(self, parent=None): super(MyDay, self).__init__() self.setObjectName('my_day') - self.setStyleSheet('#my_day{background-image:url("../images/10.jpg");border-radius: 10px;}') + self.setStyleSheet('#my_day{background-image:url("../images/0.jpg");border-radius: 10px;}') self.setAttribute(Qt.WA_StyledBackground) # 下面这一句有问题,需要修复修改主题的实现方法 @@ -30,7 +39,7 @@ class MyDay(QWidget): head_layout = QHBoxLayout() # 头部总布局 head_widget = QWidget(self) - head_widget.setStyleSheet('background-color:gray') + # head_widget.setStyleSheet('background-color:gray') # head_widget.setMinimumHeight(175) # head_widget.setMaximumHeight(180) @@ -75,38 +84,79 @@ class MyDay(QWidget): self.setLayout(layout) # self.menu_image.clicked.connect(self.menu_action) - button_menu = QMenu(self) + self.button_menu = QMenu(self) # 背景透明 - button_menu.setAttribute(Qt.WA_TranslucentBackground) + self.button_menu.setAttribute(Qt.WA_TranslucentBackground) # 无边框、去掉自带阴影 - button_menu.setWindowFlags( - button_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint) + self.button_menu.setWindowFlags( + self.button_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint) - self.menu_image.setMenu(button_menu) + self.menu_image.setMenu(self.button_menu) theme_label = QAction(self) theme_label.setText('主题') theme_label.setDisabled(True) - button_menu.addAction(theme_label) - button_menu.addSeparator() + 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_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) + # for i in range(11): + label_action1 = QAction(self) + label_action1.setIcon(QIcon('../images/1.jpg')) + label_action1.setText('渐变1') + label_action1.triggered.connect(lambda: self.menu_action(1)) + self.button_menu.addAction(label_action1) - # pass + label_action2 = QAction(self) + label_action2.setIcon(QIcon('../images/2.jpg')) + label_action2.setText('渐变2') + label_action2.triggered.connect(lambda: self.menu_action(2)) + self.button_menu.addAction(label_action2) - # todo : 下面的方法实现点击更换主题的功能 + label_action3 = QAction(self) + label_action3.setIcon(QIcon('../images/3.jpg')) + label_action3.setText('渐变3') + label_action3.triggered.connect(lambda: self.menu_action(3)) + self.button_menu.addAction(label_action3) + + label_action4 = QAction(self) + label_action4.setIcon(QIcon('../images/4.jpg')) + label_action4.setText('渐变4') + label_action4.triggered.connect(lambda: self.menu_action(4)) + self.button_menu.addAction(label_action4) + + label_action5 = QAction(self) + label_action5.setIcon(QIcon('../images/5.jpg')) + label_action5.setText('渐变5') + label_action5.triggered.connect(lambda: self.menu_action(5)) + self.button_menu.addAction(label_action5) + # print(self.button_menu.size()) + + # print(button_menu.actions()[0]) + # actions = button_menu.actions() + # for i in actions: + # print(i) + # j = 1 + # i.triggered.connect(lambda: self.menu_action(str(j))) + # j += 1 + + # pass + + # todo : 下面的方法实现点击更换主题的功能 def menu_action(self, count): + count = str(count) # 点击按钮 - self.setStyleSheet('#my_day{background-image:url("../images/4.jpg");' - 'background-position: center; border-radius: 10px;' - '}') + self.setStyleSheet('#my_day{background-image:url("../images/' + count + '.jpg");' + 'background-position: center; border-radius: 10px;' + '}') self.head_label.show() print('选中:' + count) diff --git a/view/ToDoListView.py b/view/ToDoListView.py index 97bf8c4..210f2af 100644 --- a/view/ToDoListView.py +++ b/view/ToDoListView.py @@ -5,15 +5,25 @@ from PyQt5.QtWidgets import * from PyQt5.QtCore import Qt 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): def __init__(self, list_name): super(ToDoList, self).__init__() - self.setObjectName('important') + self.setObjectName('todolist') self.setAttribute(Qt.WA_StyledBackground) # todo : 使用网格布局设置背景图 - self.setStyleSheet('#important{background-image:url("../images/10.jpg");border-radius: 10px;}') + self.setStyleSheet('#todolist{background-image:url("../images/10.jpg");border-radius: 10px;}') # 布局样式:最外面一个大的垂直布局,里面的最上面标题是一个水平布局,水平布局显示的是一个垂直布局和一个右边的选项,用来更换背景 # 布局样式:继承QWidget,里面一个垂直布局,最上面一个QWidget用来设置头部布局 @@ -77,33 +87,82 @@ class ToDoList(QWidget): self.setLayout(layout) # self.menu_image.clicked.connect(self.menu_action) - button_menu = QMenu(self) + self.button_menu = QMenu(self) # 背景透明 - button_menu.setAttribute(Qt.WA_TranslucentBackground) + self.button_menu.setAttribute(Qt.WA_TranslucentBackground) # 无边框、去掉自带阴影 - button_menu.setWindowFlags( - button_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint) + self.button_menu.setWindowFlags( + self.button_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint) - self.menu_image.setMenu(button_menu) + self.menu_image.setMenu(self.button_menu) theme_label = QAction(self) theme_label.setText('主题') theme_label.setDisabled(True) - button_menu.addAction(theme_label) - button_menu.addSeparator() + 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') + label_action1.triggered.connect(lambda: self.menu_action(1)) + self.button_menu.addAction(label_action1) + + label_action2 = QAction(self) + label_action2.setIcon(QIcon('../images/2.jpg')) + label_action2.setText('渐变2') + label_action2.triggered.connect(lambda: self.menu_action(2)) + self.button_menu.addAction(label_action2) + + label_action3 = QAction(self) + label_action3.setIcon(QIcon('../images/3.jpg')) + label_action3.setText('渐变3') + label_action3.triggered.connect(lambda: self.menu_action(3)) + self.button_menu.addAction(label_action3) + + label_action4 = QAction(self) + label_action4.setIcon(QIcon('../images/4.jpg')) + label_action4.setText('渐变4') + label_action4.triggered.connect(lambda: self.menu_action(4)) + self.button_menu.addAction(label_action4) + + label_action5 = QAction(self) + label_action5.setIcon(QIcon('../images/5.jpg')) + label_action5.setText('渐变5') + label_action5.triggered.connect(lambda: self.menu_action(5)) + self.button_menu.addAction(label_action5) # 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) + # 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 : 下面的方法实现点击更换主题的功能 def menu_action(self, count): # 点击按钮 + count = str(count) # self.menu_label = ChangeTheme() - self.setStyleSheet('#important{background-image:url("../images/4.jpg");' - 'background-position: center; border-radius: 10px;' - '}') - print('选中:' + count) + self.setStyleSheet('#todolist{background-image:url("../images/' + count + '.jpg");' + 'background-position: center; border-radius: 10px;' + '}') + # print('选中:' + count) + + def line_edit_add(self, name): + self.add_todo.todo_name.emit(name) + # print('添加的新ToDo:' + name) + 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() diff --git a/view/UserLabel.py b/view/UserLabel.py index 8315650..4c9f3e9 100644 --- a/view/UserLabel.py +++ b/view/UserLabel.py @@ -1,12 +1,31 @@ import os +import sys + from PyQt5.QtCore import Qt from PyQt5.QtGui import * from PyQt5.QtWidgets import * +import configparser +from utils.ReturnWorkDir import * +from view.LoginWidget import LoginWidget -def about_qt(): - # 关于Qt - QApplication.instance().aboutQt() +# 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) class User(QLabel): @@ -31,9 +50,15 @@ class User(QLabel): self.user_name = QLabel("本地账号") self.user_name.setObjectName('user_name') self.user_mail = QLabel('未同步') - # self.user_mail.setObjectName('user_mail') + + # 读取文件内容 + self.account = read_init_file() + if self.account: + self.user_name.setText(self.account[1]) + self.user_mail.setText(self.account[3]) + # self.user_mail.setObjectName('user_mail') self.user_mail.setStyleSheet('font-size:14px') - # self.menu_label = QLabel('') + # 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, @@ -71,7 +96,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/exit.svg'), '登出', self.exit_account) + if self.account: + self.context_menu.addAction(QIcon(os.getcwd() + '/../images/exit.svg'), '登出', self.exit_account) + else: + self.context_menu.addAction(QIcon(os.getcwd() + '/../images/login.svg'), '登录', self.login_account) # todo 设置右键点击事件 @@ -83,3 +111,20 @@ class User(QLabel): def exit_account(self): pass + + def login_account(self): + + 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_())