improved simple image viewer

This commit is contained in:
Rafael 2016-03-21 22:06:17 +01:00
parent 4da12a2796
commit 035448172c
4 changed files with 9 additions and 13 deletions

View file

@ -30,6 +30,7 @@ PictureDialog::PictureDialog(QWidget *parent) :
ui(new Ui::PictureDialog)
{
ui->setupUi(this);
windowTitleStr = this->windowTitle();
jsonDrawString = ui->labJSON->text();
}
@ -38,12 +39,7 @@ PictureDialog::~PictureDialog()
delete ui;
}
void PictureDialog::setSnapmaticPicture(QPixmap pixmap)
{
ui->labPicture->setPixmap(pixmap);
}
void PictureDialog::setJsonString(SnapmaticPicture *picture)
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture)
{
QString locX = QString::number(picture->getLocationX());
QString locY = QString::number(picture->getLocationY());
@ -59,7 +55,9 @@ void PictureDialog::setJsonString(SnapmaticPicture *picture)
}
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());
}
void PictureDialog::on_cmdClose_clicked()

View file

@ -31,8 +31,7 @@ class PictureDialog : public QDialog
Q_OBJECT
public:
explicit PictureDialog(QWidget *parent = 0);
void setSnapmaticPicture(QPixmap pixmap);
void setJsonString(SnapmaticPicture *picture);
void setSnapmaticPicture(SnapmaticPicture *picture);
~PictureDialog();
private slots:
@ -41,6 +40,7 @@ private slots:
private:
Ui::PictureDialog *ui;
QString jsonDrawString;
QString windowTitleStr;
};
#endif // PICTUREDIALOG_H

View file

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>%1 - Simple Image Viewer</string>
</property>
<layout class="QVBoxLayout" name="vlPictureLayout">
<property name="leftMargin">
@ -50,7 +50,7 @@
<item>
<widget class="QLabel" name="labJSON">
<property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;Location:&lt;/span&gt; X: %1, Y: %2, Z: %3 &lt;br&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Players:&lt;/span&gt; %4&lt;br&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Crew ID:&lt;/span&gt; %5</string>
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;Location: &lt;/span&gt;%1, %2, %3 &lt;br&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Players: &lt;/span&gt;%4&lt;br&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Crew ID: &lt;/span&gt;%5</string>
</property>
</widget>
</item>

View file

@ -48,9 +48,7 @@ int main(int argc, char *argv[])
SnapmaticPicture picture;
picture.readingPictureFromFile(arg1);
picDialog.setWindowFlags(picDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
picDialog.setWindowTitle(picture.getPictureStr());
picDialog.setSnapmaticPicture(picture.getPixmap());
picDialog.setJsonString(&picture);
picDialog.setSnapmaticPicture(&picture);
picDialog.show();
return a.exec();