Merge branch 'master' into tooomm-qt5

This commit is contained in:
tooomm 2026-05-30 14:49:55 +02:00 committed by GitHub
commit 9d4cf57c70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
593 changed files with 12518 additions and 6581 deletions

View file

@ -1,8 +1,8 @@
/**
* @file color_identity_widget.h
* @ingroup CardExtraInfoWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef COLOR_IDENTITY_WIDGET_H
#define COLOR_IDENTITY_WIDGET_H

View file

@ -1,8 +1,8 @@
/**
* @file mana_cost_widget.h
* @ingroup CardExtraInfoWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef MANA_COST_WIDGET_H
#define MANA_COST_WIDGET_H

View file

@ -1,8 +1,8 @@
/**
* @file mana_symbol_widget.h
* @ingroup CardExtraInfoWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef MANA_SYMBOL_WIDGET_H
#define MANA_SYMBOL_WIDGET_H

View file

@ -95,8 +95,9 @@ void CardGroupDisplayWidget::onSelectionChanged(const QItemSelection &selected,
for (auto &range : deselected) {
for (int row = range.top(); row <= range.bottom(); ++row) {
QModelIndex idx = range.model()->index(row, 0, range.parent());
if (proxyModel)
if (proxyModel) {
idx = proxyModel->mapToSource(idx);
}
auto it = indexToWidgetMap.find(QPersistentModelIndex(idx));
if (it != indexToWidgetMap.end()) {

View file

@ -1,8 +1,8 @@
/**
* @file card_group_display_widget.h
* @ingroup DeckEditorCardGroupWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARD_GROUP_DISPLAY_WIDGET_H
#define CARD_GROUP_DISPLAY_WIDGET_H

View file

@ -1,8 +1,8 @@
/**
* @file flat_card_group_display_widget.h
* @ingroup DeckEditorCardGroupWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef FLAT_CARD_GROUP_DISPLAY_WIDGET_H
#define FLAT_CARD_GROUP_DISPLAY_WIDGET_H

View file

@ -1,8 +1,8 @@
/**
* @file overlapped_card_group_display_widget.h
* @ingroup DeckEditorCardGroupWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef OVERLAPPED_CARD_GROUP_DISPLAY_WIDGET_H
#define OVERLAPPED_CARD_GROUP_DISPLAY_WIDGET_H

View file

@ -43,11 +43,13 @@ CardInfoDisplayWidget::CardInfoDisplayWidget(const CardRef &cardRef, QWidget *pa
void CardInfoDisplayWidget::setCard(const ExactCard &card)
{
if (exactCard)
if (exactCard) {
disconnect(exactCard.getCardPtr().data(), nullptr, this, nullptr);
}
exactCard = card;
if (exactCard)
if (exactCard) {
connect(exactCard.getCardPtr().data(), &QObject::destroyed, this, &CardInfoDisplayWidget::clear);
}
text->setCard(exactCard);
pic->setCard(exactCard);

View file

@ -1,8 +1,8 @@
/**
* @file card_info_display_widget.h
* @ingroup CardWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARDINFOWIDGET_H
#define CARDINFOWIDGET_H

View file

@ -1,8 +1,8 @@
/**
* @file card_info_frame_widget.h
* @ingroup CardWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARDFRAME_H
#define CARDFRAME_H

View file

@ -1,8 +1,8 @@
/**
* @file card_info_picture_art_crop_widget.h
* @ingroup CardWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARD_INFO_PICTURE_ART_CROP_WIDGET_H
#define CARD_INFO_PICTURE_ART_CROP_WIDGET_H

View file

@ -2,8 +2,8 @@
* @file card_info_picture_enlarged_widget.h
* @ingroup CardWigets
* @ingroup DeckEditorWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARD_PICTURE_ENLARGED_WIDGET_H
#define CARD_PICTURE_ENLARGED_WIDGET_H

View file

@ -1,8 +1,8 @@
/**
* @file card_info_picture_widget.h
* @ingroup CardWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARD_INFO_PICTURE_H
#define CARD_INFO_PICTURE_H

View file

@ -2,8 +2,8 @@
* @file card_info_picture_with_text_overlay_widget.h
* @ingroup CardWidgets
* @ingroup DeckStorageWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARD_PICTURE_WITH_TEXT_OVERLAY_H
#define CARD_PICTURE_WITH_TEXT_OVERLAY_H

View file

@ -73,8 +73,9 @@ void CardInfoTextWidget::setCard(const ExactCard &exactCard)
QStringList cardProps = card->getProperties();
for (const QString &key : cardProps) {
if (key.contains("-"))
if (key.contains("-")) {
continue;
}
QString keyText = Mtg::getNicePropertyName(key).toHtmlEscaped() + ":";
text +=
QString("<tr><td>%1</td><td></td><td>%2</td></tr>").arg(keyText, card->getProperty(key).toHtmlEscaped());

View file

@ -1,8 +1,8 @@
/**
* @file card_info_text_widget.h
* @ingroup CardWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARDINFOTEXT_H
#define CARDINFOTEXT_H

View file

@ -3,8 +3,8 @@
* @ingroup CardWidgets
* @ingroup DeckEditorWidgets
* @ingroup DeckStorageWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARD_SIZE_WIDGET_H
#define CARD_SIZE_WIDGET_H

View file

@ -1,8 +1,8 @@
/**
* @file deck_card_zone_display_widget.h
* @ingroup DeckEditorWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DECK_CARD_ZONE_DISPLAY_WIDGET_H
#define DECK_CARD_ZONE_DISPLAY_WIDGET_H

View file

@ -2,8 +2,8 @@
* @file deck_preview_card_picture_widget.h
* @ingroup CardWidgets
* @ingroup Lobby
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DECK_PREVIEW_CARD_PICTURE_WIDGET_H
#define DECK_PREVIEW_CARD_PICTURE_WIDGET_H

View file

@ -17,8 +17,9 @@ AbstractAnalyticsPanelWidget *
AnalyticsPanelWidgetFactory::create(const QString &type, QWidget *parent, DeckListStatisticsAnalyzer *analyzer) const
{
auto it = widgets.find(type);
if (it == widgets.end())
if (it == widgets.end()) {
return nullptr;
}
auto w = it->creator(parent, analyzer);

View file

@ -20,12 +20,11 @@
DrawProbabilityWidget::DrawProbabilityWidget(QWidget *parent, DeckListStatisticsAnalyzer *analyzer)
: AbstractAnalyticsPanelWidget(parent, analyzer)
{
controls = new QWidget(this);
controlLayout = new QHBoxLayout(controls);
controlLayout->setContentsMargins(11, 0, 11, 0);
controls = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAlwaysOff);
controls->setSpacing(4, 4);
labelPrefix = new QLabel(this);
controlLayout->addWidget(labelPrefix);
controls->addWidget(labelPrefix);
criteriaCombo = new QComboBox(this);
// Give these things item-data so we can translate the actual user-facing strings
@ -33,33 +32,32 @@ DrawProbabilityWidget::DrawProbabilityWidget(QWidget *parent, DeckListStatistics
criteriaCombo->addItem(QString(), "type");
criteriaCombo->addItem(QString(), "subtype");
criteriaCombo->addItem(QString(), "cmc");
controlLayout->addWidget(criteriaCombo);
controls->addWidget(criteriaCombo);
exactnessCombo = new QComboBox(this);
exactnessCombo->addItem(QString(), true); // At least
exactnessCombo->addItem(QString(), false); // Exactly
controlLayout->addWidget(exactnessCombo);
controls->addWidget(exactnessCombo);
quantitySpin = new QSpinBox(this);
quantitySpin->setRange(1, 60);
controlLayout->addWidget(quantitySpin);
controls->addWidget(quantitySpin);
labelMiddle = new QLabel(this);
controlLayout->addWidget(labelMiddle);
controls->addWidget(labelMiddle);
drawnSpin = new QSpinBox(this);
drawnSpin->setRange(1, 60);
drawnSpin->setValue(7);
controlLayout->addWidget(drawnSpin);
controls->addWidget(drawnSpin);
labelSuffix = new QLabel(this);
controlLayout->addWidget(labelSuffix);
controls->addWidget(labelSuffix);
labelPrefix->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
labelMiddle->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
labelSuffix->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
controlLayout->addStretch(1);
layout->addWidget(controls);
// Table

View file

@ -1,6 +1,8 @@
#ifndef COCKATRICE_DRAW_PROBABILITY_WIDGET_H
#define COCKATRICE_DRAW_PROBABILITY_WIDGET_H
#include "../../../../layouts/flow_layout.h"
#include "../../../general/layout_containers/flow_widget.h"
#include "../../abstract_analytics_panel_widget.h"
#include "../../deck_list_statistics_analyzer.h"
#include "draw_probability_config.h"
@ -31,8 +33,7 @@ private slots:
private:
DrawProbabilityConfig config;
QWidget *controls;
QHBoxLayout *controlLayout;
FlowWidget *controls;
QLabel *labelPrefix;
QLabel *labelMiddle;
QLabel *labelSuffix;

View file

@ -28,8 +28,9 @@ ManaBaseConfigDialog::ManaBaseConfigDialog(DeckListStatisticsAnalyzer *analyzer,
// select initial filters
for (int i = 0; i < filterList->count(); ++i) {
if (config.filters.contains(filterList->item(i)->text()))
if (config.filters.contains(filterList->item(i)->text())) {
filterList->item(i)->setSelected(true);
}
}
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);

View file

@ -1,8 +1,8 @@
/**
* @file mana_base_widget.h
* @ingroup DeckEditorAnalyticsWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef MANA_BASE_WIDGET_H
#define MANA_BASE_WIDGET_H

View file

@ -69,8 +69,9 @@ void ManaCurveConfigDialog::setFromConfig(const ManaCurveConfig &cfg)
{
groupBy->setCurrentText(cfg.groupBy);
// restore filters
for (int i = 0; i < filterList->count(); ++i)
for (int i = 0; i < filterList->count(); ++i) {
filterList->item(i)->setSelected(cfg.filters.contains(filterList->item(i)->text()));
}
showMain->setChecked(cfg.showMain);
showCatRows->setChecked(cfg.showCategoryRows);
@ -81,8 +82,9 @@ void ManaCurveConfigDialog::accept()
cfg.groupBy = groupBy->currentText();
cfg.filters.clear();
for (auto *item : filterList->selectedItems())
for (auto *item : filterList->selectedItems()) {
cfg.filters << item->text();
}
cfg.showMain = showMain->isChecked();
cfg.showCategoryRows = showCatRows->isChecked();

View file

@ -51,15 +51,17 @@ void ManaCurveTotalWidget::updateDisplay(const QString &categoryName,
for (auto it = cmcIt->cbegin(); it != cmcIt->cend(); ++it) {
const QString &category = it.key();
if (!config.filters.isEmpty() && !config.filters.contains(category))
if (!config.filters.isEmpty() && !config.filters.contains(category)) {
continue;
}
const int value = it.value();
QStringList cards;
const auto catIt = cardsMap.constFind(category);
if (catIt != cardsMap.cend())
if (catIt != cardsMap.cend()) {
cards = catIt->value(cmc);
}
segments.push_back({category, value, cards, GameSpecificColors::MTG::colorHelper(category)});
}

View file

@ -69,16 +69,18 @@ static void buildMapsByCategory(const QHash<QString, QHash<int, int>> &categoryC
const QString &category = catIt.key();
const auto &countsByCmc = catIt.value();
for (auto it = countsByCmc.cbegin(); it != countsByCmc.cend(); ++it)
for (auto it = countsByCmc.cbegin(); it != countsByCmc.cend(); ++it) {
outCmcMap[it.key()][category] = it.value();
}
}
for (auto catIt = categoryCards.cbegin(); catIt != categoryCards.cend(); ++catIt) {
const QString &category = catIt.key();
const auto &cardsByCmc = catIt.value();
for (auto it = cardsByCmc.cbegin(); it != cardsByCmc.cend(); ++it)
for (auto it = cardsByCmc.cbegin(); it != cardsByCmc.cend(); ++it) {
outCardsMap[category][it.key()] = it.value();
}
}
}
@ -88,8 +90,9 @@ static void findGlobalCmcRange(const QHash<QString, QHash<int, int>> &categoryCo
maxCmc = 0;
for (const auto &countsByCmc : categoryCounts) {
for (auto it = countsByCmc.cbegin(); it != countsByCmc.cend(); ++it)
for (auto it = countsByCmc.cbegin(); it != countsByCmc.cend(); ++it) {
maxCmc = qMax(maxCmc, it.key());
}
}
}

View file

@ -1,8 +1,8 @@
/**
* @file mana_curve_widget.h
* @ingroup DeckEditorAnalyticsWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef MANA_CURVE_WIDGET_H
#define MANA_CURVE_WIDGET_H
@ -37,7 +37,7 @@ public:
{
config = ManaCurveConfig::fromJson(o);
updateDisplay();
};
}
QJsonObject extractConfigFromDialog(QDialog *dlg) const override;

View file

@ -26,8 +26,9 @@ ManaDevotionConfigDialog::ManaDevotionConfigDialog(DeckListStatisticsAnalyzer *a
// select initial filters
for (int i = 0; i < filterList->count(); ++i) {
if (config.filters.contains(filterList->item(i)->text()))
if (config.filters.contains(filterList->item(i)->text())) {
filterList->item(i)->setSelected(true);
}
}
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);

View file

@ -1,8 +1,8 @@
/**
* @file mana_devotion_widget.h
* @ingroup DeckEditorAnalyticsWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef MANA_DEVOTION_WIDGET_H
#define MANA_DEVOTION_WIDGET_H

View file

@ -24,8 +24,9 @@ ManaDistributionConfig ManaDistributionConfig::fromJson(const QJsonObject &o)
if (o.contains("filters")) {
config.filters.clear();
for (auto v : o["filters"].toArray())
for (auto v : o["filters"].toArray()) {
config.filters << v.toString();
}
}
if (o.contains("showColorRows")) {

View file

@ -62,8 +62,9 @@ void ManaDistributionConfigDialog::setFromConfig(const ManaDistributionConfig &c
displayType->setCurrentText(cfg.displayType);
for (int i = 0; i < filterList->count(); ++i)
for (int i = 0; i < filterList->count(); ++i) {
filterList->item(i)->setSelected(cfg.filters.contains(filterList->item(i)->text()));
}
showColorRows->setChecked(cfg.showColorRows);
}
@ -74,8 +75,9 @@ void ManaDistributionConfigDialog::accept()
// Filters
cfg.filters.clear();
for (auto *item : filterList->selectedItems())
for (auto *item : filterList->selectedItems()) {
cfg.filters << item->text();
}
cfg.showColorRows = showColorRows->isChecked();

View file

@ -23,8 +23,8 @@ DeckAnalyticsWidget::DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnal
layout = new QVBoxLayout(this);
// Controls
controlContainer = new QWidget(this);
controlLayout = new QHBoxLayout(controlContainer);
controlContainer = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAlwaysOff);
controlContainer->setSpacing(4, 4);
addButton = new QPushButton(this);
removeButton = new QPushButton(this);
saveButton = new QPushButton(this);
@ -32,11 +32,11 @@ DeckAnalyticsWidget::DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnal
includeSideboardCheckBox = new QCheckBox(this);
includeSideboardCheckBox->setChecked(false);
controlLayout->addWidget(addButton);
controlLayout->addWidget(removeButton);
controlLayout->addWidget(saveButton);
controlLayout->addWidget(loadButton);
controlLayout->addWidget(includeSideboardCheckBox);
controlContainer->addWidget(addButton);
controlContainer->addWidget(removeButton);
controlContainer->addWidget(saveButton);
controlContainer->addWidget(loadButton);
controlContainer->addWidget(includeSideboardCheckBox);
layout->addWidget(controlContainer);

View file

@ -7,6 +7,7 @@
#ifndef DECK_ANALYTICS_WIDGET_H
#define DECK_ANALYTICS_WIDGET_H
#include "../general/layout_containers/flow_widget.h"
#include "abstract_analytics_panel_widget.h"
#include "deck_list_statistics_analyzer.h"
#include "resizable_panel.h"
@ -51,8 +52,7 @@ private:
void addPanelInstance(const QString &typeId, AbstractAnalyticsPanelWidget *panel, const QJsonObject &cfg = {});
QVBoxLayout *layout;
QWidget *controlContainer;
QHBoxLayout *controlLayout;
FlowWidget *controlContainer;
QPushButton *addButton;
QPushButton *removeButton;

View file

@ -191,10 +191,12 @@ double DeckListStatisticsAnalyzer::hypergeometric(int N, int K, int n, int k)
}
auto choose = [](int n, int r) -> double {
if (r > n)
if (r > n) {
return 0.0;
if (r == 0 || r == n)
}
if (r == 0 || r == n) {
return 1.0;
}
double res = 1.0;
for (int i = 1; i <= r; ++i) {
res *= (n - r + i);

View file

@ -58,7 +58,3 @@ void DeckEditorCardDatabaseDockWidget::clearAllDatabaseFilters()
{
databaseDisplayWidget->clearAllDatabaseFilters();
}
void DeckEditorCardDatabaseDockWidget::highlightAllSearchEdit()
{
databaseDisplayWidget->searchEdit->setSelection(0, databaseDisplayWidget->searchEdit->text().length());
}

View file

@ -23,7 +23,6 @@ public:
public slots:
void retranslateUi();
void clearAllDatabaseFilters();
void highlightAllSearchEdit();
private:
void createDatabaseDisplayDock(AbstractTabDeckEditor *deckEditor);

View file

@ -121,9 +121,10 @@ void DeckEditorDatabaseDisplayWidget::updateSearch(const QString &search)
{
databaseDisplayModel->setStringFilter(search);
QModelIndexList sel = databaseView->selectionModel()->selectedRows();
if (sel.isEmpty() && databaseDisplayModel->rowCount())
if (sel.isEmpty() && databaseDisplayModel->rowCount()) {
databaseView->selectionModel()->setCurrentIndex(databaseDisplayModel->index(0, 0),
QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
}
}
void DeckEditorDatabaseDisplayWidget::clearAllDatabaseFilters()
@ -147,11 +148,13 @@ void DeckEditorDatabaseDisplayWidget::updateCard(const QModelIndex &current, con
void DeckEditorDatabaseDisplayWidget::actAddCardToMainDeck()
{
highlightAllSearchEdit();
emit addCardToMainDeck(currentCard());
}
void DeckEditorDatabaseDisplayWidget::actAddCardToSideboard()
{
highlightAllSearchEdit();
emit addCardToSideboard(currentCard());
}
@ -240,4 +243,9 @@ void DeckEditorDatabaseDisplayWidget::retranslateUi()
{
aAddCard->setText(tr("Add card to &maindeck"));
aAddCardToSideboard->setText(tr("Add card to &sideboard"));
}
void DeckEditorDatabaseDisplayWidget::highlightAllSearchEdit()
{
searchEdit->setSelection(0, searchEdit->text().length());
}

View file

@ -25,7 +25,6 @@ class DeckEditorDatabaseDisplayWidget : public QWidget
public:
explicit DeckEditorDatabaseDisplayWidget(QWidget *parent, AbstractTabDeckEditor *deckEditor);
AbstractTabDeckEditor *deckEditor;
SearchLineEdit *searchEdit;
CardDatabaseModel *databaseModel;
CardDatabaseDisplayModel *databaseDisplayModel;
@ -58,10 +57,13 @@ private:
KeySignals searchKeySignals;
QTreeView *databaseView;
QHBoxLayout *searchLayout;
SearchLineEdit *searchEdit;
QAction *aAddCard, *aAddCardToSideboard;
QVBoxLayout *centralFrame;
QWidget *centralWidget;
void highlightAllSearchEdit();
private slots:
void retranslateUi();
void saveDbHeaderState();

View file

@ -314,8 +314,9 @@ void DeckEditorDeckDockWidget::initializeFormats()
ExactCard DeckEditorDeckDockWidget::getCurrentCard()
{
QModelIndex current = deckView->selectionModel()->currentIndex();
if (!current.isValid())
if (!current.isValid()) {
return {};
}
const QString cardName = current.siblingAtColumn(DeckListModelColumns::CARD_NAME).data().toString();
const QString cardProviderID = current.siblingAtColumn(DeckListModelColumns::CARD_PROVIDER_ID).data().toString();
const QModelIndex gparent = current.parent().parent();
@ -530,7 +531,7 @@ void DeckEditorDeckDockWidget::changeSelectedCard(int changeBy)
// currentIndex will return an index for the underlying deckModel instead of the proxy.
// That index will return an invalid index when indexBelow/indexAbove crosses a header node,
// causing the selection to fail to move down.
/// \todo Figure out why it's happening so we can do a proper fix instead of a hacky workaround
//! \todo Figure out why it's happening so we can do a proper fix instead of a hacky workaround.
if (deckViewCurrentIndex.model() == proxy->sourceModel()) {
deckViewCurrentIndex = proxy->mapFromSource(deckViewCurrentIndex);
}
@ -634,8 +635,8 @@ void DeckEditorDeckDockWidget::actSwapSelection()
{
auto selectedRows = getSelectedCardNodeSourceIndices();
// hack to maintain the old reselection behavior when currently selected row of a single-selection gets deleted
// TODO: remove the hack and also handle reselection when all rows of a multi-selection gets deleted
//! \todo Remove the hack and also handle reselection when all rows of a multi-selection gets deleted.
// Hack: maintains old reselection behavior when single-selection row is deleted.
if (selectedRows.length() == 1) {
deckView->setSelectionMode(QAbstractItemView::SingleSelection);
}
@ -651,10 +652,12 @@ void DeckEditorDeckDockWidget::actSwapSelection()
void DeckEditorDeckDockWidget::actDecrementCard(const ExactCard &card, QString zoneName)
{
if (!card)
if (!card) {
return;
if (card.getInfo().getIsToken())
}
if (card.getInfo().getIsToken()) {
zoneName = DECK_ZONE_TOKENS;
}
deckStateManager->decrementCard(card, zoneName);
}
@ -663,8 +666,8 @@ void DeckEditorDeckDockWidget::actDecrementSelection()
{
auto selectedRows = getSelectedCardNodeSourceIndices();
// hack to maintain the old reselection behavior when currently selected row of a single-selection gets deleted
// TODO: remove the hack and also handle reselection when all rows of a multi-selection gets deleted
//! \todo Remove the hack and also handle reselection when all rows of a multi-selection gets deleted.
// Hack: maintains old reselection behavior when single-selection row is deleted.
if (selectedRows.length() == 1) {
deckView->setSelectionMode(QAbstractItemView::SingleSelection);
}
@ -680,8 +683,8 @@ void DeckEditorDeckDockWidget::actRemoveCard()
{
auto selectedRows = getSelectedCardNodeSourceIndices();
// hack to maintain the old reselection behavior when currently selected row of a single-selection gets deleted
// TODO: remove the hack and also handle reselection when all rows of a multi-selection gets deleted
//! \todo Remove the hack and also handle reselection when all rows of a multi-selection gets deleted.
// Hack: maintains old reselection behavior when single-selection row is deleted.
if (selectedRows.length() == 1) {
deckView->setSelectionMode(QAbstractItemView::SingleSelection);
}

View file

@ -89,8 +89,9 @@ void DeckEditorFilterDockWidget::filterViewCustomContextMenu(const QPoint &point
QModelIndex idx;
idx = filterView->indexAt(point);
if (!idx.isValid())
if (!idx.isValid()) {
return;
}
action = menu.addAction(QString("delete"));
action->setData(point);
@ -105,8 +106,9 @@ void DeckEditorFilterDockWidget::filterRemove(const QAction *action)
point = action->data().toPoint();
idx = filterView->indexAt(point);
if (!idx.isValid())
if (!idx.isValid()) {
return;
}
filterModel->removeRow(idx.row(), idx.parent());
}

View file

@ -8,8 +8,9 @@
QVariant DeckListStyleProxy::data(const QModelIndex &index, int role) const
{
QModelIndex src = mapToSource(index);
if (!src.isValid())
if (!src.isValid()) {
return {};
}
QVariant value = QIdentityProxyModel::data(index, role);

View file

@ -192,8 +192,9 @@ QModelIndex DeckStateManager::addCard(const ExactCard &card, const QString &zone
QModelIndex DeckStateManager::decrementCard(const ExactCard &card, const QString &zoneName)
{
if (!card)
if (!card) {
return {};
}
QString providerId = card.getPrinting().getUuid();
QString collectorNumber = card.getPrinting().getProperty("num");
@ -241,15 +242,17 @@ static bool doSwapCard(DeckListModel *model,
bool DeckStateManager::swapCardAtIndex(const QModelIndex &idx)
{
if (!idx.isValid())
if (!idx.isValid()) {
return false;
}
QString cardName = idx.siblingAtColumn(DeckListModelColumns::CARD_NAME).data().toString();
QString providerId = idx.siblingAtColumn(DeckListModelColumns::CARD_PROVIDER_ID).data().toString();
QModelIndex gparent = idx.parent().parent();
if (!gparent.isValid())
if (!gparent.isValid()) {
return false;
}
QString zoneName = gparent.siblingAtColumn(DeckListModelColumns::CARD_NAME).data(Qt::EditRole).toString();
QString otherZoneName = zoneName == DECK_ZONE_MAIN ? DECK_ZONE_SIDE : DECK_ZONE_MAIN;

View file

@ -154,9 +154,11 @@ public:
*/
QModelIndex modifyDeck(const QString &reason, const std::function<QModelIndex(DeckListModel *)> &operation);
/// @name Metadata setters
/// @brief These methods set the metadata. Will no-op if the new value is the same as the current value.
/// Saves the operation to history if successful.
/**
* @name Metadata setters
* @brief These methods set the metadata. Will no-op if the new value is the same as the current value.
* Saves the operation to history if successful.
*/
///@{
void setName(const QString &name);
void setComments(const QString &comments);

