diff --git a/ui/dialogs/info_dialog.py b/ui/dialogs/info_dialog.py index 71f9816..a38dc84 100644 --- a/ui/dialogs/info_dialog.py +++ b/ui/dialogs/info_dialog.py @@ -1,11 +1,13 @@ import sys -from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QTextEdit, QPushButton +from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QTextEdit, QPushButton, QApplication from PyQt6.QtCore import QTimer -from PyQt6.QtGui import QKeySequence +from PyQt6.QtGui import QKeySequence, QClipboard from ui.widgets.qText_edit import ReadOnlyTextEdit +from utils.universal_speech import UniversalSpeech + class InfoDialog(QDialog): - def __init__(self, title: str, label: str, text: str, is_html_content: bool=False): + def __init__(self, title: str, label: str, text: str, is_html_content: bool = False): super().__init__() self.title = title self.label = label @@ -13,21 +15,19 @@ def __init__(self, title: str, label: str, text: str, is_html_content: bool=Fals self.is_html_content = is_html_content self.init_ui() - def init_ui(self): - self.setWindowTitle(self.title) self.resize(400, 300) self.setFocus() label = QLabel(self.label, self) - text_edit = ReadOnlyTextEdit(self) - text_edit.setAccessibleName(self.label) + self.text_edit = ReadOnlyTextEdit(self) + self.text_edit.setAccessibleName(self.label) if self.is_html_content: - text_edit.setHtml(self.text) + self.text_edit.setHtml(self.text) else: - text_edit.setText(self.text) + self.text_edit.setText(self.text) # Copy button copy_button = QPushButton('نسخ', self) @@ -35,19 +35,25 @@ def init_ui(self): copy_button.setShortcut(QKeySequence("Ctrl+C")) copy_button.setStyleSheet('background-color: red; color: white;') - # close button + + # Close button close_button = QPushButton('إغلاق', self) close_button.setShortcut(QKeySequence("Ctrl+W")) close_button.clicked.connect(self.reject) - close_button.setStyleSheet(f'background-color: red; color: white;') + close_button.setStyleSheet('background-color: red; color: white;') + # Layout layout = QVBoxLayout() layout.addWidget(label) - layout.addWidget(text_edit) + layout.addWidget(self.text_edit) + layout.addWidget(copy_button) layout.addWidget(close_button) self.setLayout(layout) - QTimer.singleShot(300, text_edit.setFocus) + + # Focus the text edit after dialog opens + QTimer.singleShot(300, self.text_edit.setFocus) def copy_text(self): clipboard = QApplication.clipboard() - clipboard.setText(self.text_edit.toPlainText()) \ No newline at end of file + clipboard.setText(self.text_edit.toPlainText()) + UniversalSpeech.say("تم نسخ النص إلى الحافظة") \ No newline at end of file