diff --git a/cockatrice/src/abstractcarditem.cpp b/cockatrice/src/abstractcarditem.cpp index e2e19881..8f6b4023 100644 --- a/cockatrice/src/abstractcarditem.cpp +++ b/cockatrice/src/abstractcarditem.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #ifdef _WIN32 #include "round.h" #endif /* _WIN32 */ @@ -66,6 +67,9 @@ QSizeF AbstractCardItem::getTranslatedSize(QPainter *painter) const void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &translatedSize, int angle) { + const int MAX_FONT_SIZE = settingsCache->getMaxFontSize(); + const int fontSize = std::max(9, MAX_FONT_SIZE); + QRectF totalBoundingRect = painter->combinedTransform().mapRect(boundingRect()); painter->resetTransform(); @@ -77,9 +81,6 @@ void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &transla painter->setTransform(pixmapTransform); QFont f; - int fontSize = round(translatedSize.height() / 8); - if (fontSize < 9) - fontSize = 9; f.setPixelSize(fontSize); painter->setFont(f); diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 0bb33552..b992ec4c 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -351,11 +351,19 @@ AppearanceSettingsPage::AppearanceSettingsPage() minPlayersForMultiColumnLayoutEdit.setValue(settingsCache->getMinPlayersForMultiColumnLayout()); connect(&minPlayersForMultiColumnLayoutEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setMinPlayersForMultiColumnLayout(int))); minPlayersForMultiColumnLayoutLabel.setBuddy(&minPlayersForMultiColumnLayoutEdit); - + + maxFontSizeForCardsEdit.setMinimum(9); + maxFontSizeForCardsEdit.setMaximum(100); + maxFontSizeForCardsEdit.setValue(settingsCache->getMaxFontSize()); + connect(&maxFontSizeForCardsEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setMaxFontSize(int))); + maxFontSizeForCardsLabel.setBuddy(&maxFontSizeForCardsEdit); + QGridLayout *tableGrid = new QGridLayout; tableGrid->addWidget(&invertVerticalCoordinateCheckBox, 0, 0, 1, 2); tableGrid->addWidget(&minPlayersForMultiColumnLayoutLabel, 1, 0, 1, 1); tableGrid->addWidget(&minPlayersForMultiColumnLayoutEdit, 1, 1, 1, 1); + tableGrid->addWidget(&maxFontSizeForCardsLabel, 2, 0, 1, 1); + tableGrid->addWidget(&maxFontSizeForCardsEdit, 2, 1, 1, 1); tableGroupBox = new QGroupBox; tableGroupBox->setLayout(tableGrid); @@ -392,6 +400,7 @@ void AppearanceSettingsPage::retranslateUi() tableGroupBox->setTitle(tr("Table grid layout")); invertVerticalCoordinateCheckBox.setText(tr("Invert vertical coordinate")); minPlayersForMultiColumnLayoutLabel.setText(tr("Minimum player count for multi-column layout:")); + maxFontSizeForCardsLabel.setText(tr("Maximum font size for information displayed on cards")); } UserInterfaceSettingsPage::UserInterfaceSettingsPage() diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index c331be89..03dba7bd 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -88,6 +88,7 @@ private: QLabel themeLabel; QComboBox themeBox; QLabel minPlayersForMultiColumnLayoutLabel; + QLabel maxFontSizeForCardsLabel; QCheckBox displayCardNamesCheckBox; QCheckBox cardScalingCheckBox; QCheckBox horizontalHandCheckBox; @@ -98,6 +99,7 @@ private: QGroupBox *handGroupBox; QGroupBox *tableGroupBox; QSpinBox minPlayersForMultiColumnLayoutEdit; + QSpinBox maxFontSizeForCardsEdit; public: AppearanceSettingsPage(); void retranslateUi(); diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index ab4a608d..d54e58ea 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -658,3 +658,9 @@ void SettingsCache::setUpdateReleaseChannel(int _updateReleaseChannel) updateReleaseChannel = _updateReleaseChannel; settings->setValue("personal/updatereleasechannel", updateReleaseChannel); } + +void SettingsCache::setMaxFontSize(int _max) +{ + maxFontSize = _max; + settings->setValue("game/maxfontsize", maxFontSize); +} \ No newline at end of file diff --git a/cockatrice/src/settingscache.h b/cockatrice/src/settingscache.h index dbc16d87..6a825e88 100644 --- a/cockatrice/src/settingscache.h +++ b/cockatrice/src/settingscache.h @@ -61,6 +61,7 @@ private: QString deckPath, replaysPath, picsPath, customPicsPath, cardDatabasePath, customCardDatabasePath, tokenDatabasePath, themeName; bool notifyAboutUpdates; int updateReleaseChannel; + int maxFontSize; bool picDownload; bool notificationsEnabled; bool spectatorNotificationsEnabled; @@ -187,6 +188,7 @@ public: bool getSpectatorsCanSeeEverything() const { return spectatorsCanSeeEverything; } bool getRememberGameSettings() const { return rememberGameSettings; } int getKeepAlive() const { return keepalive; } + int getMaxFontSize() const { return (maxFontSize > 1) ? maxFontSize : 9; } void setClientID(QString clientID); void setKnownMissingFeatures(QString _knownMissingFeatures); QString getClientID() { return clientID; } @@ -256,6 +258,7 @@ public slots: void setRememberGameSettings(const bool _rememberGameSettings); void setNotifyAboutUpdate(int _notifyaboutupdate); void setUpdateReleaseChannel(int _updateReleaseChannel); + void setMaxFontSize(int _max); }; extern SettingsCache *settingsCache;