allow max font size to be defined by user (#2488)

This commit is contained in:
Zach H 2017-03-19 14:13:20 -04:00 committed by GitHub
parent 1cc50b2793
commit a2a7561613
5 changed files with 25 additions and 4 deletions

View file

@ -3,6 +3,7 @@
#include <QCursor> #include <QCursor>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <cmath> #include <cmath>
#include <algorithm>
#ifdef _WIN32 #ifdef _WIN32
#include "round.h" #include "round.h"
#endif /* _WIN32 */ #endif /* _WIN32 */
@ -66,6 +67,9 @@ QSizeF AbstractCardItem::getTranslatedSize(QPainter *painter) const
void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &translatedSize, int angle) 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()); QRectF totalBoundingRect = painter->combinedTransform().mapRect(boundingRect());
painter->resetTransform(); painter->resetTransform();
@ -77,9 +81,6 @@ void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &transla
painter->setTransform(pixmapTransform); painter->setTransform(pixmapTransform);
QFont f; QFont f;
int fontSize = round(translatedSize.height() / 8);
if (fontSize < 9)
fontSize = 9;
f.setPixelSize(fontSize); f.setPixelSize(fontSize);
painter->setFont(f); painter->setFont(f);

View file

@ -351,11 +351,19 @@ AppearanceSettingsPage::AppearanceSettingsPage()
minPlayersForMultiColumnLayoutEdit.setValue(settingsCache->getMinPlayersForMultiColumnLayout()); minPlayersForMultiColumnLayoutEdit.setValue(settingsCache->getMinPlayersForMultiColumnLayout());
connect(&minPlayersForMultiColumnLayoutEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setMinPlayersForMultiColumnLayout(int))); connect(&minPlayersForMultiColumnLayoutEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setMinPlayersForMultiColumnLayout(int)));
minPlayersForMultiColumnLayoutLabel.setBuddy(&minPlayersForMultiColumnLayoutEdit); 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; QGridLayout *tableGrid = new QGridLayout;
tableGrid->addWidget(&invertVerticalCoordinateCheckBox, 0, 0, 1, 2); tableGrid->addWidget(&invertVerticalCoordinateCheckBox, 0, 0, 1, 2);
tableGrid->addWidget(&minPlayersForMultiColumnLayoutLabel, 1, 0, 1, 1); tableGrid->addWidget(&minPlayersForMultiColumnLayoutLabel, 1, 0, 1, 1);
tableGrid->addWidget(&minPlayersForMultiColumnLayoutEdit, 1, 1, 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 = new QGroupBox;
tableGroupBox->setLayout(tableGrid); tableGroupBox->setLayout(tableGrid);
@ -392,6 +400,7 @@ void AppearanceSettingsPage::retranslateUi()
tableGroupBox->setTitle(tr("Table grid layout")); tableGroupBox->setTitle(tr("Table grid layout"));
invertVerticalCoordinateCheckBox.setText(tr("Invert vertical coordinate")); invertVerticalCoordinateCheckBox.setText(tr("Invert vertical coordinate"));
minPlayersForMultiColumnLayoutLabel.setText(tr("Minimum player count for multi-column layout:")); minPlayersForMultiColumnLayoutLabel.setText(tr("Minimum player count for multi-column layout:"));
maxFontSizeForCardsLabel.setText(tr("Maximum font size for information displayed on cards"));
} }
UserInterfaceSettingsPage::UserInterfaceSettingsPage() UserInterfaceSettingsPage::UserInterfaceSettingsPage()

View file

@ -88,6 +88,7 @@ private:
QLabel themeLabel; QLabel themeLabel;
QComboBox themeBox; QComboBox themeBox;
QLabel minPlayersForMultiColumnLayoutLabel; QLabel minPlayersForMultiColumnLayoutLabel;
QLabel maxFontSizeForCardsLabel;
QCheckBox displayCardNamesCheckBox; QCheckBox displayCardNamesCheckBox;
QCheckBox cardScalingCheckBox; QCheckBox cardScalingCheckBox;
QCheckBox horizontalHandCheckBox; QCheckBox horizontalHandCheckBox;
@ -98,6 +99,7 @@ private:
QGroupBox *handGroupBox; QGroupBox *handGroupBox;
QGroupBox *tableGroupBox; QGroupBox *tableGroupBox;
QSpinBox minPlayersForMultiColumnLayoutEdit; QSpinBox minPlayersForMultiColumnLayoutEdit;
QSpinBox maxFontSizeForCardsEdit;
public: public:
AppearanceSettingsPage(); AppearanceSettingsPage();
void retranslateUi(); void retranslateUi();

View file

@ -658,3 +658,9 @@ void SettingsCache::setUpdateReleaseChannel(int _updateReleaseChannel)
updateReleaseChannel = _updateReleaseChannel; updateReleaseChannel = _updateReleaseChannel;
settings->setValue("personal/updatereleasechannel", updateReleaseChannel); settings->setValue("personal/updatereleasechannel", updateReleaseChannel);
} }
void SettingsCache::setMaxFontSize(int _max)
{
maxFontSize = _max;
settings->setValue("game/maxfontsize", maxFontSize);
}

View file

@ -61,6 +61,7 @@ private:
QString deckPath, replaysPath, picsPath, customPicsPath, cardDatabasePath, customCardDatabasePath, tokenDatabasePath, themeName; QString deckPath, replaysPath, picsPath, customPicsPath, cardDatabasePath, customCardDatabasePath, tokenDatabasePath, themeName;
bool notifyAboutUpdates; bool notifyAboutUpdates;
int updateReleaseChannel; int updateReleaseChannel;
int maxFontSize;
bool picDownload; bool picDownload;
bool notificationsEnabled; bool notificationsEnabled;
bool spectatorNotificationsEnabled; bool spectatorNotificationsEnabled;
@ -187,6 +188,7 @@ public:
bool getSpectatorsCanSeeEverything() const { return spectatorsCanSeeEverything; } bool getSpectatorsCanSeeEverything() const { return spectatorsCanSeeEverything; }
bool getRememberGameSettings() const { return rememberGameSettings; } bool getRememberGameSettings() const { return rememberGameSettings; }
int getKeepAlive() const { return keepalive; } int getKeepAlive() const { return keepalive; }
int getMaxFontSize() const { return (maxFontSize > 1) ? maxFontSize : 9; }
void setClientID(QString clientID); void setClientID(QString clientID);
void setKnownMissingFeatures(QString _knownMissingFeatures); void setKnownMissingFeatures(QString _knownMissingFeatures);
QString getClientID() { return clientID; } QString getClientID() { return clientID; }
@ -256,6 +258,7 @@ public slots:
void setRememberGameSettings(const bool _rememberGameSettings); void setRememberGameSettings(const bool _rememberGameSettings);
void setNotifyAboutUpdate(int _notifyaboutupdate); void setNotifyAboutUpdate(int _notifyaboutupdate);
void setUpdateReleaseChannel(int _updateReleaseChannel); void setUpdateReleaseChannel(int _updateReleaseChannel);
void setMaxFontSize(int _max);
}; };
extern SettingsCache *settingsCache; extern SettingsCache *settingsCache;