game tab: added splitter for manual size control of text boxes
This commit is contained in:
parent
0b22f73095
commit
5f46b5cd41
6 changed files with 36 additions and 61 deletions
|
@ -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());
|
||||
setMinimized(settingsCache->getCardInfoMinimized());
|
||||
setMaximumHeight(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();
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -19,7 +19,7 @@ SettingsCache::SettingsCache()
|
|||
|
||||
picDownload = settings->value("personal/picturedownload", true).toBool();
|
||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||
cardInfoMinimized = settings->value("interface/cardinfominimized", false).toBool();
|
||||
tabGameSplitterSizes = 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::setCardInfoMinimized(bool _cardInfoMinimized)
|
||||
void SettingsCache::setTabGameSplitterSizes(const QByteArray &_tabGameSplitterSizes)
|
||||
{
|
||||
cardInfoMinimized = _cardInfoMinimized;
|
||||
settings->setValue("interface/cardinfominimized", cardInfoMinimized);
|
||||
tabGameSplitterSizes = _tabGameSplitterSizes;
|
||||
settings->setValue("interface/tabgame_splittersizes", tabGameSplitterSizes);
|
||||
}
|
||||
|
||||
void SettingsCache::setDisplayCardNames(int _displayCardNames)
|
||||
|
|
|
@ -28,7 +28,7 @@ private:
|
|||
QString handBgPath, stackBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
|
||||
bool picDownload;
|
||||
bool doubleClickToPlay;
|
||||
bool cardInfoMinimized;
|
||||
QByteArray tabGameSplitterSizes;
|
||||
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 getCardInfoMinimized() const { return cardInfoMinimized; }
|
||||
QByteArray getTabGameSplitterSizes() const { return tabGameSplitterSizes; }
|
||||
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 setCardInfoMinimized(bool _cardInfoMinimized);
|
||||
void setTabGameSplitterSizes(const QByteArray &_tabGameSplitterSizes);
|
||||
void setDisplayCardNames(int _displayCardNames);
|
||||
void setHorizontalHand(int _horizontalHand);
|
||||
void setInvertVerticalCoordinate(int _invertVerticalCoordinate);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#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->addLayout(verticalLayout);
|
||||
mainLayout->addWidget(splitter);
|
||||
|
||||
if (spectator && !spectatorsCanTalk) {
|
||||
sayLabel->hide();
|
||||
|
@ -253,12 +260,16 @@ 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();
|
||||
|
@ -767,12 +778,12 @@ void TabGame::showCardInfoPopup(const QPoint &pos, const QString &cardName)
|
|||
infoPopup = new CardInfoWidget(CardInfoWidget::ModePopUp, 0, Qt::Widget | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint);
|
||||
connect(infoPopup, SIGNAL(mouseReleased()), this, SLOT(deleteCardInfoPopup()));
|
||||
infoPopup->setCard(cardName);
|
||||
QRect screenRect = qApp->desktop()->screenGeometry(this);
|
||||
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()))
|
||||
);
|
||||
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->grabMouse();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue