void qMessageOutput(QtMsgType, const QMessageLogContext &, const QString &);
void loadSkinFormFromXML(QFile *, UIInformation *);
void loadControllerFormFromXML(QFile *, UIInformation *);
+int getControlIndex();
+int getPriority(QFile *file);
QApplication *qt5App = NULL;
static MainWindow *mainwindow;
static UIInformation *uiInfo;
+#define CONTROL_PRIORITY_MAX 10
#define FORM_FILE_NAME "layout.qml"
#define CON_FORM_SUBPATH "controller"
// mainwindow->move(100, 100); // TODO: MRU
mainwindow->show();
- mainwindow->openController(0);
+ mainwindow->openController(getControlIndex());
mainwindow->startSwapper();
}
delete component;
delete engine;
}
+
+int getControlIndex()
+{
+ int controlIndex = 0;
+ int controlPriority = 0;
+ int priority = CONTROL_PRIORITY_MAX;
+
+ if (!uiInfo)
+ return controlIndex;
+
+ /* find high priority*/
+ QString line;
+ QDir skinDir(uiInfo->skinPath + CON_FORM_SUBPATH);
+ QFileInfoList entries = skinDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ for (int i = 0; i < entries.size(); i++) {
+ QFile iniFile(entries.at(i).filePath() + QDir::separator() + "info.ini");
+ if (iniFile.exists()) {
+ controlPriority = getPriority(&iniFile);
+ if (controlPriority < priority) {
+ controlIndex = i;
+ priority = controlPriority;
+ }
+ }
+ }
+
+ return controlIndex;
+}
+
+int getPriority(QFile *file)
+{
+ int priority = CONTROL_PRIORITY_MAX;
+ QRegExp rx("=");
+
+ /* read priority in info.ini file */
+ if (file->open(QFile::ReadOnly)) {
+ QTextStream in(file);
+ do {
+ QString line = in.readLine();
+ QStringList list = line.split(rx, QString::SkipEmptyParts);
+ if (QString::compare(list.at(0), "priority", Qt::CaseInsensitive) == 0) {
+ priority = list.at(1).toInt();
+ }
+ } while(!in.atEnd());
+ file->close();
+ }
+
+ return priority;
+}