-
Notifications
You must be signed in to change notification settings - Fork 8
/
basicimagewidget.cpp
74 lines (62 loc) · 1.77 KB
/
basicimagewidget.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
69
70
71
72
73
#include "basicimagewidget.h"
#include "imagefiledialog.h"
#include <QSettings>
#include <QString>
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5,15,1)
#define WEBP_FILTER " *.webp *.WEBP"
#else
#define WEBP_FILTER ""
#endif
BasicImageWidget::BasicImageWidget()
{
m_parent=0;
}
void BasicImageWidget::saveAsImage()
{
if (!imdata.isNull())
{
QSettings settings;
QString cdir=settings.value(folderSettings,folderSettings).toString();
ImageFileDialog dlg(m_parent);
dlg.init();
dlg.setFileMode( QFileDialog::AnyFile);
dlg.setAcceptMode(QFileDialog::AcceptSave);
dlg.setDirectory(cdir);
dlg.setNameFilter("Images (*.png *.xpm *.jpg *.jpeg *.bmp *.tiff *.tif *.PNG *.XPM *.JPG *.JPEG *.BMP *.TIF *.TIFF" WEBP_FILTER ")");
dlg.setWindowTitle("Save "+saveTitle);
QString fileName;
imdata=imdata.convertToFormat(QImage::Format_ARGB32);
if (dlg.exec())
{
fileName = dlg.selectedFiles().first();
settings.setValue(folderSettings, QFileInfo(fileName).absoluteDir().absolutePath());
if (!imdata.save(fileName))
{//probably no file type was supplied...
fileName.append(".png");
imdata.save(fileName);
}
}
dlg.deinit();
}
}
void BasicImageWidget::setFolderSettings(const QString & fsetting)
{
folderSettings=fsetting;
}
void BasicImageWidget::setFolderSettings(const char * fsetting)
{
folderSettings=fsetting;
}
void BasicImageWidget::setSaveTitle(const QString& stitle)
{
saveTitle=stitle;
}
void BasicImageWidget::setSaveTitle(const char * stitle)
{
saveTitle=stitle;
}
void BasicImageWidget::setBasicImageParent(QWidget *p)
{
m_parent=p;
}