-
Notifications
You must be signed in to change notification settings - Fork 2
Fix unreliable stylesheet selector in highlight preview widget #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
bc6d571
6ca2e2b
9ec7992
82afb5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -216,8 +216,24 @@ def __init__(self, parent): | |||||
|
|
||||||
| self._mainLayout.addWidget(self._colorWidget) | ||||||
|
|
||||||
| # Preview area: hover to see the overlay effect | ||||||
| self._previewLabel = QtWidgets.QLabel("Preview:", self) | ||||||
| self._previewLabel.setFixedWidth(100) | ||||||
|
|
||||||
| self._previewArea = _HighlightPreviewWidget(self) | ||||||
| self._previewArea.setFixedHeight(80) | ||||||
|
|
||||||
| self._previewWidget = QtWidgets.QWidget(self) | ||||||
| self._previewLayout = QtWidgets.QHBoxLayout(self._previewWidget) | ||||||
| self._previewLayout.setSpacing(10) | ||||||
| self._previewLayout.addWidget(self._previewLabel, 0, QtCore.Qt.AlignTop) | ||||||
| self._previewLayout.addWidget(self._previewArea) | ||||||
|
|
||||||
| self._mainLayout.addWidget(self._previewWidget) | ||||||
|
|
||||||
| self._color = self._DEFAULT_COLOR | ||||||
| self._updateButtonPreview() | ||||||
| self._updateOverlayPreview() | ||||||
|
|
||||||
| @property | ||||||
| def _qcolor(self) -> QtGui.QColor: | ||||||
|
|
@@ -234,6 +250,9 @@ def _updateButtonPreview(self): | |||||
| border: 1px solid #888; | ||||||
| }}""") | ||||||
|
|
||||||
| def _updateOverlayPreview(self): | ||||||
| self._previewArea.setOverlayColor(self._qcolor) | ||||||
|
|
||||||
| def _selectColor(self): | ||||||
| initial = self._qcolor | ||||||
| color = QtWidgets.QColorDialog.getColor( | ||||||
|
|
@@ -243,6 +262,7 @@ def _selectColor(self): | |||||
| if color.isValid(): | ||||||
| self._color = f"{color.red()},{color.green()},{color.blue()},{color.alpha()}" | ||||||
| self._updateButtonPreview() | ||||||
| self._updateOverlayPreview() | ||||||
|
|
||||||
| def getColor(self) -> str: | ||||||
| return self._color | ||||||
|
|
@@ -259,9 +279,61 @@ def setColor(self, colorStr: str): | |||||
| pqi_log.warning(f"Invalid color string: {colorStr}. Resetting to default. Error: {e}") | ||||||
| self._color = self._DEFAULT_COLOR | ||||||
| self._updateButtonPreview() | ||||||
| self._updateOverlayPreview() | ||||||
|
|
||||||
|
|
||||||
| class _HighlightPreviewWidget(QtWidgets.QWidget): | ||||||
| """ A preview widget that shows a colored overlay when the mouse hovers over it. """ | ||||||
|
|
||||||
| def __init__(self, parent=None): | ||||||
| super().__init__(parent) | ||||||
| self._highlightColor = QtGui.QColor(255, 0, 0, 51) | ||||||
|
|
||||||
| self.setStyleSheet("_HighlightPreviewWidget { border: 1px solid #aaa; }") | ||||||
|
||||||
| self.setStyleSheet("_HighlightPreviewWidget { border: 1px solid #aaa; }") | |
| self.setStyleSheet("border: 1px solid #aaa;") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -587,10 +587,16 @@ def _selectWidget(self, widgetId: int): | |
| # | | ||
| # * Close the server / Stop Serving -> Disable Inspect | ||
| # ---------------------------------------------------------------------------------------- | ||
| def _buildClientSettings(self) -> dict: | ||
| """ Build a dict of settings that need to be synced to the client. """ | ||
| return { | ||
| 'highlight_color': SettingsController.instance().highlightColor, | ||
| } | ||
|
|
||
| def _buildInspectExtraData(self) -> dict: | ||
| return { | ||
| 'mock_left_button_down': self._isMockLeftButtonDownAction.isChecked(), | ||
| 'highlight_color': SettingsController.instance().highlightColor, | ||
| **self._buildClientSettings(), | ||
| } | ||
|
|
||
| def _beginInspect(self): | ||
|
|
@@ -631,8 +637,14 @@ def _disableInspect(self): | |
| def _openSettingWindow(self): | ||
| if self._settingWindow is None: | ||
| self._settingWindow = SettingWindow(self) | ||
| self._settingWindow.sigSettingsSaved.connect(self._onSettingsSaved) | ||
| self._settingWindow.show() | ||
|
|
||
| def _onSettingsSaved(self): | ||
| worker = self._getWorker() | ||
| if worker: | ||
| worker.sendSettingsChanged(self._buildClientSettings()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new real-time sync path sends Useful? React with 👍 / 👎. |
||
|
|
||
| # endregion | ||
|
|
||
| # region -- code exec -- | ||
|
|
@@ -805,16 +817,17 @@ def _openLogDir(self): | |
|
|
||
| def _clearLogs(self): | ||
| """ Clear the logs in the console and file. """ | ||
| _title = "Clear Logs" | ||
| reply = QtWidgets.QMessageBox.question( | ||
| self, | ||
| self._getWindowTitle(), | ||
| _title, | ||
| "Are you sure you want to delete all logs?", | ||
| QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, | ||
| QtWidgets.QMessageBox.No | ||
| ) | ||
| if reply == QtWidgets.QMessageBox.Yes: | ||
| pqi_log.clear_logs() | ||
| QtWidgets.QMessageBox.information(self, self._getWindowTitle(), | ||
| QtWidgets.QMessageBox.information(self, _title, | ||
| "All logs have been deleted.") | ||
| # endregion | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on_settings_changedmutates runtime highlight behavior but does so silently, which leaves no evidence that a receivedCMD_SETTINGS_CHANGEDwas actually applied on the client. Because this is the endpoint of the new synchronization feature, the lack of logging on this branch makes it difficult to distinguish transport issues from apply-time issues when users report mismatched overlay colors.Useful? React with 👍 / 👎.