-
Notifications
You must be signed in to change notification settings - Fork 1
/
processEvents.cpp
41 lines (36 loc) · 1.19 KB
/
processEvents.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
#include "mainwindow.h"
void MainWindow::dragEnterEvent(QDragEnterEvent* event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
}
}
void MainWindow::dropEvent(QDropEvent* event) {
QFileInfo url(event->mimeData()->urls()[0].toLocalFile());
if (url.isDir()) type = "dir";
else {
QMimeDatabase db;
type = db.mimeTypeForFile(url).name();
type.erase(type.begin() + type.indexOf('/'), type.end());
}
if (type == "image" || type == "video" || type == "dir") {
fi = url;
setup();
}
else {
QMessageBox msg(QMessageBox::Warning, "Warning!!!", "The input file format is unsupported", QMessageBox::Ok);
msg.setStyleSheet("QPushButton{height: 25px}");
msg.exec();
}
}
void MainWindow::closeEvent(QCloseEvent* event) {
QMessageBox msg(QMessageBox::Question, "Confirmation", "Do you want to close?\n", QMessageBox::Yes | QMessageBox::No);
msg.setStyleSheet("QPushButton{height: 25px}");
if (msg.exec() == QMessageBox::Yes) {
if (process != NULL) {
process->kill();
delete process;
}
event->accept();
}
else event->ignore();
}