-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
82 lines (65 loc) · 1.9 KB
/
main.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
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
#include <QApplication>
#include <QFileInfo>
#include <QDir>
#include <QDebug>
#include "DropArea.h"
#include "MyGallery.h"
#include "ThumbnailBarItem.h"
#include "Settings.h"
//int main(int argc, char *argv[])
//{
// QGuiApplication app(argc, argv);
// QtQuick2ApplicationViewer viewer;
// viewer.setMainQmlFile(QStringLiteral("qml/MyGallery/main.qml"));
// viewer.showExpanded();
// return app.exec();
//}
int main(int argc, char *argv[])
{
qDebug() << "In the name of God\n"
"MyGallery\n"
"Version 1.0\n"
"Under GPL V3\n"
"Author: Daizhe\n"
"Email: qidaizhe11@gmail.com\n";
QDir cnf_dir("/mnt/sdcard/mygallery");
if (!cnf_dir.exists()) {
cnf_dir.mkpath("/mnt/sdcard/mygallery");
}
QApplication app(argc, argv);
app.setApplicationName("MyGallery");
QStringList args = app.arguments();
if (args.count() == 1) {
args << "/mnt/sdcard/image/";
}
for (int i = 1; i < args.count(); ++i) {
QString argument_str = args.at(1);
if (!QFileInfo(argument_str).isRelative()) {
continue;
}
argument_str = QDir::currentPath() + "/" + argument_str;
args.replace(i, argument_str);
}
MyGallery* window = new MyGallery();
if (args.count() == 2) {
QString argument_str = args.at(1);
QString dir_str = argument_str;
QFileInfo file(argument_str);
if (!file.isDir()) {
dir_str = file.dir().path();
}
window->autoAdd(dir_str,
(argument_str == dir_str) ? QString() : argument_str);
} else {
for (int i = 1; i < args.count(); ++i) {
window->autoAdd(args.at(i));
}
}
QObject::connect(&app, SIGNAL(messageReceived(QString)),
window, SLOT(add(QString)));
window->setWindowIcon(":/pics.icon.png");
window->showFullScreen();
return app.exec();
}