This commit is contained in:
parent
703574f8c1
commit
cc851254be
7 changed files with 28 additions and 20 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
main/__pycache__/
|
|
@ -1,5 +1,5 @@
|
||||||
from PyQt5.QtWidgets import *
|
from PyQt5.QtWidgets import *
|
||||||
from tool.FileConfig import *
|
from FileConfig import *
|
||||||
|
|
||||||
|
|
||||||
class ConfigView(QWidget):
|
class ConfigView(QWidget):
|
|
@ -46,20 +46,22 @@ def checkConfig(config_file):
|
||||||
return [access_key_id, access_key_secret, bucket_name, endpoint, upload_path, upload_domain]
|
return [access_key_id, access_key_secret, bucket_name, endpoint, upload_path, upload_domain]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
saveConfig(None)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def saveConfig(access_key_id, access_key_secret, bucket_name, endpoint, upload_path, upload_domain):
|
def saveConfig(access_key_id=None, access_key_secret=None, bucket_name=None, endpoint=None, upload_path=None, upload_domain=None):
|
||||||
|
|
||||||
config_file = set_config_path()
|
config_file = set_config_path()
|
||||||
|
|
||||||
with open(config_file, 'w+') as file:
|
with open(config_file, 'w+') as file:
|
||||||
json_config = {
|
if access_key_id is not None:
|
||||||
"OSS_ACCESS_KEY_ID": access_key_id,
|
json_config = {
|
||||||
"OSS_ACCESS_KEY_SECRET": access_key_secret,
|
"OSS_ACCESS_KEY_ID": access_key_id,
|
||||||
"OSS_BUCKET": bucket_name,
|
"OSS_ACCESS_KEY_SECRET": access_key_secret,
|
||||||
"OSS_ENDPOINT": endpoint,
|
"OSS_BUCKET": bucket_name,
|
||||||
"UPLOAD_PATH": upload_path if upload_path[-1] == '/' else upload_path + '/',
|
"OSS_ENDPOINT": endpoint,
|
||||||
"UPLOAD_DOMAIN": upload_domain if upload_domain[-1] == '/' else upload_domain + '/'
|
"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))
|
}
|
||||||
|
file.write(json.dumps(json_config))
|
|
@ -7,7 +7,7 @@ from PyQt5.QtCore import QSize, Qt, QThread, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtWidgets import *
|
from PyQt5.QtWidgets import *
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
from PyQt5.QtGui import QPixmap
|
from PyQt5.QtGui import QPixmap
|
||||||
from tool import FileConfig
|
import FileConfig
|
||||||
import notify2
|
import notify2
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class UploadAction(QThread):
|
||||||
with open(FileConfig.set_config_path(), 'r') as file:
|
with open(FileConfig.set_config_path(), 'r') as file:
|
||||||
config = json.load(file)
|
config = json.load(file)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e,'UploadTip')
|
||||||
self.status.emit(False)
|
self.status.emit(False)
|
||||||
|
|
||||||
self.filepath = filepath
|
self.filepath = filepath
|
||||||
|
@ -154,9 +154,10 @@ class UploadTip(QWidget):
|
||||||
mimeData = clipboard.mimeData()
|
mimeData = clipboard.mimeData()
|
||||||
|
|
||||||
if mimeData.hasImage():
|
if mimeData.hasImage():
|
||||||
|
import uuid
|
||||||
|
|
||||||
# 根据时间设置图片文件名
|
# 根据时间设置图片文件名
|
||||||
file_name = time.strftime('%Y-%m-%d-%H%M%S', time.localtime()) + '.png'
|
file_name = str(uuid.uuid4())[:5] +'-'+time.strftime('%Y-%m-%d-%H%M%S', time.localtime())+ '.png'
|
||||||
# 将图片保存到指定位置
|
# 将图片保存到指定位置
|
||||||
self.restore_path = '/tmp/' + file_name
|
self.restore_path = '/tmp/' + file_name
|
||||||
clipboard.pixmap().save(self.restore_path, 'PNG')
|
clipboard.pixmap().save(self.restore_path, 'PNG')
|
||||||
|
@ -164,8 +165,12 @@ class UploadTip(QWidget):
|
||||||
# print(restore_path)
|
# print(restore_path)
|
||||||
self.setImage(self.restore_path)
|
self.setImage(self.restore_path)
|
||||||
elif mimeData.hasText():
|
elif mimeData.hasText():
|
||||||
self.restore_path = clipboard.text()
|
try:
|
||||||
self.setImage(self.restore_path)
|
self.restore_path = clipboard.text()
|
||||||
|
self.setImage(self.restore_path)
|
||||||
|
except Exception as e:
|
||||||
|
print('目录不是图片!')
|
||||||
|
|
||||||
print("pasted from clipboard")
|
print("pasted from clipboard")
|
||||||
|
|
||||||
# 设置点击事件的信号传递
|
# 设置点击事件的信号传递
|
|
@ -4,9 +4,9 @@ from PyQt5.QtWidgets import *
|
||||||
from PyQt5.QtGui import *
|
from PyQt5.QtGui import *
|
||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtCore import Qt, QSize
|
||||||
|
|
||||||
from tool.UploadTip import UploadTip
|
from UploadTip import UploadTip
|
||||||
from tool.ConfigWidget import ConfigView
|
from ConfigWidget import ConfigView
|
||||||
from tool import QSSLoader
|
import QSSLoader
|
||||||
|
|
||||||
class MainWindow(QWidget):
|
class MainWindow(QWidget):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -53,8 +53,8 @@ class MainWindow(QWidget):
|
||||||
|
|
||||||
self.listWidget.addItem(self.upload_item)
|
self.listWidget.addItem(self.upload_item)
|
||||||
self.listWidget.addItem(self.set_item)
|
self.listWidget.addItem(self.set_item)
|
||||||
upload_widget = UploadTip()
|
|
||||||
config_widget = ConfigView()
|
config_widget = ConfigView()
|
||||||
|
upload_widget = UploadTip()
|
||||||
|
|
||||||
self.stackedWidget.addWidget(upload_widget)
|
self.stackedWidget.addWidget(upload_widget)
|
||||||
self.stackedWidget.addWidget(config_widget)
|
self.stackedWidget.addWidget(config_widget)
|
||||||
|
|
Loading…
Reference in a new issue