diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index a9939468..2d1bc248 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -124,21 +124,22 @@ QPixmap *CardInfo::loadPixmap() return pixmap; if (getName().isEmpty()) { - pixmap->load(QString("%1/back.jpg").arg(picsPath)); + pixmap->load(settingsCache->getCardBackPicturePath()); return pixmap; } - sets.sortByKey(); + SetList sortedSets = sets; + sortedSets.sortByKey(); QString debugOutput = QString("CardDatabase: loading pixmap for '%1' from ").arg(getName()); - for (int i = 0; i < sets.size(); i++) - debugOutput.append(QString("%1, ").arg(sets[i]->getShortName())); + for (int i = 0; i < sortedSets.size(); i++) + debugOutput.append(QString("%1, ").arg(sortedSets[i]->getShortName())); qDebug(debugOutput.toLatin1()); QString correctedName = getCorrectedName(); - for (int i = 0; i < sets.size(); i++) { - if (pixmap->load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg(sets[i]->getShortName()).arg(correctedName))) + for (int i = 0; i < sortedSets.size(); i++) { + if (pixmap->load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg(sortedSets[i]->getShortName()).arg(correctedName))) return pixmap; - if (pixmap->load(QString("%1/%2/%3%4.full.jpg").arg(picsPath).arg(sets[i]->getShortName()).arg(correctedName).arg(1))) + if (pixmap->load(QString("%1/%2/%3%4.full.jpg").arg(picsPath).arg(sortedSets[i]->getShortName()).arg(correctedName).arg(1))) return pixmap; } if (pixmap->load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg("downloadedPics").arg(correctedName))) @@ -245,6 +246,7 @@ CardDatabase::CardDatabase(QObject *parent) noCard = new CardInfo(this); noCard->loadPixmap(); // cache pixmap for card back + connect(settingsCache, SIGNAL(cardBackPicturePathChanged()), noCard, SLOT(updatePixmapCache())); } CardDatabase::~CardDatabase() diff --git a/cockatrice/src/carddatabase.h b/cockatrice/src/carddatabase.h index ecb36f09..16822a8e 100644 --- a/cockatrice/src/carddatabase.h +++ b/cockatrice/src/carddatabase.h @@ -85,6 +85,7 @@ public: QPixmap *getPixmap(QSize size); void clearPixmapCache(); void clearPixmapCacheMiss(); +public slots: void updatePixmapCache(); signals: void pixmapUpdated(); diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index c140e307..d7365adb 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -67,14 +67,6 @@ GeneralSettingsPage::GeneralSettingsPage() QPushButton *cardDatabasePathButton = new QPushButton("..."); connect(cardDatabasePathButton, SIGNAL(clicked()), this, SLOT(cardDatabasePathButtonClicked())); - /* - cardBackgroundPathLabel = new QLabel; - cardBackgroundPathEdit = new QLineEdit(settings.value("cardbackground").toString()); - cardBackgroundPathEdit->setReadOnly(true); - QPushButton *cardBackgroundPathButton = new QPushButton("..."); - connect(cardBackgroundPathButton, SIGNAL(clicked()), this, SLOT(cardBackgroundPathButtonClicked())); - */ - QGridLayout *pathsGrid = new QGridLayout; pathsGrid->addWidget(deckPathLabel, 0, 0); pathsGrid->addWidget(deckPathEdit, 0, 1); @@ -85,11 +77,6 @@ GeneralSettingsPage::GeneralSettingsPage() pathsGrid->addWidget(cardDatabasePathLabel, 2, 0); pathsGrid->addWidget(cardDatabasePathEdit, 2, 1); pathsGrid->addWidget(cardDatabasePathButton, 2, 2); - /* - pathsGrid->addWidget(cardBackgroundPathLabel, 3, 0); - pathsGrid->addWidget(cardBackgroundPathEdit, 3, 1); - pathsGrid->addWidget(cardBackgroundPathButton, 3, 2); - */ pathsGroupBox = new QGroupBox; pathsGroupBox->setLayout(pathsGrid); @@ -146,19 +133,6 @@ void GeneralSettingsPage::cardDatabasePathButtonClicked() settingsCache->setCardDatabasePath(path); } -void GeneralSettingsPage::cardBackgroundPathButtonClicked() -{ - QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); - if (path.isEmpty()) - return; - QSettings settings; - settings.beginGroup("paths"); - settings.setValue("cardbackground", path); - cardBackgroundPathEdit->setText(path); - - emit cardBackgroundPathChanged(path); -} - void GeneralSettingsPage::languageBoxChanged(int index) { settingsCache->setLang(languageBox->itemData(index).toString()); @@ -173,7 +147,6 @@ void GeneralSettingsPage::retranslateUi() deckPathLabel->setText(tr("Decks directory:")); picsPathLabel->setText(tr("Pictures directory:")); cardDatabasePathLabel->setText(tr("Path to card database:")); - //cardBackgroundPathLabel->setText(tr("Path to card background:")); } AppearanceSettingsPage::AppearanceSettingsPage() @@ -196,6 +169,12 @@ AppearanceSettingsPage::AppearanceSettingsPage() QPushButton *playerAreaBgButton = new QPushButton("..."); connect(playerAreaBgButton, SIGNAL(clicked()), this, SLOT(playerAreaBgButtonClicked())); + cardBackPicturePathLabel = new QLabel; + cardBackPicturePathEdit = new QLineEdit(settingsCache->getCardBackPicturePath()); + cardBackPicturePathEdit->setReadOnly(true); + QPushButton *cardBackPicturePathButton = new QPushButton("..."); + connect(cardBackPicturePathButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathButtonClicked())); + QGridLayout *zoneBgGrid = new QGridLayout; zoneBgGrid->addWidget(handBgLabel, 0, 0); zoneBgGrid->addWidget(handBgEdit, 0, 1); @@ -206,6 +185,9 @@ AppearanceSettingsPage::AppearanceSettingsPage() zoneBgGrid->addWidget(playerAreaBgLabel, 2, 0); zoneBgGrid->addWidget(playerAreaBgEdit, 2, 1); zoneBgGrid->addWidget(playerAreaBgButton, 2, 2); + zoneBgGrid->addWidget(cardBackPicturePathLabel, 3, 0); + zoneBgGrid->addWidget(cardBackPicturePathEdit, 3, 1); + zoneBgGrid->addWidget(cardBackPicturePathButton, 3, 2); zoneBgGroupBox = new QGroupBox; zoneBgGroupBox->setLayout(zoneBgGrid); @@ -260,6 +242,7 @@ void AppearanceSettingsPage::retranslateUi() handBgLabel->setText(tr("Path to hand background:")); tableBgLabel->setText(tr("Path to table background:")); playerAreaBgLabel->setText(tr("Path to player info background:")); + cardBackPicturePathLabel->setText(tr("Path to picture of card back:")); handGroupBox->setTitle(tr("Hand layout")); horizontalHandCheckBox->setText(tr("Display hand horizontally (wastes space)")); @@ -302,6 +285,16 @@ void AppearanceSettingsPage::playerAreaBgButtonClicked() settingsCache->setPlayerBgPath(path); } +void AppearanceSettingsPage::cardBackPicturePathButtonClicked() +{ + QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); + if (path.isEmpty()) + return; + + cardBackPicturePathEdit->setText(path); + settingsCache->setCardBackPicturePath(path); +} + UserInterfaceSettingsPage::UserInterfaceSettingsPage() { doubleClickToPlayCheckBox = new QCheckBox; @@ -422,7 +415,6 @@ DlgSettings::DlgSettings(QWidget *parent) QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(hboxLayout); - //mainLayout->addStretch(1); mainLayout->addSpacing(12); mainLayout->addLayout(buttonsLayout); setLayout(mainLayout); diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index ad1f6be1..b8575fb9 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -29,22 +29,20 @@ private slots: void deckPathButtonClicked(); void picsPathButtonClicked(); void cardDatabasePathButtonClicked(); - void cardBackgroundPathButtonClicked(); void languageBoxChanged(int index); signals: void picsPathChanged(const QString &path); void cardDatabasePathChanged(const QString &path); - void cardBackgroundPathChanged(const QString &path); void changeLanguage(const QString &qmFile); void picDownloadChanged(int state); private: QStringList findQmFiles(); QString languageName(const QString &qmFile); - QLineEdit *deckPathEdit, *picsPathEdit, *cardDatabasePathEdit, *cardBackgroundPathEdit; + QLineEdit *deckPathEdit, *picsPathEdit, *cardDatabasePathEdit; QGroupBox *personalGroupBox, *pathsGroupBox; QComboBox *languageBox; QCheckBox *picDownloadCheckBox; - QLabel *languageLabel, *deckPathLabel, *picsPathLabel, *cardDatabasePathLabel, *cardBackgroundPathLabel; + QLabel *languageLabel, *deckPathLabel, *picsPathLabel, *cardDatabasePathLabel; }; class AppearanceSettingsPage : public AbstractSettingsPage { @@ -53,13 +51,15 @@ private slots: void handBgButtonClicked(); void tableBgButtonClicked(); void playerAreaBgButtonClicked(); + void cardBackPicturePathButtonClicked(); signals: void handBgChanged(const QString &path); void tableBgChanged(const QString &path); void playerAreaBgChanged(const QString &path); + void cardBackPicturePathChanged(const QString &path); private: - QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel; - QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit; + QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel, *cardBackPicturePathLabel; + QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit, *cardBackPicturePathEdit; QCheckBox *horizontalHandCheckBox, *economicGridCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox; QGroupBox *zoneBgGroupBox, *handGroupBox, *tableGroupBox, *zoneViewGroupBox; public: diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index 8f9fbb0e..3d291f7e 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -14,6 +14,7 @@ SettingsCache::SettingsCache() handBgPath = settings->value("zonebg/hand").toString(); tableBgPath = settings->value("zonebg/table").toString(); playerBgPath = settings->value("zonebg/playerarea").toString(); + cardBackPicturePath = settings->value("paths/cardbackpicture").toString(); picDownload = settings->value("personal/picturedownload", false).toBool(); doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool(); @@ -72,6 +73,13 @@ void SettingsCache::setPlayerBgPath(const QString &_playerBgPath) emit playerBgPathChanged(); } +void SettingsCache::setCardBackPicturePath(const QString &_cardBackPicturePath) +{ + cardBackPicturePath = _cardBackPicturePath; + settings->setValue("paths/cardbackpicture", cardBackPicturePath); + emit cardBackPicturePathChanged(); +} + void SettingsCache::setPicDownload(int _picDownload) { picDownload = _picDownload; diff --git a/cockatrice/src/settingscache.h b/cockatrice/src/settingscache.h index 319f036d..d501d44b 100644 --- a/cockatrice/src/settingscache.h +++ b/cockatrice/src/settingscache.h @@ -14,6 +14,7 @@ signals: void handBgPathChanged(); void tableBgPathChanged(); void playerBgPathChanged(); + void cardBackPicturePathChanged(); void picDownloadChanged(); void horizontalHandChanged(); void economicGridChanged(); @@ -22,7 +23,7 @@ private: QString lang; QString deckPath, picsPath, cardDatabasePath; - QString handBgPath, tableBgPath, playerBgPath; + QString handBgPath, tableBgPath, playerBgPath, cardBackPicturePath; bool picDownload; bool doubleClickToPlay; bool horizontalHand; @@ -37,6 +38,7 @@ public: QString getHandBgPath() const { return handBgPath; } QString getTableBgPath() const { return tableBgPath; } QString getPlayerBgPath() const { return playerBgPath; } + QString getCardBackPicturePath() const { return cardBackPicturePath; } bool getPicDownload() const { return picDownload; } bool getDoubleClickToPlay() const { return doubleClickToPlay; } bool getHorizontalHand() const { return horizontalHand; } @@ -51,6 +53,7 @@ public slots: void setHandBgPath(const QString &_handBgPath); void setTableBgPath(const QString &_tableBgPath); void setPlayerBgPath(const QString &_playerBgPath); + void setCardBackPicturePath(const QString &_cardBackPicturePath); void setPicDownload(int _picDownload); void setDoubleClickToPlay(int _doubleClickToPlay); void setHorizontalHand(int _horizontalHand); diff --git a/cockatrice/translations/cockatrice_de.ts b/cockatrice/translations/cockatrice_de.ts index 973597ad..e7ffe2fe 100644 --- a/cockatrice/translations/cockatrice_de.ts +++ b/cockatrice/translations/cockatrice_de.ts @@ -27,57 +27,62 @@ AppearanceSettingsPage - + Zone background pictures Hintergrundbilder für Kartenzonen - + Path to hand background: Hintergrundbild für die Hand: - + Path to table background: Hintergrundbild für das Spielfeld: - + Path to player info background: Hintergrundbild für den Spielerbereich: - + + Path to picture of card back: + Pfad zum Bild der Kartenrückseite: + + + Hand layout Kartenhand - + Display hand horizontally (wastes space) Hand horizonal anzeigen (verschwendet Platz) - + Table grid layout Spielfeldraster - + Economic layout Platzsparende Anordnung - + Zone view layout Aussehen des Zonenbetrachters - + Sort by name nach Namen sortieren - + Sort by type nach Kartentypen sortieren @@ -86,9 +91,10 @@ standardmäßig alphabetisch sortieren - - - + + + + Choose path Pfad auswählen @@ -843,54 +849,54 @@ DlgSettings - - - + + + Error Fehler - + Your card database is invalid. Please check if the path is set correctly. Ihre Kartendatenbank ist ungültig. Bitte überprüfen Sie, ob der Pfad korrekt gesetzt ist. - + The path to your deck directory is invalid. Der Pfad zum Deckverzeichnis ist ungültig. - + The path to your card pictures directory is invalid. Der Pfad zum Kartenbilderverzeichnis ist ungültig. - + Settings Einstellungen - + General Allgemeines - + Appearance Erscheinungsbild - + User interface Bedienung - + Messages Nachrichten - + &Close S&chließen @@ -1286,51 +1292,50 @@ GeneralSettingsPage - - - - + + + Choose path Pfad auswählen - + Personal settings Persönliche Einstellungen - + Language: Sprache: - + Download card pictures on the fly Kartenbilder dynamisch herunterladen - + Paths Pfade - + Decks directory: Verzeichnis mit Decklisten: - + Pictures directory: Verzeichnis mit Bilddateien: - + Path to card database: Pfad zur Kartendatenbank: - + English Deutsch @@ -2166,12 +2171,12 @@ MessagesSettingsPage - + &Add &Hinzufügen - + &Remove &Entfernen @@ -2184,12 +2189,12 @@ Entfernen - + Add message Nachricht hinzufügen - + Message: Nachricht: @@ -2996,12 +3001,12 @@ Bitte geben Sie einen Namen ein: UserInterfaceSettingsPage - + General interface settings Allgemeine Bedienung - + &Double-click cards to play them (instead of single-click) Karten durch &Doppelklick ausspielen (statt Einzelklick) diff --git a/cockatrice/translations/cockatrice_en.ts b/cockatrice/translations/cockatrice_en.ts index ecd6152f..41cd8323 100644 --- a/cockatrice/translations/cockatrice_en.ts +++ b/cockatrice/translations/cockatrice_en.ts @@ -4,64 +4,70 @@ AppearanceSettingsPage - + Zone background pictures - + Path to hand background: - + Path to table background: - + Path to player info background: - + + Path to picture of card back: + + + + Hand layout - + Display hand horizontally (wastes space) - + Table grid layout - + Economic layout - + Zone view layout - + Sort by name - + Sort by type - - - + + + + Choose path @@ -724,54 +730,54 @@ DlgSettings - - - + + + Error - + Your card database is invalid. Please check if the path is set correctly. - + The path to your deck directory is invalid. - + The path to your card pictures directory is invalid. - + Settings - + General - + Appearance - + User interface - + Messages - + &Close @@ -901,51 +907,50 @@ GeneralSettingsPage - - - - + + + Choose path - + Personal settings - + Language: - + Download card pictures on the fly - + Paths - + Decks directory: - + Pictures directory: - + Path to card database: - + English English @@ -1469,22 +1474,22 @@ MessagesSettingsPage - + &Add - + &Remove - + Add message - + Message: @@ -2087,12 +2092,12 @@ Please enter a name: UserInterfaceSettingsPage - + General interface settings - + &Double-click cards to play them (instead of single-click)