controller: set default controller 80/29080/2
authorhyunjin816.lee <hyunjin816.lee@samsung.com>
Wed, 24 Sep 2014 07:44:06 +0000 (16:44 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 22 Oct 2014 04:48:19 +0000 (21:48 -0700)
set default controller using by priority in info.ini file

Change-Id: Ide8861b5cc878ec70ef49180a32ef243c1bc6ad1
Signed-off-by: hyunjin816.lee <hyunjin816.lee@samsung.com>
tizen/src/display/qt5_supplement.cpp

index 9b895717cc5dfec7429446405b321cb7b6f14da2..6c70b91081874483745cd0d400b49bca74f00e54 100644 (file)
@@ -48,6 +48,8 @@ extern "C" {
 void qMessageOutput(QtMsgType, const QMessageLogContext &, const QString &);
 void loadSkinFormFromXML(QFile *, UIInformation *);
 void loadControllerFormFromXML(QFile *, UIInformation *);
+int getControlIndex();
+int getPriority(QFile *file);
 
 QApplication *qt5App = NULL;
 
@@ -57,6 +59,7 @@ static char *argv[0];
 static MainWindow *mainwindow;
 static UIInformation *uiInfo;
 
+#define CONTROL_PRIORITY_MAX 10
 #define FORM_FILE_NAME "layout.qml"
 #define CON_FORM_SUBPATH "controller"
 
@@ -116,7 +119,7 @@ void qt5_skin_init(void)
 //    mainwindow->move(100, 100); // TODO: MRU
     mainwindow->show();
 
-    mainwindow->openController(0);
+    mainwindow->openController(getControlIndex());
 
     mainwindow->startSwapper();
 }
@@ -314,3 +317,51 @@ void loadControllerFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
     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;
+}