mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 00:14:40 -07:00
Merge branch 'master' into tooomm-qt5
This commit is contained in:
commit
bbf2412157
219 changed files with 7310 additions and 1824 deletions
|
|
@ -14,8 +14,8 @@
|
|||
#include <QtConcurrent>
|
||||
#include <libcockatrice/card/database/card_database.h>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/settings/download_settings.h>
|
||||
#include <libcockatrice/settings/paths_settings.h>
|
||||
#include <libcockatrice/settings/personal_settings.h>
|
||||
#include <version_string.h>
|
||||
|
||||
#define SPOILERS_STATUS_URL "https://raw.githubusercontent.com/Cockatrice/Magic-Spoiler/files/SpoilerSeasonEnabled"
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
SpoilerBackgroundUpdater::SpoilerBackgroundUpdater(QObject *apParent) : QObject(apParent), cardUpdateProcess(nullptr)
|
||||
{
|
||||
isSpoilerDownloadEnabled = SettingsCache::instance().personal().getDownloadSpoilersStatus();
|
||||
isSpoilerDownloadEnabled = SettingsCache::instance().downloads().getDownloadSpoilersStatus();
|
||||
if (isSpoilerDownloadEnabled) {
|
||||
// Start the process of checking if we're in spoiler season
|
||||
// File exists means we're in spoiler season
|
||||
|
|
|
|||
|
|
@ -11,18 +11,22 @@
|
|||
#include <QGlobalStatic>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <libcockatrice/settings/appearance_settings.h>
|
||||
#include <libcockatrice/settings/cache_storage_settings.h>
|
||||
#include <libcockatrice/settings/card_database_settings.h>
|
||||
#include <libcockatrice/settings/card_override_settings.h>
|
||||
#include <libcockatrice/settings/cards_display_settings.h>
|
||||
#include <libcockatrice/settings/chat_settings.h>
|
||||
#include <libcockatrice/settings/commander_bracket_settings.h>
|
||||
#include <libcockatrice/settings/debug_settings.h>
|
||||
#include <libcockatrice/settings/deck_editor_settings.h>
|
||||
#include <libcockatrice/settings/download_settings.h>
|
||||
#include <libcockatrice/settings/game_filters_settings.h>
|
||||
#include <libcockatrice/settings/game_settings.h>
|
||||
#include <libcockatrice/settings/interface_settings.h>
|
||||
#include <libcockatrice/settings/layouts_settings.h>
|
||||
#include <libcockatrice/settings/message_settings.h>
|
||||
#include <libcockatrice/settings/network_settings.h>
|
||||
#include <libcockatrice/settings/paths_settings.h>
|
||||
#include <libcockatrice/settings/personal_settings.h>
|
||||
#include <libcockatrice/settings/recents_settings.h>
|
||||
|
|
@ -135,8 +139,12 @@ SettingsCache::SettingsCache()
|
|||
personalSettings = new PersonalSettings(settingsPath, this);
|
||||
cardsDisplaySettings = new CardsDisplaySettings(settingsPath, this);
|
||||
interfaceSettings = new InterfaceSettings(settingsPath, this);
|
||||
deckEditorSettings = new DeckEditorSettings(settingsPath, this);
|
||||
pathsSettings = new PathsSettings(settingsPath, this);
|
||||
visualDeckStorageSettings = new VisualDeckStorageSettings(settingsPath, this);
|
||||
appearanceSettings = new AppearanceSettings(settingsPath, this);
|
||||
networkSettings = new NetworkSettings(settingsPath, this);
|
||||
commanderBracketSettings = new CommanderBracketSettings(settingsPath, this);
|
||||
|
||||
// Forward ICardDatabasePathProvider signal from PathsSettings
|
||||
connect(pathsSettings, &PathsSettings::cardDatabasePathChanged, this,
|
||||
|
|
@ -147,7 +155,13 @@ SettingsCache::SettingsCache()
|
|||
releaseChannels << new StableReleaseChannel();
|
||||
releaseChannels << new BetaReleaseChannel();
|
||||
|
||||
themeName = personalSettings->getThemeName();
|
||||
themeName = appearanceSettings->getThemeName();
|
||||
|
||||
auto definitions = commanderBracketSettings->loadDefinitions();
|
||||
if (definitions.isEmpty()) {
|
||||
definitions = CommanderBracketSettings::defaultDefinitions();
|
||||
}
|
||||
commanderBracketSettings->reloadDefinitions(definitions);
|
||||
|
||||
loadPaths();
|
||||
}
|
||||
|
|
@ -155,7 +169,7 @@ SettingsCache::SettingsCache()
|
|||
void SettingsCache::setThemeName(const QString &_themeName)
|
||||
{
|
||||
themeName = _themeName;
|
||||
personalSettings->setThemeName(themeName);
|
||||
appearanceSettings->setThemeName(themeName);
|
||||
emit themeChanged();
|
||||
}
|
||||
|
||||
|
|
@ -216,15 +230,15 @@ void SettingsCache::loadPaths()
|
|||
// customPicsPath derived from picsPath
|
||||
QString picsPath = pathsIni.value("paths/pics").toString();
|
||||
if (picsPath.endsWith("/")) {
|
||||
computePath("custompics", picsPath + "CUSTOM/");
|
||||
computePath("customPics", picsPath + "CUSTOM/");
|
||||
} else {
|
||||
computePath("custompics", picsPath + "/CUSTOM/");
|
||||
computePath("customPics", picsPath + "/CUSTOM/");
|
||||
}
|
||||
|
||||
computePath("customsets", dataPath + "/customsets/");
|
||||
computeFilePath("carddatabase", dataPath + "/cards.xml");
|
||||
computeFilePath("tokendatabase", dataPath + "/tokens.xml");
|
||||
computeFilePath("spoilerdatabase", dataPath + "/spoiler.xml");
|
||||
computePath("customSets", dataPath + "/customsets/");
|
||||
computeFilePath("cardDatabase", dataPath + "/cards.xml");
|
||||
computeFilePath("tokenDatabase", dataPath + "/tokens.xml");
|
||||
computeFilePath("spoilerDatabase", dataPath + "/spoiler.xml");
|
||||
}
|
||||
|
||||
void SettingsCache::resetPaths()
|
||||
|
|
@ -272,12 +286,12 @@ QString SettingsCache::getTokenDatabasePath() const
|
|||
// INetworkSettingsProvider - delegate to sub-objects
|
||||
int SettingsCache::getKeepAlive() const
|
||||
{
|
||||
return personalSettings->getKeepAlive();
|
||||
return networkSettings->getKeepAlive();
|
||||
}
|
||||
|
||||
int SettingsCache::getTimeOut() const
|
||||
{
|
||||
return personalSettings->getTimeOut();
|
||||
return networkSettings->getTimeOut();
|
||||
}
|
||||
|
||||
bool SettingsCache::getNotifyAboutUpdates() const
|
||||
|
|
@ -287,17 +301,17 @@ bool SettingsCache::getNotifyAboutUpdates() const
|
|||
|
||||
void SettingsCache::setKnownMissingFeatures(const QString &_knownMissingFeatures)
|
||||
{
|
||||
interfaceSettings->setKnownMissingFeatures(_knownMissingFeatures);
|
||||
networkSettings->setKnownMissingFeatures(_knownMissingFeatures);
|
||||
}
|
||||
|
||||
QString SettingsCache::getKnownMissingFeatures()
|
||||
{
|
||||
return interfaceSettings->getKnownMissingFeatures();
|
||||
return networkSettings->getKnownMissingFeatures();
|
||||
}
|
||||
|
||||
QString SettingsCache::getClientID()
|
||||
{
|
||||
return personalSettings->getClientID();
|
||||
return networkSettings->getClientID();
|
||||
}
|
||||
|
||||
// Release channels
|
||||
|
|
@ -412,7 +426,7 @@ CardsDisplaySettings &SettingsCache::cardsDisplay() const
|
|||
return *cardsDisplaySettings;
|
||||
}
|
||||
|
||||
InterfaceSettings &SettingsCache::interface() const
|
||||
InterfaceSettings &SettingsCache::userInterface() const
|
||||
{
|
||||
return *interfaceSettings;
|
||||
}
|
||||
|
|
@ -422,7 +436,22 @@ PathsSettings &SettingsCache::paths() const
|
|||
return *pathsSettings;
|
||||
}
|
||||
|
||||
DeckEditorSettings &SettingsCache::deckEditor() const
|
||||
{
|
||||
return *deckEditorSettings;
|
||||
}
|
||||
|
||||
VisualDeckStorageSettings &SettingsCache::visualDeckStorage() const
|
||||
{
|
||||
return *visualDeckStorageSettings;
|
||||
}
|
||||
|
||||
AppearanceSettings &SettingsCache::appearance() const
|
||||
{
|
||||
return *appearanceSettings;
|
||||
}
|
||||
|
||||
NetworkSettings &SettingsCache::network() const
|
||||
{
|
||||
return *networkSettings;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ class CardDatabaseSettings;
|
|||
class CardOverrideSettings;
|
||||
class CardsDisplaySettings;
|
||||
class ChatSettings;
|
||||
class CommanderBracketSettings;
|
||||
class DebugSettings;
|
||||
class DeckEditorSettings;
|
||||
class DownloadSettings;
|
||||
class GameFiltersSettings;
|
||||
class GameSettings;
|
||||
|
|
@ -44,6 +46,8 @@ class SoundSettings;
|
|||
class TabsSettings;
|
||||
class UpdatesSettings;
|
||||
class VisualDeckStorageSettings;
|
||||
class AppearanceSettings;
|
||||
class NetworkSettings;
|
||||
class QSettings;
|
||||
|
||||
class SettingsCache : public ICardDatabasePathProvider, public INetworkSettingsProvider
|
||||
|
|
@ -75,8 +79,12 @@ private:
|
|||
PersonalSettings *personalSettings;
|
||||
CardsDisplaySettings *cardsDisplaySettings;
|
||||
InterfaceSettings *interfaceSettings;
|
||||
DeckEditorSettings *deckEditorSettings;
|
||||
PathsSettings *pathsSettings;
|
||||
VisualDeckStorageSettings *visualDeckStorageSettings;
|
||||
AppearanceSettings *appearanceSettings;
|
||||
NetworkSettings *networkSettings;
|
||||
CommanderBracketSettings *commanderBracketSettings;
|
||||
|
||||
QString themeName;
|
||||
|
||||
|
|
@ -138,9 +146,16 @@ public:
|
|||
[[nodiscard]] UpdatesSettings &updates() const;
|
||||
[[nodiscard]] PersonalSettings &personal() const;
|
||||
[[nodiscard]] CardsDisplaySettings &cardsDisplay() const;
|
||||
[[nodiscard]] InterfaceSettings &interface() const;
|
||||
[[nodiscard]] InterfaceSettings &userInterface() const;
|
||||
[[nodiscard]] DeckEditorSettings &deckEditor() const;
|
||||
[[nodiscard]] PathsSettings &paths() const;
|
||||
[[nodiscard]] VisualDeckStorageSettings &visualDeckStorage() const;
|
||||
[[nodiscard]] AppearanceSettings &appearance() const;
|
||||
[[nodiscard]] NetworkSettings &network() const;
|
||||
[[nodiscard]] CommanderBracketSettings &commanderBrackets() const
|
||||
{
|
||||
return *commanderBracketSettings;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool getIsPortableBuild() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <QtMath>
|
||||
|
||||
CardCounterSettings::CardCounterSettings(const QString &settingsPath, QObject *parent)
|
||||
: SettingsManager(settingsPath + "global.ini", "cards", "counters", parent)
|
||||
: SettingsManager(settingsPath + "card_counters.ini", "cards", "counters", parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
69
cockatrice/src/client/url_scheme_event_filter.h
Normal file
69
cockatrice/src/client/url_scheme_event_filter.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#ifndef COCKATRICE_URL_SCHEME_EVENT_FILTER_H
|
||||
#define COCKATRICE_URL_SCHEME_EVENT_FILTER_H
|
||||
|
||||
#include <QEvent>
|
||||
#include <QFileOpenEvent>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
/**
|
||||
* @brief Event filter that catches QFileOpenEvent URLs matching a scheme and
|
||||
* re-emits them as urlReceived().
|
||||
*
|
||||
* On macOS, when the application is registered as a URL scheme handler, the
|
||||
* OS delivers incoming URLs via QFileOpenEvent on the QApplication object.
|
||||
* Install this filter on QApplication to intercept them:
|
||||
*
|
||||
* @code
|
||||
* UrlSchemeEventFilter filter(QStringList{QStringLiteral("cockatrice")});
|
||||
* QObject::connect(&filter, &UrlSchemeEventFilter::urlReceived,
|
||||
* &mainWindow, &MainWindow::handleUrl);
|
||||
* app.installEventFilter(&filter);
|
||||
* @endcode
|
||||
*
|
||||
* Note: the strings are compared against QUrl::scheme(), so they must be
|
||||
* written without the "://" suffix (e.g. "cockatrice", not "cockatrice://").
|
||||
*/
|
||||
class UrlSchemeEventFilter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UrlSchemeEventFilter(const QStringList &schemes, QObject *parent = nullptr)
|
||||
: QObject(parent), prefixes(schemes)
|
||||
{
|
||||
}
|
||||
|
||||
signals:
|
||||
void urlReceived(const QString &url);
|
||||
|
||||
public:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override
|
||||
{
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
auto *fileEvent = static_cast<QFileOpenEvent *>(event);
|
||||
|
||||
const QUrl url = fileEvent->url();
|
||||
|
||||
for (const auto &prefix : prefixes) {
|
||||
if (url.scheme() == prefix) {
|
||||
emit urlReceived(url.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (url.isLocalFile()) {
|
||||
emit urlReceived(url.toLocalFile());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
private:
|
||||
QStringList prefixes;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_URL_SCHEME_EVENT_FILTER_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue