fix: improve ui.py code quality
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
from PySide6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout,
|
from PySide6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout,
|
||||||
QLineEdit, QPushButton, QLabel, QComboBox,
|
QLineEdit, QPushButton, QLabel, QComboBox,
|
||||||
QProgressBar, QTextEdit, QFrame)
|
QProgressBar, QTextEdit, QFrame, QFileDialog)
|
||||||
from PySide6.QtCore import Qt, QRect
|
from PySide6.QtCore import Qt, Signal
|
||||||
from PySide6.QtGui import QPixmap, QPainter, QPen, QColor, QBrush
|
|
||||||
|
|
||||||
class DropZone(QFrame):
|
class DropZone(QFrame):
|
||||||
|
file_dropped = Signal(str)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.setAcceptDrops(True)
|
self.setAcceptDrops(True)
|
||||||
@@ -48,14 +49,13 @@ class DropZone(QFrame):
|
|||||||
if urls:
|
if urls:
|
||||||
self.file_selected = urls[0].toLocalFile()
|
self.file_selected = urls[0].toLocalFile()
|
||||||
event.acceptProposedAction()
|
event.acceptProposedAction()
|
||||||
self.parent().on_file_selected(self.file_selected)
|
self.file_dropped.emit(self.file_selected)
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
from PySide6.QtWidgets import QFileDialog
|
|
||||||
filepath, _ = QFileDialog.getOpenFileName(self, "选择文件")
|
filepath, _ = QFileDialog.getOpenFileName(self, "选择文件")
|
||||||
if filepath:
|
if filepath:
|
||||||
self.file_selected = filepath
|
self.file_selected = filepath
|
||||||
self.parent().on_file_selected(filepath)
|
self.file_dropped.emit(filepath)
|
||||||
|
|
||||||
class UiCreator:
|
class UiCreator:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user