mirror of
https://git.citron-emu.org/citron/emulator
synced 2026-01-28 21:53:28 +00:00
add: rainbow_style.cpp
Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
38
src/citron/util/rainbow_style.cpp
Normal file
38
src/citron/util/rainbow_style.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// SPDX-FileCopyrightText: 2025 citron Emulator Project
|
||||
|
||||
#include "citron/util/rainbow_style.h"
|
||||
#include "citron/uisettings.h"
|
||||
#include "citron/theme.h"
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
#include <QWidget>
|
||||
|
||||
float RainbowStyle::s_hue = 0.0f;
|
||||
|
||||
RainbowStyle::RainbowStyle(QStyle* baseStyle) : QProxyStyle(baseStyle) {
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, &QTimer::timeout, this, &RainbowStyle::UpdateHue);
|
||||
m_timer->start(33);
|
||||
}
|
||||
|
||||
void RainbowStyle::UpdateHue() {
|
||||
if (UISettings::values.enable_rainbow_mode.GetValue()) {
|
||||
s_hue += 0.005f;
|
||||
if (s_hue > 1.0f) s_hue = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
QColor RainbowStyle::GetCurrentHighlightColor() {
|
||||
if (!UISettings::values.enable_rainbow_mode.GetValue()) {
|
||||
return QColor(Theme::GetAccentColor());
|
||||
}
|
||||
return QColor::fromHsvF(s_hue, 0.7f, 1.0f);
|
||||
}
|
||||
|
||||
QPalette RainbowStyle::standardPalette() const {
|
||||
QPalette pal = QProxyStyle::standardPalette();
|
||||
QColor highlight = GetCurrentHighlightColor();
|
||||
pal.setColor(QPalette::Highlight, highlight);
|
||||
pal.setColor(QPalette::Link, highlight);
|
||||
return pal;
|
||||
}
|
||||
Reference in New Issue
Block a user