controller: add priority sorting for controller menu 95/29295/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Fri, 24 Oct 2014 05:49:43 +0000 (14:49 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Fri, 24 Oct 2014 05:49:43 +0000 (14:49 +0900)
Change-Id: I9c757d131bbb0b9c35884e27436032a2fed078a0
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/display/qt5_supplement.cpp

index ebe584ecd7f3b4f5ebeb3238e1fa5d5203391265..8a54cd093648fd2a9a4a750d7af27555c6fb592e 100644 (file)
@@ -48,8 +48,6 @@ extern "C" {
 void qMessageOutput(QtMsgType, const QMessageLogContext &, const QString &);
 void loadMainFormFromXML(QFile *, UIInformation *);
 void loadConFormFromXML(QFile *, UIInformation *);
-int getControlIndex();
-int getPriority(QFile *file);
 
 QApplication *qt5App = NULL;
 
@@ -59,12 +57,17 @@ static char *argv[0];
 static MainWindow *mainwindow;
 static UIInformation *uiInfo;
 
-#define CONTROL_PRIORITY_MAX 10
 #define SKIN_PROPERTIES_FILE_NAME ".skin.properties"
 #define SKIN_INFO_FILE_NAME "info.ini"
 #define FORM_FILE_NAME "layout.qml"
 #define CON_FORM_SUBPATH "controller"
 
+class ConFile {
+public:
+    QFile *formFile;
+    int priority;
+};
+
 void qt5_gui_init(void)
 {
     QCoreApplication::setApplicationName("Tizen Emulator");
@@ -128,9 +131,34 @@ void qt5_gui_init(void)
     /* load controller forms */
     QDir skinDir(uiInfo->skinPath + CON_FORM_SUBPATH);
     QFileInfoList entries = skinDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
-    for (int i = 0; i < entries.size(); i++) {
-        QFile conXMLFile(entries.at(i).filePath() + QDir::separator() + FORM_FILE_NAME);
-        loadConFormFromXML(&conXMLFile, uiInfo);
+
+    if (entries.isEmpty() == false) {
+        /* sort by priority */
+        QList<ConFile *> conFileList;
+
+        for (int i = 0; i < entries.size(); i++) {
+            ConFile *conFile = new ConFile();
+
+            QString conPath = entries.at(i).filePath() + QDir::separator();
+            conFile->formFile = new QFile(conPath + FORM_FILE_NAME);
+            QSettings conInfo(conPath + SKIN_INFO_FILE_NAME, QSettings::IniFormat);
+            conFile->priority = conInfo.value("priority").toInt();
+
+            int j = 0;
+            for ( ; j < conFileList.size(); j++) {
+                if (conFileList.at(j)->priority > conFile->priority) {
+                    break;
+                }
+            }
+            conFileList.insert(j, conFile);
+        }
+
+        /* loading */
+        for (int i = 0; i < conFileList.size(); i++) {
+            loadConFormFromXML(conFileList.at(i)->formFile, uiInfo);
+            delete conFileList.at(i)->formFile;
+            delete conFileList.at(i);
+        }
     }
 
     /* GUI */
@@ -150,7 +178,7 @@ void qt5_gui_init(void)
 
     mainwindow->show();
 
-    mainwindow->openController(getControlIndex(), true);
+    mainwindow->openController(0, true);
 
     mainwindow->startSwapper();
 }
@@ -349,6 +377,9 @@ void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
     delete engine;
 }
 
+#if 0
+#define CONTROL_PRIORITY_MAX 10
+
 int getControlIndex()
 {
     int controlIndex = 0;
@@ -397,3 +428,4 @@ int getPriority(QFile *file)
 
     return priority;
 }
+#endif