Commit 62dc3a7c authored by woogerboy21's avatar woogerboy21
Browse files

Merge pull request #1342 from marcofernandezheras/CardInfoLayout

Deck Editor layout
parents ba90d84a e9e75961
...@@ -7,39 +7,52 @@ ...@@ -7,39 +7,52 @@
#include "cardinfotext.h" #include "cardinfotext.h"
#include "settingscache.h" #include "settingscache.h"
#include <QSplitter>
#include <QVBoxLayout> #include <QVBoxLayout>
CardFrame::CardFrame(int width, int height, const QString &cardName, QWidget *parent) CardFrame::CardFrame(const QString &cardName, QWidget *parent)
: QTabWidget(parent), info(0), cardTextOnly(false) : QTabWidget(parent), info(0), cardTextOnly(false)
{ {
setFixedWidth(width);
setMinimumHeight(height);
setContentsMargins(3, 3, 3, 3); setContentsMargins(3, 3, 3, 3);
pic = new CardInfoPicture(width - 6); pic = new CardInfoPicture();
pic->setObjectName("pic");
text = new CardInfoText(); text = new CardInfoText();
text->setObjectName("text");
tab1 = new QWidget(this); tab1 = new QWidget(this);
tab2 = new QWidget(this); tab2 = new QWidget(this);
tab3 = new QWidget(this); tab3 = new QWidget(this);
tab1->setObjectName("tab1");
tab2->setObjectName("tab2");
tab3->setObjectName("tab3");
insertTab(ImageOnlyView, tab1, QString()); insertTab(ImageOnlyView, tab1, QString());
insertTab(TextOnlyView, tab2, QString()); insertTab(TextOnlyView, tab2, QString());
insertTab(ImageAndTextView, tab3, QString()); insertTab(ImageAndTextView, tab3, QString());
connect(this, SIGNAL(currentChanged(int)), this, SLOT(setViewMode(int))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(setViewMode(int)));
tab1Layout = new QVBoxLayout(); tab1Layout = new QVBoxLayout();
tab1Layout->setObjectName("tab1Layout");
tab1Layout->setContentsMargins(0, 0, 0, 0); tab1Layout->setContentsMargins(0, 0, 0, 0);
tab1Layout->setSpacing(0); tab1Layout->setSpacing(0);
tab1->setLayout(tab1Layout); tab1->setLayout(tab1Layout);
tab2Layout = new QVBoxLayout(); tab2Layout = new QVBoxLayout();
tab2Layout->setObjectName("tab2Layout");
tab2Layout->setContentsMargins(0, 0, 0, 0); tab2Layout->setContentsMargins(0, 0, 0, 0);
tab2Layout->setSpacing(0); tab2Layout->setSpacing(0);
tab2->setLayout(tab2Layout); tab2->setLayout(tab2Layout);
splitter = new QSplitter();
splitter->setObjectName("splitter");
splitter->setOrientation(Qt::Vertical);
tab3Layout = new QVBoxLayout(); tab3Layout = new QVBoxLayout();
tab3Layout->setObjectName("tab3Layout");
tab3Layout->setContentsMargins(0, 0, 0, 0); tab3Layout->setContentsMargins(0, 0, 0, 0);
tab3Layout->setSpacing(0); tab3Layout->setSpacing(0);
tab3Layout->addWidget(splitter);
tab3->setLayout(tab3Layout); tab3->setLayout(tab3Layout);
setViewMode(settingsCache->getCardInfoViewMode()); setViewMode(settingsCache->getCardInfoViewMode());
...@@ -67,8 +80,8 @@ void CardFrame::setViewMode(int mode) ...@@ -67,8 +80,8 @@ void CardFrame::setViewMode(int mode)
tab2Layout->addWidget(text); tab2Layout->addWidget(text);
break; break;
case ImageAndTextView: case ImageAndTextView:
tab3Layout->addWidget(pic); splitter->addWidget(pic);
tab3Layout->addWidget(text); splitter->addWidget(text);
break; break;
} }
......
...@@ -8,6 +8,7 @@ class CardInfo; ...@@ -8,6 +8,7 @@ class CardInfo;
class CardInfoPicture; class CardInfoPicture;
class CardInfoText; class CardInfoText;
class QVBoxLayout; class QVBoxLayout;
class QSplitter;
class CardFrame : public QTabWidget { class CardFrame : public QTabWidget {
Q_OBJECT Q_OBJECT
...@@ -19,11 +20,11 @@ private: ...@@ -19,11 +20,11 @@ private:
bool cardTextOnly; bool cardTextOnly;
QWidget *tab1, *tab2, *tab3; QWidget *tab1, *tab2, *tab3;
QVBoxLayout *tab1Layout, *tab2Layout, *tab3Layout; QVBoxLayout *tab1Layout, *tab2Layout, *tab3Layout;
QSplitter *splitter;
public: public:
enum ViewMode { ImageOnlyView, TextOnlyView, ImageAndTextView }; enum ViewMode { ImageOnlyView, TextOnlyView, ImageAndTextView };
CardFrame(int width, int height, const QString &cardName = QString(), CardFrame(const QString &cardName = QString(),
QWidget *parent = 0); QWidget *parent = 0);
void retranslateUi(); void retranslateUi();
public slots: public slots:
......
...@@ -8,14 +8,12 @@ ...@@ -8,14 +8,12 @@
#include "carddatabase.h" #include "carddatabase.h"
#include "main.h" #include "main.h"
CardInfoPicture::CardInfoPicture(int width, QWidget *parent) CardInfoPicture::CardInfoPicture(QWidget *parent)
: QWidget(parent), : QWidget(parent),
info(0), info(0),
pixmapDirty(true) pixmapDirty(true)
{ {
setFixedWidth(width);
setMinimumHeight(100); setMinimumHeight(100);
setMaximumHeight(width / (qreal) CARD_WIDTH * (qreal) CARD_HEIGHT);
} }
void CardInfoPicture::setCard(CardInfo *card) void CardInfoPicture::setCard(CardInfo *card)
......
...@@ -15,7 +15,7 @@ private: ...@@ -15,7 +15,7 @@ private:
bool pixmapDirty; bool pixmapDirty;
public: public:
CardInfoPicture(int width, QWidget *parent = 0); CardInfoPicture(QWidget *parent = 0);
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
......
...@@ -11,6 +11,7 @@ FilterBuilder::FilterBuilder(QWidget *parent) ...@@ -11,6 +11,7 @@ FilterBuilder::FilterBuilder(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
filterCombo = new QComboBox; filterCombo = new QComboBox;
filterCombo->setObjectName("filterCombo");
for (int i = 0; i < CardFilter::AttrEnd; i++) for (int i = 0; i < CardFilter::AttrEnd; i++)
filterCombo->addItem( filterCombo->addItem(
tr(CardFilter::attrName(static_cast<CardFilter::Attr>(i))), tr(CardFilter::attrName(static_cast<CardFilter::Attr>(i))),
...@@ -18,6 +19,7 @@ FilterBuilder::FilterBuilder(QWidget *parent) ...@@ -18,6 +19,7 @@ FilterBuilder::FilterBuilder(QWidget *parent)
); );
typeCombo = new QComboBox; typeCombo = new QComboBox;
typeCombo->setObjectName("typeCombo");
for (int i = 0; i < CardFilter::TypeEnd; i++) for (int i = 0; i < CardFilter::TypeEnd; i++)
typeCombo->addItem( typeCombo->addItem(
tr(CardFilter::typeName(static_cast<CardFilter::Type>(i))), tr(CardFilter::typeName(static_cast<CardFilter::Type>(i))),
...@@ -25,12 +27,15 @@ FilterBuilder::FilterBuilder(QWidget *parent) ...@@ -25,12 +27,15 @@ FilterBuilder::FilterBuilder(QWidget *parent)
); );
QPushButton *ok = new QPushButton(QIcon(":/resources/increment.svg"), QString()); QPushButton *ok = new QPushButton(QIcon(":/resources/increment.svg"), QString());
ok->setObjectName("ok");
ok->setMaximumSize(20, 20); ok->setMaximumSize(20, 20);
edit = new QLineEdit; edit = new QLineEdit;
edit->setObjectName("edit");
edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QGridLayout *layout = new QGridLayout; QGridLayout *layout = new QGridLayout;
layout->setObjectName("layout");
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(typeCombo, 0, 0, 1, 2); layout->addWidget(typeCombo, 0, 0, 1, 2);
......
...@@ -223,8 +223,8 @@ int main(int argc, char *argv[]) ...@@ -223,8 +223,8 @@ int main(int argc, char *argv[])
generateClientID(); //generate the users client id generateClientID(); //generate the users client id
qDebug() << "ClientID In Cache: " << settingsCache->getClientID(); qDebug() << "ClientID In Cache: " << settingsCache->getClientID();
ui.show(); ui.showMaximized();
qDebug("main(): ui.show() finished"); qDebug("main(): ui.showMaximized() finished");
app.exec(); app.exec();
} }
......
#include "settingscache.h" #include "settingscache.h"
#include <QSettings> #include <QSettings>
#if QT_VERSION >= 0x050000
#include <QStandardPaths>
#else
#include <QDesktopServices>
#endif
QString SettingsCache::getLayoutsSettingsPath()
{
QString file = "";
#ifndef PORTABLE_BUILD
#if QT_VERSION >= 0x050000
file = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#else
file = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#endif
file.append("/settings/layouts/");
#endif
return file;
}
SettingsCache::SettingsCache() SettingsCache::SettingsCache()
{ {
...@@ -97,6 +118,16 @@ SettingsCache::SettingsCache() ...@@ -97,6 +118,16 @@ SettingsCache::SettingsCache()
spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool(); spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool();
clientID = settings->value("personal/clientid", "notset").toString(); clientID = settings->value("personal/clientid", "notset").toString();
QString file = getLayoutsSettingsPath();
file.append("deckLayout.ini");
QSettings layout_settings(file , QSettings::IniFormat);
deckEditorLayoutState = layout_settings.value("layouts/deckEditor_state").toByteArray();
deckEditorGeometry = layout_settings.value("layouts/deckEditor_geometry").toByteArray();
deckEditorCardSize = layout_settings.value("layouts/deckEditor_CardSize", QSize(250,500)).toSize();
deckEditorFilterSize = layout_settings.value("layouts/deckEditor_FilterSize", QSize(250,250)).toSize();
deckEditorDeckSize = layout_settings.value("layouts/deckEditor_DeckSize", QSize(250,360)).toSize();
} }
void SettingsCache::setCardInfoViewMode(const int _viewMode) { void SettingsCache::setCardInfoViewMode(const int _viewMode) {
...@@ -462,6 +493,56 @@ QStringList SettingsCache::getCountries() const ...@@ -462,6 +493,56 @@ QStringList SettingsCache::getCountries() const
return countries; return countries;
} }
void SettingsCache::setDeckEditorLayoutState(const QByteArray &value)
{
deckEditorLayoutState = value;
QString file = getLayoutsSettingsPath();
file.append("deckLayout.ini");
QSettings layout_settings(file , QSettings::IniFormat);
layout_settings.setValue("layouts/deckEditor_state",value);
}
void SettingsCache::setDeckEditorGeometry(const QByteArray &value)
{
deckEditorGeometry = value;
QString file = getLayoutsSettingsPath();
file.append("deckLayout.ini");
QSettings layout_settings(file , QSettings::IniFormat);
layout_settings.setValue("layouts/deckEditor_geometry",value);
}
void SettingsCache::setDeckEditorCardSize(const QSize &value)
{
deckEditorCardSize = value;
QString file = getLayoutsSettingsPath();
file.append("deckLayout.ini");
QSettings layout_settings(file , QSettings::IniFormat);
layout_settings.setValue("layouts/deckEditor_CardSize",value);
}
void SettingsCache::setDeckEditorDeckSize(const QSize &value)
{
deckEditorDeckSize = value;
QString file = getLayoutsSettingsPath();
file.append("deckLayout.ini");
QSettings layout_settings(file , QSettings::IniFormat);
layout_settings.setValue("layouts/deckEditor_DeckSize",value);
}
void SettingsCache::setDeckEditorFilterSize(const QSize &value)
{
deckEditorFilterSize = value;
QString file = getLayoutsSettingsPath();
file.append("deckLayout.ini");
QSettings layout_settings(file , QSettings::IniFormat);
layout_settings.setValue("layouts/deckEditor_FilterSize",value);
}
void SettingsCache::setGameDescription(const QString _gameDescription) void SettingsCache::setGameDescription(const QString _gameDescription)
{ {
gameDescription = _gameDescription; gameDescription = _gameDescription;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define SETTINGSCACHE_H #define SETTINGSCACHE_H
#include <QObject> #include <QObject>
#include <QSize>
#include <QStringList> #include <QStringList>
// the falbacks are used for cards without a muid // the falbacks are used for cards without a muid
...@@ -99,6 +100,10 @@ private: ...@@ -99,6 +100,10 @@ private:
bool spectatorsCanTalk; bool spectatorsCanTalk;
bool spectatorsCanSeeEverything; bool spectatorsCanSeeEverything;
int keepalive; int keepalive;
QByteArray deckEditorLayoutState, deckEditorGeometry;
QSize deckEditorFilterSize, deckEditorDeckSize, deckEditorCardSize;
QString getLayoutsSettingsPath();
public: public:
SettingsCache(); SettingsCache();
const QByteArray &getMainWindowGeometry() const { return mainWindowGeometry; } const QByteArray &getMainWindowGeometry() const { return mainWindowGeometry; }
...@@ -172,6 +177,17 @@ public: ...@@ -172,6 +177,17 @@ public:
int getKeepAlive() const { return keepalive; } int getKeepAlive() const { return keepalive; }
void setClientID(QString clientID); void setClientID(QString clientID);
QString getClientID() { return clientID; } QString getClientID() { return clientID; }
QByteArray getDeckEditorLayoutState() const { return deckEditorLayoutState; }
void setDeckEditorLayoutState(const QByteArray &value);
QByteArray getDeckEditorGeometry() const { return deckEditorGeometry; }
void setDeckEditorGeometry(const QByteArray &value);
QSize getDeckEditorCardSize() const { return deckEditorCardSize; }
void setDeckEditorCardSize(const QSize &value);
QSize getDeckEditorDeckSize() const { return deckEditorDeckSize; }
void setDeckEditorDeckSize(const QSize &value);
QSize getDeckEditorFilterSize() const { return deckEditorFilterSize; }
void setDeckEditorFilterSize(const QSize &value);
public slots: public slots:
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry); void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
void setLang(const QString &_lang); void setLang(const QString &_lang);
......
This diff is collapsed.
...@@ -20,6 +20,10 @@ class FilterTreeModel; ...@@ -20,6 +20,10 @@ class FilterTreeModel;
class FilterBuilder; class FilterBuilder;
class CardInfo; class CardInfo;
class QGroupBox; class QGroupBox;
class QHBoxLayout;
class QPushButton;
class QMainWindow;
class QDockWidget;
class SearchLineEdit : public QLineEdit { class SearchLineEdit : public QLineEdit {
private: private:
...@@ -73,6 +77,12 @@ class TabDeckEditor : public Tab { ...@@ -73,6 +77,12 @@ class TabDeckEditor : public Tab {
void filterViewCustomContextMenu(const QPoint &point); void filterViewCustomContextMenu(const QPoint &point);
void filterRemove(QAction *action); void filterRemove(QAction *action);
void setPriceTagFeatureEnabled(int enabled); void setPriceTagFeatureEnabled(int enabled);
bool eventFilter(QObject *o, QEvent *e);
void loadLayout();
void restartLayout();
void freeDocksSize();
private: private:
CardInfo *currentCardInfo() const; CardInfo *currentCardInfo() const;
void addCardHelper(QString zoneName); void addCardHelper(QString zoneName);
...@@ -99,14 +109,25 @@ private: ...@@ -99,14 +109,25 @@ private:
QLabel *hashLabel; QLabel *hashLabel;
FilterTreeModel *filterModel; FilterTreeModel *filterModel;
QTreeView *filterView; QTreeView *filterView;
QGroupBox *filterBox; QWidget *filterBox;
QMenu *deckMenu, *dbMenu; QMenu *deckMenu, *dbMenu;
QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aAnalyzeDeck, *aClose, *aOpenCustomFolder; QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aAnalyzeDeck, *aClose, *aOpenCustomFolder;
QAction *aEditSets, *aEditTokens, *aClearFilterAll, *aClearFilterOne; QAction *aEditSets, *aEditTokens, *aClearFilterAll, *aClearFilterOne;
QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement;// *aUpdatePrices; QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement;// *aUpdatePrices;
QAction *aResetLayout;
bool modified; bool modified;
QMainWindow *MainWindow;
QVBoxLayout *centralFrame;
QHBoxLayout *searchLayout;
QPushButton *btnFilter;
QPushButton *btnDeck;
QPushButton *btnCard;
QDockWidget *cardInfoDock;
QDockWidget *deckDock;
QDockWidget *filterDock;
QWidget *centralWidget;
public: public:
TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent = 0); TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent = 0);
~TabDeckEditor(); ~TabDeckEditor();
...@@ -115,6 +136,13 @@ public: ...@@ -115,6 +136,13 @@ public:
void setDeck(DeckLoader *_deckLoader); void setDeck(DeckLoader *_deckLoader);
void setModified(bool _windowModified); void setModified(bool _windowModified);
bool confirmClose(); bool confirmClose();
void createShowHideDocksButtons();
void createDeckDock();
void createCardInfoDock();
void createFiltersDock();
void createMenus();
void createCentralFrame();
public slots: public slots:
void closeRequest(); void closeRequest();
void checkFirstRunDetected(); void checkFirstRunDetected();
......
...@@ -282,7 +282,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay) ...@@ -282,7 +282,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
gameView = new GameView(scene); gameView = new GameView(scene);
gameView->hide(); gameView->hide();
cardInfo = new CardFrame(250, 372); cardInfo = new CardFrame();
playerListWidget = new PlayerListWidget(0, 0, this); playerListWidget = new PlayerListWidget(0, 0, this);
playerListWidget->setFocusPolicy(Qt::NoFocus); playerListWidget->setFocusPolicy(Qt::NoFocus);
...@@ -396,7 +396,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client ...@@ -396,7 +396,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
gameView = new GameView(scene); gameView = new GameView(scene);
gameView->hide(); gameView->hide();
cardInfo = new CardFrame(250, 372); cardInfo = new CardFrame();
playerListWidget = new PlayerListWidget(tabSupervisor, clients.first(), this); playerListWidget = new PlayerListWidget(tabSupervisor, clients.first(), this);
playerListWidget->setFocusPolicy(Qt::NoFocus); playerListWidget->setFocusPolicy(Qt::NoFocus);
connect(playerListWidget, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool))); connect(playerListWidget, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment