Merge pull request #901 from poixen/left_justified_hand

Left hand justification
This commit is contained in:
Zach 2015-04-04 17:45:02 -04:00
commit 8ca2135f08
6 changed files with 27 additions and 5 deletions

View file

@ -309,9 +309,13 @@ AppearanceSettingsPage::AppearanceSettingsPage()
horizontalHandCheckBox.setChecked(settingsCache->getHorizontalHand());
connect(&horizontalHandCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setHorizontalHand(int)));
leftJustifiedHandCheckBox.setChecked(settingsCache->getLeftJustified());
connect(&leftJustifiedHandCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setLeftJustified(int)));
QGridLayout *handGrid = new QGridLayout;
handGrid->addWidget(&horizontalHandCheckBox, 0, 0, 1, 2);
handGrid->addWidget(&leftJustifiedHandCheckBox, 1, 0, 1, 2);
handGroupBox = new QGroupBox;
handGroupBox->setLayout(handGrid);
@ -356,6 +360,7 @@ void AppearanceSettingsPage::retranslateUi()
handGroupBox->setTitle(tr("Hand layout"));
horizontalHandCheckBox.setText(tr("Display hand horizontally (wastes space)"));
leftJustifiedHandCheckBox.setText(tr("Enable left justification"));
tableGroupBox->setTitle(tr("Table grid layout"));
invertVerticalCoordinateCheckBox.setText(tr("Invert vertical coordinate"));

View file

@ -100,6 +100,7 @@ private:
QCheckBox displayCardNamesCheckBox;
QCheckBox cardScalingCheckBox;
QCheckBox horizontalHandCheckBox;
QCheckBox leftJustifiedHandCheckBox;
QCheckBox invertVerticalCoordinateCheckBox;
QGroupBox *zoneBgGroupBox;
QGroupBox *cardsGroupBox;

View file

@ -88,19 +88,22 @@ void HandZone::reorganizeCards()
if (!cards.isEmpty()) {
const int cardCount = cards.size();
if (settingsCache->getHorizontalHand()) {
const int xPadding = 5;
qreal totalWidth = boundingRect().width() - 2 * xPadding;
bool leftJustified = settingsCache->getLeftJustified();
qreal cardWidth = cards.at(0)->boundingRect().width();
const int xPadding = leftJustified ? cardWidth * 1.4 : 5;
qreal totalWidth = leftJustified? boundingRect().width() - (1 * xPadding) - 5 : boundingRect().width() - 2 * xPadding;
for (int i = 0; i < cardCount; i++) {
CardItem *c = cards.at(i);
// If the total width of the cards is smaller than the available width,
// the cards do not need to overlap and are displayed in the center of the area.
if (cardWidth * cardCount > totalWidth)
c->setPos(xPadding + ((qreal) i) * (totalWidth - cardWidth) / (cardCount - 1), 5);
else
c->setPos(xPadding + ((qreal) i) * cardWidth + (totalWidth - cardCount * cardWidth) / 2, 5);
else {
qreal xPosition = leftJustified ? xPadding + ((qreal) i) * cardWidth :
xPadding + ((qreal) i) * cardWidth + (totalWidth - cardCount * cardWidth) / 2;
c->setPos(xPosition, 5);
}
c->setRealZValue(i);
}
} else {

View file

@ -115,6 +115,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
userInfo->CopyFrom(info);
connect(settingsCache, SIGNAL(horizontalHandChanged()), this, SLOT(rearrangeZones()));
connect(settingsCache, SIGNAL(handJustificationChanged()), this, SLOT(rearrangeZones()));
playerArea = new PlayerArea(this);

View file

@ -77,6 +77,14 @@ SettingsCache::SettingsCache()
scaleCards = settings->value("cards/scaleCards", true).toBool();
showMessagePopups = settings->value("chat/showmessagepopups", true).toBool();
showMentionPopups = settings->value("chat/showmentionpopups", true).toBool();
leftJustified = settings->value("interface/leftjustified", false).toBool();
}
void SettingsCache::setLeftJustified(const int _leftJustified) {
leftJustified = _leftJustified;
settings->setValue("interface/leftjustified", leftJustified);
emit handJustificationChanged();
}
void SettingsCache::setCardScaling(const int _scaleCards) {

View file

@ -30,6 +30,7 @@ signals:
void picDownloadHqChanged();
void displayCardNamesChanged();
void horizontalHandChanged();
void handJustificationChanged();
void invertVerticalCoordinateChanged();
void minPlayersForMultiColumnLayoutChanged();
void soundEnabledChanged();
@ -77,6 +78,7 @@ private:
bool scaleCards;
bool showMessagePopups;
bool showMentionPopups;
bool leftJustified;
public:
SettingsCache();
const QByteArray &getMainWindowGeometry() const { return mainWindowGeometry; }
@ -131,6 +133,7 @@ public:
bool getScaleCards() const { return scaleCards; }
bool getShowMessagePopup() const { return showMessagePopups; }
bool getShowMentionPopup() const { return showMentionPopups; }
bool getLeftJustified() const { return leftJustified; }
public slots:
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
void setLang(const QString &_lang);
@ -178,6 +181,7 @@ public slots:
void setCardScaling(const int _scaleCards);
void setShowMessagePopups(const int _showMessagePopups);
void setShowMentionPopups(const int _showMentionPopups);
void setLeftJustified( const int _leftJustified);
};
extern SettingsCache *settingsCache;