-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathImageNoteEditor.cpp
52 lines (44 loc) · 1.57 KB
/
ImageNoteEditor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "ImageNoteEditor.h"
#include <QFileDialog>
#include <QPushButton>
#include <QVBoxLayout>
#include <QPixmap>
#include "ImageNote.h"
/***
* ImageNoteEditor
*/
void ImageNoteEditor::BACKEND_SET_CONTENT()
{
ressource->setDescription(getDescriptionWidget()->text());
ressource->setMediaPath(currentImgPath);
}
void ImageNoteEditor::LOAD_IMAGE(){
currentImgPath = QFileDialog::getOpenFileName(this, "Ouvrir un fichier", QString(), "Images (*.png *.jpeg *.xpm *.jpg)");
image = QPixmap(currentImgPath);
int w = imageWidget->width();
int h = imageWidget->height();
if(!image.isNull()){
imageWidget->setPixmap(image.scaled(w, h, Qt::KeepAspectRatio));
}
}
ImageNoteEditor::ImageNoteEditor(ImageNote *img, QWidget *parent)
:BinaryEditor(img, parent), ressource(img), currentImgPath(img->getMediaPath())
{
btnAddImage = new QPushButton("Picture");
image = QPixmap(ressource->getMediaPath());
imageWidget = new QLabel();
imageWidget->setAlignment(Qt::AlignHCenter);
int w = imageWidget->width();
int h = imageWidget->height();
if(!image.isNull()){
imageWidget->setPixmap(image.scaled(w, h, Qt::KeepAspectRatio));
}
else {
imageWidget->setPixmap(QPixmap(":/images/image_not_found").scaled(w, h, Qt::KeepAspectRatio));
}
contentLayout->addWidget(imageWidget);
contentLayout->addWidget(new QLabel("Description:"));
contentLayout->addWidget(getDescriptionWidget());
buttonsLayout->addWidget(btnAddImage);
QObject::connect(btnAddImage, SIGNAL(clicked()), this, SLOT(LOAD_IMAGE()));
}