summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f134d76..8f2b6a5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,12 +22,6 @@ void printHelp()
int main(int argc, char *argv[])
{
-
- /* TEST */
-
-
- /* TEST */
-
QApplication app(argc, argv, QApplication::GuiServer);
app.setOrganizationName("team_projekt_2011");
app.setApplicationName("prebootGUI");
@@ -42,11 +36,12 @@ int main(int argc, char *argv[])
/* Parse cmdline argus. */
QMap<QString, QString> clOpts;
int longIndex = 0;
- static const char *optString = "u:hDd:";
+ static const char *optString = "u:d:c:Dh";
static const struct option longOpts[] =
{
{"url", required_argument, NULL, 'u'},
- {"downloaddir", required_argument, NULL, 'd'},
+ {"download", required_argument, NULL, 'd'},
+ {"config", required_argument, NULL, 'c'},
{"debug", no_argument, NULL, 'D'},
{"help", no_argument, NULL, 'h'}
};
@@ -61,10 +56,12 @@ int main(int argc, char *argv[])
case 'd':
clOpts.insert("downloadDir", optarg);
break;
- case 'D':
+ case 'c':
+ clOpts.insert("configFile", optarg);
+ case 'D':
clOpts.insert("debug", "debug");
break;
- case 'h':
+ case 'h':
clOpts.insert("help", "help");
break;
}
@@ -78,8 +75,27 @@ int main(int argc, char *argv[])
debug = true;
qDebug() << "Debug mode activated.";
}
+ 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
+ /* temporary */
+ configFilePath = QApplication::applicationDirPath() + "/fbgui.conf";
+ }
+ }
+ if (debug) qDebug() << "Config file is: " << configFilePath;
+
// Read the config file, for now hardcoded expected name.
- QSettings confFileSettings(app.applicationDirPath() + "/fbgui.conf", QSettings::IniFormat);
+ QSettings confFileSettings(configFilePath, QSettings::IniFormat);
confFileSettings.setIniCodec("UTF-8");
if (clOpts.contains("url")) {
@@ -107,13 +123,16 @@ int main(int argc, char *argv[])
}
else
{
- downloadPath = "/downloads"; // Default download dir.
+ downloadPath = DEFAULT_DOWNLOAD_DIR; // Default download dir.
if (debug) qDebug() << "Download directory set by default.";
}
-
if (debug) qDebug() << "Download directory: " << downloadPath;
+ if (confFileSettings.contains("default/updateInterval")){
+ updateInterval = confFileSettings.value("default/updateInterval").toInt();
+ if (debug) qDebug() << "Read updateInterval from confFile: " << updateInterval;
+ }
+
fbgui gui;
- gui.setAttribute(Qt::WA_QuitOnClose, true);
return app.exec();
}