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 tool.FileConfig import *
|
||||
from FileConfig import *
|
||||
|
||||
|
||||
class ConfigView(QWidget):
|
|
@ -46,14 +46,16 @@ def checkConfig(config_file):
|
|||
return [access_key_id, access_key_secret, bucket_name, endpoint, upload_path, upload_domain]
|
||||
except Exception as e:
|
||||
print(e)
|
||||
saveConfig(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()
|
||||
|
||||
with open(config_file, 'w+') as file:
|
||||
if access_key_id is not None:
|
||||
json_config = {
|
||||
"OSS_ACCESS_KEY_ID": access_key_id,
|
||||
"OSS_ACCESS_KEY_SECRET": access_key_secret,
|
|
@ -7,7 +7,7 @@ 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 FileConfig
|
||||
import notify2
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ class UploadAction(QThread):
|
|||
with open(FileConfig.set_config_path(), 'r') as file:
|
||||
config = json.load(file)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(e,'UploadTip')
|
||||
self.status.emit(False)
|
||||
|
||||
self.filepath = filepath
|
||||
|
@ -154,9 +154,10 @@ class UploadTip(QWidget):
|
|||
mimeData = clipboard.mimeData()
|
||||
|
||||
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
|
||||
clipboard.pixmap().save(self.restore_path, 'PNG')
|
||||
|
@ -164,8 +165,12 @@ class UploadTip(QWidget):
|
|||
# print(restore_path)
|
||||
self.setImage(self.restore_path)
|
||||
elif mimeData.hasText():
|
||||
try:
|
||||
self.restore_path = clipboard.text()
|
||||
self.setImage(self.restore_path)
|
||||
except Exception as e:
|
||||
print('目录不是图片!')
|
||||
|
||||
print("pasted from clipboard")
|
||||
|
||||
# 设置点击事件的信号传递
|
|
@ -4,9 +4,9 @@ from PyQt5.QtWidgets import *
|
|||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
|
||||
from tool.UploadTip import UploadTip
|
||||
from tool.ConfigWidget import ConfigView
|
||||
from tool import QSSLoader
|
||||
from UploadTip import UploadTip
|
||||
from ConfigWidget import ConfigView
|
||||
import QSSLoader
|
||||
|
||||
class MainWindow(QWidget):
|
||||
def __init__(self):
|
||||
|
@ -53,8 +53,8 @@ class MainWindow(QWidget):
|
|||
|
||||
self.listWidget.addItem(self.upload_item)
|
||||
self.listWidget.addItem(self.set_item)
|
||||
upload_widget = UploadTip()
|
||||
config_widget = ConfigView()
|
||||
upload_widget = UploadTip()
|
||||
|
||||
self.stackedWidget.addWidget(upload_widget)
|
||||
self.stackedWidget.addWidget(config_widget)
|
||||
|
|
Loading…
Reference in a new issue