Merge branch 'master' into newsearchbar

This commit is contained in:
Matt Lowe 2014-11-19 22:21:43 +01:00
commit 916735d613
14 changed files with 180 additions and 100 deletions

View file

@ -242,6 +242,13 @@ endif()
if(UNIX)
if(APPLE)
set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME}")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.cockatrice.${PROJECT_NAME}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME}-${PROJECT_VERSION}")
set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
INSTALL(TARGETS cockatrice BUNDLE DESTINATION ./)
INSTALL(FILES ${cockatrice_QM} DESTINATION ./cockatrice.app/Contents/Resources/translations)
else()

View file

@ -101,6 +101,14 @@ QString PictureToLoad::getSetName() const
return QString("");
}
CardSet *PictureToLoad::getCurrentSet() const
{
if (setIndex < sortedSets.size())
return sortedSets[setIndex];
else
return 0;
}
PictureLoader::PictureLoader(const QString &__picsPath, bool _picDownload, bool _picDownloadHq, QObject *parent)
: QObject(parent),
_picsPath(__picsPath), picDownload(_picDownload), picDownloadHq(_picDownloadHq),
@ -134,15 +142,17 @@ void PictureLoader::processLoadQueue()
PictureToLoad ptl = loadQueue.takeFirst();
mutex.unlock();
QString setName = ptl.getSetName();
QString correctedCardname = ptl.getCard()->getCorrectedName();
qDebug() << "Trying to load picture (set: " << setName << " card: " << correctedCardname << ")";
//The list of paths to the folders in which to search for images
QList<QString> picsPaths = QList<QString>() << _picsPath + "/CUSTOM/" + ptl.getCard()->getCorrectedName();
QList<QString> picsPaths = QList<QString>() << _picsPath + "/CUSTOM/" + correctedCardname;
QString setName=ptl.getSetName();
if(!setName.isEmpty())
{
picsPaths << _picsPath + "/" + setName + "/" + ptl.getCard()->getCorrectedName()
<< _picsPath + "/downloadedPics/" + setName + "/" + ptl.getCard()->getCorrectedName();
picsPaths << _picsPath + "/" + setName + "/" + correctedCardname
<< _picsPath + "/downloadedPics/" + setName + "/" + correctedCardname;
}
QImage image;
@ -154,12 +164,14 @@ void PictureLoader::processLoadQueue()
for (int i = 0; i < picsPaths.length() && !found; i ++) {
imgReader.setFileName(picsPaths.at(i));
if (imgReader.read(&image)) {
qDebug() << "Picture found on disk (set: " << setName << " card: " << correctedCardname << ")";
emit imageLoaded(ptl.getCard(), image);
found = true;
break;
}
imgReader.setFileName(picsPaths.at(i) + ".full");
if (imgReader.read(&image)) {
qDebug() << "Picture.full found on disk (set: " << setName << " card: " << correctedCardname << ")";
emit imageLoaded(ptl.getCard(), image);
found = true;
}
@ -167,24 +179,32 @@ void PictureLoader::processLoadQueue()
if (!found) {
if (picDownload) {
qDebug() << "Picture NOT found, trying to download (set: " << setName << " card: " << correctedCardname << ")";
cardsToDownload.append(ptl);
if (!downloadRunning)
startNextPicDownload();
} else {
if (ptl.nextSet())
{
qDebug() << "Picture NOT found and download disabled, moving to next set (newset: " << setName << " card: " << correctedCardname << ")";
mutex.lock();
loadQueue.prepend(ptl);
else
mutex.unlock();
} else {
qDebug() << "Picture NOT found, download disabled, no more sets to try: BAILING OUT (oldset: " << setName << " card: " << correctedCardname << ")";
emit imageLoaded(ptl.getCard(), QImage());
}
}
}
}
}
QString PictureLoader::getPicUrl(CardInfo *card)
QString PictureLoader::getPicUrl()
{
if (!picDownload) return QString("");
CardSet *set = card->getPreferredSet();
CardInfo *card = cardBeingDownloaded.getCard();
CardSet *set=cardBeingDownloaded.getCurrentSet();
QString picUrl = QString("");
// if sets have been defined for the card, they can contain custom picUrls
@ -204,17 +224,19 @@ QString PictureLoader::getPicUrl(CardInfo *card)
return picUrl;
}
// otherwise, fallback to the default url
picUrl = picDownloadHq ? settingsCache->getPicUrlHq() : settingsCache->getPicUrl();
picUrl.replace("!name!", QUrl::toPercentEncoding(card->getCorrectedName()));
// if a card has a muid, use the default url; if not, use the fallback
int muid = set ? muid = card->getMuId(set->getShortName()) : 0;
if(muid)
picUrl = picDownloadHq ? settingsCache->getPicUrlHq() : settingsCache->getPicUrl();
else
picUrl = picDownloadHq ? settingsCache->getPicUrlHqFallback() : settingsCache->getPicUrlFallback();
picUrl.replace("!name!", QUrl::toPercentEncoding(card->getCorrectedName()));
picUrl.replace("!cardid!", QUrl::toPercentEncoding(QString::number(muid)));
if (set) {
picUrl.replace("!setcode!", QUrl::toPercentEncoding(set->getShortName()));
picUrl.replace("!setname!", QUrl::toPercentEncoding(set->getLongName()));
}
int muid = card->getPreferredMuId();
if (muid)
picUrl.replace("!cardid!", QUrl::toPercentEncoding(QString::number(muid)));
if (picUrl.contains("!name!") ||
picUrl.contains("!setcode!") ||
@ -239,19 +261,33 @@ void PictureLoader::startNextPicDownload()
cardBeingDownloaded = cardsToDownload.takeFirst();
QString picUrl = getPicUrl(cardBeingDownloaded.getCard());
QString picUrl = getPicUrl();
if (picUrl.isEmpty()) {
qDebug() << "No url for" << cardBeingDownloaded.getCard()->getName();
cardBeingDownloaded = 0;
downloadRunning = false;
return;
picDownloadFailed();
} else {
QUrl url(picUrl);
QNetworkRequest req(url);
qDebug() << "starting picture download:" << cardBeingDownloaded.getCard()->getName() << "Url:" << req.url();
networkManager->get(req);
}
}
QUrl url(picUrl);
QNetworkRequest req(url);
qDebug() << "starting picture download:" << cardBeingDownloaded.getCard()->getName() << "Url:" << req.url();
networkManager->get(req);
void PictureLoader::picDownloadFailed()
{
if (cardBeingDownloaded.nextSet())
{
qDebug() << "Picture NOT found, download failed, moving to next set (newset: " << cardBeingDownloaded.getSetName() << " card: " << cardBeingDownloaded.getCard()->getCorrectedName() << ")";
mutex.lock();
loadQueue.prepend(cardBeingDownloaded);
mutex.unlock();
emit startLoadQueue();
} else {
qDebug() << "Picture NOT found, download failed, no more sets to try: BAILING OUT (oldset: " << cardBeingDownloaded.getSetName() << " card: " << cardBeingDownloaded.getCard()->getCorrectedName() << ")";
cardBeingDownloaded = 0;
emit imageLoaded(cardBeingDownloaded.getCard(), QImage());
}
}
void PictureLoader::picDownloadFinished(QNetworkReply *reply)
@ -288,21 +324,9 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
}
emit imageLoaded(cardBeingDownloaded.getCard(), testImage);
} else if (cardBeingDownloaded.getHq()) {
qDebug() << "HQ: received invalid picture. URL:" << reply->request().url();
cardBeingDownloaded.setHq(false);
cardsToDownload.prepend(cardBeingDownloaded);
} else {
qDebug() << "LQ: received invalid picture. URL:" << reply->request().url();
if (cardBeingDownloaded.nextSet()) {
cardBeingDownloaded.setHq(true);
mutex.lock();
loadQueue.prepend(cardBeingDownloaded);
mutex.unlock();
emit startLoadQueue();
} else
emit imageLoaded(cardBeingDownloaded.getCard(), QImage());
}
picDownloadFailed();
}
reply->deleteLater();
startNextPicDownload();
@ -497,21 +521,6 @@ void CardInfo::updatePixmapCache()
emit pixmapUpdated();
}
CardSet* CardInfo::getPreferredSet()
{
if(sets.isEmpty())
return 0;
SetList sortedSets = sets;
sortedSets.sortByKey();
return sortedSets.first();
}
int CardInfo::getPreferredMuId()
{
CardSet *set = getPreferredSet();
return set ? muIds[set->getShortName()] : 0;
}
QString CardInfo::simplifyName(const QString &name) {
QString simpleName(name);

View file

@ -53,6 +53,7 @@ private:
public:
PictureToLoad(CardInfo *_card = 0, bool _hq = true);
CardInfo *getCard() const { return card; }
CardSet *getCurrentSet() const;
QString getSetName() const;
bool nextSet();
bool getHq() const { return hq; }
@ -70,7 +71,7 @@ private:
PictureToLoad cardBeingDownloaded;
bool picDownload, picDownloadHq, downloadRunning, loadQueueRunning;
void startNextPicDownload();
QString getPicUrl(CardInfo* card);
QString getPicUrl();
public:
PictureLoader(const QString &__picsPath, bool _picDownload, bool _picDownloadHq, QObject *parent = 0);
~PictureLoader();
@ -80,6 +81,7 @@ public:
void loadImage(CardInfo *card);
private slots:
void picDownloadFinished(QNetworkReply *reply);
void picDownloadFailed();
public slots:
void processLoadQueue();
signals:
@ -163,8 +165,6 @@ public:
void clearPixmapCache();
void clearPixmapCacheMiss();
void imageLoaded(const QImage &image);
CardSet *getPreferredSet();
int getPreferredMuId();
/**
* Simplify a name to have no punctuation and lowercase all letters, for

View file

@ -56,7 +56,12 @@ void DlgCreateGame::sharedCtor()
onlyBuddiesCheckBox = new QCheckBox(tr("Only &buddies can join"));
onlyRegisteredCheckBox = new QCheckBox(tr("Only &registered users can join"));
if (room && room->getUserInfo()->user_level() & ServerInfo_User::IsRegistered)
{
onlyRegisteredCheckBox->setChecked(true);
} else {
onlyBuddiesCheckBox->setEnabled(false);
onlyRegisteredCheckBox->setEnabled(false);
}
QGridLayout *joinRestrictionsLayout = new QGridLayout;
joinRestrictionsLayout->addWidget(passwordLabel, 0, 0);

View file

@ -25,6 +25,8 @@ SettingsCache::SettingsCache()
picDownloadHq = settings->value("personal/picturedownloadhq", false).toBool();
picUrl = settings->value("personal/picUrl", PIC_URL_DEFAULT).toString();
picUrlHq = settings->value("personal/picUrlHq", PIC_URL_HQ_DEFAULT).toString();
picUrlFallback = settings->value("personal/picUrlFallback", PIC_URL_FALLBACK).toString();
picUrlHqFallback = settings->value("personal/picUrlHqFallback", PIC_URL_HQ_FALLBACK).toString();
mainWindowGeometry = settings->value("interface/main_window_geometry").toByteArray();
notificationsEnabled = settings->value("interface/notificationsenabled", true).toBool();
@ -153,6 +155,18 @@ void SettingsCache::setPicUrlHq(const QString &_picUrlHq)
settings->setValue("personal/picUrlHq", picUrlHq);
}
void SettingsCache::setPicUrlFallback(const QString &_picUrlFallback)
{
picUrlFallback = _picUrlFallback;
settings->setValue("personal/picUrlFallback", picUrlFallback);
}
void SettingsCache::setPicUrlHqFallback(const QString &_picUrlHqFallback)
{
picUrlHqFallback = _picUrlHqFallback;
settings->setValue("personal/picUrlHqFallback", picUrlHqFallback);
}
void SettingsCache::setNotificationsEnabled(int _notificationsEnabled)
{
notificationsEnabled = _notificationsEnabled;

View file

@ -4,7 +4,9 @@
#include <QObject>
#define PIC_URL_DEFAULT "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=card"
#define PIC_URL_FALLBACK "http://mtgimage.com/set/!setcode!/!name!.jpg"
#define PIC_URL_HQ_DEFAULT "http://mtgimage.com/multiverseid/!cardid!.jpg"
#define PIC_URL_HQ_FALLBACK "http://mtgimage.com/set/!setcode!/!name!.jpg"
class QSettings;
@ -57,6 +59,8 @@ private:
bool ignoreUnregisteredUsers;
QString picUrl;
QString picUrlHq;
QString picUrlFallback;
QString picUrlHqFallback;
bool attemptAutoConnect;
public:
SettingsCache();
@ -93,6 +97,8 @@ public:
bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; }
QString getPicUrl() const { return picUrl; }
QString getPicUrlHq() const { return picUrlHq; }
QString getPicUrlFallback() const { return picUrlFallback; }
QString getPicUrlHqFallback() const { return picUrlHqFallback; }
void copyPath(const QString &src, const QString &dst);
bool getAutoConnect() const { return attemptAutoConnect; }
public slots:
@ -129,6 +135,8 @@ public slots:
void setIgnoreUnregisteredUsers(bool _ignoreUnregisteredUsers);
void setPicUrl(const QString &_picUrl);
void setPicUrlHq(const QString &_picUrlHq);
void setPicUrlFallback(const QString &_picUrlFallback);
void setPicUrlHqFallback(const QString &_picUrlHqFallback);
void setAutoConnect(const bool &_autoConnect);
};

View file

@ -365,7 +365,7 @@ void TabDeckEditor::updateCardInfoRight(const QModelIndex &current, const QModel
void TabDeckEditor::updateSearch(const QString &search)
{
databaseDisplayModel->setCardNameBeginning(search);
databaseDisplayModel->setCardName(search);
QModelIndexList sel = databaseView->selectionModel()->selectedRows();
if (sel.isEmpty() && databaseDisplayModel->rowCount())
databaseView->selectionModel()->setCurrentIndex(databaseDisplayModel->index(0, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);

View file

@ -43,48 +43,48 @@
</message>
<message>
<source>Path to hand background:</source>
<translation type="obsolete">Chemin pour les images de fond de main:</translation>
<translation>Chemin vers l&apos;image de fond de la zone de main:</translation>
</message>
<message>
<source>Path to stack background:</source>
<translation type="obsolete">Chemin pour les images de fond de pile:</translation>
<translation>Chemin vers l&apos;image de fond de la pile:</translation>
</message>
<message>
<source>Path to table background:</source>
<translation type="obsolete">Chemin pour les images d&apos;arrière-plan:</translation>
<translation>Chemin vers l&apos;image de fond de la zone de jeu:</translation>
</message>
<message>
<source>Path to player info background:</source>
<translation type="obsolete">Chemin pour les images de fond d&apos;affichage d&apos;informations:</translation>
<translation>Chemin vers l&apos;image de fond d&apos;informations joueur:</translation>
</message>
<message>
<source>Path to picture of card back:</source>
<translation type="obsolete">Chemin pour les images de dos des cartes:</translation>
</message>
<translation>Chemin vers l&apos;image de dos des cartes:</translation>
</message>
<message>
<location filename="../src/dlg_settings.cpp" line="366"/>
<source>Hand background:</source>
<translation type="unfinished"></translation>
<translation>Image de fond de la zone de main:</translation>
</message>
<message>
<location filename="../src/dlg_settings.cpp" line="367"/>
<source>Stack background:</source>
<translation type="unfinished"></translation>
<translation>Image de fond de la pile:</translation>
</message>
<message>
<location filename="../src/dlg_settings.cpp" line="368"/>
<source>Table background:</source>
<translation type="unfinished"></translation>
<translation>Image de fond de la zone de jeu:</translation>
</message>
<message>
<location filename="../src/dlg_settings.cpp" line="369"/>
<source>Player info background:</source>
<translation type="unfinished"></translation>
<translation>Image de fond de la zone d&apos;informations joueur:</translation>
</message>
<message>
<location filename="../src/dlg_settings.cpp" line="370"/>
<source>Card back:</source>
<translation type="unfinished"></translation>
<translation>Dos de carte:</translation>
</message>
<message>
<location filename="../src/dlg_settings.cpp" line="372"/>
@ -104,7 +104,7 @@
<message>
<location filename="../src/dlg_settings.cpp" line="376"/>
<source>Display hand horizontally (wastes space)</source>
<translation>Montrer la main horizontalement</translation>
<translation>Afficher la main horizontalement (perte d'espace)</translation>
</message>
<message>
<location filename="../src/dlg_settings.cpp" line="378"/>
@ -124,7 +124,7 @@
<message>
<location filename="../src/dlg_settings.cpp" line="382"/>
<source>Zone view layout</source>
<translation>Voir disposition de la zone</translation>
<translation>Disposition de la zone d'aperçu</translation>
</message>
<message>
<location filename="../src/dlg_settings.cpp" line="383"/>
@ -151,60 +151,60 @@
<message>
<source>Please enter the duration of the ban (in minutes).
Enter 0 for an indefinite ban.</source>
<translation type="obsolete">Entrez la durée de temps du ban (en minutes).
Entrez 0 pour une durée illimitée du ban.</translation>
<translation type="obsolete">Entrez la durée de temps de blocage (en minutes).
Entrez 0 pour un blocage permanent.</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="34"/>
<source>ban &amp;user name</source>
<translation type="unfinished"></translation>
<translation>bloquer &amp;nom d&apos;utilisateur</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="37"/>
<source>ban &amp;IP address</source>
<translation type="unfinished"></translation>
<translation>bloquer &amp;adresse IP</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="45"/>
<source>Ban type</source>
<translation type="unfinished"></translation>
<translation>Type du blocage</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="48"/>
<source>&amp;permanent ban</source>
<translation type="unfinished"></translation>
<translation>&amp;blocage permanent</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="49"/>
<source>&amp;temporary ban</source>
<translation type="unfinished"></translation>
<translation>&amp;blocage temporaire</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="52"/>
<source>&amp;Days:</source>
<translation type="unfinished"></translation>
<translation>&amp;Jours:</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="58"/>
<source>&amp;Hours:</source>
<translation type="unfinished"></translation>
<translation>&amp;Heures:</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="64"/>
<source>&amp;Minutes:</source>
<translation type="unfinished"></translation>
<translation>&amp;Minutes:</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="79"/>
<source>Duration of the ban</source>
<translation type="unfinished"></translation>
<translation>Durée du blocage</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="82"/>
<source>Please enter the reason for the ban.
This is only saved for moderators and cannot be seen by the banned person.</source>
<translation>Veuillez expliquer la raison du ban.
Cette information ne sera consultable que par les modérateurs.</translation>
<translation>Veuillez expliquer la raison du blocage.
Cette information sera consultable uniquement par les modérateurs.</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="85"/>
@ -229,12 +229,12 @@ Cette information ne sera consultable que par les modérateurs.</translation>
<message>
<location filename="../src/userlist.cpp" line="115"/>
<source>Error</source>
<translation type="unfinished">Erreur</translation>
<translation>Érreur</translation>
</message>
<message>
<location filename="../src/userlist.cpp" line="115"/>
<source>You have to select a name-based or IP-based ban, or both.</source>
<translation type="unfinished"></translation>
<translation>Vous devez choisir un blocage à partir du nom ou de l&apos;IP, ou des deux.</translation>
</message>
</context>
<context>
@ -369,6 +369,12 @@ Cette information ne sera consultable que par les modérateurs.</translation>
<message>
<source>&amp;Clone</source>
<translation type="obsolete">&amp;Copier une carte</translation>
<translation>&amp;Copier une carte</translation>
</message>
<message>
<location filename="../src/carditem.cpp" line="214"/>
<source>Ctrl+H</source>
<translation>Ctrl+H</translation>
</message>
<message>
<source>&amp;Attach to card...</source>
@ -384,16 +390,16 @@ Cette information ne sera consultable que par les modérateurs.</translation>
</message>
<message>
<source>Set &amp;P/T...</source>
<translation type="obsolete">Fixer &amp;F/E...</translation>
<translation type="obsolete">Définir &amp;F/E...</translation>
</message>
<message>
<source>&amp;Draw arrow...</source>
<translation type="obsolete">&amp;Tracer une flèche...</translation>
</message>
<message>
<location filename="../src/carditem.cpp" line="83"/>
<source>&amp;Power / toughness</source>
<translation>F&amp;orce / Endurance</translation>
<location filename="../src/carditem.cpp" line="219"/>
<source>&amp;Power / Toughness</source>
<translation>&amp;Force / Endurance</translation>
</message>
<message>
<source>&amp;Increase power</source>
@ -445,7 +451,7 @@ Cette information ne sera consultable que par les modérateurs.</translation>
</message>
<message>
<source>Set &amp;power and toughness...</source>
<translation type="obsolete">Fi&amp;xer la force et l&apos;endurance...</translation>
<translation>&amp;finir la force et l&apos;endurance...</translation>
</message>
<message>
<source>Ctrl+P</source>
@ -477,7 +483,7 @@ Cette information ne sera consultable que par les modérateurs.</translation>
</message>
<message>
<source>&amp;Set counters (%1)...</source>
<translation type="obsolete">&amp;Fixer marqueurs (%1)...</translation>
<translation>&amp;Définir marqueurs (%1)...</translation>
</message>
<message>
<source>&amp;top of library</source>
@ -497,7 +503,7 @@ Cette information ne sera consultable que par les modérateurs.</translation>
</message>
<message>
<source>&amp;exile</source>
<translation type="obsolete">&amp;exiler</translation>
<translation>&amp;exile</translation>
</message>
<message>
<location filename="../src/carditem.cpp" line="82"/>
@ -2230,7 +2236,7 @@ Would you like to change your database location setting?</source>
<message>
<location filename="../src/window_main.cpp" line="228"/>
<source>Italian:</source>
<translation type="unfinished"></translation>
<translation>Italien:</translation>
</message>
<message>
<location filename="../src/window_main.cpp" line="235"/>
@ -5714,6 +5720,12 @@ Entrez 0 pour une durée illimitée du ban.</translation>
<translation type="obsolete">&amp;Commentaires:</translation>
</message>
<message>
<location filename="../src/window_deckeditor.cpp" line="118"/>
<source>Hash:</source>
<translation>Empreinte:</translation>
</message>
<message>
<location filename="../src/window_deckeditor.cpp" line="132"/>
<source>&amp;Update prices</source>
<translation type="obsolete">Mettre à &amp;jour les prix</translation>
</message>