Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
MainWindow Class Reference

#include <window_main.h>

Inheritance diagram for MainWindow:
[legend]
Collaboration diagram for MainWindow:
[legend]

Public Slots

void actCheckCardUpdates ()
void actCheckCardUpdatesBackground ()
void actCheckServerUpdates ()
void actCheckClientUpdates ()
void actConnect ()
void actExit ()
void handleCockatriceLink (const QString &url)

Signals

void cardDatabaseUpdateFinished (bool success)
 Emitted after the card-database update subprocess exits.
void cardDatabaseUpdateProgress (const CardUpdateProgress &progress)
 Emitted while the card-database update subprocess runs. progress.done/progress.total are byte counts for the first two stages and set indices for "import".

Public Member Functions

 MainWindow (QWidget *parent=nullptr)
void setConnectTo (QString url)
void setSkipStartupAutoConnect (bool skip)
 ~MainWindow () override
RemoteClient * getRemoteClient () const
TabSupervisor * getTabSupervisor () const
bool closeForUpdate ()
 Closes the window so an update installer can replace the running binaries. Returns true only if the shutdown actually ran (settings flushed, tabs shut down); false if the close was vetoed by the user or is already in progress.

Protected Member Functions

void closeEvent (QCloseEvent *event) override
void changeEvent (QEvent *event) override

Private Slots

void updateTabMenu (const QList< QMenu * > &newMenuList)
void statusChanged (ClientStatus _status)
void localGameEnded ()
void pixmapCacheSizeChanged (int newSizeInMBs)
void actDisconnect ()
void actSinglePlayer ()
void actWatchReplay ()
void actFullScreen (bool checked)
void actSettings ()
void actAbout ()
void actTips ()
void actUpdate ()
void actViewLog ()
void actOpenSettingsFolder ()
void actShow ()
void showWindowIfHidden ()
void onUrlChainFinished (bool connected)
void cardUpdateError (QProcess::ProcessError err)
void cardUpdateFinished (int exitCode, QProcess::ExitStatus exitStatus)
void cardUpdateProgressOutput ()
void cardUpdateStandardError ()
void refreshShortcuts ()
void cardDatabaseLoadingFailed ()
void cardDatabaseNewSetsFound (int numUnknownSets, QStringList unknownSetsNames)
void cardDatabaseAllNewSetsEnabled ()
void checkClientUpdatesFinished (bool needToUpdate, bool isCompatible, Release *release)
void actCheckCommanderBracketDefinitionUpdates ()
void actOpenCustomFolder ()
void actOpenCustomsetsFolder ()
void actAddCustomSet ()
void actReloadCardDatabase ()
void actManageSets ()
void actEditTokens ()
void startupConfigCheck ()
void alertForcedOracleRun (const QString &version, bool isUpdate)
void applyStartupDestination ()
void onStartupDestinationConnected (int destination, const ContextConnectToServer &serverContext)
void startupDestinationFailed (const QString &reason)
bool startupDestinationConnectsToServer () const
void attemptStartupAutoConnect ()

Private Member Functions

void retranslateUi ()
void createActions ()
void createMenus ()
void createTrayIcon ()
int getNextCustomSetPrefix (QDir dataDir)
void runFirstRunWizard (bool firstRun=false)
QString getCardUpdaterBinaryName ()
void createCardUpdateProcess (bool background=false)
void exitCardDatabaseUpdate (bool doReload)
void reloadCardDatabaseAndCheckSets ()
 Reloads the card database on a worker thread and runs checkUnknownSets() once the finished snapshot has been swapped in.
bool requestCardUpdateRaise ()
 Tries to bring the open card database updater window to the front.
void announceCardUpdateRunning ()
 Tells the user an update is running without blocking, honoring a hidden status bar.
void notifyCardUpdateFinishedFromTray (bool success)
 Posts a tray notification when the status bar cannot show progress.
void startLocalGame (const LocalGameOptions &options)

Private Attributes

