Gave error dlg a description of the error for the user.
This commit is contained in:
parent
d078cf52c9
commit
aa658f95f6
3 changed files with 17 additions and 8 deletions
|
@ -4,18 +4,19 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
DlgAddSetResult::DlgAddSetResult(QWidget *parent, bool success) : QDialog(parent) {
|
DlgAddSetResult::DlgAddSetResult(QWidget *parent, bool success, QString msg) : QDialog(parent) {
|
||||||
status = new QLabel(this);
|
status = new QLabel(this);
|
||||||
restart = new QLabel(this);
|
message = new QLabel(this);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
setWindowTitle(tr("Success"));
|
setWindowTitle(tr("Success"));
|
||||||
status->setText(QString("Sets/cards added to Cockatrice."));
|
status->setText(QString("Sets/cards added to Cockatrice."));
|
||||||
restart->setText(QString("You must restart Cockatrice to use the new sets/cards."));
|
message->setText(QString("You must restart Cockatrice to use the new sets/cards."));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setWindowTitle(tr("Failed"));
|
setWindowTitle(tr("Failed"));
|
||||||
status->setText(QString("Sets/cards failed to import."));
|
status->setText(QString("Sets/cards failed to import."));
|
||||||
|
message->setText(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
|
||||||
|
@ -25,7 +26,7 @@ DlgAddSetResult::DlgAddSetResult(QWidget *parent, bool success) : QDialog(parent
|
||||||
|
|
||||||
QVBoxLayout *parentLayout = new QVBoxLayout(this);
|
QVBoxLayout *parentLayout = new QVBoxLayout(this);
|
||||||
parentLayout->addWidget(status);
|
parentLayout->addWidget(status);
|
||||||
parentLayout->addWidget(restart);
|
parentLayout->addWidget(message);
|
||||||
parentLayout->addWidget(buttonBox);
|
parentLayout->addWidget(buttonBox);
|
||||||
|
|
||||||
setLayout(parentLayout);
|
setLayout(parentLayout);
|
||||||
|
|
|
@ -3,15 +3,16 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
class DlgAddSetResult : public QDialog {
|
class DlgAddSetResult : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DlgAddSetResult(QWidget *parent, bool success);
|
DlgAddSetResult(QWidget *parent, bool success, QString msg);
|
||||||
private slots:
|
private slots:
|
||||||
void closeDialog();
|
void closeDialog();
|
||||||
private:
|
private:
|
||||||
QLabel *status, *restart;
|
QLabel *status, *message;
|
||||||
QPushButton *ok;
|
QPushButton *ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -885,16 +885,23 @@ void TabDeckEditor::actAddCustomSet()
|
||||||
if (!dialog.exec())
|
if (!dialog.exec())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QString fileName = dialog.selectedFiles().at(0);
|
||||||
|
|
||||||
|
if (!QFile::exists(fileName)) {
|
||||||
|
DlgAddSetResult dlg(this, false, QString("Selected file cannot be found."));
|
||||||
|
dlg.exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QDir dir(dataDir + "/customsets");
|
QDir dir(dataDir + "/customsets");
|
||||||
int nextPrefix = getNextCustomSetPrefix(dir);
|
int nextPrefix = getNextCustomSetPrefix(dir);
|
||||||
|
|
||||||
QString fileName = dialog.selectedFiles().at(0);
|
|
||||||
bool res = QFile::copy(
|
bool res = QFile::copy(
|
||||||
fileName, dir.absolutePath() + "/" + (nextPrefix > 9 ? "" : "0") +
|
fileName, dir.absolutePath() + "/" + (nextPrefix > 9 ? "" : "0") +
|
||||||
QString::number(nextPrefix) + "." + QFileInfo(fileName).fileName()
|
QString::number(nextPrefix) + "." + QFileInfo(fileName).fileName()
|
||||||
);
|
);
|
||||||
|
|
||||||
DlgAddSetResult dlg(this, res);
|
DlgAddSetResult dlg(this, res, QString());
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue