Project

General

Profile

Bug #1530 ยป 1530.patch

Dean Brown, 06/22/2025 03:32 AM

View differences:

client/gui-qt/shortcuts.cpp
**************************************************************************/
void fc_shortcuts_dialog::init()
{
fc_shortcut *sc;
QPushButton *but;
QScrollArea *scroll;
QSize size;
QString desc;
QWidget *widget;
shortcut_id id;
widget = new QWidget(this);
scroll = new QScrollArea(this);
scroll->setWidgetResizable(true);
scroll_layout = new QVBoxLayout;
populate_scroll_layout();
main_layout = new QVBoxLayout;
foreach (sc, fc_shortcuts::sc()->hash) {
id = fc_shortcuts::sc()->get_id(sc);
desc = fc_shortcuts::sc()->get_desc(id);
add_option(sc);
}
widget->setProperty("doomed", true);
widget->setLayout(scroll_layout);
scroll->setWidget(widget);
......
}
/**********************************************************************//**
Adds shortcut option for dialog
Adds all the shortcut options to the dialog's scroll_layout
**************************************************************************/
void fc_shortcuts_dialog::populate_scroll_layout()
{
fc_shortcut *sc;
shortcut_id id;
QString desc;
foreach (sc, fc_shortcuts::sc()->hash) {
id = fc_shortcuts::sc()->get_id(sc);
desc = fc_shortcuts::sc()->get_desc(id);
add_option(sc);
}
}
/**********************************************************************//**
Adds a shortcut option to the dialog's scroll_layout
**************************************************************************/
void fc_shortcuts_dialog::add_option(fc_shortcut *sc)
{
......
**************************************************************************/
void fc_shortcuts_dialog::refresh()
{
QLayout *layout;
QLayoutItem *item;
QLayoutItem *box_layout_item;
QLayoutItem *row_layout_item;
QWidget *widget;
layout = main_layout;
while ((item = layout->takeAt(0))) {
if (item->layout() != nullptr) {
// Nothing
} else if ((widget = item->widget()) != nullptr) {
widget->hide();
delete widget;
} else {
delete item;
QLayout *box_layout; // corresponds to one of the hb's in add_option()
// clear out the scroll_layout
while ((row_layout_item = scroll_layout->takeAt(0)) != nullptr) {
box_layout = row_layout_item->layout();
while ((box_layout_item = box_layout->takeAt(0)) != nullptr) {
widget = box_layout_item->widget();
if (widget != nullptr) { // this test may not be needed
delete widget;
}
delete box_layout_item;
}
delete row_layout_item;
}
delete main_layout;
init();
// re-populate the scroll_layout
populate_scroll_layout();
}
/**********************************************************************//**
client/gui-qt/shortcuts.h
QMap<shortcut_id, fc_shortcut*> *hashcopy;
void add_option(fc_shortcut *sc);
void init();
void populate_scroll_layout();
void refresh();
public:
fc_shortcuts_dialog(QWidget *parent = 0);
    (1-1/1)