QList< QMenu * > tabMenus
QMenu * cockatriceMenu
QMenu * dbMenu
QMenu * tabsMenu
QMenu * helpMenu
QMenu * trayIconMenu
QAction * aAbout
QAction * aSettings
QAction * aShow
QAction * aExit
QToolButton * settingsButton = nullptr
QAction * aConnect
QAction * aDisconnect
QAction * aRegister
QAction * aForgotPassword
QAction * aSinglePlayer
QAction * aWatchReplay
QAction * aFullScreen
QAction * aManageSets
QAction * aEditTokens
QAction * aOpenCustomFolder
QAction * aOpenCustomsetsFolder
QAction * aAddCustomSet
QAction * aReloadCardDatabase
QAction * aTips
QAction * aUpdate
QAction * aCheckCardUpdates
QAction * aCheckCardUpdatesBackground
QAction * aFirstRunWizard
QAction * aStatusBar
QAction * aViewLog
QAction * aOpenSettingsFolder
TabSupervisor * tabSupervisor
IntentUrlParser * urlParser
WndSets * wndSets
ConnectionController * connectionController
LocalServer * localServer
LagMonitor lagMonitor
 watches the main thread for event loop stalls
LatencyStatusWidget * latencyStatus = nullptr
 status bar widget with live round-trip stats and history graph
bool bHasActivated
bool askedForDbUpdater
bool bClosingDown = false
 guards closeEvent() against re-entrancy
bool skipStartupAutoConnect = false
bool startupAutoConnectAttempted = false
bool firstRunWizardActive = false
QProcess * cardUpdateProcess
QByteArray cardUpdateOutputBuffer
QByteArray cardUpdateErrorOutput
 diagnostic output collected from the updater's stderr
QByteArray cardUpdateErrorPartial
 incomplete trailing stderr line, kept for line-based logging
CardUpdateStage cardUpdateLoggedStage = CardUpdateStage::Unknown
 stage of the last logged progress update
QElapsedTimer cardUpdateProgressLogTimer
 throttles progress logging to the running stage
CardDatabaseUpdateStatusBar * cardUpdateStatusBar = nullptr
 status bar widget tracking the card database update
DlgViewLog * logviewDialog
GameReplay * replay
DlgTipOfTheDay * tip
QUrl connectTo

Static Private Attributes

static const QString appName = "Cockatrice"
static const QStringList fileNameFilters

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( QWidget * parent = nullptr)
explicit

◆ ~MainWindow()

MainWindow::~MainWindow ( )
override

Member Function Documentation

◆ actAbout

void MainWindow::actAbout ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actAddCustomSet

void MainWindow::actAddCustomSet ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actCheckCardUpdates

void MainWindow::actCheckCardUpdates ( )
slot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actCheckCardUpdatesBackground

void MainWindow::actCheckCardUpdatesBackground ( )
slot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actCheckClientUpdates

void MainWindow::actCheckClientUpdates ( )
slot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actCheckCommanderBracketDefinitionUpdates

void MainWindow::actCheckCommanderBracketDefinitionUpdates ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actCheckServerUpdates

void MainWindow::actCheckServerUpdates ( )
slot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actConnect

void MainWindow::actConnect ( )
slot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actDisconnect

void MainWindow::actDisconnect ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actEditTokens

void MainWindow::actEditTokens ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actExit

void MainWindow::actExit ( )
slot
Here is the caller graph for this function:

◆ actFullScreen

void MainWindow::actFullScreen ( bool checked)
privateslot
Here is the caller graph for this function:

◆ actManageSets

void MainWindow::actManageSets ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actOpenCustomFolder

void MainWindow::actOpenCustomFolder ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actOpenCustomsetsFolder

void MainWindow::actOpenCustomsetsFolder ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actOpenSettingsFolder

void MainWindow::actOpenSettingsFolder ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actReloadCardDatabase

void MainWindow::actReloadCardDatabase ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actSettings

void MainWindow::actSettings ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actShow

void MainWindow::actShow ( )
privateslot
Here is the caller graph for this function:

