Added context menu
--HG-- branch : feature
This commit is contained in:
parent
d2e0c7822f
commit
58b1e84917
|
@ -31,6 +31,7 @@
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QMenu>
|
||||||
#include "../xml/vpattern.h"
|
#include "../xml/vpattern.h"
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../core/vapplication.h"
|
#include "../core/vapplication.h"
|
||||||
|
@ -65,7 +66,6 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
|
||||||
connect(ui->plainTextEditTechNotes, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
|
connect(ui->plainTextEditTechNotes, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
|
||||||
|
|
||||||
InitImage();
|
InitImage();
|
||||||
connect(ui->deleteImageButton, &QPushButton::clicked, this, &DialogPatternProperties::DeleteImage);
|
|
||||||
|
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &DialogPatternProperties::Ok);
|
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &DialogPatternProperties::Ok);
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this,
|
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this,
|
||||||
|
@ -620,8 +620,20 @@ void DialogPatternProperties::InitImage()
|
||||||
QBuffer buffer(&ba);
|
QBuffer buffer(&ba);
|
||||||
buffer.open(QIODevice::ReadOnly);
|
buffer.open(QIODevice::ReadOnly);
|
||||||
image.load(&buffer, "PNG"); // writes image into ba in PNG format
|
image.load(&buffer, "PNG"); // writes image into ba in PNG format
|
||||||
|
|
||||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image));
|
ui->imageLabel->setPixmap(QPixmap::fromImage(image));
|
||||||
|
ui->imageLabel->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
connect(ui->changeImageButton, &QPushButton::clicked, this, &DialogPatternProperties::SetNewImage);
|
connect(ui->changeImageButton, &QPushButton::clicked, this, &DialogPatternProperties::SetNewImage);
|
||||||
|
connect(ui->deleteImageButton, &QPushButton::clicked, this, &DialogPatternProperties::DeleteImage);
|
||||||
|
connect(ui->imageLabel, &QWidget::customContextMenuRequested, this, &DialogPatternProperties::ShowContextMenu);
|
||||||
|
|
||||||
|
deleteAction = new QAction("Delete image", this);
|
||||||
|
changeImageAction = new QAction("Change image", this);
|
||||||
|
saveImageAction = new QAction("Save image to file", this);
|
||||||
|
showImageAction = new QAction("Show image", this);
|
||||||
|
connect(deleteAction, &QAction::triggered, this, &DialogPatternProperties::DeleteImage);
|
||||||
|
connect(changeImageAction, &QAction::triggered, this, &DialogPatternProperties::SetNewImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -658,3 +670,15 @@ void DialogPatternProperties::DeleteImage()
|
||||||
doc->DeleteImage();
|
doc->DeleteImage();
|
||||||
ui->imageLabel->setText("Change image");
|
ui->imageLabel->setText("Change image");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogPatternProperties::ShowContextMenu()
|
||||||
|
{
|
||||||
|
QMenu menu(this);
|
||||||
|
menu.addAction(deleteAction);
|
||||||
|
menu.addAction(changeImageAction);
|
||||||
|
menu.addAction(saveImageAction);
|
||||||
|
menu.addAction(showImageAction);
|
||||||
|
menu.exec(QCursor::pos());
|
||||||
|
menu.show();
|
||||||
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ public slots:
|
||||||
void CheckStateSize(int state);
|
void CheckStateSize(int state);
|
||||||
void DescEdited();
|
void DescEdited();
|
||||||
void SetNewImage();
|
void SetNewImage();
|
||||||
|
void ShowContextMenu();
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -80,6 +81,10 @@ private:
|
||||||
bool defaultChanged;
|
bool defaultChanged;
|
||||||
bool securityChanged;
|
bool securityChanged;
|
||||||
bool isInitialized;
|
bool isInitialized;
|
||||||
|
QAction *deleteAction;
|
||||||
|
QAction *changeImageAction;
|
||||||
|
QAction *saveImageAction;
|
||||||
|
QAction *showImageAction;
|
||||||
|
|
||||||
void SetHeightsChecked(bool enabled);
|
void SetHeightsChecked(bool enabled);
|
||||||
void SetSizesChecked(bool enabled);
|
void SetSizesChecked(bool enabled);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user