Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
df834183
Commit
df834183
authored
May 07, 2015
by
poixen
Browse files
Merge pull request #1053 from poixen/reveal_makeover
Updated reveal zone
parents
433412de
1e0c4cbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/zoneviewwidget.cpp
View file @
df834183
...
...
@@ -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
::
Frameless
Window
Hint
),
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"
);
}
cockatrice/src/zoneviewwidget.h
View file @
df834183
...
...
@@ -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
cockatrice/src/zoneviewzone.cpp
View file @
df834183
#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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment