Use theme based icons for status dock, group, and duration icon

This commit is contained in:
WarmUpTill
2023-03-18 15:27:51 +01:00
committed by WarmUpTill
parent e66d0bc6b8
commit 9e4b003608
11 changed files with 52 additions and 12 deletions

View File

@@ -121,8 +121,9 @@ DurationModifierEdit::DurationModifierEdit(QWidget *parent)
_duration = new DurationSelection(parent);
_toggle = new QPushButton(parent);
_toggle->setMaximumWidth(22);
_toggle->setIcon(
QIcon(QString::fromStdString(getDataFilePath("res/time.svg"))));
const auto path = QString::fromStdString(getDataFilePath(
"res/images/" + GetThemeTypeName() + "time.svg"));
_toggle->setIcon(QIcon(path));
populateDurationModifierTypes(_condition);
QWidget::connect(_condition, SIGNAL(currentIndexChanged(int)), this,
SLOT(_ModifierChanged(int)));

View File

@@ -27,10 +27,9 @@ MacroTreeItem::MacroTreeItem(MacroTree *tree, std::shared_ptr<Macro> macroItem,
bool isGroup = _macro->IsGroup();
if (isGroup) {
QIcon icon;
icon.addFile(
QString::fromUtf8(":/res/images/sources/group.svg"),
QSize(), QIcon::Normal, QIcon::Off);
const auto path = QString::fromStdString(getDataFilePath(
"res/images/" + GetThemeTypeName() + "group.svg"));
QIcon icon(path);
QPixmap pixmap = icon.pixmap(QSize(16, 16));
_iconLabel = new QLabel();
_iconLabel->setPixmap(pixmap);

View File

@@ -120,10 +120,9 @@ StatusDock::StatusDock(QWidget *parent) : OBSDock(parent)
QAction *action = new QAction;
action->setProperty("themeID", QVariant(QString::fromUtf8("cogsIcon")));
action->connect(action, &QAction::triggered, OpenSettingsWindow);
QIcon icon;
icon.addFile(
QString::fromUtf8(":/settings/images/settings/advanced.svg"),
QSize(), QIcon::Normal, QIcon::Off);
const auto path = QString::fromStdString(getDataFilePath(
"res/images/" + GetThemeTypeName() + "advanced.svg"));
QIcon icon(path);
action->setIcon(icon);
auto toolbar = new QToolBar;

View File

@@ -16,6 +16,7 @@
#include <QSystemTrayIcon>
#include <QGuiApplication>
#include <QCursor>
#include <QMainWindow>
#include <unordered_map>
#include <regex>
#include <set>
@@ -867,6 +868,22 @@ bool windowPosValid(QPoint pos)
return !!QGuiApplication::screenAt(pos);
}
std::string GetThemeTypeName()
{
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(29, 0, 0)
return obs_frontend_is_theme_dark() ? "Dark" : "Light";
#else
auto mainWindow =
static_cast<QMainWindow *>(obs_frontend_get_main_window());
if (!mainWindow) {
return "Dark";
}
QColor color = mainWindow->palette().text().color();
const bool themeDarkMode = !(color.redF() < 0.5);
return themeDarkMode ? "Dark" : "Light";
#endif
}
QMetaObject::Connection PulseWidget(QWidget *widget, QColor startColor,
QColor endColor, bool once)
{

View File

@@ -105,6 +105,7 @@ int findIdxInRagne(QComboBox *list, int start, int stop,
bool DisplayMessage(const QString &msg, bool question = false);
void DisplayTrayMessage(const QString &title, const QString &msg);
bool windowPosValid(QPoint pos);
std::string GetThemeTypeName();
/* Generic helpers */