int main(int argc, char *argv[]) { qInstallMsgHandler(myMessageOutput); QApplication a(argc, argv); MainWindow w; #ifdef WINDOWS purgeLogfile(); #endif QVariant url; url = _get("url"); if (url.isNull() != true && url.toString() != "") { w.to_url = url.toString(); } else { w.to_url = "file:///C:/Users/ayon/Documents/GitHub/qushie-app/index.html"; } w.Init(); w.show(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QApplication::setApplicationName("popcorn"); QApplication::setApplicationVersion(QString::number(VERSION_MAJOR) + "." + QString::number(VERSION_MINOR) + "." + QString::number(VERSION_PATCH)); #ifdef Q_OS_LINUX home_path = QDir::homePath() + "/.config/popcorn/"; #else home_path = QDir::homePath() + "/popcorn/"; #endif QDir().mkpath(home_path); QCommandLineOption ini_file_option("c", "Configuration file to use", "ini_file", home_path + "/popcorn.ini"); QCommandLineOption index_file_option("i", "Index file (.html) to load", "index_file"); QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); parser.addOption(ini_file_option); parser.addOption(index_file_option); parser.process(a); #ifdef Q_OS_LINUX display = XOpenDisplay(NULL); #endif application_path = QFileInfo(QCoreApplication::applicationFilePath()).canonicalPath() + "/"; QString ini_file = parser.value(ini_file_option); settings = new QSettings(ini_file, QSettings::IniFormat); qDebug() << "[main]: ini file is" << settings->fileName(); QString filespath = QDir::homePath() + "/popcorn-files/"; if (!settings->contains("window_title")) settings->setValue("window_title", "Popcorn Popup"); if (!settings->contains("webinspector")) settings->setValue("webinspector", "false"); if (!settings->contains("jail_working")) settings->setValue("jail_working", filespath); if (!settings->contains("fileread_jailed")) settings->setValue("fileread_jailed", "true"); if (!settings->contains("log_to_file")) settings->setValue("log_to_file", "false"); if (!settings->contains("log_to_stdout")) settings->setValue("log_to_stdout", "false"); if (!settings->contains("context_menu")) settings->setValue("context_menu", "true"); if (!settings->contains("log_threshold")) settings->setValue("log_threshold", 0); if (!settings->contains("index_file")) settings->setValue("index_file", ""); jail_working_path = settings->value("jail_working").toString(); QDir().mkpath(jail_working_path); if (!settings->value("jail_working").toString().endsWith("/")) { jail_working_path.append("/"); settings->setValue("jail_working", jail_working_path); } purgeLogfile(); if (settings->value("log_to_file").toString() == "true") { qInstallMessageHandler(logToFile); } else if (settings->value("log_to_stdout").toString() == "true") { qInstallMessageHandler(logToStdout); } else { qDebug() << "[main]: Logging disabled. Enable log_to_file or log_to_stdout in ini file."; qInstallMessageHandler(noLog); } settings->setValue("exit", "false"); // this tells us if the program has crashed or exited normally MainWindow w; w.init(parser.value(index_file_option)); w.show(); return a.exec(); }