mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 19:13:25 -08:00
Compare commits
3 commits
329a6ba94c
...
26a74c96c5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26a74c96c5 | ||
|
|
e9cd9453ea | ||
|
|
bc26e19564 |
5 changed files with 56 additions and 22 deletions
|
|
@ -20,6 +20,7 @@
|
|||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QResizeEvent>
|
||||
#include <QTimer>
|
||||
#include <libcockatrice/card/card_info_comparator.h>
|
||||
#include <libcockatrice/card/database/card_database.h>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
|
|
@ -82,13 +83,8 @@ void VisualDeckEditorWidget::initializeSearchBarAndCompleter()
|
|||
searchBar = new QLineEdit(searchContainer);
|
||||
searchContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
connect(searchBar, &QLineEdit::returnPressed, this, [=, this]() {
|
||||
if (!searchBar->hasFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ExactCard card = CardDatabaseManager::query()->getCard({searchBar->text()});
|
||||
if (card) {
|
||||
emit cardAdditionRequested(card);
|
||||
if (searchBar->hasFocus()) {
|
||||
addCardFromSearch();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -133,16 +129,24 @@ void VisualDeckEditorWidget::initializeSearchBarAndCompleter()
|
|||
// Search button functionality
|
||||
searchPushButton = new CompactPushButton(searchContainer);
|
||||
searchPushButton->setButtonIcon(themePixmap(QStringLiteral("icons/search")));
|
||||
connect(searchPushButton, &QPushButton::clicked, this, [=, this]() {
|
||||
ExactCard card = CardDatabaseManager::query()->getCard({searchBar->text()});
|
||||
if (card) {
|
||||
emit cardAdditionRequested(card);
|
||||
}
|
||||
});
|
||||
connect(searchPushButton, &QPushButton::clicked, this, [this] { addCardFromSearch(); });
|
||||
|
||||
searchLayout->addWidget(searchPushButton);
|
||||
}
|
||||
|
||||
void VisualDeckEditorWidget::addCardFromSearch()
|
||||
{
|
||||
ExactCard card = CardDatabaseManager::query()->getCard({searchBar->text()});
|
||||
if (!card) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit cardAdditionRequested(card);
|
||||
|
||||
searchBar->setFocus();
|
||||
QTimer::singleShot(0, searchBar, [this] { searchBar->setSelection(0, searchBar->text().length()); });
|
||||
}
|
||||
|
||||
void VisualDeckEditorWidget::initializeDisplayOptionsWidget()
|
||||
{
|
||||
displayOptionsWidget = new VisualDeckDisplayOptionsWidget(this);
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ signals:
|
|||
|
||||
protected:
|
||||
void initializeSearchBarAndCompleter();
|
||||
void addCardFromSearch();
|
||||
void initializeDisplayOptionsWidget();
|
||||
void initializeDisplayOptionsAndSearchWidget();
|
||||
void initializeScrollAreaAndZoneContainer();
|
||||
|
|
|
|||
|
|
@ -575,11 +575,18 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
void MainWindow::startupConfigCheck()
|
||||
{
|
||||
const bool isCleanInstall = SettingsCache::instance().network().getClientVersion() == CLIENT_INFO_NOT_SET;
|
||||
|
||||
// checkUnknownSets() is intentionally deferred from the card database load
|
||||
// (which runs in main() before MainWindow exists) so that
|
||||
// cardDatabaseNewSetsFound / cardDatabaseAllNewSetsEnabled have live
|
||||
// receivers when emitted.
|
||||
CardDatabaseManager::getInstance()->checkUnknownSets();
|
||||
// On a clean install the onboarding wizard owns the first-run experience;
|
||||
// wait until it closes so the legacy "all sets enabled" welcome and the
|
||||
// Manage Sets dialog don't appear first.
|
||||
if (!isCleanInstall) {
|
||||
CardDatabaseManager::getInstance()->checkUnknownSets();
|
||||
}
|
||||
|
||||
if (SettingsCache::instance().debug().getLocalGameOnStartup()) {
|
||||
LocalGameOptions options;
|
||||
|
|
@ -593,14 +600,14 @@ void MainWindow::startupConfigCheck()
|
|||
|
||||
actCheckCommanderBracketDefinitionUpdates();
|
||||
|
||||
if (SettingsCache::instance().network().getClientVersion() == CLIENT_INFO_NOT_SET) {
|
||||
if (isCleanInstall) {
|
||||
// no config found, 99% new clean install
|
||||
qCInfo(WindowMainStartupVersionLog)
|
||||
<< "Startup: old client version empty, assuming first start after clean install";
|
||||
SettingsCache::instance().downloads().resetToDefaultURLs(); // populate the download urls
|
||||
SettingsCache::instance().network().setClientVersion(VERSION_STRING);
|
||||
actCheckServerUpdates();
|
||||
runFirstRunWizard();
|
||||
runFirstRunWizard(true);
|
||||
|
||||
if (QString(VERSION_STRING).contains("custom", Qt::CaseInsensitive)) {
|
||||
SettingsCache::instance().updates().setCheckUpdatesOnStartup(false);
|
||||
|
|
@ -680,7 +687,7 @@ void MainWindow::startupConfigCheck()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::runFirstRunWizard()
|
||||
void MainWindow::runFirstRunWizard(bool firstRun)
|
||||
{
|
||||
auto *wizard = new FirstRunWizard(this);
|
||||
wizard->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
|
@ -692,6 +699,19 @@ void MainWindow::runFirstRunWizard()
|
|||
connect(wizard, &FirstRunWizard::registerRequested, connectionController, &ConnectionController::registerToServer);
|
||||
connect(wizard, &FirstRunWizard::connectRequested, connectionController, &ConnectionController::connectToServer);
|
||||
|
||||
if (firstRun) {
|
||||
// The onboarding wizard owns set handling for a clean install. Suppress
|
||||
// the legacy set dialogs while it's open and run checkUnknownSets() once
|
||||
// it closes so the sets end up enabled in the right order.
|
||||
firstRunWizardActive = true;
|
||||
connect(wizard, &QDialog::finished, this, [this] {
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
CardDatabaseManager::getInstance()->checkUnknownSets();
|
||||
firstRunWizardActive = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
wizard->setModal(true);
|
||||
wizard->show();
|
||||
}
|
||||
|
|
@ -995,7 +1015,7 @@ void MainWindow::cardDatabaseLoadingFailed()
|
|||
|
||||
void MainWindow::cardDatabaseNewSetsFound(int numUnknownSets, QStringList unknownSetsNames)
|
||||
{
|
||||
if (SettingsCache::instance().updates().getAlwaysEnableNewSets()) {
|
||||
if (firstRunWizardActive || SettingsCache::instance().updates().getAlwaysEnableNewSets()) {
|
||||
CardDatabaseManager::getInstance()->enableAllUnknownSets();
|
||||
const auto reloadOk1 =
|
||||
QtConcurrent::run([] { CardDatabaseManager::getInstance()->reloadCardDatabasesAndNotify(); });
|
||||
|
|
@ -1038,6 +1058,12 @@ void MainWindow::cardDatabaseNewSetsFound(int numUnknownSets, QStringList unknow
|
|||
|
||||
void MainWindow::cardDatabaseAllNewSetsEnabled()
|
||||
{
|
||||
if (firstRunWizardActive || CardDatabaseManager::getInstance()->getCardList().isEmpty()) {
|
||||
// The onboarding wizard owns the first-run messaging on a clean install,
|
||||
// and with no card data there are no sets to have enabled.
|
||||
return;
|
||||
}
|
||||
|
||||
QMessageBox::information(
|
||||
this, tr("Welcome"),
|
||||
tr("Hi! It seems like you're running this version of Cockatrice for the first time.\nAll the sets in the card "
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ private:
|
|||
void createTrayIcon();
|
||||
int getNextCustomSetPrefix(QDir dataDir);
|
||||
|
||||
void runFirstRunWizard();
|
||||
void runFirstRunWizard(bool firstRun = false);
|
||||
|
||||
inline QString getCardUpdaterBinaryName()
|
||||
{
|
||||
|
|
@ -169,6 +169,7 @@ private:
|
|||
bool bHasActivated, askedForDbUpdater;
|
||||
bool skipStartupAutoConnect = false;
|
||||
bool startupAutoConnectAttempted = false;
|
||||
bool firstRunWizardActive = false;
|
||||
QProcess *cardUpdateProcess;
|
||||
QByteArray cardUpdateOutputBuffer;
|
||||
DlgViewLog *logviewDialog;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@ set(oracle_SOURCES
|
|||
../cockatrice/src/interface/pixel_map_generator.cpp
|
||||
../cockatrice/src/interface/theme_config.cpp
|
||||
../cockatrice/src/interface/theme_manager.cpp
|
||||
../cockatrice/src/interface/widgets/quick_settings/settings_button_widget.cpp
|
||||
../cockatrice/src/interface/widgets/quick_settings/settings_popup_widget.cpp
|
||||
${VERSION_STRING_CPP}
|
||||
)
|
||||
|
||||
|
|
@ -123,10 +121,14 @@ target_link_libraries(
|
|||
oracle
|
||||
PUBLIC libcockatrice_card
|
||||
PUBLIC libcockatrice_settings
|
||||
PUBLIC libcockatrice_network
|
||||
PUBLIC libcockatrice_protocol
|
||||
PUBLIC ${ORACLE_QT_MODULES}
|
||||
)
|
||||
|
||||
# Only user_level.h is needed from the network headers (pulled in transitively
|
||||
# by pixel_map_generator.h); nothing from the network libraries is linked.
|
||||
target_include_directories(oracle PRIVATE ${CMAKE_SOURCE_DIR}/libcockatrice_network)
|
||||
|
||||
if(ZLIB_FOUND)
|
||||
target_link_libraries(oracle PUBLIC ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue