diff --git a/images/SwiftUI.png b/images/SwiftUI.png new file mode 100644 index 0000000..9687d4d Binary files /dev/null and b/images/SwiftUI.png differ diff --git a/images/g.jpeg b/images/g.jpeg new file mode 100644 index 0000000..0264044 Binary files /dev/null and b/images/g.jpeg differ diff --git a/images/icon.png b/images/icon.png new file mode 100644 index 0000000..2f12939 Binary files /dev/null and b/images/icon.png differ diff --git a/images/icon.svg b/images/icon.svg new file mode 100644 index 0000000..1da81a5 --- /dev/null +++ b/images/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/lol.png b/images/lol.png new file mode 100644 index 0000000..8e081f5 Binary files /dev/null and b/images/lol.png differ diff --git a/images/pic_list.png b/images/pic_list.png new file mode 100644 index 0000000..3b8f0a1 Binary files /dev/null and b/images/pic_list.png differ diff --git a/images/setting.png b/images/setting.png new file mode 100644 index 0000000..cb8a195 Binary files /dev/null and b/images/setting.png differ diff --git a/images/setting_icon.png b/images/setting_icon.png new file mode 100644 index 0000000..dbd50d9 Binary files /dev/null and b/images/setting_icon.png differ diff --git a/images/todo.svg b/images/todo.svg new file mode 100644 index 0000000..00804b5 --- /dev/null +++ b/images/todo.svg @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/up.png b/images/up.png new file mode 100644 index 0000000..3caedfa Binary files /dev/null and b/images/up.png differ diff --git a/images/upload.png b/images/upload.png new file mode 100644 index 0000000..a6d90d4 Binary files /dev/null and b/images/upload.png differ diff --git a/resource/current.qss b/resource/current.qss new file mode 100644 index 0000000..f842b8d --- /dev/null +++ b/resource/current.qss @@ -0,0 +1,64 @@ +/*去掉item虚线边框*/ +QListWidget, QListView, QTreeWidget, QTreeView { + outline: 0px; +} +/*设置左侧选项的最小最大宽度,文字颜色和背景颜色*/ +QListWidget { + min-width: 120px; + max-width: 120px; + color: white; + background: black; + +} + +QPushButton { + 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: pink; +} +QPushButton:pressed, +QPushButton:pressed:focus { + /* 改变背景色 */ + background-color: #f50057; + /* 改变边框风格 */ + border-style:inset; + /* 改变边框风格 */ + border-style:inset; +} + +QPushButton#upload_btn { + padding: 3px 20px; + text-align:center; +} + + +/*被选中时的背景颜色和左边框颜色*/ +QListWidget::item:selected { + background: rgb(52, 52, 52); + border-right: 4px solid rgb(9, 187, 7); +} +/*鼠标悬停颜色*/ +HistoryPanel::item:hover { + background: rgb(52, 52, 52); +} + +/*右侧的层叠窗口的背景颜色*/ +QStackedWidget { + background: rgb(30, 30, 30); +} +/*模拟的页面*/ +QLabel { + color: white; +} +QLineEdit { + border: 2px solid rgb(52,52,52); + border-top-left-radius:10px; + border-top-right-radius:10px; + border-bottom-left-radius:10px; + border-bottom-right-radius:10px; + +} \ No newline at end of file diff --git a/start.py b/start.py index 0c96a34..77452d4 100644 --- a/start.py +++ b/start.py @@ -1,91 +1,72 @@ +import os import sys +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.QtCore import Qt, QSize -from PyQt5 import QtCore -from PyQt5.QtGui import QFont, QIcon -from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QDialog, QLabel, QLineEdit, QGridLayout, QApplication -from PyQt5.QtCore import Qt -from qt_material import apply_stylesheet +from tool.UploadTip import UploadTip +from tool.ConfigWidget import ConfigView +from tool import QSSLoader - -class MainWin(QWidget): +class MainWindow(QWidget): def __init__(self): - super(MainWin, self).__init__() - self.setWindowTitle('上传至阿里云cos') - self.resize(400, 500) - self.setWindowIcon(QIcon('./images/icon.png')) + super(MainWindow, self).__init__() + layout = QHBoxLayout(self, spacing=0) + self.listWidget = QListWidget() + self.resize(800, 600) - layout = QVBoxLayout() + layout.addWidget(self.listWidget) - self.config_btn = QPushButton('配置') - # self.config_btn - self.config_btn.setFixedSize(60, 40) + # 右侧层叠窗口 + self.stackedWidget = QStackedWidget(self) + layout.addWidget(self.stackedWidget) + + layout.setContentsMargins(0, 0, 0, 0) - self.config_btn.clicked.connect(self.configAction) - layout.addStretch() - layout.addWidget(self.config_btn, 0, Qt.AlignCenter) - layout.addStretch() - # layout.addLayout(tip_widget) - layout.addStretch() self.setLayout(layout) + self.iniUI() - def configAction(self): - dialog = QDialog() - dialog.setMinimumWidth(500) - dialog.setWindowTitle("配置oss信息") - access_key_id_label = QLabel('access_key_id:') - access_key_id_text = QLineEdit() - access_key_secret_label = QLabel('access_key_secret:') - access_key_secret_text = QLineEdit() - access_key_secret_text.setEchoMode(QLineEdit.Password) - bucket_name_label = QLabel('bucket_name') - bucket_name_text = QLineEdit() - bucket_name_text.setPlaceholderText('设置存储空间名') - endpoint_label = QLabel('endpoint') - endpoint_text = QLineEdit() - endpoint_text.setPlaceholderText('地域节点(如:oss-cn-beijing.aliyuncs.com)') - upload_path_label = QLabel('upload_path') - upload_path_text = QLineEdit() - upload_path_text.setPlaceholderText('上传路径(如:images/)') - upload_domain_label = QLabel('upload_domain') - upload_domain_text = QLineEdit() - upload_domain_text.setPlaceholderText('绑定域名(需要带https://)') - dialog_layout = QGridLayout() - font = QFont() - font.setFamily("Arial") - font.setPointSize(50) - dialog.setFont(font) - dialog_layout.addWidget(access_key_id_label, 0, 0) - dialog_layout.addWidget(access_key_id_text, 0, 1) - dialog_layout.addWidget(access_key_secret_label, 1, 0) - dialog_layout.addWidget(access_key_secret_text, 1, 1) - dialog_layout.addWidget(bucket_name_label, 2, 0) - dialog_layout.addWidget(bucket_name_text, 2, 1) - dialog_layout.addWidget(endpoint_label, 3, 0) - dialog_layout.addWidget(endpoint_text, 3, 1) - dialog_layout.addWidget(upload_path_label, 4, 0) - dialog_layout.addWidget(upload_path_text, 4, 1) - dialog_layout.addWidget(upload_domain_label, 5, 0) - dialog_layout.addWidget(upload_domain_text, 5, 1) - save_btn = QPushButton('保存配置') - content = [access_key_id_text.text(), access_key_secret_text.text(), bucket_name_text.text(), - endpoint_text.text(), upload_path_text.text(), upload_domain_text.text()] + def iniUI(self): + # 初始化界面 + # 通过QListWidget的当前item变化来切换QStackedWidget中的序号 + self.listWidget.currentRowChanged.connect( + self.stackedWidget.setCurrentIndex) + # 去掉边框 + # self.listWidget.setFrameShape(QListWidget.NoFrame) + # # 隐藏滚动条 + self.listWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + self.listWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - save_btn.clicked.connect(lambda: self.save_oss_config(content)) - dialog_layout.addWidget(save_btn, 6, 1) - dialog.setLayout(dialog_layout) - # 设置窗口的属性为ApplicationModal模态,用户只有关闭弹窗后,才能关闭主界面 - dialog.setWindowModality(QtCore.Qt.ApplicationModal) - dialog.exec_() + # print(os.getcwd()) + self.upload_item = QListWidgetItem( + QIcon(QPixmap(os.getcwd()+'/images/upload.png')), '上传区', self.listWidget) + self.set_item = QListWidgetItem( + QIcon(QPixmap(os.getcwd()+'/images/setting_icon.png')), '配置区域') + self.upload_item.setSizeHint(QSize(16777215, 60)) + # 文字居中 + self.upload_item.setTextAlignment(Qt.AlignCenter) + + self.set_item.setSizeHint(QSize(16777215, 60)) + # 文字居中 + self.set_item.setTextAlignment(Qt.AlignCenter) + + self.listWidget.addItem(self.upload_item) + self.listWidget.addItem(self.set_item) + upload_widget = UploadTip() + config_widget = ConfigView() + + self.stackedWidget.addWidget(upload_widget) + self.stackedWidget.addWidget(config_widget) - def save_oss_config(self, content): - print(content) - for i in content: - print(i) if __name__ == '__main__': app = QApplication(sys.argv) - main = MainWin() - apply_stylesheet(app, theme='dark_yellow.xml') + main = MainWindow() + style_file = 'resource/current.qss' + style_sheet = QSSLoader.QSSLoader.read_qss_file(style_file) + # apply_stylesheet(app, theme='light_blue.xml') app.setWindowIcon(QIcon('./images/icon.svg')) + main.setStyleSheet(style_sheet) + main.show() sys.exit(app.exec_()) diff --git a/test/ConfigView.py b/test/ConfigView.py new file mode 100644 index 0000000..c37b319 --- /dev/null +++ b/test/ConfigView.py @@ -0,0 +1,64 @@ +import os +import sys + +from PyQt5 import QtCore +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.QtCore import Qt + +from ListWidgetItem import ListWidgetItem + +class ConfigView(QLabel): + def __init__(self): + super(ConfigView, self).__init__() + self.config_view=QLabel() + + def configAction(self): + dialog = QDialog() + # dialog.resize(300,200) + dialog.setMaximumSize(500 ,400) + dialog.setWindowTitle("配置oss信息") + access_key_id_label = QLabel('access_key_id:') + access_key_id_text = QLineEdit() + access_key_secret_label = QLabel('access_key_secret:') + access_key_secret_text = QLineEdit() + access_key_secret_text.setEchoMode(QLineEdit.Password) + bucket_name_label = QLabel('bucket_name') + bucket_name_text = QLineEdit() + bucket_name_text.setPlaceholderText('设置存储空间名') + endpoint_label = QLabel('endpoint') + endpoint_text = QLineEdit() + endpoint_text.setPlaceholderText('地域节点(如:oss-cn-beijing.aliyuncs.com)') + upload_path_label = QLabel('upload_path') + upload_path_text = QLineEdit() + upload_path_text.setPlaceholderText('上传路径(如:images/)') + upload_domain_label = QLabel('upload_domain') + upload_domain_text = QLineEdit() + upload_domain_text.setPlaceholderText('绑定域名(需要带https://)') + dialog_layout = QGridLayout() + font = QFont() + font.setFamily("Arial") + font.setPointSize(50) + dialog.setFont(font) + dialog_layout.addWidget(access_key_id_label, 0, 0) + dialog_layout.addWidget(access_key_id_text, 0, 1) + dialog_layout.addWidget(access_key_secret_label, 1, 0) + dialog_layout.addWidget(access_key_secret_text, 1, 1) + dialog_layout.addWidget(bucket_name_label, 2, 0) + dialog_layout.addWidget(bucket_name_text, 2, 1) + dialog_layout.addWidget(endpoint_label, 3, 0) + dialog_layout.addWidget(endpoint_text, 3, 1) + dialog_layout.addWidget(upload_path_label, 4, 0) + dialog_layout.addWidget(upload_path_text, 4, 1) + dialog_layout.addWidget(upload_domain_label, 5, 0) + dialog_layout.addWidget(upload_domain_text, 5, 1) + save_btn = QPushButton('保存配置') + content = [access_key_id_text.text(), access_key_secret_text.text(), bucket_name_text.text(), + endpoint_text.text(), upload_path_text.text(), upload_domain_text.text()] + + save_btn.clicked.connect(lambda: self.save_oss_config(content)) + dialog_layout.addWidget(save_btn, 6, 1) + dialog.setLayout(dialog_layout) + # 设置窗口的属性为ApplicationModal模态,用户只有关闭弹窗后,才能关闭主界面 + dialog.setWindowModality(QtCore.Qt.ApplicationModal) + dialog.exec_() \ No newline at end of file diff --git a/tool/ConfigWidget.py b/tool/ConfigWidget.py new file mode 100644 index 0000000..407e0e8 --- /dev/null +++ b/tool/ConfigWidget.py @@ -0,0 +1,68 @@ +from PyQt5.QtWidgets import * +from tool.FileConfig import * + + +class ConfigView(QWidget): + def __init__(self): + super(ConfigView, self).__init__() + layout = QGridLayout() + + self.access_key_id_label = QLabel('access_key_id:') + self.access_key_id_text = QLineEdit() + self.access_key_secret_label = QLabel('access_key_secret:') + self.access_key_secret_text = QLineEdit() + self.access_key_secret_text.setEchoMode(QLineEdit.Password) + self.bucket_name_label = QLabel('bucket_name') + self.bucket_name_text = QLineEdit() + self.bucket_name_text.setPlaceholderText('设置存储空间名') + self.endpoint_label = QLabel('endpoint') + self.endpoint_text = QLineEdit() + self.endpoint_text.setPlaceholderText('地域节点(如:oss-cn-beijing.aliyuncs.com)') + self.upload_path_label = QLabel('upload_path') + self.upload_path_text = QLineEdit() + self.upload_path_text.setPlaceholderText('上传路径(如:images/)') + self.upload_domain_label = QLabel('upload_domain') + self.upload_domain_text = QLineEdit() + self.upload_domain_text.setPlaceholderText('绑定域名(需要带https://)') + self.set_confirm = QPushButton('保存') + self.set_confirm.setObjectName('set_confirm') + self.set_default = QPushButton('设为默认图床') + self.set_default.setCheckable(False) + self.set_default.setObjectName('default_btn') + btn_layout = QHBoxLayout() + btn_layout.addWidget(self.set_confirm) + btn_layout.addWidget(self.set_default) + + # 填充配置文件 + config = checkConfig(set_config_path()) + + if config != None: + self.access_key_id_text.setText(config[0]) + self.access_key_secret_text.setText(config[1]) + self.bucket_name_text.setText(config[2]) + self.endpoint_text.setText(config[3]) + self.upload_path_text.setText(config[4]) + self.upload_domain_text.setText(config[5]) + + self.set_confirm.clicked.connect(self.save_config) + + layout.addWidget(self.access_key_id_label, 0, 0) + layout.addWidget(self.access_key_id_text, 0, 1) + layout.addWidget(self.access_key_secret_label, 1, 0) + layout.addWidget(self.access_key_secret_text, 1, 1) + layout.addWidget(self.bucket_name_label, 2, 0) + layout.addWidget(self.bucket_name_text, 2, 1) + layout.addWidget(self.endpoint_label, 3, 0) + layout.addWidget(self.endpoint_text, 3, 1) + layout.addWidget(self.upload_path_label, 4, 0) + layout.addWidget(self.upload_path_text, 4, 1) + layout.addWidget(self.upload_domain_label, 5, 0) + layout.addWidget(self.upload_domain_text, 5, 1) + layout.addItem(btn_layout, 6, 1) + + self.setLayout(layout) + + def save_config(self): + saveConfig(self.access_key_id_text.text(), self.access_key_secret_text.text(), self.bucket_name_text.text(), + self.endpoint_text.text(), + self.upload_path_text.text(), self.upload_domain_text.text()) diff --git a/tool/FileConfig.py b/tool/FileConfig.py new file mode 100644 index 0000000..5bcd366 --- /dev/null +++ b/tool/FileConfig.py @@ -0,0 +1,65 @@ +import json +import os +import platform + + +config_json = ''' +{ + "OSS_ACCESS_KEY_ID": "", + "OSS_ACCESS_KEY_SECRET": "", + "OSS_BUCKET": "", + "OSS_ENDPOINT": "", + "UPLOAD_PATH": "", + "UPLOAD_DOMAIN": "" +} +''' + + +def set_config_path(): + # 创建Linux下配置文件目录 + if platform.system() == 'Linux': + # + config_path = os.path.expanduser('~') + '/.config/PyQtPicUpload/' + if not os.path.exists(config_path): + os.mkdir(config_path) + # print(config_path) + config_file = config_path + 'config.json' + return config_file + +# 检测配置文件 +def checkConfig(config_file): + try: + with open(config_file, 'r') as file: + config = json.load(file) + # print(str(config)) + access_key_id = config['OSS_ACCESS_KEY_ID'] + # print(access_key_id) + access_key_secret = config['OSS_ACCESS_KEY_SECRET'] + # print(access_key_secret) + bucket_name = config['OSS_BUCKET'] + endpoint = config['OSS_ENDPOINT'] + upload_path = config['UPLOAD_PATH'] + upload_domain = config['UPLOAD_DOMAIN'] + # print(upload_domain) + for param in (access_key_id, access_key_secret, bucket_name, endpoint, upload_path, upload_domain): + assert '' != param, '请配置上传参数!' + return [access_key_id, access_key_secret, bucket_name, endpoint, upload_path, upload_domain] + except Exception as e: + print(e) + return None + + +def saveConfig(access_key_id, access_key_secret, bucket_name, endpoint, upload_path, upload_domain): + + config_file = set_config_path() + + with open(config_file, 'w+') as file: + json_config = { + "OSS_ACCESS_KEY_ID": access_key_id, + "OSS_ACCESS_KEY_SECRET": access_key_secret, + "OSS_BUCKET": bucket_name, + "OSS_ENDPOINT": endpoint, + "UPLOAD_PATH": upload_path if upload_path[-1] == '/' else upload_path + '/', + "UPLOAD_DOMAIN": upload_domain if upload_domain[-1] == '/' else upload_domain + '/' + } + file.write(json.dumps(json_config)) \ No newline at end of file diff --git a/tool/QSSLoader.py b/tool/QSSLoader.py new file mode 100644 index 0000000..74ce321 --- /dev/null +++ b/tool/QSSLoader.py @@ -0,0 +1,8 @@ +class QSSLoader: + def __init__(self): + pass + + @staticmethod + def read_qss_file(qss_file_name): + with open(qss_file_name, 'r', encoding='UTF-8') as file: + return file.read() diff --git a/tool/UploadTip.py b/tool/UploadTip.py new file mode 100644 index 0000000..6e4e4b9 --- /dev/null +++ b/tool/UploadTip.py @@ -0,0 +1,173 @@ +import json +import sys +import time +import os +import oss2 +from PyQt5.QtCore import QSize, Qt, QThread, pyqtSignal, pyqtSlot +from PyQt5.QtWidgets import * +from PyQt5 import QtCore +from PyQt5.QtGui import QPixmap +from tool import FileConfig +import notify2 + + +class UploadAction(QThread): + status = pyqtSignal(str) + + def __init__(self, filepath): + super(UploadAction, self).__init__() + try: + with open(FileConfig.set_config_path(), 'r') as file: + config = json.load(file) + except Exception as e: + print(e) + self.status.emit(False) + + self.filepath = filepath + # print(str(config)) + self.access_key_id = config['OSS_ACCESS_KEY_ID'] + # print(access_key_id) + self.access_key_secret = config['OSS_ACCESS_KEY_SECRET'] + # print(access_key_secret) + self.bucket_name = config['OSS_BUCKET'] + self.endpoint = config['OSS_ENDPOINT'] + self.upload_path = config['UPLOAD_PATH'] if config['UPLOAD_PATH'][-1] == '/' else config['UPLOAD_PATH'] + '/' + # 在域名后面添加 / + self.upload_domain = config['UPLOAD_DOMAIN'] if config['UPLOAD_DOMAIN'][-1] == '/' else config[ + 'UPLOAD_DOMAIN'] + '/' + + def percentage(self, consumed_bytes, total_bytes): + """进度条回调函数,计算当前完成的百分比 + :param consumed_bytes: 已经上传/下载的数据量 + :param total_bytes: 总数据量 + """ + if total_bytes: + rate = int(100 * (float(consumed_bytes) / float(total_bytes))) + print('\r{0}% '.format(rate)) + sys.stdout.flush() + + def run(self): + print('filepath:',self.filepath) + # 创建Bucket对象,所有Object相关的接口都可以通过Bucket对象来进行 + bucket = oss2.Bucket(oss2.Auth(self.access_key_id, self.access_key_secret), self.endpoint, self.bucket_name) + # 必须以二进制的方式打开文件。 + # 填写本地文件的完整路径。如果未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件。 + with open(self.filepath, 'rb') as fileobj: + # 填写Object完整路径。Object完整路径中不能包含Bucket名称。 + upload_name = self.upload_path + self.filepath.split('/')[-1] + bucket.put_object(upload_name, fileobj, progress_callback=self.percentage) + self.status.emit(self.upload_domain + upload_name) + # print('result_url:',self.upload_domain + upload_name) +class UploadTip(QWidget): + def __init__(self): + super(UploadTip, self).__init__() + self.pic_show = QLabel() + # self.resize(300,500) + # self.pic_show.setMaximumSize(300, 400) + self.pic_show.setObjectName('pic_show') + # self.pic_show.setStyleSheet('align:center') + self.pic_show.setAlignment(Qt.AlignCenter) + + self.pic_show.setPixmap( + QPixmap(os.getcwd() + '/images/upload.png')) + + self.pic_show.setStyleSheet('border:4px solid;') + # self.pic_show. + # .scaled(self.pic_show.size(), aspectRatioMode=QtCore.Qt.KeepAspectRatio) + + self.pic_tip = QLabel('Ctrl + V 粘贴图片') + self.pic_tip.setAlignment(QtCore.Qt.AlignCenter) + + self.tip_layout = QVBoxLayout(self) + self.tip_layout.addStretch() + self.tip_layout.addWidget(self.pic_show) + self.tip_layout.addStretch() + + self.tip_layout.addWidget(self.pic_tip) + # self.tip_layout.addStretch() + self.upload_btn = QPushButton('点击上传') + self.upload_btn.setObjectName('upload_btn') + + # self.upload_btn.set(Qt.AlignCenter) + + self.tip_layout.addWidget(self.upload_btn, 0, Qt.AlignCenter) + + # layout.setSpacing(0) + # 美化风格 + # self.setStyleSheet(qt_material.apply_stylesheet(self,'')) + self.createActions() + + self.upload_btn.clicked.connect(self.upload_action) + + self.restore_path = '' + self.setLayout(self.tip_layout) + def upload_action(self): + if self.restore_path != '': + self.upload_btn.setEnabled(False) + self.upload_btn.setText('上传中...') + self.upload_action.start() + + def upload_status(self, status): + # print('upload_status:',status) + # 判断上传结果 + if status: + print(status) + clipboard = QApplication.clipboard() + clipboard.setText('![]('+status+')') + notify2.init('OSS上传') + notify2.Notification('OSS上传',status,self.restore_path).show() + self.upload_btn.setText('点击上传') + self.upload_btn.setEnabled(True) + else: + print('upload error !') + os.remove(self.restore_path) + + def createActions(self): + pastAction = QAction(self) + pastAction.setShortcut("Ctrl+V") + pastAction.triggered.connect(self.pasteData) + self.addAction((pastAction)) # Activate QAction + + def setImage(self, path): + # print(path) + image = QPixmap(path) + # print(image.width(),image.height()) + if image.width() > image.height(): + scale = self.pic_show.width() / image.width() + # print('比例:', scale) + + # width=scale*clipboard.pixmap().width()*scale + height = image.height() * scale + # print('转换后高度:', height) + self.pic_show.setPixmap(image.scaled(QSize(self.pic_show.width(), int(height)))) # 用于粘贴图片 + else: + scale = self.pic_show.height() / image.height() + # print('比例:', scale) + width = image.width() * scale + # print('转换后宽度:', width) + self.pic_show.setPixmap(image.scaled(QSize(int(width), self.pic_show.height()))) + self.pic_show.setAlignment(QtCore.Qt.AlignCenter) + + + def pasteData(self): + clipboard = QApplication.clipboard() + mimeData = clipboard.mimeData() + + if mimeData.hasImage(): + + # 根据时间设置图片文件名 + file_name = time.strftime('%Y-%m-%d-%H%M%S', time.localtime()) + '.png' + # 将图片保存到指定位置 + self.restore_path = '/tmp/' + file_name + clipboard.pixmap().save(self.restore_path, 'PNG') + + # print(restore_path) + self.setImage(self.restore_path) + elif mimeData.hasText(): + self.restore_path = clipboard.text() + self.setImage(self.restore_path) + print("pasted from clipboard") + + # 设置点击事件的信号传递 + self.upload_action = UploadAction(self.restore_path) + self.upload_action.status.connect(self.upload_status)