Merge branch 'master' of ssh://cockatrice.de/home/cockgit/cockatrice
|
@ -112,4 +112,10 @@ SOURCES += src/counter.cpp \
|
||||||
../common/protocol_datastructures.cpp
|
../common/protocol_datastructures.cpp
|
||||||
|
|
||||||
TRANSLATIONS += translations/cockatrice_de.ts translations/cockatrice_en.ts
|
TRANSLATIONS += translations/cockatrice_de.ts translations/cockatrice_en.ts
|
||||||
CONFIG += qt debug
|
win32 {
|
||||||
|
RC_FILE = cockatrice.rc
|
||||||
|
}
|
||||||
|
macx {
|
||||||
|
ICON = resources/appicon.icns
|
||||||
|
CONFIG += x86 ppc
|
||||||
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<file>resources/hr.jpg</file>
|
<file>resources/hr.jpg</file>
|
||||||
<file>translations/cockatrice_de.qm</file>
|
<file>translations/cockatrice_de.qm</file>
|
||||||
<file>translations/cockatrice_en.qm</file>
|
<file>translations/cockatrice_en.qm</file>
|
||||||
<file>resources/icon.svg</file>
|
<file>resources/appicon.svg</file>
|
||||||
<file>resources/add_to_sideboard.svg</file>
|
<file>resources/add_to_sideboard.svg</file>
|
||||||
<file>resources/decrement.svg</file>
|
<file>resources/decrement.svg</file>
|
||||||
<file>resources/increment.svg</file>
|
<file>resources/increment.svg</file>
|
||||||
|
|
1
cockatrice/cockatrice.rc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ID1_ICON1 ICON DISCARDABLE "resources/appicon.ico"
|
BIN
cockatrice/resources/appicon.icns
Normal file
BIN
cockatrice/resources/appicon.ico
Normal file
After Width: | Height: | Size: 345 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 760 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 764 KiB After Width: | Height: | Size: 9 KiB |
Before Width: | Height: | Size: 764 KiB After Width: | Height: | Size: 9.1 KiB |
|
@ -232,7 +232,7 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
||||||
}
|
}
|
||||||
|
|
||||||
CardDatabase::CardDatabase(QObject *parent)
|
CardDatabase::CardDatabase(QObject *parent)
|
||||||
: QObject(parent), noCard(0)
|
: QObject(parent), downloadRunning(false), loadSuccess(false), noCard(0)
|
||||||
{
|
{
|
||||||
connect(settingsCache, SIGNAL(picsPathChanged()), this, SLOT(clearPixmapCache()));
|
connect(settingsCache, SIGNAL(picsPathChanged()), this, SLOT(clearPixmapCache()));
|
||||||
connect(settingsCache, SIGNAL(cardDatabasePathChanged()), this, SLOT(loadCardDatabase()));
|
connect(settingsCache, SIGNAL(cardDatabasePathChanged()), this, SLOT(loadCardDatabase()));
|
||||||
|
@ -331,22 +331,20 @@ void CardDatabase::startPicDownload(CardInfo *card)
|
||||||
void CardDatabase::startNextPicDownload()
|
void CardDatabase::startNextPicDownload()
|
||||||
{
|
{
|
||||||
if (cardsToDownload.isEmpty()) {
|
if (cardsToDownload.isEmpty()) {
|
||||||
|
cardBeingDownloaded = 0;
|
||||||
downloadRunning = false;
|
downloadRunning = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadRunning = true;
|
downloadRunning = true;
|
||||||
|
|
||||||
CardInfo *card = cardsToDownload.takeFirst();
|
cardBeingDownloaded = cardsToDownload.takeFirst();
|
||||||
QNetworkRequest req(QUrl(card->getPicURL()));
|
QNetworkRequest req(QUrl(cardBeingDownloaded->getPicURL()));
|
||||||
req.setOriginatingObject(card);
|
|
||||||
networkManager->get(req);
|
networkManager->get(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardDatabase::picDownloadFinished(QNetworkReply *reply)
|
void CardDatabase::picDownloadFinished(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
CardInfo *card = static_cast<CardInfo *>(reply->request().originatingObject());
|
|
||||||
|
|
||||||
QString picsPath = settingsCache->getPicsPath();
|
QString picsPath = settingsCache->getPicsPath();
|
||||||
const QByteArray &picData = reply->readAll();
|
const QByteArray &picData = reply->readAll();
|
||||||
QPixmap testPixmap;
|
QPixmap testPixmap;
|
||||||
|
@ -357,13 +355,13 @@ void CardDatabase::picDownloadFinished(QNetworkReply *reply)
|
||||||
return;
|
return;
|
||||||
dir.mkdir("downloadedPics");
|
dir.mkdir("downloadedPics");
|
||||||
}
|
}
|
||||||
QFile newPic(picsPath + "/downloadedPics/" + card->getCorrectedName() + ".full.jpg");
|
QFile newPic(picsPath + "/downloadedPics/" + cardBeingDownloaded->getCorrectedName() + ".full.jpg");
|
||||||
if (!newPic.open(QIODevice::WriteOnly))
|
if (!newPic.open(QIODevice::WriteOnly))
|
||||||
return;
|
return;
|
||||||
newPic.write(picData);
|
newPic.write(picData);
|
||||||
newPic.close();
|
newPic.close();
|
||||||
|
|
||||||
card->updatePixmapCache();
|
cardBeingDownloaded->updatePixmapCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
@ -430,12 +428,12 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CardDatabase::loadFromFile(const QString &fileName)
|
bool CardDatabase::loadFromFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
if (!file.isOpen())
|
if (!file.isOpen())
|
||||||
return -1;
|
return false;
|
||||||
QXmlStreamReader xml(&file);
|
QXmlStreamReader xml(&file);
|
||||||
clear();
|
clear();
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
|
@ -453,7 +451,7 @@ int CardDatabase::loadFromFile(const QString &fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug(QString("%1 cards in %2 sets loaded").arg(cardHash.size()).arg(setHash.size()).toLatin1());
|
qDebug(QString("%1 cards in %2 sets loaded").arg(cardHash.size()).arg(setHash.size()).toLatin1());
|
||||||
return cardHash.size();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CardDatabase::saveToFile(const QString &fileName)
|
bool CardDatabase::saveToFile(const QString &fileName)
|
||||||
|
@ -494,11 +492,13 @@ void CardDatabase::picDownloadChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardDatabase::loadCardDatabase()
|
bool CardDatabase::loadCardDatabase()
|
||||||
{
|
{
|
||||||
QString cardDatabasePath = settingsCache->getCardDatabasePath();
|
QString cardDatabasePath = settingsCache->getCardDatabasePath();
|
||||||
if (!cardDatabasePath.isEmpty())
|
if (!cardDatabasePath.isEmpty())
|
||||||
loadFromFile(cardDatabasePath);
|
loadSuccess = loadFromFile(cardDatabasePath);
|
||||||
|
else loadSuccess = false;
|
||||||
|
return loadSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CardDatabase::getAllColors() const
|
QStringList CardDatabase::getAllColors() const
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
class CardInfo;
|
class CardInfo;
|
||||||
|
@ -96,7 +97,9 @@ protected:
|
||||||
QHash<QString, CardSet *> setHash;
|
QHash<QString, CardSet *> setHash;
|
||||||
QNetworkAccessManager *networkManager;
|
QNetworkAccessManager *networkManager;
|
||||||
QList<CardInfo *> cardsToDownload;
|
QList<CardInfo *> cardsToDownload;
|
||||||
|
CardInfo *cardBeingDownloaded;
|
||||||
bool downloadRunning;
|
bool downloadRunning;
|
||||||
|
bool loadSuccess;
|
||||||
CardInfo *noCard;
|
CardInfo *noCard;
|
||||||
private:
|
private:
|
||||||
void loadCardsFromXml(QXmlStreamReader &xml);
|
void loadCardsFromXml(QXmlStreamReader &xml);
|
||||||
|
@ -110,16 +113,17 @@ public:
|
||||||
CardSet *getSet(const QString &setName);
|
CardSet *getSet(const QString &setName);
|
||||||
QList<CardInfo *> getCardList() const { return cardHash.values(); }
|
QList<CardInfo *> getCardList() const { return cardHash.values(); }
|
||||||
SetList getSetList() const;
|
SetList getSetList() const;
|
||||||
int loadFromFile(const QString &fileName);
|
bool loadFromFile(const QString &fileName);
|
||||||
bool saveToFile(const QString &fileName);
|
bool saveToFile(const QString &fileName);
|
||||||
void startPicDownload(CardInfo *card);
|
void startPicDownload(CardInfo *card);
|
||||||
QStringList getAllColors() const;
|
QStringList getAllColors() const;
|
||||||
QStringList getAllMainCardTypes() const;
|
QStringList getAllMainCardTypes() const;
|
||||||
|
bool getLoadSuccess() const { return loadSuccess; }
|
||||||
public slots:
|
public slots:
|
||||||
void clearPixmapCache();
|
void clearPixmapCache();
|
||||||
private slots:
|
private slots:
|
||||||
void picDownloadFinished(QNetworkReply *reply);
|
void picDownloadFinished(QNetworkReply *reply);
|
||||||
void loadCardDatabase();
|
bool loadCardDatabase();
|
||||||
void picDownloadChanged();
|
void picDownloadChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -454,6 +454,21 @@ void DlgSettings::changeEvent(QEvent *event)
|
||||||
QDialog::changeEvent(event);
|
QDialog::changeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DlgSettings::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
if (!db->getLoadSuccess()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Your card database is invalid. Please check if the path is set correctly."));
|
||||||
|
event->ignore();
|
||||||
|
} else if (!QDir(settingsCache->getDeckPath()).exists()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("The path to your deck directory is invalid."));
|
||||||
|
event->ignore();
|
||||||
|
} else if (!QDir(settingsCache->getPicsPath()).exists()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("The path to your card pictures directory is invalid."));
|
||||||
|
event->ignore();
|
||||||
|
} else
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
void DlgSettings::retranslateUi()
|
void DlgSettings::retranslateUi()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Settings"));
|
setWindowTitle(tr("Settings"));
|
||||||
|
|
|
@ -13,6 +13,7 @@ class QComboBox;
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QCloseEvent;
|
||||||
|
|
||||||
class AbstractSettingsPage : public QWidget {
|
class AbstractSettingsPage : public QWidget {
|
||||||
public:
|
public:
|
||||||
|
@ -107,6 +108,7 @@ private:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *event);
|
void changeEvent(QEvent *event);
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,10 +26,12 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QDir>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "window_main.h"
|
#include "window_main.h"
|
||||||
|
#include "dlg_settings.h"
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include "pingpixmapgenerator.h"
|
#include "pingpixmapgenerator.h"
|
||||||
|
@ -80,20 +82,30 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||||
|
|
||||||
MainWindow ui;
|
bool startMainProgram = true;
|
||||||
qDebug("main(): MainWindow constructor finished");
|
if (!db->getLoadSuccess() || !QDir(settingsCache->getDeckPath()).exists() || !QDir(settingsCache->getPicsPath()).exists()) {
|
||||||
|
DlgSettings dlgSettings;
|
||||||
|
dlgSettings.show();
|
||||||
|
app.exec();
|
||||||
|
startMainProgram = (db->getLoadSuccess() && QDir(settingsCache->getDeckPath()).exists() && QDir(settingsCache->getPicsPath()).exists());
|
||||||
|
}
|
||||||
|
|
||||||
QIcon icon(":/resources/icon.svg");
|
if (startMainProgram) {
|
||||||
ui.setWindowIcon(icon);
|
MainWindow ui;
|
||||||
|
qDebug("main(): MainWindow constructor finished");
|
||||||
ui.show();
|
|
||||||
qDebug("main(): ui.show() finished");
|
QIcon icon(":/resources/appicon.svg");
|
||||||
|
ui.setWindowIcon(icon);
|
||||||
int retval = app.exec();
|
|
||||||
|
ui.show();
|
||||||
|
qDebug("main(): ui.show() finished");
|
||||||
|
|
||||||
|
app.exec();
|
||||||
|
}
|
||||||
|
|
||||||
delete pingPixmapGenerator;
|
delete pingPixmapGenerator;
|
||||||
delete db;
|
delete db;
|
||||||
delete settingsCache;
|
delete settingsCache;
|
||||||
|
|
||||||
return retval;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -564,32 +564,54 @@
|
||||||
<context>
|
<context>
|
||||||
<name>DlgSettings</name>
|
<name>DlgSettings</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="459"/>
|
<location filename="../src/dlg_settings.cpp" line="460"/>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="463"/>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="466"/>
|
||||||
|
<source>Error</source>
|
||||||
|
<translation>Fehler</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="460"/>
|
||||||
|
<source>Your card database is invalid. Please check if the path is set correctly.</source>
|
||||||
|
<translation>Ihre Kartendatenbank ist ungültig. Bitte überprüfen Sie, ob der Pfad korrekt gesetzt ist.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="463"/>
|
||||||
|
<source>The path to your deck directory is invalid.</source>
|
||||||
|
<translation>Der Pfad zum Deckverzeichnis ist ungültig.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="466"/>
|
||||||
|
<source>The path to your card pictures directory is invalid.</source>
|
||||||
|
<translation>Der Pfad zum Kartenbilderverzeichnis ist ungültig.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="474"/>
|
||||||
<source>Settings</source>
|
<source>Settings</source>
|
||||||
<translation>Einstellungen</translation>
|
<translation>Einstellungen</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="461"/>
|
<location filename="../src/dlg_settings.cpp" line="476"/>
|
||||||
<source>General</source>
|
<source>General</source>
|
||||||
<translation>Allgemeines</translation>
|
<translation>Allgemeines</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="462"/>
|
<location filename="../src/dlg_settings.cpp" line="477"/>
|
||||||
<source>Appearance</source>
|
<source>Appearance</source>
|
||||||
<translation>Erscheinungsbild</translation>
|
<translation>Erscheinungsbild</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="463"/>
|
<location filename="../src/dlg_settings.cpp" line="478"/>
|
||||||
<source>User interface</source>
|
<source>User interface</source>
|
||||||
<translation>Bedienung</translation>
|
<translation>Bedienung</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="464"/>
|
<location filename="../src/dlg_settings.cpp" line="479"/>
|
||||||
<source>Messages</source>
|
<source>Messages</source>
|
||||||
<translation>Nachrichten</translation>
|
<translation>Nachrichten</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="466"/>
|
<location filename="../src/dlg_settings.cpp" line="481"/>
|
||||||
<source>&Close</source>
|
<source>&Close</source>
|
||||||
<translation>S&chließen</translation>
|
<translation>S&chließen</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -2237,17 +2259,17 @@
|
||||||
<translation>Deck</translation>
|
<translation>Deck</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/playerlistwidget.cpp" line="51"/>
|
<location filename="../src/playerlistwidget.cpp" line="52"/>
|
||||||
<source>no deck</source>
|
<source>no deck</source>
|
||||||
<translation>kein Deck</translation>
|
<translation>kein Deck</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/playerlistwidget.cpp" line="52"/>
|
<location filename="../src/playerlistwidget.cpp" line="53"/>
|
||||||
<source>local deck</source>
|
<source>local deck</source>
|
||||||
<translation>lokales Deck</translation>
|
<translation>lokales Deck</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/playerlistwidget.cpp" line="53"/>
|
<location filename="../src/playerlistwidget.cpp" line="54"/>
|
||||||
<source>ID #%1</source>
|
<source>ID #%1</source>
|
||||||
<translation>ID #%1</translation>
|
<translation>ID #%1</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -2770,17 +2792,17 @@ Willst du die Änderungen speichern?</translation>
|
||||||
<translation type="obsolete">alphabetisch sortieren</translation>
|
<translation type="obsolete">alphabetisch sortieren</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/zoneviewwidget.cpp" line="70"/>
|
<location filename="../src/zoneviewwidget.cpp" line="71"/>
|
||||||
<source>sort by name</source>
|
<source>sort by name</source>
|
||||||
<translation>nach Namen sortieren</translation>
|
<translation>nach Namen sortieren</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/zoneviewwidget.cpp" line="72"/>
|
<location filename="../src/zoneviewwidget.cpp" line="73"/>
|
||||||
<source>sort by type</source>
|
<source>sort by type</source>
|
||||||
<translation>nach Kartentypen sortieren</translation>
|
<translation>nach Kartentypen sortieren</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/zoneviewwidget.cpp" line="74"/>
|
<location filename="../src/zoneviewwidget.cpp" line="75"/>
|
||||||
<source>shuffle when closing</source>
|
<source>shuffle when closing</source>
|
||||||
<translation>beim Schließen mischen</translation>
|
<translation>beim Schließen mischen</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -453,32 +453,54 @@
|
||||||
<context>
|
<context>
|
||||||
<name>DlgSettings</name>
|
<name>DlgSettings</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="459"/>
|
<location filename="../src/dlg_settings.cpp" line="460"/>
|
||||||
<source>Settings</source>
|
<location filename="../src/dlg_settings.cpp" line="463"/>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="466"/>
|
||||||
|
<source>Error</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="461"/>
|
<location filename="../src/dlg_settings.cpp" line="460"/>
|
||||||
<source>General</source>
|
<source>Your card database is invalid. Please check if the path is set correctly.</source>
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/dlg_settings.cpp" line="462"/>
|
|
||||||
<source>Appearance</source>
|
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="463"/>
|
<location filename="../src/dlg_settings.cpp" line="463"/>
|
||||||
<source>User interface</source>
|
<source>The path to your deck directory is invalid.</source>
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/dlg_settings.cpp" line="464"/>
|
|
||||||
<source>Messages</source>
|
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/dlg_settings.cpp" line="466"/>
|
<location filename="../src/dlg_settings.cpp" line="466"/>
|
||||||
|
<source>The path to your card pictures directory is invalid.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="474"/>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="476"/>
|
||||||
|
<source>General</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="477"/>
|
||||||
|
<source>Appearance</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="478"/>
|
||||||
|
<source>User interface</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="479"/>
|
||||||
|
<source>Messages</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/dlg_settings.cpp" line="481"/>
|
||||||
<source>&Close</source>
|
<source>&Close</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -1516,17 +1538,17 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/playerlistwidget.cpp" line="51"/>
|
<location filename="../src/playerlistwidget.cpp" line="52"/>
|
||||||
<source>no deck</source>
|
<source>no deck</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/playerlistwidget.cpp" line="52"/>
|
<location filename="../src/playerlistwidget.cpp" line="53"/>
|
||||||
<source>local deck</source>
|
<source>local deck</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/playerlistwidget.cpp" line="53"/>
|
<location filename="../src/playerlistwidget.cpp" line="54"/>
|
||||||
<source>ID #%1</source>
|
<source>ID #%1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -1992,17 +2014,17 @@ Do you want to save the changes?</source>
|
||||||
<context>
|
<context>
|
||||||
<name>ZoneViewWidget</name>
|
<name>ZoneViewWidget</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/zoneviewwidget.cpp" line="70"/>
|
<location filename="../src/zoneviewwidget.cpp" line="71"/>
|
||||||
<source>sort by name</source>
|
<source>sort by name</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/zoneviewwidget.cpp" line="72"/>
|
<location filename="../src/zoneviewwidget.cpp" line="73"/>
|
||||||
<source>sort by type</source>
|
<source>sort by type</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/zoneviewwidget.cpp" line="74"/>
|
<location filename="../src/zoneviewwidget.cpp" line="75"/>
|
||||||
<source>shuffle when closing</source>
|
<source>shuffle when closing</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
68
nsis/cockatrice.nsi
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
!include "MUI2.nsh"
|
||||||
|
|
||||||
|
Name "Cockatrice"
|
||||||
|
OutFile "cockatrice_win32.exe"
|
||||||
|
SetCompressor lzma
|
||||||
|
InstallDir "$PROGRAMFILES\Cockatrice"
|
||||||
|
|
||||||
|
!define MUI_ABORTWARNING
|
||||||
|
!define MUI_WELCOMEFINISHPAGE_BITMAP "leftimage.bmp"
|
||||||
|
!define MUI_HEADERIMAGE
|
||||||
|
!define MUI_HEADERIMAGE_BITMAP "headerimage.bmp"
|
||||||
|
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Cockatrice.$\r$\n$\r$\nClick Next to continue."
|
||||||
|
!define MUI_FINISHPAGE_RUN "$INSTDIR/oracle.exe"
|
||||||
|
!define MUI_FINISHPAGE_RUN_TEXT "Run card database downloader now"
|
||||||
|
!define MUI_FINISHPAGE_RUN_PARAMETERS "-dlsets"
|
||||||
|
|
||||||
|
!insertmacro MUI_PAGE_WELCOME
|
||||||
|
!insertmacro MUI_PAGE_COMPONENTS
|
||||||
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
|
!insertmacro MUI_PAGE_FINISH
|
||||||
|
|
||||||
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
|
Section "Application" SecApplication
|
||||||
|
SetOutPath "$INSTDIR"
|
||||||
|
File ..\cockatrice\release\cockatrice.exe
|
||||||
|
File ..\oracle\release\oracle.exe
|
||||||
|
File data\libgcc_s_dw2-1.dll
|
||||||
|
File data\mingwm10.dll
|
||||||
|
File data\QtCore4.dll
|
||||||
|
File data\QtGui4.dll
|
||||||
|
File data\QtNetwork4.dll
|
||||||
|
File data\QtSvg4.dll
|
||||||
|
File data\QtXml4.dll
|
||||||
|
|
||||||
|
SetOutPath "$INSTDIR\zonebg"
|
||||||
|
File /r ..\zonebg\*.*
|
||||||
|
|
||||||
|
SetOutPath "$INSTDIR\plugins"
|
||||||
|
File /r data\plugins\*.*
|
||||||
|
|
||||||
|
SetOutPath "$INSTDIR\pics"
|
||||||
|
SetOutPath "$INSTDIR\decks"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "Update configuration" SecUpdateConfig
|
||||||
|
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$INSTDIR\cards.xml"
|
||||||
|
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$INSTDIR\decks"
|
||||||
|
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$INSTDIR\pics"
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "Start menu item" SecStartMenu
|
||||||
|
createDirectory "$SMPROGRAMS\Cockatrice"
|
||||||
|
createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe"
|
||||||
|
createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe"
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
LangString DESC_SecApplication ${LANG_ENGLISH} "Cockatrice program files"
|
||||||
|
LangString DESC_SecUpdateConfig ${LANG_ENGLISH} "Update the paths in the application settings according to the installation paths."
|
||||||
|
LangString DESC_SecStartMenu ${LANG_ENGLISH} "Create start menu items for Cockatrice and Oracle."
|
||||||
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecApplication} $(DESC_SecApplication)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecUpdateConfig} $(DESC_SecUpdateConfig)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(DESC_SecStartMenu)
|
||||||
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||||
|
|
BIN
nsis/headerimage.bmp
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
nsis/leftimage.bmp
Normal file
After Width: | Height: | Size: 201 KiB |
|
@ -7,7 +7,15 @@
|
||||||
OracleImporter::OracleImporter(const QString &_dataDir, QObject *parent)
|
OracleImporter::OracleImporter(const QString &_dataDir, QObject *parent)
|
||||||
: CardDatabase(parent), dataDir(_dataDir), setIndex(-1)
|
: CardDatabase(parent), dataDir(_dataDir), setIndex(-1)
|
||||||
{
|
{
|
||||||
QString fileName = dataDir + "/sets.xml";
|
buffer = new QBuffer(this);
|
||||||
|
http = new QHttp(this);
|
||||||
|
connect(http, SIGNAL(requestFinished(int, bool)), this, SLOT(httpRequestFinished(int, bool)));
|
||||||
|
connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)), this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
|
||||||
|
connect(http, SIGNAL(dataReadProgress(int, int)), this, SIGNAL(dataReadProgress(int, int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OracleImporter::readSetsFromFile(const QString &fileName)
|
||||||
|
{
|
||||||
QFile setsFile(fileName);
|
QFile setsFile(fileName);
|
||||||
if (!setsFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!setsFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
QMessageBox::critical(0, tr("Error"), tr("Cannot open file '%1'.").arg(fileName));
|
QMessageBox::critical(0, tr("Error"), tr("Cannot open file '%1'.").arg(fileName));
|
||||||
|
@ -15,6 +23,19 @@ OracleImporter::OracleImporter(const QString &_dataDir, QObject *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
QXmlStreamReader xml(&setsFile);
|
QXmlStreamReader xml(&setsFile);
|
||||||
|
readSetsFromXml(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OracleImporter::readSetsFromByteArray(const QByteArray &data)
|
||||||
|
{
|
||||||
|
QXmlStreamReader xml(data);
|
||||||
|
readSetsFromXml(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OracleImporter::readSetsFromXml(QXmlStreamReader &xml)
|
||||||
|
{
|
||||||
|
allSets.clear();
|
||||||
|
|
||||||
QString edition;
|
QString edition;
|
||||||
QString editionLong;
|
QString editionLong;
|
||||||
QString editionURL;
|
QString editionURL;
|
||||||
|
@ -34,19 +55,13 @@ OracleImporter::OracleImporter(const QString &_dataDir, QObject *parent)
|
||||||
else if (xml.name() == "url")
|
else if (xml.name() == "url")
|
||||||
editionURL = xml.readElementText();
|
editionURL = xml.readElementText();
|
||||||
}
|
}
|
||||||
setsToDownload << SetToDownload(edition, editionLong, editionURL, import);
|
allSets << SetToDownload(edition, editionLong, editionURL, import);
|
||||||
edition = editionLong = editionURL = QString();
|
edition = editionLong = editionURL = QString();
|
||||||
} else if (xml.name() == "picture_url")
|
} else if (xml.name() == "picture_url")
|
||||||
pictureUrl = xml.readElementText();
|
pictureUrl = xml.readElementText();
|
||||||
else if (xml.name() == "set_url")
|
else if (xml.name() == "set_url")
|
||||||
setUrl = xml.readElementText();
|
setUrl = xml.readElementText();
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = new QBuffer(this);
|
|
||||||
http = new QHttp(this);
|
|
||||||
connect(http, SIGNAL(requestFinished(int, bool)), this, SLOT(httpRequestFinished(int, bool)));
|
|
||||||
connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)), this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
|
|
||||||
connect(http, SIGNAL(dataReadProgress(int, int)), this, SIGNAL(dataReadProgress(int, int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CardInfo *OracleImporter::addCard(QString cardName, const QString &cardCost, const QString &cardType, const QString &cardPT, const QStringList &cardText)
|
CardInfo *OracleImporter::addCard(QString cardName, const QString &cardCost, const QString &cardType, const QString &cardPT, const QStringList &cardText)
|
||||||
|
@ -188,19 +203,24 @@ QString OracleImporter::getURLFromName(QString name) const
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OracleImporter::startDownload()
|
||||||
|
{
|
||||||
|
setsToDownload.clear();
|
||||||
|
for (int i = 0; i < allSets.size(); ++i)
|
||||||
|
if (allSets[i].getImport())
|
||||||
|
setsToDownload.append(allSets[i]);
|
||||||
|
|
||||||
|
if (setsToDownload.isEmpty())
|
||||||
|
return 0;
|
||||||
|
setIndex = 0;
|
||||||
|
emit setIndexChanged(0, 0, setsToDownload[0].getLongName());
|
||||||
|
|
||||||
|
downloadNextFile();
|
||||||
|
return setsToDownload.size();
|
||||||
|
}
|
||||||
|
|
||||||
void OracleImporter::downloadNextFile()
|
void OracleImporter::downloadNextFile()
|
||||||
{
|
{
|
||||||
if (setIndex == -1) {
|
|
||||||
for (int i = 0; i < setsToDownload.size(); ++i)
|
|
||||||
if (!setsToDownload[i].getImport()) {
|
|
||||||
setsToDownload.removeAt(i);
|
|
||||||
--i;
|
|
||||||
}
|
|
||||||
if (setsToDownload.isEmpty())
|
|
||||||
return;
|
|
||||||
setIndex = 0;
|
|
||||||
emit setIndexChanged(0, 0, setsToDownload[0].getLongName());
|
|
||||||
}
|
|
||||||
QString urlString = setsToDownload[setIndex].getUrl();
|
QString urlString = setsToDownload[setIndex].getUrl();
|
||||||
if (urlString.isEmpty())
|
if (urlString.isEmpty())
|
||||||
urlString = setUrl;
|
urlString = setUrl;
|
||||||
|
@ -245,9 +265,9 @@ void OracleImporter::httpRequestFinished(int requestId, bool error)
|
||||||
++setIndex;
|
++setIndex;
|
||||||
|
|
||||||
if (setIndex == setsToDownload.size()) {
|
if (setIndex == setsToDownload.size()) {
|
||||||
setIndex = -1;
|
|
||||||
saveToFile(dataDir + "/cards.xml");
|
saveToFile(dataDir + "/cards.xml");
|
||||||
emit setIndexChanged(cards, setIndex, QString());
|
emit setIndexChanged(cards, setIndex, QString());
|
||||||
|
setIndex = -1;
|
||||||
} else {
|
} else {
|
||||||
downloadNextFile();
|
downloadNextFile();
|
||||||
emit setIndexChanged(cards, setIndex, setsToDownload[setIndex].getLongName());
|
emit setIndexChanged(cards, setIndex, setsToDownload[setIndex].getLongName());
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QHttp>
|
#include <QHttp>
|
||||||
|
|
||||||
class QBuffer;
|
class QBuffer;
|
||||||
|
class QXmlStreamReader;
|
||||||
|
|
||||||
class SetToDownload {
|
class SetToDownload {
|
||||||
private:
|
private:
|
||||||
|
@ -15,7 +16,7 @@ public:
|
||||||
const QString &getLongName() const { return longName; }
|
const QString &getLongName() const { return longName; }
|
||||||
const QString &getUrl() const { return url; }
|
const QString &getUrl() const { return url; }
|
||||||
bool getImport() const { return import; }
|
bool getImport() const { return import; }
|
||||||
void setImport(bool _import) { qDebug(QString("%1: setting import to %2").arg(getShortName()).arg(_import).toUtf8()); import = _import; }
|
void setImport(bool _import) { import = _import; }
|
||||||
SetToDownload(const QString &_shortName, const QString &_longName, const QString &_url, bool _import)
|
SetToDownload(const QString &_shortName, const QString &_longName, const QString &_url, bool _import)
|
||||||
: shortName(_shortName), longName(_longName), url(_url), import(_import) { }
|
: shortName(_shortName), longName(_longName), url(_url), import(_import) { }
|
||||||
};
|
};
|
||||||
|
@ -23,7 +24,7 @@ public:
|
||||||
class OracleImporter : public CardDatabase {
|
class OracleImporter : public CardDatabase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QList<SetToDownload> setsToDownload;
|
QList<SetToDownload> allSets, setsToDownload;
|
||||||
QString pictureUrl, setUrl;
|
QString pictureUrl, setUrl;
|
||||||
QString dataDir;
|
QString dataDir;
|
||||||
int setIndex;
|
int setIndex;
|
||||||
|
@ -32,6 +33,8 @@ private:
|
||||||
QHttp *http;
|
QHttp *http;
|
||||||
QString getURLFromName(QString name) const;
|
QString getURLFromName(QString name) const;
|
||||||
|
|
||||||
|
void downloadNextFile();
|
||||||
|
void readSetsFromXml(QXmlStreamReader &xml);
|
||||||
CardInfo *addCard(QString cardName, const QString &cardCost, const QString &cardType, const QString &cardPT, const QStringList &cardText);
|
CardInfo *addCard(QString cardName, const QString &cardCost, const QString &cardType, const QString &cardPT, const QStringList &cardText);
|
||||||
private slots:
|
private slots:
|
||||||
void httpRequestFinished(int requestId, bool error);
|
void httpRequestFinished(int requestId, bool error);
|
||||||
|
@ -41,10 +44,11 @@ signals:
|
||||||
void dataReadProgress(int bytesRead, int totalBytes);
|
void dataReadProgress(int bytesRead, int totalBytes);
|
||||||
public:
|
public:
|
||||||
OracleImporter(const QString &_dataDir, QObject *parent = 0);
|
OracleImporter(const QString &_dataDir, QObject *parent = 0);
|
||||||
|
void readSetsFromByteArray(const QByteArray &data);
|
||||||
|
void readSetsFromFile(const QString &fileName);
|
||||||
|
int startDownload();
|
||||||
int importTextSpoiler(CardSet *set, const QByteArray &data);
|
int importTextSpoiler(CardSet *set, const QByteArray &data);
|
||||||
void downloadNextFile();
|
QList<SetToDownload> &getSets() { return allSets; }
|
||||||
int getSetsCount() const { return setsToDownload.size(); }
|
|
||||||
QList<SetToDownload> &getSets() { return setsToDownload; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
#include "window_main.h"
|
#include "window_main.h"
|
||||||
#include "oracleimporter.h"
|
#include "oracleimporter.h"
|
||||||
|
|
||||||
|
const QString WindowMain::defaultSetsUrl = QString("http://www.cockatrice.de/files/sets.xml");
|
||||||
|
|
||||||
WindowMain::WindowMain(QWidget *parent)
|
WindowMain::WindowMain(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
importer = new OracleImporter(qApp->applicationDirPath() + "/../oracle", this);
|
importer = new OracleImporter(qApp->applicationDirPath(), this);
|
||||||
|
nam = new QNetworkAccessManager(this);
|
||||||
|
|
||||||
QVBoxLayout *checkboxLayout = new QVBoxLayout;
|
checkBoxLayout = new QVBoxLayout;
|
||||||
QList<SetToDownload> &sets = importer->getSets();
|
|
||||||
for (int i = 0; i < sets.size(); ++i) {
|
|
||||||
QCheckBox *checkBox = new QCheckBox(sets[i].getLongName());
|
|
||||||
checkBox->setChecked(sets[i].getImport());
|
|
||||||
connect(checkBox, SIGNAL(stateChanged(int)), this, SLOT(checkBoxChanged(int)));
|
|
||||||
checkboxLayout->addWidget(checkBox);
|
|
||||||
checkBoxList << checkBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *checkboxFrame = new QWidget;
|
QWidget *checkboxFrame = new QWidget;
|
||||||
checkboxFrame->setLayout(checkboxLayout);
|
checkboxFrame->setLayout(checkBoxLayout);
|
||||||
|
|
||||||
QScrollArea *checkboxArea = new QScrollArea;
|
QScrollArea *checkboxArea = new QScrollArea;
|
||||||
checkboxArea->setWidget(checkboxFrame);
|
checkboxArea->setWidget(checkboxFrame);
|
||||||
|
@ -61,10 +58,76 @@ WindowMain::WindowMain(QWidget *parent)
|
||||||
|
|
||||||
connect(importer, SIGNAL(setIndexChanged(int, int, const QString &)), this, SLOT(updateTotalProgress(int, int, const QString &)));
|
connect(importer, SIGNAL(setIndexChanged(int, int, const QString &)), this, SLOT(updateTotalProgress(int, int, const QString &)));
|
||||||
connect(importer, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateFileProgress(int, int)));
|
connect(importer, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateFileProgress(int, int)));
|
||||||
totalProgressBar->setMaximum(importer->getSetsCount());
|
|
||||||
|
aLoadSetsFile = new QAction(tr("Load sets information from &file..."), this);
|
||||||
|
connect(aLoadSetsFile, SIGNAL(triggered()), this, SLOT(actLoadSetsFile()));
|
||||||
|
aDownloadSetsFile = new QAction(tr("&Download sets information..."), this);
|
||||||
|
connect(aDownloadSetsFile, SIGNAL(triggered()), this, SLOT(actDownloadSetsFile()));
|
||||||
|
aExit = new QAction(tr("E&xit"), this);
|
||||||
|
connect(aExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||||
|
|
||||||
|
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||||
|
fileMenu->addAction(aLoadSetsFile);
|
||||||
|
fileMenu->addAction(aDownloadSetsFile);
|
||||||
|
fileMenu->addSeparator();
|
||||||
|
fileMenu->addAction(aExit);
|
||||||
|
|
||||||
setWindowTitle(tr("Oracle importer"));
|
setWindowTitle(tr("Oracle importer"));
|
||||||
setFixedSize(500, 300);
|
setFixedSize(600, 500);
|
||||||
|
|
||||||
|
QStringList args = qApp->arguments();
|
||||||
|
if (args.contains("-dlsets"))
|
||||||
|
downloadSetsFile(defaultSetsUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowMain::updateSetList()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < checkBoxList.size(); ++i)
|
||||||
|
delete checkBoxList[i];
|
||||||
|
checkBoxList.clear();
|
||||||
|
|
||||||
|
QList<SetToDownload> &sets = importer->getSets();
|
||||||
|
for (int i = 0; i < sets.size(); ++i) {
|
||||||
|
QCheckBox *checkBox = new QCheckBox(sets[i].getLongName());
|
||||||
|
checkBox->setChecked(sets[i].getImport());
|
||||||
|
connect(checkBox, SIGNAL(stateChanged(int)), this, SLOT(checkBoxChanged(int)));
|
||||||
|
checkBoxLayout->addWidget(checkBox);
|
||||||
|
checkBoxList << checkBox;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowMain::actLoadSetsFile()
|
||||||
|
{
|
||||||
|
QFileDialog dialog(this, tr("Load sets file"));
|
||||||
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
|
dialog.setNameFilter("Sets XML file (*.xml)");
|
||||||
|
if (!dialog.exec())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString fileName = dialog.selectedFiles().at(0);
|
||||||
|
importer->readSetsFromFile(fileName);
|
||||||
|
updateSetList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowMain::actDownloadSetsFile()
|
||||||
|
{
|
||||||
|
QString url = QInputDialog::getText(this, tr("Load sets from URL"), tr("Please enter the URL of the sets file:"), QLineEdit::Normal, defaultSetsUrl);
|
||||||
|
if (!url.isEmpty())
|
||||||
|
downloadSetsFile(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowMain::downloadSetsFile(const QString &url)
|
||||||
|
{
|
||||||
|
QNetworkReply *reply = nam->get(QNetworkRequest(url));
|
||||||
|
connect(reply, SIGNAL(finished()), this, SLOT(setsDownloadFinished()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowMain::setsDownloadFinished()
|
||||||
|
{
|
||||||
|
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
|
||||||
|
importer->readSetsFromByteArray(reply->readAll());
|
||||||
|
reply->deleteLater();
|
||||||
|
updateSetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowMain::updateTotalProgress(int cardsImported, int setIndex, const QString &nextSetName)
|
void WindowMain::updateTotalProgress(int cardsImported, int setIndex, const QString &nextSetName)
|
||||||
|
@ -91,7 +154,8 @@ void WindowMain::actStart()
|
||||||
startButton->setEnabled(false);
|
startButton->setEnabled(false);
|
||||||
for (int i = 0; i < checkBoxList.size(); ++i)
|
for (int i = 0; i < checkBoxList.size(); ++i)
|
||||||
checkBoxList[i]->setEnabled(false);
|
checkBoxList[i]->setEnabled(false);
|
||||||
importer->downloadNextFile();
|
int setsCount = importer->startDownload();
|
||||||
|
totalProgressBar->setMaximum(setsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowMain::checkBoxChanged(int state)
|
void WindowMain::checkBoxChanged(int state)
|
||||||
|
|
|
@ -10,21 +10,37 @@ class QProgressBar;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
class QVBoxLayout;
|
||||||
|
class QMenu;
|
||||||
|
class QAction;
|
||||||
|
class QNetworkAccessManager;
|
||||||
|
|
||||||
class WindowMain : public QMainWindow {
|
class WindowMain : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
OracleImporter *importer;
|
static const QString defaultSetsUrl;
|
||||||
|
|
||||||
|
OracleImporter *importer;
|
||||||
|
QNetworkAccessManager *nam;
|
||||||
|
|
||||||
|
QMenu *fileMenu;
|
||||||
|
QAction *aLoadSetsFile, *aDownloadSetsFile, *aExit;
|
||||||
QPushButton *startButton;
|
QPushButton *startButton;
|
||||||
QLabel *totalLabel, *fileLabel, *nextSetLabel1, *nextSetLabel2;
|
QLabel *totalLabel, *fileLabel, *nextSetLabel1, *nextSetLabel2;
|
||||||
QProgressBar *totalProgressBar, *fileProgressBar;
|
QProgressBar *totalProgressBar, *fileProgressBar;
|
||||||
QTextEdit *messageLog;
|
QTextEdit *messageLog;
|
||||||
|
QVBoxLayout *checkBoxLayout;
|
||||||
QList<QCheckBox *> checkBoxList;
|
QList<QCheckBox *> checkBoxList;
|
||||||
|
|
||||||
|
void downloadSetsFile(const QString &url);
|
||||||
private slots:
|
private slots:
|
||||||
void updateTotalProgress(int cardsImported, int setIndex, const QString &nextSetName);
|
void updateTotalProgress(int cardsImported, int setIndex, const QString &nextSetName);
|
||||||
void updateFileProgress(int bytesRead, int totalBytes);
|
void updateFileProgress(int bytesRead, int totalBytes);
|
||||||
|
void updateSetList();
|
||||||
void actStart();
|
void actStart();
|
||||||
|
void actLoadSetsFile();
|
||||||
|
void actDownloadSetsFile();
|
||||||
|
void setsDownloadFinished();
|
||||||
void checkBoxChanged(int state);
|
void checkBoxChanged(int state);
|
||||||
public:
|
public:
|
||||||
WindowMain(QWidget *parent = 0);
|
WindowMain(QWidget *parent = 0);
|
||||||
|
|