-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
83 lines (62 loc) · 2.61 KB
/
mainwindow.cpp
File metadata and controls
83 lines (62 loc) · 2.61 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "fxwidget.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowTitle("Visual Effects Qt");
effectsBox = new QComboBox(this);
foreach(QString fx, ui->fxwidget->fxList())
effectsBox->addItem(fx);
playPauseButton = new QPushButton(this);
decreaseRefreshButton = new QPushButton(this);
decreaseRefreshButton->setText("-");
increaseRefreshButton = new QPushButton(this);
increaseRefreshButton->setText("+");
updateIntervalLabel = new QLabel(this);
updateIntervalLabel->setMinimumWidth(20);
updateIntervalLabel->setAlignment(Qt::AlignCenter);
//updateIntervalLabel->setStyleSheet("QLabel{color: white;}");
ui->mainToolBar->addWidget(effectsBox);
ui->mainToolBar->addSeparator();
ui->mainToolBar->addWidget(playPauseButton);
ui->mainToolBar->addSeparator();
ui->mainToolBar->addWidget(decreaseRefreshButton);
ui->mainToolBar->addWidget(updateIntervalLabel);
ui->mainToolBar->addWidget(increaseRefreshButton);
connect(effectsBox, SIGNAL(currentIndexChanged(int)), ui->fxwidget, SLOT(onEffectSelected(int)));
connect(playPauseButton, &QPushButton::pressed, ui->fxwidget, &FxWidget::onPlayPausePressed);
connect(decreaseRefreshButton, &QPushButton::released, ui->fxwidget, &FxWidget::onDecreaseIntervalPressed);
connect(increaseRefreshButton, &QPushButton::released, ui->fxwidget, &FxWidget::onIncreaseIntervalPressed);
connect(ui->fxKindBox, SIGNAL(currentIndexChanged(int)), ui->fxwidget, SLOT(onFxKindSelected(int)));
connect(ui->fxwidget, &FxWidget::statusUpdated, this, &MainWindow::onStatusUpdated);
connect(ui->fxwidget, &FxWidget::paramsUpdated, this, &MainWindow::onParamsUpdated);
onStatusUpdated();
onParamsUpdated();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::onStatusUpdated()
{
playPauseButton->setText(ui->fxwidget->isRunning() ? "Pause" : "Play");
playPauseButton->setEnabled((ui->fxwidget->updateInterval() > 0) ? true : false);
updateIntervalLabel->setText(QString("%1").arg(ui->fxwidget->updateInterval()));
}
void MainWindow::onParamsUpdated()
{
QPair<int, QVector<QString>> paramsString = ui->fxwidget->fxKindList();
ui->fxKindBox->clear();
if (!paramsString.second.isEmpty()) {
foreach(QString param, paramsString.second)
ui->fxKindBox->addItem(param);
ui->fxKindBox->setCurrentIndex(paramsString.first);
ui->fxKindBox->setEnabled(true);
}
else {
ui->fxKindBox->setEnabled(false);
}
}