Added showImage to context menu
--HG-- branch : feature
This commit is contained in:
parent
ae53e505c4
commit
5fda012b86
|
@ -610,7 +610,7 @@ void DialogPatternProperties::InitComboBox(QComboBox *box, const QMap<GVal, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPatternProperties::InitImage()
|
QImage DialogPatternProperties::GetImage()
|
||||||
{
|
{
|
||||||
// we set an image from file.val
|
// we set an image from file.val
|
||||||
QImage image;
|
QImage image;
|
||||||
|
@ -624,9 +624,14 @@ void DialogPatternProperties::InitImage()
|
||||||
{
|
{
|
||||||
extension = "PNG";
|
extension = "PNG";
|
||||||
}
|
}
|
||||||
image.load(&buffer, extension.toLatin1().data()); // writes image into ba in PNG format
|
image.load(&buffer, extension.toLatin1().data()); // writes image into ba in 'extension' format
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image));
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogPatternProperties::InitImage()
|
||||||
|
{
|
||||||
|
ui->imageLabel->setPixmap(QPixmap::fromImage(GetImage()));
|
||||||
ui->imageLabel->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->imageLabel->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
ui->imageLabel->setScaledContents(true);
|
ui->imageLabel->setScaledContents(true);
|
||||||
|
|
||||||
|
@ -641,6 +646,7 @@ void DialogPatternProperties::InitImage()
|
||||||
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);
|
connect(saveImageAction, &QAction::triggered, this, &DialogPatternProperties::SaveImage);
|
||||||
|
connect(showImageAction, &QAction::triggered, this, &DialogPatternProperties::ShowImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -695,7 +701,7 @@ void DialogPatternProperties::SaveImage()
|
||||||
byteArray.append(doc->GetImage().toUtf8());
|
byteArray.append(doc->GetImage().toUtf8());
|
||||||
QByteArray ba = QByteArray::fromBase64(byteArray);
|
QByteArray ba = QByteArray::fromBase64(byteArray);
|
||||||
QString extension = "." + doc->GetImageExtension();
|
QString extension = "." + doc->GetImageExtension();
|
||||||
QString filter = "Images (*" + extension + ")";
|
QString filter = tr("Images (*") + extension + ")";
|
||||||
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), "untitled", filter, &filter);
|
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), "untitled", filter, &filter);
|
||||||
if (not filename.endsWith(extension.toUpper()))
|
if (not filename.endsWith(extension.toUpper()))
|
||||||
{
|
{
|
||||||
|
@ -709,6 +715,16 @@ void DialogPatternProperties::SaveImage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogPatternProperties::ShowImage()
|
||||||
|
{
|
||||||
|
QLabel *label = new QLabel(this, Qt::Window);
|
||||||
|
QImage image = GetImage();
|
||||||
|
label->setPixmap(QPixmap::fromImage(image));
|
||||||
|
label->setGeometry(QRect(QCursor::pos(), image.size()));
|
||||||
|
label->show();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPatternProperties::ShowContextMenu()
|
void DialogPatternProperties::ShowContextMenu()
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,6 +67,7 @@ private slots:
|
||||||
void SecurityValueChanged();
|
void SecurityValueChanged();
|
||||||
void DeleteImage();
|
void DeleteImage();
|
||||||
void SaveImage();
|
void SaveImage();
|
||||||
|
void ShowImage();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogPatternProperties)
|
Q_DISABLE_COPY(DialogPatternProperties)
|
||||||
Ui::DialogPatternProperties *ui;
|
Ui::DialogPatternProperties *ui;
|
||||||
|
@ -108,6 +109,7 @@ private:
|
||||||
void UpdateDefHeight();
|
void UpdateDefHeight();
|
||||||
void UpdateDefSize();
|
void UpdateDefSize();
|
||||||
void InitImage();
|
void InitImage();
|
||||||
|
QImage GetImage();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGPATTERNPROPERTIES_H
|
#endif // DIALOGPATTERNPROPERTIES_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user