fix(jira-knowledge): replace popup with inline help toggle for macOS reliability
QFrame+Qt.Popup and QDialog popups are unreliable on macOS inside QDialog parents — they may appear behind the parent or not receive clicks. Replace with a simple inline QLabel that toggles visibility when the ? button is clicked. This is the most reliable approach across all platforms. - Add self._inline_help QLabel below the mapping input (hidden by default) - _toggle_inline_help() simply shows/hides the label - Styled with dark background, blue border, matching the app theme - No external popup windows needed Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+20
-59
@@ -129,15 +129,14 @@ class JiraConnectDialog(QDialog):
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
# Click-based popover: build help content once, show on click
|
# Click-based inline help: toggle a QLabel below the input
|
||||||
self._help_text = (
|
self._help_text = (
|
||||||
"<b>" + tr("connectors.jira_kb_project_id_title") + "</b><br>"
|
"<b>" + tr("connectors.jira_kb_project_id_title") + "</b><br>"
|
||||||
+ tr("connectors.jira_kb_project_id_help")
|
+ tr("connectors.jira_kb_project_id_help")
|
||||||
+ "<br><br><b>" + tr("connectors.jira_kb_jira_key_title") + "</b><br>"
|
+ "<br><br><b>" + tr("connectors.jira_kb_jira_key_title") + "</b><br>"
|
||||||
+ tr("connectors.jira_kb_jira_key_help")
|
+ tr("connectors.jira_kb_jira_key_help")
|
||||||
)
|
)
|
||||||
self._help_popup = None
|
self.help_icon.clicked.connect(self._toggle_inline_help)
|
||||||
self.help_icon.clicked.connect(self._toggle_help_popup)
|
|
||||||
label_row = QHBoxLayout()
|
label_row = QHBoxLayout()
|
||||||
label_row.setSpacing(4)
|
label_row.setSpacing(4)
|
||||||
label_row.addWidget(mapping_label)
|
label_row.addWidget(mapping_label)
|
||||||
@@ -147,6 +146,18 @@ class JiraConnectDialog(QDialog):
|
|||||||
label_widget.setLayout(label_row)
|
label_widget.setLayout(label_row)
|
||||||
mapping_form.addRow(label_widget, self.project_mapping)
|
mapping_form.addRow(label_widget, self.project_mapping)
|
||||||
|
|
||||||
|
# Inline help panel (hidden by default, toggled by ? button)
|
||||||
|
self._inline_help = QLabel(self._help_text)
|
||||||
|
self._inline_help.setObjectName("hint")
|
||||||
|
self._inline_help.setWordWrap(True)
|
||||||
|
self._inline_help.setTextFormat(Qt.RichText)
|
||||||
|
self._inline_help.setStyleSheet(
|
||||||
|
"background: #1E2A3A; border: 1px solid #5B9BD5; border-radius: 6px;"
|
||||||
|
" padding: 8px 10px; color: #E0E0E0; font-size: 12px;"
|
||||||
|
)
|
||||||
|
self._inline_help.hide()
|
||||||
|
mapping_form.addRow("", self._inline_help)
|
||||||
|
|
||||||
# Validation hint for common mistakes (e.g., entering ABC-123 instead of ABC)
|
# Validation hint for common mistakes (e.g., entering ABC-123 instead of ABC)
|
||||||
self.mapping_validation = QLabel()
|
self.mapping_validation = QLabel()
|
||||||
self.mapping_validation.setObjectName("hint")
|
self.mapping_validation.setObjectName("hint")
|
||||||
@@ -188,62 +199,12 @@ class JiraConnectDialog(QDialog):
|
|||||||
self.kb_enabled.toggled.connect(self._update_sync_state)
|
self.kb_enabled.toggled.connect(self._update_sync_state)
|
||||||
self._update_sync_state(self.kb_enabled.isChecked())
|
self._update_sync_state(self.kb_enabled.isChecked())
|
||||||
|
|
||||||
def _toggle_help_popup(self) -> None:
|
def _toggle_inline_help(self) -> None:
|
||||||
"""Show/hide a floating help popup when the ? button is clicked."""
|
"""Toggle the inline help panel below the mapping input."""
|
||||||
if self._help_popup is not None and self._help_popup.isVisible():
|
if self._inline_help.isHidden():
|
||||||
self._help_popup.close()
|
self._inline_help.show()
|
||||||
self._help_popup = None
|
else:
|
||||||
return
|
self._inline_help.hide()
|
||||||
|
|
||||||
# Use a small QDialog (not QFrame+Qt.Popup) — more reliable on macOS
|
|
||||||
popup = QDialog(self)
|
|
||||||
popup.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint)
|
|
||||||
popup.setAttribute(Qt.WA_TranslucentBackground, False)
|
|
||||||
popup.setStyleSheet("""
|
|
||||||
QDialog {
|
|
||||||
background: #2D2D2D;
|
|
||||||
border: 1px solid #5B9BD5;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
""")
|
|
||||||
popup_layout = QVBoxLayout(popup)
|
|
||||||
popup_layout.setContentsMargins(14, 12, 14, 12)
|
|
||||||
|
|
||||||
content = QLabel(self._help_text)
|
|
||||||
content.setWordWrap(True)
|
|
||||||
content.setMaximumWidth(380)
|
|
||||||
content.setStyleSheet(
|
|
||||||
"color: #E0E0E0; font-size: 12px; background: transparent; border: none;"
|
|
||||||
)
|
|
||||||
content.setTextFormat(Qt.RichText)
|
|
||||||
content.setOpenExternalLinks(True)
|
|
||||||
popup_layout.addWidget(content)
|
|
||||||
|
|
||||||
# Close button row
|
|
||||||
close_row = QHBoxLayout()
|
|
||||||
close_row.addStretch(1)
|
|
||||||
close_btn = QPushButton("✕")
|
|
||||||
close_btn.setFixedSize(24, 24)
|
|
||||||
close_btn.setStyleSheet("""
|
|
||||||
QPushButton {
|
|
||||||
border: none; background: transparent; color: #999;
|
|
||||||
font-size: 14px; font-weight: bold;
|
|
||||||
}
|
|
||||||
QPushButton:hover { color: #fff; }
|
|
||||||
""")
|
|
||||||
close_btn.clicked.connect(popup.close)
|
|
||||||
close_row.addWidget(close_btn)
|
|
||||||
popup_layout.addLayout(close_row)
|
|
||||||
|
|
||||||
# Position below the help button
|
|
||||||
btn_global = self.help_icon.mapToGlobal(
|
|
||||||
QPoint(0, self.help_icon.height() + 4)
|
|
||||||
)
|
|
||||||
popup.move(btn_global)
|
|
||||||
popup.show()
|
|
||||||
popup.raise_()
|
|
||||||
popup.activateWindow()
|
|
||||||
self._help_popup = popup
|
|
||||||
|
|
||||||
def _on_paste(self, text: str) -> None:
|
def _on_paste(self, text: str) -> None:
|
||||||
"""Auto-fill Base URL from a pasted Jira link."""
|
"""Auto-fill Base URL from a pasted Jira link."""
|
||||||
|
|||||||
Reference in New Issue
Block a user