-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoutputnode.cpp
More file actions
50 lines (41 loc) · 1.41 KB
/
outputnode.cpp
File metadata and controls
50 lines (41 loc) · 1.41 KB
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
#include "outputnode.h"
OutputNode::OutputNode(QWidget *parent)
: QWidget(parent)
{
// Create layouts
mainLayout = new QVBoxLayout(this);
// Create title label
titleLabel = new QLabel("Output File", this);
titleLabel->setAlignment(Qt::AlignCenter);
// Create path edit and browse button
QHBoxLayout *pathLayout = new QHBoxLayout();
pathEdit = new QLineEdit(this);
browseButton = new QPushButton("Browse...", this);
pathLayout->addWidget(pathEdit);
pathLayout->addWidget(browseButton);
// Add widgets to layout
mainLayout->addWidget(titleLabel);
mainLayout->addLayout(pathLayout);
// Connections
connect(browseButton, &QPushButton::clicked, this, &OutputNode::selectOutputFile);
connect(pathEdit, &QLineEdit::textChanged, [this](const QString &text) {
output_file = text;
emit fileChanged(text);
});
}
void OutputNode::selectOutputFile()
{
QString filePath = QFileDialog::getSaveFileName(this,
"Select Output File",
QDir::homePath(),
"Images (*.png *.jpg *.jpeg *.bmp)");
if (!filePath.isEmpty()) {
output_file = filePath;
pathEdit->setText(filePath);
emit fileChanged(filePath);
}
}
QString OutputNode::getFilePath() const
{
return output_file;
}