-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
picturenote.cpp
68 lines (56 loc) · 1.31 KB
/
picturenote.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "picturenote.h"
#include <QClipboard>
#include <QApplication>
#include <QLabel>
#include <QScrollArea>
#include <QPicture>
#include <QMessageBox>
PictureNote::PictureNote(const QFileInfo& fileinfo, Note::Type type_new)
: Note(fileinfo, type_new)
{
label = new QLabel();
label->setScaledContents(true);
scroll_area = new QScrollArea;
scroll_area->setWidget(label);
load(); //loading note's content
}
PictureNote::~PictureNote()
{
label->deleteLater();
scroll_area->deleteLater();
}
//Reading file
void PictureNote::load()
{
file.close();
QImage image(file.fileName());
label->setPixmap(QPixmap::fromImage(image));
label->adjustSize();
}
//Saving note
void PictureNote::save(bool forced)
{
if(!(content_changed || forced)) return; //If file doesn't need in saving, exiting from function
file.close();
//label->picture()->save(file.fileName()); //TODO: this is readonly now
content_changed = false;
}
//Returning widget (it's can be placed to tabwidget)
QWidget* PictureNote::widget()
{
return scroll_area;
}
//Coping note's content to clipboard
void PictureNote::copy() const
{
QClipboard* clipboard = QApplication::clipboard();
clipboard->setPixmap(*label->pixmap());
}
bool PictureNote::isDocumentSupported() const
{
return false;
}
QTextDocument* PictureNote::document() const
{
return 0;
}