From ca36d08893724c37cc500dd71c9e6abd1f54796b Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 16 Sep 2017 09:53:30 +0200 Subject: [PATCH] Qt: use rgba lambda for default stylesheet --- rpcs3/rpcs3_app.cpp | 59 +++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/rpcs3/rpcs3_app.cpp b/rpcs3/rpcs3_app.cpp index f89151ce8c..44211c4e00 100644 --- a/rpcs3/rpcs3_app.cpp +++ b/rpcs3/rpcs3_app.cpp @@ -275,46 +275,53 @@ void rpcs3_app::OnChangeStyleSheetRequest(const QString& sheetFilePath) QFile file(sheetFilePath); if (sheetFilePath == "") { + auto rgba = [](const QColor& c, int v = 0) + { + return QString("rgba(%1, %2, %3, %4);").arg(c.red() + v).arg(c.green() + v).arg(c.blue() + v).arg(c.alpha() + v); + }; + // toolbar color stylesheet - QColor tbc = GUI::mw_tool_bar_color; - QString style_toolbar = QString( - "QLineEdit#mw_searchbar { margin-left:14px; background-color: rgba(%1, %2, %3, %4); }" - "QToolBar#mw_toolbar { background-color: rgba(%1, %2, %3, %4); }" - "QToolBar#mw_toolbar QSlider { background-color: rgba(%1, %2, %3, %4); }" - "QToolBar#mw_toolbar::separator {background-color: rgba(%5, %6, %7, %8); width: 1px; margin-top: 2px; margin-bottom: 2px;}") - .arg(tbc.red()).arg(tbc.green()).arg(tbc.blue()).arg(tbc.alpha()) - .arg(tbc.red() - 20).arg(tbc.green() - 20).arg(tbc.blue() - 20).arg(tbc.alpha() - 20); + QString rgba_tool_bar = rgba(GUI::mw_tool_bar_color); + QString style_toolbar = QString + ( + "QLineEdit#mw_searchbar { margin-left:14px; background-color: " + rgba_tool_bar + " }" + "QToolBar#mw_toolbar { background-color: " + rgba_tool_bar + " }" + "QToolBar#mw_toolbar QSlider { background-color: " + rgba_tool_bar + " }" + "QToolBar#mw_toolbar::separator { background-color: " + rgba(GUI::mw_tool_bar_color, -20) + " width: 1px; margin-top: 2px; margin-bottom: 2px; }" + ); // toolbar icon color stylesheet - QColor tic = GUI::mw_tool_icon_color; - QString style_toolbar_icons = QString( - "QLabel#toolbar_icon_color { color: rgba(%1, %2, %3, %4); }") - .arg(tic.red()).arg(tic.green()).arg(tic.blue()).arg(tic.alpha()); + QString style_toolbar_icons = QString + ( + "QLabel#toolbar_icon_color { color: " + rgba(GUI::mw_tool_icon_color) + " }" + ); // thumbnail icon color stylesheet - QColor thic = GUI::mw_thumb_icon_color; - QString style_thumbnail_icons = QString( - "QLabel#thumbnail_icon_color { color: rgba(%1, %2, %3, %4); }") - .arg(thic.red()).arg(thic.green()).arg(thic.blue()).arg(thic.alpha()); + QString style_thumbnail_icons = QString + ( + "QLabel#thumbnail_icon_color { color: " + rgba(GUI::mw_thumb_icon_color) + " }" + ); // gamelist toolbar stylesheet - QColor gltic = GUI::gl_tool_icon_color; - QString style_gamelist_toolbar = QString( + QString style_gamelist_toolbar = QString + ( "QLineEdit#tb_searchbar { background: transparent; }" - "QLabel#gamelist_toolbar_icon_color { color: rgba(%1, %2, %3, %4); }") - .arg(gltic.red()).arg(gltic.green()).arg(gltic.blue()).arg(gltic.alpha()); + "QLabel#gamelist_toolbar_icon_color { color: " + rgba(GUI::gl_tool_icon_color) + " }" + ); // gamelist icon color stylesheet - QColor glic = GUI::gl_icon_color; - QString style_gamelist_icons = QString( - "QLabel#gamelist_icon_background_color { color: rgba(%1, %2, %3, %4); }") - .arg(glic.red()).arg(glic.green()).arg(glic.blue()).arg(glic.alpha()); + QString style_gamelist_icons = QString + ( + "QLabel#gamelist_icon_background_color { color: " + rgba(GUI::gl_icon_color) + " }" + ); // other objects' stylesheet - QString style_rest = QString( + QString style_rest = QString + ( "QWidget#header_section { background-color: #ffffff; }" "QLabel#l_controller { color: #434343; }" - "QLabel#gamegrid_font { font-weight: 600; font-size: 8pt; font-family: Lucida Grande; color: rgba(51, 51, 51, 255); }"); + "QLabel#gamegrid_font { font-weight: 600; font-size: 8pt; font-family: Lucida Grande; color: rgba(51, 51, 51, 255); }" + ); setStyleSheet(style_toolbar + style_toolbar_icons + style_thumbnail_icons + style_gamelist_toolbar + style_gamelist_icons + style_rest); }