◆ actSinglePlayer

void MainWindow::actSinglePlayer ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actTips

void MainWindow::actTips ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actUpdate

void MainWindow::actUpdate ( )
privateslot
Here is the caller graph for this function:

◆ actViewLog

void MainWindow::actViewLog ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actWatchReplay

void MainWindow::actWatchReplay ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ alertForcedOracleRun

void MainWindow::alertForcedOracleRun ( const QString & version,
bool isUpdate )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ announceCardUpdateRunning()

void MainWindow::announceCardUpdateRunning ( )
private

Tells the user an update is running without blocking, honoring a hidden status bar.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyStartupDestination

void MainWindow::applyStartupDestination ( )
privateslot

Drives the server-based startup destinations (Server lobby, Server Room) through the intent system: fetch saved credentials, connect to the configured server, then land on the Lobby or join the configured room by name.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ attemptStartupAutoConnect

void MainWindow::attemptStartupAutoConnect ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cardDatabaseAllNewSetsEnabled

void MainWindow::cardDatabaseAllNewSetsEnabled ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cardDatabaseLoadingFailed

void MainWindow::cardDatabaseLoadingFailed ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cardDatabaseNewSetsFound

void MainWindow::cardDatabaseNewSetsFound ( int numUnknownSets,
QStringList unknownSetsNames )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cardDatabaseUpdateFinished

void MainWindow::cardDatabaseUpdateFinished ( bool success)
signal

Emitted after the card-database update subprocess exits.

Here is the caller graph for this function:

◆ cardDatabaseUpdateProgress

void MainWindow::cardDatabaseUpdateProgress ( const CardUpdateProgress & progress)
signal

Emitted while the card-database update subprocess runs. progress.done/progress.total are byte counts for the first two stages and set indices for "import".

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cardUpdateError

void MainWindow::cardUpdateError ( QProcess::ProcessError err)
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cardUpdateFinished

void MainWindow::cardUpdateFinished ( int exitCode,
QProcess::ExitStatus exitStatus )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cardUpdateProgressOutput

void MainWindow::cardUpdateProgressOutput ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cardUpdateStandardError

void MainWindow::cardUpdateStandardError ( )
privateslot
Here is the caller graph for this function:

◆ changeEvent()

void MainWindow::changeEvent ( QEvent * event)
overrideprotected
Here is the call graph for this function:

◆ checkClientUpdatesFinished

void MainWindow::checkClientUpdatesFinished ( bool needToUpdate,
bool isCompatible,
Release * release )
privateslot
Here is the caller graph for this function:

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent * event)
overrideprotected
Here is the call graph for this function:

◆ closeForUpdate()

bool MainWindow::closeForUpdate ( )

Closes the window so an update installer can replace the running binaries. Returns true only if the shutdown actually ran (settings flushed, tabs shut down); false if the close was vetoed by the user or is already in progress.

◆ createActions()

void MainWindow::createActions ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createCardUpdateProcess()

void MainWindow::createCardUpdateProcess ( bool background = false)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createMenus()

void MainWindow::createMenus ( )
private
Here is the caller graph for this function:

◆ createTrayIcon()

void MainWindow::createTrayIcon ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exitCardDatabaseUpdate()

void MainWindow::exitCardDatabaseUpdate ( bool doReload)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCardUpdaterBinaryName()

QString MainWindow::getCardUpdaterBinaryName ( )
inlineprivate
Here is the caller graph for this function:

◆ getNextCustomSetPrefix()

int MainWindow::getNextCustomSetPrefix ( QDir dataDir)
private
Here is the caller graph for this function:

◆ getRemoteClient()

RemoteClient * MainWindow::getRemoteClient ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabSupervisor()

TabSupervisor * MainWindow::getTabSupervisor ( ) const
inline
Here is the caller graph for this function:

◆ handleCockatriceLink

void MainWindow::handleCockatriceLink ( const QString & url)
slot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ localGameEnded

void MainWindow::localGameEnded ( )
privateslot
Here is the caller graph for this function:

