Skip to content

Commit a6bacfa

Browse files
committed
Add screen reader feedback for copy action:
- Integrated `UniversalSpeech.say` to announce "تم نسخ النص إلى الحافظة" when text is copied. - This helps visually impaired users know the action was successful.
1 parent fd1f806 commit a6bacfa

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

ui/dialogs/info_dialog.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,59 @@
11
import sys
2-
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QTextEdit, QPushButton
2+
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QTextEdit, QPushButton, QApplication
33
from PyQt6.QtCore import QTimer
4-
from PyQt6.QtGui import QKeySequence
4+
from PyQt6.QtGui import QKeySequence, QClipboard
55
from ui.widgets.qText_edit import ReadOnlyTextEdit
6+
from utils.universal_speech import UniversalSpeech
7+
68

79
class InfoDialog(QDialog):
8-
def __init__(self, title: str, label: str, text: str, is_html_content: bool=False):
10+
def __init__(self, title: str, label: str, text: str, is_html_content: bool = False):
911
super().__init__()
1012
self.title = title
1113
self.label = label
1214
self.text = text
1315
self.is_html_content = is_html_content
1416
self.init_ui()
1517

16-
1718
def init_ui(self):
18-
1919
self.setWindowTitle(self.title)
2020
self.resize(400, 300)
2121
self.setFocus()
2222

2323
label = QLabel(self.label, self)
2424

25-
text_edit = ReadOnlyTextEdit(self)
26-
text_edit.setAccessibleName(self.label)
25+
self.text_edit = ReadOnlyTextEdit(self)
26+
self.text_edit.setAccessibleName(self.label)
2727
if self.is_html_content:
28-
text_edit.setHtml(self.text)
28+
self.text_edit.setHtml(self.text)
2929
else:
30-
text_edit.setText(self.text)
30+
self.text_edit.setText(self.text)
3131

3232
# Copy button
3333
copy_button = QPushButton('نسخ', self)
3434
copy_button.clicked.connect(self.copy_text)
3535
copy_button.setShortcut(QKeySequence("Ctrl+C"))
3636
copy_button.setStyleSheet('background-color: red; color: white;')
3737

38-
# close button
38+
39+
# Close button
3940
close_button = QPushButton('إغلاق', self)
4041
close_button.setShortcut(QKeySequence("Ctrl+W"))
4142
close_button.clicked.connect(self.reject)
42-
close_button.setStyleSheet(f'background-color: red; color: white;')
43+
close_button.setStyleSheet('background-color: red; color: white;')
4344

45+
# Layout
4446
layout = QVBoxLayout()
4547
layout.addWidget(label)
46-
layout.addWidget(text_edit)
48+
layout.addWidget(self.text_edit)
49+
layout.addWidget(copy_button)
4750
layout.addWidget(close_button)
4851
self.setLayout(layout)
49-
QTimer.singleShot(300, text_edit.setFocus)
52+
53+
# Focus the text edit after dialog opens
54+
QTimer.singleShot(300, self.text_edit.setFocus)
5055

5156
def copy_text(self):
5257
clipboard = QApplication.clipboard()
53-
clipboard.setText(self.text_edit.toPlainText())
58+
clipboard.setText(self.text_edit.toPlainText())
59+
UniversalSpeech.say("تم نسخ النص إلى الحافظة")

0 commit comments

Comments
 (0)