mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
refactor closeTab
This commit is contained in:
parent
3a4ec1062b
commit
2a62b8c6ef
2 changed files with 4 additions and 12 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue