Left hand justification

Set to false by default, let me know if you think it should be true.

As all cards are played to the left of the screen this feels more
comfortable to use as you dont need to keep looking at different areas
of the screen.

Will auto rearrange when changed during game-play.
This commit is contained in:
Matt Lowe 2015-04-02 12:49:06 +02:00
parent fb49a8867e
commit a082fbcfef
6 changed files with 27 additions and 5 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -77,6 +77,14 @@ SettingsCache::SettingsCache()
scaleCards = settings->value("cards/scaleCards", true).toBool(); scaleCards = settings->value("cards/scaleCards", true).toBool();
showMessagePopups = settings->value("chat/showmessagepopups", true).toBool(); showMessagePopups = settings->value("chat/showmessagepopups", true).toBool();
showMentionPopups = settings->value("chat/showmentionpopups", 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) { void SettingsCache::setCardScaling(const int _scaleCards) {

View file

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