Updated reveal zone check boxes
I saw in some images from other platforms it can take up alot of space. Made the boxed horizontal, rather than vertical. WIP Remade reveal zone + darkened card area to eaisily see boundries + reverted back to using a window + window can be resized + removed fake title bar and "X" + moved all cards revealed slightly to the right, makes it easier to drag-select from the left Cleanup Changed style to use cockatrice icon Changed cast from static_cast to qstyleoption_cast
This commit is contained in:
parent
cf24f4aa04
commit
1e0c4cbf87
3 changed files with 20 additions and 26 deletions
|
@ -7,6 +7,8 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QStyleOptionTitleBar>
|
||||||
#include "zoneviewwidget.h"
|
#include "zoneviewwidget.h"
|
||||||
#include "carditem.h"
|
#include "carditem.h"
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
|
@ -57,28 +59,14 @@ void TitleLabel::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, bool _writeableRevealZone, const QList<const ServerInfo_Card *> &cardList)
|
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, bool _writeableRevealZone, const QList<const ServerInfo_Card *> &cardList)
|
||||||
: QGraphicsWidget(0, Qt::Tool | Qt::FramelessWindowHint), canBeShuffled(_origZone->getIsShufflable()), player(_player)
|
: QGraphicsWidget(0, Qt::Window), canBeShuffled(_origZone->getIsShufflable()), player(_player)
|
||||||
{
|
{
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
setZValue(2000000006);
|
setZValue(2000000006);
|
||||||
setFlag(ItemIgnoresTransformations);
|
setFlag(ItemIgnoresTransformations);
|
||||||
|
|
||||||
QGraphicsLinearLayout *hbox = new QGraphicsLinearLayout(Qt::Horizontal);
|
|
||||||
titleLabel = new TitleLabel;
|
|
||||||
connect(titleLabel, SIGNAL(mouseMoved(QPointF)), this, SLOT(moveWidget(QPointF)));
|
|
||||||
closeButton = new QPushButton("X");
|
|
||||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
|
||||||
closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
||||||
QGraphicsProxyWidget *closeButtonProxy = new QGraphicsProxyWidget;
|
|
||||||
closeButtonProxy->setWidget(closeButton);
|
|
||||||
|
|
||||||
hbox->addItem(titleLabel);
|
|
||||||
hbox->addItem(closeButtonProxy);
|
|
||||||
QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
|
QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
|
||||||
|
|
||||||
vbox->addItem(hbox);
|
|
||||||
|
|
||||||
QGraphicsLinearLayout *hPilebox = 0;
|
QGraphicsLinearLayout *hPilebox = 0;
|
||||||
|
|
||||||
if (numberCards < 0) {
|
if (numberCards < 0) {
|
||||||
|
@ -179,19 +167,13 @@ void ZoneViewWidget::processSetPileView(int value) {
|
||||||
|
|
||||||
void ZoneViewWidget::retranslateUi()
|
void ZoneViewWidget::retranslateUi()
|
||||||
{
|
{
|
||||||
titleLabel->setText(zone->getTranslatedName(false, CaseNominative));
|
setWindowTitle(zone->getTranslatedName(false, CaseNominative));
|
||||||
sortByNameCheckBox.setText(tr("sort by name"));
|
sortByNameCheckBox.setText(tr("sort by name"));
|
||||||
sortByTypeCheckBox.setText(tr("sort by type"));
|
sortByTypeCheckBox.setText(tr("sort by type"));
|
||||||
shuffleCheckBox.setText(tr("shuffle when closing"));
|
shuffleCheckBox.setText(tr("shuffle when closing"));
|
||||||
pileViewCheckBox.setText(tr("pile view"));
|
pileViewCheckBox.setText(tr("pile view"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
|
||||||
{
|
|
||||||
painter->fillRect(boundingRect(), palette().color(QPalette::Window));
|
|
||||||
QGraphicsWidget::paint(painter, option, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZoneViewWidget::moveWidget(QPointF scenePos)
|
void ZoneViewWidget::moveWidget(QPointF scenePos)
|
||||||
{
|
{
|
||||||
if(scenePos.x() < 0)
|
if(scenePos.x() < 0)
|
||||||
|
@ -264,3 +246,9 @@ void ZoneViewWidget::zoneDeleted()
|
||||||
emit closePressed(this);
|
emit closePressed(this);
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneViewWidget::initStyleOption(QStyleOption *option) const {
|
||||||
|
QStyleOptionTitleBar *titleBar = qstyleoption_cast<QStyleOptionTitleBar *>(option);
|
||||||
|
if (titleBar)
|
||||||
|
titleBar->icon = QIcon(":/resources/appicon.svg");
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class GameScene;
|
||||||
class ServerInfo_Card;
|
class ServerInfo_Card;
|
||||||
class QGraphicsSceneMouseEvent;
|
class QGraphicsSceneMouseEvent;
|
||||||
class QGraphicsSceneWheelEvent;
|
class QGraphicsSceneWheelEvent;
|
||||||
|
class QStyleOption;
|
||||||
|
|
||||||
class TitleLabel : public QGraphicsWidget {
|
class TitleLabel : public QGraphicsWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -68,7 +69,7 @@ public:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void initStyleOption(QStyleOption *option) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGraphicsSceneWheelEvent>
|
#include <QGraphicsSceneWheelEvent>
|
||||||
|
#include <QBrush>
|
||||||
|
#include <QPainter>
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "carddragitem.h"
|
#include "carddragitem.h"
|
||||||
|
@ -32,8 +34,11 @@ QRectF ZoneViewZone::boundingRect() const
|
||||||
return bRect;
|
return bRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewZone::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
void ZoneViewZone::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||||
{
|
{
|
||||||
|
QBrush windowBrush(QColor(240,240,240));
|
||||||
|
windowBrush.setColor(windowBrush.color().darker(150));
|
||||||
|
painter->fillRect(boundingRect(), windowBrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewZone::initializeCards(const QList<const ServerInfo_Card *> &cardList)
|
void ZoneViewZone::initializeCards(const QList<const ServerInfo_Card *> &cardList)
|
||||||
|
@ -123,7 +128,7 @@ void ZoneViewZone::reorganizeCards()
|
||||||
}
|
}
|
||||||
|
|
||||||
lastCardType = cardType;
|
lastCardType = cardType;
|
||||||
qreal x = typeColumn * CARD_WIDTH;
|
qreal x = 7 + (typeColumn * CARD_WIDTH);
|
||||||
qreal y = typeRow * CARD_HEIGHT / 3;
|
qreal y = typeRow * CARD_HEIGHT / 3;
|
||||||
c->setPos(x + 5, y + 5);
|
c->setPos(x + 5, y + 5);
|
||||||
c->setRealZValue(i);
|
c->setRealZValue(i);
|
||||||
|
@ -132,7 +137,7 @@ void ZoneViewZone::reorganizeCards()
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < cardCount; i++) {
|
for (int i = 0; i < cardCount; i++) {
|
||||||
CardItem *c = cardsToDisplay.at(i);
|
CardItem *c = cardsToDisplay.at(i);
|
||||||
qreal x = (i / rows) * CARD_WIDTH;
|
qreal x = 7 + ((i / rows) * CARD_WIDTH);
|
||||||
qreal y = (i % rows) * CARD_HEIGHT / 3;
|
qreal y = (i % rows) * CARD_HEIGHT / 3;
|
||||||
c->setPos(x + 5, y + 5);
|
c->setPos(x + 5, y + 5);
|
||||||
c->setRealZValue(i);
|
c->setRealZValue(i);
|
||||||
|
|
Loading…
Reference in a new issue