From ee0a010add9d6b3d777f08e3b87f7cf432638086 Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Sat, 9 Oct 2010 14:09:36 +0200 Subject: [PATCH] fixed bug #35 --- cockatrice/cockatrice.qrc | 1 + cockatrice/resources/icon_delete.svg | 357 +++++++++++++++++++++++++++ cockatrice/src/carddatabase.cpp | 2 +- cockatrice/src/dlg_settings.cpp | 73 ++++-- cockatrice/src/dlg_settings.h | 4 + 5 files changed, 421 insertions(+), 16 deletions(-) create mode 100644 cockatrice/resources/icon_delete.svg diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 14581493..ee53d1af 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -1,6 +1,7 @@ resources/back.svg + resources/icon_delete.svg resources/icon_tab_changed.svg resources/icon_config_general.svg resources/icon_config_appearance.svg diff --git a/cockatrice/resources/icon_delete.svg b/cockatrice/resources/icon_delete.svg new file mode 100644 index 00000000..008d8d42 --- /dev/null +++ b/cockatrice/resources/icon_delete.svg @@ -0,0 +1,357 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 4bb24da5..02a6f4d4 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -454,7 +454,7 @@ bool CardDatabase::loadFromFile(const QString &fileName) } } qDebug(QString("%1 cards in %2 sets loaded").arg(cardHash.size()).arg(setHash.size()).toLatin1()); - return true; + return !cardHash.isEmpty(); } bool CardDatabase::saveToFile(const QString &fileName) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index a27d4b37..1c433494 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -151,43 +151,57 @@ void GeneralSettingsPage::retranslateUi() AppearanceSettingsPage::AppearanceSettingsPage() { + QIcon deleteIcon(":/resources/icon_delete.svg"); + handBgLabel = new QLabel; handBgEdit = new QLineEdit(settingsCache->getHandBgPath()); handBgEdit->setReadOnly(true); + QPushButton *handBgClearButton = new QPushButton(deleteIcon, QString()); + connect(handBgClearButton, SIGNAL(clicked()), this, SLOT(handBgClearButtonClicked())); QPushButton *handBgButton = new QPushButton("..."); connect(handBgButton, SIGNAL(clicked()), this, SLOT(handBgButtonClicked())); tableBgLabel = new QLabel; tableBgEdit = new QLineEdit(settingsCache->getTableBgPath()); tableBgEdit->setReadOnly(true); + QPushButton *tableBgClearButton = new QPushButton(deleteIcon, QString()); + connect(tableBgClearButton, SIGNAL(clicked()), this, SLOT(tableBgClearButtonClicked())); QPushButton *tableBgButton = new QPushButton("..."); connect(tableBgButton, SIGNAL(clicked()), this, SLOT(tableBgButtonClicked())); playerAreaBgLabel = new QLabel; playerAreaBgEdit = new QLineEdit(settingsCache->getPlayerBgPath()); playerAreaBgEdit->setReadOnly(true); + QPushButton *playerAreaBgClearButton = new QPushButton(deleteIcon, QString()); + connect(playerAreaBgClearButton, SIGNAL(clicked()), this, SLOT(playerAreaBgClearButtonClicked())); QPushButton *playerAreaBgButton = new QPushButton("..."); connect(playerAreaBgButton, SIGNAL(clicked()), this, SLOT(playerAreaBgButtonClicked())); cardBackPicturePathLabel = new QLabel; cardBackPicturePathEdit = new QLineEdit(settingsCache->getCardBackPicturePath()); cardBackPicturePathEdit->setReadOnly(true); + QPushButton *cardBackPicturePathClearButton = new QPushButton(deleteIcon, QString()); + connect(cardBackPicturePathClearButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathClearButtonClicked())); QPushButton *cardBackPicturePathButton = new QPushButton("..."); connect(cardBackPicturePathButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathButtonClicked())); QGridLayout *zoneBgGrid = new QGridLayout; zoneBgGrid->addWidget(handBgLabel, 0, 0); zoneBgGrid->addWidget(handBgEdit, 0, 1); - zoneBgGrid->addWidget(handBgButton, 0, 2); + zoneBgGrid->addWidget(handBgClearButton, 0, 2); + zoneBgGrid->addWidget(handBgButton, 0, 3); zoneBgGrid->addWidget(tableBgLabel, 1, 0); zoneBgGrid->addWidget(tableBgEdit, 1, 1); - zoneBgGrid->addWidget(tableBgButton, 1, 2); + zoneBgGrid->addWidget(tableBgClearButton, 1, 2); + zoneBgGrid->addWidget(tableBgButton, 1, 3); zoneBgGrid->addWidget(playerAreaBgLabel, 2, 0); zoneBgGrid->addWidget(playerAreaBgEdit, 2, 1); - zoneBgGrid->addWidget(playerAreaBgButton, 2, 2); + zoneBgGrid->addWidget(playerAreaBgClearButton, 2, 2); + zoneBgGrid->addWidget(playerAreaBgButton, 2, 3); zoneBgGrid->addWidget(cardBackPicturePathLabel, 3, 0); zoneBgGrid->addWidget(cardBackPicturePathEdit, 3, 1); - zoneBgGrid->addWidget(cardBackPicturePathButton, 3, 2); + zoneBgGrid->addWidget(cardBackPicturePathClearButton, 3, 2); + zoneBgGrid->addWidget(cardBackPicturePathButton, 3, 3); zoneBgGroupBox = new QGroupBox; zoneBgGroupBox->setLayout(zoneBgGrid); @@ -255,6 +269,12 @@ void AppearanceSettingsPage::retranslateUi() zoneViewSortByTypeCheckBox->setText(tr("Sort by type")); } +void AppearanceSettingsPage::handBgClearButtonClicked() +{ + handBgEdit->setText(QString()); + settingsCache->setHandBgPath(QString()); +} + void AppearanceSettingsPage::handBgButtonClicked() { QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); @@ -265,6 +285,12 @@ void AppearanceSettingsPage::handBgButtonClicked() settingsCache->setHandBgPath(path); } +void AppearanceSettingsPage::tableBgClearButtonClicked() +{ + tableBgEdit->setText(QString()); + settingsCache->setTableBgPath(QString()); +} + void AppearanceSettingsPage::tableBgButtonClicked() { QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); @@ -275,6 +301,12 @@ void AppearanceSettingsPage::tableBgButtonClicked() settingsCache->setTableBgPath(path); } +void AppearanceSettingsPage::playerAreaBgClearButtonClicked() +{ + playerAreaBgEdit->setText(QString()); + settingsCache->setPlayerBgPath(QString()); +} + void AppearanceSettingsPage::playerAreaBgButtonClicked() { QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); @@ -285,6 +317,12 @@ void AppearanceSettingsPage::playerAreaBgButtonClicked() settingsCache->setPlayerBgPath(path); } +void AppearanceSettingsPage::cardBackPicturePathClearButtonClicked() +{ + cardBackPicturePathEdit->setText(QString()); + settingsCache->setCardBackPicturePath(QString()); +} + void AppearanceSettingsPage::cardBackPicturePathButtonClicked() { QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); @@ -485,17 +523,22 @@ void DlgSettings::changeEvent(QEvent *event) void DlgSettings::closeEvent(QCloseEvent *event) { - if (!db->getLoadSuccess()) { - QMessageBox::critical(this, tr("Error"), tr("Your card database is invalid. Please check if the path is set correctly.")); - event->ignore(); - } else if (!QDir(settingsCache->getDeckPath()).exists()) { - QMessageBox::critical(this, tr("Error"), tr("The path to your deck directory is invalid.")); - event->ignore(); - } else if (!QDir(settingsCache->getPicsPath()).exists()) { - QMessageBox::critical(this, tr("Error"), tr("The path to your card pictures directory is invalid.")); - event->ignore(); - } else - event->accept(); + if (!db->getLoadSuccess()) + if (QMessageBox::critical(this, tr("Error"), tr("Your card database is invalid. Would you like to go back and set the correct path?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + event->ignore(); + return; + } + if (!QDir(settingsCache->getDeckPath()).exists()) + if (QMessageBox::critical(this, tr("Error"), tr("The path to your deck directory is invalid. Would you like to go back and set the correct path?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + event->ignore(); + return; + } + if (!QDir(settingsCache->getPicsPath()).exists()) + if (QMessageBox::critical(this, tr("Error"), tr("The path to your card pictures directory is invalid. Would you like to go back and set the correct path?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + event->ignore(); + return; + } + event->accept(); } void DlgSettings::retranslateUi() diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index f9cb71a1..9e82cc7a 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -48,9 +48,13 @@ private: class AppearanceSettingsPage : public AbstractSettingsPage { Q_OBJECT private slots: + void handBgClearButtonClicked(); void handBgButtonClicked(); + void tableBgClearButtonClicked(); void tableBgButtonClicked(); + void playerAreaBgClearButtonClicked(); void playerAreaBgButtonClicked(); + void cardBackPicturePathClearButtonClicked(); void cardBackPicturePathButtonClicked(); signals: void handBgChanged(const QString &path);