mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 12:23:58 -07:00
Merge branch 'master' into tooomm-qt5
This commit is contained in:
commit
9d4cf57c70
593 changed files with 12518 additions and 6581 deletions
|
|
@ -137,8 +137,6 @@ void AbstractTabDeckEditor::onDeckModified()
|
|||
void AbstractTabDeckEditor::addCardHelper(const ExactCard &card, const QString &zoneName)
|
||||
{
|
||||
deckStateManager->addCard(card, zoneName);
|
||||
|
||||
cardDatabaseDockWidget->highlightAllSearchEdit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -146,10 +144,11 @@ void AbstractTabDeckEditor::addCardHelper(const ExactCard &card, const QString &
|
|||
*/
|
||||
void AbstractTabDeckEditor::actAddCard(const ExactCard &card)
|
||||
{
|
||||
if (QApplication::keyboardModifiers() & Qt::ControlModifier)
|
||||
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
|
||||
actAddCardToSideboard(card);
|
||||
else
|
||||
} else {
|
||||
addCardHelper(card, DECK_ZONE_MAIN);
|
||||
}
|
||||
|
||||
deckMenu->setSaveStatus(true);
|
||||
}
|
||||
|
|
@ -203,8 +202,9 @@ void AbstractTabDeckEditor::setDeck(const LoadedDeck &_deck)
|
|||
void AbstractTabDeckEditor::actNewDeck()
|
||||
{
|
||||
auto deckOpenLocation = confirmOpen(false);
|
||||
if (deckOpenLocation == CANCELLED)
|
||||
if (deckOpenLocation == CANCELLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deckOpenLocation == NEW_TAB) {
|
||||
emit openDeckEditor(LoadedDeck());
|
||||
|
|
@ -229,22 +229,25 @@ void AbstractTabDeckEditor::cleanDeckAndResetModified()
|
|||
AbstractTabDeckEditor::DeckOpenLocation AbstractTabDeckEditor::confirmOpen(const bool openInSameTabIfBlank)
|
||||
{
|
||||
if (SettingsCache::instance().getOpenDeckInNewTab()) {
|
||||
if (openInSameTabIfBlank && deckStateManager->isBlankNewDeck())
|
||||
if (openInSameTabIfBlank && deckStateManager->isBlankNewDeck()) {
|
||||
return SAME_TAB;
|
||||
else
|
||||
} else {
|
||||
return NEW_TAB;
|
||||
}
|
||||
}
|
||||
|
||||
if (!deckStateManager->isModified())
|
||||
if (!deckStateManager->isModified()) {
|
||||
return SAME_TAB;
|
||||
}
|
||||
|
||||
tabSupervisor->setCurrentWidget(this);
|
||||
QMessageBox *msgBox = createSaveConfirmationWindow();
|
||||
QPushButton *newTabButton = msgBox->addButton(tr("Open in new tab"), QMessageBox::ApplyRole);
|
||||
int ret = msgBox->exec();
|
||||
|
||||
if (msgBox->clickedButton() == newTabButton)
|
||||
if (msgBox->clickedButton() == newTabButton) {
|
||||
return NEW_TAB;
|
||||
}
|
||||
|
||||
switch (ret) {
|
||||
case QMessageBox::Save:
|
||||
|
|
@ -277,12 +280,14 @@ QMessageBox *AbstractTabDeckEditor::createSaveConfirmationWindow()
|
|||
void AbstractTabDeckEditor::actLoadDeck()
|
||||
{
|
||||
auto deckOpenLocation = confirmOpen();
|
||||
if (deckOpenLocation == CANCELLED)
|
||||
if (deckOpenLocation == CANCELLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
DlgLoadDeck dialog(this);
|
||||
if (!dialog.exec())
|
||||
if (!dialog.exec()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString fileName = dialog.selectedFiles().at(0);
|
||||
openDeckFromFile(fileName, deckOpenLocation);
|
||||
|
|
@ -295,8 +300,9 @@ void AbstractTabDeckEditor::actLoadDeck()
|
|||
void AbstractTabDeckEditor::actOpenRecent(const QString &fileName)
|
||||
{
|
||||
auto deckOpenLocation = confirmOpen();
|
||||
if (deckOpenLocation == CANCELLED)
|
||||
if (deckOpenLocation == CANCELLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
openDeckFromFile(fileName, deckOpenLocation);
|
||||
}
|
||||
|
|
@ -349,8 +355,9 @@ bool AbstractTabDeckEditor::actSaveDeck()
|
|||
|
||||
return true;
|
||||
}
|
||||
if (loadedDeck.lastLoadInfo.fileName.isEmpty())
|
||||
if (loadedDeck.lastLoadInfo.fileName.isEmpty()) {
|
||||
return actSaveDeckAs();
|
||||
}
|
||||
|
||||
if (DeckLoader::saveToFile(loadedDeck)) {
|
||||
deckStateManager->setModified(false);
|
||||
|
|
@ -378,8 +385,9 @@ bool AbstractTabDeckEditor::actSaveDeckAs()
|
|||
dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS);
|
||||
dialog.selectFile(deckList.getName().trimmed());
|
||||
|
||||
if (!dialog.exec())
|
||||
if (!dialog.exec()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString fileName = dialog.selectedFiles().at(0);
|
||||
DeckFileFormat::Format fmt = DeckFileFormat::getFormatFromName(fileName);
|
||||
|
|
@ -405,10 +413,11 @@ bool AbstractTabDeckEditor::actSaveDeckAs()
|
|||
*/
|
||||
void AbstractTabDeckEditor::saveDeckRemoteFinished(const Response &response)
|
||||
{
|
||||
if (response.response_code() != Response::RespOk)
|
||||
if (response.response_code() != Response::RespOk) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("The deck could not be saved."));
|
||||
else
|
||||
} else {
|
||||
deckStateManager->setModified(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -418,12 +427,14 @@ void AbstractTabDeckEditor::saveDeckRemoteFinished(const Response &response)
|
|||
void AbstractTabDeckEditor::actLoadDeckFromClipboard()
|
||||
{
|
||||
auto deckOpenLocation = confirmOpen();
|
||||
if (deckOpenLocation == CANCELLED)
|
||||
if (deckOpenLocation == CANCELLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
DlgLoadDeckFromClipboard dlg(this);
|
||||
if (!dlg.exec())
|
||||
if (!dlg.exec()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deckOpenLocation == NEW_TAB) {
|
||||
emit openDeckEditor({.deckList = dlg.getDeckList()});
|
||||
|
|
@ -443,8 +454,9 @@ void AbstractTabDeckEditor::editDeckInClipboard(bool annotated)
|
|||
{
|
||||
LoadedDeck loadedDeck = deckStateManager->toLoadedDeck();
|
||||
DlgEditDeckInClipboard dlg(loadedDeck.deckList, annotated, this);
|
||||
if (!dlg.exec())
|
||||
if (!dlg.exec()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setDeck({dlg.getDeckList(), loadedDeck.lastLoadInfo});
|
||||
deckStateManager->setModified(true);
|
||||
|
|
@ -502,12 +514,14 @@ void AbstractTabDeckEditor::actPrintDeck()
|
|||
void AbstractTabDeckEditor::actLoadDeckFromWebsite()
|
||||
{
|
||||
auto deckOpenLocation = confirmOpen();
|
||||
if (deckOpenLocation == CANCELLED)
|
||||
if (deckOpenLocation == CANCELLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
DlgLoadDeckFromWebsite dlg(this);
|
||||
if (!dlg.exec())
|
||||
if (!dlg.exec()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deckOpenLocation == NEW_TAB) {
|
||||
emit openDeckEditor({.deckList = dlg.getDeck()});
|
||||
|
|
@ -590,10 +604,11 @@ bool AbstractTabDeckEditor::confirmClose()
|
|||
if (deckStateManager->isModified()) {
|
||||
tabSupervisor->setCurrentWidget(this);
|
||||
int ret = createSaveConfirmationWindow()->exec();
|
||||
if (ret == QMessageBox::Save)
|
||||
if (ret == QMessageBox::Save) {
|
||||
return actSaveDeck();
|
||||
else if (ret == QMessageBox::Cancel)
|
||||
} else if (ret == QMessageBox::Cancel) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -601,7 +616,8 @@ bool AbstractTabDeckEditor::confirmClose()
|
|||
/** @brief Handles close requests from outside (tab manager). */
|
||||
bool AbstractTabDeckEditor::closeRequest()
|
||||
{
|
||||
if (!confirmClose())
|
||||
if (!confirmClose()) {
|
||||
return false;
|
||||
}
|
||||
return close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,55 +98,79 @@ inline static DeckFormat apiNameToFormat(const QString &name)
|
|||
{
|
||||
const QString n = name.trimmed();
|
||||
|
||||
if (n.compare("Standard", Qt::CaseInsensitive) == 0)
|
||||
if (n.compare("Standard", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Standard;
|
||||
if (n.compare("Modern", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Modern", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Modern;
|
||||
if (n.compare("Commander", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Commander", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Commander;
|
||||
if (n.compare("Legacy", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Legacy", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Legacy;
|
||||
if (n.compare("Vintage", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Vintage", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Vintage;
|
||||
if (n.compare("Pauper", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Pauper", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Pauper;
|
||||
if (n.compare("Custom", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Custom", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Custom;
|
||||
if (n.compare("Frontier", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Frontier", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Frontier;
|
||||
if (n.compare("Future Std", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Future Std", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::FutureStandard;
|
||||
if (n.compare("Penny Dreadful", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Penny Dreadful", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::PennyDreadful;
|
||||
if (n.compare("1v1 Commander", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("1v1 Commander", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Commander1v1;
|
||||
if (n.compare("Dual Commander", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Dual Commander", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::DualCommander;
|
||||
if (n.compare("Brawl", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Brawl", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Brawl;
|
||||
}
|
||||
|
||||
if (n.compare("Alchemy", Qt::CaseInsensitive) == 0)
|
||||
if (n.compare("Alchemy", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Alchemy;
|
||||
if (n.compare("Historic", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Historic", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Historic;
|
||||
if (n.compare("Gladiator", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Gladiator", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Gladiator;
|
||||
if (n.compare("Oathbreaker", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Oathbreaker", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Oathbreaker;
|
||||
if (n.compare("Old School", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Old School", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::OldSchool;
|
||||
if (n.compare("Pauper Commander", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Pauper Commander", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::PauperCommander;
|
||||
if (n.compare("Pioneer", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Pioneer", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Pioneer;
|
||||
if (n.compare("PreDH", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("PreDH", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::PreDH;
|
||||
if (n.compare("Premodern", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Premodern", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Premodern;
|
||||
if (n.compare("Standard Brawl", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Standard Brawl", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::StandardBrawl;
|
||||
if (n.compare("Timeless", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Timeless", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Timeless;
|
||||
}
|
||||
|
||||
return DeckFormat::Unknown;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,16 +21,16 @@ void ArchidektApiResponseCard::fromJson(const QJsonObject &json)
|
|||
edition.fromJson(json.value("edition").toObject());
|
||||
|
||||
flavor = json.value("flavor").toString();
|
||||
//! \todo but not really important
|
||||
//! \todo games = {""};
|
||||
//! \todo options = {""};
|
||||
//! \todo Parse games and options fields (not really important).
|
||||
// games = {""};
|
||||
// options = {""};
|
||||
scryfallImageHash = json.value("scryfallImageHash").toString();
|
||||
oracleCard = json.value("oracleCard").toObject();
|
||||
owned = json.value("owned").toInt();
|
||||
pinnedStatus = json.value("pinnedStatus").toInt();
|
||||
rarity = json.value("rarity").toString();
|
||||
//! \todo but not really important
|
||||
//! \todo globalCategories = {""};
|
||||
//! \todo Parse globalCategories field (not really important).
|
||||
// globalCategories = {""};
|
||||
}
|
||||
|
||||
void ArchidektApiResponseCard::debugPrint() const
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public:
|
|||
QJsonObject getOracleCard() const
|
||||
{
|
||||
return oracleCard;
|
||||
};
|
||||
}
|
||||
|
||||
QString getCollectorNumber() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public:
|
|||
ArchidektApiResponseCard getCard() const
|
||||
{
|
||||
return card;
|
||||
};
|
||||
}
|
||||
|
||||
QList<Category> getCategories() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ void ArchidektApiResponseDeck::fromJson(const QJsonObject &json)
|
|||
cards.append(entry);
|
||||
}
|
||||
|
||||
// TODO but not really important
|
||||
//! \todo Parse customCards field (not really important).
|
||||
// customCards = {""};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public:
|
|||
QVector<ArchidektApiResponseCardEntry> getCards() const
|
||||
{
|
||||
return cards;
|
||||
};
|
||||
}
|
||||
|
||||
QVector<ArchidektApiResponseDeckCategory> getCategories() const
|
||||
{
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
QString getDeckName() const
|
||||
{
|
||||
return name;
|
||||
};
|
||||
}
|
||||
|
||||
int getDeckFormat() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ void ArchidektApiResponseDeckListingContainer::fromJson(const QJsonObject &json)
|
|||
theoryCrafted = json.value("theoryCrafted").toBool();
|
||||
game = json.value("game").toString();
|
||||
hasDescription = json.value("hasDescription").toBool();
|
||||
// TODO
|
||||
//! \todo Parse tags field.
|
||||
// tags = {""};
|
||||
parentFolderId = json.value("parentFolderId").toInt();
|
||||
owner.fromJson(json.value("owner").toObject());
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ void ArchidektApiResponseDeckOwner::fromJson(const QJsonObject &json)
|
|||
avatar = QUrl(json.value("avatar").toString());
|
||||
moderator = json.value("moderator").toBool();
|
||||
pledgeLevel = json.value("pledgeLevel").toInt();
|
||||
// TODO but not really important
|
||||
//! \todo Parse roles field (not really important).
|
||||
// roles = {""};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,21 +20,27 @@ static QString timeAgo(const QString ×tamp)
|
|||
{
|
||||
QDateTime dt = QDateTime::fromString(timestamp, Qt::ISODate);
|
||||
|
||||
if (!dt.isValid())
|
||||
if (!dt.isValid()) {
|
||||
return timestamp; // fallback if parsing fails
|
||||
}
|
||||
|
||||
qint64 secs = dt.secsTo(QDateTime::currentDateTimeUtc());
|
||||
|
||||
if (secs < 60)
|
||||
if (secs < 60) {
|
||||
return QString("%1 seconds ago").arg(secs);
|
||||
if (secs < 3600)
|
||||
}
|
||||
if (secs < 3600) {
|
||||
return QString("%1 minutes ago").arg(secs / 60);
|
||||
if (secs < 86400)
|
||||
}
|
||||
if (secs < 86400) {
|
||||
return QString("%1 hours ago").arg(secs / 3600);
|
||||
if (secs < 30 * 86400)
|
||||
}
|
||||
if (secs < 30 * 86400) {
|
||||
return QString("%1 days ago").arg(secs / 86400);
|
||||
if (secs < 365 * 86400)
|
||||
}
|
||||
if (secs < 365 * 86400) {
|
||||
return QString("%1 months ago").arg(secs / (30 * 86400));
|
||||
}
|
||||
|
||||
return QString("%1 years ago").arg(secs / (365 * 86400));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,16 +82,16 @@ public:
|
|||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
/// Slider controlling the scale of card thumbnails in all deck entry widgets.
|
||||
/** @brief Slider controlling the scale of card thumbnails in all deck entry widgets. */
|
||||
CardSizeWidget *cardSizeSlider;
|
||||
|
||||
/// Main horizontal layout containing the FlowWidget.
|
||||
/** @brief Main horizontal layout containing the FlowWidget. */
|
||||
QHBoxLayout *layout;
|
||||
|
||||
/// Container providing scrollable multi-row flow layout of deck entries.
|
||||
/** @brief Container providing scrollable multi-row flow layout of deck entries. */
|
||||
FlowWidget *flowWidget;
|
||||
|
||||
/// Shared network manager used to download card images for all child entry widgets.
|
||||
/** @brief Shared network manager used to download card images for all child entry widgets. */
|
||||
QNetworkAccessManager *imageNetworkManager;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -93,10 +93,11 @@ void TabArchidekt::initializeUi()
|
|||
colorLayout->addWidget(manaSymbol);
|
||||
|
||||
connect(manaSymbol, &ManaSymbolWidget::colorToggled, this, [this](QChar c, bool active) {
|
||||
if (active)
|
||||
if (active) {
|
||||
activeColors.insert(c);
|
||||
else
|
||||
} else {
|
||||
activeColors.remove(c);
|
||||
}
|
||||
doSearch();
|
||||
});
|
||||
}
|
||||
|
|
@ -298,16 +299,18 @@ void TabArchidekt::setupFilterWidgets()
|
|||
searchModel->updateSearchResults(text);
|
||||
QString pattern = ".*" + QRegularExpression::escape(text) + ".*";
|
||||
proxyModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
|
||||
if (!text.isEmpty())
|
||||
if (!text.isEmpty()) {
|
||||
completer->complete();
|
||||
}
|
||||
});
|
||||
|
||||
connect(commandersField, &QLineEdit::textChanged, this, [=](const QString &text) {
|
||||
searchModel->updateSearchResults(text);
|
||||
QString pattern = ".*" + QRegularExpression::escape(text) + ".*";
|
||||
proxyModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
|
||||
if (!text.isEmpty())
|
||||
if (!text.isEmpty()) {
|
||||
completer->complete();
|
||||
}
|
||||
});
|
||||
|
||||
// Assemble secondary toolbar
|
||||
|
|
@ -492,12 +495,13 @@ QString TabArchidekt::buildSearchUrl()
|
|||
|
||||
QString logic = "GTE";
|
||||
QString selected = minDeckSizeLogicCombo->currentText();
|
||||
if (selected == "≥")
|
||||
if (selected == "≥") {
|
||||
logic = "GTE";
|
||||
else if (selected == "≤")
|
||||
} else if (selected == "≤") {
|
||||
logic = "LTE";
|
||||
else
|
||||
} else {
|
||||
logic = "";
|
||||
}
|
||||
|
||||
if (!logic.isEmpty()) {
|
||||
query.addQueryItem("sizeLogic", logic);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_deck_api_response.h
|
||||
* @ingroup ApiResponses
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_DECK_API_RESPONSE_H
|
||||
#define EDHREC_DECK_API_RESPONSE_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_card_prices.h
|
||||
* @ingroup ApiResponses
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_COMMANDER_API_RESPONSE_CARD_PRICES_H
|
||||
#define EDHREC_COMMANDER_API_RESPONSE_CARD_PRICES_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_card_container.h
|
||||
* @ingroup ApiResponses
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef CONTAINER_ENTRY_H
|
||||
#define CONTAINER_ENTRY_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_card_details.h
|
||||
* @ingroup ApiResponses
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef CARD_VIEW_H
|
||||
#define CARD_VIEW_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_card_list.h
|
||||
* @ingroup ApiResponses
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef CARD_LIST_H
|
||||
#define CARD_LIST_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_commander_api_response_commander_details.h
|
||||
* @ingroup ApiResponses
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_H
|
||||
#define EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_top_cards_api_response.h
|
||||
* @ingroup ApiResponses
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_TOP_CARDS_API_RESPONSE_H
|
||||
#define EDHREC_TOP_CARDS_API_RESPONSE_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_top_commanders_api_response.h
|
||||
* @ingroup ApiResponses
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_TOP_COMMANDERS_API_RESPONSE_H
|
||||
#define EDHREC_TOP_COMMANDERS_API_RESPONSE_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_top_tags_api_response.h
|
||||
* @ingroup ApiResponses
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_TOP_TAGS_API_RESPONSE_H
|
||||
#define EDHREC_TOP_TAGS_API_RESPONSE_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_card_prices_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_API_RESPONSE_CARD_PRICES_DISPLAY_WIDGET_H
|
||||
#define EDHREC_API_RESPONSE_CARD_PRICES_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_card_details_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_COMMANDER_API_RESPONSE_CARD_DETAILS_DISPLAY_WIDGET_H
|
||||
#define EDHREC_COMMANDER_API_RESPONSE_CARD_DETAILS_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_card_inclusion_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_API_RESPONSE_CARD_INCLUSION_DISPLAY_WIDGET_H
|
||||
#define EDHREC_API_RESPONSE_CARD_INCLUSION_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_card_list_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_COMMANDER_API_RESPONSE_CARD_LIST_DISPLAY_WIDGET_H
|
||||
#define EDHREC_COMMANDER_API_RESPONSE_CARD_LIST_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_card_synergy_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_API_RESPONSE_CARD_SYNERGY_DISPLAY_WIDGET_H
|
||||
#define EDHREC_API_RESPONSE_CARD_SYNERGY_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_api_response_commander_details_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H
|
||||
#define EDHREC_COMMANDER_API_RESPONSE_COMMANDER_DETAILS_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_commander_api_response_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_COMMANDER_API_RESPONSE_DISPLAY_WIDGET_H
|
||||
#define EDHREC_COMMANDER_API_RESPONSE_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_commander_api_response_navigation_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_COMMANDER_API_RESPONSE_NAVIGATION_WIDGET_H
|
||||
#define EDHREC_COMMANDER_API_RESPONSE_NAVIGATION_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_top_cards_api_response_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_TOP_CARDS_API_RESPONSE_DISPLAY_WIDGET_H
|
||||
#define EDHREC_TOP_CARDS_API_RESPONSE_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_top_commanders_api_response_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_TOP_COMMANDERS_API_RESPONSE_DISPLAY_WIDGET_H
|
||||
#define EDHREC_TOP_COMMANDERS_API_RESPONSE_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file edhrec_top_tags_api_response_display_widget.h
|
||||
* @ingroup ApiResponseDisplayWidgets
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef EDHREC_TOP_TAGS_API_RESPONSE_DISPLAY_WIDGET_H
|
||||
#define EDHREC_TOP_TAGS_API_RESPONSE_DISPLAY_WIDGET_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_edhrec.h
|
||||
* @ingroup Tabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_EDHREC_H
|
||||
#define TAB_EDHREC_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_edhrec_main.h
|
||||
* @ingroup Tabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_EDHREC_MAIN_H
|
||||
#define TAB_EDHREC_MAIN_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab.h
|
||||
* @ingroup Tabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_H
|
||||
#define TAB_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_account.h
|
||||
* @ingroup AccountTabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_ACCOUNT_H
|
||||
#define TAB_ACCOUNT_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_admin.h
|
||||
* @ingroup ServerTabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_ADMIN_H
|
||||
#define TAB_ADMIN_H
|
||||
|
|
|
|||
|
|
@ -81,8 +81,9 @@ void TabDeckEditor::createMenus()
|
|||
QString TabDeckEditor::getTabText() const
|
||||
{
|
||||
QString result = tr("Deck: %1").arg(deckStateManager->getSimpleDeckName());
|
||||
if (deckStateManager->isModified())
|
||||
if (deckStateManager->isModified()) {
|
||||
result.prepend("* ");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -137,9 +138,9 @@ void TabDeckEditor::loadLayout()
|
|||
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
||||
|
||||
auto layoutState = layouts.getDeckEditorLayoutState();
|
||||
if (layoutState.isNull())
|
||||
if (layoutState.isNull()) {
|
||||
restartLayout();
|
||||
else {
|
||||
} else {
|
||||
restoreState(layoutState);
|
||||
restoreGeometry(layouts.getDeckEditorGeometry());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,8 +181,9 @@ void TabDeckStorage::retranslateUi()
|
|||
QString TabDeckStorage::getTargetPath() const
|
||||
{
|
||||
RemoteDeckList_TreeModel::Node *curRight = serverDirView->getCurrentItem();
|
||||
if (curRight == nullptr)
|
||||
if (curRight == nullptr) {
|
||||
return {};
|
||||
}
|
||||
auto *dir = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight);
|
||||
if (dir == nullptr) {
|
||||
dir = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight->getParent());
|
||||
|
|
@ -237,13 +238,15 @@ void TabDeckStorage::actOpenLocalDeck()
|
|||
{
|
||||
QModelIndexList curLefts = localDirView->selectionModel()->selectedRows();
|
||||
for (const auto &curLeft : curLefts) {
|
||||
if (localDirModel->isDir(curLeft))
|
||||
if (localDirModel->isDir(curLeft)) {
|
||||
continue;
|
||||
}
|
||||
QString filePath = localDirModel->filePath(curLeft);
|
||||
|
||||
std::optional<LoadedDeck> deckOpt = DeckLoader::loadFromFile(filePath, DeckFileFormat::Cockatrice, true);
|
||||
if (!deckOpt)
|
||||
if (!deckOpt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
emit openDeckEditor(deckOpt.value());
|
||||
}
|
||||
|
|
@ -320,10 +323,12 @@ void TabDeckStorage::uploadDeck(const QString &filePath, const QString &targetPa
|
|||
QString deckName =
|
||||
getTextWithMax(this, tr("Enter deck name"), tr("This decklist does not have a name.\nPlease enter a name:"),
|
||||
QLineEdit::Normal, deckFileInfo.completeBaseName(), &ok);
|
||||
if (!ok)
|
||||
if (!ok) {
|
||||
return;
|
||||
if (deckName.isEmpty())
|
||||
}
|
||||
if (deckName.isEmpty()) {
|
||||
deckName = tr("Unnamed deck");
|
||||
}
|
||||
deck.setName(deckName);
|
||||
} else {
|
||||
deck.setName(deck.getName().left(MAX_NAME_LENGTH));
|
||||
|
|
@ -372,8 +377,9 @@ void TabDeckStorage::actNewLocalFolder()
|
|||
bool ok;
|
||||
QString folderName =
|
||||
QInputDialog::getText(this, tr("New folder"), tr("Name of new folder:"), QLineEdit::Normal, "", &ok);
|
||||
if (!ok || folderName.isEmpty())
|
||||
if (!ok || folderName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
localDirModel->mkdir(dirIndex, folderName);
|
||||
}
|
||||
|
|
@ -387,8 +393,9 @@ void TabDeckStorage::actDeleteLocalDeck()
|
|||
}
|
||||
|
||||
if (QMessageBox::warning(this, tr("Delete local file"), tr("Are you sure you want to delete the selected files?"),
|
||||
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
||||
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &curLeft : curLefts) {
|
||||
if (curLeft.isValid()) {
|
||||
|
|
@ -414,8 +421,9 @@ void TabDeckStorage::actOpenRemoteDeck()
|
|||
{
|
||||
for (const auto &curRight : serverDirView->getCurrentSelection()) {
|
||||
RemoteDeckList_TreeModel::FileNode *node = dynamic_cast<RemoteDeckList_TreeModel::FileNode *>(curRight);
|
||||
if (!node)
|
||||
if (!node) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Command_DeckDownload cmd;
|
||||
cmd.set_deck_id(node->getId());
|
||||
|
|
@ -428,15 +436,17 @@ void TabDeckStorage::actOpenRemoteDeck()
|
|||
|
||||
void TabDeckStorage::openRemoteDeckFinished(const Response &r, const CommandContainer &commandContainer)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
if (r.response_code() != Response::RespOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
|
||||
const Command_DeckDownload &cmd = commandContainer.session_command(0).GetExtension(Command_DeckDownload::ext);
|
||||
|
||||
std::optional<LoadedDeck> deckOpt = DeckLoader::loadFromRemote(QString::fromStdString(resp.deck()), cmd.deck_id());
|
||||
if (!deckOpt)
|
||||
if (!deckOpt) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit openDeckEditor(deckOpt.value());
|
||||
}
|
||||
|
|
@ -488,8 +498,9 @@ void TabDeckStorage::downloadFinished(const Response &r,
|
|||
const CommandContainer & /*commandContainer*/,
|
||||
const QVariant &extraData)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
if (r.response_code() != Response::RespOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Response_DeckDownload &resp = r.GetExtension(Response_DeckDownload::ext);
|
||||
QString filePath = extraData.toString();
|
||||
|
|
@ -504,12 +515,14 @@ void TabDeckStorage::actNewFolder()
|
|||
QString targetPath = getTargetPath();
|
||||
int max_length = MAX_NAME_LENGTH - targetPath.length() - 1; // generated length would be path + / + name
|
||||
|
||||
if (max_length < 1) // can't create path that's short enough
|
||||
if (max_length < 1) { // can't create path that's short enough
|
||||
return;
|
||||
}
|
||||
|
||||
QString folderName = getTextWithMax(this, tr("New folder"), tr("Name of new folder:"), max_length);
|
||||
if (folderName.isEmpty())
|
||||
if (folderName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// '/' isn't a valid filename character on *nix so we're choosing to replace it with a different arbitrary
|
||||
// character.
|
||||
|
|
@ -527,8 +540,9 @@ void TabDeckStorage::actNewFolder()
|
|||
|
||||
void TabDeckStorage::newFolderFinished(const Response &response, const CommandContainer &commandContainer)
|
||||
{
|
||||
if (response.response_code() != Response::RespOk)
|
||||
if (response.response_code() != Response::RespOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Command_DeckNewDir &cmd = commandContainer.session_command(0).GetExtension(Command_DeckNewDir::ext);
|
||||
serverDirView->addFolderToTree(QString::fromStdString(cmd.dir_name()),
|
||||
|
|
@ -562,8 +576,9 @@ void TabDeckStorage::deleteRemoteDeck(const RemoteDeckList_TreeModel::Node *curR
|
|||
PendingCommand *pend;
|
||||
if (const auto *dir = dynamic_cast<const RemoteDeckList_TreeModel::DirectoryNode *>(curRight)) {
|
||||
QString targetPath = dir->getPath();
|
||||
if (targetPath.isEmpty())
|
||||
if (targetPath.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (targetPath.length() > MAX_NAME_LENGTH) {
|
||||
qCritical() << "target path to delete is too long" << targetPath;
|
||||
return;
|
||||
|
|
@ -585,22 +600,26 @@ void TabDeckStorage::deleteRemoteDeck(const RemoteDeckList_TreeModel::Node *curR
|
|||
|
||||
void TabDeckStorage::deleteDeckFinished(const Response &response, const CommandContainer &commandContainer)
|
||||
{
|
||||
if (response.response_code() != Response::RespOk)
|
||||
if (response.response_code() != Response::RespOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Command_DeckDel &cmd = commandContainer.session_command(0).GetExtension(Command_DeckDel::ext);
|
||||
RemoteDeckList_TreeModel::Node *toDelete = serverDirView->getNodeById(cmd.deck_id());
|
||||
if (toDelete)
|
||||
if (toDelete) {
|
||||
serverDirView->removeNode(toDelete);
|
||||
}
|
||||
}
|
||||
|
||||
void TabDeckStorage::deleteFolderFinished(const Response &response, const CommandContainer &commandContainer)
|
||||
{
|
||||
if (response.response_code() != Response::RespOk)
|
||||
if (response.response_code() != Response::RespOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Command_DeckDelDir &cmd = commandContainer.session_command(0).GetExtension(Command_DeckDelDir::ext);
|
||||
RemoteDeckList_TreeModel::Node *toDelete = serverDirView->getNodeByPath(QString::fromStdString(cmd.path()));
|
||||
if (toDelete)
|
||||
if (toDelete) {
|
||||
serverDirView->removeNode(toDelete);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
* @file tab_deck_storage.h
|
||||
* @ingroup DeckStorageWidgets
|
||||
* @ingroup Tabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_DECK_STORAGE_H
|
||||
#define TAB_DECK_STORAGE_H
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
#include "../game/game_view.h"
|
||||
#include "../game/log/message_log_widget.h"
|
||||
#include "../game/phases_toolbar.h"
|
||||
#include "../game/player/player.h"
|
||||
#include "../game/player/player_list_widget.h"
|
||||
#include "../game/player/player_logic.h"
|
||||
#include "../game/replay.h"
|
||||
#include "../interface/card_picture_loader/card_picture_loader.h"
|
||||
#include "../interface/widgets/cards/card_info_frame_widget.h"
|
||||
|
|
@ -125,8 +125,9 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
|
|||
refreshShortcuts();
|
||||
|
||||
// append game to rooms game list for others to see
|
||||
for (int i = game->getGameMetaInfo()->gameTypesSize() - 1; i >= 0; i--)
|
||||
for (int i = game->getGameMetaInfo()->gameTypesSize() - 1; i >= 0; i--) {
|
||||
gameTypes.append(game->getGameMetaInfo()->findRoomGameType(i));
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, this, &TabGame::loadLayout);
|
||||
}
|
||||
|
|
@ -282,12 +283,14 @@ void TabGame::retranslateUi()
|
|||
updatePlayerListDockTitle();
|
||||
cardInfoDock->setWindowTitle(tr("Card Info") + (cardInfoDock->isWindow() ? tabText : QString()));
|
||||
messageLayoutDock->setWindowTitle(tr("Messages") + (messageLayoutDock->isWindow() ? tabText : QString()));
|
||||
if (replayDock)
|
||||
if (replayDock) {
|
||||
replayDock->setWindowTitle(tr("Replay Timeline") + (replayDock->isWindow() ? tabText : QString()));
|
||||
}
|
||||
|
||||
if (phasesMenu) {
|
||||
for (int i = 0; i < phaseActions.size(); ++i)
|
||||
for (int i = 0; i < phaseActions.size(); ++i) {
|
||||
phaseActions[i]->setText(phasesToolbar->getLongPhaseName(i));
|
||||
}
|
||||
phasesMenu->setTitle(tr("&Phases"));
|
||||
}
|
||||
|
||||
|
|
@ -313,8 +316,9 @@ void TabGame::retranslateUi()
|
|||
if (aRotateViewCCW) {
|
||||
aRotateViewCCW->setText(tr("Rotate View Co&unterclockwise"));
|
||||
}
|
||||
if (aGameInfo)
|
||||
if (aGameInfo) {
|
||||
aGameInfo->setText(tr("Game &information"));
|
||||
}
|
||||
if (aConcede) {
|
||||
if (game->getPlayerManager()->isMainPlayerConceded()) {
|
||||
aConcede->setText(tr("Un&concede"));
|
||||
|
|
@ -359,13 +363,15 @@ void TabGame::retranslateUi()
|
|||
|
||||
cardInfoFrameWidget->retranslateUi();
|
||||
|
||||
QMapIterator<int, Player *> i(game->getPlayerManager()->getPlayers());
|
||||
QMapIterator<int, PlayerLogic *> i(game->getPlayerManager()->getPlayers());
|
||||
|
||||
while (i.hasNext())
|
||||
while (i.hasNext()) {
|
||||
i.next().value()->getGraphicsItem()->retranslateUi();
|
||||
}
|
||||
QMapIterator<int, TabbedDeckViewContainer *> j(deckViewContainers);
|
||||
while (j.hasNext())
|
||||
while (j.hasNext()) {
|
||||
j.next().value()->playerDeckView->retranslateUi();
|
||||
}
|
||||
|
||||
scene->retranslateUi();
|
||||
}
|
||||
|
|
@ -483,19 +489,22 @@ void TabGame::actGameInfo()
|
|||
|
||||
void TabGame::actConcede()
|
||||
{
|
||||
Player *player = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer());
|
||||
if (player == nullptr)
|
||||
PlayerLogic *player = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer());
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (!player->getConceded()) {
|
||||
if (QMessageBox::question(this, tr("Concede"), tr("Are you sure you want to concede this game?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
emit game->getPlayerManager()->activeLocalPlayerConceded();
|
||||
} else {
|
||||
if (QMessageBox::question(this, tr("Unconcede"),
|
||||
tr("You have already conceded. Do you want to return to this game?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
emit game->getPlayerManager()->activeLocalPlayerUnconceded();
|
||||
}
|
||||
}
|
||||
|
|
@ -511,20 +520,23 @@ bool TabGame::leaveGame()
|
|||
if (!game->getPlayerManager()->isSpectator()) {
|
||||
tabSupervisor->setCurrentWidget(this);
|
||||
if (QMessageBox::question(this, tr("Leave game"), tr("Are you sure you want to leave this game?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!replayDock)
|
||||
if (!replayDock) {
|
||||
emit gameLeft();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TabGame::actSay()
|
||||
{
|
||||
if (completer->popup()->isVisible())
|
||||
if (completer->popup()->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sayEdit->text().startsWith("/card ")) {
|
||||
cardInfoFrameWidget->setCard(sayEdit->text().mid(6));
|
||||
|
|
@ -569,8 +581,9 @@ void TabGame::actPhaseAction()
|
|||
void TabGame::actNextPhase()
|
||||
{
|
||||
int phase = game->getGameState()->getCurrentPhase();
|
||||
if (++phase >= phasesToolbar->phaseCount())
|
||||
if (++phase >= phasesToolbar->phaseCount()) {
|
||||
phase = 0;
|
||||
}
|
||||
|
||||
emit phaseChanged(phase);
|
||||
}
|
||||
|
|
@ -593,16 +606,9 @@ void TabGame::actNextPhaseAction()
|
|||
|
||||
void TabGame::actRemoveLocalArrows()
|
||||
{
|
||||
QMapIterator<int, Player *> playerIterator(game->getPlayerManager()->getPlayers());
|
||||
while (playerIterator.hasNext()) {
|
||||
Player *player = playerIterator.next().value();
|
||||
if (!player->getPlayerInfo()->getLocal())
|
||||
continue;
|
||||
QMapIterator<int, ArrowItem *> arrowIterator(player->getArrows());
|
||||
while (arrowIterator.hasNext()) {
|
||||
ArrowItem *a = arrowIterator.next().value();
|
||||
emit arrowDeletionRequested(a->getId());
|
||||
}
|
||||
auto *local = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer());
|
||||
if (local) {
|
||||
scene->requestClearArrowsForPlayer(local->getPlayerInfo()->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -641,14 +647,14 @@ void TabGame::notifyPlayerKicked()
|
|||
msgBox.exec();
|
||||
}
|
||||
|
||||
Player *TabGame::addPlayer(Player *newPlayer)
|
||||
PlayerLogic *TabGame::addPlayer(PlayerLogic *newPlayer)
|
||||
{
|
||||
QString newPlayerName = "@" + newPlayer->getPlayerInfo()->getName();
|
||||
addPlayerToAutoCompleteList(newPlayerName);
|
||||
|
||||
scene->addPlayer(newPlayer);
|
||||
|
||||
connect(newPlayer, &Player::newCardAdded, this, &TabGame::newCardAdded);
|
||||
connect(newPlayer, &PlayerLogic::newCardAdded, this, &TabGame::newCardAdded);
|
||||
connect(newPlayer->getPlayerMenu(), &PlayerMenu::cardMenuUpdated, this, &TabGame::setCardMenu);
|
||||
|
||||
messageLog->connectToPlayerEventHandler(newPlayer->getPlayerEventHandler());
|
||||
|
|
@ -669,7 +675,7 @@ Player *TabGame::addPlayer(Player *newPlayer)
|
|||
return newPlayer;
|
||||
}
|
||||
|
||||
void TabGame::addLocalPlayer(Player *newPlayer, int playerId)
|
||||
void TabGame::addLocalPlayer(PlayerLogic *newPlayer, int playerId)
|
||||
{
|
||||
if (game->getGameState()->getClients().size() == 1) {
|
||||
newPlayer->getPlayerMenu()->setShortcutsActive();
|
||||
|
|
@ -690,7 +696,7 @@ void TabGame::addLocalPlayer(Player *newPlayer, int playerId)
|
|||
}
|
||||
}
|
||||
|
||||
void TabGame::processPlayerLeave(Player *leavingPlayer)
|
||||
void TabGame::processPlayerLeave(PlayerLogic *leavingPlayer)
|
||||
{
|
||||
QString playerName = "@" + leavingPlayer->getPlayerInfo()->getName();
|
||||
removePlayerFromAutoCompleteList(playerName);
|
||||
|
|
@ -737,13 +743,13 @@ void TabGame::processMultipleRemotePlayerDeckSelect(QVector<QPair<int, QPair<QSt
|
|||
}
|
||||
}
|
||||
|
||||
void TabGame::processLocalPlayerDeckSelect(Player *localPlayer, int playerId, ServerInfo_Player playerInfo)
|
||||
void TabGame::processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
|
||||
{
|
||||
loadDeckForLocalPlayer(localPlayer, playerId, playerInfo);
|
||||
processLocalPlayerReady(playerId, playerInfo);
|
||||
}
|
||||
|
||||
void TabGame::loadDeckForLocalPlayer(Player *localPlayer, int playerId, ServerInfo_Player playerInfo)
|
||||
void TabGame::loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
|
||||
{
|
||||
TabbedDeckViewContainer *deckViewContainer = deckViewContainers.value(playerId);
|
||||
if (playerInfo.has_deck_list()) {
|
||||
|
|
@ -770,7 +776,7 @@ void TabGame::processLocalPlayerReadyStateChanged(int playerId, bool ready)
|
|||
deckViewContainers.value(playerId)->playerDeckView->setReadyStart(ready);
|
||||
}
|
||||
|
||||
void TabGame::createZoneForPlayer(Player *newPlayer, int playerId)
|
||||
void TabGame::createZoneForPlayer(PlayerLogic *newPlayer, int playerId)
|
||||
{
|
||||
if (!game->getPlayerManager()->getSpectators().contains(playerId)) {
|
||||
|
||||
|
|
@ -806,9 +812,10 @@ void TabGame::startGame(bool _resuming)
|
|||
mainWidget->setCurrentWidget(gamePlayAreaWidget);
|
||||
|
||||
if (!_resuming) {
|
||||
QMapIterator<int, Player *> playerIterator(game->getPlayerManager()->getPlayers());
|
||||
while (playerIterator.hasNext())
|
||||
QMapIterator<int, PlayerLogic *> playerIterator(game->getPlayerManager()->getPlayers());
|
||||
while (playerIterator.hasNext()) {
|
||||
playerIterator.next().value()->setGameStarted();
|
||||
}
|
||||
}
|
||||
|
||||
playerListWidget->setGameStarted(true, game->getGameState()->isResuming());
|
||||
|
|
@ -848,14 +855,15 @@ void TabGame::closeGame()
|
|||
gameMenu->addAction(aLeaveGame);
|
||||
}
|
||||
|
||||
Player *TabGame::setActivePlayer(int id)
|
||||
PlayerLogic *TabGame::setActivePlayer(int id)
|
||||
{
|
||||
Player *player = game->getPlayerManager()->getPlayer(id);
|
||||
if (!player)
|
||||
PlayerLogic *player = game->getPlayerManager()->getPlayer(id);
|
||||
if (!player) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
playerListWidget->setActivePlayer(id);
|
||||
QMapIterator<int, Player *> i(game->getPlayerManager()->getPlayers());
|
||||
QMapIterator<int, PlayerLogic *> i(game->getPlayerManager()->getPlayers());
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (i.value() == player) {
|
||||
|
|
@ -887,6 +895,11 @@ void TabGame::newCardAdded(AbstractCardItem *card)
|
|||
connect(card, &AbstractCardItem::showCardInfoPopup, this, &TabGame::showCardInfoPopup);
|
||||
connect(card, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
connect(card, &AbstractCardItem::cardShiftClicked, this, &TabGame::linkCardToChat);
|
||||
CardItem *cardItem = qobject_cast<CardItem *>(card);
|
||||
if (cardItem) {
|
||||
connect(cardItem->getState(), &CardState::zoneChanged, scene,
|
||||
[this, cardItem]() { scene->onCardZoneChanged(cardItem, false); });
|
||||
}
|
||||
}
|
||||
|
||||
QString TabGame::getTabText() const
|
||||
|
|
@ -894,26 +907,31 @@ QString TabGame::getTabText() const
|
|||
QString gameTypeInfo;
|
||||
if (!gameTypes.empty()) {
|
||||
gameTypeInfo = gameTypes.at(0);
|
||||
if (gameTypes.size() > 1)
|
||||
if (gameTypes.size() > 1) {
|
||||
gameTypeInfo.append("...");
|
||||
}
|
||||
}
|
||||
|
||||
QString gameDesc(game->getGameMetaInfo()->description());
|
||||
QString gameId(QString::number(game->getGameMetaInfo()->gameId()));
|
||||
|
||||
QString tabText;
|
||||
if (replayDock)
|
||||
if (replayDock) {
|
||||
tabText.append(tr("Replay") + " ");
|
||||
if (!gameTypeInfo.isEmpty())
|
||||
tabText.append(gameTypeInfo + " ");
|
||||
if (!gameDesc.isEmpty()) {
|
||||
if (gameDesc.length() >= 15)
|
||||
tabText.append("| " + gameDesc.left(15) + "... ");
|
||||
else
|
||||
tabText.append("| " + gameDesc + " ");
|
||||
}
|
||||
if (!tabText.isEmpty())
|
||||
if (!gameTypeInfo.isEmpty()) {
|
||||
tabText.append(gameTypeInfo + " ");
|
||||
}
|
||||
if (!gameDesc.isEmpty()) {
|
||||
if (gameDesc.length() >= 15) {
|
||||
tabText.append("| " + gameDesc.left(15) + "... ");
|
||||
} else {
|
||||
tabText.append("| " + gameDesc + " ");
|
||||
}
|
||||
}
|
||||
if (!tabText.isEmpty()) {
|
||||
tabText.append("| ");
|
||||
}
|
||||
tabText.append("#" + gameId);
|
||||
|
||||
return tabText;
|
||||
|
|
@ -949,8 +967,6 @@ void TabGame::createMenuItems()
|
|||
connect(aReverseTurn, &QAction::triggered, game->getGameEventHandler(), &GameEventHandler::handleReverseTurn);
|
||||
aRemoveLocalArrows = new QAction(this);
|
||||
connect(aRemoveLocalArrows, &QAction::triggered, this, &TabGame::actRemoveLocalArrows);
|
||||
connect(this, &TabGame::arrowDeletionRequested, game->getGameEventHandler(),
|
||||
&GameEventHandler::handleArrowDeletion);
|
||||
aRotateViewCW = new QAction(this);
|
||||
connect(aRotateViewCW, &QAction::triggered, this, &TabGame::actRotateViewCW);
|
||||
aRotateViewCCW = new QAction(this);
|
||||
|
|
@ -1127,12 +1143,16 @@ void TabGame::actResetLayout()
|
|||
void TabGame::createPlayAreaWidget(bool bReplay)
|
||||
{
|
||||
phasesToolbar = new PhasesToolbar;
|
||||
if (!bReplay)
|
||||
if (!bReplay) {
|
||||
connect(phasesToolbar, &PhasesToolbar::sendGameCommand, game->getGameEventHandler(),
|
||||
qOverload<const ::google::protobuf::Message &, int>(&GameEventHandler::sendGameCommand));
|
||||
}
|
||||
scene = new GameScene(phasesToolbar, this);
|
||||
connect(game->getPlayerManager(), &PlayerManager::playerConceded, scene, &GameScene::rearrange);
|
||||
connect(game->getPlayerManager(), &PlayerManager::playerCountChanged, scene, &GameScene::rearrange);
|
||||
connect(scene, &GameScene::arrowDeletionRequested, game->getGameEventHandler(),
|
||||
&GameEventHandler::handleArrowDeletion);
|
||||
connect(game->getGameEventHandler(), &GameEventHandler::arrowDeleted, scene, &GameScene::deleteArrow);
|
||||
gameView = new GameView(scene);
|
||||
|
||||
auto gamePlayAreaVBox = new QVBoxLayout;
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@
|
|||
* @ingroup Tabs
|
||||
* @ingroup GameWidgets
|
||||
* @ingroup Lobby
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_GAME_H
|
||||
#define TAB_GAME_H
|
||||
|
||||
#include "../game/abstract_game.h"
|
||||
#include "../game/log/message_log_widget.h"
|
||||
#include "../game/player/player.h"
|
||||
#include "../game/player/player_logic.h"
|
||||
#include "../interface/widgets/menus/tearoff_menu.h"
|
||||
#include "../interface/widgets/replay/replay_manager.h"
|
||||
#include "tab.h"
|
||||
|
|
@ -99,21 +99,21 @@ private:
|
|||
|
||||
QMap<QDockWidget *, DockActions> dockToActions;
|
||||
|
||||
Player *addPlayer(Player *newPlayer);
|
||||
void addLocalPlayer(Player *newPlayer, int playerId);
|
||||
PlayerLogic *addPlayer(PlayerLogic *newPlayer);
|
||||
void addLocalPlayer(PlayerLogic *newPlayer, int playerId);
|
||||
void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName);
|
||||
void processMultipleRemotePlayerDeckSelect(QVector<QPair<int, QPair<QString, QString>>> playerIdDeckMap);
|
||||
void processLocalPlayerDeckSelect(Player *localPlayer, int playerId, ServerInfo_Player playerInfo);
|
||||
void loadDeckForLocalPlayer(Player *localPlayer, int playerId, ServerInfo_Player playerInfo);
|
||||
void processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
|
||||
void loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
|
||||
void processLocalPlayerReady(int playerId, ServerInfo_Player playerInfo);
|
||||
void createZoneForPlayer(Player *newPlayer, int playerId);
|
||||
void createZoneForPlayer(PlayerLogic *newPlayer, int playerId);
|
||||
|
||||
void startGame(bool resuming);
|
||||
void stopGame();
|
||||
void closeGame();
|
||||
bool leaveGame();
|
||||
|
||||
Player *setActivePlayer(int id);
|
||||
PlayerLogic *setActivePlayer(int id);
|
||||
void setActivePhase(int phase);
|
||||
void createMenuItems();
|
||||
void createReplayMenuItems();
|
||||
|
|
@ -137,7 +137,6 @@ signals:
|
|||
void gameLeft();
|
||||
void chatMessageSent(QString chatMessage);
|
||||
void turnAdvanced();
|
||||
void arrowDeletionRequested(int arrowId);
|
||||
|
||||
private slots:
|
||||
void adminLockChanged(bool lock);
|
||||
|
|
@ -163,7 +162,7 @@ private slots:
|
|||
void actCompleterChanged();
|
||||
void notifyPlayerJoin(QString playerName);
|
||||
void notifyPlayerKicked();
|
||||
void processPlayerLeave(Player *leavingPlayer);
|
||||
void processPlayerLeave(PlayerLogic *leavingPlayer);
|
||||
void actResetLayout();
|
||||
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_home.h
|
||||
* @ingroup Tabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_HOME_H
|
||||
#define TAB_HOME_H
|
||||
|
|
|
|||
|
|
@ -83,18 +83,22 @@ void TabLog::getClicked()
|
|||
privateChat->setChecked(true);
|
||||
}
|
||||
|
||||
if (maximumResults->value() == 0)
|
||||
if (maximumResults->value() == 0) {
|
||||
maximumResults->setValue(1000);
|
||||
}
|
||||
|
||||
int dateRange = 0;
|
||||
if (lastHour->isChecked())
|
||||
if (lastHour->isChecked()) {
|
||||
dateRange = 1;
|
||||
}
|
||||
|
||||
if (today->isChecked())
|
||||
if (today->isChecked()) {
|
||||
dateRange = 24;
|
||||
}
|
||||
|
||||
if (pastDays->isChecked())
|
||||
if (pastDays->isChecked()) {
|
||||
dateRange = pastXDays->value() * 24;
|
||||
}
|
||||
|
||||
Command_ViewLogHistory cmd;
|
||||
cmd.set_user_name(findUsername->text().toStdString());
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_logs.h
|
||||
* @ingroup ServerTabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_LOG_H
|
||||
#define TAB_LOG_H
|
||||
|
|
|
|||
|
|
@ -72,8 +72,9 @@ void TabMessage::retranslateUi()
|
|||
|
||||
void TabMessage::tabActivated()
|
||||
{
|
||||
if (!sayEdit->hasFocus())
|
||||
if (!sayEdit->hasFocus()) {
|
||||
sayEdit->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
QString TabMessage::getUserName() const
|
||||
|
|
@ -94,8 +95,9 @@ void TabMessage::closeEvent(QCloseEvent *event)
|
|||
|
||||
void TabMessage::sendMessage()
|
||||
{
|
||||
if (sayEdit->text().isEmpty() || !userOnline)
|
||||
if (sayEdit->text().isEmpty() || !userOnline) {
|
||||
return;
|
||||
}
|
||||
|
||||
Command_Message cmd;
|
||||
cmd.set_user_name(otherUserInfo->name());
|
||||
|
|
@ -110,9 +112,10 @@ void TabMessage::sendMessage()
|
|||
|
||||
void TabMessage::messageSent(const Response &response)
|
||||
{
|
||||
if (response.response_code() == Response::RespInIgnoreList)
|
||||
if (response.response_code() == Response::RespInIgnoreList) {
|
||||
chatView->appendMessage(tr(
|
||||
"This user is ignoring you, they cannot see your messages in main chat and you cannot join their games."));
|
||||
}
|
||||
}
|
||||
|
||||
void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
|
||||
|
|
@ -120,12 +123,15 @@ void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
|
|||
auto userInfo = event.sender_name() == otherUserInfo->name() ? otherUserInfo : ownUserInfo;
|
||||
|
||||
chatView->appendMessage(QString::fromStdString(event.message()), {}, *userInfo, true);
|
||||
if (tabSupervisor->currentIndex() != tabSupervisor->indexOf(this))
|
||||
if (tabSupervisor->currentIndex() != tabSupervisor->indexOf(this)) {
|
||||
soundEngine->playSound("private_message");
|
||||
if (SettingsCache::instance().getShowMessagePopup() && shouldShowSystemPopup(event))
|
||||
}
|
||||
if (SettingsCache::instance().getShowMessagePopup() && shouldShowSystemPopup(event)) {
|
||||
showSystemPopup(event);
|
||||
if (QString::fromStdString(event.sender_name()).toLower().simplified() == "servatrice")
|
||||
}
|
||||
if (QString::fromStdString(event.sender_name()).toLower().simplified() == "servatrice") {
|
||||
sayEdit->setDisabled(true);
|
||||
}
|
||||
|
||||
emit userEvent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_message.h
|
||||
* @ingroup MessagingTabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_MESSAGE_H
|
||||
#define TAB_MESSAGE_H
|
||||
|
|
|
|||
|
|
@ -256,13 +256,15 @@ void TabReplays::actOpenLocalReplay()
|
|||
{
|
||||
QModelIndexList curLefts = localDirView->selectionModel()->selectedRows();
|
||||
for (const auto &curLeft : curLefts) {
|
||||
if (localDirModel->isDir(curLeft))
|
||||
if (localDirModel->isDir(curLeft)) {
|
||||
continue;
|
||||
}
|
||||
QString filePath = localDirModel->filePath(curLeft);
|
||||
|
||||
QFile f(filePath);
|
||||
if (!f.open(QIODevice::ReadOnly))
|
||||
if (!f.open(QIODevice::ReadOnly)) {
|
||||
continue;
|
||||
}
|
||||
QByteArray _data = f.readAll();
|
||||
f.close();
|
||||
|
||||
|
|
@ -319,8 +321,9 @@ void TabReplays::actNewLocalFolder()
|
|||
bool ok;
|
||||
QString folderName =
|
||||
QInputDialog::getText(this, tr("New folder"), tr("Name of new folder:"), QLineEdit::Normal, "", &ok);
|
||||
if (!ok || folderName.isEmpty())
|
||||
if (!ok || folderName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
localDirModel->mkdir(dirIndex, folderName);
|
||||
}
|
||||
|
|
@ -378,8 +381,9 @@ void TabReplays::actOpenRemoteReplay()
|
|||
|
||||
void TabReplays::openRemoteReplayFinished(const Response &r)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
if (r.response_code() != Response::RespOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Response_ReplayDownload &resp = r.GetExtension(Response_ReplayDownload::ext);
|
||||
GameReplay *replay = new GameReplay;
|
||||
|
|
@ -438,8 +442,9 @@ void TabReplays::downloadFinished(const Response &r,
|
|||
const CommandContainer & /* commandContainer */,
|
||||
const QVariant &extraData)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
if (r.response_code() != Response::RespOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Response_ReplayDownload &resp = r.GetExtension(Response_ReplayDownload::ext);
|
||||
QString filePath = extraData.toString();
|
||||
|
|
@ -475,8 +480,9 @@ void TabReplays::actKeepRemoteReplay()
|
|||
|
||||
void TabReplays::keepRemoteReplayFinished(const Response &r, const CommandContainer &commandContainer)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
if (r.response_code() != Response::RespOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Command_ReplayModifyMatch &cmd =
|
||||
commandContainer.session_command(0).GetExtension(Command_ReplayModifyMatch::ext);
|
||||
|
|
@ -513,8 +519,9 @@ void TabReplays::actDeleteRemoteReplay()
|
|||
|
||||
void TabReplays::deleteRemoteReplayFinished(const Response &r, const CommandContainer &commandContainer)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
if (r.response_code() != Response::RespOk) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Command_ReplayDeleteMatch &cmd =
|
||||
commandContainer.session_command(0).GetExtension(Command_ReplayDeleteMatch::ext);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
* @file tab_replays.h
|
||||
* @ingroup Replays
|
||||
* @ingroup Tabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_REPLAYS_H
|
||||
#define TAB_REPLAYS_H
|
||||
|
|
|
|||
|
|
@ -41,9 +41,10 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
|
|||
ownUser(_ownUser), userListProxy(_tabSupervisor->getUserListManager())
|
||||
{
|
||||
const int gameTypeListSize = info.gametype_list_size();
|
||||
for (int i = 0; i < gameTypeListSize; ++i)
|
||||
for (int i = 0; i < gameTypeListSize; ++i) {
|
||||
gameTypes.insert(info.gametype_list(i).game_type_id(),
|
||||
QString::fromStdString(info.gametype_list(i).description()));
|
||||
}
|
||||
|
||||
QMap<int, GameTypeMap> tempMap;
|
||||
tempMap.insert(info.room_id(), gameTypes);
|
||||
|
|
@ -117,8 +118,9 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
|
|||
userList->sortItems();
|
||||
|
||||
const int gameListSize = info.game_list_size();
|
||||
for (int i = 0; i < gameListSize; ++i)
|
||||
for (int i = 0; i < gameListSize; ++i) {
|
||||
gameSelector->processGameInfo(info.game_list(i));
|
||||
}
|
||||
|
||||
completer = new QCompleter(autocompleteUserList, sayEdit);
|
||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
|
@ -182,8 +184,9 @@ void TabRoom::closeEvent(QCloseEvent *event)
|
|||
|
||||
void TabRoom::tabActivated()
|
||||
{
|
||||
if (!sayEdit->hasFocus())
|
||||
if (!sayEdit->hasFocus()) {
|
||||
sayEdit->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
QString TabRoom::sanitizeHtml(QString dirty) const
|
||||
|
|
@ -211,8 +214,9 @@ void TabRoom::sendMessage()
|
|||
|
||||
void TabRoom::sayFinished(const Response &response)
|
||||
{
|
||||
if (response.response_code() == Response::RespChatFlood)
|
||||
if (response.response_code() == Response::RespChatFlood) {
|
||||
chatView->appendMessage(tr("You are flooding the chat. Please wait a couple of seconds."));
|
||||
}
|
||||
}
|
||||
|
||||
void TabRoom::actClearChat()
|
||||
|
|
@ -258,8 +262,9 @@ void TabRoom::processRoomEvent(const RoomEvent &event)
|
|||
void TabRoom::processListGamesEvent(const Event_ListGames &event)
|
||||
{
|
||||
const int gameListSize = event.game_list_size();
|
||||
for (int i = 0; i < gameListSize; ++i)
|
||||
for (int i = 0; i < gameListSize; ++i) {
|
||||
gameSelector->processGameInfo(event.game_list(i));
|
||||
}
|
||||
}
|
||||
|
||||
void TabRoom::processJoinRoomEvent(const Event_JoinRoom &event)
|
||||
|
|
@ -284,26 +289,30 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event)
|
|||
QString senderName = QString::fromStdString(event.name());
|
||||
QString message = QString::fromStdString(event.message());
|
||||
|
||||
if (userListProxy->isUserIgnored(senderName))
|
||||
if (userListProxy->isUserIgnored(senderName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
UserListTWI *twi = userList->getUsers().value(senderName);
|
||||
ServerInfo_User userInfo = {};
|
||||
if (twi) {
|
||||
userInfo = twi->getUserInfo();
|
||||
if (SettingsCache::instance().getIgnoreUnregisteredUsers() &&
|
||||
!UserLevelFlags(userInfo.user_level()).testFlag(ServerInfo_User::IsRegistered))
|
||||
!UserLevelFlags(userInfo.user_level()).testFlag(ServerInfo_User::IsRegistered)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.message_type() == Event_RoomSay::ChatHistory && !SettingsCache::instance().getRoomHistory())
|
||||
if (event.message_type() == Event_RoomSay::ChatHistory && !SettingsCache::instance().getRoomHistory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.message_type() == Event_RoomSay::ChatHistory)
|
||||
if (event.message_type() == Event_RoomSay::ChatHistory) {
|
||||
message =
|
||||
"[" +
|
||||
QString(QDateTime::fromMSecsSinceEpoch(event.time_of()).toLocalTime().toString("d MMM yyyy HH:mm:ss")) +
|
||||
"] " + message;
|
||||
}
|
||||
|
||||
chatView->appendMessage(message, event.message_type(), userInfo, true);
|
||||
emit userEvent(false);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
* @file tab_room.h
|
||||
* @ingroup RoomTabs
|
||||
* @ingroup Lobby
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_ROOM_H
|
||||
#define TAB_ROOM_H
|
||||
|
|
|
|||
|
|
@ -69,27 +69,35 @@ void RoomSelector::processListRoomsEvent(const Event_ListRooms &event)
|
|||
for (int j = 0; j < roomList->topLevelItemCount(); ++j) {
|
||||
QTreeWidgetItem *twi = roomList->topLevelItem(j);
|
||||
if (twi->data(0, Qt::UserRole).toInt() == room.room_id()) {
|
||||
if (room.has_name())
|
||||
if (room.has_name()) {
|
||||
twi->setData(0, Qt::DisplayRole, QString::fromStdString(room.name()));
|
||||
if (room.has_description())
|
||||
}
|
||||
if (room.has_description()) {
|
||||
twi->setData(1, Qt::DisplayRole, QString::fromStdString(room.description()));
|
||||
if (room.has_permissionlevel())
|
||||
}
|
||||
if (room.has_permissionlevel()) {
|
||||
twi->setData(2, Qt::DisplayRole, getRoomPermissionDisplay(room));
|
||||
if (room.has_player_count())
|
||||
}
|
||||
if (room.has_player_count()) {
|
||||
twi->setData(3, Qt::DisplayRole, room.player_count());
|
||||
if (room.has_game_count())
|
||||
}
|
||||
if (room.has_game_count()) {
|
||||
twi->setData(4, Qt::DisplayRole, room.game_count());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
QTreeWidgetItem *twi = new QTreeWidgetItem;
|
||||
twi->setData(0, Qt::UserRole, room.room_id());
|
||||
if (room.has_name())
|
||||
if (room.has_name()) {
|
||||
twi->setData(0, Qt::DisplayRole, QString::fromStdString(room.name()));
|
||||
if (room.has_description())
|
||||
}
|
||||
if (room.has_description()) {
|
||||
twi->setData(1, Qt::DisplayRole, QString::fromStdString(room.description()));
|
||||
if (room.has_permissionlevel())
|
||||
}
|
||||
if (room.has_permissionlevel()) {
|
||||
twi->setData(2, Qt::DisplayRole, getRoomPermissionDisplay(room));
|
||||
}
|
||||
twi->setData(3, Qt::DisplayRole, room.player_count());
|
||||
twi->setData(4, Qt::DisplayRole, room.game_count());
|
||||
twi->setTextAlignment(2, Qt::AlignRight);
|
||||
|
|
@ -97,9 +105,11 @@ void RoomSelector::processListRoomsEvent(const Event_ListRooms &event)
|
|||
twi->setTextAlignment(4, Qt::AlignRight);
|
||||
|
||||
roomList->addTopLevelItem(twi);
|
||||
if (room.has_auto_join())
|
||||
if (room.auto_join())
|
||||
if (room.has_auto_join()) {
|
||||
if (room.auto_join()) {
|
||||
emit joinRoomRequest(room.room_id(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,10 +123,12 @@ QString RoomSelector::getRoomPermissionDisplay(const ServerInfo_Room &room)
|
|||
*/
|
||||
|
||||
QString roomPermissionDisplay = QString::fromStdString(room.privilegelevel()).toLower();
|
||||
if (QString::fromStdString(room.permissionlevel()).toLower() != "none")
|
||||
if (QString::fromStdString(room.permissionlevel()).toLower() != "none") {
|
||||
roomPermissionDisplay = QString::fromStdString(room.permissionlevel()).toLower();
|
||||
if (roomPermissionDisplay == "") // catch all for misconfigured .ini room definitions
|
||||
}
|
||||
if (roomPermissionDisplay == "") { // catch all for misconfigured .ini room definitions
|
||||
roomPermissionDisplay = "none";
|
||||
}
|
||||
|
||||
return roomPermissionDisplay;
|
||||
}
|
||||
|
|
@ -124,8 +136,9 @@ QString RoomSelector::getRoomPermissionDisplay(const ServerInfo_Room &room)
|
|||
void RoomSelector::joinClicked()
|
||||
{
|
||||
QTreeWidgetItem *twi = roomList->currentItem();
|
||||
if (!twi)
|
||||
if (!twi) {
|
||||
return;
|
||||
}
|
||||
|
||||
int id = twi->data(0, Qt::UserRole).toInt();
|
||||
|
||||
|
|
@ -185,8 +198,9 @@ void TabServer::joinRoom(int id, bool setCurrent)
|
|||
return;
|
||||
}
|
||||
|
||||
if (setCurrent)
|
||||
if (setCurrent) {
|
||||
tabSupervisor->setCurrentWidget((QWidget *)room);
|
||||
}
|
||||
}
|
||||
|
||||
void TabServer::joinRoomFinished(const Response &r,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_server.h
|
||||
* @ingroup ServerTabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_SERVER_H
|
||||
#define TAB_SERVER_H
|
||||
|
|
|
|||
|
|
@ -70,18 +70,22 @@ void CloseButton::paintEvent(QPaintEvent * /*event*/)
|
|||
QStyleOption opt;
|
||||
opt.initFrom(this);
|
||||
opt.state |= QStyle::State_AutoRaise;
|
||||
if (isEnabled() && underMouse() && !isChecked() && !isDown())
|
||||
if (isEnabled() && underMouse() && !isChecked() && !isDown()) {
|
||||
opt.state |= QStyle::State_Raised;
|
||||
if (isChecked())
|
||||
}
|
||||
if (isChecked()) {
|
||||
opt.state |= QStyle::State_On;
|
||||
if (isDown())
|
||||
}
|
||||
if (isDown()) {
|
||||
opt.state |= QStyle::State_Sunken;
|
||||
}
|
||||
|
||||
if (const auto *tb = qobject_cast<const QTabBar *>(parent())) {
|
||||
int index = tb->currentIndex();
|
||||
auto position = (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, tb);
|
||||
if (tb->tabButton(index, position) == this)
|
||||
if (tb->tabButton(index, position) == this) {
|
||||
opt.state |= QStyle::State_Selected;
|
||||
}
|
||||
}
|
||||
|
||||
style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this);
|
||||
|
|
@ -206,20 +210,25 @@ void TabSupervisor::retranslateUi()
|
|||
tabs.append(tabAccount);
|
||||
tabs.append(tabLog);
|
||||
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
||||
while (roomIterator.hasNext())
|
||||
while (roomIterator.hasNext()) {
|
||||
tabs.append(roomIterator.next().value());
|
||||
}
|
||||
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
||||
while (gameIterator.hasNext())
|
||||
while (gameIterator.hasNext()) {
|
||||
tabs.append(gameIterator.next().value());
|
||||
}
|
||||
QListIterator<TabGame *> replayIterator(replayTabs);
|
||||
while (replayIterator.hasNext())
|
||||
while (replayIterator.hasNext()) {
|
||||
tabs.append(replayIterator.next());
|
||||
}
|
||||
QListIterator<AbstractTabDeckEditor *> deckEditorIterator(deckEditorTabs);
|
||||
while (deckEditorIterator.hasNext())
|
||||
while (deckEditorIterator.hasNext()) {
|
||||
tabs.append(deckEditorIterator.next());
|
||||
}
|
||||
QMapIterator<QString, TabMessage *> messageIterator(messageTabs);
|
||||
while (messageIterator.hasNext())
|
||||
while (messageIterator.hasNext()) {
|
||||
tabs.append(messageIterator.next().value());
|
||||
}
|
||||
|
||||
for (auto &tab : tabs) {
|
||||
if (tab) {
|
||||
|
|
@ -426,9 +435,10 @@ void TabSupervisor::startLocal(const QList<AbstractClient *> &_clients)
|
|||
isLocalGame = true;
|
||||
userInfo = new ServerInfo_User;
|
||||
localClients = _clients;
|
||||
for (int i = 0; i < localClients.size(); ++i)
|
||||
for (int i = 0; i < localClients.size(); ++i) {
|
||||
connect(localClients[i], &AbstractClient::gameEventContainerReceived, this,
|
||||
&TabSupervisor::processGameEventContainer);
|
||||
}
|
||||
connect(localClients.first(), &AbstractClient::gameJoinedEventReceived, this, &TabSupervisor::localGameJoined);
|
||||
}
|
||||
|
||||
|
|
@ -437,8 +447,9 @@ void TabSupervisor::startLocal(const QList<AbstractClient *> &_clients)
|
|||
*/
|
||||
void TabSupervisor::stop()
|
||||
{
|
||||
if ((!client) && localClients.isEmpty())
|
||||
if ((!client) && localClients.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
resetTabsMenu();
|
||||
|
||||
|
|
@ -672,10 +683,12 @@ void TabSupervisor::openTabLog()
|
|||
|
||||
void TabSupervisor::updatePingTime(int value, int max)
|
||||
{
|
||||
if (!tabServer)
|
||||
if (!tabServer) {
|
||||
return;
|
||||
if (tabServer->getContentsChanged())
|
||||
}
|
||||
if (tabServer->getContentsChanged()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
|
||||
}
|
||||
|
|
@ -684,12 +697,14 @@ void TabSupervisor::gameJoined(const Event_GameJoined &event)
|
|||
{
|
||||
QMap<int, QString> roomGameTypes;
|
||||
TabRoom *room = roomTabs.value(event.game_info().room_id());
|
||||
if (room)
|
||||
if (room) {
|
||||
roomGameTypes = room->getGameTypes();
|
||||
else
|
||||
for (int i = 0; i < event.game_types_size(); ++i)
|
||||
} else {
|
||||
for (int i = 0; i < event.game_types_size(); ++i) {
|
||||
roomGameTypes.insert(event.game_types(i).game_type_id(),
|
||||
QString::fromStdString(event.game_types(i).description()));
|
||||
}
|
||||
}
|
||||
|
||||
auto *tab = new TabGame(this, QList<AbstractClient *>() << client, event, roomGameTypes);
|
||||
connect(tab, &TabGame::gameClosing, this, &TabSupervisor::gameLeft);
|
||||
|
|
@ -718,14 +733,16 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
|
|||
|
||||
void TabSupervisor::gameLeft(TabGame *tab)
|
||||
{
|
||||
if (tab == currentWidget())
|
||||
if (tab == currentWidget()) {
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
gameTabs.remove(tab->getGame()->getGameMetaInfo()->gameId());
|
||||
removeTab(indexOf(tab));
|
||||
|
||||
if (!localClients.isEmpty())
|
||||
if (!localClients.isEmpty()) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
|
||||
|
|
@ -736,14 +753,16 @@ void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
|
|||
connect(tab, &TabRoom::openMessageDialog, this, &TabSupervisor::addMessageTab);
|
||||
myAddTab(tab);
|
||||
roomTabs.insert(info.room_id(), tab);
|
||||
if (setCurrent)
|
||||
if (setCurrent) {
|
||||
setCurrentWidget(tab);
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::roomLeft(TabRoom *tab)
|
||||
{
|
||||
if (tab == currentWidget())
|
||||
if (tab == currentWidget()) {
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
roomTabs.remove(tab->getRoomId());
|
||||
removeTab(indexOf(tab));
|
||||
|
|
@ -771,16 +790,18 @@ void TabSupervisor::openReplay(GameReplay *replay)
|
|||
|
||||
void TabSupervisor::replayLeft(TabGame *tab)
|
||||
{
|
||||
if (tab == currentWidget())
|
||||
if (tab == currentWidget()) {
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
replayTabs.removeOne(tab);
|
||||
}
|
||||
|
||||
TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
|
||||
{
|
||||
if (receiverName == QString::fromStdString(userInfo->name()))
|
||||
if (receiverName == QString::fromStdString(userInfo->name())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ServerInfo_User otherUser;
|
||||
if (auto user = userListManager->getOnlineUser(receiverName)) {
|
||||
|
|
@ -792,8 +813,9 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus
|
|||
TabMessage *tab;
|
||||
tab = messageTabs.value(QString::fromStdString(otherUser.name()));
|
||||
if (tab) {
|
||||
if (focus)
|
||||
if (focus) {
|
||||
setCurrentWidget(tab);
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
||||
|
|
@ -802,8 +824,9 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus
|
|||
connect(tab, &TabMessage::maximizeClient, this, &TabSupervisor::maximizeMainWindow);
|
||||
myAddTab(tab);
|
||||
messageTabs.insert(receiverName, tab);
|
||||
if (focus)
|
||||
if (focus) {
|
||||
setCurrentWidget(tab);
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
||||
|
|
@ -814,8 +837,9 @@ void TabSupervisor::maximizeMainWindow()
|
|||
|
||||
void TabSupervisor::talkLeft(TabMessage *tab)
|
||||
{
|
||||
if (tab == currentWidget())
|
||||
if (tab == currentWidget()) {
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
messageTabs.remove(tab->getUserName());
|
||||
removeTab(indexOf(tab));
|
||||
|
|
@ -912,8 +936,9 @@ TabEdhRec *TabSupervisor::addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCo
|
|||
|
||||
void TabSupervisor::deckEditorClosed(AbstractTabDeckEditor *tab)
|
||||
{
|
||||
if (tab == currentWidget())
|
||||
if (tab == currentWidget()) {
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
deckEditorTabs.removeOne(tab);
|
||||
removeTab(indexOf(tab));
|
||||
|
|
@ -926,8 +951,9 @@ void TabSupervisor::tabUserEvent(bool globalEvent)
|
|||
tab->setContentsChanged(true);
|
||||
setTabIcon(indexOf(tab), QPixmap("theme:icons/tab_changed"));
|
||||
}
|
||||
if (globalEvent && SettingsCache::instance().getNotificationsEnabled())
|
||||
if (globalEvent && SettingsCache::instance().getNotificationsEnabled()) {
|
||||
QApplication::alert(this);
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::updateTabText(Tab *tab, const QString &newTabText)
|
||||
|
|
@ -940,39 +966,44 @@ void TabSupervisor::updateTabText(Tab *tab, const QString &newTabText)
|
|||
void TabSupervisor::processRoomEvent(const RoomEvent &event)
|
||||
{
|
||||
TabRoom *tab = roomTabs.value(event.room_id(), 0);
|
||||
if (tab)
|
||||
if (tab) {
|
||||
tab->processRoomEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::processGameEventContainer(const GameEventContainer &cont)
|
||||
{
|
||||
TabGame *tab = gameTabs.value(cont.game_id());
|
||||
if (tab)
|
||||
if (tab) {
|
||||
tab->getGame()->getGameEventHandler()->processGameEventContainer(cont, qobject_cast<AbstractClient *>(sender()),
|
||||
{});
|
||||
else
|
||||
} else {
|
||||
qCInfo(TabSupervisorLog) << "gameEvent: invalid gameId" << cont.game_id();
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::processUserMessageEvent(const Event_UserMessage &event)
|
||||
{
|
||||
QString senderName = QString::fromStdString(event.sender_name());
|
||||
TabMessage *tab = messageTabs.value(senderName);
|
||||
if (!tab)
|
||||
if (!tab) {
|
||||
tab = messageTabs.value(QString::fromStdString(event.receiver_name()));
|
||||
}
|
||||
if (!tab) {
|
||||
const ServerInfo_User *onlineUserInfo = userListManager->getOnlineUser(senderName);
|
||||
if (onlineUserInfo) {
|
||||
auto userLevel = UserLevelFlags(onlineUserInfo->user_level());
|
||||
if (SettingsCache::instance().getIgnoreUnregisteredUserMessages() &&
|
||||
!userLevel.testFlag(ServerInfo_User::IsRegistered))
|
||||
!userLevel.testFlag(ServerInfo_User::IsRegistered)) {
|
||||
// Flags are additive, so reg/mod/admin are all IsRegistered
|
||||
return;
|
||||
}
|
||||
}
|
||||
tab = addMessageTab(QString::fromStdString(event.sender_name()), false);
|
||||
}
|
||||
if (!tab)
|
||||
if (!tab) {
|
||||
return;
|
||||
}
|
||||
tab->processUserMessageEvent(event);
|
||||
}
|
||||
|
||||
|
|
@ -990,8 +1021,9 @@ void TabSupervisor::actShowPopup(const QString &message)
|
|||
void TabSupervisor::processUserLeft(const QString &userName)
|
||||
{
|
||||
TabMessage *tab = messageTabs.value(userName);
|
||||
if (tab)
|
||||
if (tab) {
|
||||
tab->processUserLeft();
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::processUserJoined(const ServerInfo_User &userInfoJoined)
|
||||
|
|
@ -1015,8 +1047,9 @@ void TabSupervisor::processUserJoined(const ServerInfo_User &userInfoJoined)
|
|||
}
|
||||
|
||||
TabMessage *tab = messageTabs.value(userName);
|
||||
if (tab)
|
||||
if (tab) {
|
||||
tab->processUserJoined(userInfoJoined);
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::updateCurrent(int index)
|
||||
|
|
@ -1029,8 +1062,9 @@ void TabSupervisor::updateCurrent(int index)
|
|||
}
|
||||
emit setMenu(static_cast<Tab *>(widget(index))->getTabMenus());
|
||||
tab->tabActivated();
|
||||
} else
|
||||
} else {
|
||||
emit setMenu();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1040,8 +1074,9 @@ void TabSupervisor::updateCurrent(int index)
|
|||
*/
|
||||
bool TabSupervisor::getAdminLocked() const
|
||||
{
|
||||
if (!tabAdmin)
|
||||
if (!tabAdmin) {
|
||||
return true;
|
||||
}
|
||||
return tabAdmin->getLocked();
|
||||
}
|
||||
|
||||
|
|
@ -1065,12 +1100,13 @@ void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
|||
tr("You have been promoted. Please log out and back in for changes to take effect."));
|
||||
break;
|
||||
case Event_NotifyUser::WARNING: {
|
||||
if (!QString::fromStdString(event.warning_reason()).simplified().isEmpty())
|
||||
if (!QString::fromStdString(event.warning_reason()).simplified().isEmpty()) {
|
||||
QMessageBox::warning(this, tr("Warned"),
|
||||
tr("You have received a warning due to %1.\nPlease refrain from engaging in this "
|
||||
"activity or further actions may be taken against you. If you have any "
|
||||
"questions, please private message a moderator.")
|
||||
.arg(QString::fromStdString(event.warning_reason()).simplified()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Event_NotifyUser::CUSTOM: {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
* @file tab_supervisor.h
|
||||
* @ingroup Core
|
||||
* @ingroup Tabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_SUPERVISOR_H
|
||||
#define TAB_SUPERVISOR_H
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_visual_database_display.h
|
||||
* @ingroup Tabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_VISUAL_DATABASE_DISPLAY_H
|
||||
#define TAB_VISUAL_DATABASE_DISPLAY_H
|
||||
|
|
@ -23,8 +23,8 @@ public:
|
|||
void retranslateUi() override;
|
||||
[[nodiscard]] QString getTabText() const override
|
||||
{
|
||||
return visualDatabaseDisplayWidget->displayModeButton->isChecked() ? tr("Database Display")
|
||||
: tr("Visual Database Display");
|
||||
return visualDatabaseDisplayWidget->isVisualDisplayMode() ? tr("Visual Database Display")
|
||||
: tr("Database Display");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ TabDeckEditorVisual::TabDeckEditorVisual(TabSupervisor *_tabSupervisor) : Abstra
|
|||
refreshShortcuts();
|
||||
|
||||
loadLayout();
|
||||
filterDockWidget->setHidden(true);
|
||||
cardDatabaseDockWidget->setHidden(true);
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +100,7 @@ void TabDeckEditorVisual::createMenus()
|
|||
|
||||
registerDockWidget(viewMenu, cardInfoDockWidget, {250, 500});
|
||||
registerDockWidget(viewMenu, deckDockWidget, {250, 360});
|
||||
registerDockWidget(viewMenu, filterDockWidget, {250, 250});
|
||||
// registerDockWidget(viewMenu, filterDockWidget, {250, 250});
|
||||
registerDockWidget(viewMenu, printingSelectorDockWidget, {525, 250});
|
||||
|
||||
viewMenu->addSeparator();
|
||||
|
|
@ -116,8 +117,9 @@ void TabDeckEditorVisual::createMenus()
|
|||
QString TabDeckEditorVisual::getTabText() const
|
||||
{
|
||||
QString result = tr("Visual Deck: %1").arg(deckStateManager->getSimpleDeckName());
|
||||
if (deckStateManager->isModified())
|
||||
if (deckStateManager->isModified()) {
|
||||
result.prepend("* ");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -275,18 +277,18 @@ void TabDeckEditorVisual::restartLayout()
|
|||
|
||||
deckDockWidget->setVisible(true);
|
||||
cardInfoDockWidget->setVisible(true);
|
||||
filterDockWidget->setVisible(false);
|
||||
// filterDockWidget->setVisible(false);
|
||||
printingSelectorDockWidget->setVisible(true);
|
||||
|
||||
setCentralWidget(centralWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, deckDockWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, cardInfoDockWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, filterDockWidget);
|
||||
// addDockWidget(Qt::RightDockWidgetArea, filterDockWidget);
|
||||
addDockWidget(Qt::RightDockWidgetArea, printingSelectorDockWidget);
|
||||
|
||||
splitDockWidget(cardInfoDockWidget, printingSelectorDockWidget, Qt::Vertical);
|
||||
splitDockWidget(cardInfoDockWidget, deckDockWidget, Qt::Horizontal);
|
||||
splitDockWidget(cardInfoDockWidget, filterDockWidget, Qt::Horizontal);
|
||||
// splitDockWidget(cardInfoDockWidget, filterDockWidget, Qt::Horizontal);
|
||||
|
||||
QTimer::singleShot(100, this, SLOT(freeDocksSize()));
|
||||
}
|
||||
|
|
@ -298,13 +300,13 @@ void TabDeckEditorVisual::retranslateUi()
|
|||
|
||||
cardInfoDockWidget->setWindowTitle(tr("Card Info"));
|
||||
deckDockWidget->setWindowTitle(tr("Deck"));
|
||||
filterDockWidget->setWindowTitle(tr("Filters"));
|
||||
// filterDockWidget->setWindowTitle(tr("Filters"));
|
||||
|
||||
viewMenu->setTitle(tr("&View"));
|
||||
|
||||
dockToActions[cardInfoDockWidget].menu->setTitle(tr("Card Info"));
|
||||
dockToActions[deckDockWidget].menu->setTitle(tr("Deck"));
|
||||
dockToActions[filterDockWidget].menu->setTitle(tr("Filters"));
|
||||
// dockToActions[filterDockWidget].menu->setTitle(tr("Filters"));
|
||||
dockToActions[printingSelectorDockWidget].menu->setTitle(tr("Printing"));
|
||||
|
||||
for (auto &actions : dockToActions.values()) {
|
||||
|
|
|
|||
|
|
@ -63,19 +63,19 @@ public:
|
|||
CardDatabaseModel *_cardDatabaseModel,
|
||||
CardDatabaseDisplayModel *_cardDatabaseDisplayModel);
|
||||
|
||||
/// Add a new tab with a widget and title.
|
||||
/** @brief Add a new tab with a widget and title. */
|
||||
void addNewTab(QWidget *widget, const QString &title);
|
||||
|
||||
/// Remove the currently active tab.
|
||||
/** @brief Remove the currently active tab. */
|
||||
void removeCurrentTab();
|
||||
|
||||
/// Set the title of a specific tab.
|
||||
/** @brief Set the title of a specific tab. */
|
||||
void setTabTitle(int index, const QString &title);
|
||||
|
||||
/// Get the currently active tab widget.
|
||||
/** @brief Get the currently active tab widget. */
|
||||
[[nodiscard]] QWidget *getCurrentTab() const;
|
||||
|
||||
/// Get the total number of tabs.
|
||||
/** @brief Get the total number of tabs. */
|
||||
[[nodiscard]] int getTabCount() const;
|
||||
|
||||
VisualDeckEditorWidget *visualDeckView; ///< Visual deck editor widget.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* @file tab_deck_storage_visual.h
|
||||
* @ingroup Tabs
|
||||
* @brief TODO: Document this.
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef TAB_DECK_STORAGE_VISUAL_H
|
||||
#define TAB_DECK_STORAGE_VISUAL_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue