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
2543a5b2
Commit
2543a5b2
authored
Oct 14, 2010
by
Max-Wilhelm Bruker
Browse files
card info widget fix
parent
10a92c3e
Changes
5
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/abstractcarditem.cpp
View file @
2543a5b2
...
@@ -184,7 +184,7 @@ void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
...
@@ -184,7 +184,7 @@ void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
if
(
event
->
button
()
==
Qt
::
LeftButton
)
if
(
event
->
button
()
==
Qt
::
LeftButton
)
setCursor
(
Qt
::
ClosedHandCursor
);
setCursor
(
Qt
::
ClosedHandCursor
);
else
if
(
event
->
button
()
==
Qt
::
MidButton
)
{
else
if
(
event
->
button
()
==
Qt
::
MidButton
)
{
infoWidget
=
new
CardInfoWidget
(
false
,
0
,
Qt
::
Widget
|
Qt
::
FramelessWindowHint
|
Qt
::
X11BypassWindowManagerHint
|
Qt
::
WindowStaysOnTopHint
);
infoWidget
=
new
CardInfoWidget
(
CardInfoWidget
::
ModePopUp
,
0
,
Qt
::
Widget
|
Qt
::
FramelessWindowHint
|
Qt
::
X11BypassWindowManagerHint
|
Qt
::
WindowStaysOnTopHint
);
infoWidget
->
setCard
(
this
);
infoWidget
->
setCard
(
this
);
infoWidget
->
move
(
event
->
screenPos
().
x
()
-
infoWidget
->
width
()
/
2
,
event
->
screenPos
().
y
()
-
infoWidget
->
height
()
/
2
);
infoWidget
->
move
(
event
->
screenPos
().
x
()
-
infoWidget
->
width
()
/
2
,
event
->
screenPos
().
y
()
-
infoWidget
->
height
()
/
2
);
infoWidget
->
show
();
infoWidget
->
show
();
...
...
cockatrice/src/cardinfowidget.cpp
View file @
2543a5b2
...
@@ -9,12 +9,10 @@
...
@@ -9,12 +9,10 @@
#include
"main.h"
#include
"main.h"
#include
"settingscache.h"
#include
"settingscache.h"
CardInfoWidget
::
CardInfoWidget
(
bool
showMinimizeButton
,
QWidget
*
parent
,
Qt
::
WindowFlags
flags
)
CardInfoWidget
::
CardInfoWidget
(
ResizeMode
_mode
,
QWidget
*
parent
,
Qt
::
WindowFlags
flags
)
:
QFrame
(
parent
,
flags
),
pixmap
Height
(
pixmapWidth
),
minimized
(
false
),
minimizeButton
(
0
),
info
(
0
)
:
QFrame
(
parent
,
flags
),
pixmap
Width
(
160
),
aspectRatio
((
qreal
)
CARD_HEIGHT
/
(
qreal
)
CARD_WIDTH
),
minimized
(
false
),
mode
(
_mode
),
minimizeButton
(
0
),
info
(
0
)
{
{
pixmapHeight
=
pixmapWidth
*
CARD_HEIGHT
/
CARD_WIDTH
;
if
(
mode
==
ModeGameTab
)
{
if
(
showMinimizeButton
)
{
minimizeButton
=
new
QPushButton
(
QIcon
(
style
()
->
standardIcon
(
QStyle
::
SP_ArrowUp
)),
QString
());
minimizeButton
=
new
QPushButton
(
QIcon
(
style
()
->
standardIcon
(
QStyle
::
SP_ArrowUp
)),
QString
());
connect
(
minimizeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
minimizeClicked
()));
connect
(
minimizeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
minimizeClicked
()));
}
}
...
@@ -51,7 +49,7 @@ CardInfoWidget::CardInfoWidget(bool showMinimizeButton, QWidget *parent, Qt::Win
...
@@ -51,7 +49,7 @@ CardInfoWidget::CardInfoWidget(bool showMinimizeButton, QWidget *parent, Qt::Win
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
int
row
=
0
;
int
row
=
0
;
if
(
showMinimizeButton
)
if
(
mode
==
ModeGameTab
)
grid
->
addWidget
(
minimizeButton
,
row
++
,
1
,
1
,
1
,
Qt
::
AlignRight
);
grid
->
addWidget
(
minimizeButton
,
row
++
,
1
,
1
,
1
,
Qt
::
AlignRight
);
grid
->
addWidget
(
cardPicture
,
row
++
,
0
,
1
,
2
);
grid
->
addWidget
(
cardPicture
,
row
++
,
0
,
1
,
2
);
grid
->
addWidget
(
nameLabel1
,
row
,
0
);
grid
->
addWidget
(
nameLabel1
,
row
,
0
);
...
@@ -71,13 +69,16 @@ CardInfoWidget::CardInfoWidget(bool showMinimizeButton, QWidget *parent, Qt::Win
...
@@ -71,13 +69,16 @@ CardInfoWidget::CardInfoWidget(bool showMinimizeButton, QWidget *parent, Qt::Win
retranslateUi
();
retranslateUi
();
setFrameStyle
(
QFrame
::
Panel
|
QFrame
::
Raised
);
setFrameStyle
(
QFrame
::
Panel
|
QFrame
::
Raised
);
if
(
showMinimizeButton
)
{
if
(
mode
==
ModeGameTab
)
{
textLabel
->
setFixedHeight
(
100
);
textLabel
->
setFixedHeight
(
100
);
setFixedWidth
(
sizeHint
().
width
());
setFixedWidth
(
sizeHint
().
width
());
setMinimized
(
settingsCache
->
getCardInfoMinimized
());
setMinimized
(
settingsCache
->
getCardInfoMinimized
());
}
else
}
else
if
(
mode
==
ModePopUp
)
setFixedWidth
(
350
);
setFixedWidth
(
350
);
setFixedHeight
(
sizeHint
().
height
());
else
setFixedWidth
(
250
);
if
(
mode
!=
ModeDeckEditor
)
setFixedHeight
(
sizeHint
().
height
());
}
}
void
CardInfoWidget
::
minimizeClicked
()
void
CardInfoWidget
::
minimizeClicked
()
...
@@ -134,11 +135,11 @@ void CardInfoWidget::setCard(AbstractCardItem *card)
...
@@ -134,11 +135,11 @@ void CardInfoWidget::setCard(AbstractCardItem *card)
void
CardInfoWidget
::
updatePixmap
()
void
CardInfoWidget
::
updatePixmap
()
{
{
QPixmap
*
resizedPixmap
=
info
->
getPixmap
(
QSize
(
pixmapWidth
,
pixmap
Height
));
QPixmap
*
resizedPixmap
=
info
->
getPixmap
(
QSize
(
pixmapWidth
,
pixmap
Width
*
aspectRatio
));
if
(
resizedPixmap
)
if
(
resizedPixmap
)
cardPicture
->
setPixmap
(
*
resizedPixmap
);
cardPicture
->
setPixmap
(
*
resizedPixmap
);
else
else
cardPicture
->
setPixmap
(
*
(
db
->
getCard
()
->
getPixmap
(
QSize
(
pixmapWidth
,
pixmap
Height
))));
cardPicture
->
setPixmap
(
*
(
db
->
getCard
()
->
getPixmap
(
QSize
(
pixmapWidth
,
pixmap
Width
*
aspectRatio
))));
}
}
void
CardInfoWidget
::
retranslateUi
()
void
CardInfoWidget
::
retranslateUi
()
...
@@ -148,3 +149,11 @@ void CardInfoWidget::retranslateUi()
...
@@ -148,3 +149,11 @@ void CardInfoWidget::retranslateUi()
cardtypeLabel1
->
setText
(
tr
(
"Card type:"
));
cardtypeLabel1
->
setText
(
tr
(
"Card type:"
));
powtoughLabel1
->
setText
(
tr
(
"P / T:"
));
powtoughLabel1
->
setText
(
tr
(
"P / T:"
));
}
}
void
CardInfoWidget
::
resizeEvent
(
QResizeEvent
*
/*event*/
)
{
if
(
mode
==
ModeDeckEditor
)
{
pixmapWidth
=
qMin
(
width
()
*
0.95
,
(
height
()
-
200
)
/
aspectRatio
);
updatePixmap
();
}
}
cockatrice/src/cardinfowidget.h
View file @
2543a5b2
...
@@ -8,13 +8,17 @@ class QTextEdit;
...
@@ -8,13 +8,17 @@ class QTextEdit;
class
QPushButton
;
class
QPushButton
;
class
AbstractCardItem
;
class
AbstractCardItem
;
class
CardInfo
;
class
CardInfo
;
class
QResizeEvent
;
class
CardInfoWidget
:
public
QFrame
{
class
CardInfoWidget
:
public
QFrame
{
Q_OBJECT
Q_OBJECT
public:
enum
ResizeMode
{
ModeDeckEditor
,
ModeGameTab
,
ModePopUp
};
private:
private:
static
const
int
pixmapWidth
=
160
;
int
pixmapWidth
;
int
pixmapHeight
;
qreal
aspectRatio
;
bool
minimized
;
bool
minimized
;
ResizeMode
mode
;
QPushButton
*
minimizeButton
;
QPushButton
*
minimizeButton
;
QLabel
*
cardPicture
;
QLabel
*
cardPicture
;
...
@@ -27,7 +31,7 @@ private:
...
@@ -27,7 +31,7 @@ private:
CardInfo
*
info
;
CardInfo
*
info
;
void
setMinimized
(
bool
_minimized
);
void
setMinimized
(
bool
_minimized
);
public:
public:
CardInfoWidget
(
bool
showMinimizeButton
=
tru
e
,
QWidget
*
parent
=
0
,
Qt
::
WindowFlags
f
=
0
);
CardInfoWidget
(
ResizeMode
_mod
e
,
QWidget
*
parent
=
0
,
Qt
::
WindowFlags
f
=
0
);
void
retranslateUi
();
void
retranslateUi
();
public
slots
:
public
slots
:
void
setCard
(
CardInfo
*
card
);
void
setCard
(
CardInfo
*
card
);
...
@@ -36,6 +40,8 @@ public slots:
...
@@ -36,6 +40,8 @@ public slots:
private
slots
:
private
slots
:
void
updatePixmap
();
void
updatePixmap
();
void
minimizeClicked
();
void
minimizeClicked
();
protected:
void
resizeEvent
(
QResizeEvent
*
event
);
};
};
#endif
#endif
cockatrice/src/tab_game.cpp
View file @
2543a5b2
...
@@ -164,7 +164,7 @@ TabGame::TabGame(QList<AbstractClient *> &_clients, int _gameId, const QString &
...
@@ -164,7 +164,7 @@ TabGame::TabGame(QList<AbstractClient *> &_clients, int _gameId, const QString &
gameView
=
new
GameView
(
scene
);
gameView
=
new
GameView
(
scene
);
gameView
->
hide
();
gameView
->
hide
();
cardInfo
=
new
CardInfoWidget
;
cardInfo
=
new
CardInfoWidget
(
CardInfoWidget
::
ModeGameTab
)
;
playerListWidget
=
new
PlayerListWidget
;
playerListWidget
=
new
PlayerListWidget
;
playerListWidget
->
setFocusPolicy
(
Qt
::
NoFocus
);
playerListWidget
->
setFocusPolicy
(
Qt
::
NoFocus
);
messageLog
=
new
MessageLogWidget
;
messageLog
=
new
MessageLogWidget
;
...
...
cockatrice/src/window_deckeditor.cpp
View file @
2543a5b2
...
@@ -81,8 +81,8 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
...
@@ -81,8 +81,8 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
leftFrame
->
addLayout
(
searchLayout
);
leftFrame
->
addLayout
(
searchLayout
);
leftFrame
->
addWidget
(
databaseView
);
leftFrame
->
addWidget
(
databaseView
);
cardInfo
=
new
CardInfoWidget
;
cardInfo
=
new
CardInfoWidget
(
CardInfoWidget
::
ModeDeckEditor
)
;
cardInfo
->
setSizePolicy
(
QSizePolicy
::
Minimum
,
QSizePolicy
::
Preferred
);
cardInfo
->
setSizePolicy
(
QSizePolicy
::
Minimum
,
QSizePolicy
::
Expanding
);
QToolBar
*
verticalToolBar
=
new
QToolBar
;
QToolBar
*
verticalToolBar
=
new
QToolBar
;
verticalToolBar
->
setOrientation
(
Qt
::
Vertical
);
verticalToolBar
->
setOrientation
(
Qt
::
Vertical
);
...
@@ -94,9 +94,8 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
...
@@ -94,9 +94,8 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
verticalToolBarLayout
->
addStretch
();
verticalToolBarLayout
->
addStretch
();
QVBoxLayout
*
middleFrame
=
new
QVBoxLayout
;
QVBoxLayout
*
middleFrame
=
new
QVBoxLayout
;
middleFrame
->
addWidget
(
cardInfo
);
middleFrame
->
addWidget
(
cardInfo
,
10
);
middleFrame
->
addLayout
(
verticalToolBarLayout
);
middleFrame
->
addLayout
(
verticalToolBarLayout
);
middleFrame
->
addStretch
();
deckModel
=
new
DeckListModel
(
this
);
deckModel
=
new
DeckListModel
(
this
);
deckView
=
new
QTreeView
();
deckView
=
new
QTreeView
();
...
...
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