initial experiment with editor layout
This commit is contained in:
parent
95c6058dc3
commit
0b2231639f
6 changed files with 158 additions and 42 deletions
|
@ -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
|
||||
|
|
64
cockatrice/src/cardframe.cpp
Normal file
64
cockatrice/src/cardframe.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#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();
|
||||
}
|
32
cockatrice/src/cardframe.h
Normal file
32
cockatrice/src/cardframe.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#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
|
|
@ -51,23 +51,29 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, const QString &cardName, QWidge
|
|||
textLabel->setReadOnly(true);
|
||||
|
||||
QGridLayout *grid = new QGridLayout(this);
|
||||
int row = 0;
|
||||
if (mode == ModeGameTab)
|
||||
if (mode == ModeGameTab) {
|
||||
int row = 0;
|
||||
|
||||
grid->addWidget(dropList, row++, 1, 1, 1, Qt::AlignRight);
|
||||
grid->addWidget(cardPicture, row++, 0, 1, 2);
|
||||
grid->addWidget(nameLabel1, row, 0);
|
||||
grid->addWidget(nameLabel2, row++, 1);
|
||||
grid->addWidget(manacostLabel1, row, 0);
|
||||
grid->addWidget(manacostLabel2, row++, 1);
|
||||
grid->addWidget(cardtypeLabel1, row, 0);
|
||||
grid->addWidget(cardtypeLabel2, row++, 1);
|
||||
grid->addWidget(powtoughLabel1, row, 0);
|
||||
grid->addWidget(powtoughLabel2, row++, 1);
|
||||
grid->addWidget(loyaltyLabel1, row, 0);
|
||||
grid->addWidget(loyaltyLabel2, row++, 1);
|
||||
grid->addWidget(textLabel, row, 0, -1, 2);
|
||||
grid->setRowStretch(row, 1);
|
||||
grid->setColumnStretch(1, 1);
|
||||
grid->addWidget(cardPicture, row++, 0, 1, 2);
|
||||
grid->addWidget(nameLabel1, row, 0);
|
||||
grid->addWidget(nameLabel2, row++, 1);
|
||||
grid->addWidget(manacostLabel1, row, 0);
|
||||
grid->addWidget(manacostLabel2, row++, 1);
|
||||
grid->addWidget(cardtypeLabel1, row, 0);
|
||||
grid->addWidget(cardtypeLabel2, row++, 1);
|
||||
grid->addWidget(powtoughLabel1, row, 0);
|
||||
grid->addWidget(powtoughLabel2, row++, 1);
|
||||
grid->addWidget(loyaltyLabel1, row, 0);
|
||||
grid->addWidget(loyaltyLabel2, row++, 1);
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
QVBoxLayout *deckFrame = new QVBoxLayout;
|
||||
deckFrame->addLayout(grid);
|
||||
deckFrame->addWidget(deckView, 10);
|
||||
deckFrame->addLayout(deckToolbarLayout);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->addLayout(leftFrame, 10);
|
||||
mainLayout->addLayout(middleFrame);
|
||||
mainLayout->addLayout(rightFrame, 10);
|
||||
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);
|
||||
|
|
|
@ -10,7 +10,7 @@ class CardDatabaseDisplayModel;
|
|||
class DeckListModel;
|
||||
class QTreeView;
|
||||
class QTableView;
|
||||
class CardInfoWidget;
|
||||
class CardFrame;
|
||||
class QTextEdit;
|
||||
class DlgCardSearch;
|
||||
class QLabel;
|
||||
|
@ -71,7 +71,7 @@ private:
|
|||
DeckListModel *deckModel;
|
||||
QTreeView *databaseView;
|
||||
QTreeView *deckView;
|
||||
CardInfoWidget *cardInfo;
|
||||
CardFrame *cardInfo;
|
||||
QLabel *searchLabel;
|
||||
SearchLineEdit *searchEdit;
|
||||
QLabel *nameLabel;
|
||||
|
|
Loading…
Reference in a new issue