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
0b223163
Commit
0b223163
authored
Jan 05, 2014
by
sylvanbasilisk
Browse files
initial experiment with editor layout
parent
95c6058d
Changes
6
Show whitespace changes
Inline
Side-by-side
cockatrice/CMakeLists.txt
View file @
0b223163
...
...
@@ -33,6 +33,7 @@ SET(cockatrice_SOURCES
src/dlg_load_deck_from_clipboard.cpp
src/dlg_load_remote_deck.cpp
src/cardinfowidget.cpp
src/cardframe.cpp
src/messagelogwidget.cpp
src/zoneviewzone.cpp
src/zoneviewwidget.cpp
...
...
@@ -110,6 +111,7 @@ SET(cockatrice_HEADERS
src/dlg_load_deck_from_clipboard.h
src/dlg_load_remote_deck.h
src/cardinfowidget.h
src/cardframe.h
src/messagelogwidget.h
src/zoneviewzone.h
src/zoneviewwidget.h
...
...
cockatrice/src/cardframe.cpp
0 → 100644
View file @
0b223163
#include
"cardframe.h"
#include
<QLabel>
#include
"carditem.h"
#include
"carddatabase.h"
#include
"main.h"
CardFrame
::
CardFrame
(
const
QString
&
cardName
,
QWidget
*
parent
,
Qt
::
WindowFlags
flags
)
:
QLabel
(
parent
,
flags
)
,
info
(
0
)
{
this
->
setAlignment
(
Qt
::
AlignCenter
);
setFrameStyle
(
QFrame
::
Panel
|
QFrame
::
Raised
);
setFixedWidth
(
250
);
setCard
(
db
->
getCard
(
cardName
));
}
void
CardFrame
::
setCard
(
CardInfo
*
card
)
{
if
(
info
)
disconnect
(
info
,
0
,
this
,
0
);
info
=
card
;
connect
(
info
,
SIGNAL
(
pixmapUpdated
()),
this
,
SLOT
(
updatePixmap
()));
connect
(
info
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
clear
()));
updatePixmap
();
}
void
CardFrame
::
setCard
(
const
QString
&
cardName
)
{
setCard
(
db
->
getCard
(
cardName
));
}
void
CardFrame
::
setCard
(
AbstractCardItem
*
card
)
{
setCard
(
card
->
getInfo
());
}
void
CardFrame
::
clear
()
{
setCard
(
db
->
getCard
());
}
void
CardFrame
::
updatePixmap
()
{
qreal
aspectRatio
=
(
qreal
)
CARD_HEIGHT
/
(
qreal
)
CARD_WIDTH
;
qreal
pixmapWidth
=
this
->
width
();
if
(
pixmapWidth
==
0
)
return
;
QPixmap
*
resizedPixmap
=
info
->
getPixmap
(
QSize
(
pixmapWidth
,
pixmapWidth
*
aspectRatio
));
if
(
resizedPixmap
)
this
->
setPixmap
(
*
resizedPixmap
);
else
this
->
setPixmap
(
*
(
db
->
getCard
()
->
getPixmap
(
QSize
(
pixmapWidth
,
pixmapWidth
*
aspectRatio
))));
}
QString
CardFrame
::
getCardName
()
const
{
return
info
->
getName
();
}
cockatrice/src/cardframe.h
0 → 100644
View file @
0b223163
#ifndef CARDFRAME_H
#define CARDFRAME_H
#include
<QLabel>
#include
<QStringList>
class
AbstractCardItem
;
class
CardInfo
;
class
QResizeEvent
;
class
CardFrame
:
public
QLabel
{
Q_OBJECT
private:
CardInfo
*
info
;
public:
CardFrame
(
const
QString
&
cardName
=
QString
(),
QWidget
*
parent
=
0
,
Qt
::
WindowFlags
f
=
0
);
QString
getCardName
()
const
;
public
slots
:
void
setCard
(
CardInfo
*
card
);
void
setCard
(
const
QString
&
cardName
);
void
setCard
(
AbstractCardItem
*
card
);
private
slots
:
void
clear
();
void
updatePixmap
();
};
#endif
cockatrice/src/cardinfowidget.cpp
View file @
0b223163
...
...
@@ -51,8 +51,9 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, const QString &cardName, QWidge
textLabel
->
setReadOnly
(
true
);
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
if
(
mode
==
ModeGameTab
)
{
int
row
=
0
;
if
(
mode
==
ModeGameTab
)
grid
->
addWidget
(
dropList
,
row
++
,
1
,
1
,
1
,
Qt
::
AlignRight
);
grid
->
addWidget
(
cardPicture
,
row
++
,
0
,
1
,
2
);
grid
->
addWidget
(
nameLabel1
,
row
,
0
);
...
...
@@ -68,6 +69,11 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, const QString &cardName, QWidge
grid
->
addWidget
(
textLabel
,
row
,
0
,
-
1
,
2
);
grid
->
setRowStretch
(
row
,
1
);
grid
->
setColumnStretch
(
1
,
1
);
}
else
{
/*grid->addWidget(cardPicture, 0, 0);
grid->setRowStretch(0, 1);
grid->setColumnStretch(0, 1);*/
}
retranslateUi
();
setFrameStyle
(
QFrame
::
Panel
|
QFrame
::
Raised
);
...
...
cockatrice/src/tab_deck_editor.cpp
View file @
0b223163
...
...
@@ -21,7 +21,6 @@
#include
"carddatabase.h"
#include
"carddatabasemodel.h"
#include
"decklistmodel.h"
#include
"cardinfowidget.h"
#include
"dlg_cardsearch.h"
#include
"dlg_load_deck_from_clipboard.h"
#include
"dlg_edit_tokens.h"
...
...
@@ -34,6 +33,18 @@
#include
"pending_command.h"
#include
"pb/response.pb.h"
#include
"pb/command_deck_upload.pb.h"
#include
<QGridLayout>
#include
<QLabel>
#include
<QTextEdit>
#include
<QPushButton>
#include
<QStyle>
#include
<QMouseEvent>
#include
<QDesktopWidget>
#include
"cardframe.h"
#include
"carditem.h"
#include
"carddatabase.h"
#include
"main.h"
#include
"settingscache.h"
void
SearchLineEdit
::
keyPressEvent
(
QKeyEvent
*
event
)
{
...
...
@@ -85,25 +96,16 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
connect
(
databaseView
,
SIGNAL
(
doubleClicked
(
const
QModelIndex
&
)),
this
,
SLOT
(
actAddCard
()));
searchEdit
->
setTreeView
(
databaseView
);
QVBoxLayout
*
leftFrame
=
new
QVBoxLayout
;
leftFrame
->
addLayout
(
searchLayout
);
leftFrame
->
addWidget
(
databaseView
);
cardInfo
=
new
CardInfoWidget
(
CardInfoWidget
::
ModeDeckEditor
);
cardInfo
=
new
CardFrame
();
cardInfo
->
setSizePolicy
(
QSizePolicy
::
Minimum
,
QSizePolicy
::
Expanding
);
QToolBar
*
verticalToolBar
=
new
QToolBar
;
verticalToolBar
->
setOrientation
(
Qt
::
Vertical
);
verticalToolBar
->
setToolButtonStyle
(
Qt
::
ToolButtonTextBesideIcon
);
verticalToolBar
->
setOrientation
(
Qt
::
Horizontal
);
verticalToolBar
->
setIconSize
(
QSize
(
24
,
24
));
QHBoxLayout
*
verticalToolBarLayout
=
new
QHBoxLayout
;
verticalToolBarLayout
->
addStretch
();
//
verticalToolBarLayout->addStretch();
verticalToolBarLayout
->
addWidget
(
verticalToolBar
);
verticalToolBarLayout
->
addStretch
();
QVBoxLayout
*
middleFrame
=
new
QVBoxLayout
;
middleFrame
->
addWidget
(
cardInfo
,
10
);
middleFrame
->
addLayout
(
verticalToolBarLayout
);
//verticalToolBarLayout->addStretch();
deckModel
=
new
DeckListModel
(
this
);
connect
(
deckModel
,
SIGNAL
(
deckHashChanged
()),
this
,
SLOT
(
updateHash
()));
...
...
@@ -129,8 +131,8 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
grid
->
addWidget
(
nameLabel
,
0
,
0
);
grid
->
addWidget
(
nameEdit
,
0
,
1
);
grid
->
addWidget
(
commentsLabel
,
1
,
0
);
grid
->
addWidget
(
commentsEdit
,
1
,
1
);
/*
grid->addWidget(commentsLabel, 1, 0);
grid->addWidget(commentsEdit, 1, 1);
*/
grid
->
addWidget
(
hashLabel1
,
2
,
0
);
grid
->
addWidget
(
hashLabel
,
2
,
1
);
...
...
@@ -152,15 +154,25 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
deckToolbarLayout
->
addWidget
(
deckToolBar
);
deckToolbarLayout
->
addStretch
();
QVBoxLayout
*
rightFrame
=
new
QVBoxLayout
;
rightFrame
->
addLayout
(
grid
);
rightFrame
->
addWidget
(
deckView
,
10
);
rightFrame
->
addLayout
(
deckToolbarLayout
);
QHBoxLayout
*
mainLayout
=
new
QHBoxLayout
;
mainLayout
->
addLayout
(
leftFrame
,
10
);
mainLayout
->
addLayout
(
middleFrame
);
mainLayout
->
addLayout
(
rightFrame
,
10
);
QVBoxLayout
*
deckFrame
=
new
QVBoxLayout
;
deckFrame
->
addLayout
(
grid
);
deckFrame
->
addWidget
(
deckView
,
10
);
deckFrame
->
addLayout
(
deckToolbarLayout
);
QHBoxLayout
*
topFrame
=
new
QHBoxLayout
;
topFrame
->
addWidget
(
cardInfo
,
10
);
topFrame
->
addLayout
(
deckFrame
);
QVBoxLayout
*
botFrame
=
new
QVBoxLayout
;
QGridLayout
*
searchAndButtons
=
new
QGridLayout
;
searchAndButtons
->
addLayout
(
verticalToolBarLayout
,
0
,
0
);
searchAndButtons
->
addLayout
(
searchLayout
,
0
,
1
);
botFrame
->
addLayout
(
searchAndButtons
);
botFrame
->
addWidget
(
databaseView
);
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addLayout
(
topFrame
,
10
);
mainLayout
->
addLayout
(
botFrame
,
10
);
setLayout
(
mainLayout
);
aNewDeck
=
new
QAction
(
QString
(),
this
);
...
...
cockatrice/src/tab_deck_editor.h
View file @
0b223163
...
...
@@ -10,7 +10,7 @@ class CardDatabaseDisplayModel;
class
DeckListModel
;
class
QTreeView
;
class
QTableView
;
class
Card
InfoWidget
;
class
Card
Frame
;
class
QTextEdit
;
class
DlgCardSearch
;
class
QLabel
;
...
...
@@ -71,7 +71,7 @@ private:
DeckListModel
*
deckModel
;
QTreeView
*
databaseView
;
QTreeView
*
deckView
;
Card
InfoWidget
*
cardInfo
;
Card
Frame
*
cardInfo
;
QLabel
*
searchLabel
;
SearchLineEdit
*
searchEdit
;
QLabel
*
nameLabel
;
...
...
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