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
5f46b5cd
Commit
5f46b5cd
authored
Apr 06, 2011
by
Max-Wilhelm Bruker
Browse files
game tab: added splitter for manual size control of text boxes
parent
0b22f730
Changes
6
Show whitespace changes
Inline
Side-by-side
cockatrice/src/cardinfowidget.cpp
View file @
5f46b5cd
...
...
@@ -11,13 +11,8 @@
#include
"settingscache.h"
CardInfoWidget
::
CardInfoWidget
(
ResizeMode
_mode
,
QWidget
*
parent
,
Qt
::
WindowFlags
flags
)
:
QFrame
(
parent
,
flags
),
pixmapWidth
(
160
),
aspectRatio
((
qreal
)
CARD_HEIGHT
/
(
qreal
)
CARD_WIDTH
),
minimized
(
false
),
mode
(
_mode
),
minimizeButton
(
0
),
info
(
0
)
:
QFrame
(
parent
,
flags
),
pixmapWidth
(
160
),
aspectRatio
((
qreal
)
CARD_HEIGHT
/
(
qreal
)
CARD_WIDTH
),
minimized
(
false
),
mode
(
_mode
),
info
(
0
)
{
if
(
mode
==
ModeGameTab
)
{
minimizeButton
=
new
QPushButton
(
QIcon
(
style
()
->
standardIcon
(
QStyle
::
SP_ArrowUp
)),
QString
());
connect
(
minimizeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
minimizeClicked
()));
}
cardPicture
=
new
QLabel
;
cardPicture
->
setAlignment
(
Qt
::
AlignCenter
);
...
...
@@ -38,8 +33,6 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, QWidget *parent, Qt::WindowFlag
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
int
row
=
0
;
if
(
mode
==
ModeGameTab
)
grid
->
addWidget
(
minimizeButton
,
row
++
,
1
,
1
,
1
,
Qt
::
AlignRight
);
grid
->
addWidget
(
cardPicture
,
row
++
,
0
,
1
,
2
);
grid
->
addWidget
(
nameLabel1
,
row
,
0
);
grid
->
addWidget
(
nameLabel2
,
row
++
,
1
);
...
...
@@ -58,43 +51,15 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, QWidget *parent, Qt::WindowFlag
retranslateUi
();
setFrameStyle
(
QFrame
::
Panel
|
QFrame
::
Raised
);
setMinimumHeight
(
350
);
if
(
mode
==
ModeGameTab
)
{
textLabel
->
setFixedHeight
(
100
);
setFixedWidth
(
sizeHint
().
width
());
setM
inimized
(
settingsCache
->
getCardInfoMinimized
()
);
setM
aximumHeight
(
580
);
}
else
if
(
mode
==
ModePopUp
)
setFixedWidth
(
350
);
else
setFixedWidth
(
250
);
if
(
mode
!=
ModeDeckEditor
)
setFixedHeight
(
sizeHint
().
height
());
}
void
CardInfoWidget
::
minimizeClicked
()
{
setMinimized
(
!
minimized
);
settingsCache
->
setCardInfoMinimized
(
minimized
);
}
void
CardInfoWidget
::
setMinimized
(
bool
_minimized
)
{
minimized
=
_minimized
;
cardPicture
->
setVisible
(
!
minimized
);
nameLabel2
->
setVisible
(
!
minimized
);
nameLabel1
->
setVisible
(
!
minimized
);
manacostLabel1
->
setVisible
(
!
minimized
);
manacostLabel2
->
setVisible
(
!
minimized
);
cardtypeLabel1
->
setVisible
(
!
minimized
);
cardtypeLabel2
->
setVisible
(
!
minimized
);
powtoughLabel1
->
setVisible
(
!
minimized
);
powtoughLabel2
->
setVisible
(
!
minimized
);
textLabel
->
setVisible
(
!
minimized
);
if
(
minimizeButton
)
minimizeButton
->
setIcon
(
style
()
->
standardIcon
(
minimized
?
QStyle
::
SP_ArrowDown
:
QStyle
::
SP_ArrowUp
));
setFixedHeight
(
sizeHint
().
height
());
}
void
CardInfoWidget
::
setCard
(
CardInfo
*
card
)
...
...
@@ -147,7 +112,7 @@ void CardInfoWidget::retranslateUi()
void
CardInfoWidget
::
resizeEvent
(
QResizeEvent
*
/*event*/
)
{
if
(
mode
==
ModeDeckEditor
)
{
if
(
(
mode
==
ModeDeckEditor
)
||
(
mode
==
ModeGameTab
))
{
pixmapWidth
=
qMin
(
width
()
*
0.95
,
(
height
()
-
200
)
/
aspectRatio
);
updatePixmap
();
}
...
...
cockatrice/src/cardinfowidget.h
View file @
5f46b5cd
...
...
@@ -21,7 +21,6 @@ private:
bool
minimized
;
ResizeMode
mode
;
QPushButton
*
minimizeButton
;
QLabel
*
cardPicture
;
QLabel
*
nameLabel1
,
*
nameLabel2
;
QLabel
*
manacostLabel1
,
*
manacostLabel2
;
...
...
@@ -30,7 +29,6 @@ private:
QTextEdit
*
textLabel
;
CardInfo
*
info
;
void
setMinimized
(
bool
_minimized
);
public:
CardInfoWidget
(
ResizeMode
_mode
,
QWidget
*
parent
=
0
,
Qt
::
WindowFlags
f
=
0
);
void
retranslateUi
();
...
...
@@ -41,7 +39,6 @@ public slots:
private
slots
:
void
clear
();
void
updatePixmap
();
void
minimizeClicked
();
signals:
void
mouseReleased
();
protected:
...
...
cockatrice/src/settingscache.cpp
View file @
5f46b5cd
...
...
@@ -19,7 +19,7 @@ SettingsCache::SettingsCache()
picDownload
=
settings
->
value
(
"personal/picturedownload"
,
true
).
toBool
();
doubleClickToPlay
=
settings
->
value
(
"interface/doubleclicktoplay"
,
true
).
toBool
();
cardInfoMinim
ize
d
=
settings
->
value
(
"interface/
cardinfominimized"
,
false
).
toBool
();
tabGameSplitterS
ize
s
=
settings
->
value
(
"interface/
tabgame_splittersizes"
).
toByteArray
();
displayCardNames
=
settings
->
value
(
"cards/displaycardnames"
,
true
).
toBool
();
horizontalHand
=
settings
->
value
(
"hand/horizontal"
,
true
).
toBool
();
invertVerticalCoordinate
=
settings
->
value
(
"table/invert_vertical"
,
false
).
toBool
();
...
...
@@ -104,10 +104,10 @@ void SettingsCache::setDoubleClickToPlay(int _doubleClickToPlay)
settings
->
setValue
(
"interface/doubleclicktoplay"
,
doubleClickToPlay
);
}
void
SettingsCache
::
set
CardInfoMinimized
(
bool
_cardInfoMinim
ize
d
)
void
SettingsCache
::
set
TabGameSplitterSizes
(
const
QByteArray
&
_tabGameSplitterS
ize
s
)
{
cardInfoMinim
ize
d
=
_
cardInfoMinim
ize
d
;
settings
->
setValue
(
"interface/
cardinfominim
ize
d
"
,
cardInfoMinim
ize
d
);
tabGameSplitterS
ize
s
=
_
tabGameSplitterS
ize
s
;
settings
->
setValue
(
"interface/
tabgame_splitters
ize
s
"
,
tabGameSplitterS
ize
s
);
}
void
SettingsCache
::
setDisplayCardNames
(
int
_displayCardNames
)
...
...
cockatrice/src/settingscache.h
View file @
5f46b5cd
...
...
@@ -28,7 +28,7 @@ private:
QString
handBgPath
,
stackBgPath
,
tableBgPath
,
playerBgPath
,
cardBackPicturePath
;
bool
picDownload
;
bool
doubleClickToPlay
;
bool
cardInfoMinim
ize
d
;
QByteArray
tabGameSplitterS
ize
s
;
bool
displayCardNames
;
bool
horizontalHand
;
bool
invertVerticalCoordinate
;
...
...
@@ -47,7 +47,7 @@ public:
QString
getCardBackPicturePath
()
const
{
return
cardBackPicturePath
;
}
bool
getPicDownload
()
const
{
return
picDownload
;
}
bool
getDoubleClickToPlay
()
const
{
return
doubleClickToPlay
;
}
bool
getCardInfoMinim
ize
d
()
const
{
return
cardInfoMinim
ize
d
;
}
QByteArray
getTabGameSplitterS
ize
s
()
const
{
return
tabGameSplitterS
ize
s
;
}
bool
getDisplayCardNames
()
const
{
return
displayCardNames
;
}
bool
getHorizontalHand
()
const
{
return
horizontalHand
;
}
bool
getInvertVerticalCoordinate
()
const
{
return
invertVerticalCoordinate
;
}
...
...
@@ -66,7 +66,7 @@ public slots:
void
setCardBackPicturePath
(
const
QString
&
_cardBackPicturePath
);
void
setPicDownload
(
int
_picDownload
);
void
setDoubleClickToPlay
(
int
_doubleClickToPlay
);
void
set
CardInfoMinimized
(
bool
_cardInfoMinim
ize
d
);
void
set
TabGameSplitterSizes
(
const
QByteArray
&
_tabGameSplitterS
ize
s
);
void
setDisplayCardNames
(
int
_displayCardNames
);
void
setHorizontalHand
(
int
_horizontalHand
);
void
setInvertVerticalCoordinate
(
int
_invertVerticalCoordinate
);
...
...
cockatrice/src/tab_game.cpp
View file @
5f46b5cd
#include
<QLabel>
#include
<QHBoxLayout>
#include
<QSplitter>
#include
<QMenu>
#include
<QAction>
#include
<QMessageBox>
...
...
@@ -191,17 +192,23 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
deckViewContainerLayout
=
new
QVBoxLayout
;
QVBoxLayout
*
verticalLayout
=
new
QVBoxLayout
;
verticalLayout
->
addWidget
(
cardInfo
);
verticalLayout
->
addWidget
(
playerListWidget
,
1
);
verticalLayout
->
addWidget
(
timeElapsedLabel
);
verticalLayout
->
addWidget
(
messageLog
,
5
);
verticalLayout
->
addLayout
(
hLayout
);
QVBoxLayout
*
messageLogLayout
=
new
QVBoxLayout
;
messageLogLayout
->
addWidget
(
timeElapsedLabel
);
messageLogLayout
->
addWidget
(
messageLog
);
messageLogLayout
->
addLayout
(
hLayout
);
QWidget
*
messageLogLayoutWidget
=
new
QWidget
;
messageLogLayoutWidget
->
setLayout
(
messageLogLayout
);
splitter
=
new
QSplitter
(
Qt
::
Vertical
);
splitter
->
addWidget
(
cardInfo
);
splitter
->
addWidget
(
playerListWidget
);
splitter
->
addWidget
(
messageLogLayoutWidget
);
mainLayout
=
new
QHBoxLayout
;
mainLayout
->
addWidget
(
gameView
,
10
);
mainLayout
->
addLayout
(
deckViewContainerLayout
,
10
);
mainLayout
->
add
Layout
(
verticalLayout
);
mainLayout
->
add
Widget
(
splitter
);
if
(
spectator
&&
!
spectatorsCanTalk
)
{
sayLabel
->
hide
();
...
...
@@ -254,11 +261,15 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
retranslateUi
();
setLayout
(
mainLayout
);
splitter
->
restoreState
(
settingsCache
->
getTabGameSplitterSizes
());
messageLog
->
logGameJoined
(
gameId
);
}
TabGame
::~
TabGame
()
{
settingsCache
->
setTabGameSplitterSizes
(
splitter
->
saveState
());
QMapIterator
<
int
,
Player
*>
i
(
players
);
while
(
i
.
hasNext
())
delete
i
.
next
().
value
();
...
...
@@ -768,11 +779,11 @@ void TabGame::showCardInfoPopup(const QPoint &pos, const QString &cardName)
connect
(
infoPopup
,
SIGNAL
(
mouseReleased
()),
this
,
SLOT
(
deleteCardInfoPopup
()));
infoPopup
->
setCard
(
cardName
);
QRect
screenRect
=
qApp
->
desktop
()
->
screenGeometry
(
this
);
infoPopup
->
show
();
infoPopup
->
move
(
qMax
(
screenRect
.
left
(),
qMin
(
pos
.
x
()
-
infoPopup
->
width
()
/
2
,
screenRect
.
left
()
+
screenRect
.
width
()
-
infoPopup
->
width
())),
qMax
(
screenRect
.
top
(),
qMin
(
pos
.
y
()
-
infoPopup
->
height
()
/
2
,
screenRect
.
top
()
+
screenRect
.
height
()
-
infoPopup
->
height
()))
);
infoPopup
->
show
();
infoPopup
->
grabMouse
();
}
...
...
cockatrice/src/tab_game.h
View file @
5f46b5cd
...
...
@@ -12,6 +12,7 @@ class DeckView;
class
GameScene
;
class
CardInfoWidget
;
class
MessageLogWidget
;
class
QSplitter
;
class
QLabel
;
class
QLineEdit
;
class
QPushButton
;
...
...
@@ -98,6 +99,7 @@ private:
int
currentPhase
;
int
activePlayer
;
QSplitter
*
splitter
;
CardInfoWidget
*
infoPopup
;
CardInfoWidget
*
cardInfo
;
PlayerListWidget
*
playerListWidget
;
...
...
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