mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 19:45:20 +00:00
Qt: clean up gui_settings.h - move general functions to qt_utils.h
This commit is contained in:
parent
c10e195dba
commit
baea538c32
15 changed files with 187 additions and 175 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "debugger_frame.h"
|
||||
#include "qt_utils.h"
|
||||
|
||||
#include <QScrollBar>
|
||||
#include <QApplication>
|
||||
|
@ -155,10 +156,10 @@ void debugger_frame::ChangeColors()
|
|||
{
|
||||
if (m_list)
|
||||
{
|
||||
m_list->m_color_bp = gui::get_Label_Color("debugger_frame_breakpoint", QPalette::Background);
|
||||
m_list->m_color_pc = gui::get_Label_Color("debugger_frame_pc", QPalette::Background);
|
||||
m_list->m_text_color_bp = gui::get_Label_Color("debugger_frame_breakpoint");;
|
||||
m_list->m_text_color_pc = gui::get_Label_Color("debugger_frame_pc");;
|
||||
m_list->m_color_bp = gui::utils::get_label_color("debugger_frame_breakpoint", QPalette::Background);
|
||||
m_list->m_color_pc = gui::utils::get_label_color("debugger_frame_pc", QPalette::Background);
|
||||
m_list->m_text_color_bp = gui::utils::get_label_color("debugger_frame_breakpoint");;
|
||||
m_list->m_text_color_pc = gui::utils::get_label_color("debugger_frame_pc");;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "game_compatibility.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
|
||||
constexpr auto qstr = QString::fromStdString;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "game_list_frame.h"
|
||||
|
||||
#include "qt_utils.h"
|
||||
#include "settings_dialog.h"
|
||||
#include "table_item_delegate.h"
|
||||
#include "custom_table_widget_item.h"
|
||||
|
@ -790,7 +790,7 @@ void game_list_frame::RepaintIcons(const bool& fromSettings)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_Icon_Color = gui::get_Label_Color("gamelist_icon_background_color");
|
||||
m_Icon_Color = gui::utils::get_label_color("gamelist_icon_background_color");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "game_list_grid.h"
|
||||
#include "game_list_grid_delegate.h"
|
||||
#include "gui_settings.h"
|
||||
#include "qt_utils.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
|
@ -20,8 +20,8 @@ game_list_grid::game_list_grid(const QSize& icon_size, const QColor& icon_color,
|
|||
}
|
||||
|
||||
// font by stylesheet
|
||||
QFont font = gui::get_Label_Font("gamegrid_font");
|
||||
QColor font_color = gui::get_Label_Color("gamegrid_font");
|
||||
QFont font = gui::utils::get_label_font("gamegrid_font");
|
||||
QColor font_color = gui::utils::get_label_color("gamegrid_font");
|
||||
|
||||
grid_item_delegate = new game_list_grid_delegate(item_size, m_margin_factor, m_text_factor, font, font_color, this);
|
||||
setItemDelegate(grid_item_delegate);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "gamepads_settings_dialog.h"
|
||||
#include "pad_settings_dialog.h"
|
||||
#include "qt_utils.h"
|
||||
|
||||
#include "../Emu/Io/PadHandler.h"
|
||||
#include "../ds4_pad_handler.h"
|
||||
#ifdef _WIN32
|
||||
|
@ -11,6 +13,7 @@
|
|||
#include "../keyboard_pad_handler.h"
|
||||
#include "../Emu/Io/Null/NullPadHandler.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QInputDialog>
|
||||
|
@ -368,7 +371,7 @@ void gamepads_settings_dialog::ChangeInputType(int player)
|
|||
if (config_enabled)
|
||||
{
|
||||
QString s_profile_dir = qstr(PadHandlerBase::get_config_dir(cur_pad_handler->m_type));
|
||||
QStringList profiles = gui_settings::GetDirEntries(QDir(s_profile_dir), QStringList() << "*.yml");
|
||||
QStringList profiles = gui::utils::get_dir_entries(QDir(s_profile_dir), QStringList() << "*.yml");
|
||||
|
||||
if (profiles.isEmpty())
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "game_list_frame.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
|
||||
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
||||
|
@ -79,105 +78,6 @@ q_pair_list gui_settings::Var2List(const QVariant& var)
|
|||
return list;
|
||||
}
|
||||
|
||||
QIcon gui_settings::colorizedIcon(const QIcon& icon, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks, bool colorizeAll)
|
||||
{
|
||||
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);
|
||||
pixmap.fill(newColor);
|
||||
pixmap.setMask(mask);
|
||||
|
||||
// special masks for disc icon and others
|
||||
|
||||
if (useSpecialMasks)
|
||||
{
|
||||
auto saturatedColor = [](const QColor& col, float sat /* must be < 1 */)
|
||||
{
|
||||
int r = col.red() + sat * (255 - col.red());
|
||||
int g = col.green() + sat * (255 - col.green());
|
||||
int b = col.blue() + sat * (255 - col.blue());
|
||||
return QColor(r, g, b, col.alpha());
|
||||
};
|
||||
|
||||
QColor colorS1(Qt::white);
|
||||
QPixmap pixmapS1 = old_pixmap;
|
||||
QBitmap maskS1 = pixmapS1.createMaskFromColor(colorS1, Qt::MaskOutColor);
|
||||
pixmapS1.fill(colorS1);
|
||||
pixmapS1.setMask(maskS1);
|
||||
|
||||
QColor colorS2(0, 173, 246, 255);
|
||||
QPixmap pixmapS2 = old_pixmap;
|
||||
QBitmap maskS2 = pixmapS2.createMaskFromColor(colorS2, Qt::MaskOutColor);
|
||||
pixmapS2.fill(saturatedColor(newColor, 0.6f));
|
||||
pixmapS2.setMask(maskS2);
|
||||
|
||||
QColor colorS3(0, 132, 244, 255);
|
||||
QPixmap pixmapS3 = old_pixmap;
|
||||
QBitmap maskS3 = pixmapS3.createMaskFromColor(colorS3, Qt::MaskOutColor);
|
||||
pixmapS3.fill(saturatedColor(newColor, 0.3f));
|
||||
pixmapS3.setMask(maskS3);
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.drawPixmap(QPoint(0, 0), pixmapS1);
|
||||
painter.drawPixmap(QPoint(0, 0), pixmapS2);
|
||||
painter.drawPixmap(QPoint(0, 0), pixmapS3);
|
||||
painter.end();
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QImage gui_settings::GetOpaqueImageArea(const QString& path)
|
||||
{
|
||||
QImage image = QImage(path);
|
||||
|
||||
int w_min = 0;
|
||||
int w_max = image.width();
|
||||
int h_min = 0;
|
||||
int h_max = image.height();
|
||||
|
||||
for (int y = 0; y < image.height(); ++y)
|
||||
{
|
||||
QRgb *row = (QRgb*)image.scanLine(y);
|
||||
bool rowFilled = false;
|
||||
|
||||
for (int x = 0; x < image.width(); ++x)
|
||||
{
|
||||
if (qAlpha(row[x]))
|
||||
{
|
||||
rowFilled = true;
|
||||
w_min = std::max(w_min, x);
|
||||
|
||||
if (w_max > x)
|
||||
{
|
||||
w_max = x;
|
||||
x = w_min;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rowFilled)
|
||||
{
|
||||
h_max = std::min(h_max, y);
|
||||
h_min = y;
|
||||
}
|
||||
}
|
||||
|
||||
return image.copy(QRect(QPoint(w_max, h_max), QPoint(w_min, h_min)));
|
||||
}
|
||||
|
||||
void gui_settings::SetValue(const gui_save& entry, const QVariant& value)
|
||||
{
|
||||
m_settings.beginGroup(entry.key);
|
||||
|
@ -320,17 +220,6 @@ QStringList gui_settings::GetConfigEntries()
|
|||
return res;
|
||||
}
|
||||
|
||||
QStringList gui_settings::GetDirEntries(const QDir& dir, const QStringList& nameFilters)
|
||||
{
|
||||
QFileInfoList entries = dir.entryInfoList(nameFilters, QDir::Files);
|
||||
QStringList res;
|
||||
for (const QFileInfo &entry : entries)
|
||||
{
|
||||
res.append(entry.baseName());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void gui_settings::BackupSettingsToTarget(const QString& friendlyName)
|
||||
{
|
||||
QSettings target(ComputeSettingsDir() + friendlyName + ".ini", QSettings::Format::IniFormat);
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#include <QVariant>
|
||||
#include <QSize>
|
||||
#include <QColor>
|
||||
#include <QBitmap>
|
||||
#include <QLabel>
|
||||
|
||||
struct gui_save
|
||||
{
|
||||
|
@ -72,22 +70,6 @@ namespace gui
|
|||
return gl_max_slider_pos * current_delta / size_delta;
|
||||
};
|
||||
|
||||
inline QColor get_Label_Color(const QString& objectName, QPalette::ColorRole colorRole = QPalette::Foreground)
|
||||
{
|
||||
QLabel dummy_color;
|
||||
dummy_color.setObjectName(objectName);
|
||||
dummy_color.ensurePolished();
|
||||
return dummy_color.palette().color(colorRole);
|
||||
};
|
||||
|
||||
inline QFont get_Label_Font(const QString& objectName)
|
||||
{
|
||||
QLabel dummy_font;
|
||||
dummy_font.setObjectName(objectName);
|
||||
dummy_font.ensurePolished();
|
||||
return dummy_font.font();
|
||||
};
|
||||
|
||||
inline QString get_Single_Line(const QString& multi_line_string)
|
||||
{
|
||||
QString single_line_string = multi_line_string;
|
||||
|
@ -222,22 +204,10 @@ public:
|
|||
bool GetGamelistColVisibility(int col);
|
||||
QColor GetCustomColor(int col);
|
||||
QStringList GetConfigEntries();
|
||||
static QStringList GetDirEntries(const QDir& dir, const QStringList& nameFilters);
|
||||
QString GetCurrentStylesheetPath();
|
||||
QStringList GetStylesheetEntries();
|
||||
QStringList GetGameListCategoryFilters();
|
||||
|
||||
/**
|
||||
Creates a custom colored QIcon based on another QIcon
|
||||
@param icon the icon to colorize
|
||||
@param oldColor the current color of icon
|
||||
@param newColor the desired color for the new 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, bool colorizeAll = false);
|
||||
static QPixmap colorizedPixmap(const QPixmap& old_pixmap, const QColor& oldColor, const QColor& newColor, bool useSpecialMasks = false, bool colorizeAll = false);
|
||||
static QImage GetOpaqueImageArea(const QString& path);
|
||||
|
||||
public Q_SLOTS:
|
||||
void Reset(bool removeMeta = false);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "log_frame.h"
|
||||
#include "qt_utils.h"
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "rpcs3_version.h"
|
||||
|
@ -267,7 +268,7 @@ void log_frame::CreateAndConnectActions()
|
|||
menu->exec(mapToGlobal(pos));
|
||||
});
|
||||
|
||||
connect(m_tabWidget, &QTabWidget::currentChanged, [this](int index)
|
||||
connect(m_tabWidget, &QTabWidget::currentChanged, [this](int/* index*/)
|
||||
{
|
||||
if (m_find_dialog)
|
||||
m_find_dialog->close();
|
||||
|
@ -289,18 +290,18 @@ void log_frame::RepaintTextColors()
|
|||
{
|
||||
// Get text color. Do this once to prevent possible slowdown
|
||||
m_color.clear();
|
||||
m_color.append(gui::get_Label_Color("log_level_always"));
|
||||
m_color.append(gui::get_Label_Color("log_level_fatal"));
|
||||
m_color.append(gui::get_Label_Color("log_level_error"));
|
||||
m_color.append(gui::get_Label_Color("log_level_todo"));
|
||||
m_color.append(gui::get_Label_Color("log_level_success"));
|
||||
m_color.append(gui::get_Label_Color("log_level_warning"));
|
||||
m_color.append(gui::get_Label_Color("log_level_notice"));
|
||||
m_color.append(gui::get_Label_Color("log_level_trace"));
|
||||
m_color.append(gui::utils::get_label_color("log_level_always"));
|
||||
m_color.append(gui::utils::get_label_color("log_level_fatal"));
|
||||
m_color.append(gui::utils::get_label_color("log_level_error"));
|
||||
m_color.append(gui::utils::get_label_color("log_level_todo"));
|
||||
m_color.append(gui::utils::get_label_color("log_level_success"));
|
||||
m_color.append(gui::utils::get_label_color("log_level_warning"));
|
||||
m_color.append(gui::utils::get_label_color("log_level_notice"));
|
||||
m_color.append(gui::utils::get_label_color("log_level_trace"));
|
||||
|
||||
m_color_stack = gui::get_Label_Color("log_stack");
|
||||
m_color_stack = gui::utils::get_label_color("log_stack");
|
||||
|
||||
m_tty->setTextColor(gui::get_Label_Color("tty_text"));
|
||||
m_tty->setTextColor(gui::utils::get_label_color("tty_text"));
|
||||
}
|
||||
|
||||
void log_frame::UpdateUI()
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <QDesktopWidget>
|
||||
#include <QMimeData>
|
||||
|
||||
#include "qt_utils.h"
|
||||
#include "vfs_dialog.h"
|
||||
#include "save_manager_dialog.h"
|
||||
#include "trophy_manager_dialog.h"
|
||||
|
@ -604,11 +605,11 @@ void main_window::SaveWindowState()
|
|||
|
||||
void main_window::RepaintThumbnailIcons()
|
||||
{
|
||||
QColor newColor = gui::get_Label_Color("thumbnail_icon_color");
|
||||
QColor newColor = gui::utils::get_label_color("thumbnail_icon_color");
|
||||
|
||||
auto icon = [&newColor](const QString& path)
|
||||
{
|
||||
return gui_settings::colorizedIcon(QPixmap::fromImage(gui_settings::GetOpaqueImageArea(path)), gui::mw_tool_icon_color, newColor);
|
||||
return gui::utils::get_colorized_icon(QPixmap::fromImage(gui::utils::get_opaque_image_area(path)), gui::mw_tool_icon_color, newColor);
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -635,12 +636,12 @@ void main_window::RepaintToolBarIcons()
|
|||
}
|
||||
else
|
||||
{
|
||||
newColor = gui::get_Label_Color("toolbar_icon_color");
|
||||
newColor = gui::utils::get_label_color("toolbar_icon_color");
|
||||
}
|
||||
|
||||
auto icon = [&newColor](const QString& path)
|
||||
{
|
||||
return gui_settings::colorizedIcon(QIcon(path), gui::mw_tool_icon_color, newColor);
|
||||
return gui::utils::get_colorized_icon(QIcon(path), gui::mw_tool_icon_color, newColor);
|
||||
};
|
||||
|
||||
m_icon_play = icon(":/Icons/play.png");
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QAction>
|
||||
#include <QPainter>
|
||||
|
||||
#include "qt_utils.h"
|
||||
#include "pad_settings_dialog.h"
|
||||
#include "ui_pad_settings_dialog.h"
|
||||
|
||||
|
@ -281,10 +282,8 @@ pad_settings_dialog::pad_settings_dialog(const std::string& device, const std::s
|
|||
|
||||
UpdateLabel();
|
||||
|
||||
gui_settings settings(this);
|
||||
|
||||
// repaint and resize controller image
|
||||
ui->l_controller->setPixmap(settings.colorizedPixmap(*ui->l_controller->pixmap(), QColor(), gui::get_Label_Color("l_controller"), false, true));
|
||||
ui->l_controller->setPixmap(gui::utils::get_colorized_pixmap(*ui->l_controller->pixmap(), QColor(), gui::utils::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());
|
||||
|
||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QDialog>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <QButtonGroup>
|
||||
|
||||
#include "keyboard_pad_handler.h"
|
||||
#include "Utilities/types.h"
|
||||
|
@ -12,7 +13,6 @@
|
|||
#include "Emu/Io/PadHandler.h"
|
||||
#include "stdafx.h"
|
||||
#include "Emu/System.h"
|
||||
#include "gui_settings.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "xinput_pad_handler.h"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
#include "qt_utils.h"
|
||||
#include <QApplication>
|
||||
#include <QBitmap>
|
||||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
|
||||
namespace gui
|
||||
|
@ -33,5 +35,125 @@ namespace gui
|
|||
|
||||
return QRect(frame_x, frame_y, width, height);
|
||||
}
|
||||
|
||||
QPixmap get_colorized_pixmap(const QPixmap& old_pixmap, const QColor& old_color, const QColor& new_color, bool use_special_masks, bool colorize_all)
|
||||
{
|
||||
QPixmap pixmap = old_pixmap;
|
||||
|
||||
if (colorize_all)
|
||||
{
|
||||
QBitmap mask = pixmap.createMaskFromColor(Qt::transparent, Qt::MaskInColor);
|
||||
pixmap.fill(new_color);
|
||||
pixmap.setMask(mask);
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QBitmap mask = pixmap.createMaskFromColor(old_color, Qt::MaskOutColor);
|
||||
pixmap.fill(new_color);
|
||||
pixmap.setMask(mask);
|
||||
|
||||
// special masks for disc icon and others
|
||||
if (use_special_masks)
|
||||
{
|
||||
// Example usage for an icon with multiple shades of the same color
|
||||
|
||||
//auto saturatedColor = [](const QColor& col, float sat /* must be < 1 */)
|
||||
//{
|
||||
// int r = col.red() + sat * (255 - col.red());
|
||||
// int g = col.green() + sat * (255 - col.green());
|
||||
// int b = col.blue() + sat * (255 - col.blue());
|
||||
// return QColor(r, g, b, col.alpha());
|
||||
//};
|
||||
|
||||
//QColor test_color(0, 173, 246, 255);
|
||||
//QPixmap test_pixmap = old_pixmap;
|
||||
//QBitmap test_mask = test_pixmap.createMaskFromColor(test_color, Qt::MaskOutColor);
|
||||
//test_pixmap.fill(saturatedColor(new_color, 0.6f));
|
||||
//test_pixmap.setMask(test_mask);
|
||||
|
||||
QColor white_color(Qt::white);
|
||||
QPixmap white_pixmap = old_pixmap;
|
||||
QBitmap white_mask = white_pixmap.createMaskFromColor(white_color, Qt::MaskOutColor);
|
||||
white_pixmap.fill(white_color);
|
||||
white_pixmap.setMask(white_mask);
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.drawPixmap(QPoint(0, 0), white_pixmap);
|
||||
//painter.drawPixmap(QPoint(0, 0), test_pixmap);
|
||||
painter.end();
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QIcon get_colorized_icon(const QIcon& old_icon, const QColor& old_color, const QColor& new_color, bool use_special_masks, bool colorize_all)
|
||||
{
|
||||
return QIcon(get_colorized_pixmap(old_icon.pixmap(old_icon.availableSizes().at(0)), old_color, new_color, use_special_masks, colorize_all));
|
||||
}
|
||||
|
||||
QStringList get_dir_entries(const QDir& dir, const QStringList& name_filters)
|
||||
{
|
||||
QFileInfoList entries = dir.entryInfoList(name_filters, QDir::Files);
|
||||
QStringList res;
|
||||
for (const QFileInfo &entry : entries)
|
||||
{
|
||||
res.append(entry.baseName());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
QColor get_label_color(const QString& object_name, QPalette::ColorRole color_role)
|
||||
{
|
||||
QLabel dummy_color;
|
||||
dummy_color.setObjectName(object_name);
|
||||
dummy_color.ensurePolished();
|
||||
return dummy_color.palette().color(color_role);
|
||||
};
|
||||
|
||||
QFont get_label_font(const QString& object_name)
|
||||
{
|
||||
QLabel dummy_font;
|
||||
dummy_font.setObjectName(object_name);
|
||||
dummy_font.ensurePolished();
|
||||
return dummy_font.font();
|
||||
};
|
||||
|
||||
QImage get_opaque_image_area(const QString& path)
|
||||
{
|
||||
QImage image = QImage(path);
|
||||
|
||||
int w_min = 0;
|
||||
int w_max = image.width();
|
||||
int h_min = 0;
|
||||
int h_max = image.height();
|
||||
|
||||
for (int y = 0; y < image.height(); ++y)
|
||||
{
|
||||
QRgb *row = (QRgb*)image.scanLine(y);
|
||||
bool row_filled = false;
|
||||
|
||||
for (int x = 0; x < image.width(); ++x)
|
||||
{
|
||||
if (qAlpha(row[x]))
|
||||
{
|
||||
row_filled = true;
|
||||
w_min = std::max(w_min, x);
|
||||
|
||||
if (w_max > x)
|
||||
{
|
||||
w_max = x;
|
||||
x = w_min;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (row_filled)
|
||||
{
|
||||
h_max = std::min(h_max, y);
|
||||
h_min = y;
|
||||
}
|
||||
}
|
||||
|
||||
return image.copy(QRect(QPoint(w_max, h_max), QPoint(w_min, h_min)));
|
||||
}
|
||||
} // utils
|
||||
} // gui
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
#include <QtCore>
|
||||
#include <QFont>
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
|
||||
namespace gui
|
||||
{
|
||||
|
@ -10,5 +13,27 @@ namespace gui
|
|||
// Creates a frame geometry rectangle with given width height that's centered inside the origin,
|
||||
// while still considering screen boundaries.
|
||||
QRect create_centered_window_geometry(const QRect& origin, s32 width, s32 height);
|
||||
|
||||
// Returns a custom colored QPixmap based on another QPixmap.
|
||||
// use colorize_all to repaint every opaque pixel with the chosen color
|
||||
// use_special_masks is only used for pixmaps with multiple predefined colors
|
||||
QPixmap get_colorized_pixmap(const QPixmap& old_pixmap, const QColor& old_color, const QColor& new_color, bool use_special_masks = false, bool colorize_all = false);
|
||||
|
||||
// Returns a custom colored QIcon based on another QIcon.
|
||||
// use colorize_all to repaint every opaque pixel with the chosen color
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
|
||||
// Returns the color specified by its color_role for the QLabels with object_name
|
||||
QColor get_label_color(const QString& object_name, QPalette::ColorRole color_role = QPalette::Foreground);
|
||||
|
||||
// Returns the font of the QLabels with object_name
|
||||
QFont get_label_font(const QString& object_name);
|
||||
|
||||
// Returns the part of the image loaded from path that is inside the bounding box of its opaque areas
|
||||
QImage get_opaque_image_area(const QString& path);
|
||||
} // utils
|
||||
} // gui
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QInputDialog>
|
||||
|
@ -13,8 +12,8 @@
|
|||
#include <QDesktopWidget>
|
||||
#include <QTimer>
|
||||
|
||||
#include "qt_utils.h"
|
||||
#include "settings_dialog.h"
|
||||
|
||||
#include "ui_settings_dialog.h"
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -756,7 +755,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
|||
}
|
||||
else
|
||||
{
|
||||
button->setIcon(gui_settings::colorizedIcon(icon, iconColor, color));
|
||||
button->setIcon(gui::utils::get_colorized_icon(icon, iconColor, color));
|
||||
}
|
||||
button->setText("");
|
||||
button->setStyleSheet(styleSheet().append("text-align:left;"));
|
||||
|
@ -857,7 +856,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
|
|||
xgui_settings->SetCustomColor(i, dlg.customColor(i));
|
||||
}
|
||||
xgui_settings->SetValue(color, dlg.selectedColor());
|
||||
button->setIcon(gui_settings::colorizedIcon(button->icon(), oldColor, dlg.selectedColor(), true));
|
||||
button->setIcon(gui::utils::get_colorized_icon(button->icon(), oldColor, dlg.selectedColor(), true));
|
||||
Q_EMIT GuiRepaintRequest();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "Emu/GameInfo.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QTabWidget>
|
||||
|
||||
#include <memory>
|
||||
|
|
Loading…
Add table
Reference in a new issue