◆ notifyCardUpdateFinishedFromTray()

void MainWindow::notifyCardUpdateFinishedFromTray ( bool success)
private

Posts a tray notification when the status bar cannot show progress.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onStartupDestinationConnected

void MainWindow::onStartupDestinationConnected ( int destination,
const ContextConnectToServer & serverContext )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onUrlChainFinished

void MainWindow::onUrlChainFinished ( bool connected)
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pixmapCacheSizeChanged

void MainWindow::pixmapCacheSizeChanged ( int newSizeInMBs)
privateslot
Here is the caller graph for this function:

◆ refreshShortcuts

void MainWindow::refreshShortcuts ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reloadCardDatabaseAndCheckSets()

void MainWindow::reloadCardDatabaseAndCheckSets ( )
private

Reloads the card database on a worker thread and runs checkUnknownSets() once the finished snapshot has been swapped in.

The loader never runs checkUnknownSets() itself (see main.cpp); post-update loads that can introduce new sets must own the check, and it has to run after the queued snapshot swap, not on the worker.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ requestCardUpdateRaise()

bool MainWindow::requestCardUpdateRaise ( )
private

Tries to bring the open card database updater window to the front.

Returns
true when the updater acknowledged the request
Here is the call graph for this function:
Here is the caller graph for this function:

◆ retranslateUi()

void MainWindow::retranslateUi ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ runFirstRunWizard()

void MainWindow::runFirstRunWizard ( bool firstRun = false)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setConnectTo()

void MainWindow::setConnectTo ( QString url)
inline
Here is the caller graph for this function:

◆ setSkipStartupAutoConnect()

void MainWindow::setSkipStartupAutoConnect ( bool skip)
inline
Here is the caller graph for this function:

◆ showWindowIfHidden

void MainWindow::showWindowIfHidden ( )
privateslot
Here is the caller graph for this function:

◆ startLocalGame()

void MainWindow::startLocalGame ( const LocalGameOptions & options)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startupConfigCheck

void MainWindow::startupConfigCheck ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startupDestinationConnectsToServer

bool MainWindow::startupDestinationConnectsToServer ( ) const
nodiscardprivateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startupDestinationFailed

void MainWindow::startupDestinationFailed ( const QString & reason)
privateslot
Here is the caller graph for this function:

◆ statusChanged

void MainWindow::statusChanged ( ClientStatus _status)
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateTabMenu

void MainWindow::updateTabMenu ( const QList< QMenu * > & newMenuList)
privateslot

Replaces the tab-specific menus that are shown in the menuBar.

Parameters
newMenuListThe tab-specific menus to show in the menuBar
Here is the caller graph for this function:

Member Data Documentation

◆ aAbout

QAction* MainWindow::aAbout
private

◆ aAddCustomSet

QAction * MainWindow::aAddCustomSet
private

◆ aCheckCardUpdates

QAction * MainWindow::aCheckCardUpdates
private

◆ aCheckCardUpdatesBackground

QAction * MainWindow::aCheckCardUpdatesBackground
private

◆ aConnect

QAction* MainWindow::aConnect
private

◆ aDisconnect

QAction * MainWindow::aDisconnect
private

◆ aEditTokens

QAction * MainWindow::aEditTokens
private

◆ aExit

QAction * MainWindow::aExit
private

◆ aFirstRunWizard

QAction * MainWindow::aFirstRunWizard
private

◆ aForgotPassword

QAction * MainWindow::aForgotPassword
private

◆ aFullScreen

QAction * MainWindow::aFullScreen
private

◆ aManageSets

QAction* MainWindow::aManageSets
private

◆ aOpenCustomFolder

QAction * MainWindow::aOpenCustomFolder
private

◆ aOpenCustomsetsFolder

QAction * MainWindow::aOpenCustomsetsFolder
private

◆ aOpenSettingsFolder

QAction * MainWindow::aOpenSettingsFolder
private

◆ appName

const QString MainWindow::appName = "Cockatrice"
staticprivate

