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
d6ce1852
Commit
d6ce1852
authored
Jun 18, 2015
by
Fabio Bas
Browse files
Fix deckeditor jitter problem; fix #1143
parent
85334246
Changes
4
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/cardframe.cpp
View file @
d6ce1852
...
...
@@ -15,11 +15,11 @@ CardFrame::CardFrame(int width, int height,
,
info
(
0
)
,
cardTextOnly
(
false
)
{
setMaximumWidth
(
width
);
setMinimumWidth
(
width
);
setFixedWidth
(
width
);
setMinimumHeight
(
height
);
pic
=
new
CardInfoPicture
(
width
);
setContentsMargins
(
3
,
3
,
3
,
3
);
pic
=
new
CardInfoPicture
(
width
-
6
);
text
=
new
CardInfoText
();
tab1
=
new
QWidget
(
this
);
...
...
cockatrice/src/cardinfopicture.cpp
View file @
d6ce1852
#include
"cardinfopicture.h"
#include
<QLabel>
#include
<QWidget>
#include
<QPainter>
#include
<QStyle>
#include
"carditem.h"
#include
"carddatabase.h"
#include
"main.h"
CardInfoPicture
::
CardInfoPicture
(
int
maximumWidth
,
QWidget
*
parent
)
:
QLabel
(
parent
)
,
info
(
0
)
,
noPicture
(
true
)
{
setAlignment
(
Qt
::
AlignCenter
);
setMaximumWidth
(
maximumWidth
);
}
void
CardInfoPicture
::
setNoPicture
(
bool
status
)
CardInfoPicture
::
CardInfoPicture
(
int
width
,
QWidget
*
parent
)
:
QWidget
(
parent
),
info
(
0
),
pixmapDirty
(
true
)
{
if
(
noPicture
!=
status
)
{
noPicture
=
status
;
emit
hasPictureChanged
();
}
setFixedWidth
(
width
);
setMinimumHeight
(
100
);
setMaximumHeight
(
width
/
(
qreal
)
CARD_WIDTH
*
(
qreal
)
CARD_HEIGHT
);
}
void
CardInfoPicture
::
setCard
(
CardInfo
*
card
)
...
...
@@ -32,26 +28,37 @@ void CardInfoPicture::setCard(CardInfo *card)
updatePixmap
();
}
void
CardInfoPicture
::
resizeEvent
(
QResizeEvent
*
/* e */
)
void
CardInfoPicture
::
resizeEvent
(
QResizeEvent
*
)
{
updatePixmap
();
}
void
CardInfoPicture
::
updatePixmap
()
{
if
(
info
==
0
||
width
()
==
0
||
height
()
==
0
)
{
setNoPicture
(
true
);
return
;
}
pixmapDirty
=
true
;
update
();
}
void
CardInfoPicture
::
loadPixmap
()
{
if
(
info
)
info
->
getPixmap
(
size
(),
resizedPixmap
);
else
resizedPixmap
=
QPixmap
();
QPixmap
resizedPixmap
;
info
->
getPixmap
(
size
(),
resizedPixmap
);
if
(
resizedPixmap
.
isNull
())
{
setNoPicture
(
true
);
if
(
resizedPixmap
.
isNull
())
db
->
getCard
()
->
getPixmap
(
size
(),
resizedPixmap
);
}
else
{
setNoPicture
(
false
);
}
this
->
setPixmap
(
resizedPixmap
);
}
void
CardInfoPicture
::
paintEvent
(
QPaintEvent
*
)
{
if
(
width
()
==
0
||
height
()
==
0
)
return
;
if
(
pixmapDirty
)
loadPixmap
();
QPainter
painter
(
this
);
style
()
->
drawItemPixmap
(
&
painter
,
rect
(),
Qt
::
AlignHCenter
,
resizedPixmap
);
}
cockatrice/src/cardinfopicture.h
View file @
d6ce1852
#ifndef CARDINFOPICTURE_H
#define CARDINFOPICTURE_H
#include
<Q
Label
>
#include
<Q
Widget
>
class
AbstractCardItem
;
class
CardInfo
;
class
CardInfoPicture
:
public
Q
Label
{
class
CardInfoPicture
:
public
Q
Widget
{
Q_OBJECT
signals:
void
hasPictureChanged
();
private:
CardInfo
*
info
;
bool
noPicture
;
QPixmap
resizedPixmap
;
bool
pixmapDirty
;
public:
CardInfoPicture
(
int
maximumWidth
,
QWidget
*
parent
=
0
);
bool
hasPicture
()
const
{
return
!
noPicture
;
}
private:
void
setNoPicture
(
bool
status
);
CardInfoPicture
(
int
width
,
QWidget
*
parent
=
0
);
protected:
void
resizeEvent
(
QResizeEvent
*
event
);
void
paintEvent
(
QPaintEvent
*
);
void
loadPixmap
();
public
slots
:
void
setCard
(
CardInfo
*
card
);
void
updatePixmap
();
...
...
cockatrice/src/tab_deck_editor.cpp
View file @
d6ce1852
...
...
@@ -108,7 +108,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
leftFrame
->
addLayout
(
searchLayout
);
leftFrame
->
addWidget
(
databaseView
);
cardInfo
=
new
CardFrame
(
250
,
3
56
);
cardInfo
=
new
CardFrame
(
250
,
3
72
);
filterModel
=
new
FilterTreeModel
();
databaseDisplayModel
->
setFilterTree
(
filterModel
->
filterTree
());
...
...
@@ -143,7 +143,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
filterBox
->
setLayout
(
filterLayout
);
QVBoxLayout
*
middleFrame
=
new
QVBoxLayout
;
middleFrame
->
addWidget
(
cardInfo
,
0
,
Qt
::
AlignTop
);
middleFrame
->
addWidget
(
cardInfo
,
1
,
Qt
::
AlignTop
);
middleFrame
->
addWidget
(
filterBox
,
0
);
deckModel
=
new
DeckListModel
(
this
);
...
...
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