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 <QGraphicsSceneMouseEvent>
#include <cmath>
#include <algorithm>
#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);

View file

@ -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()

View file

@ -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();

View file

@ -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);
}

View file

@ -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;