refactor closeTab

This commit is contained in:
RickyRister 2025-01-11 22:06:01 -08:00
parent 3a4ec1062b
commit 2a62b8c6ef
2 changed files with 4 additions and 12 deletions

View file

@ -339,19 +339,12 @@ void TabSupervisor::updatePingTime(int value, int max)
setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
}
void TabSupervisor::closeButtonPressed()
{
Tab *tab = static_cast<Tab *>(static_cast<CloseButton *>(sender())->property("tab").value<QObject *>());
tab->closeRequest();
}
void TabSupervisor::addCloseButtonToTab(Tab *tab, int tabIndex)
{
QTabBar::ButtonPosition closeSide =
(QTabBar::ButtonPosition)tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tabBar());
CloseButton *closeButton = new CloseButton;
connect(closeButton, &CloseButton::clicked, this, &TabSupervisor::closeButtonPressed);
closeButton->setProperty("tab", QVariant::fromValue((QObject *)tab));
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::closeRequest);
tabBar()->setTabButton(tabIndex, closeSide, closeButton);
}

View file

@ -135,7 +135,6 @@ public slots:
void openReplay(GameReplay *replay);
void maximizeMainWindow();
private slots:
void closeButtonPressed();
void updateCurrent(int index);
void updatePingTime(int value, int max);
void gameJoined(const Event_GameJoined &event);