Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/cmake/ui-components.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ target_sources(
components/MenuButton.hpp
components/MenuCheckBox.cpp
components/MenuCheckBox.hpp
components/MenuRadioButton.cpp
components/MenuRadioButton.hpp
components/Multiview.cpp
components/Multiview.hpp
components/MuteCheckBox.hpp
Expand Down
21 changes: 11 additions & 10 deletions frontend/components/MenuCheckBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,25 @@ MenuCheckBox::MenuCheckBox(const QString &text, QWidget *parent) : QCheckBox(tex
setContentsMargins(0, 0, 0, 0);

if (auto menu = qobject_cast<QMenu *>(parent)) {
connect(menu, &QMenu::hovered, this, [this, menu](QAction *action) {
if (action != menuAction) {
setHovered(false);
update();
}
connect(menu, &QMenu::aboutToShow, this, [this]() {
setHovered(false);
update();
});
connect(menu, &QMenu::aboutToHide, this, [this]() {
setHovered(false);
update();
});
connect(menu, &QMenu::aboutToHide, this, [this]() { setHovered(false); });
}
}

void MenuCheckBox::setAction(QAction *action)
void MenuCheckBox::focusInEvent(QFocusEvent *)
{
menuAction = action;
setHovered(true);
}

void MenuCheckBox::focusInEvent(QFocusEvent *)
void MenuCheckBox::focusOutEvent(QFocusEvent *)
{
setHovered(true);
setHovered(false);
}

void MenuCheckBox::mousePressEvent(QMouseEvent *event)
Expand Down
4 changes: 1 addition & 3 deletions frontend/components/MenuCheckBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ class MenuCheckBox : public QCheckBox {
public:
explicit MenuCheckBox(const QString &text, QWidget *parent = nullptr);

void setAction(QAction *action);

protected:
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
Expand All @@ -42,7 +41,6 @@ class MenuCheckBox : public QCheckBox {
void paintEvent(QPaintEvent *event) override;

private:
QPointer<QAction> menuAction = nullptr;
bool mousePressInside = false;

bool isHovered = false;
Expand Down
113 changes: 113 additions & 0 deletions frontend/components/MenuRadioButton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/******************************************************************************
Copyright (C) 2026 by Taylor Giampaolo <warchamp7@obsproject.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include "MenuRadioButton.hpp"

#include <QMenu>
#include <QMouseEvent>
#include <QStyleOptionButton>
#include <QStylePainter>

MenuRadioButton::MenuRadioButton(const QString &text, QWidget *parent) : QRadioButton(text, parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
setContentsMargins(0, 0, 0, 0);

if (auto menu = qobject_cast<QMenu *>(parent)) {
connect(menu, &QMenu::aboutToShow, this, [this]() {
setHovered(false);
update();
});
connect(menu, &QMenu::aboutToHide, this, [this]() {
setHovered(false);
update();
});
}
}

void MenuRadioButton::focusInEvent(QFocusEvent *)
{
setHovered(true);
}

void MenuRadioButton::focusOutEvent(QFocusEvent *)
{
setHovered(false);
}

void MenuRadioButton::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
mousePressInside = true;
event->accept();
} else {
QRadioButton::mousePressEvent(event);
}
}

void MenuRadioButton::mouseMoveEvent(QMouseEvent *event)
{
if (!rect().contains(event->pos())) {
mousePressInside = false;
}
event->accept();
}

void MenuRadioButton::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
if (mousePressInside && rect().contains(event->pos())) {
toggle();
}
event->accept();
} else {
QRadioButton::mouseReleaseEvent(event);
}

mousePressInside = false;
}

void MenuRadioButton::enterEvent(QEnterEvent *)
{
setHovered(true);
update();
}

void MenuRadioButton::leaveEvent(QEvent *)
{
setHovered(false);
update();
}

void MenuRadioButton::paintEvent(QPaintEvent *)
{
QStylePainter p(this);
QStyleOptionButton opt;
initStyleOption(&opt);

if (isHovered) {
opt.state |= QStyle::State_MouseOver;
opt.state |= QStyle::State_Selected;
}

p.drawControl(QStyle::CE_RadioButton, opt);
}

void MenuRadioButton::setHovered(bool hovered)
{
isHovered = hovered;
}
48 changes: 48 additions & 0 deletions frontend/components/MenuRadioButton.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/******************************************************************************
Copyright (C) 2026 by Taylor Giampaolo <warchamp7@obsproject.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#pragma once

#include <QRadioButton>
#include <QPointer>

class QStyleOptionButton;
class QStylePainter;
class QMouseEvent;

class MenuRadioButton : public QRadioButton {
Q_OBJECT

public:
explicit MenuRadioButton(const QString &text, QWidget *parent = nullptr);

protected:
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;
void paintEvent(QPaintEvent *event) override;

bool isHovered = false;
void setHovered(bool hovered);

private:
bool mousePressInside = false;
};
3 changes: 3 additions & 0 deletions frontend/data/themes/Light/radio_checked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/data/themes/Light/radio_checked_disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/data/themes/Light/radio_checked_focus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/data/themes/Light/radio_unchecked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/data/themes/Light/radio_unchecked_disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions frontend/data/themes/Light/radio_unchecked_focus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 30 additions & 4 deletions frontend/data/themes/Yami.obt
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,6 @@ SourceTreeItem {
QMenu::item,
QMenu > QWidget {
padding: var(--padding_large) var(--padding_menu);
padding-right: 20px;
}

QMenu > QWidget {
Expand Down Expand Up @@ -755,6 +754,7 @@ QListWidget::item:hover {
}

QMenu::item:focus,
QMenu > QWidget:focus,
QListView::item:focus,
QListWidget::item:focus,
QMenu::item:selected:focus,
Expand Down Expand Up @@ -793,6 +793,10 @@ QListWidget QLineEdit:focus {
border: 1px solid var(--grey1);
}

QMenu MenuRadioButton {
padding-left: var(--padding_large);
}

/* Settings QList */

OBSBasicSettings QScrollBar:vertical {
Expand Down Expand Up @@ -1418,9 +1422,7 @@ QDoubleSpinBox::down-arrow {
color: var(--text);
}


/* Buttons */

QPushButton {
background-color: var(--button_bg);
color: var(--text);
Expand Down Expand Up @@ -1532,7 +1534,6 @@ QToolButton:disabled,
}

/* Sliders */

QSlider::groove {
background-color: var(--grey4);
border: none;
Expand Down Expand Up @@ -1999,6 +2000,7 @@ OBSBasicSettings {

QCheckBox::indicator,
QGroupBox::indicator,
QRadioButton::indicator,
QTableView::indicator {
width: var(--icon_base);
height: var(--icon_base);
Expand Down Expand Up @@ -2045,6 +2047,30 @@ QTableView::indicator:unchecked:disabled {
image: url(theme:Yami/checkbox_unchecked_disabled.svg);
}

QRadioButton::indicator:checked {
image: url(theme:Yami/radio_checked.svg);
}

QRadioButton::indicator:unchecked {
image: url(theme:Yami/radio_unchecked.svg);
}

QRadioButton::indicator:checked:hover {
image: url(theme:Yami/radio_checked_focus.svg);
}

QRadioButton::indicator:unchecked:hover {
image: url(theme:Yami/radio_unchecked_focus.svg);
}

QRadioButton::indicator:checked:disabled {
image: url(theme:Yami/radio_checked_disabled.svg);
}

QRadioButton::indicator:unchecked:disabled {
image: url(theme:Yami/radio_unchecked_disabled.svg);
}

/* Icon Checkboxes */
.checkbox-icon {
outline: none;
Expand Down
3 changes: 3 additions & 0 deletions frontend/data/themes/Yami/radio_checked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/data/themes/Yami/radio_checked_disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/data/themes/Yami/radio_checked_focus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/data/themes/Yami/radio_unchecked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/data/themes/Yami/radio_unchecked_disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions frontend/data/themes/Yami/radio_unchecked_focus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading