mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Tabs] Add a setting to define startup tab on application launch (#7121)
* [Tabs] Add a setting to define startup tab on application launch. Took 29 minutes * Naming and sizing Took 4 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
fbe5c4ade0
commit
16b6132701
14 changed files with 599 additions and 3 deletions
|
|
@ -5,6 +5,26 @@ TabsSettings::TabsSettings(const QString &settingPath, QObject *parent)
|
|||
{
|
||||
}
|
||||
|
||||
int TabsSettings::getStartupTabIndex() const
|
||||
{
|
||||
return getValue("startupTab", QString(), QString(), StartupTab::StartupTabHome).toInt();
|
||||
}
|
||||
|
||||
QString TabsSettings::getStartupServerHost() const
|
||||
{
|
||||
return getValue("startupServerHost", QString(), QString(), QString()).toString();
|
||||
}
|
||||
|
||||
QString TabsSettings::getStartupServerPort() const
|
||||
{
|
||||
return getValue("startupServerPort", QString(), QString(), QString()).toString();
|
||||
}
|
||||
|
||||
QString TabsSettings::getStartupRoomName() const
|
||||
{
|
||||
return getValue("startupRoomName", QString(), QString(), QString()).toString();
|
||||
}
|
||||
|
||||
bool TabsSettings::getTabVisualDeckStorageOpen() const
|
||||
{
|
||||
return getValue("visualDeckStorage", QString(), QString(), true).toBool();
|
||||
|
|
@ -40,6 +60,42 @@ bool TabsSettings::getTabLogOpen() const
|
|||
return getValue("log", QString(), QString(), true).toBool();
|
||||
}
|
||||
|
||||
void TabsSettings::setStartupTabIndex(int value)
|
||||
{
|
||||
if (getStartupTabIndex() == value) {
|
||||
return;
|
||||
}
|
||||
setValue(value, "startupTab");
|
||||
emit startupTabIndexChanged(value);
|
||||
}
|
||||
|
||||
void TabsSettings::setStartupServerHost(const QString &host)
|
||||
{
|
||||
if (getStartupServerHost() == host) {
|
||||
return;
|
||||
}
|
||||
setValue(host, "startupServerHost");
|
||||
emit startupServerHostChanged(host);
|
||||
}
|
||||
|
||||
void TabsSettings::setStartupServerPort(const QString &port)
|
||||
{
|
||||
if (getStartupServerPort() == port) {
|
||||
return;
|
||||
}
|
||||
setValue(port, "startupServerPort");
|
||||
emit startupServerPortChanged(port);
|
||||
}
|
||||
|
||||
void TabsSettings::setStartupRoomName(const QString &roomName)
|
||||
{
|
||||
if (getStartupRoomName() == roomName) {
|
||||
return;
|
||||
}
|
||||
setValue(roomName, "startupRoomName");
|
||||
emit startupRoomNameChanged(roomName);
|
||||
}
|
||||
|
||||
void TabsSettings::setTabVisualDeckStorageOpen(bool value)
|
||||
{
|
||||
setValue(value, "visualDeckStorage");
|
||||
|
|
|
|||
|
|
@ -5,12 +5,35 @@
|
|||
|
||||
#include <libcockatrice/interfaces/interface_tabs_settings_provider.h>
|
||||
|
||||
/**
|
||||
* @brief The tab the application selects after launch.
|
||||
*
|
||||
* The destination is a request: tabs that were not open before (Deck Editor, Server Room, …)
|
||||
* are opened as part of the startup flow. Destinations that require a server connection use the
|
||||
* intent system to satisfy their pre-conditions.
|
||||
*/
|
||||
enum StartupTab
|
||||
{
|
||||
StartupTabHome, ///< The Home tab
|
||||
StartupTabVisualDeckStorage, ///< The visual deck storage tab
|
||||
StartupTabDeckStorage, ///< The deck storage tab
|
||||
StartupTabReplays, ///< The game replays tab
|
||||
StartupTabDeckEditor, ///< A fresh classic deck editor tab
|
||||
StartupTabVisualDeckEditor, ///< A fresh visual deck editor tab
|
||||
StartupTabServer, ///< The server lobby: connect and select the server tab
|
||||
StartupTabServerRoom ///< A server room: connect and join the room by name
|
||||
};
|
||||
|
||||
class TabsSettings : public SettingsManager, public ITabsSettingsProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class SettingsCache;
|
||||
|
||||
public:
|
||||
[[nodiscard]] int getStartupTabIndex() const override;
|
||||
[[nodiscard]] QString getStartupServerHost() const override;
|
||||
[[nodiscard]] QString getStartupServerPort() const override;
|
||||
[[nodiscard]] QString getStartupRoomName() const override;
|
||||
[[nodiscard]] bool getTabVisualDeckStorageOpen() const override;
|
||||
[[nodiscard]] bool getTabServerOpen() const override;
|
||||
[[nodiscard]] bool getTabAccountOpen() const override;
|
||||
|
|
@ -19,6 +42,10 @@ public:
|
|||
[[nodiscard]] bool getTabAdminOpen() const override;
|
||||
[[nodiscard]] bool getTabLogOpen() const override;
|
||||
|
||||
void setStartupTabIndex(int value);
|
||||
void setStartupServerHost(const QString &host);
|
||||
void setStartupServerPort(const QString &port);
|
||||
void setStartupRoomName(const QString &roomName);
|
||||
void setTabVisualDeckStorageOpen(bool value);
|
||||
void setTabServerOpen(bool value);
|
||||
void setTabAccountOpen(bool value);
|
||||
|
|
@ -27,6 +54,12 @@ public:
|
|||
void setTabAdminOpen(bool value);
|
||||
void setTabLogOpen(bool value);
|
||||
|
||||
signals:
|
||||
void startupTabIndexChanged(int index);
|
||||
void startupServerHostChanged(const QString &host);
|
||||
void startupServerPortChanged(const QString &port);
|
||||
void startupRoomNameChanged(const QString &roomName);
|
||||
|
||||
public:
|
||||
explicit TabsSettings(const QString &settingPath, QObject *parent = nullptr);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue