mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-26 04:40:50 -08:00
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:
@@ -7,6 +7,8 @@
|
||||
#include <QPainter>
|
||||
#include <QPalette>
|
||||
#include <QScrollBar>
|
||||
#include <QStyleOption>
|
||||
#include <QStyleOptionTitleBar>
|
||||
#include "zoneviewwidget.h"
|
||||
#include "carditem.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)
|
||||
: QGraphicsWidget(0, Qt::Tool | Qt::FramelessWindowHint), canBeShuffled(_origZone->getIsShufflable()), player(_player)
|
||||
: QGraphicsWidget(0, Qt::Window), canBeShuffled(_origZone->getIsShufflable()), player(_player)
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setZValue(2000000006);
|
||||
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);
|
||||
|
||||
vbox->addItem(hbox);
|
||||
|
||||
QGraphicsLinearLayout *hPilebox = 0;
|
||||
|
||||
if (numberCards < 0) {
|
||||
@@ -179,19 +167,13 @@ void ZoneViewWidget::processSetPileView(int value) {
|
||||
|
||||
void ZoneViewWidget::retranslateUi()
|
||||
{
|
||||
titleLabel->setText(zone->getTranslatedName(false, CaseNominative));
|
||||
setWindowTitle(zone->getTranslatedName(false, CaseNominative));
|
||||
sortByNameCheckBox.setText(tr("sort by name"));
|
||||
sortByTypeCheckBox.setText(tr("sort by type"));
|
||||
shuffleCheckBox.setText(tr("shuffle when closing"));
|
||||
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)
|
||||
{
|
||||
if(scenePos.x() < 0)
|
||||
@@ -264,3 +246,9 @@ void ZoneViewWidget::zoneDeleted()
|
||||
emit closePressed(this);
|
||||
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 QGraphicsSceneMouseEvent;
|
||||
class QGraphicsSceneWheelEvent;
|
||||
class QStyleOption;
|
||||
|
||||
class TitleLabel : public QGraphicsWidget {
|
||||
Q_OBJECT
|
||||
@@ -68,7 +69,7 @@ public:
|
||||
void retranslateUi();
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void initStyleOption(QStyleOption *option) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <math.h>
|
||||
#include <QDebug>
|
||||
#include <QGraphicsSceneWheelEvent>
|
||||
#include <QBrush>
|
||||
#include <QPainter>
|
||||
#include "zoneviewzone.h"
|
||||
#include "player.h"
|
||||
#include "carddragitem.h"
|
||||
@@ -32,8 +34,11 @@ QRectF ZoneViewZone::boundingRect() const
|
||||
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)
|
||||
@@ -123,7 +128,7 @@ void ZoneViewZone::reorganizeCards()
|
||||
}
|
||||
|
||||
lastCardType = cardType;
|
||||
qreal x = typeColumn * CARD_WIDTH;
|
||||
qreal x = 7 + (typeColumn * CARD_WIDTH);
|
||||
qreal y = typeRow * CARD_HEIGHT / 3;
|
||||
c->setPos(x + 5, y + 5);
|
||||
c->setRealZValue(i);
|
||||
@@ -132,7 +137,7 @@ void ZoneViewZone::reorganizeCards()
|
||||
} else {
|
||||
for (int i = 0; i < cardCount; 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;
|
||||
c->setPos(x + 5, y + 5);
|
||||
c->setRealZValue(i);
|
||||
|
||||
Reference in New Issue
Block a user