-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainwindow.cpp
53 lines (48 loc) · 1.36 KB
/
mainwindow.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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QKeyEvent"
#include "QFileDialog"
#include "functions/grayscale.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->connect(this, SIGNAL(LeftKey()), ui->OGLCanvas, SLOT(LeftKey()));
this->connect(this, SIGNAL(RightKey()), ui->OGLCanvas, SLOT(RightKey()));
this->connect(this, SIGNAL(SetDirectory(QString)), ui->OGLCanvas, SLOT(SetDirectory(QString)));
ui->OGLCanvas->InitializeMenu(ui->menuBar);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::OpenFileExplorer() {
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::Directory);
if(dialog.exec()) {
auto selected = dialog.selectedFiles();
QString dirPath = selected[0];
emit SetDirectory(dirPath);
}
}
void MainWindow::keyPressEvent(QKeyEvent *keyEvent) {
switch (keyEvent->key()) {
case Qt::Key_Left:
emit LeftKey();
break;
case Qt::Key_Right:
emit RightKey();
break;
case Qt::Key_F11:
// how to hide widgets?
emit showFullScreen();
break;
case Qt::Key_F10:
emit showNormal();
break;
default:
QWidget::keyPressEvent(keyEvent);
break;
};
}