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."""
progress = 100.0*self.value()/self.maximum()
angle = ceil(16*3.6*progress)
qPaint = QPainter(self)
qPaint.setRenderHint(QPainter.Antialiasing, True)
qPaint.setPen(self._dPen)
qPaint.setBrush(self._dBrush)
qPaint.drawEllipse(self._dRect)
qPaint.setPen(self._bPen)
qPaint.drawArc(self._cRect, 0, 360*16)
qPaint.setPen(self._cPen)
qPaint.drawArc(self._cRect, 90*16, -angle)
qPaint.setPen(self._tColor)
qPaint.drawText(self._cRect, Qt.AlignCenter, self._text or f"{progress:.1f} %")
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setPen(self._dPen)
painter.setBrush(self._dBrush)
painter.drawEllipse(self._dRect)
painter.setPen(self._bPen)
painter.drawArc(self._cRect, 0, 360*16)
painter.setPen(self._cPen)
painter.drawArc(self._cRect, 90*16, -angle)
painter.setPen(self._tColor)
painter.drawText(self._cRect, Qt.AlignCenter, self._text or f"{progress:.1f} %")
return
# END Class NProgressCircle
+1 -1
View File
@@ -160,7 +160,7 @@ class _NPagedToolButton(QToolButton):
if self.isChecked():
backCol = palette.highlight()
paint.setBrush(backCol)
paint.setOpacity(0.5)
paint.setOpacity(0.35)
paint.drawRoundedRect(0, 0, width, height, self._cR, self._cR)
textCol = palette.highlightedText().color()
else:
+5 -5
View File
@@ -43,11 +43,11 @@ class NProgressSimple(QProgressBar):
"""Custom painter for the progress bar."""
if (value := self.value()) > 0:
progress = ceil(self.width()*float(value)/self.maximum())
qPaint = QPainter(self)
qPaint.setRenderHint(QPainter.Antialiasing, True)
qPaint.setPen(self.palette().highlight().color())
qPaint.setBrush(self.palette().highlight())
qPaint.drawRect(0, 0, progress, self.height())
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setPen(self.palette().highlight().color())
painter.setBrush(self.palette().highlight())
painter.drawRect(0, 0, progress, self.height())
return
# 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
import logging
from typing import Literal
from PyQt5.QtGui import QColor, QPaintEvent, QPainter
@@ -64,14 +65,13 @@ class StatusLED(QAbstractButton):
return
def paintEvent(self, event: QPaintEvent) -> None:
"""Drawing the LED."""
qPalette = self.palette()
qPaint = QPainter(self)
qPaint.setRenderHint(QPainter.Antialiasing, True)
qPaint.setPen(qPalette.dark().color())
qPaint.setBrush(self._theCol)
qPaint.setOpacity(1.0)
qPaint.drawEllipse(1, 1, self.width() - 2, self.height() - 2)
"""Draw the LED."""
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing, True)
painter.setPen(self.palette().dark().color())
painter.setBrush(self._theCol)
painter.setOpacity(1.0)
painter.drawEllipse(1, 1, self.width() - 2, self.height() - 2)
return
# END Class StatusLED
+1 -1
View File
@@ -355,7 +355,7 @@ class _ProjectListItem(QStyledItemDelegate):
painter.save()
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.setOpacity(1.0)