mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 10:23:02 -07:00
[DeckShare] Use the stable server client for the visual deck storage tab
This commit is contained in:
parent
bb06de724f
commit
4b870fdf06
3 changed files with 8 additions and 8 deletions
|
|
@ -672,7 +672,7 @@ void TabSupervisor::actTabVisualDeckStorage(bool checked)
|
||||||
|
|
||||||
void TabSupervisor::openTabVisualDeckStorage()
|
void TabSupervisor::openTabVisualDeckStorage()
|
||||||
{
|
{
|
||||||
tabVisualDeckStorage = new TabDeckStorageVisual(this);
|
tabVisualDeckStorage = new TabDeckStorageVisual(this, client);
|
||||||
myAddTab(tabVisualDeckStorage, aTabVisualDeckStorage);
|
myAddTab(tabVisualDeckStorage, aTabVisualDeckStorage);
|
||||||
connect(tabVisualDeckStorage, &QObject::destroyed, this, [this] {
|
connect(tabVisualDeckStorage, &QObject::destroyed, this, [this] {
|
||||||
tabVisualDeckStorage = nullptr;
|
tabVisualDeckStorage = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
#include <libcockatrice/protocol/pb/response_deck_share_create.pb.h>
|
#include <libcockatrice/protocol/pb/response_deck_share_create.pb.h>
|
||||||
#include <libcockatrice/protocol/pending_command.h>
|
#include <libcockatrice/protocol/pending_command.h>
|
||||||
|
|
||||||
TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor)
|
TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor, AbstractClient *_client)
|
||||||
: Tab(_tabSupervisor), visualDeckStorageWidget(new VisualDeckStorageWidget(this))
|
: Tab(_tabSupervisor), client(_client), visualDeckStorageWidget(new VisualDeckStorageWidget(this))
|
||||||
{
|
{
|
||||||
connect(this, &TabDeckStorageVisual::openDeckEditor, tabSupervisor, &TabSupervisor::openDeckInNewTab);
|
connect(this, &TabDeckStorageVisual::openDeckEditor, tabSupervisor, &TabSupervisor::openDeckInNewTab);
|
||||||
connect(visualDeckStorageWidget, &VisualDeckStorageWidget::deckLoadRequested, this,
|
connect(visualDeckStorageWidget, &VisualDeckStorageWidget::deckLoadRequested, this,
|
||||||
|
|
@ -35,7 +35,6 @@ TabDeckStorageVisual::TabDeckStorageVisual(TabSupervisor *_tabSupervisor)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AbstractClient *client = tabSupervisor->getClient();
|
|
||||||
connect(client, &AbstractClient::statusChanged, this, &TabDeckStorageVisual::handleConnectionChanged);
|
connect(client, &AbstractClient::statusChanged, this, &TabDeckStorageVisual::handleConnectionChanged);
|
||||||
shareDeckAvailable = (client->getStatus() == StatusLoggedIn);
|
shareDeckAvailable = (client->getStatus() == StatusLoggedIn);
|
||||||
visualDeckStorageWidget->setShareAvailable(shareDeckAvailable);
|
visualDeckStorageWidget->setShareAvailable(shareDeckAvailable);
|
||||||
|
|
@ -152,9 +151,9 @@ void TabDeckStorageVisual::actShareSelected()
|
||||||
}
|
}
|
||||||
|
|
||||||
shareBar->setCreateEnabled(false);
|
shareBar->setCreateEnabled(false);
|
||||||
PendingCommand *pend = tabSupervisor->getClient()->prepareSessionCommand(cmd);
|
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||||
connect(pend, &PendingCommand::finished, this, &TabDeckStorageVisual::shareFinished);
|
connect(pend, &PendingCommand::finished, this, &TabDeckStorageVisual::shareFinished);
|
||||||
tabSupervisor->getClient()->sendCommand(pend);
|
client->sendCommand(pend);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabDeckStorageVisual::shareFinished(const Response &response, const CommandContainer & /*commandContainer*/)
|
void TabDeckStorageVisual::shareFinished(const Response &response, const CommandContainer & /*commandContainer*/)
|
||||||
|
|
@ -175,7 +174,7 @@ void TabDeckStorageVisual::shareFinished(const Response &response, const Command
|
||||||
const QDateTime expiry = QDateTime::fromSecsSinceEpoch(resp.expires_at(), Qt::UTC);
|
const QDateTime expiry = QDateTime::fromSecsSinceEpoch(resp.expires_at(), Qt::UTC);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const QString link = DeckShareUtils::buildShareLink(tabSupervisor->getClient(), token);
|
const QString link = DeckShareUtils::buildShareLink(client, token);
|
||||||
DeckShareUtils::copyShareLinkToClipboard(link);
|
DeckShareUtils::copyShareLinkToClipboard(link);
|
||||||
|
|
||||||
showShareNotice(
|
showShareNotice(
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class TabDeckStorageVisual final : public Tab
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit TabDeckStorageVisual(TabSupervisor *_tabSupervisor);
|
explicit TabDeckStorageVisual(TabSupervisor *_tabSupervisor, AbstractClient *_client);
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
|
|
||||||
[[nodiscard]] QString getTabText() const override
|
[[nodiscard]] QString getTabText() const override
|
||||||
|
|
@ -73,6 +73,7 @@ private:
|
||||||
VisualDeckStorageWidget *visualDeckStorageWidget;
|
VisualDeckStorageWidget *visualDeckStorageWidget;
|
||||||
|
|
||||||
ShareBarWidget *shareBar;
|
ShareBarWidget *shareBar;
|
||||||
|
AbstractClient *client;
|
||||||
bool shareDeckAvailable = false;
|
bool shareDeckAvailable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue