-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
fd1f806
commit a6bacfa
Showing
1 changed file
with
20 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,59 @@ | ||
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 | ||
self.text = text | ||
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) | ||
copy_button.clicked.connect(self.copy_text) | ||
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()) | ||
clipboard.setText(self.text_edit.toPlainText()) | ||
UniversalSpeech.say("تم نسخ النص إلى الحافظة") |