mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-16 23:42:15 -07:00
Home tab to replace generic deck editor on startup (#6114)
This commit is contained in:
parent
22c8268f02
commit
93c15c8151
26 changed files with 751 additions and 8 deletions
14
cockatrice/src/client/tabs/tab_home.cpp
Normal file
14
cockatrice/src/client/tabs/tab_home.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "tab_home.h"
|
||||
|
||||
#include <QGroupBox>
|
||||
#include <QPushButton>
|
||||
|
||||
TabHome::TabHome(TabSupervisor *_tabSupervisor, AbstractClient *_client) : Tab(_tabSupervisor), client(_client)
|
||||
{
|
||||
homeWidget = new HomeWidget(this, tabSupervisor);
|
||||
setCentralWidget(homeWidget);
|
||||
}
|
||||
|
||||
void TabHome::retranslateUi()
|
||||
{
|
||||
}
|
||||
29
cockatrice/src/client/tabs/tab_home.h
Normal file
29
cockatrice/src/client/tabs/tab_home.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef TAB_HOME_H
|
||||
#define TAB_HOME_H
|
||||
|
||||
#include "../../server/abstract_client.h"
|
||||
#include "../ui/widgets/general/home_widget.h"
|
||||
#include "tab.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <qgroupbox.h>
|
||||
|
||||
class AbstractClient;
|
||||
|
||||
class TabHome : public Tab
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
AbstractClient *client;
|
||||
HomeWidget *homeWidget;
|
||||
|
||||
public:
|
||||
TabHome(TabSupervisor *_tabSupervisor, AbstractClient *_client);
|
||||
void retranslateUi() override;
|
||||
QString getTabText() const override
|
||||
{
|
||||
return tr("Home");
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TAB_HOME_H
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
#include "tab_deck_editor.h"
|
||||
#include "tab_deck_storage.h"
|
||||
#include "tab_game.h"
|
||||
#include "tab_home.h"
|
||||
#include "tab_logs.h"
|
||||
#include "tab_message.h"
|
||||
#include "tab_replays.h"
|
||||
|
|
@ -312,7 +313,9 @@ static void checkAndTrigger(QAction *checkableAction, bool checked)
|
|||
*/
|
||||
void TabSupervisor::initStartupTabs()
|
||||
{
|
||||
auto homeTab = addHomeTab();
|
||||
addDeckEditorTab(nullptr);
|
||||
setCurrentWidget(homeTab);
|
||||
|
||||
if (SettingsCache::instance().getTabVisualDeckStorageOpen()) {
|
||||
openTabVisualDeckStorage();
|
||||
|
|
@ -501,6 +504,8 @@ void TabSupervisor::actTabVisualDeckStorage(bool checked)
|
|||
if (checked && !tabVisualDeckStorage) {
|
||||
openTabVisualDeckStorage();
|
||||
setCurrentWidget(tabVisualDeckStorage);
|
||||
} else if (checked && tabVisualDeckStorage) {
|
||||
setCurrentWidget(tabVisualDeckStorage);
|
||||
} else if (!checked && tabVisualDeckStorage) {
|
||||
tabVisualDeckStorage->closeRequest();
|
||||
}
|
||||
|
|
@ -735,6 +740,17 @@ void TabSupervisor::roomLeft(TabRoom *tab)
|
|||
removeTab(indexOf(tab));
|
||||
}
|
||||
|
||||
void TabSupervisor::switchToFirstAvailableNetworkTab()
|
||||
{
|
||||
if (!roomTabs.isEmpty()) {
|
||||
setCurrentWidget(roomTabs.first());
|
||||
} else if (tabServer) {
|
||||
setCurrentWidget(tabServer);
|
||||
} else {
|
||||
openTabServer();
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::openReplay(GameReplay *replay)
|
||||
{
|
||||
auto *replayTab = new TabGame(this, replay);
|
||||
|
|
@ -796,6 +812,14 @@ void TabSupervisor::talkLeft(TabMessage *tab)
|
|||
removeTab(indexOf(tab));
|
||||
}
|
||||
|
||||
TabHome *TabSupervisor::addHomeTab()
|
||||
{
|
||||
auto *tab = new TabHome(this, client);
|
||||
myAddTab(tab);
|
||||
setCurrentWidget(tab);
|
||||
return tab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new deck editor tab and loads the deck into it.
|
||||
* Creates either a classic or visual deck editor tab depending on settings
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class AbstractClient;
|
|||
class Tab;
|
||||
class TabServer;
|
||||
class TabRoom;
|
||||
class TabHome;
|
||||
class TabGame;
|
||||
class TabDeckStorage;
|
||||
class TabReplays;
|
||||
|
|
@ -167,15 +168,16 @@ public slots:
|
|||
TabEdhRecMain *addEdhrecMainTab();
|
||||
TabEdhRec *addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander = false);
|
||||
void openReplay(GameReplay *replay);
|
||||
void switchToFirstAvailableNetworkTab();
|
||||
void maximizeMainWindow();
|
||||
void actTabVisualDeckStorage(bool checked);
|
||||
void actTabReplays(bool checked);
|
||||
private slots:
|
||||
void refreshShortcuts();
|
||||
|
||||
void actTabVisualDeckStorage(bool checked);
|
||||
void actTabServer(bool checked);
|
||||
void actTabAccount(bool checked);
|
||||
void actTabDeckStorage(bool checked);
|
||||
void actTabReplays(bool checked);
|
||||
void actTabAdmin(bool checked);
|
||||
void actTabLog(bool checked);
|
||||
|
||||
|
|
@ -199,6 +201,7 @@ private slots:
|
|||
void processUserLeft(const QString &userName);
|
||||
void processUserJoined(const ServerInfo_User &userInfo);
|
||||
void talkLeft(TabMessage *tab);
|
||||
TabHome *addHomeTab();
|
||||
void deckEditorClosed(AbstractTabDeckEditor *tab);
|
||||
void tabUserEvent(bool globalEvent);
|
||||
void updateTabText(Tab *tab, const QString &newTabText);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue