mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 16:32:20 -07:00
Compare commits
3 commits
7de41be2a9
...
1cda4220b3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1cda4220b3 | ||
|
|
2acef566e5 | ||
|
|
124990239c |
10 changed files with 59 additions and 129 deletions
2
.github/workflows/codeql.yml
vendored
2
.github/workflows/codeql.yml
vendored
|
|
@ -40,7 +40,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout repository"
|
- name: "Checkout repository"
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Initialize CodeQL"
|
- name: "Initialize CodeQL"
|
||||||
uses: github/codeql-action/init@v4
|
uses: github/codeql-action/init@v4
|
||||||
|
|
|
||||||
2
.github/workflows/docker-release.yml
vendored
2
.github/workflows/docker-release.yml
vendored
|
|
@ -127,7 +127,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Download digests"
|
- name: "Download digests"
|
||||||
uses: actions/download-artifact@v8
|
uses: actions/download-artifact@v7
|
||||||
with:
|
with:
|
||||||
path: ${{ runner.temp }}/digests
|
path: ${{ runner.temp }}/digests
|
||||||
pattern: digest-*
|
pattern: digest-*
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,9 @@
|
||||||
#include "dlg_convert_deck_to_cod_format.h"
|
#include "dlg_convert_deck_to_cod_format.h"
|
||||||
|
|
||||||
#include "../../../client/settings/cache_settings.h"
|
|
||||||
#include "../../deck_loader/deck_loader.h"
|
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QDir>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <libcockatrice/settings/visual_deck_storage_settings.h>
|
|
||||||
|
|
||||||
DialogConvertDeckToCodFormat::DialogConvertDeckToCodFormat(QWidget *parent) : QDialog(parent)
|
DialogConvertDeckToCodFormat::DialogConvertDeckToCodFormat(QWidget *parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
|
|
@ -46,71 +38,3 @@ bool DialogConvertDeckToCodFormat::dontAskAgain() const
|
||||||
{
|
{
|
||||||
return dontAskAgainCheckbox->isChecked();
|
return dontAskAgainCheckbox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
bool confirmOverwriteIfExists(QWidget *parent, const QString &filePath)
|
|
||||||
{
|
|
||||||
QFileInfo fileInfo(filePath);
|
|
||||||
QString newFileName = QDir::toNativeSeparators(fileInfo.path() + "/" + fileInfo.completeBaseName() + ".cod");
|
|
||||||
|
|
||||||
if (QFile::exists(newFileName)) {
|
|
||||||
QMessageBox::StandardButton reply =
|
|
||||||
QMessageBox::question(parent, QObject::tr("Overwrite Existing File?"),
|
|
||||||
QObject::tr("A .cod version of this deck already exists. Overwrite it?"),
|
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
|
||||||
return reply == QMessageBox::Yes;
|
|
||||||
}
|
|
||||||
return true; // Safe to proceed
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
bool DialogConvertDeckToCodFormat::promptIfRequired(QWidget *parent,
|
|
||||||
const QString &filePath,
|
|
||||||
const std::function<bool()> &convert)
|
|
||||||
{
|
|
||||||
if (DeckFileFormat::getFormatFromName(filePath) == DeckFileFormat::Cockatrice) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve saved preference if the prompt is disabled
|
|
||||||
if (!SettingsCache::instance().visualDeckStorage().getVisualDeckStoragePromptForConversion()) {
|
|
||||||
if (!SettingsCache::instance().visualDeckStorage().getVisualDeckStorageAlwaysConvert()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!confirmOverwriteIfExists(parent, filePath)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return convert();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show the dialog to the user
|
|
||||||
DialogConvertDeckToCodFormat conversionDialog(parent);
|
|
||||||
if (conversionDialog.exec() != QDialog::Accepted) {
|
|
||||||
SettingsCache::instance().visualDeckStorage().setVisualDeckStoragePromptForConversion(
|
|
||||||
!conversionDialog.dontAskAgain());
|
|
||||||
SettingsCache::instance().visualDeckStorage().setVisualDeckStorageAlwaysConvert(false);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to convert file
|
|
||||||
if (!confirmOverwriteIfExists(parent, filePath)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!convert()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conversionDialog.dontAskAgain()) {
|
|
||||||
SettingsCache::instance().visualDeckStorage().setVisualDeckStoragePromptForConversion(false);
|
|
||||||
SettingsCache::instance().visualDeckStorage().setVisualDeckStorageAlwaysConvert(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
class QWidget;
|
|
||||||
|
|
||||||
class DialogConvertDeckToCodFormat : public QDialog
|
class DialogConvertDeckToCodFormat : public QDialog
|
||||||
{
|
{
|
||||||
|
|
@ -27,21 +24,6 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] bool dontAskAgain() const;
|
[[nodiscard]] bool dontAskAgain() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Checks whether the deck file at \a filePath can store tags.
|
|
||||||
*
|
|
||||||
* If the file is not a .cod deck, prompts the user for conversion to the
|
|
||||||
* Cockatrice format, honoring the saved "always convert / don't ask again"
|
|
||||||
* preference. On acceptance \a convert is called to perform the conversion.
|
|
||||||
*
|
|
||||||
* @param parent The widget to parent the prompt to.
|
|
||||||
* @param filePath The path of the deck file to check.
|
|
||||||
* @param convert Called to convert the deck once the user agrees.
|
|
||||||
* @return true if tags can be stored (no conversion needed, or the conversion
|
|
||||||
* was performed), false if the user declined to convert.
|
|
||||||
*/
|
|
||||||
static bool promptIfRequired(QWidget *parent, const QString &filePath, const std::function<bool()> &convert);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVBoxLayout *layout;
|
QVBoxLayout *layout;
|
||||||
QLabel *label;
|
QLabel *label;
|
||||||
|
|
|
||||||
|
|
@ -530,13 +530,6 @@ void UserInfoPopup::rebuildActionButtons(const ServerInfo_User &userInfo, bool o
|
||||||
connect(games, &QPushButton::clicked, this, [this, name] { emit showGamesRequested(name); });
|
connect(games, &QPushButton::clicked, this, [this, name] { emit showGamesRequested(name); });
|
||||||
add(games);
|
add(games);
|
||||||
|
|
||||||
// ── Invite (only while the inviter has a joinable game for this user) ────
|
|
||||||
if (!isSelf && online && gameInviteAvailable && gameInviteAvailable(name)) {
|
|
||||||
auto *invite = makeBtn(tr("Invite"), tr("Invite to your game"), actionArea, theme);
|
|
||||||
connect(invite, &QPushButton::clicked, this, [this, name] { emit inviteRequested(name); });
|
|
||||||
add(invite);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Buddy / ignore (registered users only) ────────────────────────────────
|
// ── Buddy / ignore (registered users only) ────────────────────────────────
|
||||||
if (!isSelf && isReg) {
|
if (!isSelf && isReg) {
|
||||||
if (isBuddy) {
|
if (isBuddy) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <functional>
|
|
||||||
#include <libcockatrice/network/server/remote/user_level.h>
|
#include <libcockatrice/network/server/remote/user_level.h>
|
||||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/serverinfo_game.pb.h>
|
#include <libcockatrice/protocol/pb/serverinfo_game.pb.h>
|
||||||
|
|
@ -150,17 +149,6 @@ public:
|
||||||
/** Re-pulls the avatar/card art for the currently shown user (e.g. after it loads). */
|
/** Re-pulls the avatar/card art for the currently shown user (e.g. after it loads). */
|
||||||
void refreshHeader();
|
void refreshHeader();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a predicate evaluated on every action-button rebuild. It receives
|
|
||||||
* the name of the user the popup currently shows; when it returns true an
|
|
||||||
* "Invite" button is shown. The popup itself never resolves the invite
|
|
||||||
* link, it just forwards the request.
|
|
||||||
*/
|
|
||||||
void setGameInviteAvailable(std::function<bool(const QString &userName)> available)
|
|
||||||
{
|
|
||||||
gameInviteAvailable = std::move(available);
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void mouseEnteredPopup();
|
void mouseEnteredPopup();
|
||||||
void mouseLeftPopup();
|
void mouseLeftPopup();
|
||||||
|
|
@ -171,7 +159,6 @@ signals:
|
||||||
|
|
||||||
// ── Action signals — connect to UserContextMenu::exec*() ──────────────────
|
// ── Action signals — connect to UserContextMenu::exec*() ──────────────────
|
||||||
void chatRequested(const QString &userName);
|
void chatRequested(const QString &userName);
|
||||||
void inviteRequested(const QString &userName);
|
|
||||||
void detailsRequested(const QString &userName);
|
void detailsRequested(const QString &userName);
|
||||||
void showGamesRequested(const QString &userName);
|
void showGamesRequested(const QString &userName);
|
||||||
void addBuddyRequested(const QString &userName);
|
void addBuddyRequested(const QString &userName);
|
||||||
|
|
@ -213,7 +200,6 @@ private:
|
||||||
QString currentUser;
|
QString currentUser;
|
||||||
ServerInfo_User currentUserInfo;
|
ServerInfo_User currentUserInfo;
|
||||||
bool currentOnline = false;
|
bool currentOnline = false;
|
||||||
std::function<bool(const QString &userName)> gameInviteAvailable;
|
|
||||||
|
|
||||||
UserInfoHeaderWidget *header;
|
UserInfoHeaderWidget *header;
|
||||||
QWidget *actionArea; ///< rebuilt per user
|
QWidget *actionArea; ///< rebuilt per user
|
||||||
|
|
|
||||||
|
|
@ -347,11 +347,6 @@ UserListWidget::UserListWidget(TabSupervisor *_tabSupervisor,
|
||||||
&cardArtProvider->cache(), &cardArtParamsMap,
|
&cardArtProvider->cache(), &cardArtParamsMap,
|
||||||
window()); // parented to main window so it floats above siblings
|
window()); // parented to main window so it floats above siblings
|
||||||
|
|
||||||
// The invite availability is scoped to the room this list belongs to,
|
|
||||||
// and gated on the room's buddy-only setting for the hovered user.
|
|
||||||
userInfoPopup->setGameInviteAvailable(
|
|
||||||
[this](const QString &userName) { return userContextMenu->hasGameInviteLink(userName); });
|
|
||||||
|
|
||||||
userInfoPopup->hide();
|
userInfoPopup->hide();
|
||||||
userInfoPopup->setWindowOpacity(0.0);
|
userInfoPopup->setWindowOpacity(0.0);
|
||||||
userInfoPopup->installEventFilter(this);
|
userInfoPopup->installEventFilter(this);
|
||||||
|
|
@ -669,8 +664,6 @@ void UserListWidget::connectPopupSignals()
|
||||||
|
|
||||||
// Wire all action signals to UserContextMenu::exec*()
|
// Wire all action signals to UserContextMenu::exec*()
|
||||||
connect(userInfoPopup, &UserInfoPopup::chatRequested, userContextMenu, &UserContextMenu::execChat);
|
connect(userInfoPopup, &UserInfoPopup::chatRequested, userContextMenu, &UserContextMenu::execChat);
|
||||||
connect(userInfoPopup, &UserInfoPopup::inviteRequested, this,
|
|
||||||
[this](const QString &userName) { userContextMenu->execInvite(userName); });
|
|
||||||
connect(userInfoPopup, &UserInfoPopup::detailsRequested, userContextMenu, &UserContextMenu::execDetails);
|
connect(userInfoPopup, &UserInfoPopup::detailsRequested, userContextMenu, &UserContextMenu::execDetails);
|
||||||
connect(userInfoPopup, &UserInfoPopup::showGamesRequested, userContextMenu, &UserContextMenu::execShowGames);
|
connect(userInfoPopup, &UserInfoPopup::showGamesRequested, userContextMenu, &UserContextMenu::execShowGames);
|
||||||
connect(userInfoPopup, &UserInfoPopup::addBuddyRequested, userContextMenu, &UserContextMenu::execAddToBuddy);
|
connect(userInfoPopup, &UserInfoPopup::addBuddyRequested, userContextMenu, &UserContextMenu::execAddToBuddy);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <libcockatrice/network/server/remote/user_level.h>
|
|
||||||
#include <libcockatrice/protocol/pb/moderator_commands.pb.h>
|
#include <libcockatrice/protocol/pb/moderator_commands.pb.h>
|
||||||
|
|
||||||
class QTreeWidget;
|
class QTreeWidget;
|
||||||
|
|
|
||||||
|
|
@ -1139,8 +1139,7 @@ QList<GameInviteOption> TabSupervisor::getGameInviteLinksForRoom(int roomId) con
|
||||||
// The inviter may be in several games of the same room (hosting one and
|
// The inviter may be in several games of the same room (hosting one and
|
||||||
// spectating another, for example). Return every game so the caller can
|
// spectating another, for example). Return every game so the caller can
|
||||||
// let the user choose which one to invite to.
|
// let the user choose which one to invite to.
|
||||||
for (auto it = gameTabs.cbegin(); it != gameTabs.cend(); ++it) {
|
for (TabGame *tab : gameTabs) {
|
||||||
TabGame *tab = it.value();
|
|
||||||
GameMetaInfo *metaInfo = tab->getGame()->getGameMetaInfo();
|
GameMetaInfo *metaInfo = tab->getGame()->getGameMetaInfo();
|
||||||
if (metaInfo->proto().room_id() != roomId) {
|
if (metaInfo->proto().room_id() != roomId) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
#include "../visual_deck_storage_widget.h"
|
#include "../visual_deck_storage_widget.h"
|
||||||
#include "deck_preview_deck_tags_display_widget.h"
|
#include "deck_preview_deck_tags_display_widget.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
@ -497,6 +499,21 @@ void DeckPreviewWidget::actDeleteFile()
|
||||||
// The folder widget removes this preview once the row is gone.
|
// The folder widget removes this preview once the row is gone.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool confirmOverwriteIfExists(QWidget *parent, const QString &filePath)
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
QString newFileName = QDir::toNativeSeparators(fileInfo.path() + "/" + fileInfo.completeBaseName() + ".cod");
|
||||||
|
|
||||||
|
if (QFile::exists(newFileName)) {
|
||||||
|
QMessageBox::StandardButton reply =
|
||||||
|
QMessageBox::question(parent, QObject::tr("Overwrite Existing File?"),
|
||||||
|
QObject::tr("A .cod version of this deck already exists. Overwrite it?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
return reply == QMessageBox::Yes;
|
||||||
|
}
|
||||||
|
return true; // Safe to proceed
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the deck's file format supports tags.
|
* Checks if the deck's file format supports tags.
|
||||||
* If not, then prompt the user for file conversion.
|
* If not, then prompt the user for file conversion.
|
||||||
|
|
@ -504,8 +521,45 @@ void DeckPreviewWidget::actDeleteFile()
|
||||||
*/
|
*/
|
||||||
bool DeckPreviewWidget::promptFileConversionIfRequired()
|
bool DeckPreviewWidget::promptFileConversionIfRequired()
|
||||||
{
|
{
|
||||||
return DialogConvertDeckToCodFormat::promptIfRequired(this, filePath, [this] {
|
if (DeckFileFormat::getFormatFromName(filePath) == DeckFileFormat::Cockatrice) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve saved preference if the prompt is disabled
|
||||||
|
if (!SettingsCache::instance().visualDeckStorage().getVisualDeckStoragePromptForConversion()) {
|
||||||
|
if (!SettingsCache::instance().visualDeckStorage().getVisualDeckStorageAlwaysConvert()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!confirmOverwriteIfExists(this, filePath)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
model->convertToCockatriceFormat(row());
|
model->convertToCockatriceFormat(row());
|
||||||
return true;
|
return true;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// Show the dialog to the user
|
||||||
|
DialogConvertDeckToCodFormat conversionDialog(this);
|
||||||
|
if (conversionDialog.exec() != QDialog::Accepted) {
|
||||||
|
SettingsCache::instance().visualDeckStorage().setVisualDeckStoragePromptForConversion(
|
||||||
|
!conversionDialog.dontAskAgain());
|
||||||
|
SettingsCache::instance().visualDeckStorage().setVisualDeckStorageAlwaysConvert(false);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to convert file
|
||||||
|
if (!confirmOverwriteIfExists(this, filePath)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
model->convertToCockatriceFormat(row());
|
||||||
|
|
||||||
|
if (conversionDialog.dontAskAgain()) {
|
||||||
|
SettingsCache::instance().visualDeckStorage().setVisualDeckStoragePromptForConversion(false);
|
||||||
|
SettingsCache::instance().visualDeckStorage().setVisualDeckStorageAlwaysConvert(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue