Make some minor improvements to custom widget highlighting

This commit is contained in:
Veronica Berglyd Olsen
2024-02-01 20:34:42 +01:00
parent d504c0a7ec
commit 3b9ef47e0f
5 changed files with 26 additions and 26 deletions
+11 -11
View File
@@ -84,17 +84,17 @@ class NProgressCircle(QProgressBar):
"""Custom painter for the progress bar.""" """Custom painter for the progress bar."""
progress = 100.0*self.value()/self.maximum() progress = 100.0*self.value()/self.maximum()
angle = ceil(16*3.6*progress) angle = ceil(16*3.6*progress)
qPaint = QPainter(self) painter = QPainter(self)
qPaint.setRenderHint(QPainter.Antialiasing, True) painter.setRenderHint(QPainter.Antialiasing, True)
qPaint.setPen(self._dPen) painter.setPen(self._dPen)
qPaint.setBrush(self._dBrush) painter.setBrush(self._dBrush)
qPaint.drawEllipse(self._dRect) painter.drawEllipse(self._dRect)
qPaint.setPen(self._bPen) painter.setPen(self._bPen)
qPaint.drawArc(self._cRect, 0, 360*16) painter.drawArc(self._cRect, 0, 360*16)
qPaint.setPen(self._cPen) painter.setPen(self._cPen)
qPaint.drawArc(self._cRect, 90*16, -angle) painter.drawArc(self._cRect, 90*16, -angle)
qPaint.setPen(self._tColor) painter.setPen(self._tColor)
qPaint.drawText(self._cRect, Qt.AlignCenter, self._text or f"{progress:.1f} %") painter.drawText(self._cRect, Qt.AlignCenter, self._text or f"{progress:.1f} %")
return return
# END Class NProgressCircle # END Class NProgressCircle
+1 -1
View File
@@ -160,7 +160,7 @@ class _NPagedToolButton(QToolButton):
if self.isChecked(): if self.isChecked():
backCol = palette.highlight() backCol = palette.highlight()
paint.setBrush(backCol) paint.setBrush(backCol)
paint.setOpacity(0.5) paint.setOpacity(0.35)
paint.drawRoundedRect(0, 0, width, height, self._cR, self._cR) paint.drawRoundedRect(0, 0, width, height, self._cR, self._cR)
textCol = palette.highlightedText().color() textCol = palette.highlightedText().color()
else: else:
+5 -5
View File
@@ -43,11 +43,11 @@ class NProgressSimple(QProgressBar):
"""Custom painter for the progress bar.""" """Custom painter for the progress bar."""
if (value := self.value()) > 0: if (value := self.value()) > 0:
progress = ceil(self.width()*float(value)/self.maximum()) progress = ceil(self.width()*float(value)/self.maximum())
qPaint = QPainter(self) painter = QPainter(self)
qPaint.setRenderHint(QPainter.Antialiasing, True) painter.setRenderHint(QPainter.Antialiasing, True)
qPaint.setPen(self.palette().highlight().color()) painter.setPen(self.palette().highlight().color())
qPaint.setBrush(self.palette().highlight()) painter.setBrush(self.palette().highlight())
qPaint.drawRect(0, 0, progress, self.height()) painter.drawRect(0, 0, progress, self.height())
return return
# END Class NProgressSimple # END Class NProgressSimple
+8 -8
View File
@@ -24,6 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Literal from typing import Literal
from PyQt5.QtGui import QColor, QPaintEvent, QPainter from PyQt5.QtGui import QColor, QPaintEvent, QPainter
@@ -64,14 +65,13 @@ class StatusLED(QAbstractButton):
return return
def paintEvent(self, event: QPaintEvent) -> None: def paintEvent(self, event: QPaintEvent) -> None:
"""Drawing the LED.""" """Draw the LED."""
qPalette = self.palette() painter = QPainter(self)
qPaint = QPainter(self) painter.setRenderHint(QPainter.Antialiasing, True)
qPaint.setRenderHint(QPainter.Antialiasing, True) painter.setPen(self.palette().dark().color())
qPaint.setPen(qPalette.dark().color()) painter.setBrush(self._theCol)
qPaint.setBrush(self._theCol) painter.setOpacity(1.0)
qPaint.setOpacity(1.0) painter.drawEllipse(1, 1, self.width() - 2, self.height() - 2)
qPaint.drawEllipse(1, 1, self.width() - 2, self.height() - 2)
return return
# END Class StatusLED # END Class StatusLED
+1 -1
View File
@@ -355,7 +355,7 @@ class _ProjectListItem(QStyledItemDelegate):
painter.save() painter.save()
if opt.state & QStyle.StateFlag.State_Selected == QStyle.StateFlag.State_Selected: if opt.state & QStyle.StateFlag.State_Selected == QStyle.StateFlag.State_Selected:
painter.setOpacity(0.5) painter.setOpacity(0.25)
painter.fillRect(rect, qApp.palette().highlight()) painter.fillRect(rect, qApp.palette().highlight())
painter.setOpacity(1.0) painter.setOpacity(1.0)