Added saveImage button to context menu

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2016-03-18 20:23:19 +02:00
parent 58b1e84917
commit a2619d8584
2 changed files with 19 additions and 0 deletions

View File

@ -634,6 +634,7 @@ void DialogPatternProperties::InitImage()
showImageAction = new QAction("Show image", this); showImageAction = new QAction("Show image", this);
connect(deleteAction, &QAction::triggered, this, &DialogPatternProperties::DeleteImage); connect(deleteAction, &QAction::triggered, this, &DialogPatternProperties::DeleteImage);
connect(changeImageAction, &QAction::triggered, this, &DialogPatternProperties::SetNewImage); connect(changeImageAction, &QAction::triggered, this, &DialogPatternProperties::SetNewImage);
connect(saveImageAction, &QAction::triggered, this, &DialogPatternProperties::SaveImage);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -671,6 +672,23 @@ void DialogPatternProperties::DeleteImage()
ui->imageLabel->setText("Change image"); ui->imageLabel->setText("Change image");
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveImage()
{
QByteArray byteArray;
byteArray.append(doc->GetImage().toUtf8());
QByteArray ba = QByteArray::fromBase64(byteArray);
QString extension = ".PNG";
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"));
QFile file(filename + extension);
if (file.open(QIODevice::WriteOnly))
{
file.write(ba);
file.close();
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::ShowContextMenu() void DialogPatternProperties::ShowContextMenu()
{ {

View File

@ -66,6 +66,7 @@ private slots:
void DefValueChanged(); void DefValueChanged();
void SecurityValueChanged(); void SecurityValueChanged();
void DeleteImage(); void DeleteImage();
void SaveImage();
private: private:
Q_DISABLE_COPY(DialogPatternProperties) Q_DISABLE_COPY(DialogPatternProperties)
Ui::DialogPatternProperties *ui; Ui::DialogPatternProperties *ui;