diff --git a/utils/CreateToDo.py b/utils/CreateToDo.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/CreateToDoList.py b/utils/CreateToDoList.py new file mode 100644 index 0000000..347890b --- /dev/null +++ b/utils/CreateToDoList.py @@ -0,0 +1,5 @@ +import os + +print(os.environ['HOME']) +print(os.path.expandvars('~')) +print(os.path.expandvars('$HOME')) diff --git a/utils/JianGuoYun.py b/utils/JianGuoYun.py new file mode 100644 index 0000000..6dec226 --- /dev/null +++ b/utils/JianGuoYun.py @@ -0,0 +1,15 @@ +from webdav3.client import Client + +import configparser + +options = { + 'webdav_hostname': "https://dav.jianguoyun.com/dav/", + 'webdav_login': "794508986@qq.com", + 'webdav_password': "awncxpzjbgxxztbs" +} +client = Client(options) +# client.execute_request('list') +list1 = client.list('/') +print(list1) +exist = client.check('OpenTodoList') +print(exist) diff --git a/utils/nextcloud.py b/utils/NextCloud.py similarity index 100% rename from utils/nextcloud.py rename to utils/NextCloud.py diff --git a/utils/ReadConfig.py b/utils/ReadConfig.py new file mode 100644 index 0000000..1dbcda4 --- /dev/null +++ b/utils/ReadConfig.py @@ -0,0 +1,31 @@ +import configparser + +cfg_data = ''' +[info] +users_dir= /home +name= $USER +home_dir= %(users_dir)s/%(name)s +''' + +config = configparser.ConfigParser() + +config.read_string(cfg_data) + +users_dir = config['info']['users_dir'] +name = config['info']['name'] +home_dir = config['info']['home_dir'] + +print(users_dir) +print(name) +print(home_dir) +with open('test.ini', 'w') as config_file: + config.write(config_file) + +config.add_section('Accounts') +config['Accounts']['baseUrl'] = 'https://cloud.liyp.cc' +config['Accounts']['name'] = 'admin' +config['Accounts']['type'] = 'NextCloud' +config['Accounts']['username'] = 'admin' + +with open('test.ini', 'w') as config_file: + config.write(config_file) \ No newline at end of file diff --git a/utils/Sync.py b/utils/Sync.py new file mode 100644 index 0000000..6c28b00 --- /dev/null +++ b/utils/Sync.py @@ -0,0 +1,13 @@ +from webdav3.client import Client + + +# todo : 需要的参数有同步类型 +class Sync: + """ + :param type 同步的账号类型 + """ + + def __init__(self, type): + super(Sync, self).__init__() + types = ['NextCloud', 'JianGuoYun', 'WebDav'] + # 根据不同的账号类型调用不同的方式 diff --git a/utils/test.ini b/utils/test.ini new file mode 100644 index 0000000..af63095 --- /dev/null +++ b/utils/test.ini @@ -0,0 +1,11 @@ +[info] +users_dir = /home +name = $USER +home_dir = %(users_dir)s/%(name)s + +[Accounts] +baseurl = https://cloud.liyp.cc +name = admin +type = NextCloud +username = admin + diff --git a/view/ImportantView.py b/view/ImportantView.py new file mode 100644 index 0000000..52cc47d --- /dev/null +++ b/view/ImportantView.py @@ -0,0 +1,108 @@ +import os +import sys +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +from PyQt5.QtCore import Qt + +from view.AddToDoLabel import AddToDoAction + + +class Important(QWidget): + def __init__(self): + 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;}') + + # 布局样式:最外面一个大的垂直布局,里面的最上面标题是一个水平布局,水平布局显示的是一个垂直布局和一个右边的选项,用来更换背景 + # 布局样式:继承QWidget,里面一个垂直布局,最上面一个QWidget用来设置头部布局 + # 头部QWidget里面一个水平布局,水平布局里面一个QWidget(方便设置整体位置),然后是一个 + layout = QVBoxLayout() + head_layout = QHBoxLayout() + + head_widget = QWidget(self) + # todo : + # head_widget.setMinimumHeight(175) + + self.todo_list = QListWidget() + self.todo_list.setObjectName('todo_list') + + # todo : 重写QLabel,实现添加功能 + # 添加ToDo的标签 + self.add_todo = AddToDoAction() + self.add_todo.setAlignment(Qt.AlignCenter) + # self.add_todo.setPlaceholderText('添加任务') + + # head_widget.setMaximumHeight(100) + # head_widget. + # head_widget.setObjectName('head_widget') + head_widget.setAttribute(Qt.WA_StyledBackground) + # self.setStyleSheet('#head_widget{margin:50px}') + + # head_widget.setPalette(palette) + + head_widget.setLayout(head_layout) + head_layout.setAlignment(Qt.AlignCenter) + # head_left_layout = QVBoxLayout() + # layout.addStretch(0) + layout.addWidget(head_widget, 2, Qt.AlignTop) + # layout.addSpacing(1) + # layout.addStretch(0) + layout.addWidget(self.todo_list, 6, Qt.AlignCenter | Qt.AlignTop) + head_label = QLabel("重要") + head_label.setObjectName('head_label') + font = QFont() + font.setPointSize(32) + head_label.setFont(font) + + layout.addStretch(1) + + head_layout.addWidget(head_label, 8) + layout.addStretch(1) + layout.addWidget(self.add_todo, 2, Qt.AlignHCenter) + + self.menu_image = QPushButton() + self.menu_image.setObjectName('menu_image') + self.menu_image.setFixedSize(30, 30) + # 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) + # 背景透明 + button_menu.setAttribute(Qt.WA_TranslucentBackground) + # 无边框、去掉自带阴影 + button_menu.setWindowFlags( + button_menu.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint) + + self.menu_image.setMenu(button_menu) + + theme_label = QAction(self) + theme_label.setText('主题') + theme_label.setDisabled(True) + button_menu.addAction(theme_label) + button_menu.addSeparator() + # 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 : 下面的方法实现点击更换主题的功能 + + def menu_action(self, count): + # 点击按钮 + # self.menu_label = ChangeTheme() + self.setStyleSheet('#important{background-image:url("../images/4.jpg");' + 'background-position: center; border-radius: 10px;' + '}') + print('选中:' + count) diff --git a/view/UserLabel.py b/view/UserLabel.py index 67d13c8..8315650 100644 --- a/view/UserLabel.py +++ b/view/UserLabel.py @@ -28,11 +28,11 @@ class User(QLabel): QPixmap(os.path.abspath('../') + '/images/user.svg').scaled(50, 50, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)) layout.addWidget(self.pic_label, 2) - self.user_name = QLabel("用户登录") + 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.user_mail = QLabel('未同步') + # self.user_mail.setObjectName('user_mail') + self.user_mail.setStyleSheet('font-size:14px') # self.menu_label = QLabel('') # self.menu_label.setObjectName('menu') # self.menu_label.setPixmap( @@ -71,7 +71,7 @@ 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) + self.context_menu.addAction(QIcon(os.getcwd() + '/../images/exit.svg'), '登出', self.exit_account) # todo 设置右键点击事件 @@ -83,6 +83,3 @@ class User(QLabel): def exit_account(self): pass - - -