-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileSelector.cpp
90 lines (80 loc) · 2.41 KB
/
FileSelector.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
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
84
85
86
87
88
89
90
/*
* File: FileSelector.cpp
* Author: rukshan
*
* Created on September 7, 2013, 11:25 PM
*/
#include "FileSelector.h"
#include <iostream>
using namespace std;
FileSelector::FileSelector() {
}
FileSelector::~FileSelector() {
}
void FileSelector::openFile() {
// QFileDialog::getOpenFileName(this, tr("Open Document"), QDir::currentPath(), tr("Document files (*.mp4 *.flv);;All files (*.*)"), 0, QFileDialog::DontUseNativeDialog);
QString filename = QFileDialog::getOpenFileName(
this,
tr("Open Document"),
QDir::currentPath(),
tr("Media files (*.mp4 *.flv);;Document files (*.doc *.rtf);;All files (*.*)"));
if (!filename.isNull()) {
// qDebug(filename.toAscii());
dataObject ob;
ob.object = "file_selector_open";
ob.val=0;
ob.msg = filename.toStdString();
Notify(ob);
// cout<<filename.toStdString()<<endl;
}
}
void FileSelector::openSubFile(){
QString filename = QFileDialog::getOpenFileName(
this,
tr("Open Document"),
QDir::currentPath(),
tr("Subtitle files (*.srt *.ass);;All files (*.*)"));
if (!filename.isNull()) {
dataObject ob;
ob.object = "file_selector_open";
ob.val=1;
ob.msg = filename.toStdString();
Notify(ob);
}
}
void FileSelector::openFiles() {
QStringList filenames = QFileDialog::getOpenFileNames(
this,
tr("Open Document"),
QDir::currentPath(),
tr("Documents (*.doc);;All files (*.*)"));
if (!filenames.isEmpty()) {
qDebug(filenames.join(",").toAscii());
}
}
void FileSelector::openDir() {
QString dirname = QFileDialog::getExistingDirectory(
this,
tr("Select a Directory"),
QDir::currentPath());
if (!dirname.isNull()) {
qDebug(dirname.toAscii());
}
}
void FileSelector::saveFile() {
QString filename = QFileDialog::getSaveFileName(
this,
tr("Save Document"),
QDir::currentPath(),
tr("srt (*.srt);;ssa (*.ssa)"));
// if(filename.endsWith(".srt",Qt::CaseInsensitive)){
// cout<<"srt"<<endl;
// }
if (!filename.isNull()) {
dataObject ob;
ob.object = "file_selector_save";
ob.msg = filename.toStdString();
Notify(ob);
qDebug(filename.toAscii());
}
}