Commit 54ebb6a5 authored by woogerboy21's avatar woogerboy21
Browse files

Merge branch 'master' into mod_notify_onbanwarn

parents 00afe74a f35c047d
...@@ -14,10 +14,7 @@ ...@@ -14,10 +14,7 @@
# Cockatrice # Cockatrice
Cockatrice is an open-source multiplatform software for playing card games, Cockatrice is an open-source multiplatform supported program for playing tabletop card games over a network. The program's server design prevents any kind of client modifications to gain an unfair advantage in a game. The client also has a built in single-player mode where you can brew without being connected to a server. This project is written in C++/Qt with support for both Qt4 and Qt5.<br>
such as Magic: The Gathering, over a network. It is fully client-server based
to prevent any kind of cheating, though it supports single-player games without
a network interface as well. Both client and server are written in Qt, supporting both Qt4 and Qt5.<br>
# Downloads # Downloads
......
...@@ -2,8 +2,10 @@ set(VERSION_STRING_CPP "${PROJECT_BINARY_DIR}/version_string.cpp") ...@@ -2,8 +2,10 @@ set(VERSION_STRING_CPP "${PROJECT_BINARY_DIR}/version_string.cpp")
set(VERSION_STRING_H "${PROJECT_BINARY_DIR}/version_string.h") set(VERSION_STRING_H "${PROJECT_BINARY_DIR}/version_string.h")
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
set( hstring "extern const char *VERSION_STRING\;\n" ) set( hstring "extern const char *VERSION_STRING\;
set( cppstring "const char * VERSION_STRING = \"${PROJECT_VERSION_FRIENDLY}\"\;\n") extern const char *VERSION_DATE\;\n" )
set( cppstring "const char *VERSION_STRING = \"${PROJECT_VERSION_FRIENDLY}\"\;
const char *VERSION_DATE = \"${GIT_COMMIT_DATE_FRIENDLY}\"\;\n")
file(WRITE ${PROJECT_BINARY_DIR}/version_string.cpp.txt ${cppstring} ) file(WRITE ${PROJECT_BINARY_DIR}/version_string.cpp.txt ${cppstring} )
file(WRITE ${PROJECT_BINARY_DIR}/version_string.h.txt ${hstring} ) file(WRITE ${PROJECT_BINARY_DIR}/version_string.h.txt ${hstring} )
......
...@@ -16,7 +16,8 @@ SET(cockatrice_SOURCES ...@@ -16,7 +16,8 @@ SET(cockatrice_SOURCES
src/dlg_edit_tokens.cpp src/dlg_edit_tokens.cpp
src/dlg_edit_user.cpp src/dlg_edit_user.cpp
src/dlg_register.cpp src/dlg_register.cpp
src/abstractclient.cpp src/dlg_update.cpp
src/abstractclient.cpp
src/remoteclient.cpp src/remoteclient.cpp
src/main.cpp src/main.cpp
src/window_main.cpp src/window_main.cpp
...@@ -107,6 +108,8 @@ SET(cockatrice_SOURCES ...@@ -107,6 +108,8 @@ SET(cockatrice_SOURCES
src/settings/messagesettings.cpp src/settings/messagesettings.cpp
src/settings/gamefilterssettings.cpp src/settings/gamefilterssettings.cpp
src/settings/layoutssettings.cpp src/settings/layoutssettings.cpp
src/update_checker.cpp
src/update_downloader.cpp
${VERSION_STRING_CPP} ${VERSION_STRING_CPP}
) )
......
#define HUMAN_DOWNLOAD_URL "https://bintray.com/cockatrice/Cockatrice/Cockatrice/_latestVersion"
#define API_DOWNLOAD_BASE_URL "https://dl.bintray.com/cockatrice/Cockatrice/"
#define DATE_LENGTH 10
#define MAX_DATE_LENGTH 100
#define SHORT_SHA1_HASH_LENGTH 7
#include <QtNetwork>
#include <QProgressDialog>
#include <QDesktopServices>
#include <QMessageBox>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QLabel>
#include <QProgressBar>
#include <QApplication>
#include "dlg_update.h"
#include "window_main.h"
DlgUpdate::DlgUpdate(QWidget *parent) : QDialog(parent) {
//Handle layout
text = new QLabel(this);
progress = new QProgressBar(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
ok = new QPushButton("Ok", this);
manualDownload = new QPushButton("Update Anyway", this);
enableUpdateButton(false); //Unless we know there's an update available, you can't install
gotoDownload = new QPushButton("Open Download Page", this);
buttonBox->addButton(manualDownload, QDialogButtonBox::ActionRole);
buttonBox->addButton(gotoDownload, QDialogButtonBox::ActionRole);
buttonBox->addButton(ok, QDialogButtonBox::AcceptRole);
connect(gotoDownload, SIGNAL(clicked()), this, SLOT(gotoDownloadPage()));
connect(manualDownload, SIGNAL(clicked()), this, SLOT(downloadUpdate()));
connect(ok, SIGNAL(clicked()), this, SLOT(closeDialog()));
QVBoxLayout *parentLayout = new QVBoxLayout(this);
parentLayout->addWidget(text);
parentLayout->addWidget(progress);
parentLayout->addWidget(buttonBox);
setLayout(parentLayout);
//Check for SSL (this probably isn't necessary)
if (!QSslSocket::supportsSsl()) {
enableUpdateButton(false);
QMessageBox::critical(
this,
tr("Error"),
tr("Cockatrice was not built with SSL support, so cannot download updates! "
"Please visit the download page and update manually."));
}
//Initialize the checker and downloader class
uDownloader = new UpdateDownloader(this);
connect(uDownloader, SIGNAL(downloadSuccessful(QUrl)), this, SLOT(downloadSuccessful(QUrl)));
connect(uDownloader, SIGNAL(progressMade(qint64, qint64)),
this, SLOT(downloadProgressMade(qint64, qint64)));
connect(uDownloader, SIGNAL(error(QString)),
this, SLOT(downloadError(QString)));
uChecker = new UpdateChecker(this);
connect(uChecker, SIGNAL(finishedCheck(bool, bool, QVariantMap * )),
this, SLOT(finishedUpdateCheck(bool, bool, QVariantMap * )));
connect(uChecker, SIGNAL(error(QString)),
this, SLOT(updateCheckError(QString)));
//Check for updates
beginUpdateCheck();
}
void DlgUpdate::closeDialog() {
accept();
}
void DlgUpdate::gotoDownloadPage() {
QUrl openUrl(HUMAN_DOWNLOAD_URL);
QDesktopServices::openUrl(openUrl);
}
void DlgUpdate::downloadUpdate() {
setLabel("Downloading update...");
enableUpdateButton(false);
uDownloader->beginDownload(updateUrl);
}
void DlgUpdate::beginUpdateCheck() {
progress->setMinimum(0);
progress->setMaximum(0);
setLabel("Checking for updates...");
uChecker->check();
}
void DlgUpdate::finishedUpdateCheck(bool needToUpdate, bool isCompatible, QVariantMap *build) {
QString commitHash, commitDate;
//Update the UI to say we've finished
progress->setMaximum(100);
setLabel("Finished checking for updates.");
//If there are no available builds, then they can't auto update.
enableUpdateButton(isCompatible);
//If there is an update, save its URL and work out its name
if (isCompatible) {
QString endUrl = (*build)["path"].toString();
updateUrl = API_DOWNLOAD_BASE_URL + endUrl;
commitHash = (*build)["sha1"].toString().left(SHORT_SHA1_HASH_LENGTH);
commitDate = (*build)["created"].toString().remove(DATE_LENGTH, MAX_DATE_LENGTH);
}
//Give the user the appropriate message
if (needToUpdate) {
if (isCompatible) {
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Update Available",
"A new build (commit " + commitHash + ") from " + commitDate +
" is available. Download?",
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes)
downloadUpdate();
}
else {
QMessageBox::information(this, "Cockatrice Update",
tr("Your version of Cockatrice is out of date, but there are no packages"
" available for your operating system. You may have to use a developer build or build from source"
" yourself. Please visit the download page."));
}
}
else {
//If there's no need to update, tell them that. However we still allow them to run the
//downloader themselves if there's a compatible build
QMessageBox::information(this, tr("Cockatrice Update"), tr("Your version of Cockatrice is up to date."));
}
}
void DlgUpdate::enableUpdateButton(bool enable) {
manualDownload->setEnabled(enable);
}
void DlgUpdate::setLabel(QString newText) {
text->setText(newText);
}
void DlgUpdate::updateCheckError(QString errorString) {
setLabel("Error");
QMessageBox::critical(this, tr("Update Error"), "An error occurred while checking for updates: " + errorString);
}
void DlgUpdate::downloadError(QString errorString) {
setLabel("Error");
enableUpdateButton(true);
QMessageBox::critical(this, tr("Update Error"), "An error occurred while downloading an update: " + errorString);
}
void DlgUpdate::downloadSuccessful(QUrl filepath) {
setLabel("Installing...");
//Try to open the installer. If it opens, quit Cockatrice
if (QDesktopServices::openUrl(filepath))
{
QMetaObject::invokeMethod((MainWindow*) parent(), "close", Qt::QueuedConnection);
close();
} else {
setLabel("Error");
QMessageBox::critical(this, tr("Update Error"), "Unable to open the installer. You might be able to manually update"
" by closing Cockatrice and running the installer at " + filepath.toLocalFile() + ".");
}
}
void DlgUpdate::downloadProgressMade(qint64 bytesRead, qint64 totalBytes) {
progress->setMaximum(totalBytes);
progress->setValue(bytesRead);
}
#ifndef DLG_UPDATE_H
#define DLG_UPDATE_H
#include <QtNetwork>
#include <QProgressDialog>
#include "update_checker.h"
#include "update_downloader.h"
class DlgUpdate : public QDialog {
Q_OBJECT
public:
DlgUpdate(QWidget *parent);
private slots:
void finishedUpdateCheck(bool needToUpdate, bool isCompatible, QVariantMap *build);
void gotoDownloadPage();
void downloadUpdate();
void updateCheckError(QString errorString);
void downloadSuccessful(QUrl filepath);
void downloadProgressMade(qint64 bytesRead, qint64 totalBytes);
void downloadError(QString errorString);
void closeDialog();
private:
QUrl updateUrl;
void enableUpdateButton(bool enable);
void beginUpdateCheck();
void setLabel(QString text);
QLabel *text;
QProgressBar *progress;
QPushButton *manualDownload, *gotoDownload, *ok;
QPushButton *cancel;
UpdateChecker *uChecker;
UpdateDownloader *uDownloader;
};
#endif
...@@ -88,10 +88,10 @@ CardSet *PictureToLoad::getCurrentSet() const ...@@ -88,10 +88,10 @@ CardSet *PictureToLoad::getCurrentSet() const
return 0; return 0;
} }
QStringList PictureLoader::md5Blacklist = QStringList() QStringList PictureLoaderWorker::md5Blacklist = QStringList()
<< "db0c48db407a907c16ade38de048a441"; // card back returned by gatherer when card is not found << "db0c48db407a907c16ade38de048a441"; // card back returned by gatherer when card is not found
PictureLoader::PictureLoader() PictureLoaderWorker::PictureLoaderWorker()
: QObject(0), : QObject(0),
downloadRunning(false), loadQueueRunning(false) downloadRunning(false), loadQueueRunning(false)
{ {
...@@ -110,12 +110,12 @@ PictureLoader::PictureLoader() ...@@ -110,12 +110,12 @@ PictureLoader::PictureLoader()
moveToThread(pictureLoaderThread); moveToThread(pictureLoaderThread);
} }
PictureLoader::~PictureLoader() PictureLoaderWorker::~PictureLoaderWorker()
{ {
pictureLoaderThread->deleteLater(); pictureLoaderThread->deleteLater();
} }
void PictureLoader::processLoadQueue() void PictureLoaderWorker::processLoadQueue()
{ {
if (loadQueueRunning) if (loadQueueRunning)
return; return;
...@@ -160,7 +160,7 @@ void PictureLoader::processLoadQueue() ...@@ -160,7 +160,7 @@ void PictureLoader::processLoadQueue()
} }
} }
bool PictureLoader::cardImageExistsOnDisk(QString & setName, QString & correctedCardname) bool PictureLoaderWorker::cardImageExistsOnDisk(QString & setName, QString & correctedCardname)
{ {
QImage image; QImage image;
QImageReader imgReader; QImageReader imgReader;
...@@ -194,7 +194,7 @@ bool PictureLoader::cardImageExistsOnDisk(QString & setName, QString & corrected ...@@ -194,7 +194,7 @@ bool PictureLoader::cardImageExistsOnDisk(QString & setName, QString & corrected
return false; return false;
} }
QString PictureLoader::getPicUrl() QString PictureLoaderWorker::getPicUrl()
{ {
if (!picDownload) return QString(""); if (!picDownload) return QString("");
...@@ -242,7 +242,7 @@ QString PictureLoader::getPicUrl() ...@@ -242,7 +242,7 @@ QString PictureLoader::getPicUrl()
return picUrl; return picUrl;
} }
void PictureLoader::startNextPicDownload() void PictureLoaderWorker::startNextPicDownload()
{ {
if (cardsToDownload.isEmpty()) { if (cardsToDownload.isEmpty()) {
cardBeingDownloaded = 0; cardBeingDownloaded = 0;
...@@ -267,7 +267,7 @@ void PictureLoader::startNextPicDownload() ...@@ -267,7 +267,7 @@ void PictureLoader::startNextPicDownload()
} }
} }
void PictureLoader::picDownloadFailed() void PictureLoaderWorker::picDownloadFailed()
{ {
if (cardBeingDownloaded.nextSet()) if (cardBeingDownloaded.nextSet())
{ {
...@@ -283,13 +283,13 @@ void PictureLoader::picDownloadFailed() ...@@ -283,13 +283,13 @@ void PictureLoader::picDownloadFailed()
} }
} }
bool PictureLoader::imageIsBlackListed(const QByteArray &picData) bool PictureLoaderWorker::imageIsBlackListed(const QByteArray &picData)
{ {
QString md5sum = QCryptographicHash::hash(picData, QCryptographicHash::Md5).toHex(); QString md5sum = QCryptographicHash::hash(picData, QCryptographicHash::Md5).toHex();
return md5Blacklist.contains(md5sum); return md5Blacklist.contains(md5sum);
} }
void PictureLoader::picDownloadFinished(QNetworkReply *reply) void PictureLoaderWorker::picDownloadFinished(QNetworkReply *reply)
{ {
if (reply->error()) { if (reply->error()) {
qDebug() << "Download failed:" << reply->errorString(); qDebug() << "Download failed:" << reply->errorString();
...@@ -349,7 +349,7 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply) ...@@ -349,7 +349,7 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
startNextPicDownload(); startNextPicDownload();
} }
void PictureLoader::enqueueImageLoad(CardInfo *card) void PictureLoaderWorker::enqueueImageLoad(CardInfo *card)
{ {
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
...@@ -367,20 +367,31 @@ void PictureLoader::enqueueImageLoad(CardInfo *card) ...@@ -367,20 +367,31 @@ void PictureLoader::enqueueImageLoad(CardInfo *card)
emit startLoadQueue(); emit startLoadQueue();
} }
void PictureLoader::picDownloadChanged() void PictureLoaderWorker::picDownloadChanged()
{ {
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
picDownload = settingsCache->getPicDownload(); picDownload = settingsCache->getPicDownload();
QPixmapCache::clear();
} }
void PictureLoader::picsPathChanged() void PictureLoaderWorker::picsPathChanged()
{ {
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
picsPath = settingsCache->getPicsPath(); picsPath = settingsCache->getPicsPath();
}
QPixmapCache::clear(); PictureLoader::PictureLoader()
: QObject(0)
{
worker = new PictureLoaderWorker;
connect(settingsCache, SIGNAL(picsPathChanged()), this, SLOT(picsPathChanged()));
connect(settingsCache, SIGNAL(picDownloadChanged()), this, SLOT(picDownloadChanged()));
connect(worker, SIGNAL(imageLoaded(CardInfo *, const QImage &)), this, SLOT(imageLoaded(CardInfo *, const QImage &)));
}
PictureLoader::~PictureLoader()
{
worker->deleteLater();
} }
void PictureLoader::internalGetCardBackPixmap(QPixmap &pixmap, QSize size) void PictureLoader::internalGetCardBackPixmap(QPixmap &pixmap, QSize size)
...@@ -388,7 +399,7 @@ void PictureLoader::internalGetCardBackPixmap(QPixmap &pixmap, QSize size) ...@@ -388,7 +399,7 @@ void PictureLoader::internalGetCardBackPixmap(QPixmap &pixmap, QSize size)
QString backCacheKey = "_trice_card_back_" + QString::number(size.width()) + QString::number(size.height()); QString backCacheKey = "_trice_card_back_" + QString::number(size.width()) + QString::number(size.height());
if(!QPixmapCache::find(backCacheKey, &pixmap)) if(!QPixmapCache::find(backCacheKey, &pixmap))
{ {
qDebug() << "cache fail for" << backCacheKey; qDebug() << "cache fail for" << backCacheKey;
pixmap = QPixmap("theme:cardback").scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); pixmap = QPixmap("theme:cardback").scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmapCache::insert(backCacheKey, pixmap); QPixmapCache::insert(backCacheKey, pixmap);
} }
...@@ -425,7 +436,7 @@ void PictureLoader::getPixmap(QPixmap &pixmap, CardInfo *card, QSize size) ...@@ -425,7 +436,7 @@ void PictureLoader::getPixmap(QPixmap &pixmap, CardInfo *card, QSize size)
if(card) if(card)
{ {
// add the card to the load queue // add the card to the load queue
getInstance().enqueueImageLoad(card); getInstance().worker->enqueueImageLoad(card);
} }
} }
...@@ -471,6 +482,16 @@ void PictureLoader::cacheCardPixmaps(QList<CardInfo *> cards) ...@@ -471,6 +482,16 @@ void PictureLoader::cacheCardPixmaps(QList<CardInfo *> cards)
if(QPixmapCache::find(key, &tmp)) if(QPixmapCache::find(key, &tmp))
continue; continue;
getInstance().enqueueImageLoad(card); getInstance().worker->enqueueImageLoad(card);
} }
} }
void PictureLoader::picDownloadChanged()
{
QPixmapCache::clear();
}
void PictureLoader::picsPathChanged()
{
QPixmapCache::clear();
}
\ No newline at end of file
...@@ -28,21 +28,14 @@ public: ...@@ -28,21 +28,14 @@ public:
bool nextSet(); bool nextSet();
}; };
class PictureLoader : public QObject { class PictureLoaderWorker : public QObject {
Q_OBJECT Q_OBJECT
public: public:
static PictureLoader& getInstance() PictureLoaderWorker();
{ ~PictureLoaderWorker();
static PictureLoader instance;
return instance;
}
private:
PictureLoader();
~PictureLoader();
// Don't implement
PictureLoader(PictureLoader const&);
void operator=(PictureLoader const&);
void enqueueImageLoad(CardInfo *card);
private:
static QStringList md5Blacklist; static QStringList md5Blacklist;
QThread *pictureLoaderThread; QThread *pictureLoaderThread;
...@@ -55,18 +48,9 @@ private: ...@@ -55,18 +48,9 @@ private:
PictureToLoad cardBeingDownloaded; PictureToLoad cardBeingDownloaded;
bool picDownload, downloadRunning, loadQueueRunning; bool picDownload, downloadRunning, loadQueueRunning;
void startNextPicDownload(); void startNextPicDownload();
void imageLoaded(CardInfo *card, const QImage &image);
QString getPicUrl(); QString getPicUrl();
bool cardImageExistsOnDisk(QString & setName, QString & correctedCardname); bool cardImageExistsOnDisk(QString & setName, QString & correctedCardname);
bool imageIsBlackListed(const QByteArray &picData); bool imageIsBlackListed(const QByteArray &picData);
public:
void enqueueImageLoad(CardInfo *card);
static void getPixmap(QPixmap &pixmap, CardInfo *card, QSize size);
static void clearPixmapCache(CardInfo *card);
static void clearPixmapCache();
static void cacheCardPixmaps(QList<CardInfo *> cards);
protected:
static void internalGetCardBackPixmap(QPixmap &pixmap, QSize size);
private slots: private slots:
void picDownloadFinished(QNetworkReply *reply); void picDownloadFinished(QNetworkReply *reply);
void picDownloadFailed(); void picDownloadFailed();
...@@ -77,6 +61,36 @@ public slots: ...@@ -77,6 +61,36 @@ public slots:
void processLoadQueue(); void processLoadQueue();
signals: signals:
void startLoadQueue(); void startLoadQueue();
void imageLoaded(CardInfo *card, const QImage &image);
}; };
class PictureLoader : public QObject {
Q_OBJECT
public:
static PictureLoader& getInstance()
{
static PictureLoader instance;
return instance;
}
private:
PictureLoader();
~PictureLoader();
// Don't implement
PictureLoader(PictureLoader const&);
void operator=(PictureLoader const&);
PictureLoaderWorker * worker;
public:
static void getPixmap(QPixmap &pixmap, CardInfo *card, QSize size);
static void clearPixmapCache(CardInfo *card);
static void clearPixmapCache();
static void cacheCardPixmaps(QList<CardInfo *> cards);
protected:
static void internalGetCardBackPixmap(QPixmap &pixmap, QSize size);
private slots:
void picDownloadChanged();
void picsPathChanged();
public slots:
void imageLoaded(CardInfo *card, const QImage &image);
};
#endif #endif
...@@ -57,3 +57,43 @@ void LayoutsSettings::setDeckEditorFilterSize(const QSize &value) ...@@ -57,3 +57,43 @@ void LayoutsSettings::setDeckEditorFilterSize(const QSize &value)
{ {
setValue(value,"layouts/deckEditor_FilterSize"); setValue(value,"layouts/deckEditor_FilterSize");
} }
void LayoutsSettings::setGamePlayAreaGeometry(const QByteArray &value)
{
setValue(value,"layouts/gameplayarea_geometry");
}
void LayoutsSettings::setGamePlayAreaState(const QByteArray &value)
{
setValue(value,"layouts/gameplayarea_state");
}
const QByteArray LayoutsSettings::getGamePlayAreaLayoutState()
{
return getValue("layouts/gameplayarea_state").toByteArray();
}
const QByteArray LayoutsSettings::getGamePlayAreaGeometry()
{
return getValue("layouts/gameplayarea_geometry").toByteArray();
}
void LayoutsSettings::setReplayPlayAreaGeometry(const QByteArray &value)
{
setValue(value,"layouts/replayplayarea_geometry");
}
void LayoutsSettings::setReplayPlayAreaState(const QByteArray &value)
{
setValue(value,"layouts/replayplayarea_state");
}
const QByteArray LayoutsSettings::getReplayPlayAreaLayoutState()
{
return getValue("layouts/replayplayarea_state").toByteArray();
}
const QByteArray LayoutsSettings::getReplayPlayAreaGeometry()
{
return getValue("layouts/replayplayarea_geometry").toByteArray();
}
...@@ -15,12 +15,20 @@ public: ...@@ -15,12 +15,20 @@ public:
void setDeckEditorCardSize(const QSize &value); void setDeckEditorCardSize(const QSize &value);
void setDeckEditorDeckSize(const QSize &value); void setDeckEditorDeckSize(const QSize &value);
void setDeckEditorFilterSize(const QSize &value); void setDeckEditorFilterSize(const QSize &value);
void setGamePlayAreaGeometry(const QByteArray &value);
void setGamePlayAreaState(const QByteArray &value);
void setReplayPlayAreaGeometry(const QByteArray &value);
void setReplayPlayAreaState(const QByteArray &value);
const QByteArray getDeckEditorLayoutState(); const QByteArray getDeckEditorLayoutState();
const QByteArray getDeckEditorGeometry(); const QByteArray getDeckEditorGeometry();
const QSize getDeckEditorCardSize(); const QSize getDeckEditorCardSize();
const QSize getDeckEditorDeckSize(); const QSize getDeckEditorDeckSize();
const QSize getDeckEditorFilterSize(); const QSize getDeckEditorFilterSize();
const QByteArray getGamePlayAreaLayoutState();
const QByteArray getGamePlayAreaGeometry();
const QByteArray getReplayPlayAreaLayoutState();
const QByteArray getReplayPlayAreaGeometry();
signals: signals:
public slots: public slots:
......
...@@ -612,4 +612,4 @@ void SettingsCache::setNotifyAboutUpdate(int _notifyaboutupdate) ...@@ -612,4 +612,4 @@ void SettingsCache::setNotifyAboutUpdate(int _notifyaboutupdate)
{ {
notifyAboutUpdates = _notifyaboutupdate; notifyAboutUpdates = _notifyaboutupdate;
settings->setValue("personal/updatenotification", notifyAboutUpdates); settings->setValue("personal/updatenotification", notifyAboutUpdates);
} }
\ No newline at end of file
...@@ -243,4 +243,5 @@ void ShortcutsSettings::fillDefaultShorcuts() ...@@ -243,4 +243,5 @@ void ShortcutsSettings::fillDefaultShorcuts()
defaultShortCuts["Player/phase9"] = parseSequenceString("F9"); defaultShortCuts["Player/phase9"] = parseSequenceString("F9");
defaultShortCuts["tab_room/aClearChat"] = parseSequenceString("F12"); defaultShortCuts["tab_room/aClearChat"] = parseSequenceString("F12");
defaultShortCuts["DlgLoadDeckFromClipboard/refreshButton"] = parseSequenceString("F5"); defaultShortCuts["DlgLoadDeckFromClipboard/refreshButton"] = parseSequenceString("F5");
defaultShortCuts["Player/aResetLayout"] = parseSequenceString("");
} }
...@@ -170,6 +170,8 @@ void SoundEngine::themeChangedSlot() ...@@ -170,6 +170,8 @@ void SoundEngine::themeChangedSlot()
<< "player_join" << "player_leave" << "player_disconnect" << "player_reconnect" << "player_concede" << "player_join" << "player_leave" << "player_disconnect" << "player_reconnect" << "player_concede"
// Spectator // Spectator
<< "spectator_join" << "spectator_leave" << "spectator_join" << "spectator_leave"
// Buddy
<< "buddy_join" << "buddy_leave"
// Chat & UI // Chat & UI
<< "chat_mention" << "all_mention" << "private_message"; << "chat_mention" << "all_mention" << "private_message";
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
Tab::Tab(TabSupervisor *_tabSupervisor, QWidget *parent) Tab::Tab(TabSupervisor *_tabSupervisor, QWidget *parent)
: QWidget(parent), tabSupervisor(_tabSupervisor), contentsChanged(false), infoPopup(0) : QMainWindow(parent), tabSupervisor(_tabSupervisor), contentsChanged(false), infoPopup(0)
{ {
setAttribute(Qt::WA_DeleteOnClose);
} }
void Tab::showCardInfoPopup(const QPoint &pos, const QString &cardName) void Tab::showCardInfoPopup(const QPoint &pos, const QString &cardName)
......
#ifndef TAB_H #ifndef TAB_H
#define TAB_H #define TAB_H
#include <QWidget> #include <QMainWindow>
class QMenu; class QMenu;
class TabSupervisor; class TabSupervisor;
class CardInfoWidget; class CardInfoWidget;
class Tab : public QWidget { class Tab : public QMainWindow {
Q_OBJECT Q_OBJECT
signals: signals:
void userEvent(bool globalEvent = true); void userEvent(bool globalEvent = true);
......
...@@ -83,7 +83,10 @@ TabAdmin::TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, bool ...@@ -83,7 +83,10 @@ TabAdmin::TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, bool
mainLayout->addWidget(lockButton); mainLayout->addWidget(lockButton);
retranslateUi(); retranslateUi();
setLayout(mainLayout);
QWidget * mainWidget = new QWidget(this);
mainWidget->setLayout(mainLayout);
setCentralWidget(mainWidget);
} }
void TabAdmin::retranslateUi() void TabAdmin::retranslateUi()
......
...@@ -52,30 +52,6 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event) ...@@ -52,30 +52,6 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event)
QLineEdit::keyPressEvent(event); QLineEdit::keyPressEvent(event);
} }
void TabDeckEditor::createShowHideDocksButtons()
{
btnFilter = new QPushButton(QPixmap("theme:icons/view"),QString());
btnFilter->setObjectName("btnFilter");
btnFilter->setCheckable(true);
btnFilter->setChecked(true);
btnFilter->setMaximumWidth(30);
searchLayout->addWidget(btnFilter);
btnDeck = new QPushButton(QPixmap("theme:hand"),QString());
btnDeck->setObjectName("btnDeck");
btnDeck->setCheckable(true);
btnDeck->setChecked(true);
btnDeck->setMaximumWidth(30);
searchLayout->addWidget(btnDeck);
btnCard = new QPushButton(QPixmap("theme:cardback"),QString());
btnCard->setObjectName("btnCard");
btnCard->setCheckable(true);
btnCard->setChecked(true);
btnCard->setMaximumWidth(30);
searchLayout->addWidget(btnCard);
}
void TabDeckEditor::createDeckDock() void TabDeckEditor::createDeckDock()
{ {
deckModel = new DeckListModel(this); deckModel = new DeckListModel(this);
...@@ -160,7 +136,7 @@ void TabDeckEditor::createDeckDock() ...@@ -160,7 +136,7 @@ void TabDeckEditor::createDeckDock()
rightFrame->addWidget(deckView, 10); rightFrame->addWidget(deckView, 10);
rightFrame->addLayout(deckToolbarLayout); rightFrame->addLayout(deckToolbarLayout);
deckDock = new QDockWidget(MainWindow); deckDock = new QDockWidget(this);
deckDock->setObjectName("deckDock"); deckDock->setObjectName("deckDock");
deckDock->setMinimumSize(QSize(200, 41)); deckDock->setMinimumSize(QSize(200, 41));
...@@ -171,8 +147,8 @@ void TabDeckEditor::createDeckDock() ...@@ -171,8 +147,8 @@ void TabDeckEditor::createDeckDock()
deckDockContents->setLayout(rightFrame); deckDockContents->setLayout(rightFrame);
deckDock->setWidget(deckDockContents); deckDock->setWidget(deckDockContents);
connect(btnDeck,SIGNAL(toggled(bool)),deckDock,SLOT(setVisible(bool)));
deckDock->installEventFilter(this); deckDock->installEventFilter(this);
connect(deckDock, SIGNAL(topLevelChanged(bool)), this, SLOT(dockTopLevelChanged(bool)));
} }
void TabDeckEditor::createCardInfoDock() void TabDeckEditor::createCardInfoDock()
...@@ -183,7 +159,7 @@ void TabDeckEditor::createCardInfoDock() ...@@ -183,7 +159,7 @@ void TabDeckEditor::createCardInfoDock()
cardInfoFrame->setObjectName("cardInfoFrame"); cardInfoFrame->setObjectName("cardInfoFrame");
cardInfoFrame->addWidget(cardInfo); cardInfoFrame->addWidget(cardInfo);
cardInfoDock = new QDockWidget(MainWindow); cardInfoDock = new QDockWidget(this);
cardInfoDock->setObjectName("cardInfoDock"); cardInfoDock->setObjectName("cardInfoDock");
cardInfoDock->setMinimumSize(QSize(200, 41)); cardInfoDock->setMinimumSize(QSize(200, 41));
...@@ -194,8 +170,8 @@ void TabDeckEditor::createCardInfoDock() ...@@ -194,8 +170,8 @@ void TabDeckEditor::createCardInfoDock()
cardInfoDockContents->setLayout(cardInfoFrame); cardInfoDockContents->setLayout(cardInfoFrame);
cardInfoDock->setWidget(cardInfoDockContents); cardInfoDock->setWidget(cardInfoDockContents);
connect(btnCard,SIGNAL(toggled(bool)),cardInfoDock,SLOT(setVisible(bool)));
cardInfoDock->installEventFilter(this); cardInfoDock->installEventFilter(this);
connect(cardInfoDock, SIGNAL(topLevelChanged(bool)), this, SLOT(dockTopLevelChanged(bool)));
} }
void TabDeckEditor::createFiltersDock() void TabDeckEditor::createFiltersDock()
...@@ -243,17 +219,17 @@ void TabDeckEditor::createFiltersDock() ...@@ -243,17 +219,17 @@ void TabDeckEditor::createFiltersDock()
filterFrame->setObjectName("filterFrame"); filterFrame->setObjectName("filterFrame");
filterFrame->addWidget(filterBox); filterFrame->addWidget(filterBox);
filterDock = new QDockWidget(MainWindow); filterDock = new QDockWidget(this);
filterDock->setObjectName("filterDock"); filterDock->setObjectName("filterDock");
filterDock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable); filterDock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
QWidget *filterDockContents = new QWidget(MainWindow); QWidget *filterDockContents = new QWidget(this);
filterDockContents->setObjectName("filterDockContents"); filterDockContents->setObjectName("filterDockContents");
filterDockContents->setLayout(filterFrame); filterDockContents->setLayout(filterFrame);
filterDock->setWidget(filterDockContents); filterDock->setWidget(filterDockContents);
connect(btnFilter,SIGNAL(toggled(bool)),filterDock,SLOT(setVisible(bool)));
filterDock->installEventFilter(this); filterDock->installEventFilter(this);
connect(filterDock, SIGNAL(topLevelChanged(bool)), this, SLOT(dockTopLevelChanged(bool)));
} }
void TabDeckEditor::createMenus() void TabDeckEditor::createMenus()
...@@ -297,9 +273,6 @@ void TabDeckEditor::createMenus() ...@@ -297,9 +273,6 @@ void TabDeckEditor::createMenus()
aEditTokens = new QAction(QString(), this); aEditTokens = new QAction(QString(), this);
connect(aEditTokens, SIGNAL(triggered()), this, SLOT(actEditTokens())); connect(aEditTokens, SIGNAL(triggered()), this, SLOT(actEditTokens()));
aResetLayout = new QAction(QString(), this);
connect(aResetLayout,SIGNAL(triggered()),this,SLOT(restartLayout()));
deckMenu = new QMenu(this); deckMenu = new QMenu(this);
deckMenu->addAction(aNewDeck); deckMenu->addAction(aNewDeck);
deckMenu->addAction(aLoadDeck); deckMenu->addAction(aLoadDeck);
...@@ -313,8 +286,6 @@ void TabDeckEditor::createMenus() ...@@ -313,8 +286,6 @@ void TabDeckEditor::createMenus()
deckMenu->addSeparator(); deckMenu->addSeparator();
deckMenu->addAction(aAnalyzeDeck); deckMenu->addAction(aAnalyzeDeck);
deckMenu->addSeparator(); deckMenu->addSeparator();
deckMenu->addAction(aResetLayout);
deckMenu->addSeparator();
deckMenu->addAction(aClose); deckMenu->addAction(aClose);
addTabMenu(deckMenu); addTabMenu(deckMenu);
...@@ -338,6 +309,41 @@ void TabDeckEditor::createMenus() ...@@ -338,6 +309,41 @@ void TabDeckEditor::createMenus()
dbMenu->addAction(aOpenCustomsetsFolder); dbMenu->addAction(aOpenCustomsetsFolder);
#endif #endif
addTabMenu(dbMenu); addTabMenu(dbMenu);
viewMenu = new QMenu(this);
cardInfoDockMenu = viewMenu->addMenu(QString());
deckDockMenu = viewMenu->addMenu(QString());
filterDockMenu = viewMenu->addMenu(QString());
aCardInfoDockVisible = cardInfoDockMenu->addAction(QString());
aCardInfoDockVisible->setCheckable(true);
connect(aCardInfoDockVisible,SIGNAL(triggered()),this,SLOT(dockVisibleTriggered()));
aCardInfoDockFloating = cardInfoDockMenu->addAction(QString());
aCardInfoDockFloating->setCheckable(true);
connect(aCardInfoDockFloating,SIGNAL(triggered()),this,SLOT(dockFloatingTriggered()));
aDeckDockVisible = deckDockMenu->addAction(QString());
aDeckDockVisible->setCheckable(true);
connect(aDeckDockVisible,SIGNAL(triggered()),this,SLOT(dockVisibleTriggered()));
aDeckDockFloating = deckDockMenu->addAction(QString());
aDeckDockFloating->setCheckable(true);
connect(aDeckDockFloating,SIGNAL(triggered()),this,SLOT(dockFloatingTriggered()));
aFilterDockVisible = filterDockMenu->addAction(QString());
aFilterDockVisible->setCheckable(true);
connect(aFilterDockVisible,SIGNAL(triggered()),this,SLOT(dockVisibleTriggered()));
aFilterDockFloating = filterDockMenu->addAction(QString());
aFilterDockFloating->setCheckable(true);
connect(aFilterDockFloating,SIGNAL(triggered()),this,SLOT(dockFloatingTriggered()));
viewMenu->addSeparator();
aResetLayout = viewMenu->addAction(QString());
connect(aResetLayout,SIGNAL(triggered()),this,SLOT(restartLayout()));
viewMenu->addAction(aResetLayout);
addTabMenu(viewMenu);
} }
void TabDeckEditor::createCentralFrame() void TabDeckEditor::createCentralFrame()
...@@ -414,41 +420,43 @@ void TabDeckEditor::createCentralFrame() ...@@ -414,41 +420,43 @@ void TabDeckEditor::createCentralFrame()
searchLayout->setObjectName("searchLayout"); searchLayout->setObjectName("searchLayout");
searchLayout->addWidget(deckEditToolBar); searchLayout->addWidget(deckEditToolBar);
searchLayout->addWidget(searchEdit); searchLayout->addWidget(searchEdit);
createShowHideDocksButtons();
centralFrame = new QVBoxLayout; centralFrame = new QVBoxLayout;
centralFrame->setObjectName("centralFrame"); centralFrame->setObjectName("centralFrame");
centralFrame->addLayout(searchLayout); centralFrame->addLayout(searchLayout);
centralFrame->addWidget(databaseView); centralFrame->addWidget(databaseView);
centralWidget = new QWidget(MainWindow); centralWidget = new QWidget(this);
centralWidget->setObjectName("centralWidget"); centralWidget->setObjectName("centralWidget");
centralWidget->setLayout(centralFrame); centralWidget->setLayout(centralFrame);
MainWindow->setCentralWidget(centralWidget); setCentralWidget(centralWidget);
MainWindow->setDockOptions(QMainWindow::AnimatedDocks|QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks); setDockOptions(QMainWindow::AnimatedDocks|QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setObjectName("mainLayout");
mainLayout->addWidget(MainWindow);
setLayout(mainLayout);
} }
void TabDeckEditor::restartLayout() void TabDeckEditor::restartLayout()
{ {
btnDeck->setChecked(true); deckDock->setVisible(true);
btnFilter->setChecked(true); cardInfoDock->setVisible(true);
btnCard->setChecked(true); filterDock->setVisible(true);
deckDock->setFloating(false); deckDock->setFloating(false);
cardInfoDock->setFloating(false); cardInfoDock->setFloating(false);
filterDock->setFloating(false); filterDock->setFloating(false);
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(2), deckDock); aCardInfoDockVisible->setChecked(true);
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(2), cardInfoDock); aDeckDockVisible->setChecked(true);
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(2), filterDock); aFilterDockVisible->setChecked(true);
MainWindow->splitDockWidget(cardInfoDock, deckDock, Qt::Horizontal); aCardInfoDockFloating->setChecked(false);
MainWindow->splitDockWidget(cardInfoDock, filterDock, Qt::Vertical); aDeckDockFloating->setChecked(false);
aFilterDockFloating->setChecked(false);
addDockWidget(static_cast<Qt::DockWidgetArea>(2), deckDock);
addDockWidget(static_cast<Qt::DockWidgetArea>(2), cardInfoDock);
addDockWidget(static_cast<Qt::DockWidgetArea>(2), filterDock);
splitDockWidget(cardInfoDock, deckDock, Qt::Horizontal);
splitDockWidget(cardInfoDock, filterDock, Qt::Vertical);
deckDock->setMinimumWidth(360); deckDock->setMinimumWidth(360);
deckDock->setMaximumWidth(360); deckDock->setMaximumWidth(360);
...@@ -496,12 +504,20 @@ void TabDeckEditor::refreshShortcuts() ...@@ -496,12 +504,20 @@ void TabDeckEditor::refreshShortcuts()
void TabDeckEditor::loadLayout() void TabDeckEditor::loadLayout()
{ {
MainWindow->restoreState(settingsCache->layouts().getDeckEditorLayoutState()); restoreState(settingsCache->layouts().getDeckEditorLayoutState());
MainWindow->restoreGeometry(settingsCache->layouts().getDeckEditorGeometry()); restoreGeometry(settingsCache->layouts().getDeckEditorGeometry());
aCardInfoDockVisible->setChecked(cardInfoDock->isVisible());
aFilterDockVisible->setChecked(filterDock->isVisible());
aDeckDockVisible->setChecked(deckDock->isVisible());
btnCard->setChecked(!cardInfoDock->isHidden()); aCardInfoDockFloating->setEnabled(aCardInfoDockVisible->isChecked());
btnFilter->setChecked(!filterDock->isHidden()); aDeckDockFloating->setEnabled(aDeckDockVisible->isChecked());
btnDeck->setChecked(!deckDock->isHidden()); aFilterDockFloating->setEnabled(aFilterDockVisible->isChecked());
aCardInfoDockFloating->setChecked(cardInfoDock->isFloating());
aFilterDockFloating->setChecked(filterDock->isFloating());
aDeckDockFloating->setChecked(deckDock->isFloating());
cardInfoDock->setMinimumSize(settingsCache->layouts().getDeckEditorCardSize()); cardInfoDock->setMinimumSize(settingsCache->layouts().getDeckEditorCardSize());
cardInfoDock->setMaximumSize(settingsCache->layouts().getDeckEditorCardSize()); cardInfoDock->setMaximumSize(settingsCache->layouts().getDeckEditorCardSize());
...@@ -518,8 +534,7 @@ void TabDeckEditor::loadLayout() ...@@ -518,8 +534,7 @@ void TabDeckEditor::loadLayout()
TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent) TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
: Tab(_tabSupervisor, parent), modified(false) : Tab(_tabSupervisor, parent), modified(false)
{ {
MainWindow = new QMainWindow; setObjectName("TabDeckEditor");
MainWindow->setObjectName("MainWindow");
createMenus(); createMenus();
...@@ -587,13 +602,25 @@ void TabDeckEditor::retranslateUi() ...@@ -587,13 +602,25 @@ void TabDeckEditor::retranslateUi()
aEditSets->setText(tr("&Edit sets...")); aEditSets->setText(tr("&Edit sets..."));
aEditTokens->setText(tr("Edit &tokens...")); aEditTokens->setText(tr("Edit &tokens..."));
btnCard->setToolTip(tr("Show/Hide card information"));
btnDeck->setToolTip(tr("Show/Hide deck"));
btnFilter->setToolTip(tr("Show/Hide filters"));
aResetLayout->setText(tr("Reset layout"));
cardInfoDock->setWindowTitle(tr("Card Info")); cardInfoDock->setWindowTitle(tr("Card Info"));
deckDock->setWindowTitle(tr("Deck")); deckDock->setWindowTitle(tr("Deck"));
filterDock->setWindowTitle(tr("Filters")); filterDock->setWindowTitle(tr("Filters"));
viewMenu->setTitle(tr("&View"));
cardInfoDockMenu->setTitle(tr("Card Info"));
deckDockMenu->setTitle(tr("Deck"));
filterDockMenu->setTitle(tr("Filters"));
aCardInfoDockVisible->setText(tr("Visible"));
aCardInfoDockFloating->setText(tr("Floating"));
aDeckDockVisible->setText(tr("Visible"));
aDeckDockFloating->setText(tr("Floating"));
aFilterDockVisible->setText(tr("Visible"));
aFilterDockFloating->setText(tr("Floating"));
aResetLayout->setText(tr("Reset layout"));
} }
QString TabDeckEditor::getTabText() const QString TabDeckEditor::getTabText() const
...@@ -998,28 +1025,6 @@ void TabDeckEditor::setPriceTagFeatureEnabled(int /* enabled */) ...@@ -998,28 +1025,6 @@ void TabDeckEditor::setPriceTagFeatureEnabled(int /* enabled */)
deckModel->pricesUpdated(); deckModel->pricesUpdated();
} }
bool TabDeckEditor::eventFilter(QObject * o, QEvent * e)
{
if(e->type() == QEvent::Close)
{
if(o == cardInfoDock)
btnCard->setChecked(false);
else if(o == deckDock)
btnDeck->setChecked(false);
else if(o == filterDock)
btnFilter->setChecked(false);
}
if( o == this && e->type() == QEvent::Hide){
settingsCache->layouts().setDeckEditorLayoutState(MainWindow->saveState());
settingsCache->layouts().setDeckEditorGeometry(MainWindow->saveGeometry());
settingsCache->layouts().setDeckEditorCardSize(cardInfoDock->size());
settingsCache->layouts().setDeckEditorFilterSize(filterDock->size());
settingsCache->layouts().setDeckEditorDeckSize(deckDock->size());
}
return false;
}
/* /*
void TabDeckEditor::actUpdatePrices() void TabDeckEditor::actUpdatePrices()
{ {
...@@ -1105,3 +1110,99 @@ void TabDeckEditor::checkFirstRunDetected() ...@@ -1105,3 +1110,99 @@ void TabDeckEditor::checkFirstRunDetected()
actEditSets(); actEditSets();
} }
} }
// Method uses to sync docks state with menu items state
bool TabDeckEditor::eventFilter(QObject * o, QEvent * e)
{
if(e->type() == QEvent::Close)
{
if(o == cardInfoDock)
{
aCardInfoDockVisible->setChecked(false);
aCardInfoDockFloating->setEnabled(false);
} else if(o == deckDock) {
aDeckDockVisible->setChecked(false);
aDeckDockFloating->setEnabled(false);
} else if(o == filterDock) {
aFilterDockVisible->setChecked(false);
aFilterDockFloating->setEnabled(false);
}
}
if( o == this && e->type() == QEvent::Hide){
settingsCache->layouts().setDeckEditorLayoutState(saveState());
settingsCache->layouts().setDeckEditorGeometry(saveGeometry());
settingsCache->layouts().setDeckEditorCardSize(cardInfoDock->size());
settingsCache->layouts().setDeckEditorFilterSize(filterDock->size());
settingsCache->layouts().setDeckEditorDeckSize(deckDock->size());
}
return false;
}
void TabDeckEditor::dockVisibleTriggered()
{
QObject *o = sender();
if(o == aCardInfoDockVisible)
{
cardInfoDock->setVisible(aCardInfoDockVisible->isChecked());
aCardInfoDockFloating->setEnabled(aCardInfoDockVisible->isChecked());
return;
}
if(o == aDeckDockVisible)
{
deckDock->setVisible(aDeckDockVisible->isChecked());
aDeckDockFloating->setEnabled(aDeckDockVisible->isChecked());
return;
}
if(o == aFilterDockVisible)
{
filterDock->setVisible(aFilterDockVisible->isChecked());
aFilterDockFloating->setEnabled(aFilterDockVisible->isChecked());
return;
}
}
void TabDeckEditor::dockFloatingTriggered()
{
QObject *o = sender();
if(o == aCardInfoDockFloating)
{
cardInfoDock->setFloating(aCardInfoDockFloating->isChecked());
return;
}
if(o == aDeckDockFloating)
{
deckDock->setFloating(aDeckDockFloating->isChecked());
return;
}
if(o == aFilterDockFloating)
{
filterDock->setFloating(aFilterDockFloating->isChecked());
return;
}
}
void TabDeckEditor::dockTopLevelChanged(bool topLevel)
{
QObject *o = sender();
if(o == cardInfoDock)
{
aCardInfoDockFloating->setChecked(topLevel);
return;
}
if(o == deckDock)
{
aDeckDockFloating->setChecked(topLevel);
return;
}
if(o == filterDock)
{
aFilterDockFloating->setChecked(topLevel);
return;
}
}
...@@ -22,7 +22,6 @@ class CardInfo; ...@@ -22,7 +22,6 @@ class CardInfo;
class QGroupBox; class QGroupBox;
class QHBoxLayout; class QHBoxLayout;
class QPushButton; class QPushButton;
class QMainWindow;
class QDockWidget; class QDockWidget;
class SearchLineEdit : public QLineEdit { class SearchLineEdit : public QLineEdit {
...@@ -79,12 +78,15 @@ class TabDeckEditor : public Tab { ...@@ -79,12 +78,15 @@ class TabDeckEditor : public Tab {
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 loadLayout();
void restartLayout(); void restartLayout();
void freeDocksSize(); void freeDocksSize();
void refreshShortcuts(); void refreshShortcuts();
bool eventFilter(QObject *o, QEvent *e);
void dockVisibleTriggered();
void dockFloatingTriggered();
void dockTopLevelChanged(bool topLevel);
private: private:
CardInfo *currentCardInfo() const; CardInfo *currentCardInfo() const;
void addCardHelper(QString zoneName); void addCardHelper(QString zoneName);
...@@ -113,19 +115,16 @@ private: ...@@ -113,19 +115,16 @@ private:
QTreeView *filterView; QTreeView *filterView;
QWidget *filterBox; QWidget *filterBox;
QMenu *deckMenu, *dbMenu; QMenu *deckMenu, *dbMenu, *viewMenu, *cardInfoDockMenu, *deckDockMenu, *filterDockMenu;
QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aAnalyzeDeck, *aClose, *aOpenCustomFolder, *aOpenCustomsetsFolder; QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aAnalyzeDeck, *aClose, *aOpenCustomFolder, *aOpenCustomsetsFolder;
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; QAction *aResetLayout;
QAction *aCardInfoDockVisible, *aCardInfoDockFloating, *aDeckDockVisible, *aDeckDockFloating, *aFilterDockVisible, *aFilterDockFloating;
bool modified; bool modified;
QMainWindow *MainWindow;
QVBoxLayout *centralFrame; QVBoxLayout *centralFrame;
QHBoxLayout *searchLayout; QHBoxLayout *searchLayout;
QPushButton *btnFilter;
QPushButton *btnDeck;
QPushButton *btnCard;
QDockWidget *cardInfoDock; QDockWidget *cardInfoDock;
QDockWidget *deckDock; QDockWidget *deckDock;
QDockWidget *filterDock; QDockWidget *filterDock;
...@@ -138,7 +137,6 @@ public: ...@@ -138,7 +137,6 @@ 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 createDeckDock();
void createCardInfoDock(); void createCardInfoDock();
void createFiltersDock(); void createFiltersDock();
......
...@@ -110,7 +110,10 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c ...@@ -110,7 +110,10 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c
rightToolBar->addAction(aDeleteRemoteDeck); rightToolBar->addAction(aDeleteRemoteDeck);
retranslateUi(); retranslateUi();
setLayout(hbox);
QWidget * mainWidget = new QWidget(this);
mainWidget->setLayout(hbox);
setCentralWidget(mainWidget);
} }
void TabDeckStorage::retranslateUi() void TabDeckStorage::retranslateUi()
......
This diff is collapsed.
...@@ -56,6 +56,8 @@ class GameReplay; ...@@ -56,6 +56,8 @@ class GameReplay;
class ServerInfo_User; class ServerInfo_User;
class PendingCommand; class PendingCommand;
class LineEditCompleter; class LineEditCompleter;
class QDockWidget;
class QStackedWidget;
class ToggleButton : public QPushButton { class ToggleButton : public QPushButton {
Q_OBJECT Q_OBJECT
...@@ -77,6 +79,7 @@ private: ...@@ -77,6 +79,7 @@ private:
QPushButton *loadLocalButton, *loadRemoteButton; QPushButton *loadLocalButton, *loadRemoteButton;
ToggleButton *readyStartButton, *sideboardLockButton; ToggleButton *readyStartButton, *sideboardLockButton;
DeckView *deckView; DeckView *deckView;
TabGame *parentGame;
int playerId; int playerId;
private slots: private slots:
void loadLocalDeck(); void loadLocalDeck();
...@@ -90,7 +93,7 @@ private slots: ...@@ -90,7 +93,7 @@ private slots:
signals: signals:
void newCardAdded(AbstractCardItem *card); void newCardAdded(AbstractCardItem *card);
public: public:
DeckViewContainer(int _playerId, TabGame *parent = 0); DeckViewContainer(int _playerId, TabGame *parent);
void retranslateUi(); void retranslateUi();
void setButtonsVisible(bool _visible); void setButtonsVisible(bool _visible);
void setReadyStart(bool ready); void setReadyStart(bool ready);
...@@ -121,6 +124,7 @@ private: ...@@ -121,6 +124,7 @@ private:
QStringList gameTypes; QStringList gameTypes;
QCompleter *completer; QCompleter *completer;
QStringList autocompleteUserList; QStringList autocompleteUserList;
QStackedWidget * mainWidget;
// Replay related members // Replay related members
GameReplay *replay; GameReplay *replay;
...@@ -128,8 +132,7 @@ private: ...@@ -128,8 +132,7 @@ private:
QList<int> replayTimeline; QList<int> replayTimeline;
ReplayTimelineWidget *timelineWidget; ReplayTimelineWidget *timelineWidget;
QToolButton *replayStartButton, *replayPauseButton, *replayFastForwardButton; QToolButton *replayStartButton, *replayPauseButton, *replayFastForwardButton;
QSplitter *splitter;
CardFrame *cardInfo; CardFrame *cardInfo;
PlayerListWidget *playerListWidget; PlayerListWidget *playerListWidget;
QLabel *timeElapsedLabel; QLabel *timeElapsedLabel;
...@@ -140,13 +143,14 @@ private: ...@@ -140,13 +143,14 @@ private:
GameScene *scene; GameScene *scene;
GameView *gameView; GameView *gameView;
QMap<int, DeckViewContainer *> deckViewContainers; QMap<int, DeckViewContainer *> deckViewContainers;
QVBoxLayout *deckViewContainerLayout; QVBoxLayout *cardVInfoLayout, *messageLogLayout, *gamePlayAreaVBox, *deckViewContainerLayout;
QHBoxLayout *mainLayout; QHBoxLayout *cardHInfoLayout, *sayHLayout, *mainHLayout, *replayControlLayout;
ZoneViewLayout *zoneLayout; QWidget *cardBoxLayoutWidget, *messageLogLayoutWidget, *gamePlayAreaWidget, *deckViewContainerWidget, *replayControlWidget;
QDockWidget *cardInfoDock, *messageLayoutDock, *playerListDock, *replayDock;
QAction *playersSeparator; QAction *playersSeparator;
QMenu *gameMenu; QMenu *gameMenu, *phasesMenu, *viewMenu, *cardInfoDockMenu, *messageLayoutDockMenu, *playerListDockMenu, *replayDockMenu;
QMenu *phasesMenu; QAction *aGameInfo, *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW, *aResetLayout, *aResetReplayLayout;
QAction *aGameInfo, *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW; QAction *aCardInfoDockVisible, *aCardInfoDockFloating, *aMessageLayoutDockVisible, *aMessageLayoutDockFloating, *aPlayerListDockVisible, *aPlayerListDockFloating, *aReplayDockVisible, *aReplayDockFloating;
QList<QAction *> phaseActions; QList<QAction *> phaseActions;
Player *addPlayer(int playerId, const ServerInfo_User &info); Player *addPlayer(int playerId, const ServerInfo_User &info);
...@@ -171,6 +175,15 @@ private: ...@@ -171,6 +175,15 @@ private:
void eventSetActivePhase(const Event_SetActivePhase &event, int eventPlayerId, const GameEventContext &context); void eventSetActivePhase(const Event_SetActivePhase &event, int eventPlayerId, const GameEventContext &context);
void eventPing(const Event_Ping &event, int eventPlayerId, const GameEventContext &context); void eventPing(const Event_Ping &event, int eventPlayerId, const GameEventContext &context);
void emitUserEvent(); void emitUserEvent();
void createMenuItems();
void createReplayMenuItems();
void createViewMenuItems();
void createCardInfoDock(bool bReplay=false);
void createPlayerListDock(bool bReplay=false);
void createMessageDock(bool bReplay=false);
void createPlayAreaWidget(bool bReplay=false);
void createDeckViewContainerWidget(bool bReplay=false);
void createReplayDock();
signals: signals:
void gameClosing(TabGame *tab); void gameClosing(TabGame *tab);
void playerAdded(Player *player); void playerAdded(Player *player);
...@@ -207,7 +220,14 @@ private slots: ...@@ -207,7 +220,14 @@ private slots:
void refreshShortcuts(); void refreshShortcuts();
void loadLayout();
void actCompleterChanged(); void actCompleterChanged();
void actResetLayout();
bool eventFilter(QObject *o, QEvent *e);
void dockVisibleTriggered();
void dockFloatingTriggered();
void dockTopLevelChanged(bool topLevel);
public: public:
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes); TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes);
TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay); TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
......
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