mirror of https://github.com/stenzek/duckstation
Qt: Add Controller LED options (where supported)
parent
722771fff6
commit
c393db419e
@ -0,0 +1,50 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 Connor McLaughlin <stenzek@gmail.com>
|
||||||
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||||
|
|
||||||
|
#include "colorpickerbutton.h"
|
||||||
|
#include "qtutils.h"
|
||||||
|
|
||||||
|
#include <QtWidgets/QColorDialog>
|
||||||
|
|
||||||
|
ColorPickerButton::ColorPickerButton(QWidget* parent) : QPushButton(parent)
|
||||||
|
{
|
||||||
|
connect(this, &QPushButton::clicked, this, &ColorPickerButton::onClicked);
|
||||||
|
updateBackgroundColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 ColorPickerButton::color()
|
||||||
|
{
|
||||||
|
return m_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorPickerButton::setColor(u32 rgb)
|
||||||
|
{
|
||||||
|
if (m_color == rgb)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_color = rgb;
|
||||||
|
updateBackgroundColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorPickerButton::updateBackgroundColor()
|
||||||
|
{
|
||||||
|
setStyleSheet(QStringLiteral("background-color: #%1;").arg(static_cast<uint>(m_color), 8, 16, QChar('0')));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorPickerButton::onClicked()
|
||||||
|
{
|
||||||
|
const u32 red = (m_color >> 16) & 0xff;
|
||||||
|
const u32 green = (m_color >> 8) & 0xff;
|
||||||
|
const u32 blue = m_color & 0xff;
|
||||||
|
|
||||||
|
const QColor initial(QColor::fromRgb(red, green, blue));
|
||||||
|
const QColor selected(QColorDialog::getColor(initial, QtUtils::GetRootWidget(this), tr("Select LED Color")));
|
||||||
|
if (initial == selected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const u32 new_rgb = (static_cast<u32>(selected.red()) << 16) | (static_cast<u32>(selected.green()) << 8) |
|
||||||
|
static_cast<u32>(selected.blue());
|
||||||
|
m_color = new_rgb;
|
||||||
|
updateBackgroundColor();
|
||||||
|
emit colorChanged(new_rgb);
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 Connor McLaughlin <stenzek@gmail.com>
|
||||||
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "common/types.h"
|
||||||
|
#include <QtWidgets/QPushButton>
|
||||||
|
|
||||||
|
class ColorPickerButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ColorPickerButton(QWidget* parent);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void colorChanged(quint32 new_color);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
quint32 color();
|
||||||
|
void setColor(quint32 rgb);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void onClicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateBackgroundColor();
|
||||||
|
|
||||||
|
u32 m_color = 0;
|
||||||
|
};
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ControllerLEDSettingsDialog</class>
|
||||||
|
<widget class="QDialog" name="ControllerLEDSettingsDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>501</width>
|
||||||
|
<height>108</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Controller LED Settings</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>SDL-0 LED</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="ColorPickerButton" name="SDL0LED"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>SDL-1 LED</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="ColorPickerButton" name="SDL1LED"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
|
<property name="title">
|
||||||
|
<string>SDL-2 LED</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="ColorPickerButton" name="SDL2LED"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
|
<property name="title">
|
||||||
|
<string>SDL-3 LED</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="ColorPickerButton" name="SDL3LED"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="4">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>ColorPickerButton</class>
|
||||||
|
<extends>QPushButton</extends>
|
||||||
|
<header>colorpickerbutton.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M9.973 18H11v-5h2v5h1.027c.132-1.202.745-2.194 1.74-3.277.113-.122.832-.867.917-.973a6 6 0 1 0-9.37-.002c.086.107.807.853.918.974.996 1.084 1.609 2.076 1.741 3.278zM10 20v1h4v-1h-4zm-4.246-5a8 8 0 1 1 12.49.002C17.624 15.774 16 17 16 18.5V21a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2.5C8 17 6.375 15.774 5.754 15z" fill="#000000"/></svg>
|
||||||
|
After Width: | Height: | Size: 458 B |
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M9.973 18H11v-5h2v5h1.027c.132-1.202.745-2.194 1.74-3.277.113-.122.832-.867.917-.973a6 6 0 1 0-9.37-.002c.086.107.807.853.918.974.996 1.084 1.609 2.076 1.741 3.278zM10 20v1h4v-1h-4zm-4.246-5a8 8 0 1 1 12.49.002C17.624 15.774 16 17 16 18.5V21a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2.5C8 17 6.375 15.774 5.754 15z" fill="#ffffff"/></svg>
|
||||||
|
After Width: | Height: | Size: 458 B |
Loading…
Reference in New Issue