mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-10-13 17:58:19 +03:00
Align favorite icon hover colors
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
@@ -31,6 +31,7 @@ from Furious.Plugins import (
|
||||
)
|
||||
from Furious.Qt import *
|
||||
from Furious.Qt.Signals import connectWeakly, singleShotWeakly
|
||||
from Furious.Qt.QtWidgets import _AppQTableSelectionDelegate
|
||||
from Furious.Qt import gettext as _
|
||||
from Furious.Service import (
|
||||
ProfileTestField,
|
||||
@@ -495,6 +496,24 @@ def _favoriteIconWithColor(colorName, selectedColorName):
|
||||
return icon
|
||||
|
||||
|
||||
class _ServerTableSelectionDelegate(_AppQTableSelectionDelegate):
|
||||
"""Keep favorite decorations aligned with native hover text painting."""
|
||||
|
||||
def initStyleOption(self, option, index):
|
||||
super().initStyleOption(option, index)
|
||||
|
||||
if (
|
||||
option.state & QStyle.StateFlag.State_MouseOver
|
||||
and not option.state & QStyle.StateFlag.State_Selected
|
||||
and not option.icon.isNull()
|
||||
):
|
||||
color = self.parent().hoverTextColor
|
||||
|
||||
if color.isValid():
|
||||
name = color.name(QColor.NameFormat.HexArgb)
|
||||
option.icon = _favoriteIconWithColor(name, name)
|
||||
|
||||
|
||||
class UserServersTableModel(QtCore.QAbstractTableModel):
|
||||
"""Expose user servers table data through a Qt item model."""
|
||||
|
||||
@@ -928,6 +947,8 @@ class ServerTableView(
|
||||
|
||||
activeServerChanged = QtCore.Signal()
|
||||
|
||||
SelectionDelegateType = _ServerTableSelectionDelegate
|
||||
|
||||
RowHeight = 42
|
||||
|
||||
Headers = [
|
||||
@@ -942,8 +963,19 @@ class ServerTableView(
|
||||
ServerTableColumn('Speed'),
|
||||
]
|
||||
|
||||
@QtCore.Property(QColor)
|
||||
def hoverTextColor(self):
|
||||
"""Read the hover text token supplied by the application stylesheet."""
|
||||
return self._hoverTextColor
|
||||
|
||||
@hoverTextColor.setter
|
||||
def hoverTextColor(self, color):
|
||||
self._hoverTextColor = QColor(color)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize the server table view."""
|
||||
self._hoverTextColor = QColor()
|
||||
|
||||
configurationEditorFactory, self.qrCodeWindowFactory, importActionsFactory = (
|
||||
kwargs.pop('configurationEditorFactory'),
|
||||
kwargs.pop('qrCodeWindowFactory'),
|
||||
|
||||
Reference in New Issue
Block a user