mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
Always set TabSupervisor as parent in Tab subclasses (#5449)
* refactor closeTab * always set tab parent to tabSupervisor * set tabSupervisor parent * use close instead of deleteLater * be more clear about overloads
This commit is contained in:
parent
3a4ec1062b
commit
a6fc88c79a
18 changed files with 25 additions and 41 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] { tab->closeRequest(); });
|
||||
tabBar()->setTabButton(tabIndex, closeSide, closeButton);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue