19 #include <QGridLayout> 21 #include <QDialogButtonBox> 22 #include <QPushButton> 24 #include <QDesktopWidget> 25 #include <QApplication> 27 #include <QMessageBox> 31 #include "data/fileio/FileSource.h" 41 m_imagePreview(nullptr),
44 setWindowTitle(title);
46 QGridLayout *grid =
new QGridLayout;
49 QGroupBox *databox =
new QGroupBox(tr(
"Image"));
51 QGridLayout *subgrid =
new QGridLayout;
52 databox->setLayout(subgrid);
56 subgrid->addWidget(
new QLabel(tr(
"Label:")), row, 0);
63 subgrid->addWidget(
new QLabel(tr(
"File or URL:")), row, 0);
68 connect(
m_imageEdit, SIGNAL(textEdited(
const QString &)),
73 QPushButton *browse =
new QPushButton(tr(
"Browse..."));
74 connect(browse, SIGNAL(clicked()),
this, SLOT(
browseClicked()));
75 subgrid->addWidget(browse, row, 2, 1, 1);
79 QGroupBox *previewbox =
new QGroupBox(tr(
"Preview"));
81 subgrid =
new QGridLayout;
82 previewbox->setLayout(subgrid);
90 QDesktopWidget *desktop = QApplication::desktop();
92 (desktop->height() * 2) / 3));
94 grid->addWidget(databox, 0, 0);
95 grid->addWidget(previewbox, 1, 0);
97 grid->setRowStretch(1, 10);
99 QDialogButtonBox *bb =
new QDialogButtonBox(QDialogButtonBox::Ok |
100 QDialogButtonBox::Cancel);
101 grid->addWidget(bb, 2, 0, 1, 1);
102 connect(bb, SIGNAL(accepted()),
this, SLOT(accept()));
103 connect(bb, SIGNAL(rejected()),
this, SLOT(reject()));
105 m_okButton = bb->button(QDialogButtonBox::Ok);
157 if (s.startsWith(
"http:") || s.startsWith(
"ftp:")) {
180 QString fileName = img;
184 if (FileSource::isRemote(fileName)) {
186 if (!FileSource::canHandleScheme(url)) {
187 QMessageBox::critical(
this, tr(
"Unsupported scheme in URL"),
188 tr(
"The URL scheme \"%1\" is not supported")
196 QMessageBox::critical(
this, tr(
"File download failed"),
197 tr(
"Failed to download URL \"%1\": %2")
198 .arg(url.toString()).arg(
m_remoteFile->getErrorString()));
223 Qt::SmoothTransformation));
void setLabel(QString label)
void setImage(QString image)
QString getOpenFileName(FileType type, QString fallbackLocation="") override
FileSource * m_remoteFile
void imageChanged(QString image)
ImageDialog(QString title, QString image="", QString label="", QWidget *parent=0)
void resizeEvent(QResizeEvent *) override
QString m_loadedImageFile
static InteractiveFileFinder * getInstance()