View file

@ -261,13 +261,7 @@ void DlgConnect::updateDisplayInfo(const QString &saveName)
QStringList _data = uci.getServerInfo(saveName);
if (_data.isEmpty()) {
_data << ""
<< ""
<< ""
<< ""
<< ""
<< ""
<< "";
_data << "" << "" << "" << "" << "" << "" << "";
}
bool savePasswordStatus = (_data.at(5) == "1");

View file

@ -1,8 +1,8 @@
/**
* @file dlg_connect.h
* @ingroup ConnectionDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_CONNECT_H
#define DLG_CONNECT_H

View file

@ -2,8 +2,8 @@
* @file dlg_convert_deck_to_cod_format.h
* @ingroup LocalDeckStorageDialogs
* @ingroup Lobby
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DIALOG_CONVERT_DECK_TO_COD_FORMAT_H
#define DIALOG_CONVERT_DECK_TO_COD_FORMAT_H

View file

@ -215,8 +215,9 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
spectatorsSeeEverythingCheckBox->setChecked(gameInfo.spectators_omniscient());
QSet<int> types;
for (int i = 0; i < gameInfo.game_types_size(); ++i)
for (int i = 0; i < gameInfo.game_types_size(); ++i) {
types.insert(gameInfo.game_types(i));
}
QMapIterator<int, QString> gameTypeIterator(gameTypes);
while (gameTypeIterator.hasNext()) {
@ -316,9 +317,9 @@ void DlgCreateGame::checkResponse(const Response &response)
{
buttonBox->setEnabled(true);
if (response.response_code() == Response::RespOk)
if (response.response_code() == Response::RespOk) {
accept();
else {
} else {
QMessageBox::critical(this, tr("Error"), tr("Server error."));
return;
}

View file

@ -1,8 +1,8 @@
/**
* @file dlg_create_game.h
* @ingroup RoomDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_CREATEGAME_H
#define DLG_CREATEGAME_H

View file

@ -95,8 +95,9 @@ void DlgDefaultTagsEditor::addItem()
// Prevent duplicate tags
for (int i = 0; i < listWidget->count(); ++i) {
QWidget *widget = listWidget->itemWidget(listWidget->item(i));
if (!widget)
if (!widget) {
continue;
}
QLineEdit *lineEdit = widget->findChild<QLineEdit *>();
if (lineEdit && lineEdit->text() == newTag) {
QMessageBox::warning(this, tr("Duplicate Tag"), tr("This tag already exists."));
@ -138,8 +139,9 @@ void DlgDefaultTagsEditor::confirmChanges()
QStringList updatedList;
for (int i = 0; i < listWidget->count(); ++i) {
QWidget *widget = listWidget->itemWidget(listWidget->item(i));
if (!widget)
if (!widget) {
continue;
}
QLineEdit *lineEdit = widget->findChild<QLineEdit *>();
if (lineEdit) {
updatedList.append(lineEdit->text());

View file

@ -2,8 +2,8 @@
* @file dlg_default_tags_editor.h
* @ingroup Dialogs
* @ingroup DeckStorageWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_DEFAULT_TAGS_EDITOR_H
#define DLG_DEFAULT_TAGS_EDITOR_H

View file

@ -1,8 +1,8 @@
/**
* @file dlg_edit_avatar.h
* @ingroup AccountDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_EDITAVATAR_H
#define DLG_EDITAVATAR_H

View file

@ -59,7 +59,7 @@ DlgEditPassword::DlgEditPassword(QWidget *parent) : QDialog(parent)
void DlgEditPassword::actOk()
{
//! \todo this stuff should be using qvalidators
//! \todo This stuff should be using QValidators.
if (newPasswordEdit->text().length() < 8) {
QMessageBox::critical(this, tr("Error"), tr("Your password is too short."));
return;

View file

@ -1,8 +1,8 @@
/**
* @file dlg_edit_password.h
* @ingroup AccountDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_EDITPASSWORD_H
#define DLG_EDITPASSWORD_H

View file

@ -149,8 +149,9 @@ void DlgEditTokens::actAddToken()
QString name;
for (;;) {
name = getTextWithMax(this, tr("Add token"), tr("Please enter the name of the token:"));
if (name.isEmpty())
if (name.isEmpty()) {
return;
}
if (databaseModel->getDatabase()->query()->getCardInfo(name)) {
QMessageBox::critical(this, tr("Error"),
tr("The chosen name conflicts with an existing card or token.\nMake sure to enable "
@ -181,18 +182,21 @@ void DlgEditTokens::actRemoveToken()
void DlgEditTokens::colorChanged(int colorIndex)
{
if (currentCard)
if (currentCard) {
currentCard->setColors(QString(colorEdit->itemData(colorIndex).toChar()));
}
}
void DlgEditTokens::ptChanged(const QString &_pt)
{
if (currentCard)
if (currentCard) {
currentCard->setPowTough(_pt);
}
}
void DlgEditTokens::annotationChanged(const QString &_annotation)
{
if (currentCard)
if (currentCard) {
currentCard->setText(_annotation);
}
}

View file

@ -1,8 +1,8 @@
/**
* @file dlg_edit_tokens.h
* @ingroup GameDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_EDIT_TOKENS_H
#define DLG_EDIT_TOKENS_H

View file

@ -26,8 +26,9 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, QString country, QStrin
int i = 1;
for (const QString &c : countries) {
countryEdit->addItem(QPixmap("theme:countries/" + c.toLower()), c);
if (c == country)
if (c == country) {
countryEdit->setCurrentIndex(i);
}
++i;
}

View file

@ -1,8 +1,8 @@
/**
* @file dlg_edit user.h
* @ingroup NetworkDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_EDITUSER_H
#define DLG_EDITUSER_H

View file

@ -87,8 +87,9 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
if (!allGameTypes.isEmpty()) {
gameTypeFilterGroupBox = new QGroupBox(tr("&Game types"));
gameTypeFilterGroupBox->setLayout(gameTypeFilterLayout);
} else
} else {
gameTypeFilterGroupBox = nullptr;
}
auto *maxPlayersFilterMinLabel = new QLabel(tr("at &least:"));
maxPlayersFilterMinSpinBox = new QSpinBox;
@ -226,8 +227,9 @@ QSet<int> DlgFilterGames::getGameTypeFilter() const
QMapIterator<int, QCheckBox *> i(gameTypeFilterCheckBoxes);
while (i.hasNext()) {
i.next();
if (i.value()->isChecked())
if (i.value()->isChecked()) {
result.insert(i.key());
}
}
return result;
}

View file

@ -1,8 +1,8 @@
/**
* @file dlg_filter_games.h
* @ingroup RoomDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_FILTER_GAMES_H
#define DLG_FILTER_GAMES_H

View file

@ -1,8 +1,8 @@
/**
* @file dlg_forgot_password_challenge.h
* @ingroup AccountDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_FORGOTPASSWORDCHALLENGE_H
#define DLG_FORGOTPASSWORDCHALLENGE_H

View file

@ -1,8 +1,8 @@
/**
* @file dlg_forgot_password_request.h
* @ingroup AccountDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_FORGOTPASSWORDREQUEST_H
#define DLG_FORGOTPASSWORDREQUEST_H

View file

@ -121,7 +121,7 @@ void DlgForgotPasswordReset::actOk()
return;
}
//! \todo this stuff should be using qvalidators
//! \todo This stuff should be using QValidators.
if (newpasswordEdit->text().length() < 8) {
QMessageBox::critical(this, tr("Error"), tr("Your password is too short."));
return;

View file

@ -1,8 +1,8 @@
/**
* @file dlg_forgot_password_reset.h
* @ingroup AccountDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_FORGOTPASSWORDRESET_H
#define DLG_FORGOTPASSWORDRESET_H

View file

@ -2,8 +2,8 @@
* @file dlg_load_deck.h
* @ingroup LocalDeckStorageDialogs
* @ingroup Lobby
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_LOAD_DECK_H
#define DLG_LOAD_DECK_H

View file

@ -2,8 +2,8 @@
* @file dlg_load_deck_from_clipboard.h
* @ingroup LocalDeckStorageDialogs
* @ingroup Lobby
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_LOAD_DECK_FROM_CLIPBOARD_H
#define DLG_LOAD_DECK_FROM_CLIPBOARD_H

View file

@ -2,8 +2,8 @@
* @file dlg_load_deck_from_website.h
* @ingroup RemoteDeckStorageDialogs
* @ingroup Lobby
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_LOAD_DECK_FROM_WEBSITE_H
#define DLG_LOAD_DECK_FROM_WEBSITE_H

View file

@ -2,8 +2,8 @@
* @file dlg_load_remote_deck.h
* @ingroup RemoteDeckStorageDialogs
* @ingroup Lobby
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_STARTGAME_H
#define DLG_STARTGAME_H

View file

@ -217,8 +217,9 @@ void WndSets::saveHeaderState()
void WndSets::rebuildMainLayout(int actionToTake)
{
if (mainLayout == nullptr)
if (mainLayout == nullptr) {
return;
}
switch (actionToTake) {
case NO_SETS_SELECTED:
@ -382,12 +383,14 @@ void WndSets::actUp()
std::sort(rows.begin(), rows.end(), std::less<QModelIndex>());
QSet<int> newRows;
if (rows.empty())
if (rows.empty()) {
return;
}
for (auto i : rows) {
if (i.row() <= 0)
if (i.row() <= 0) {
continue;
}
int oldRow = displayModel->mapToSource(i).row();
int newRow = i.row() - 1;
@ -405,12 +408,14 @@ void WndSets::actDown()
std::sort(rows.begin(), rows.end(), [](const QModelIndex &a, const QModelIndex &b) { return b < a; });
QSet<int> newRows;
if (rows.empty())
if (rows.empty()) {
return;
}
for (auto i : rows) {
if (i.row() >= displayModel->rowCount() - 1)
if (i.row() >= displayModel->rowCount() - 1) {
continue;
}
int oldRow = displayModel->mapToSource(i).row();
int newRow = i.row() + 1;
@ -428,8 +433,9 @@ void WndSets::actTop()
QSet<int> newRows;
int newRow = 0;
if (rows.empty())
if (rows.empty()) {
return;
}
for (int i = 0; i < rows.length(); i++) {
int oldRow = displayModel->mapToSource(rows.at(i)).row();
@ -454,8 +460,9 @@ void WndSets::actBottom()
QSet<int> newRows;
int newRow = model->rowCount() - 1;
if (rows.empty())
if (rows.empty()) {
return;
}
for (int i = 0; i < rows.length(); i++) {
int oldRow = displayModel->mapToSource(rows.at(i)).row();

View file

@ -1,8 +1,8 @@
/**
* @file dlg_manage_sets.h
* @ingroup Dialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_MANAGE_SETS_H
#define DLG_MANAGE_SETS_H

View file

@ -311,8 +311,9 @@ DlgRegister::DlgRegister(QWidget *parent) : QDialog(parent)
countryEdit->addItem(QPixmap("theme:countries/zw"), "zw");
countryEdit->setCurrentIndex(0);
QStringList countries = SettingsCache::instance().getCountries();
for (const QString &c : countries)
for (const QString &c : countries) {
countryEdit->addItem(QPixmap("theme:countries/" + c.toLower()), c);
}
realnameLabel = new QLabel(tr("Real name:"));
realnameEdit = new QLineEdit();
@ -356,7 +357,7 @@ DlgRegister::DlgRegister(QWidget *parent) : QDialog(parent)
void DlgRegister::actOk()
{
//! \todo this stuff should be using qvalidators
//! \todo This stuff should be using QValidators.
if (passwordEdit->text().length() < 8) {
QMessageBox::critical(this, tr("Registration Warning"), tr("Your password is too short."));
return;

View file

@ -1,8 +1,8 @@
/**
* @file dlg_register.h
* @ingroup AccountDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_REGISTER_H
#define DLG_REGISTER_H

View file

@ -237,8 +237,9 @@ QMap<QString, int> DlgSelectSetForCards::getSetsForCards()
for (auto cardName : cardNames) {
CardInfoPtr infoPtr = CardDatabaseManager::query()->getCardInfo(cardName);
if (!infoPtr)
if (!infoPtr) {
continue;
}
SetToPrintingsMap setMap = infoPtr->getSets();
for (auto &setName : setMap.keys()) {
@ -355,8 +356,9 @@ QMap<QString, QStringList> DlgSelectSetForCards::getCardsForSets()
for (auto cardName : cardNames) {
CardInfoPtr infoPtr = CardDatabaseManager::query()->getCardInfo(cardName);
if (!infoPtr)
if (!infoPtr) {
continue;
}
SetToPrintingsMap setMap = infoPtr->getSets();
for (auto it = setMap.begin(); it != setMap.end(); ++it) {

View file

@ -1,8 +1,8 @@
/**
* @file dlg_select_set_for_cards.h
* @ingroup Dialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_SELECT_SET_FOR_CARDS_H
#define DLG_SELECT_SET_FOR_CARDS_H

File diff suppressed because it is too large Load diff

View file

@ -1,343 +1,21 @@
/**
* @file dlg_settings.h
* @ingroup Dialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_SETTINGS_H
#define DLG_SETTINGS_H
#include <QCheckBox>
#include <QComboBox>
#include <QDialog>
#include <QGroupBox>
#include <QLabel>
#include <QLoggingCategory>
#include <QPushButton>
#include <QSpinBox>
#include <libcockatrice/utility/macros.h>
inline Q_LOGGING_CATEGORY(DlgSettingsLog, "dlg_settings");
class ShortcutTreeView;
class SearchLineEdit;
class QTreeView;
class QStandardItemModel;
class CardDatabase;
class QCloseEvent;
class QGridLayout;
class QHBoxLayout;
class QLineEdit;
class QListWidget;
class QListWidgetItem;
class QRadioButton;
class QSlider;
class QStackedWidget;
class QVBoxLayout;
class SequenceEdit;
class AbstractSettingsPage : public QWidget
{
public:
virtual void retranslateUi() = 0;
};
class GeneralSettingsPage : public AbstractSettingsPage
{
Q_OBJECT
public:
GeneralSettingsPage();
void retranslateUi() override;
private slots:
void deckPathButtonClicked();
void filtersPathButtonClicked();
void replaysPathButtonClicked();
void picsPathButtonClicked();
void cardDatabasePathButtonClicked();
void customCardDatabaseButtonClicked();
void tokenDatabasePathButtonClicked();
void resetAllPathsClicked();
void languageBoxChanged(int index);
private:
QStringList findQmFiles();
QString languageName(const QString &lang);
QLineEdit *deckPathEdit;
QLineEdit *filtersPathEdit;
QLineEdit *replaysPathEdit;
QLineEdit *picsPathEdit;
QLineEdit *cardDatabasePathEdit;
QLineEdit *customCardDatabasePathEdit;
QLineEdit *tokenDatabasePathEdit;
QPushButton *resetAllPathsButton;
QLabel *allPathsResetLabel;
QGroupBox *personalGroupBox;
QGroupBox *pathsGroupBox;
QComboBox languageBox;
QCheckBox startupUpdateCheckCheckBox;
QLabel startupCardUpdateCheckBehaviorLabel;
QComboBox startupCardUpdateCheckBehaviorSelector;
QLabel cardUpdateCheckIntervalLabel;
QSpinBox cardUpdateCheckIntervalSpinBox;
QLabel lastCardUpdateCheckDateLabel;
QCheckBox updateNotificationCheckBox;
QCheckBox newVersionOracleCheckBox;
QComboBox updateReleaseChannelBox;
QLabel languageLabel;
QLabel deckPathLabel;
QLabel filtersPathLabel;
QLabel replaysPathLabel;
QLabel picsPathLabel;
QLabel cardDatabasePathLabel;
QLabel customCardDatabasePathLabel;
QLabel tokenDatabasePathLabel;
QLabel updateReleaseChannelLabel;
QLabel advertiseTranslationPageLabel;
QCheckBox showTipsOnStartup;
};
class AppearanceSettingsPage : public AbstractSettingsPage
{
Q_OBJECT
private slots:
void themeBoxChanged(int index);
void openThemeLocation();
void updateHomeTabSettingsVisibility();
void showShortcutsChanged(QT_STATE_CHANGED_T enabled);
void overrideAllCardArtWithPersonalPreferenceToggled(QT_STATE_CHANGED_T enabled);
void cardViewInitialRowsMaxChanged(int value);
void cardViewExpandedRowsMaxChanged(int value);
private:
QLabel themeLabel;
QComboBox themeBox;
QPushButton openThemeButton;
QLabel homeTabBackgroundSourceLabel;
QComboBox homeTabBackgroundSourceBox;
QLabel homeTabBackgroundShuffleFrequencyLabel;
QSpinBox homeTabBackgroundShuffleFrequencySpinBox;
QLabel homeTabDisplayCardNameLabel;
QCheckBox homeTabDisplayCardNameCheckBox;
QLabel minPlayersForMultiColumnLayoutLabel;
QLabel maxFontSizeForCardsLabel;
QCheckBox showShortcutsCheckBox;
QCheckBox showGameSelectorFilterToolbarCheckBox;
QCheckBox displayCardNamesCheckBox;
QCheckBox autoRotateSidewaysLayoutCardsCheckBox;
QCheckBox overrideAllCardArtWithPersonalPreferenceCheckBox;
QCheckBox bumpSetsWithCardsInDeckToTopCheckBox;
QCheckBox cardScalingCheckBox;
QCheckBox roundCardCornersCheckBox;
QLabel verticalCardOverlapPercentLabel;
QSpinBox verticalCardOverlapPercentBox;
QLabel cardViewInitialRowsMaxLabel;
QSpinBox cardViewInitialRowsMaxBox;
QLabel cardViewExpandedRowsMaxLabel;
QSpinBox cardViewExpandedRowsMaxBox;
QCheckBox horizontalHandCheckBox;
QCheckBox leftJustifiedHandCheckBox;
QCheckBox invertVerticalCoordinateCheckBox;
QGroupBox *themeGroupBox;
QGroupBox *menuGroupBox;
QGroupBox *cardsGroupBox;
QGroupBox *handGroupBox;
QGroupBox *tableGroupBox;
QGroupBox *cardCountersGroupBox;
QList<QLabel *> cardCounterNames;
QSpinBox minPlayersForMultiColumnLayoutEdit;
QSpinBox maxFontSizeForCardsEdit;
public:
AppearanceSettingsPage();
void retranslateUi() override;
};
class UserInterfaceSettingsPage : public AbstractSettingsPage
{
Q_OBJECT
private slots:
void setNotificationEnabled(QT_STATE_CHANGED_T);
private:
QCheckBox notificationsEnabledCheckBox;
QCheckBox specNotificationsEnabledCheckBox;
QCheckBox buddyConnectNotificationsEnabledCheckBox;
QCheckBox doubleClickToPlayCheckBox;
QCheckBox clickPlaysAllSelectedCheckBox;
QCheckBox playToStackCheckBox;
QCheckBox doNotDeleteArrowsInSubPhasesCheckBox;
QCheckBox closeEmptyCardViewCheckBox;
QCheckBox focusCardViewSearchBarCheckBox;
QCheckBox annotateTokensCheckBox;
QCheckBox showDragSelectionCountCheckBox;
QCheckBox showTotalSelectionCountCheckBox;
QCheckBox useTearOffMenusCheckBox;
QCheckBox tapAnimationCheckBox;
QCheckBox openDeckInNewTabCheckBox;
QLabel visualDeckStoragePromptForConversionLabel;
QComboBox visualDeckStoragePromptForConversionSelector;
QCheckBox visualDeckStorageInGameCheckBox;
QCheckBox visualDeckStorageSelectionAnimationCheckBox;
QLabel defaultDeckEditorTypeLabel;
QComboBox defaultDeckEditorTypeSelector;
QLabel rewindBufferingMsLabel;
QSpinBox rewindBufferingMsBox;
QGroupBox *generalGroupBox;
QGroupBox *notificationsGroupBox;
QGroupBox *animationGroupBox;
QGroupBox *deckEditorGroupBox;
QGroupBox *replayGroupBox;
public:
UserInterfaceSettingsPage();
void retranslateUi() override;
};
class DeckEditorSettingsPage : public AbstractSettingsPage
{
Q_OBJECT
public:
DeckEditorSettingsPage();
void retranslateUi() override;
QString getLastUpdateTime();
private slots:
void storeSettings();
void urlListChanged(const QModelIndex &, int, int, const QModelIndex &, int);
void setSpoilersEnabled(bool);
void spoilerPathButtonClicked();
void updateSpoilers();
void unlockSettings();
void actAddURL();
void actRemoveURL();
void actEditURL();
void clearDownloadedPicsButtonClicked();
void resetDownloadedURLsButtonClicked();
private:
QPushButton clearDownloadedPicsButton;
QPushButton resetDownloadURLs;
QLabel urlLinkLabel;
QCheckBox picDownloadCheckBox;
QListWidget *urlList;
QAction *aAdd, *aEdit, *aRemove;
QCheckBox mcDownloadSpoilersCheckBox;
QLabel msDownloadSpoilersLabel;
QGroupBox *mpGeneralGroupBox;
QGroupBox *mpSpoilerGroupBox;
QLineEdit *mpSpoilerSavePathLineEdit;
QLabel mcSpoilerSaveLabel;
QLabel lastUpdatedLabel;
QLabel infoOnSpoilersLabel;
QPushButton *mpSpoilerPathButton;
QPushButton *updateNowButton;
QLabel networkCacheLabel;
QSpinBox networkCacheEdit;
QLabel networkRedirectCacheTtlLabel;
QSpinBox networkRedirectCacheTtlEdit;
QSpinBox pixmapCacheEdit;
QLabel pixmapCacheLabel;
};
class MessagesSettingsPage : public AbstractSettingsPage
{
Q_OBJECT
public:
MessagesSettingsPage();
void retranslateUi() override;
private slots:
void actAdd();
void actEdit();
void actRemove();
void updateColor(const QString &value);
void updateHighlightColor(const QString &value);
void updateTextColor(QT_STATE_CHANGED_T value);
void updateTextHighlightColor(QT_STATE_CHANGED_T value);
private:
QListWidget *messageList;
QAction *aAdd;
QAction *aEdit;
QAction *aRemove;
QCheckBox chatMentionCheckBox;
QCheckBox chatMentionCompleterCheckbox;
QCheckBox invertMentionForeground;
QCheckBox invertHighlightForeground;
QCheckBox ignoreUnregUsersMainChat;
QCheckBox ignoreUnregUserMessages;
QCheckBox messagePopups;
QCheckBox mentionPopups;
QCheckBox roomHistory;
QGroupBox *chatGroupBox;
QGroupBox *highlightGroupBox;
QGroupBox *messageGroupBox;
QLineEdit *mentionColor;
QLineEdit *highlightColor;
QLineEdit *customAlertString;
QLabel hexLabel;
QLabel hexHighlightLabel;
QLabel customAlertStringLabel;
QLabel explainMessagesLabel;
void storeSettings();
void updateMentionPreview();
void updateHighlightPreview();
};
class SoundSettingsPage : public AbstractSettingsPage
{
Q_OBJECT
public:
SoundSettingsPage();
void retranslateUi() override;
private:
QLabel themeLabel;
QComboBox themeBox;
QGroupBox *soundGroupBox;
QPushButton soundTestButton;
QCheckBox soundEnabledCheckBox;
QLabel masterVolumeLabel;
QSlider *masterVolumeSlider;
QSpinBox *masterVolumeSpinBox;
private slots:
void masterVolumeChanged(int value);
void themeBoxChanged(int index);
};
class ShortcutSettingsPage : public AbstractSettingsPage
{
Q_OBJECT
public:
ShortcutSettingsPage();
void retranslateUi() override;
private:
SearchLineEdit *searchEdit;
ShortcutTreeView *shortcutsTable;
QVBoxLayout *mainLayout;
QHBoxLayout *buttonsLayout;
QGroupBox *editShortcutGroupBox;
QGridLayout *editLayout;
QLabel *currentActionGroupLabel;
QLabel *currentActionGroupName;
QLabel *currentActionLabel;
QLabel *currentActionName;
QLabel *currentShortcutLabel;
SequenceEdit *editTextBox;
QLabel *faqLabel;
QPushButton *btnResetAll;
QPushButton *btnClearAll;
private slots:
void resetShortcuts();
void clearShortcuts();
void currentItemChanged(const QString &key);
};
class QListWidgetItem;
class DlgSettings : public QDialog
{
@ -353,8 +31,8 @@ private slots:
private:
QListWidget *contentsWidget;
QStackedWidget *pagesWidget;
QListWidgetItem *generalButton, *appearanceButton, *userInterfaceButton, *deckEditorButton, *messagesButton,
*soundButton, *shortcutsButton;
QListWidgetItem *generalButton, *appearanceButton, *userInterfaceButton, *deckEditorButton, *storageButton,
*messagesButton, *soundButton, *shortcutsButton;
void createIcons();
void retranslateUi();

View file

@ -1,8 +1,8 @@
/**
* @file dlg_startup_card_check.h
* @ingroup CardDatabaseUpdateDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_STARTUP_CARD_CHECK_H
#define DLG_STARTUP_CARD_CHECK_H

View file

@ -1,8 +1,8 @@
/**
* @file dlg_tip_of_the_day.h
* @ingroup Dialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_TIPOFDAY_H
#define DLG_TIPOFDAY_H

View file

@ -40,7 +40,7 @@ DlgUpdate::DlgUpdate(QWidget *parent) : QDialog(parent)
buttonBox->addButton(ok, QDialogButtonBox::AcceptRole);
connect(gotoDownload, &QPushButton::clicked, this, &DlgUpdate::gotoDownloadPage);
// TODO: make reinstall button actually do something when clicked
//! \todo Make reinstall button actually do something when clicked.
// connect(manualDownload, &QPushButton::clicked, this, &DlgUpdate::downloadUpdate);
connect(stopDownload, &QPushButton::clicked, this, &DlgUpdate::cancelDownload);
connect(ok, &QPushButton::clicked, this, &DlgUpdate::closeDialog);
@ -154,8 +154,9 @@ void DlgUpdate::finishedUpdateCheck(bool needToUpdate, bool isCompatible, Releas
"</a>)<br><br>" + tr("Do you want to update now?"),
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes)
if (reply == QMessageBox::Yes) {
downloadUpdate(release->getName());
}
} else {
QMessageBox::information(
this, tr("Update Available"),

View file

@ -1,8 +1,8 @@
/**
* @file dlg_update.h
* @ingroup ClientUpdateDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_UPDATE_H
#define DLG_UPDATE_H

View file

@ -60,8 +60,9 @@ void DlgViewLog::actCopyToClipboard()
void DlgViewLog::loadInitialLogBuffer()
{
QList<QString> logBuffer = Logger::getInstance().getLogBuffer();
for (const QString &message : logBuffer)
for (const QString &message : logBuffer) {
appendLogEntry(message);
}
}
void DlgViewLog::appendLogEntry(const QString &message)

View file

@ -1,8 +1,8 @@
/**
* @file dlg_view_log.h
* @ingroup ServerLogDialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DLG_VIEWLOG_H
#define DLG_VIEWLOG_H

View file

@ -73,8 +73,9 @@ TipsOfTheDay::~TipsOfTheDay()
QVariant TipsOfTheDay::data(const QModelIndex &index, int /*role*/) const
{
if (!index.isValid() || index.row() >= tipList->size() || index.column() >= TIPDDBMODEL_COLUMNS)
if (!index.isValid() || index.row() >= tipList->size() || index.column() >= TIPDDBMODEL_COLUMNS) {
return QVariant();
}
TipOfTheDay tip = tipList->at(index.row());
switch (index.column()) {

View file

@ -1,8 +1,8 @@
/**
* @file tip_of_the_day.h
* @ingroup Dialogs
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef TIP_OF_DAY_H
#define TIP_OF_DAY_H

View file

@ -1,8 +1,8 @@
/**
* @file background_sources.h
* @ingroup UI
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef COCKATRICE_BACKGROUND_SOURCES_H
#define COCKATRICE_BACKGROUND_SOURCES_H
@ -40,8 +40,9 @@ public:
static QString toId(Type type)
{
for (const auto &e : all()) {
if (e.type == type)
if (e.type == type) {
return e.id;
}
}
return {};
}
@ -49,8 +50,9 @@ public:
static Type fromId(const QString &id)
{
for (const auto &e : all()) {
if (id == e.id)
if (id == e.id) {
return e.type;
}
}
return Theme; // default
}
@ -58,8 +60,9 @@ public:
static QString toDisplay(Type type)
{
for (const auto &e : all()) {
if (e.type == type)
if (e.type == type) {
return QObject::tr(e.trKey);
}
}
return {};
}

View file

@ -3,8 +3,8 @@
* @ingroup Widgets
* @ingroup DeckEditorCardGroupWidgets
* @ingroup DeckStorageWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef BANNER_WIDGET_H
#define BANNER_WIDGET_H

View file

@ -52,8 +52,9 @@ void BarChartWidget::paintEvent(QPaintEvent *)
int barAreaWidth = right - left;
int barCount = bars.size();
if (barCount == 0)
if (barCount == 0) {
return;
}
int spacing = 6;
int barWidth = (barAreaWidth - (barCount - 1) * spacing) / barCount;
@ -91,8 +92,9 @@ void BarChartWidget::paintEvent(QPaintEvent *)
for (int j = 0; j < bar.segments.size(); j++) {
const auto &seg = bar.segments[j];
int segHeight = (seg.value * barAreaHeight / highest);
if (segHeight < 2 && seg.value > 0)
if (segHeight < 2 && seg.value > 0) {
segHeight = 2;
}
int topY = yCurrent - segHeight;
@ -189,8 +191,9 @@ void BarChartWidget::mouseMoveEvent(QMouseEvent *e)
for (int i = 0; i < segments.size(); i++) {
const auto &seg = segments[i];
int segHeight = (seg.value * barAreaHeight / highest);
if (segHeight < 2 && seg.value > 0)
if (segHeight < 2 && seg.value > 0) {
segHeight = 2;
}
int topY = yCurrent - segHeight;
int bottomY = yCurrent;

View file

@ -2,8 +2,8 @@
* @file bar_widget.h
* @ingroup Widgets
* @ingroup DeckEditorAnalyticsWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef BAR_WIDGET_H
#define BAR_WIDGET_H

View file

@ -26,16 +26,19 @@ QSize ColorBar::minimumSizeHint() const
void ColorBar::paintEvent(QPaintEvent *)
{
if (colors.isEmpty())
if (colors.isEmpty()) {
return;
}
int total = 0;
for (const auto &pair : colors)
for (const auto &pair : colors) {
total += pair.second;
}
// Prevent divide-by-zero
if (total == 0)
if (total == 0) {
return;
}
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing, true);
@ -63,8 +66,9 @@ void ColorBar::paintEvent(QPaintEvent *)
int segmentWidth = int(ratio * w);
// Ensure the segment width is at least 1 to avoid degenerate rectangles
if (segmentWidth < 1)
if (segmentWidth < 1) {
segmentWidth = 1;
}
QColor base = colorFromName(key);
@ -92,25 +96,29 @@ void ColorBar::leaveEvent(QEvent *)
void ColorBar::mouseMoveEvent(QMouseEvent *event)
{
if (!isHovered || colors.isEmpty())
if (!isHovered || colors.isEmpty()) {
return;
}
int x = int(event->position().x());
QPoint gp = event->globalPosition().toPoint();
QString text = tooltipForPosition(x);
if (!text.isEmpty())
if (!text.isEmpty()) {
QToolTip::showText(gp, text, this);
}
}
QString ColorBar::tooltipForPosition(int x) const
{
int total = 0;
for (const auto &pair : colors)
for (const auto &pair : colors) {
total += pair.second;
}
if (total == 0)
if (total == 0) {
return {};
}
int pos = 0;
@ -136,12 +144,14 @@ QColor ColorBar::colorFromName(const QString &name) const
{"W", QColor(235, 235, 230)}, {"B", QColor(30, 30, 30)},
};
if (map.contains(name))
if (map.contains(name)) {
return map[name];
}
QColor c(name);
if (!c.isValid())
if (!c.isValid()) {
c = Qt::gray;
}
return c;
}

View file

@ -92,13 +92,13 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override;
private:
/// Map of color keys to counts used for rendering.
/** @brief Map of color keys to counts used for rendering. */
QList<QPair<QString, int>> colors;
/// True if the mouse is currently inside the widget.
/** @brief True if the mouse is currently inside the widget. */
bool isHovered = false;
/// Minimum ratio a segment must exceed to be drawn.
/** @brief Minimum ratio a segment must exceed to be drawn. */
double minRatioThreshold = 0.0;
/**

View file

@ -2,8 +2,8 @@
* @file percent_bar_widget.h
* @ingroup Widgets
* @ingroup DeckEditorAnalyticsWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef PERCENT_BAR_WIDGET_H
#define PERCENT_BAR_WIDGET_H

View file

@ -44,8 +44,9 @@ void SegmentedBarWidget::paintEvent(QPaintEvent *)
const auto &seg = segments[i];
int segHeight = total > 0 ? (seg.value * barHeight / total) : 0;
if (segHeight < 2)
if (segHeight < 2) {
segHeight = 2;
}
QRect r(barX, yCurrent - segHeight, barWidth, segHeight);
bool isTop = (i == segments.size() - 1);
@ -110,8 +111,9 @@ int SegmentedBarWidget::segmentAt(int y) const
int top = currentTop - segHeight;
int bottom = currentTop;
if (y >= top && y <= bottom)
if (y >= top && y <= bottom) {
return i;
}
currentTop -= segHeight;
}

View file

@ -142,8 +142,9 @@ QString ColorPie::tooltipForPoint(const QPoint &pt) const
QPointF v = pt - center;
double distance = std::hypot(v.x(), v.y());
if (distance > size / 2.0)
if (distance > size / 2.0) {
return {};
}
double angle = std::atan2(-v.y(), v.x()) * 180.0 / M_PI;
if (angle < 0) {

View file

@ -1,8 +1,8 @@
/**
* @file dynamic_font_size_label.h
* @ingroup Widgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DYNAMICFONTSIZELABEL_H
#define DYNAMICFONTSIZELABEL_H

View file

@ -1,8 +1,8 @@
/**
* @file dynamic_font_size_push_button.h
* @ingroup PrintingWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef DYNAMICFONTSIZEPUSHBUTTON_H
#define DYNAMICFONTSIZEPUSHBUTTON_H

View file

@ -1,8 +1,8 @@
/**
* @file labeled_input.h
* @ingroup DeckEditorCardGroupWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef LABELED_INPUT_H
#define LABELED_INPUT_H

View file

@ -1,8 +1,8 @@
/**
* @file shadow_background_label.h
* @ingroup PrintingWidgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef STYLEDLABEL_H
#define STYLEDLABEL_H

View file

@ -1,8 +1,8 @@
/**
* @file home_styled_button.h
* @ingroup Widgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef HOME_STYLED_BUTTON_H
#define HOME_STYLED_BUTTON_H

View file

@ -139,8 +139,9 @@ void HomeWidget::updateRandomCard()
}
break;
}
if (!newCard)
if (!newCard) {
return;
}
connect(newCard.getCardPtr().data(), &CardInfo::pixmapUpdated, this, &HomeWidget::updateBackgroundProperties);
backgroundSourceCard->setCard(newCard);

View file

@ -2,8 +2,8 @@
* @file home_widget.h
* @ingroup Core
* @ingroup Widgets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef HOME_WIDGET_H
#define HOME_WIDGET_H

Some files were not shown because too many files have changed in this diff Show more