open error msg added

This commit is contained in:
Rafael 2016-03-21 22:14:32 +01:00
parent b06830c033
commit 93f023b89e
3 changed files with 27 additions and 19 deletions

View File

@ -20,6 +20,7 @@
#include "ui_PictureDialog.h" #include "ui_PictureDialog.h"
#include <QJsonDocument> #include <QJsonDocument>
#include <QMessageBox>
#include <QJsonObject> #include <QJsonObject>
#include <QVariantMap> #include <QVariantMap>
#include <QJsonArray> #include <QJsonArray>
@ -39,25 +40,32 @@ PictureDialog::~PictureDialog()
delete ui; delete ui;
} }
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture) void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk)
{ {
QString locX = QString::number(picture->getLocationX()); if (readOk)
QString locY = QString::number(picture->getLocationY());
QString locZ = QString::number(picture->getLocationZ());
QString crewID = QString::number(picture->getCrewNumber());
QStringList plyrsList = picture->getPlayers();
QString plyrsStr;
foreach (const QString &player, plyrsList)
{ {
plyrsStr.append(", "); QString locX = QString::number(picture->getLocationX());
plyrsStr.append(player); QString locY = QString::number(picture->getLocationY());
} QString locZ = QString::number(picture->getLocationZ());
if (plyrsStr.length() >= 1) { plyrsStr.remove(0,2); } QString crewID = QString::number(picture->getCrewNumber());
QStringList plyrsList = picture->getPlayers();
this->setWindowTitle(windowTitleStr.arg(picture->getPictureStr())); QString plyrsStr;
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID)); foreach (const QString &player, plyrsList)
ui->labPicture->setPixmap(picture->getPixmap()); {
plyrsStr.append(", ");
plyrsStr.append(player);
}
if (plyrsStr.length() >= 1) { plyrsStr.remove(0,2); }
this->setWindowTitle(windowTitleStr.arg(picture->getPictureStr()));
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID));
ui->labPicture->setPixmap(picture->getPixmap());
}
else
{
QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep()));
}
} }
void PictureDialog::on_cmdClose_clicked() void PictureDialog::on_cmdClose_clicked()

View File

@ -31,7 +31,7 @@ class PictureDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit PictureDialog(QWidget *parent = 0); explicit PictureDialog(QWidget *parent = 0);
void setSnapmaticPicture(SnapmaticPicture *picture); void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk);
~PictureDialog(); ~PictureDialog();
private slots: private slots:

View File

@ -46,9 +46,9 @@ int main(int argc, char *argv[])
{ {
PictureDialog picDialog; PictureDialog picDialog;
SnapmaticPicture picture; SnapmaticPicture picture;
picture.readingPictureFromFile(arg1); bool readOk = picture.readingPictureFromFile(arg1);
picDialog.setWindowFlags(picDialog.windowFlags()^Qt::WindowContextHelpButtonHint); picDialog.setWindowFlags(picDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
picDialog.setSnapmaticPicture(&picture); picDialog.setSnapmaticPicture(&picture, readOk);
picDialog.show(); picDialog.show();
return a.exec(); return a.exec();