mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 07:51:28 +12:00
Qt: Restrict trophy manager combo box size
This commit is contained in:
parent
05efa7d957
commit
4c03348e60
3 changed files with 29 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "qt_utils.h"
|
#include "qt_utils.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
|
#include <QFontMetrics>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
||||||
|
@ -156,6 +157,27 @@ namespace gui
|
||||||
return image.copy(QRect(QPoint(w_max, h_max), QPoint(w_min, h_min)));
|
return image.copy(QRect(QPoint(w_max, h_max), QPoint(w_min, h_min)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// taken from https://stackoverflow.com/a/30818424/8353754
|
||||||
|
// because size policies won't work as expected (see similar bugs in Qt bugtracker)
|
||||||
|
void resize_combo_box_view(QComboBox* combo)
|
||||||
|
{
|
||||||
|
int max_width = 0;
|
||||||
|
QFontMetrics font_metrics(combo->font());
|
||||||
|
|
||||||
|
for (int i = 0; i < combo->count(); ++i)
|
||||||
|
{
|
||||||
|
max_width = std::max(max_width, font_metrics.width(combo->itemText(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (combo->view()->minimumWidth() < max_width)
|
||||||
|
{
|
||||||
|
// add scrollbar width and margin
|
||||||
|
max_width += combo->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
|
||||||
|
max_width += combo->view()->autoScrollMargin();
|
||||||
|
combo->view()->setMinimumWidth(max_width);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void update_table_item_count(QTableWidget* table)
|
void update_table_item_count(QTableWidget* table)
|
||||||
{
|
{
|
||||||
if (!table)
|
if (!table)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -38,6 +39,9 @@ namespace gui
|
||||||
// Returns the part of the image loaded from path that is inside the bounding box of its opaque areas
|
// 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);
|
QImage get_opaque_image_area(const QString& path);
|
||||||
|
|
||||||
|
// Workaround: resize the dropdown combobox items
|
||||||
|
void resize_combo_box_view(QComboBox* combo);
|
||||||
|
|
||||||
// Recalculates a table's item count based on the available visible space and fills it with empty items
|
// Recalculates a table's item count based on the available visible space and fills it with empty items
|
||||||
void update_table_item_count(QTableWidget* table);
|
void update_table_item_count(QTableWidget* table);
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
|
||||||
|
|
||||||
// Game chooser combo box
|
// Game chooser combo box
|
||||||
m_game_combo = new QComboBox();
|
m_game_combo = new QComboBox();
|
||||||
|
m_game_combo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||||
|
|
||||||
// Game progression label
|
// Game progression label
|
||||||
m_game_progress = new QLabel(tr("Progress: %1% (%2/%3)").arg(0).arg(0).arg(0));
|
m_game_progress = new QLabel(tr("Progress: %1% (%2/%3)").arg(0).arg(0).arg(0));
|
||||||
|
@ -148,6 +149,8 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
|
||||||
m_game_table->setItem(i, GameColumns::GameProgress, new custom_table_widget_item(progress, Qt::UserRole, percentage));
|
m_game_table->setItem(i, GameColumns::GameProgress, new custom_table_widget_item(progress, Qt::UserRole, percentage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gui::utils::resize_combo_box_view(m_game_combo);
|
||||||
|
|
||||||
m_game_table->setSortingEnabled(true); // Enable sorting only after using setItem calls
|
m_game_table->setSortingEnabled(true); // Enable sorting only after using setItem calls
|
||||||
|
|
||||||
// Checkboxes to control dialog
|
// Checkboxes to control dialog
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue