faster shutdown + text receiving
This commit is contained in:
@@ -75,7 +75,7 @@ class DiscordPresence:
|
|||||||
print("Stopping Discord presence...")
|
print("Stopping Discord presence...")
|
||||||
self._stop_thread.set()
|
self._stop_thread.set()
|
||||||
if self._thread and self._thread.is_alive():
|
if self._thread and self._thread.is_alive():
|
||||||
self._thread.join(timeout=5)
|
self._thread.join(timeout=1)
|
||||||
|
|
||||||
self.running = False
|
self.running = False
|
||||||
self.presence = None
|
self.presence = None
|
||||||
|
|||||||
52
main.py
52
main.py
@@ -317,6 +317,38 @@ class WebSearchResults(QtWidgets.QDialog):
|
|||||||
QtWidgets.QApplication.restoreOverrideCursor()
|
QtWidgets.QApplication.restoreOverrideCursor()
|
||||||
|
|
||||||
|
|
||||||
|
class TextViewerDialog(QtWidgets.QDialog):
|
||||||
|
def __init__(self, text, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setWindowTitle("Text Received")
|
||||||
|
self.setMinimumSize(400, 300)
|
||||||
|
|
||||||
|
self.text_to_copy = text
|
||||||
|
layout = QtWidgets.QVBoxLayout(self)
|
||||||
|
|
||||||
|
self.text_edit = QtWidgets.QTextEdit()
|
||||||
|
self.text_edit.setPlainText(text)
|
||||||
|
self.text_edit.setReadOnly(True)
|
||||||
|
layout.addWidget(self.text_edit)
|
||||||
|
|
||||||
|
button_layout = QtWidgets.QHBoxLayout()
|
||||||
|
button_layout.addStretch()
|
||||||
|
|
||||||
|
copy_button = QtWidgets.QPushButton("Copy to Clipboard")
|
||||||
|
copy_button.clicked.connect(self.copy_text)
|
||||||
|
button_layout.addWidget(copy_button)
|
||||||
|
|
||||||
|
close_button = QtWidgets.QPushButton("Close")
|
||||||
|
close_button.clicked.connect(self.accept)
|
||||||
|
button_layout.addWidget(close_button)
|
||||||
|
|
||||||
|
layout.addLayout(button_layout)
|
||||||
|
|
||||||
|
def copy_text(self):
|
||||||
|
clipboard = QtWidgets.QApplication.clipboard()
|
||||||
|
clipboard.setText(self.text_to_copy)
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QtWidgets.QMainWindow):
|
class MainWindow(QtWidgets.QMainWindow):
|
||||||
show_menu_signal = QtCore.Signal()
|
show_menu_signal = QtCore.Signal()
|
||||||
|
|
||||||
@@ -481,17 +513,27 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
QtWidgets.QMessageBox.information(self, "Transfer Complete", f"Successfully received {len(received_files)} items to ~/Received.")
|
QtWidgets.QMessageBox.information(self, "Transfer Complete", f"Successfully received {len(received_files)} items to ~/Received.")
|
||||||
|
|
||||||
# Open the directory
|
reply = QtWidgets.QMessageBox.question(
|
||||||
receive_dir = str(Path.home() / "Received")
|
self,
|
||||||
url = QtCore.QUrl.fromLocalFile(receive_dir)
|
"Open Directory",
|
||||||
QtGui.QDesktopServices.openUrl(url)
|
"Do you want to open the folder now?",
|
||||||
|
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No,
|
||||||
|
QtWidgets.QMessageBox.StandardButton.Yes
|
||||||
|
)
|
||||||
|
|
||||||
|
if reply == QtWidgets.QMessageBox.StandardButton.Yes:
|
||||||
|
receive_dir = str(Path.home() / "Received")
|
||||||
|
url = QtCore.QUrl.fromLocalFile(receive_dir)
|
||||||
|
QtGui.QDesktopServices.openUrl(url)
|
||||||
|
|
||||||
@QtCore.Slot(str, int)
|
@QtCore.Slot(str, int)
|
||||||
def handle_receive_text(self, text: str, total_size: int):
|
def handle_receive_text(self, text: str, total_size: int):
|
||||||
if self.progress_dialog:
|
if self.progress_dialog:
|
||||||
self.progress_dialog.close()
|
self.progress_dialog.close()
|
||||||
self.progress_dialog = None
|
self.progress_dialog = None
|
||||||
QtWidgets.QMessageBox.information(self, "Text Received", text)
|
|
||||||
|
dialog = TextViewerDialog(text, self)
|
||||||
|
dialog.exec()
|
||||||
|
|
||||||
@QtCore.Slot(str)
|
@QtCore.Slot(str)
|
||||||
def handle_dukto_error(self, error_msg: str):
|
def handle_dukto_error(self, error_msg: str):
|
||||||
|
|||||||
Reference in New Issue
Block a user