mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
Home screen.
Took 2 hours 18 minutes Took 9 seconds Took 23 seconds
This commit is contained in:
parent
9601a1fa4e
commit
aa5a6222fd
9 changed files with 285 additions and 2 deletions
|
|
@ -50,6 +50,7 @@ set(cockatrice_SOURCES
|
|||
src/client/tabs/tab_deck_editor.cpp
|
||||
src/client/tabs/tab_deck_storage.cpp
|
||||
src/client/tabs/tab_game.cpp
|
||||
src/client/tabs/tab_home.cpp
|
||||
src/client/tabs/tab_logs.cpp
|
||||
src/client/tabs/tab_message.cpp
|
||||
src/client/tabs/tab_replays.cpp
|
||||
|
|
@ -100,6 +101,8 @@ set(cockatrice_SOURCES
|
|||
src/client/ui/widgets/deck_editor/deck_editor_deck_dock_widget.cpp
|
||||
src/client/ui/widgets/deck_editor/deck_editor_filter_dock_widget.cpp
|
||||
src/client/ui/widgets/deck_editor/deck_editor_printing_selector_dock_widget.cpp
|
||||
src/client/ui/widgets/general/home_styled_button.cpp
|
||||
src/client/ui/widgets/general/home_widget.cpp
|
||||
src/client/ui/widgets/general/display/banner_widget.cpp
|
||||
src/client/ui/widgets/general/display/bar_widget.cpp
|
||||
src/client/ui/widgets/general/display/dynamic_font_size_label.cpp
|
||||
|
|
|
|||
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 "../game_logic/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();
|
||||
}
|
||||
|
|
@ -796,6 +801,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;
|
||||
|
|
@ -168,14 +169,14 @@ public slots:
|
|||
TabEdhRec *addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander = false);
|
||||
void openReplay(GameReplay *replay);
|
||||
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 +200,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);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
#include "home_styled_button.h"
|
||||
|
||||
HomeStyledButton::HomeStyledButton(const QString &text, QWidget *parent) : QPushButton(text, parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
setStyleSheet(R"(
|
||||
QPushButton {
|
||||
font-size: 16px;
|
||||
padding: 10px;
|
||||
color: black;
|
||||
border: 1px solid #0b5e2e;
|
||||
border-radius: 6px;
|
||||
background: qlineargradient(x1:0, y1:1, x2:0, y2:0,
|
||||
stop:0 #92de58, stop:1 #139740);
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: qlineargradient(x1:0, y1:1, x2:0, y2:0,
|
||||
stop:0 #aaf57a, stop:1 #1bb24e);
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
||||
stop:0 #139740, stop:1 #0a4d23);
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// Created by ascor on 6/15/25.
|
||||
//
|
||||
|
||||
#ifndef HOME_STYLED_BUTTON_H
|
||||
#define HOME_STYLED_BUTTON_H
|
||||
#include <QPushButton>
|
||||
|
||||
class HomeStyledButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HomeStyledButton(const QString &text, QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // HOME_STYLED_BUTTON_H
|
||||
150
cockatrice/src/client/ui/widgets/general/home_widget.cpp
Normal file
150
cockatrice/src/client/ui/widgets/general/home_widget.cpp
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
#include "home_widget.h"
|
||||
|
||||
#include "../../../tabs/tab_supervisor.h"
|
||||
#include "home_styled_button.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
HomeWidget::HomeWidget(QWidget *parent, TabSupervisor *_tabSupervisor)
|
||||
: QWidget(parent), tabSupervisor(_tabSupervisor), background("theme:backgrounds/home"), overlay("theme:cockatrice")
|
||||
{
|
||||
layout = new QGridLayout(this);
|
||||
|
||||
layout->addWidget(createSettingsButtonGroup("Settings"), 0, 0, Qt::AlignTop | Qt::AlignLeft);
|
||||
layout->addWidget(createUpdatesButtonGroup("Updates"), 0, 2, Qt::AlignTop | Qt::AlignRight);
|
||||
layout->addWidget(createNavigationButtonGroup("Navigation"), 2, 0, Qt::AlignBottom | Qt::AlignLeft);
|
||||
layout->addWidget(createPlayButtonGroup("Play"), 2, 2, Qt::AlignBottom | Qt::AlignRight);
|
||||
|
||||
layout->setRowStretch(0, 1);
|
||||
layout->setRowStretch(2, 1);
|
||||
layout->setColumnStretch(0, 1);
|
||||
layout->setColumnStretch(2, 1);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
QGroupBox *HomeWidget::createSettingsButtonGroup(const QString &title)
|
||||
{
|
||||
QGroupBox *box = new QGroupBox(title);
|
||||
box->setStyleSheet(R"(
|
||||
QGroupBox {
|
||||
font-size: 20px;
|
||||
color: white; /* Title text color */
|
||||
}
|
||||
|
||||
QGroupBox::title {
|
||||
color: white;
|
||||
subcontrol-origin: margin;
|
||||
subcontrol-position: top center; /* or top left / right */
|
||||
}
|
||||
)");
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setAlignment(Qt::AlignHCenter); // Center widgets horizontally
|
||||
layout->addWidget(new HomeStyledButton("Settings"));
|
||||
box->setLayout(layout);
|
||||
return box;
|
||||
}
|
||||
|
||||
QGroupBox *HomeWidget::createUpdatesButtonGroup(const QString &title)
|
||||
{
|
||||
QGroupBox *box = new QGroupBox(title);
|
||||
box->setStyleSheet(R"(
|
||||
QGroupBox {
|
||||
font-size: 20px;
|
||||
color: white; /* Title text color */
|
||||
}
|
||||
|
||||
QGroupBox::title {
|
||||
color: white;
|
||||
subcontrol-origin: margin;
|
||||
subcontrol-position: top center; /* or top left / right */
|
||||
}
|
||||
)");
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setAlignment(Qt::AlignHCenter); // Center widgets horizontally
|
||||
layout->addWidget(new HomeStyledButton("Updates"));
|
||||
box->setLayout(layout);
|
||||
return box;
|
||||
}
|
||||
|
||||
QGroupBox *HomeWidget::createNavigationButtonGroup(const QString &title)
|
||||
{
|
||||
QGroupBox *box = new QGroupBox(title);
|
||||
box->setStyleSheet(R"(
|
||||
QGroupBox {
|
||||
font-size: 20px;
|
||||
color: white; /* Title text color */
|
||||
}
|
||||
|
||||
QGroupBox::title {
|
||||
color: white;
|
||||
subcontrol-origin: margin;
|
||||
subcontrol-position: top center; /* or top left / right */
|
||||
}
|
||||
)");
|
||||
box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setAlignment(Qt::AlignHCenter); // Center widgets horizontally
|
||||
auto replaybutton = new HomeStyledButton("View Replays");
|
||||
connect(replaybutton, &QPushButton::clicked, tabSupervisor, [this] { tabSupervisor->actTabReplays(true); });
|
||||
layout->addWidget(replaybutton);
|
||||
auto edhrecButton = new HomeStyledButton("Browse EDHRec");
|
||||
connect(edhrecButton, &QPushButton::clicked, tabSupervisor, &TabSupervisor::addEdhrecMainTab);
|
||||
layout->addWidget(edhrecButton);
|
||||
auto visualDatabaseDisplayButton = new HomeStyledButton("Browse Card Database");
|
||||
connect(visualDatabaseDisplayButton, &QPushButton::clicked, tabSupervisor,
|
||||
&TabSupervisor::addVisualDatabaseDisplayTab);
|
||||
layout->addWidget(visualDatabaseDisplayButton);
|
||||
auto visualDeckStorageButton = new HomeStyledButton("Browse Decks");
|
||||
connect(visualDeckStorageButton, &QPushButton::clicked, tabSupervisor,
|
||||
[this] { tabSupervisor->actTabVisualDeckStorage(true); });
|
||||
layout->addWidget(visualDeckStorageButton);
|
||||
box->setLayout(layout);
|
||||
return box;
|
||||
}
|
||||
|
||||
QGroupBox *HomeWidget::createPlayButtonGroup(const QString &title)
|
||||
{
|
||||
QGroupBox *box = new QGroupBox(title);
|
||||
box->setStyleSheet(R"(
|
||||
QGroupBox {
|
||||
font-size: 20px;
|
||||
color: white; /* Title text color */
|
||||
}
|
||||
|
||||
QGroupBox::title {
|
||||
color: white;
|
||||
subcontrol-origin: margin;
|
||||
subcontrol-position: top center; /* or top left / right */
|
||||
}
|
||||
)");
|
||||
box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setAlignment(Qt::AlignHCenter); // Center widgets horizontally
|
||||
|
||||
auto connectButton = new HomeStyledButton("Connect");
|
||||
layout->addWidget(connectButton, 1); // stretch factor 1
|
||||
|
||||
auto playButton = new HomeStyledButton("Play");
|
||||
layout->addWidget(playButton, 1);
|
||||
|
||||
box->setLayout(layout);
|
||||
return box;
|
||||
}
|
||||
|
||||
void HomeWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
// Draw background to fill the widget
|
||||
painter.drawPixmap(rect(), background);
|
||||
|
||||
// Draw overlay image centered
|
||||
QSize overlaySize = overlay.size();
|
||||
QPoint center((width() - overlaySize.width()) / 2, (height() - overlaySize.height()) / 2);
|
||||
painter.drawPixmap(center, overlay);
|
||||
|
||||
QWidget::paintEvent(event); // optional, depending on behavior
|
||||
}
|
||||
31
cockatrice/src/client/ui/widgets/general/home_widget.h
Normal file
31
cockatrice/src/client/ui/widgets/general/home_widget.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef HOME_WIDGET_H
|
||||
#define HOME_WIDGET_H
|
||||
#include "../../../tabs/tab_supervisor.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QWidget>
|
||||
|
||||
class HomeWidget : public QWidget
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HomeWidget(QWidget *parent, TabSupervisor *tabSupervisor);
|
||||
QGroupBox *createSettingsButtonGroup(const QString &title);
|
||||
QGroupBox *createUpdatesButtonGroup(const QString &title);
|
||||
QGroupBox *createNavigationButtonGroup(const QString &title);
|
||||
QGroupBox *createPlayButtonGroup(const QString &title);
|
||||
|
||||
public slots:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
QGridLayout *layout;
|
||||
TabSupervisor *tabSupervisor;
|
||||
QPixmap background;
|
||||
QPixmap overlay;
|
||||
};
|
||||
|
||||
#endif // HOME_WIDGET_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue