summaryrefslogtreecommitdiffstats
path: root/src/fbgui.cpp
blob: 6b70214ed7ad85541b68859f96d645b62dc91fe8 (plain) (blame)
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
#include "fbgui.h"
#include "CommandLineOptions.h"
#include "fbbrowser.h"
#include "DownloadManager.h"

#include <QApplication>
#include <QSettings>
#include <QUrl>

void printUsage()
{
    // Prints usage information.
	// TODO: Complete usage info.
    QTextStream qout(stdout); 
    qout << QObject::tr("Usage: ./fbgui [OPTIONS] <URL>") << endl;
    qout << QObject::tr("Options:") << endl;
    qout << "-h or --help " << QObject::tr("Prints usage information.") << endl;
    qout << "-qws         " << QObject::tr("Set this application to also be the server application.")  << endl;
    qout << "             " << QObject::tr("Skip this option if you have a QT server application") << endl;
    exit(1);
}

int main(int argc, char *argv[])
{


    // This is the main object of a QT Application.
    QApplication a(argc, argv);

	/*  SETTINGS TEST  */
	CommandLineOptions clOptions(argc, argv);
	QUrl url;
	if (clOptions.contains("url"))
	{
		qDebug() << "URL from clOptions is: " << clOptions.value("url");
		url = clOptions.value("url");
	}
	else
		url = QUrl("qrc:/html/errorPage.html");
	// TODO: parse url arg from CommmandLineOptions object.

	/*  SETTINGS TEST  */


    // Get the application path and prints on screen.
    qDebug() << "Application Path: " << a.applicationDirPath();
    // Is this really needed, since we kill the app through the fbbrowser object?
    QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));

    // Create a new Framebuffer-Browser object for displaying the given URL.
    fbbrowser* fbb = new fbbrowser(url);

    // Listen to the signalQuitAll() Signal to kill the app from within the browser.
    QObject::connect(fbb, SIGNAL(killApp()), &a, SLOT(quit()));

    // Display the browser.
    fbb->show();

    // Execute the application.
    return a.exec();
}