mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-23 03:02:53 +01:00
Qt: add optional states to toolbar icons
This commit is contained in:
parent
d0e9108800
commit
4557992334
@ -1421,11 +1421,27 @@ void main_window::RepaintThumbnailIcons()
|
|||||||
|
|
||||||
void main_window::RepaintToolBarIcons()
|
void main_window::RepaintToolBarIcons()
|
||||||
{
|
{
|
||||||
const QColor new_color = gui::utils::get_label_color("toolbar_icon_color");
|
std::map<QIcon::Mode, QColor> new_colors{};
|
||||||
|
new_colors[QIcon::Normal] = gui::utils::get_label_color("toolbar_icon_color");
|
||||||
|
|
||||||
const auto icon = [&new_color](const QString& path)
|
const QString sheet = static_cast<QApplication *>(QCoreApplication::instance())->styleSheet();
|
||||||
|
|
||||||
|
if (sheet.contains("toolbar_icon_color_disabled"))
|
||||||
{
|
{
|
||||||
return gui::utils::get_colorized_icon(QIcon(path), Qt::black, new_color);
|
new_colors[QIcon::Disabled] = gui::utils::get_label_color("toolbar_icon_color_disabled");
|
||||||
|
}
|
||||||
|
if (sheet.contains("toolbar_icon_color_active"))
|
||||||
|
{
|
||||||
|
new_colors[QIcon::Active] = gui::utils::get_label_color("toolbar_icon_color_active");
|
||||||
|
}
|
||||||
|
if (sheet.contains("toolbar_icon_color_selected"))
|
||||||
|
{
|
||||||
|
new_colors[QIcon::Selected] = gui::utils::get_label_color("toolbar_icon_color_selected");
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto icon = [&new_colors](const QString& path)
|
||||||
|
{
|
||||||
|
return gui::utils::get_colorized_icon(QIcon(path), Qt::black, new_colors);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_icon_play = icon(":/Icons/play.png");
|
m_icon_play = icon(":/Icons/play.png");
|
||||||
@ -1465,6 +1481,7 @@ void main_window::RepaintToolBarIcons()
|
|||||||
ui->toolbar_fullscreen->setIcon(m_icon_fullscreen_on);
|
ui->toolbar_fullscreen->setIcon(m_icon_fullscreen_on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QColor& new_color = new_colors[QIcon::Normal];
|
||||||
ui->sizeSlider->setStyleSheet(ui->sizeSlider->styleSheet().append("QSlider::handle:horizontal{ background: rgba(%1, %2, %3, %4); }")
|
ui->sizeSlider->setStyleSheet(ui->sizeSlider->styleSheet().append("QSlider::handle:horizontal{ background: rgba(%1, %2, %3, %4); }")
|
||||||
.arg(new_color.red()).arg(new_color.green()).arg(new_color.blue()).arg(new_color.alpha()));
|
.arg(new_color.red()).arg(new_color.green()).arg(new_color.blue()).arg(new_color.alpha()));
|
||||||
|
|
||||||
|
@ -150,6 +150,17 @@ namespace gui
|
|||||||
return QIcon(get_colorized_pixmap(old_icon.pixmap(old_icon.availableSizes().at(0)), old_color, new_color, use_special_masks, colorize_all));
|
return QIcon(get_colorized_pixmap(old_icon.pixmap(old_icon.availableSizes().at(0)), old_color, new_color, use_special_masks, colorize_all));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon get_colorized_icon(const QIcon& old_icon, const QColor& old_color, const std::map<QIcon::Mode, QColor>& new_colors, bool use_special_masks, bool colorize_all)
|
||||||
|
{
|
||||||
|
QIcon icon{};
|
||||||
|
const QPixmap old_pixmap = old_icon.pixmap(old_icon.availableSizes().at(0));
|
||||||
|
for (const auto& [mode, color] : new_colors)
|
||||||
|
{
|
||||||
|
icon.addPixmap(get_colorized_pixmap(old_pixmap, old_color, color, use_special_masks, colorize_all), mode);
|
||||||
|
}
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList get_dir_entries(const QDir& dir, const QStringList& name_filters)
|
QStringList get_dir_entries(const QDir& dir, const QStringList& name_filters)
|
||||||
{
|
{
|
||||||
QFileInfoList entries = dir.entryInfoList(name_filters, QDir::Files);
|
QFileInfoList entries = dir.entryInfoList(name_filters, QDir::Files);
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace gui
|
namespace gui
|
||||||
{
|
{
|
||||||
@ -57,6 +58,7 @@ namespace gui
|
|||||||
// use colorize_all to repaint every opaque pixel with the chosen color
|
// use colorize_all to repaint every opaque pixel with the chosen color
|
||||||
// use_special_masks is only used for icons with multiple predefined colors
|
// use_special_masks is only used for icons with multiple predefined colors
|
||||||
QIcon get_colorized_icon(const QIcon& old_icon, const QColor& old_color, const QColor& new_color, bool use_special_masks = false, bool colorize_all = false);
|
QIcon get_colorized_icon(const QIcon& old_icon, const QColor& old_color, const QColor& new_color, bool use_special_masks = false, bool colorize_all = false);
|
||||||
|
QIcon get_colorized_icon(const QIcon& old_icon, const QColor& old_color, const std::map<QIcon::Mode, QColor>& new_colors, bool use_special_masks = false, bool colorize_all = false);
|
||||||
|
|
||||||
// Returns a list of all base names of files in dir whose complete file names contain one of the given name_filters
|
// Returns a list of all base names of files in dir whose complete file names contain one of the given name_filters
|
||||||
QStringList get_dir_entries(const QDir& dir, const QStringList& name_filters);
|
QStringList get_dir_entries(const QDir& dir, const QStringList& name_filters);
|
||||||
|
Loading…
Reference in New Issue
Block a user