-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
36 lines (30 loc) · 1.31 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
// main.cpp: the FileInsight launcher
#include "fileinsight.h"
#include <QApplication>
#include <QCommandLineParser>
static QString ICON_NAME = "search";
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication::setApplicationName("FileInsight");
QCoreApplication::setApplicationVersion("0.3.2-dev");
// Handle command line arguments such as --help and an optional filename list
QCommandLineParser parser;
parser.setApplicationDescription(QCoreApplication::translate("main", "FileInsight is a file type analyzer using libmagic and TrID as backends."));
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument(QCoreApplication::translate("main", "files"), QCoreApplication::translate("main",
"Optional list of filenames to open."), "[filenames...]");
parser.process(a);
FileInsight w;
QStringList args = parser.positionalArguments();
// If we're given filenames on the command line, open and spawn a new tab for each.
for (int i=0; i < args.count(); i++) {
w.openFile(args[i], false);
}
// Set an icon for the program. For now we're lazily using the "Search" icon of the
// current theme...
w.setWindowIcon(QIcon::fromTheme(ICON_NAME));
w.show();
return a.exec();
}