◆ aRegister

QAction * MainWindow::aRegister
private

◆ aReloadCardDatabase

QAction * MainWindow::aReloadCardDatabase
private

◆ aSettings

QAction * MainWindow::aSettings
private

◆ aShow

QAction * MainWindow::aShow
private

◆ aSinglePlayer

QAction * MainWindow::aSinglePlayer
private

◆ askedForDbUpdater

bool MainWindow::askedForDbUpdater
private

◆ aStatusBar

QAction * MainWindow::aStatusBar
private

◆ aTips

QAction* MainWindow::aTips
private

◆ aUpdate

QAction * MainWindow::aUpdate
private

◆ aViewLog

QAction * MainWindow::aViewLog
private

◆ aWatchReplay

QAction * MainWindow::aWatchReplay
private

◆ bClosingDown

bool MainWindow::bClosingDown = false
private

guards closeEvent() against re-entrancy

◆ bHasActivated

bool MainWindow::bHasActivated
private

◆ cardUpdateErrorOutput

QByteArray MainWindow::cardUpdateErrorOutput
private

diagnostic output collected from the updater's stderr

◆ cardUpdateErrorPartial

QByteArray MainWindow::cardUpdateErrorPartial
private

incomplete trailing stderr line, kept for line-based logging

◆ cardUpdateLoggedStage

CardUpdateStage MainWindow::cardUpdateLoggedStage = CardUpdateStage::Unknown
private

stage of the last logged progress update

◆ cardUpdateOutputBuffer

QByteArray MainWindow::cardUpdateOutputBuffer
private

◆ cardUpdateProcess

QProcess* MainWindow::cardUpdateProcess
private

◆ cardUpdateProgressLogTimer

QElapsedTimer MainWindow::cardUpdateProgressLogTimer
private

throttles progress logging to the running stage

◆ cardUpdateStatusBar

CardDatabaseUpdateStatusBar* MainWindow::cardUpdateStatusBar = nullptr
private

status bar widget tracking the card database update

◆ cockatriceMenu

QMenu* MainWindow::cockatriceMenu
private

◆ connectionController

ConnectionController* MainWindow::connectionController
private

◆ connectTo

QUrl MainWindow::connectTo
private

◆ dbMenu

QMenu * MainWindow::dbMenu
private

◆ fileNameFilters

const QStringList MainWindow::fileNameFilters
staticprivate
Initial value:
= QStringList() << QObject::tr("Cockatrice card database (*.xml)")
<< QObject::tr("All files (*.*)")

◆ firstRunWizardActive

bool MainWindow::firstRunWizardActive = false
private

◆ helpMenu

QMenu * MainWindow::helpMenu
private

◆ lagMonitor

LagMonitor MainWindow::lagMonitor
private

watches the main thread for event loop stalls

◆ latencyStatus

LatencyStatusWidget* MainWindow::latencyStatus = nullptr
private

status bar widget with live round-trip stats and history graph

◆ localServer

LocalServer* MainWindow::localServer
private

◆ logviewDialog

DlgViewLog* MainWindow::logviewDialog
private

◆ replay

GameReplay* MainWindow::replay
private

◆ settingsButton

QToolButton* MainWindow::settingsButton = nullptr
private

◆ skipStartupAutoConnect

bool MainWindow::skipStartupAutoConnect = false
private

◆ startupAutoConnectAttempted

bool MainWindow::startupAutoConnectAttempted = false
private

◆ tabMenus

QList<QMenu *> MainWindow::tabMenus
private

◆ tabsMenu

QMenu * MainWindow::tabsMenu
private

◆ tabSupervisor

TabSupervisor* MainWindow::tabSupervisor
private

◆ tip

DlgTipOfTheDay* MainWindow::tip
private

◆ trayIconMenu

QMenu * MainWindow::trayIconMenu
private

◆ urlParser

IntentUrlParser* MainWindow::urlParser
private

◆ wndSets

WndSets* MainWindow::wndSets
private

The documentation for this class was generated from the following files: