1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Improve dimensions dialog layout

This commit is contained in:
Megamouse 2024-07-20 20:45:18 +02:00
parent c021165483
commit f8a729f4b4
4 changed files with 51 additions and 41 deletions

View File

@ -395,14 +395,15 @@ minifig_creator_dialog::minifig_creator_dialog(QWidget* parent)
for (const auto& [figure, figure_name] : list_minifigs)
{
const QString name = QString::fromStdString(figure_name);
QString name = QString::fromStdString(figure_name);
combo_figlist->addItem(name, QVariant(figure));
filterlist << name;
filterlist << std::move(name);
}
combo_figlist->addItem(tr("--Unknown--"), QVariant(0xFFFF));
combo_figlist->setEditable(true);
combo_figlist->setInsertPolicy(QComboBox::NoInsert);
combo_figlist->model()->sort(0, Qt::AscendingOrder);
QCompleter* co_compl = new QCompleter(filterlist, this);
co_compl->setCaseSensitivity(Qt::CaseInsensitive);
@ -455,7 +456,7 @@ minifig_creator_dialog::minifig_creator_dialog(QWidget* parent)
return;
}
const auto found_figure = list_minifigs.find(fig_num);
if (found_figure != list_minifigs.end())
if (found_figure != list_minifigs.cend())
{
s_last_figure_path += QString::fromStdString(found_figure->second + ".bin");
}
@ -533,7 +534,7 @@ void minifig_move_dialog::add_minifig_position(QGridLayout* grid_panel, u8 index
if (figure_slots[index])
{
const auto found_figure = list_minifigs.find(figure_slots[index].value());
if (found_figure != list_minifigs.end())
if (found_figure != list_minifigs.cend())
{
vbox_panel->addWidget(new QLabel(tr(found_figure->second.c_str())));
}
@ -575,26 +576,31 @@ dimensions_dialog::dimensions_dialog(QWidget* parent)
setWindowTitle(tr("Dimensions Manager"));
setObjectName("dimensions_manager");
setAttribute(Qt::WA_DeleteOnClose);
setMinimumSize(QSize(1200, 500));
setMinimumSize(QSize(800, 200));
QVBoxLayout* vbox_panel = new QVBoxLayout();
QVBoxLayout* vbox_group = new QVBoxLayout();
QHBoxLayout* hbox_group_1 = new QHBoxLayout();
QHBoxLayout* hbox_group_2 = new QHBoxLayout();
QGroupBox* group_figures = new QGroupBox(tr("Active Dimensions Figures:"));
QGridLayout* grid_group = new QGridLayout();
add_minifig_slot(grid_group, 2, 0, 0, 0);
grid_group->addWidget(new QLabel(tr("")), 0, 1);
add_minifig_slot(grid_group, 1, 1, 0, 2);
grid_group->addWidget(new QLabel(tr("")), 0, 1);
add_minifig_slot(grid_group, 3, 2, 0, 4);
add_minifig_slot(hbox_group_1, 2, 0);
hbox_group_1->addSpacerItem(new QSpacerItem(50, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
add_minifig_slot(hbox_group_1, 1, 1);
hbox_group_1->addSpacerItem(new QSpacerItem(50, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
add_minifig_slot(hbox_group_1, 3, 2);
add_minifig_slot(grid_group, 2, 3, 1, 0);
add_minifig_slot(grid_group, 2, 4, 1, 1);
grid_group->addWidget(new QLabel(tr("")), 0, 1);
add_minifig_slot(grid_group, 3, 5, 1, 3);
add_minifig_slot(grid_group, 3, 6, 1, 4);
add_minifig_slot(hbox_group_2, 2, 3);
add_minifig_slot(hbox_group_2, 2, 4);
hbox_group_2->addSpacerItem(new QSpacerItem(50, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
add_minifig_slot(hbox_group_2, 3, 5);
add_minifig_slot(hbox_group_2, 3, 6);
group_figures->setLayout(grid_group);
vbox_group->addLayout(hbox_group_1);
vbox_group->addSpacerItem(new QSpacerItem(0, 20, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
vbox_group->addLayout(hbox_group_2);
group_figures->setLayout(vbox_group);
vbox_panel->addWidget(group_figures);
setLayout(vbox_panel);
}
@ -612,7 +618,7 @@ dimensions_dialog* dimensions_dialog::get_dlg(QWidget* parent)
return inst;
}
void dimensions_dialog::add_minifig_slot(QGridLayout* grid_group, u8 pad, u8 index, u8 row, u8 column)
void dimensions_dialog::add_minifig_slot(QHBoxLayout* layout, u8 pad, u8 index)
{
ensure(index < figure_slots.size());
@ -631,7 +637,7 @@ void dimensions_dialog::add_minifig_slot(QGridLayout* grid_group, u8 pad, u8 ind
if (figure_slots[index])
{
const auto found_figure = list_minifigs.find(figure_slots[index].value());
if (found_figure != list_minifigs.end())
if (found_figure != list_minifigs.cend())
{
m_edit_figures[index]->setText(QString::fromStdString(found_figure->second));
}
@ -674,7 +680,7 @@ void dimensions_dialog::add_minifig_slot(QGridLayout* grid_group, u8 pad, u8 ind
vbox_layout->addLayout(hbox_name_move);
vbox_layout->addLayout(hbox_actions);
grid_group->addLayout(vbox_layout, row, column);
layout->addLayout(vbox_layout);
}
void dimensions_dialog::clear_figure(u8 pad, u8 index)
@ -748,15 +754,15 @@ void dimensions_dialog::load_figure_path(u8 pad, u8 index, const QString& path)
const u32 fig_num = g_dimensionstoypad.load_figure(data, std::move(dim_file), pad, index);
figure_slots[index] = fig_num;
auto name = list_minifigs.find(fig_num);
if (name != list_minifigs.end())
const auto name = list_minifigs.find(fig_num);
if (name != list_minifigs.cend())
{
m_edit_figures[index]->setText(QString::fromStdString(name->second));
}
else
{
auto blank_name = list_tokens.find(fig_num);
if (blank_name != list_tokens.end())
const auto blank_name = list_tokens.find(fig_num);
if (blank_name != list_tokens.cend())
{
m_edit_figures[index]->setText(QString::fromStdString(blank_name->second));
}

View File

@ -58,6 +58,6 @@ protected:
std::array<QLineEdit*, 7> m_edit_figures{};
private:
void add_minifig_slot(QGridLayout* grid_group, u8 pad, u8 index, u8 row, u8 column);
void add_minifig_slot(QHBoxLayout* layout, u8 pad, u8 index);
static dimensions_dialog* inst;
};

View File

@ -420,9 +420,8 @@ figure_creator_dialog::figure_creator_dialog(QWidget* parent, u8 slot)
QStringList filterlist;
u32 first_entry = 0;
for (const auto& entry : list_figures)
for (const auto& [figure, entry] : list_figures)
{
const auto figure = entry.first;
// Only display entry if it is a piece appropriate for the slot
if ((slot == 0 &&
((figure > 0x1E8480 && figure < 0x2DC6BF) || (figure > 0x3D0900 && figure < 0x4C4B3F))) ||
@ -431,9 +430,11 @@ figure_creator_dialog::figure_creator_dialog(QWidget* parent, u8 slot)
((slot == 4 || slot == 5 || slot == 7 || slot == 8) &&
(figure > 0x2DC6C0 && figure < 0x3D08FF)))
{
const u32 qnum = (figure << 8) | entry.second.first;
combo_figlist->addItem(QString::fromStdString(entry.second.second), QVariant(qnum));
filterlist << entry.second.second.c_str();
const auto& [num, figure_name] = entry;
const u32 qnum = (figure << 8) | num;
QString name = QString::fromStdString(figure_name);
combo_figlist->addItem(name, QVariant(qnum));
filterlist << std::move(name);
if (first_entry == 0)
{
first_entry = figure;
@ -444,6 +445,7 @@ figure_creator_dialog::figure_creator_dialog(QWidget* parent, u8 slot)
combo_figlist->addItem(tr("--Unknown--"), QVariant(0xFFFFFFFF));
combo_figlist->setEditable(true);
combo_figlist->setInsertPolicy(QComboBox::NoInsert);
combo_figlist->model()->sort(0, Qt::AscendingOrder);
QCompleter* co_compl = new QCompleter(filterlist, this);
co_compl->setCaseSensitivity(Qt::CaseInsensitive);
@ -460,7 +462,7 @@ figure_creator_dialog::figure_creator_dialog(QWidget* parent, u8 slot)
QHBoxLayout* hbox_number = new QHBoxLayout();
QLabel* label_number = new QLabel(tr("Figure Number:"));
QLineEdit* edit_number = new QLineEdit(QString::fromStdString(std::to_string(first_entry)));
QLineEdit* edit_number = new QLineEdit(QString::number(first_entry));
QLabel* label_series = new QLabel(tr("Series:"));
QLineEdit* edit_series = new QLineEdit("1");
QRegularExpressionValidator* rxv = new QRegularExpressionValidator(QRegularExpression("\\d*"), this);
@ -512,7 +514,7 @@ figure_creator_dialog::figure_creator_dialog(QWidget* parent, u8 slot)
return;
}
const auto found_figure = list_figures.find(fig_num);
if (found_figure != list_figures.end())
if (found_figure != list_figures.cend())
{
s_last_figure_path += QString::fromStdString(found_figure->second.second + ".bin");
}
@ -733,7 +735,7 @@ void infinity_dialog::add_figure_slot(QVBoxLayout* vbox_group, QString name, u8
if (figure_slots[slot])
{
const auto found_figure = list_figures.find(figure_slots[slot].value());
if (found_figure != list_figures.end())
if (found_figure != list_figures.cend())
{
m_edit_figures[slot]->setText(QString::fromStdString(found_figure->second.second));
}
@ -824,8 +826,8 @@ void infinity_dialog::load_figure_path(u8 slot, const QString& path)
clear_figure(slot);
const u32 fignum = g_infinitybase.load_figure(data, std::move(inf_file), slot);
auto name = list_figures.find(fignum);
if (name != list_figures.end())
const auto name = list_figures.find(fignum);
if (name != list_figures.cend())
{
m_edit_figures[slot]->setText(QString::fromStdString(name->second.second));
}

View File

@ -540,15 +540,17 @@ skylander_creator_dialog::skylander_creator_dialog(QWidget* parent)
QComboBox* combo_skylist = new QComboBox();
QStringList filterlist;
for (const auto& entry : list_skylanders)
for (const auto& [entry, figure_name] : list_skylanders)
{
const uint qvar = (entry.first.first << 16) | entry.first.second;
combo_skylist->addItem(QString::fromStdString(entry.second), QVariant(qvar));
filterlist << entry.second.c_str();
const uint qvar = (entry.first << 16) | entry.second;
QString name = QString::fromStdString(figure_name);
combo_skylist->addItem(name, QVariant(qvar));
filterlist << std::move(name);
}
combo_skylist->addItem(tr("--Unknown--"), QVariant(0xFFFFFFFF));
combo_skylist->setEditable(true);
combo_skylist->setInsertPolicy(QComboBox::NoInsert);
combo_skylist->model()->sort(0, Qt::AscendingOrder);
QCompleter* co_compl = new QCompleter(filterlist, this);
co_compl->setCaseSensitivity(Qt::CaseInsensitive);
@ -618,7 +620,7 @@ skylander_creator_dialog::skylander_creator_dialog(QWidget* parent)
QString predef_name = last_skylander_path;
const auto found_sky = list_skylanders.find(std::make_pair(sky_id, sky_var));
if (found_sky != list_skylanders.end())
if (found_sky != list_skylanders.cend())
{
predef_name += QString::fromStdString(found_sky->second + ".sky");
}
@ -815,7 +817,7 @@ void skylander_dialog::update_edits()
{
const auto& [portal_slot, sky_id, sky_var] = sd.value();
const auto found_sky = list_skylanders.find(std::make_pair(sky_id, sky_var));
if (found_sky != list_skylanders.end())
if (found_sky != list_skylanders.cend())
{
display_string = QString::fromStdString(found_sky->second);
}