Sync from development - prepare for v0.2.0

This commit is contained in:
Omni
2025-12-06 20:09:55 +00:00
parent fe14e4ecfb
commit ce969eba1b
277 changed files with 14059 additions and 3899 deletions

View File

@@ -23,8 +23,10 @@ class WarningDialog(QDialog):
self.setWindowTitle("Warning!")
self.setModal(True)
# Increased height for better text display, scalable for 800p screens
self.setFixedSize(500, 440)
self.setFixedSize(500, 460)
self.confirmed = False
self._failed_attempts = 0
self._max_attempts = 3
self._setup_ui(warning_message)
def _setup_ui(self, warning_message):
@@ -99,21 +101,21 @@ class WarningDialog(QDialog):
card_layout.addWidget(message_text)
# Confirmation entry
confirm_label = QLabel("Type 'DELETE' to confirm:")
confirm_label.setAlignment(Qt.AlignCenter)
confirm_label.setStyleSheet(
self.confirm_label = QLabel("Type 'DELETE' to confirm (all caps):")
self.confirm_label.setAlignment(Qt.AlignCenter)
self.confirm_label.setStyleSheet(
"QLabel { "
" font-size: 13px; "
" color: #e67e22; "
" margin-bottom: 2px; "
"}"
)
card_layout.addWidget(confirm_label)
card_layout.addWidget(self.confirm_label)
self.confirm_edit = QLineEdit()
self.confirm_edit.setAlignment(Qt.AlignCenter)
self.confirm_edit.setPlaceholderText("DELETE")
self.confirm_edit.setStyleSheet(
self._default_lineedit_style = (
"QLineEdit { "
" font-size: 15px; "
" border: 1px solid #e67e22; "
@@ -123,6 +125,9 @@ class WarningDialog(QDialog):
" color: #e67e22; "
"}"
)
self.confirm_edit.setStyleSheet(self._default_lineedit_style)
self.confirm_edit.textChanged.connect(self._on_text_changed)
self.confirm_edit.returnPressed.connect(self._on_confirm) # Handle Enter key
card_layout.addWidget(self.confirm_edit)
# Action buttons
@@ -178,11 +183,69 @@ class WarningDialog(QDialog):
layout.addWidget(card, alignment=Qt.AlignCenter)
layout.addStretch()
def _on_text_changed(self):
"""Reset error styling when user starts typing again."""
# Only reset if currently showing error state (darker background)
if "#3b2323" in self.confirm_edit.styleSheet():
self.confirm_edit.setStyleSheet(self._default_lineedit_style)
self.confirm_edit.setPlaceholderText("DELETE")
# Reset label but keep attempt counter if attempts were made
if self._failed_attempts > 0:
remaining = self._max_attempts - self._failed_attempts
self.confirm_label.setText(f"Type 'DELETE' to confirm (all caps) - {remaining} attempt(s) remaining:")
else:
self.confirm_label.setText("Type 'DELETE' to confirm (all caps):")
self.confirm_label.setStyleSheet(
"QLabel { "
" font-size: 13px; "
" color: #e67e22; "
" margin-bottom: 2px; "
"}"
)
def _on_confirm(self):
if self.confirm_edit.text().strip().upper() == "DELETE":
entered_text = self.confirm_edit.text().strip()
if entered_text == "DELETE":
# Correct - proceed
self.confirmed = True
self.accept()
else:
self.confirm_edit.setText("")
self.confirm_edit.setPlaceholderText("Type DELETE to confirm")
self.confirm_edit.setStyleSheet(self.confirm_edit.styleSheet() + "QLineEdit { background: #3b2323; }")
# Wrong text entered
self._failed_attempts += 1
if self._failed_attempts >= self._max_attempts:
# Too many failed attempts - cancel automatically
self.confirmed = False
self.reject()
return
# Still have attempts remaining - clear field and show error feedback
self.confirm_edit.clear()
# Update label to show remaining attempts
remaining = self._max_attempts - self._failed_attempts
self.confirm_label.setText(f"Wrong! Type 'DELETE' exactly (all caps) - {remaining} attempt(s) remaining:")
self.confirm_label.setStyleSheet(
"QLabel { "
" font-size: 13px; "
" color: #c0392b; " # Red for error
" margin-bottom: 2px; "
" font-weight: bold; "
"}"
)
# Show error state in text field
self.confirm_edit.setPlaceholderText(f"Type DELETE ({remaining} attempts left)")
self.confirm_edit.setStyleSheet(
"QLineEdit { "
" font-size: 15px; "
" border: 2px solid #c0392b; " # Red border for error
" border-radius: 6px; "
" padding: 6px; "
" background: #3b2323; " # Darker red background
" color: #e67e22; "
"}"
)