added json error msgs
This commit is contained in:
parent
53430d82c1
commit
efe1727170
2 changed files with 26 additions and 6 deletions
|
@ -42,7 +42,17 @@ PictureDialog::~PictureDialog()
|
|||
|
||||
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk)
|
||||
{
|
||||
if (readOk)
|
||||
// Showing error if reading error
|
||||
if (!readOk)
|
||||
{
|
||||
QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep())); return;
|
||||
}
|
||||
|
||||
if (picture->isPicOk())
|
||||
{
|
||||
ui->labPicture->setPixmap(picture->getPixmap());
|
||||
}
|
||||
if (picture->isJsonOk())
|
||||
{
|
||||
QString locX = QString::number(picture->getLocationX());
|
||||
QString locY = QString::number(picture->getLocationY());
|
||||
|
@ -51,19 +61,28 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk)
|
|||
QStringList plyrsList = picture->getPlayers();
|
||||
|
||||
QString plyrsStr;
|
||||
if (plyrsList.length() >= 1)
|
||||
{
|
||||
foreach (const QString &player, plyrsList)
|
||||
{
|
||||
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());
|
||||
plyrsStr.remove(0,2);
|
||||
}
|
||||
else
|
||||
{
|
||||
plyrsStr = tr("No player");
|
||||
}
|
||||
|
||||
if (crewID == "") { crewID = tr("No crew"); }
|
||||
|
||||
this->setWindowTitle(windowTitleStr.arg(picture->getPictureStr()));
|
||||
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->labJSON->setText(jsonDrawString.arg("0.0", "0.0", "0.0", tr("No player"), tr("No crew")));
|
||||
QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep()));
|
||||
}
|
||||
}
|
||||
|
|
1
main.cpp
1
main.cpp
|
@ -49,6 +49,7 @@ int main(int argc, char *argv[])
|
|||
bool readOk = picture.readingPictureFromFile(arg1);
|
||||
picDialog.setWindowFlags(picDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
|
||||
picDialog.setSnapmaticPicture(&picture, readOk);
|
||||
if (!readOk) { return 1; }
|
||||
picDialog.show();
|
||||
|
||||
return a.exec();
|
||||
|
|
Loading…
Reference in a new issue