summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-24 16:04:09 +0100
committerJonathan Bauer2011-03-24 16:04:09 +0100
commit0947d4577949dd34282701e78c2f500b1a1b20f5 (patch)
tree805c1e8715e6841d668bcce29f6d6384f461da09 /src
parentseparated debug console creation and layout setup (diff)
downloadfbgui-0947d4577949dd34282701e78c2f500b1a1b20f5.tar.gz
fbgui-0947d4577949dd34282701e78c2f500b1a1b20f5.tar.xz
fbgui-0947d4577949dd34282701e78c2f500b1a1b20f5.zip
auto-ident ?
Diffstat (limited to 'src')
-rw-r--r--src/fbgui.cpp12
-rw-r--r--src/main.cpp229
2 files changed, 122 insertions, 119 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index bc92515..a155616 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -9,13 +9,14 @@
#include <QtWebKit>
#include <QxtCore>
-QString serialLocation("");
-QString fileToTriggerURL("");
-QString sessionID("");
-QUrl baseURL("");
+
QString binPath("");
+QUrl baseURL("");
QString downloadPath("");
int updateInterval = -1;
+QString fileToTriggerURL("");
+QString serialLocation("");
+QString sessionID("");
int debugMode = -1;
//-------------------------------------------------------------------------------------------
@@ -217,7 +218,8 @@ void fbgui::setupBasicDebug()
}
}
//-------------------------------------------------------------------------------------------
-void fbgui::createDebugConsole(){
+void fbgui::createDebugConsole()
+{
// create the debug console widget
_debugConsole = new QTextEdit(this);
_debugConsole->setWindowFlags(Qt::FramelessWindowHint);
diff --git a/src/main.cpp b/src/main.cpp
index 514d124..a6dc1b2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -8,135 +8,136 @@
void printHelp()
{
- QTextStream qout(stdout);
- qout << QObject::tr("Usage: ./fbgui [OPTIONS]") << endl;
- qout << QObject::tr("Options:") << endl;
- qout << "-u <URL>, --url=<URL> " << QObject::tr("Set which URL to load.") << endl;
- qout << "-d <dir>, --download=<dir> " << QObject::tr("Specify the download directory.") << endl;
- qout << "-c <path>, --config=<path> " << QObject::tr("Path to config file.") << endl;
- qout << "-D <level>, --debug=<level> " << QObject::tr("Activate debug mode.") << endl;
- qout << "-h, --help " << QObject::tr("Prints usage information.") << endl;
- qout.flush();
- exit(EXIT_SUCCESS);
+ QTextStream qout(stdout);
+ qout << QObject::tr("Usage: ./fbgui [OPTIONS]") << endl;
+ qout << QObject::tr("Options:") << endl;
+ qout << "-u <URL>, --url=<URL> " << QObject::tr("Set which URL to load.") << endl;
+ qout << "-d <dir>, --download=<dir> " << QObject::tr("Specify the download directory.") << endl;
+ qout << "-c <path>, --config=<path> " << QObject::tr("Path to config file.") << endl;
+ qout << "-D <level>, --debug=<level> " << QObject::tr("Activate debug mode.") << endl;
+ qout << "-h, --help " << QObject::tr("Prints usage information.") << endl;
+ qout.flush();
+ exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
{
- QApplication app(argc, argv, QApplication::GuiServer);
- app.setOrganizationName("team_projekt_2011");
- app.setApplicationName("prebootGUI");
- binPath = QApplication::applicationDirPath();
+ QApplication app(argc, argv, QApplication::GuiServer);
+ app.setOrganizationName("team_projekt_2011");
+ app.setApplicationName("prebootGUI");
+ binPath = QApplication::applicationDirPath();
- QTranslator translator;
- translator.load(":" + QLocale::system().name());
- app.installTranslator(&translator);
+ QTranslator translator;
+ translator.load(":" + QLocale::system().name());
+ app.installTranslator(&translator);
- // parse command line arguments
- QMap<QString, QString> clOpts;
- int longIndex = 0;
- static const char *optString = "c:u:d:s:t:D:h";
- static const struct option longOpts[] =
- {
- {"config", required_argument, NULL, 'c'},
- {"url", required_argument, NULL, 'u'},
- {"download", required_argument, NULL, 'd'},
- {"serial", required_argument, NULL, 's'},
- {"trigger", required_argument, NULL, 't'},
- {"debug", required_argument, NULL, 'D'},
- {"help", no_argument, NULL, 'h'}
- };
- int opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
- while (opt != -1)
- {
- switch(opt)
- {
- case 'c':
- clOpts.insert("configFile", optarg);
- break;
- case 'u':
- clOpts.insert("url", optarg);
- break;
- case 'd':
- clOpts.insert("downloadDir", optarg);
- break;
- case 's':
- clOpts.insert("serialLocation", optarg);
- break;
- case 't':
- clOpts.insert("trigger", optarg);
- break;
- case 'D':
- clOpts.insert("debug", optarg);
- break;
- case 'h':
- clOpts.insert("help", "help");
- break;
- }
- opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
- }
+ // parse command line arguments
+ QMap<QString, QString> clOpts;
+ int longIndex = 0;
+ static const char *optString = "c:u:d:s:t:D:h";
+ static const struct option longOpts[] =
+ {
+ {"config", required_argument, NULL, 'c'},
+ {"url", required_argument, NULL, 'u'},
+ {"download", required_argument, NULL, 'd'},
+ {"serial", required_argument, NULL, 's'},
+ {"trigger", required_argument, NULL, 't'},
+ {"debug", required_argument, NULL, 'D'},
+ {"help", no_argument, NULL, 'h'}
+ };
+ int opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
+ while (opt != -1)
+ {
+ switch(opt)
+ {
+ case 'c':
+ clOpts.insert("configFile", optarg);
+ break;
+ case 'u':
+ clOpts.insert("url", optarg);
+ break;
+ case 'd':
+ clOpts.insert("downloadDir", optarg);
+ break;
+ case 's':
+ clOpts.insert("serialLocation", optarg);
+ break;
+ case 't':
+ clOpts.insert("trigger", optarg);
+ break;
+ case 'D':
+ clOpts.insert("debug", optarg);
+ break;
+ case 'h':
+ clOpts.insert("help", "help");
+ break;
+ }
+ opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
+ }
- if (clOpts.contains("help"))
- printHelp();
+ if (clOpts.contains("help"))
+ printHelp();
- if (clOpts.contains("debug"))
- debugMode = clOpts.value("debug").toInt();
- else
- debugMode = -1;
+ if (clOpts.contains("debug"))
+ debugMode = clOpts.value("debug").toInt();
+ else
+ debugMode = -1;
- // look for config file
- QString configFilePath;
- QFileInfo confInfo;
- if (clOpts.contains("configFile"))
- configFilePath = clOpts.value("configFile");
- else {
- confInfo = QFileInfo(QDir::home(), ".fbgui.conf");
- if (confInfo.exists())
- configFilePath = confInfo.absoluteFilePath();
- else {
- confInfo = QFileInfo(QString("/etc/fbgui.conf"));
- if (confInfo.exists())
- configFilePath = QString("/etc/fbgui.conf");
- else
- configFilePath = DEFAULT_CONFIG_PATH;
- }
- }
+ // look for config file
+ QString configFilePath;
+ QFileInfo confInfo;
+ if (clOpts.contains("configFile"))
+ configFilePath = clOpts.value("configFile");
+ else {
+ confInfo = QFileInfo(QDir::home(), ".fbgui.conf");
+ if (confInfo.exists())
+ configFilePath = confInfo.absoluteFilePath();
+ else {
+ confInfo = QFileInfo(QString("/etc/fbgui.conf"));
+ if (confInfo.exists())
+ configFilePath = QString("/etc/fbgui.conf");
+ else
+ configFilePath = DEFAULT_CONFIG_PATH;
+ }
+ }
- // read the config file
- QSettings confFileSettings(configFilePath, QSettings::IniFormat);
- confFileSettings.setIniCodec("UTF-8");
+ // read the config file
+ QSettings confFileSettings(configFilePath, QSettings::IniFormat);
+ confFileSettings.setIniCodec("UTF-8");
- if (clOpts.contains("url")) {
- baseURL = QUrl(clOpts.value("url"));
- }
- else if (confFileSettings.contains("default/pbs_url")) {
- baseURL = confFileSettings.value("default/pbs_url").toUrl();
- }
- else {
- baseURL = DEFAULT_URL;
- }
+ // set base URL to be loaded
+ if (clOpts.contains("url")) {
+ baseURL = QUrl(clOpts.value("url"));
+ }
+ else if (confFileSettings.contains("default/pbs_url")) {
+ baseURL = confFileSettings.value("default/pbs_url").toUrl();
+ }
+ else {
+ baseURL = DEFAULT_URL;
+ }
- // setting directory for downloads
- if (clOpts.contains("downloadDir")){
- downloadPath = clOpts.value("downloadDir");
- }
- else if (confFileSettings.contains("default/download_directory")){
- downloadPath = confFileSettings.value("default/download_directory").toString();
- }
- else
- downloadPath = DEFAULT_DOWNLOAD_DIR;
+ // set directory for downloads
+ if (clOpts.contains("downloadDir")){
+ downloadPath = clOpts.value("downloadDir");
+ }
+ else if (confFileSettings.contains("default/download_directory")){
+ downloadPath = confFileSettings.value("default/download_directory").toString();
+ }
+ else
+ downloadPath = DEFAULT_DOWNLOAD_DIR;
if (confFileSettings.contains("default/update_interval")){
updateInterval = confFileSettings.value("default/update_interval").toInt();
}
else updateInterval = DEFAULT_UPDATE_INTERVAL;
- // sets which file to watch to trigger loading of URL
- if (clOpts.contains("trigger"))
- fileToTriggerURL = clOpts.value("trigger");
- else if (confFileSettings.contains("default/file_trigger"))
- fileToTriggerURL = confFileSettings.value("default/file_trigger").toString();
- else
- fileToTriggerURL = DEFAULT_FILE_TRIGGER;
+ // sets which file to watch to trigger loading of URL
+ if (clOpts.contains("trigger"))
+ fileToTriggerURL = clOpts.value("trigger");
+ else if (confFileSettings.contains("default/file_trigger"))
+ fileToTriggerURL = confFileSettings.value("default/file_trigger").toString();
+ else
+ fileToTriggerURL = DEFAULT_FILE_TRIGGER;
// set serial location
if (clOpts.contains("serialLocation"))
@@ -156,7 +157,7 @@ int main(int argc, char *argv[])
qDebug() << "*******************************************";
// start fbgui
- fbgui gui;
- gui.show();
- return app.exec();
+ fbgui gui;
+ gui.show();
+ return app.exec();
}