mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix coloration of swatches on styles with distinct frame backgrounds
This commit is contained in:
parent
baf5d71f93
commit
8b887cb0ff
1
CHANGES
1
CHANGES
|
@ -71,6 +71,7 @@ Other fixes:
|
|||
- Qt: Fix preloading for ROM replacing
|
||||
- Qt: Fix screen not displaying on Wayland (fixes mgba.io/i/2190)
|
||||
- Qt: Fix crash when selecting 256-color sprite in sprite view
|
||||
- Qt: Fix coloration of swatches on styles with distinct frame backgrounds
|
||||
- VFS: Failed file mapping should return NULL on POSIX
|
||||
Misc:
|
||||
- Core: Suspend runloop when a core crashes
|
||||
|
|
|
@ -15,11 +15,8 @@ ColorPicker::ColorPicker() {
|
|||
|
||||
ColorPicker::ColorPicker(QWidget* parent, const QColor& defaultColor)
|
||||
: m_parent(parent)
|
||||
, m_defaultColor(defaultColor)
|
||||
{
|
||||
QPalette palette = parent->palette();
|
||||
palette.setColor(parent->backgroundRole(), defaultColor);
|
||||
parent->setPalette(palette);
|
||||
setColor(defaultColor);
|
||||
parent->installEventFilter(this);
|
||||
}
|
||||
|
||||
|
@ -36,10 +33,7 @@ ColorPicker& ColorPicker::operator=(const ColorPicker& other) {
|
|||
|
||||
void ColorPicker::setColor(const QColor& color) {
|
||||
m_defaultColor = color;
|
||||
|
||||
QPalette palette = m_parent->palette();
|
||||
palette.setColor(m_parent->backgroundRole(), color);
|
||||
m_parent->setPalette(palette);
|
||||
m_parent->setStyleSheet(QString("background-color: %1;").arg(color.name()));
|
||||
}
|
||||
|
||||
bool ColorPicker::eventFilter(QObject* obj, QEvent* event) {
|
||||
|
@ -57,10 +51,7 @@ bool ColorPicker::eventFilter(QObject* obj, QEvent* event) {
|
|||
colorPicker->setCurrentColor(m_defaultColor);
|
||||
colorPicker->open();
|
||||
connect(colorPicker, &QColorDialog::colorSelected, [this, swatch](const QColor& color) {
|
||||
m_defaultColor = color;
|
||||
QPalette palette = swatch->palette();
|
||||
palette.setColor(swatch->backgroundRole(), color);
|
||||
swatch->setPalette(palette);
|
||||
setColor(color);
|
||||
emit colorChanged(color);
|
||||
});
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue