-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain_window.cpp
More file actions
56 lines (48 loc) · 1.72 KB
/
main_window.cpp
File metadata and controls
56 lines (48 loc) · 1.72 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
51
52
53
54
55
56
#include "main_window.h"
#include <QDebug>
#include <QFileDialog>
#include <QMessageBox>
#include "./ui_main_window.h"
#include "viewer.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
setWindowTitle("YUVViewer");
QVariant v;
v.setValue(YUVType::YUV420P);
ui->comboBox->addItem("YUV420P", v);
v.setValue(YUVType::YUV420P2GRAY);
ui->comboBox->addItem("YUV420P2GRAY", v);
v.setValue(YUVType::YUV420PBrightnessHalf);
ui->comboBox->addItem("YUV420PBrightnessHalf", v);
v.setValue(YUVType::SINGLE_Y);
ui->comboBox->addItem("Single Y", v);
v.setValue(YUVType::SINGLE_U);
ui->comboBox->addItem("Single U", v);
v.setValue(YUVType::SINGLE_V);
ui->comboBox->addItem("Single V", v);
}
MainWindow::~MainWindow() { delete ui; }
void MainWindow::on_selectionButton_clicked() {
_attr._name = QFileDialog::getOpenFileName(this, "选择要显示的文件", "./")
.toStdString();
qDebug() << "file name: " << QString{_attr._name.c_str()};
auto widthStr = ui->widthEdit->text();
auto heightStr = ui->heightEdit->text();
if (widthStr.isEmpty() || heightStr.isEmpty()) {
QMessageBox::warning(this, "警告", "请输入图片的宽高!");
return;
}
_attr._width = widthStr.toInt();
_attr._height = heightStr.toInt();
qDebug() << "width: " << _attr._width;
qDebug() << "height: " << _attr._height;
Viewer *viewer = new Viewer();
viewer->showPicture(_attr);
viewer->show();
}
void MainWindow::on_comboBox_currentIndexChanged(int index) {
qDebug() << "current index: " << ui->comboBox->currentIndex();
qDebug() << "current text: " << ui->comboBox->currentText();
_attr._type = ui->comboBox->currentData().value<YUVType>();
}