Qt: handler zero-width columns in gamelist

This commit is contained in:
Megamouse 2018-01-14 17:56:37 +01:00 committed by Nekotekina
parent 15d0bdb7cf
commit 14ddeb07a5

View file

@ -278,14 +278,15 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std:
{
m_columnActs[col]->setCheckable(true);
connect(m_columnActs[col], &QAction::triggered, [this, col](bool val)
connect(m_columnActs[col], &QAction::triggered, [this, col](bool checked)
{
if (!val) // be sure to have at least one column left so you can call the context menu at all time
if (!checked) // be sure to have at least one column left so you can call the context menu at all time
{
int c = 0;
for (int i = 0; i < m_columnActs.count(); ++i)
{
if (xgui_settings->GetGamelistColVisibility(i)) { if (++c > 1) { break; } }
if (xgui_settings->GetGamelistColVisibility(i) && ++c > 1)
break;
}
if (c < 2)
{
@ -293,8 +294,14 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std:
return;
}
}
m_gameList->setColumnHidden(col, !val); // Negate because it's a set col hidden and we have menu say show.
xgui_settings->SetGamelistColVisibility(col, val);
m_gameList->setColumnHidden(col, !checked); // Negate because it's a set col hidden and we have menu say show.
xgui_settings->SetGamelistColVisibility(col, checked);
if (checked) // handle hidden columns that have zero width after showing them (stuck between others)
{
if (m_gameList->columnWidth(col) <= m_gameList->horizontalHeader()->minimumSectionSize())
m_gameList->setColumnWidth(col, m_gameList->horizontalHeader()->minimumSectionSize());
}
});
}
}