faster shutdown + text receiving
This commit is contained in:
@@ -75,7 +75,7 @@ class DiscordPresence:
|
||||
print("Stopping Discord presence...")
|
||||
self._stop_thread.set()
|
||||
if self._thread and self._thread.is_alive():
|
||||
self._thread.join(timeout=5)
|
||||
self._thread.join(timeout=1)
|
||||
|
||||
self.running = False
|
||||
self.presence = None
|
||||
|
||||
46
main.py
46
main.py
@@ -317,6 +317,38 @@ class WebSearchResults(QtWidgets.QDialog):
|
||||
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):
|
||||
show_menu_signal = QtCore.Signal()
|
||||
|
||||
@@ -481,7 +513,15 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
QtWidgets.QMessageBox.information(self, "Transfer Complete", f"Successfully received {len(received_files)} items to ~/Received.")
|
||||
|
||||
# Open the directory
|
||||
reply = QtWidgets.QMessageBox.question(
|
||||
self,
|
||||
"Open Directory",
|
||||
"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)
|
||||
@@ -491,7 +531,9 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
if self.progress_dialog:
|
||||
self.progress_dialog.close()
|
||||
self.progress_dialog = None
|
||||
QtWidgets.QMessageBox.information(self, "Text Received", text)
|
||||
|
||||
dialog = TextViewerDialog(text, self)
|
||||
dialog.exec()
|
||||
|
||||
@QtCore.Slot(str)
|
||||
def handle_dukto_error(self, error_msg: str):
|
||||
|
||||
Reference in New Issue
Block a user