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
fac44966
Commit
fac44966
authored
Jun 15, 2015
by
Fabio Bas
Browse files
Reworked to use a qtabwidget: better cross-os look
parent
3af58040
Changes
2
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/cardframe.cpp
View file @
fac44966
...
@@ -8,15 +8,13 @@
...
@@ -8,15 +8,13 @@
#include
"settingscache.h"
#include
"settingscache.h"
#include
<QVBoxLayout>
#include
<QVBoxLayout>
#include
<QTabBar>
CardFrame
::
CardFrame
(
int
width
,
int
height
,
CardFrame
::
CardFrame
(
int
width
,
int
height
,
const
QString
&
cardName
,
QWidget
*
parent
)
const
QString
&
cardName
,
QWidget
*
parent
)
:
Q
Frame
(
parent
)
:
Q
TabWidget
(
parent
)
,
info
(
0
)
,
info
(
0
)
,
cardTextOnly
(
false
)
,
cardTextOnly
(
false
)
{
{
setFrameStyle
(
QFrame
::
Panel
|
QFrame
::
Raised
);
setMaximumWidth
(
width
);
setMaximumWidth
(
width
);
setMinimumWidth
(
width
);
setMinimumWidth
(
width
);
setMinimumHeight
(
height
);
setMinimumHeight
(
height
);
...
@@ -24,20 +22,28 @@ CardFrame::CardFrame(int width, int height,
...
@@ -24,20 +22,28 @@ CardFrame::CardFrame(int width, int height,
pic
=
new
CardInfoPicture
(
width
);
pic
=
new
CardInfoPicture
(
width
);
text
=
new
CardInfoText
();
text
=
new
CardInfoText
();
tabBar
=
new
QTabBar
(
this
);
tab1
=
new
QWidget
(
this
);
tabBar
->
setDrawBase
(
false
);
tab2
=
new
QWidget
(
this
);
tabBar
->
insertTab
(
ImageOnlyView
,
QString
());
tab3
=
new
QWidget
(
this
);
tabBar
->
insertTab
(
TextOnlyView
,
QString
());
insertTab
(
ImageOnlyView
,
tab1
,
QString
());
tabBar
->
insertTab
(
ImageAndTextView
,
QString
());
insertTab
(
TextOnlyView
,
tab2
,
QString
());
connect
(
tabBar
,
SIGNAL
(
currentChanged
(
int
)),
this
,
SLOT
(
setViewMode
(
int
)));
insertTab
(
ImageAndTextView
,
tab3
,
QString
());
connect
(
this
,
SIGNAL
(
currentChanged
(
int
)),
this
,
SLOT
(
setViewMode
(
int
)));
QVBoxLayout
*
layout
=
new
QVBoxLayout
();
layout
->
addWidget
(
tabBar
);
tab1Layout
=
new
QVBoxLayout
();
layout
->
addWidget
(
pic
);
tab1Layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
layout
->
addWidget
(
text
);
tab1Layout
->
setSpacing
(
0
);
layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
tab1
->
setLayout
(
tab1Layout
);
layout
->
setSpacing
(
0
);
setLayout
(
layout
);
tab2Layout
=
new
QVBoxLayout
();
tab2Layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
tab2Layout
->
setSpacing
(
0
);
tab2
->
setLayout
(
tab2Layout
);
tab3Layout
=
new
QVBoxLayout
();
tab3Layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
tab3Layout
->
setSpacing
(
0
);
tab3
->
setLayout
(
tab3Layout
);
setViewMode
(
settingsCache
->
getCardInfoViewMode
());
setViewMode
(
settingsCache
->
getCardInfoViewMode
());
...
@@ -46,29 +52,26 @@ CardFrame::CardFrame(int width, int height,
...
@@ -46,29 +52,26 @@ CardFrame::CardFrame(int width, int height,
void
CardFrame
::
retranslateUi
()
void
CardFrame
::
retranslateUi
()
{
{
tabBar
->
setTabText
(
ImageOnlyView
,
tr
(
"Image"
));
setTabText
(
ImageOnlyView
,
tr
(
"Image"
));
tabBar
->
setTabText
(
TextOnlyView
,
tr
(
"Description"
));
setTabText
(
TextOnlyView
,
tr
(
"Description"
));
tabBar
->
setTabText
(
ImageAndTextView
,
tr
(
"Both"
));
setTabText
(
ImageAndTextView
,
tr
(
"Both"
));
}
}
void
CardFrame
::
setViewMode
(
int
mode
)
void
CardFrame
::
setViewMode
(
int
mode
)
{
{
if
(
tabBar
->
currentIndex
()
!=
mode
)
if
(
currentIndex
()
!=
mode
)
tabBar
->
setCurrentIndex
(
mode
);
setCurrentIndex
(
mode
);
switch
(
mode
)
switch
(
mode
)
{
{
case
ImageOnlyView
:
case
ImageOnlyView
:
pic
->
setVisible
(
true
);
text
->
setVisible
(
false
);
break
;
case
TextOnlyView
:
case
TextOnlyView
:
pic
->
setVisible
(
false
);
tab1Layout
->
addWidget
(
pic
);
t
ext
->
setVisible
(
true
);
t
ab2Layout
->
addWidget
(
text
);
break
;
break
;
case
ImageAndTextView
:
case
ImageAndTextView
:
pic
->
setVisible
(
true
);
tab3Layout
->
addWidget
(
pic
);
t
ext
->
setVisible
(
true
);
t
ab3Layout
->
addWidget
(
text
);
break
;
break
;
}
}
...
...
cockatrice/src/cardframe.h
View file @
fac44966
#ifndef CARDFRAME_H
#ifndef CARDFRAME_H
#define CARDFRAME_H
#define CARDFRAME_H
#include
<Q
Frame
>
#include
<Q
TabWidget
>
class
AbstractCardItem
;
class
AbstractCardItem
;
class
CardInfo
;
class
CardInfo
;
class
CardInfoPicture
;
class
CardInfoPicture
;
class
CardInfoText
;
class
CardInfoText
;
class
Q
TabBar
;
class
Q
VBoxLayout
;
class
CardFrame
:
public
Q
Frame
{
class
CardFrame
:
public
Q
TabWidget
{
Q_OBJECT
Q_OBJECT
private:
private:
QTabBar
*
tabBar
;
CardInfo
*
info
;
CardInfo
*
info
;
CardInfoPicture
*
pic
;
CardInfoPicture
*
pic
;
CardInfoText
*
text
;
CardInfoText
*
text
;
bool
cardTextOnly
;
bool
cardTextOnly
;
QWidget
*
tab1
,
*
tab2
,
*
tab3
;
QVBoxLayout
*
tab1Layout
,
*
tab2Layout
,
*
tab3Layout
;
public:
public:
enum
ViewMode
{
ImageOnlyView
,
TextOnlyView
,
ImageAndTextView
};
enum
ViewMode
{
ImageOnlyView
,
TextOnlyView
,
ImageAndTextView
};
...
@@ -25,7 +26,6 @@ public:
...
@@ -25,7 +26,6 @@ public:
CardFrame
(
int
width
,
int
height
,
const
QString
&
cardName
=
QString
(),
CardFrame
(
int
width
,
int
height
,
const
QString
&
cardName
=
QString
(),
QWidget
*
parent
=
0
);
QWidget
*
parent
=
0
);
void
retranslateUi
();
void
retranslateUi
();
public
slots
:
public
slots
:
void
setCard
(
CardInfo
*
card
);
void
setCard
(
CardInfo
*
card
);
void
setCard
(
const
QString
&
cardName
);
void
setCard
(
const
QString
&
cardName
);
...
...
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