Hide the tab bar if only one (own deck) is visible.

Took 9 minutes
This commit is contained in:
Lukas Brübach 2025-08-13 21:33:14 +02:00
parent 1839c3d003
commit 6435ccc5b5
2 changed files with 13 additions and 0 deletions

View file

@ -12,6 +12,7 @@ TabbedDeckViewContainer::TabbedDeckViewContainer(int _playerId, TabGame *parent)
playerDeckView = new DeckViewContainer(playerId, parentGame); playerDeckView = new DeckViewContainer(playerId, parentGame);
int playerTabIndex = addTab(playerDeckView, "Your Deck"); int playerTabIndex = addTab(playerDeckView, "Your Deck");
tabBar()->setTabButton(playerTabIndex, QTabBar::RightSide, nullptr); tabBar()->setTabButton(playerTabIndex, QTabBar::RightSide, nullptr);
updateTabBarVisibility();
} }
void TabbedDeckViewContainer::addOpponentDeckView(const DeckList &opponentDeck, int opponentId, QString opponentName) void TabbedDeckViewContainer::addOpponentDeckView(const DeckList &opponentDeck, int opponentId, QString opponentName)
@ -26,6 +27,7 @@ void TabbedDeckViewContainer::addOpponentDeckView(const DeckList &opponentDeck,
opponentDeckViews.insert(opponentId, opponentDeckView); opponentDeckViews.insert(opponentId, opponentDeckView);
} }
updateTabBarVisibility();
} }
void TabbedDeckViewContainer::closeTab(int index) void TabbedDeckViewContainer::closeTab(int index)
@ -49,4 +51,14 @@ void TabbedDeckViewContainer::closeTab(int index)
removeTab(index); removeTab(index);
widgetToClose->deleteLater(); widgetToClose->deleteLater();
updateTabBarVisibility();
}
void TabbedDeckViewContainer::updateTabBarVisibility()
{
if (tabBar()->count() <= 1) {
tabBar()->hide();
} else {
tabBar()->show();
}
} }

View file

@ -11,6 +11,7 @@ class TabbedDeckViewContainer : public QTabWidget
public: public:
explicit TabbedDeckViewContainer(int _playerId, TabGame *parent); explicit TabbedDeckViewContainer(int _playerId, TabGame *parent);
void closeTab(int index); void closeTab(int index);
void updateTabBarVisibility();
void addOpponentDeckView(const DeckList &opponentDeck, int opponentId, QString opponentName); void addOpponentDeckView(const DeckList &opponentDeck, int opponentId, QString opponentName);
int playerId; int playerId;
TabGame *parentGame; TabGame *parentGame;