servatrice/oracle/src/main.cpp
Zach H d19744236e
Automatic Spoiler Season (#2991)
* oracle now can be run in spoiler or normal mode

* tests for travis

* only run on relaunch

* spoilers in client (not oracle now) and tray icon shows when done

* spoiler status will be checked before downloading spoiler file

* only download if they care about spoilers

* reload db on spoiler download

* manual update button, code cleanup, and fix enabling sets when new

* cleanup, nullchecks, and fixes to spoiler

* reload DB even if not in spoiler season; necessary as we have a check elsewhere to prevent the reload if spoiler check happens

* Implement changes from 2991#issuecomment-356169374

* Change implicit nullptrs, alert on file deletion, minor changes

* make reload thread safe and minor changes from 2991#issuecomment-356450302

* Fix locking

* Disable update now button while process running
2018-01-10 13:27:43 -05:00

70 lines
2 KiB
C++

#include <QApplication>
#include <QTextCodec>
#include <QIcon>
#include <QTranslator>
#include <QLibraryInfo>
#include <QCommandLineParser>
#include "main.h"
#include "oraclewizard.h"
#include "settingscache.h"
#include "thememanager.h"
QTranslator *translator, *qtTranslator;
SettingsCache *settingsCache;
ThemeManager *themeManager;
const QString translationPrefix = "oracle";
QString translationPath;
bool isSpoilersOnly;
void installNewTranslator()
{
QString lang = settingsCache->getLang();
qtTranslator->load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
qApp->installTranslator(qtTranslator);
translator->load(translationPrefix + "_" + lang, translationPath);
qApp->installTranslator(translator);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("Cockatrice");
QCoreApplication::setOrganizationDomain("cockatrice");
// this can't be changed, as it influences the default savepath for cards.xml
QCoreApplication::setApplicationName("Cockatrice");
// If the program is opened with the -s flag, it will only do spoilers. Otherwise it will do MTGJSON/Tokens
QCommandLineParser parser;
QCommandLineOption showProgressOption("s", QCoreApplication::translate("main", "Only run in spoiler mode"));
parser.addOption(showProgressOption);
parser.process(app);
isSpoilersOnly = parser.isSet(showProgressOption);
#ifdef Q_OS_MAC
translationPath = qApp->applicationDirPath() + "/../Resources/translations";
#elif defined(Q_OS_WIN)
translationPath = qApp->applicationDirPath() + "/translations";
#else // linux
translationPath = qApp->applicationDirPath() + "/../share/cockatrice/translations";
#endif
settingsCache = new SettingsCache;
themeManager = new ThemeManager;
qtTranslator = new QTranslator;
translator = new QTranslator;
installNewTranslator();
OracleWizard wizard;
QIcon icon("theme:appicon.svg");
wizard.setWindowIcon(icon);
wizard.show();
return app.exec();
}