move addCloseButtonToTab up

This commit is contained in:
RickyRister 2025-01-14 00:36:43 -08:00 committed by ZeldaZach
parent 953bb500c5
commit 68ffa1f7f8
No known key found for this signature in database

View file

@ -295,6 +295,15 @@ int TabSupervisor::myAddTab(Tab *tab)
return idx; return idx;
} }
void TabSupervisor::addCloseButtonToTab(Tab *tab, int tabIndex)
{
auto closeSide = static_cast<QTabBar::ButtonPosition>(
tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, tabBar()));
auto *closeButton = new CloseButton(tab);
connect(closeButton, &CloseButton::clicked, tab, [tab] { tab->closeRequest(); });
tabBar()->setTabButton(tabIndex, closeSide, closeButton);
}
/** /**
* Resets the tabs menu to the tabs that are always available * Resets the tabs menu to the tabs that are always available
*/ */
@ -535,15 +544,6 @@ void TabSupervisor::updatePingTime(int value, int max)
setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, max))); setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
} }
void TabSupervisor::addCloseButtonToTab(Tab *tab, int tabIndex)
{
auto closeSide = static_cast<QTabBar::ButtonPosition>(
tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, tabBar()));
auto *closeButton = new CloseButton(tab);
connect(closeButton, &CloseButton::clicked, tab, [tab] { tab->closeRequest(); });
tabBar()->setTabButton(tabIndex, closeSide, closeButton);
}
void TabSupervisor::gameJoined(const Event_GameJoined &event) void TabSupervisor::gameJoined(const Event_GameJoined &event)
{ {
QMap<int, QString> roomGameTypes; QMap<int, QString> roomGameTypes;