From 9fd4def8cf5523ebaa7bc7ca06f48c6f5183cb4b Mon Sep 17 00:00:00 2001 From: "hyunjin816.lee" Date: Wed, 24 Sep 2014 16:44:06 +0900 Subject: [PATCH] controller: set default controller set default controller using by priority in info.ini file Change-Id: Ide8861b5cc878ec70ef49180a32ef243c1bc6ad1 Signed-off-by: hyunjin816.lee --- tizen/src/display/qt5_supplement.cpp | 53 +++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index 9b895717cc..6c70b91081 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -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; +} -- 2.34.1