arch/arm64: Support FEAT_CCIDX
[coreboot2.git] / util / coreboot-configurator / src / application / ToggleSwitch.cpp
blobb0a399e01cb6137ee7793abab3db189a9006858f
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <QEvent>
4 #include <QGuiApplication>
5 #include <QPainter>
6 #include <QPalette>
7 #include <QTimer>
9 #include "ToggleSwitch.h"
10 #include "ToggleSwitch.svg.h"
12 const QByteArray ToggleSwitch::s_toggleOffSvgContent = ToggleSwitchSVG::s_toggledOffContent;
13 const QByteArray ToggleSwitch::s_toggleOnSvgContent = ToggleSwitchSVG::s_toggledOnContent;
14 const int ToggleSwitch::s_colorPosInToggleOn = ToggleSwitch::s_toggleOnSvgContent.indexOf("#1a73e8");
16 ToggleSwitch::ToggleSwitch(QWidget *parent) : QCheckBox(parent){
18 setFixedWidth(50);
19 setFixedHeight(width()/2);
21 m_toggleOnSvgContentColored = s_toggleOnSvgContent;
24 void ToggleSwitch::paintEvent(QPaintEvent *event){
25 QPainter p(this);
27 if(isChecked()){
28 auto accent = palette().highlight().color();
29 m_toggleOnSvgContentColored = m_toggleOnSvgContentColored.replace(s_colorPosInToggleOn, 7, accent.name().toLatin1());
31 m_svgr.load(m_toggleOnSvgContentColored);
32 } else {
33 m_svgr.load(s_toggleOffSvgContent);
36 m_svgr.render(&p, this->rect());
37 p.end();