[DeckShare] Let intent chains opt into the link sign-in dialog

This commit is contained in:
Lukas Brübach 2026-09-19 07:10:42 +02:00 committed by GitHub
parent 34ef3c1f8b
commit 5fa8df4b83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 4 deletions

View file

@ -6,7 +6,8 @@
#include <QDialog> #include <QDialog>
IntentGetLoginCredentials::IntentGetLoginCredentials(ContextConnectToServer *_context) : Intent(), context(_context) IntentGetLoginCredentials::IntentGetLoginCredentials(ContextConnectToServer *_context, bool _promptForMissingCredentials)
: Intent(), context(_context), promptForMissingCredentials(_promptForMissingCredentials)
{ {
} }
@ -32,6 +33,14 @@ void IntentGetLoginCredentials::onPreconditionSatisfied()
void IntentGetLoginCredentials::onPreconditionNotSatisfied() void IntentGetLoginCredentials::onPreconditionNotSatisfied()
{ {
// MainWindow::applyStartupDestination runs this intent on every launch for
// users whose startup tab is Server / Server Room; keep that path quiet, as
// it was before the link-driven sign-in dialog existed.
if (!promptForMissingCredentials) {
emitFailed(tr("No saved credentials for this server"));
return;
}
// No credentials saved for the target server: ask the user for them. They // No credentials saved for the target server: ask the user for them. They
// opt into saving them so later links to the same server connect directly. // opt into saving them so later links to the same server connect directly.
const QString serverText = context->hostname + ":" + context->port; const QString serverText = context->hostname + ":" + context->port;

View file

@ -9,7 +9,10 @@ class IntentGetLoginCredentials : public Intent
Q_OBJECT Q_OBJECT
public: public:
IntentGetLoginCredentials(ContextConnectToServer *_context); // When promptForMissingCredentials is false (the default) a server without
// saved credentials fails silently; only intent chains from cockatrice://
// links opt into the interactive sign-in dialog.
explicit IntentGetLoginCredentials(ContextConnectToServer *_context, bool _promptForMissingCredentials = false);
protected: protected:
bool checkPrecondition() const override; bool checkPrecondition() const override;
@ -18,6 +21,7 @@ protected:
private: private:
ContextConnectToServer *context; ContextConnectToServer *context;
bool promptForMissingCredentials;
}; };
#endif // COCKATRICE_INTENT_LOGIN_H #endif // COCKATRICE_INTENT_LOGIN_H

View file

@ -121,7 +121,7 @@ Intent *IntentUrlParser::createJoinGameIntent(const QUrlQuery &query, QList<Inte
Intent *firstIntent = joinGameIntent; Intent *firstIntent = joinGameIntent;
if (!isConnectedTo(serverContext->hostname, serverContext->port)) { if (!isConnectedTo(serverContext->hostname, serverContext->port)) {
auto getLoginCredentialsIntent = new IntentGetLoginCredentials(serverContext); auto getLoginCredentialsIntent = new IntentGetLoginCredentials(serverContext, /*promptForMissingCredentials=*/true);
getLoginCredentialsIntent->setParent(joinGameIntent); getLoginCredentialsIntent->setParent(joinGameIntent);
chain.insert(0, getLoginCredentialsIntent); chain.insert(0, getLoginCredentialsIntent);
@ -238,7 +238,7 @@ Intent *IntentUrlParser::createOpenDeckIntent(const QUrlQuery &query, QList<Inte
Intent *firstIntent = openDeckIntent; Intent *firstIntent = openDeckIntent;
if (!isConnectedTo(serverContext->hostname, serverContext->port)) { if (!isConnectedTo(serverContext->hostname, serverContext->port)) {
auto getLoginCredentialsIntent = new IntentGetLoginCredentials(serverContext); auto getLoginCredentialsIntent = new IntentGetLoginCredentials(serverContext, /*promptForMissingCredentials=*/true);
getLoginCredentialsIntent->setParent(openDeckIntent); getLoginCredentialsIntent->setParent(openDeckIntent);
chain.insert(0, getLoginCredentialsIntent); chain.insert(0, getLoginCredentialsIntent);