diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CommandLineOptions.cpp | 6 | ||||
| -rw-r--r-- | src/CommandLineOptions.h | 8 | ||||
| -rw-r--r-- | src/fbgui.cpp | 22 | ||||
| -rwxr-xr-x | src/testApp.sh | 4 |
4 files changed, 31 insertions, 9 deletions
diff --git a/src/CommandLineOptions.cpp b/src/CommandLineOptions.cpp index 06b00ae..3b1fbd1 100644 --- a/src/CommandLineOptions.cpp +++ b/src/CommandLineOptions.cpp @@ -2,12 +2,15 @@ * This class parses the command line options. */ - +#include <QDebug> #include <getopt.h> #include <cstdlib> #include "CommandLineOptions.h" CommandLineOptions::CommandLineOptions(int argc, char * const argv[]){ + qDebug() << "Received " << argc << "arguments."; + for (int i = argc; i != 0; i--) + qDebug() << i << " argument: " << argv[i]; // Parse command line arguments. int longIndex = 0; // TODO: clean output... @@ -26,6 +29,7 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]){ switch(opt) { case 'u': + qDebug() << "Added URL to clOptions:" << optarg; options.insert("url", optarg); break; case 'h': diff --git a/src/CommandLineOptions.h b/src/CommandLineOptions.h index e75a690..dc56d34 100644 --- a/src/CommandLineOptions.h +++ b/src/CommandLineOptions.h @@ -8,6 +8,14 @@ class CommandLineOptions { public: CommandLineOptions(int argc, char * const argv[]); ~CommandLineOptions(); + + bool contains(const QString& key) const { + return options.contains(key); + } + + QString value(const QString& key) const { + return options.value(key); + } private: QMap<QString, QString> options; }; diff --git a/src/fbgui.cpp b/src/fbgui.cpp index cc10f20..6b70214 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -5,6 +5,7 @@ #include <QApplication> #include <QSettings> +#include <QUrl> void printUsage() { @@ -21,19 +22,26 @@ void printUsage() 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. - // hackfix for now... - QUrl url = QUrl(argv[4]); - QUrl defaultUrl = QUrl("http://132.230.4.3/webkitTest.html"); - qDebug() << "URL given: " << url.toString(); /* SETTINGS TEST */ - // This is the main object of a QT Application. - QApplication a(argc, argv); + // 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? diff --git a/src/testApp.sh b/src/testApp.sh index fc2bf05..81093d7 100755 --- a/src/testApp.sh +++ b/src/testApp.sh @@ -18,7 +18,9 @@ display_id=$(grep -n $(whoami) /etc/passwd| head -n 1|awk -F : '{print $1}') sleep 1 # Start the fbbrowser app. # This requires the fbgui git repository to be in the user's home directory. -$working_path/fbgui -qws -display QVFb:$display_id $url +echo "fbgui call:" +echo "$working_path/fbgui -qws -display QVFb:$display_id -u $url" +$working_path/fbgui -qws -display QVFb:$display_id --url=$url # Check if fbbrowser is not running, if so kill the qvfb. if [ $(ps aux | grep -v grep | grep -c fbgui) -eq 1 ] then |
