mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-10-26 01:20:39 -05:00
[QtUtils] Adopt window fade, path, bold font and confirmation helpers (#7622)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include <libcockatrice/network/client/remote/remote_client.h>
|
||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||
#include <libcockatrice/settings/servers_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
class QWidget;
|
||||
@@ -300,9 +301,8 @@ void ConnectionController::onLoginError(int r,
|
||||
}
|
||||
|
||||
case Response::RespRegistrationRequired: {
|
||||
if (QMessageBox::question(dialogParent, tr("Error"),
|
||||
tr("This server requires user registration. Do you want to register now?"),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
if (QtUtils::confirm(dialogParent, tr("Error"),
|
||||
tr("This server requires user registration. Do you want to register now?"))) {
|
||||
registerToServer();
|
||||
}
|
||||
return; // don't re-prompt connect
|
||||
|
||||
@@ -442,9 +442,7 @@ void DeckViewContainer::readyStart()
|
||||
void DeckViewContainer::forceStart()
|
||||
{
|
||||
const auto msg = tr("Are you sure you want to force start?\nThis will kick all non-ready players from the game.");
|
||||
const auto res =
|
||||
QMessageBox::question(this, tr("Cockatrice"), msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (res == QMessageBox::No) {
|
||||
if (!QtUtils::confirm(this, tr("Cockatrice"), msg, QMessageBox::Yes)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <libcockatrice/protocol/pb/response_deck_share_list.pb.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_deck_share_item.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <optional>
|
||||
#include <qnamespace.h>
|
||||
#include <string>
|
||||
@@ -184,13 +185,11 @@ void IntentOpenSharedDeck::onItemFailure(const QString &reason)
|
||||
}
|
||||
|
||||
const int downloadedCount = loadedDecks.size();
|
||||
const QMessageBox::StandardButton answer = QMessageBox::question(
|
||||
previewDialog, tr("Open shared decks"),
|
||||
tr("Could not download the deck \"%1\".\n\n%n deck(s) were already downloaded. Open them?", "", downloadedCount)
|
||||
.arg(itemNames.value(currentItemId, tr("Unknown deck"))),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
|
||||
if (answer == QMessageBox::Yes) {
|
||||
if (QtUtils::confirm(previewDialog, tr("Open shared decks"),
|
||||
tr("Could not download the deck \"%1\".\n\n%n deck(s) were already downloaded. Open them?", "",
|
||||
downloadedCount)
|
||||
.arg(itemNames.value(currentItemId, tr("Unknown deck"))),
|
||||
QMessageBox::Yes)) {
|
||||
finishAll();
|
||||
} else {
|
||||
previewDialog->deleteLater();
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
||||
#include <libcockatrice/settings/servers_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <memory>
|
||||
#include <qlogging.h>
|
||||
#include <qnamespace.h>
|
||||
@@ -115,9 +116,7 @@ Intent *IntentUrlParser::createJoinGameIntent(const QUrlQuery &query, PendingInt
|
||||
const QString gameDescription = query.queryItemValue("game", QUrl::FullyDecoded);
|
||||
const QString message = generateJoinGameMessage(*ctx, gameDescription);
|
||||
|
||||
const QMessageBox::StandardButton answer = QMessageBox::question(
|
||||
mainWindow, tr("Join game"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (answer != QMessageBox::Yes) {
|
||||
if (!QtUtils::confirm(mainWindow, tr("Join game"), message, QMessageBox::Yes)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -231,11 +230,10 @@ Intent *IntentUrlParser::createOpenDeckIntent(const QUrlQuery &query, PendingInt
|
||||
if (client->getStatus() == StatusLoggedIn) {
|
||||
const QString current =
|
||||
QStringLiteral("%1:%2").arg(client->serverName(), QString::number(client->serverPort()));
|
||||
const QMessageBox::StandardButton answer = QMessageBox::question(
|
||||
mainWindow, tr("Open shared deck"),
|
||||
tr("Opening this share link connects you to %1 instead of %2.\n\nContinue?").arg(target, current),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (answer != QMessageBox::Yes) {
|
||||
if (!QtUtils::confirm(
|
||||
mainWindow, tr("Open shared deck"),
|
||||
tr("Opening this share link connects you to %1 instead of %2.\n\nContinue?").arg(target, current),
|
||||
QMessageBox::Yes)) {
|
||||
return nullptr;
|
||||
}
|
||||
chain.migrationTargetHost = ctx->serverContext.hostname;
|
||||
|
||||
@@ -102,9 +102,7 @@ void PaletteGridWidget::buildGrid(QWidget *host)
|
||||
auto *label = new QLabel(groupHeaders[col], host);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
label->setToolTip(groupTips[col]);
|
||||
QFont f = label->font();
|
||||
f.setBold(true);
|
||||
label->setFont(f);
|
||||
label->setFont(QtUtils::boldFont(label->font()));
|
||||
label->setAutoFillBackground(true);
|
||||
label->setContentsMargins(4, 4, 4, 4);
|
||||
grid->addWidget(label, 0, col + 1);
|
||||
@@ -149,9 +147,7 @@ void PaletteGridWidget::buildGrid(QWidget *host)
|
||||
|
||||
auto *appHeader = new QLabel(tr("App colors"), host);
|
||||
appHeader->setToolTip(tr("Application-specific colors layered on top of the Qt palette"));
|
||||
QFont appHeaderFont = appHeader->font();
|
||||
appHeaderFont.setBold(true);
|
||||
appHeader->setFont(appHeaderFont);
|
||||
appHeader->setFont(QtUtils::boldFont(appHeader->font()));
|
||||
appHeader->setAutoFillBackground(true);
|
||||
appHeader->setContentsMargins(4, 4, 4, 4);
|
||||
grid->addWidget(appHeader, appHeaderRow, 0, 1, 4);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <QObject>
|
||||
#include <QVBoxLayout>
|
||||
#include <libcockatrice/settings/visual_deck_storage_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
|
||||
DialogConvertDeckToCodFormat::DialogConvertDeckToCodFormat(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
@@ -57,11 +58,8 @@ bool confirmOverwriteIfExists(QWidget *parent, const QString &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 QtUtils::confirm(parent, QObject::tr("Overwrite Existing File?"),
|
||||
QObject::tr("A .cod version of this deck already exists. Overwrite it?"));
|
||||
}
|
||||
return true; // Safe to proceed
|
||||
}
|
||||
|
||||
@@ -128,12 +128,8 @@ void DlgReportUser::actSubmit()
|
||||
return;
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton reply =
|
||||
QMessageBox::question(this, tr("Confirm Report"),
|
||||
tr("Submit report against %1 for %2?").arg(reportedUser, categoryBox->currentText()),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (reply != QMessageBox::Yes) {
|
||||
if (!QtUtils::confirm(this, tr("Confirm Report"),
|
||||
tr("Submit report against %1 for %2?").arg(reportedUser, categoryBox->currentText()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <google/protobuf/repeated_ptr_field.h>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_deck_share_item.pb.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
class QWidget;
|
||||
@@ -34,8 +35,7 @@ DlgSharedDecksPreview::DlgSharedDecksPreview(QWidget *parent,
|
||||
// QLabels render AutoText and markup would otherwise be shown as rich text.
|
||||
auto *titleLabel =
|
||||
new QLabel(tr("Share: %1").arg((shareName.isEmpty() ? tr("Untitled") : shareName).toHtmlEscaped()), this);
|
||||
QFont titleFont = titleLabel->font();
|
||||
titleFont.setBold(true);
|
||||
QFont titleFont = QtUtils::boldFont(titleLabel->font());
|
||||
titleFont.setPointSize(titleFont.pointSize() + 2);
|
||||
titleLabel->setFont(titleFont);
|
||||
mainLayout->addWidget(titleLabel);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
#include <version_string.h>
|
||||
|
||||
@@ -170,16 +171,11 @@ void DlgUpdate::finishedUpdateCheck(bool needToUpdate, bool isCompatible, Releas
|
||||
|
||||
publishDate = release->getPublishDate().toString(QLocale().dateFormat(QLocale::LongFormat));
|
||||
if (isCompatible) {
|
||||
int reply;
|
||||
reply = QMessageBox::question(
|
||||
window(), tr("Update Available"),
|
||||
tr("A new version of Cockatrice is available!") + "<br><br>" + "<b>" + tr("New version") +
|
||||
QString(":</b> %1<br>").arg(release->getName()) + "<b>" + tr("Released") +
|
||||
QString(":</b> %1 (<a href=\"%2\">").arg(publishDate, release->getDescriptionUrl()) + tr("Changelog") +
|
||||
"</a>)<br><br>" + tr("Do you want to update now?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (reply == QMessageBox::Yes) {
|
||||
if (QtUtils::confirm(window(), tr("Update Available"),
|
||||
tr("A new version of Cockatrice is available!") + "<br><br>" + "<b>" + tr("New version") +
|
||||
QString(":</b> %1<br>").arg(release->getName()) + "<b>" + tr("Released") +
|
||||
QString(":</b> %1 (<a href=\"%2\">").arg(publishDate, release->getDescriptionUrl()) +
|
||||
tr("Changelog") + "</a>)<br><br>" + tr("Do you want to update now?"))) {
|
||||
downloadUpdate(release->getName());
|
||||
} else {
|
||||
closeDialog();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <libcockatrice/settings/cards_display_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
|
||||
class QWidget;
|
||||
|
||||
@@ -30,10 +31,7 @@ bool OverridePrintingWarning::execMessageBox(QWidget *parent, bool enable)
|
||||
"Are you sure you would like to disable this feature?");
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton result =
|
||||
QMessageBox::question(parent, QObject::tr("Confirm Change"), message, QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (result == QMessageBox::Yes) {
|
||||
if (QtUtils::confirm(parent, QObject::tr("Confirm Change"), message)) {
|
||||
SettingsCache::instance().cardsDisplay().setOverrideAllCardArtWithPersonalPreference(enable);
|
||||
// Caches are now invalid.
|
||||
CardPictureLoader::clearPixmapCache();
|
||||
|
||||
@@ -32,9 +32,8 @@ FirstRunWizard::FirstRunWizard(QWidget *parent) : QDialog(parent)
|
||||
bannerHost = new BannerHost(this);
|
||||
|
||||
titleLabel = new QLabel(this);
|
||||
QFont titleFont = titleLabel->font();
|
||||
QFont titleFont = QtUtils::boldFont(titleLabel->font());
|
||||
titleFont.setPointSizeF(titleFont.pointSizeF() * 1.4);
|
||||
titleFont.setBold(true);
|
||||
titleLabel->setFont(titleFont);
|
||||
|
||||
subtitleLabel = new QLabel(this);
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <libcockatrice/protocol/pb/serverinfo_game.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/settings/interface_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qlogging.h>
|
||||
#include <qnamespace.h>
|
||||
#include <string>
|
||||
@@ -420,10 +421,8 @@ void GameSelector::joinGame(const ServerInfo_Game &game, const bool asSpectator,
|
||||
// spectator join, so ask first instead of surprising the player.
|
||||
const bool gameFull = game.player_count() == game.max_players();
|
||||
if (gameFull && !asSpectator && !asJudge && !overrideRestrictions) {
|
||||
const QMessageBox::StandardButton answer =
|
||||
QMessageBox::question(this, tr("Join game"), tr("The game is full. Join as a spectator instead?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||
if (answer != QMessageBox::Yes) {
|
||||
if (!QtUtils::confirm(this, tr("Join game"), tr("The game is full. Join as a spectator instead?"),
|
||||
QMessageBox::No)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <libcockatrice/protocol/pb/response_warn_list.pb.h>
|
||||
#include <libcockatrice/protocol/pb/session_commands.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
#include <string>
|
||||
|
||||
@@ -685,10 +686,8 @@ void UserContextMenu::execRemoveFromIgnore(const QString &userName)
|
||||
|
||||
void UserContextMenu::execKick(int playerId)
|
||||
{
|
||||
auto result = QMessageBox::question(static_cast<QWidget *>(parent()), tr("Kick Player"),
|
||||
tr("Are you sure you want to kick this player from the game?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||
if (result == QMessageBox::Yes) {
|
||||
if (QtUtils::confirm(static_cast<QWidget *>(parent()), tr("Kick Player"),
|
||||
tr("Are you sure you want to kick this player from the game?"), QMessageBox::No)) {
|
||||
Command_KickFromGame cmd;
|
||||
cmd.set_player_id(playerId);
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "user_list_painter.h"
|
||||
#include "user_list_proxy.h"
|
||||
|
||||
#include <QAbstractAnimation>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QApplication>
|
||||
#include <QByteArray>
|
||||
@@ -41,7 +40,6 @@
|
||||
#include <QPalette>
|
||||
#include <QPoint>
|
||||
#include <QPointF>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QRect>
|
||||
#include <QScreen>
|
||||
#include <QScrollBar>
|
||||
@@ -58,6 +56,7 @@
|
||||
#include <QWidget>
|
||||
#include <QtGlobal>
|
||||
#include <libcockatrice/settings/appearance_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
class QPixmap;
|
||||
@@ -895,11 +894,7 @@ void UserListWidget::showPopupForUser(UserListTWI *item)
|
||||
return;
|
||||
}
|
||||
|
||||
auto *fade = new QPropertyAnimation(userInfoPopup, "windowOpacity", userInfoPopup);
|
||||
fade->setDuration(120);
|
||||
fade->setStartValue(0.0);
|
||||
fade->setEndValue(1.0);
|
||||
fade->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
QtUtils::fadeWindow(userInfoPopup, 0.0, 1.0, 120);
|
||||
}
|
||||
|
||||
void UserListWidget::positionPopup(UserListTWI *item)
|
||||
@@ -976,12 +971,7 @@ void UserListWidget::hidePopup(bool immediate)
|
||||
}
|
||||
|
||||
// Fade out
|
||||
auto *fade = new QPropertyAnimation(userInfoPopup, "windowOpacity", userInfoPopup);
|
||||
fade->setDuration(100);
|
||||
fade->setStartValue(userInfoPopup->windowOpacity());
|
||||
fade->setEndValue(0.0);
|
||||
connect(fade, &QPropertyAnimation::finished, userInfoPopup, &QWidget::hide);
|
||||
fade->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
QtUtils::fadeWindow(userInfoPopup, userInfoPopup->windowOpacity(), 0.0, 100, true);
|
||||
}
|
||||
|
||||
bool UserListWidget::isPressInsideListUi(const QWidget *widget) const
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <QColor>
|
||||
#include <QColorDialog>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
@@ -30,7 +29,6 @@
|
||||
#include <QStringLiteral>
|
||||
#include <QStyleFactory>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <QVBoxLayout>
|
||||
#include <QVariant>
|
||||
#include <QtGlobal>
|
||||
@@ -39,6 +37,7 @@
|
||||
#include <libcockatrice/settings/interface_settings.h>
|
||||
#include <libcockatrice/settings/paths_settings.h>
|
||||
#include <libcockatrice/settings/personal_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
AppearanceSettingsPage::AppearanceSettingsPage()
|
||||
@@ -446,7 +445,7 @@ void AppearanceSettingsPage::openThemeLocation()
|
||||
dirDir.cdUp();
|
||||
// open if dir exists, create if parent dir does exist
|
||||
if (dirDir.exists() && dirDir.mkpath(dir)) {
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
|
||||
QtUtils::openPathInFileManager(dir);
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not create themes directory at '%1'.").arg(dir));
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <libcockatrice/settings/tabs_settings.h>
|
||||
#include <libcockatrice/settings/updates_settings.h>
|
||||
#include <libcockatrice/utility/macros.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <libcockatrice/utility/translation_loader.h>
|
||||
#include <qlogging.h>
|
||||
#include <qnamespace.h>
|
||||
@@ -547,12 +548,9 @@ void GeneralSettingsPage::cardLanguageBoxChanged(int index)
|
||||
}
|
||||
message += tr("<p>Run Oracle now?</p>");
|
||||
|
||||
const QMessageBox::StandardButton answer = QMessageBox::question(
|
||||
this, tr("Card text & images language changed"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
|
||||
// The answer only controls whether Oracle starts right away; the caches stay
|
||||
// cleared so the next import or launch rebuilds them in the new language.
|
||||
if (answer == QMessageBox::Yes) {
|
||||
if (QtUtils::confirm(this, tr("Card text & images language changed"), message, QMessageBox::Yes)) {
|
||||
emit cardDatabaseUpdateRequested();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <QStringLiteral>
|
||||
#include <QVBoxLayout>
|
||||
#include <libcockatrice/settings/personal_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
ShortcutSettingsPage::ShortcutSettingsPage()
|
||||
@@ -112,16 +113,15 @@ void ShortcutSettingsPage::currentItemChanged(const QString &key)
|
||||
|
||||
void ShortcutSettingsPage::resetShortcuts()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Restore all default shortcuts"),
|
||||
tr("Do you really want to restore all default shortcuts?")) == QMessageBox::Yes) {
|
||||
if (QtUtils::confirm(this, tr("Restore all default shortcuts"),
|
||||
tr("Do you really want to restore all default shortcuts?"))) {
|
||||
SettingsCache::instance().shortcuts().resetAllShortcuts();
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutSettingsPage::clearShortcuts()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Clear all default shortcuts"),
|
||||
tr("Do you really want to clear all shortcuts?")) == QMessageBox::Yes) {
|
||||
if (QtUtils::confirm(this, tr("Clear all default shortcuts"), tr("Do you really want to clear all shortcuts?"))) {
|
||||
SettingsCache::instance().shortcuts().clearAllShortcuts();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
@@ -45,7 +44,6 @@
|
||||
#include <QTimer>
|
||||
#include <QToolBar>
|
||||
#include <QTreeView>
|
||||
#include <QUrl>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <QtGlobal>
|
||||
@@ -65,6 +63,7 @@
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/settings/network_settings.h>
|
||||
#include <libcockatrice/settings/paths_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <libcockatrice/utility/string_limits.h>
|
||||
#include <optional>
|
||||
#include <qlogging.h>
|
||||
@@ -524,7 +523,7 @@ void TabDeckStorage::actDeleteLocalDeck()
|
||||
void TabDeckStorage::actOpenDecksFolder()
|
||||
{
|
||||
QString dir = localDirModel->rootPath();
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
|
||||
QtUtils::openPathInFileManager(dir);
|
||||
}
|
||||
|
||||
void TabDeckStorage::actRemoteDoubleClick(const QModelIndex &curRight)
|
||||
|
||||
@@ -606,15 +606,14 @@ void TabGame::actConcede()
|
||||
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) {
|
||||
if (!QtUtils::confirm(this, tr("Concede"), tr("Are you sure you want to concede this game?"),
|
||||
QMessageBox::No)) {
|
||||
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) {
|
||||
if (!QtUtils::confirm(this, tr("Unconcede"),
|
||||
tr("You have already conceded. Do you want to return to this game?"), QMessageBox::No)) {
|
||||
return;
|
||||
}
|
||||
emit game->getPlayerManager()->activeLocalPlayerUnconceded();
|
||||
@@ -631,8 +630,8 @@ bool TabGame::leaveGame()
|
||||
if (!game->getGameState()->isGameClosed()) {
|
||||
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) {
|
||||
if (!QtUtils::confirm(this, tr("Leave game"), tr("Are you sure you want to leave this game?"),
|
||||
QMessageBox::No)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <libcockatrice/protocol/pb/response_deck_download.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/settings/cards_display_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <optional>
|
||||
#include <qnamespace.h>
|
||||
|
||||
@@ -44,9 +45,7 @@ TabPublicDecks::TabPublicDecks(TabSupervisor *_tabSupervisor, AbstractClient *_c
|
||||
cardSize = SettingsCache::instance().cardsDisplay().getVisualDeckStorageCardSize();
|
||||
|
||||
titleLabel = new QLabel(tr("Public decks of %1").arg(userName.toHtmlEscaped()), this);
|
||||
QFont titleFont = titleLabel->font();
|
||||
titleFont.setBold(true);
|
||||
titleLabel->setFont(titleFont);
|
||||
titleLabel->setFont(QtUtils::boldFont(titleLabel->font()));
|
||||
|
||||
auto *headerLayout = new QHBoxLayout;
|
||||
headerLayout->addWidget(titleLabel);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <QByteArray>
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
@@ -45,7 +44,6 @@
|
||||
#include <QStyle>
|
||||
#include <QToolBar>
|
||||
#include <QTreeView>
|
||||
#include <QUrl>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
||||
@@ -61,6 +59,7 @@
|
||||
#include <libcockatrice/protocol/pb/response_replay_get_code.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/settings/paths_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qlogging.h>
|
||||
#include <qnamespace.h>
|
||||
#include <string>
|
||||
@@ -400,7 +399,7 @@ void TabReplays::actDeleteLocalReplay()
|
||||
void TabReplays::actOpenReplaysFolder()
|
||||
{
|
||||
QString dir = localDirModel->rootPath();
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
|
||||
QtUtils::openPathInFileManager(dir);
|
||||
}
|
||||
|
||||
void TabReplays::actRemoteDoubleClick(const QModelIndex &curRight)
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
#include <libcockatrice/settings/deck_editor_settings.h>
|
||||
#include <libcockatrice/settings/interface_settings.h>
|
||||
#include <libcockatrice/settings/tabs_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <memory>
|
||||
#include <qnamespace.h>
|
||||
#include <string>
|
||||
@@ -363,9 +364,8 @@ void TabSupervisor::closeEvent(QCloseEvent *event)
|
||||
QTabWidget::closeEvent(event);
|
||||
|
||||
if (getGameCount()) {
|
||||
if (QMessageBox::question(this, tr("Are you sure?"),
|
||||
tr("There are still open games. Are you sure you want to quit?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
|
||||
if (!QtUtils::confirm(this, tr("Are you sure?"),
|
||||
tr("There are still open games. Are you sure you want to quit?"), QMessageBox::No)) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/card/printing/printing_info.h>
|
||||
#include <libcockatrice/models/database/card/card_search_model.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
class QObject;
|
||||
@@ -181,9 +182,8 @@ void CardCompleterDelegate::drawManaSymbol(QPainter *p, QPoint centre, const QSt
|
||||
p->setBrush(Qt::NoBrush);
|
||||
p->drawEllipse(pip.adjusted(1, 1, -1, -1));
|
||||
|
||||
QFont f = p->font();
|
||||
QFont f = QtUtils::boldFont(p->font());
|
||||
f.setPixelSize(qMax(radius - 1, 7));
|
||||
f.setBold(true);
|
||||
|
||||
p->setFont(f);
|
||||
p->setPen(mc.text);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/models/database/card/card_search_model.h>
|
||||
#include <libcockatrice/utility/card_ref.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
template <class T> class QSharedPointer;
|
||||
@@ -346,12 +347,7 @@ void CardCompleterStyler::showPreview()
|
||||
preview->show();
|
||||
preview->raise();
|
||||
|
||||
auto *fade = new QPropertyAnimation(preview, "windowOpacity", preview);
|
||||
|
||||
fade->setDuration(FadeDuration);
|
||||
fade->setStartValue(preview->windowOpacity());
|
||||
fade->setEndValue(1.0);
|
||||
fade->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
QtUtils::fadeWindow(preview, preview->windowOpacity(), 1.0, FadeDuration);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <QSize>
|
||||
#include <QSizePolicy>
|
||||
#include <libcockatrice/settings/paths_settings.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
FilterDisplayWidget::FilterDisplayWidget(QWidget *parent, const QString &filename, FilterTreeModel *_filterModel)
|
||||
@@ -69,10 +70,8 @@ void FilterDisplayWidget::loadFilter()
|
||||
void FilterDisplayWidget::deleteFilter()
|
||||
{
|
||||
// Show confirmation dialog before deleting the filter
|
||||
QMessageBox::StandardButton reply = QMessageBox::question(
|
||||
this, tr("Confirm Delete"), tr("Are you sure you want to delete the filter '%1'?").arg(filterFilename),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if (reply == QMessageBox::Yes) {
|
||||
if (QtUtils::confirm(this, tr("Confirm Delete"),
|
||||
tr("Are you sure you want to delete the filter '%1'?").arg(filterFilename))) {
|
||||
// If confirmed, delete the filter
|
||||
QString filePath = SettingsCache::instance().paths().getFiltersPath() + QDir::separator() + filterFilename;
|
||||
QFile file(filePath);
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDialog>
|
||||
#include <QDir>
|
||||
#include <QEvent>
|
||||
@@ -112,6 +111,7 @@
|
||||
#include <libcockatrice/settings/tabs_settings.h>
|
||||
#include <libcockatrice/settings/updates_settings.h>
|
||||
#include <libcockatrice/utility/local_server_name.h>
|
||||
#include <libcockatrice/utility/qt_utils.h>
|
||||
#include <memory>
|
||||
#include <qlogging.h>
|
||||
#include <qnamespace.h>
|
||||
@@ -341,7 +341,7 @@ void MainWindow::actViewLog()
|
||||
void MainWindow::actOpenSettingsFolder()
|
||||
{
|
||||
QString dir = SettingsCache::instance().getSettingsPath();
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
|
||||
QtUtils::openPathInFileManager(dir);
|
||||
}
|
||||
|
||||
void MainWindow::retranslateUi()
|
||||
@@ -937,8 +937,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
: tr("A card database update is still running: %1.\nQuitting now will cancel it.\n"
|
||||
"Are you sure you want to quit?")
|
||||
.arg(runningFor);
|
||||
if (QMessageBox::question(this, tr("Are you sure?"), message, QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::No) == QMessageBox::No) {
|
||||
if (!QtUtils::confirm(this, tr("Are you sure?"), message, QMessageBox::No)) {
|
||||
event->ignore();
|
||||
bClosingDown = false;
|
||||
return;
|
||||
@@ -1491,13 +1490,13 @@ void MainWindow::refreshShortcuts()
|
||||
void MainWindow::actOpenCustomFolder()
|
||||
{
|
||||
QString dir = SettingsCache::instance().paths().getCustomPicsPath();
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
|
||||
QtUtils::openPathInFileManager(dir);
|
||||
}
|
||||
|
||||
void MainWindow::actOpenCustomsetsFolder()
|
||||
{
|
||||
QString dir = SettingsCache::instance().getCustomCardDatabasePath();
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
|
||||
QtUtils::openPathInFileManager(dir);
|
||||
}
|
||||
|
||||
void MainWindow::actAddCustomSet()
|
||||
|
||||
Reference in New Issue
Block a user