mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
stylesheets: add custom color to gamepad
This commit is contained in:
parent
37bc2b3bb9
commit
c7c0139788
6 changed files with 29 additions and 12 deletions
|
@ -319,6 +319,7 @@ void rpcs3_app::OnChangeStyleSheetRequest(const QString& sheetFilePath)
|
||||||
// other objects' stylesheet
|
// other objects' stylesheet
|
||||||
QString style_rest = QString(
|
QString style_rest = QString(
|
||||||
"QWidget#header_section { background-color: #ffffff; }"
|
"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_gamelist_toolbar + style_gamelist_icons + style_rest);
|
setStyleSheet(style_toolbar + style_toolbar_icons + style_gamelist_toolbar + style_gamelist_icons + style_rest);
|
||||||
|
|
|
@ -76,9 +76,23 @@ q_pair_list gui_settings::Var2List(const QVariant& var)
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon gui_settings::colorizedIcon(const QIcon& icon, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks)
|
QIcon gui_settings::colorizedIcon(const QIcon& icon, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks, bool colorizeAll)
|
||||||
{
|
{
|
||||||
QPixmap pixmap = icon.pixmap(icon.availableSizes().at(0));
|
return QIcon(colorizedPixmap(icon.pixmap(icon.availableSizes().at(0)), oldColor, newColor, useSpecialMasks, colorizeAll));
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap gui_settings::colorizedPixmap(const QPixmap& old_pixmap, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks, bool colorizeAll)
|
||||||
|
{
|
||||||
|
QPixmap pixmap = old_pixmap;
|
||||||
|
|
||||||
|
if (colorizeAll)
|
||||||
|
{
|
||||||
|
QBitmap mask = pixmap.createMaskFromColor(Qt::transparent, Qt::MaskInColor);
|
||||||
|
pixmap.fill(newColor);
|
||||||
|
pixmap.setMask(mask);
|
||||||
|
return pixmap;
|
||||||
|
}
|
||||||
|
|
||||||
QBitmap mask = pixmap.createMaskFromColor(oldColor, Qt::MaskOutColor);
|
QBitmap mask = pixmap.createMaskFromColor(oldColor, Qt::MaskOutColor);
|
||||||
pixmap.fill(newColor);
|
pixmap.fill(newColor);
|
||||||
pixmap.setMask(mask);
|
pixmap.setMask(mask);
|
||||||
|
@ -96,19 +110,19 @@ QIcon gui_settings::colorizedIcon(const QIcon& icon, const QColor& oldColor, con
|
||||||
};
|
};
|
||||||
|
|
||||||
QColor colorS1(Qt::white);
|
QColor colorS1(Qt::white);
|
||||||
QPixmap pixmapS1 = icon.pixmap(icon.availableSizes().at(0));
|
QPixmap pixmapS1 = old_pixmap;
|
||||||
QBitmap maskS1 = pixmapS1.createMaskFromColor(colorS1, Qt::MaskOutColor);
|
QBitmap maskS1 = pixmapS1.createMaskFromColor(colorS1, Qt::MaskOutColor);
|
||||||
pixmapS1.fill(colorS1);
|
pixmapS1.fill(colorS1);
|
||||||
pixmapS1.setMask(maskS1);
|
pixmapS1.setMask(maskS1);
|
||||||
|
|
||||||
QColor colorS2(0, 173, 246, 255);
|
QColor colorS2(0, 173, 246, 255);
|
||||||
QPixmap pixmapS2 = icon.pixmap(icon.availableSizes().at(0));
|
QPixmap pixmapS2 = old_pixmap;
|
||||||
QBitmap maskS2 = pixmapS2.createMaskFromColor(colorS2, Qt::MaskOutColor);
|
QBitmap maskS2 = pixmapS2.createMaskFromColor(colorS2, Qt::MaskOutColor);
|
||||||
pixmapS2.fill(saturatedColor(newColor, 0.6f));
|
pixmapS2.fill(saturatedColor(newColor, 0.6f));
|
||||||
pixmapS2.setMask(maskS2);
|
pixmapS2.setMask(maskS2);
|
||||||
|
|
||||||
QColor colorS3(0, 132, 244, 255);
|
QColor colorS3(0, 132, 244, 255);
|
||||||
QPixmap pixmapS3 = icon.pixmap(icon.availableSizes().at(0));
|
QPixmap pixmapS3 = old_pixmap;
|
||||||
QBitmap maskS3 = pixmapS3.createMaskFromColor(colorS3, Qt::MaskOutColor);
|
QBitmap maskS3 = pixmapS3.createMaskFromColor(colorS3, Qt::MaskOutColor);
|
||||||
pixmapS3.fill(saturatedColor(newColor, 0.3f));
|
pixmapS3.fill(saturatedColor(newColor, 0.3f));
|
||||||
pixmapS3.setMask(maskS3);
|
pixmapS3.setMask(maskS3);
|
||||||
|
@ -119,8 +133,7 @@ QIcon gui_settings::colorizedIcon(const QIcon& icon, const QColor& oldColor, con
|
||||||
painter.drawPixmap(QPoint(0, 0), pixmapS3);
|
painter.drawPixmap(QPoint(0, 0), pixmapS3);
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
|
return pixmap;
|
||||||
return QIcon(pixmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_settings::SetValue(const GUI_SAVE& entry, const QVariant& value)
|
void gui_settings::SetValue(const GUI_SAVE& entry, const QVariant& value)
|
||||||
|
|
|
@ -180,7 +180,8 @@ public:
|
||||||
@param newColor the desired color for the new icon
|
@param newColor the desired color for the new icon
|
||||||
@param useSpecialMasks only used for icons with white parts and disc game icon
|
@param useSpecialMasks only used for icons with white parts and disc game icon
|
||||||
*/
|
*/
|
||||||
static QIcon colorizedIcon(const QIcon& icon, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks = false);
|
static QIcon colorizedIcon(const QIcon& icon, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks = false, bool colorizeAll = false);
|
||||||
|
static QPixmap colorizedPixmap(const QPixmap& old_pixmap, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks = false, bool colorizeAll = false);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void Reset(bool removeMeta = false);
|
void Reset(bool removeMeta = false);
|
||||||
|
|
|
@ -1153,7 +1153,7 @@ void main_window::CreateConnects()
|
||||||
connect(ui->confSystemAct, &QAction::triggered, [=]() { openSettings(4); });
|
connect(ui->confSystemAct, &QAction::triggered, [=]() { openSettings(4); });
|
||||||
|
|
||||||
connect(ui->confPadAct, &QAction::triggered, this, [=](){
|
connect(ui->confPadAct, &QAction::triggered, this, [=](){
|
||||||
pad_settings_dialog dlg(this);
|
pad_settings_dialog dlg(guiSettings, this);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
});
|
});
|
||||||
connect(ui->confAutopauseManagerAct, &QAction::triggered, [=](){
|
connect(ui->confAutopauseManagerAct, &QAction::triggered, [=](){
|
||||||
|
@ -1305,7 +1305,7 @@ void main_window::CreateConnects()
|
||||||
ui->toolbar_fullscreen->setIcon(icon_fullscreen_off);
|
ui->toolbar_fullscreen->setIcon(icon_fullscreen_off);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(ui->toolbar_controls, &QAction::triggered, [=]() { pad_settings_dialog dlg(this); dlg.exec(); });
|
connect(ui->toolbar_controls, &QAction::triggered, [=]() { pad_settings_dialog dlg(guiSettings, this); dlg.exec(); });
|
||||||
connect(ui->toolbar_config, &QAction::triggered, [=]() { openSettings(0); });
|
connect(ui->toolbar_config, &QAction::triggered, [=]() { openSettings(0); });
|
||||||
connect(ui->toolbar_list, &QAction::triggered, [=]() { ui->setlistModeListAct->trigger(); });
|
connect(ui->toolbar_list, &QAction::triggered, [=]() { ui->setlistModeListAct->trigger(); });
|
||||||
connect(ui->toolbar_grid, &QAction::triggered, [=]() { ui->setlistModeGridAct->trigger(); });
|
connect(ui->toolbar_grid, &QAction::triggered, [=]() { ui->setlistModeGridAct->trigger(); });
|
||||||
|
|
|
@ -18,7 +18,7 @@ static const int PadButtonWidth = 60;
|
||||||
|
|
||||||
extern keyboard_pad_config g_kbpad_config;
|
extern keyboard_pad_config g_kbpad_config;
|
||||||
|
|
||||||
pad_settings_dialog::pad_settings_dialog(QWidget *parent) : QDialog(parent), ui(new Ui::pad_settings_dialog)
|
pad_settings_dialog::pad_settings_dialog(std::shared_ptr<gui_settings> gui_settings, QWidget *parent) : QDialog(parent), ui(new Ui::pad_settings_dialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ pad_settings_dialog::pad_settings_dialog(QWidget *parent) : QDialog(parent), ui(
|
||||||
g_kbpad_config.load();
|
g_kbpad_config.load();
|
||||||
UpdateLabel();
|
UpdateLabel();
|
||||||
|
|
||||||
|
ui->l_controller->setPixmap(gui_settings->colorizedPixmap(*ui->l_controller->pixmap(), QColor(), GUI::get_Label_Color("l_controller"), false, true));
|
||||||
ui->l_controller->setMaximumSize(ui->gb_description->sizeHint().width(), ui->l_controller->maximumHeight() * ui->gb_description->sizeHint().width() / ui->l_controller->maximumWidth());
|
ui->l_controller->setMaximumSize(ui->gb_description->sizeHint().width(), ui->l_controller->maximumHeight() * ui->gb_description->sizeHint().width() / ui->l_controller->maximumWidth());
|
||||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "Emu/Io/PadHandler.h"
|
#include "Emu/Io/PadHandler.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
|
#include "gui_settings.h"
|
||||||
|
|
||||||
enum button_ids
|
enum button_ids
|
||||||
{
|
{
|
||||||
|
@ -69,7 +70,7 @@ private:
|
||||||
public:
|
public:
|
||||||
// TODO get Init to work
|
// TODO get Init to work
|
||||||
virtual void Init(const u32 max_connect) override;
|
virtual void Init(const u32 max_connect) override;
|
||||||
explicit pad_settings_dialog(QWidget *parent = 0);
|
explicit pad_settings_dialog(std::shared_ptr<gui_settings> gui_settings, QWidget *parent = 0);
|
||||||
~pad_settings_dialog();
|
~pad_settings_dialog();
|
||||||
void keyPressEvent(QKeyEvent *keyEvent) override;
|
void keyPressEvent(QKeyEvent *keyEvent) override;
|
||||||
void UpdateLabel();
|
void UpdateLabel();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue