ui: read skin path from qemu startup option 17/25317/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Fri, 1 Aug 2014 11:58:51 +0000 (20:58 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Sat, 2 Aug 2014 05:50:06 +0000 (14:50 +0900)
layout.qml(tizen/ui/resource/[SKIN_NAME]/) file must exist in there

Change-Id: I6588f2f3f34eda4b5c96584fc8fdae50415e99fd
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/display/qt5_supplement.cpp
tizen/src/emul_state.c
tizen/src/emul_state.h
tizen/src/emulator_legacy.c
tizen/src/ui/mainwindow.cpp
tizen/src/ui/mainwindow.h

index 54af3bef0c8806aa6e909ba7614bfeadd45b459c..0b42d7fa0c22fb7d1c473c5ef85e6af68d70c6ae 100644 (file)
@@ -37,6 +37,7 @@
 #include "mainwindow.h"
 #include "uiinformation.h"
 #include "hardwarekey.h"
+#include "controllerwidget.h"
 #include "ui/xml/hardwarekeytype.h"
 #include "ui/xml/keylisttype.h"
 #include "ui/xml/layouttype.h"
@@ -58,6 +59,8 @@ static char *argv[0];
 static MainWindow *mainwindow;
 static UIInformation *uiInfo;
 
+#define FORM_FILE_NAME "layout.qml"
+
 void qt5_skin_init(void)
 {
     uiInfo = new UIInformation();
@@ -70,14 +73,12 @@ void qt5_skin_init(void)
     uiInfo->resolution.setHeight(get_emul_resolution_height());
     uiInfo->basePort = get_emul_vm_base_port();
 
-#if 0
-    /* wearable */
-    uiInfo->skinPath = "/skins/wearable-320x320-1btn/";
-#elif 1
-    /* mobile */
-    uiInfo->skinPath = "/skins/mobile-720x1280-3btn/";
+    uiInfo->skinPath = get_emul_skin_path();
+    if (uiInfo->skinPath.endsWith('/') == false) {
+        uiInfo->skinPath += "/";
+    }
+
     uiInfo->uiState.layoutScale = 50;
-#endif
 
     /* XML */
     // TODO: convert QML to XML
@@ -87,10 +88,11 @@ void qt5_skin_init(void)
     qmlRegisterType<HardwareKeyType>("EmulatorComponent", 1, 0, "Key");
     qmlRegisterType<KeyListType>("EmulatorComponent", 1, 0, "KeyList");
 
-    QFile skinXMLFile(":" + uiInfo->skinPath + "layout.qml");
+    QFile skinXMLFile(uiInfo->skinPath + FORM_FILE_NAME);
     loadSkinLayoutFromXML(&skinXMLFile, uiInfo);
 
-    QFile conXMLFile(":" + uiInfo->skinPath + "controller-layout/Basic/layout.qml");
+    // TODO:
+    QFile conXMLFile(uiInfo->skinPath + "controller-layout/Basic/layout.qml");
     loadControllerLayoutFromXML(&conXMLFile, uiInfo);
 
     /* GUI */
@@ -98,6 +100,13 @@ void qt5_skin_init(void)
     mainwindow = new MainWindow(uiInfo);
 //    mainwindow->move(100, 100); // TODO: MRU
     mainwindow->show();
+
+    ControllerWidget *con = mainwindow->getController();
+    if (con != NULL) {
+        QPoint pos = mainwindow->mapToGlobal(mainwindow->pos());
+        con->move(pos.x() + mainwindow->size().width(), pos.y());
+        con->show();
+    }
 }
 
 void qt5_early_prepare(void)
@@ -161,6 +170,12 @@ void qMessageOutput(QtMsgType type, const QMessageLogContext &context, const QSt
     case QtFatalMsg:
         fprintf(stderr, "%s [Fatal:%s:%u] %s\n", dateMsg.constData(),
             context.category, context.line, localMsg.constData());
+
+        QString err;
+        QMessageBox::critical(0, "Emulator",
+                              QString("An internal error occurred.\n: ") +
+                              err.sprintf("%s", localMsg.constData()) +
+                              "\n\nEmulator will now exit.");
         abort();
     }
 }
@@ -168,11 +183,10 @@ void qMessageOutput(QtMsgType type, const QMessageLogContext &context, const QSt
 void loadSkinLayoutFromXML(QFile *file, UIInformation *uiInfo/* out */)
 {
     if (file->exists() == false) {
-        qDebug("skin xml file is null");
-        return;
+        qFatal("%s is not found", file->fileName().toLocal8Bit().data());
     }
 
-    qDebug("load skin layout from %s", file->fileName().toLocal8Bit().data());
+    qDebug("skin form is loaded from %s", file->fileName().toLocal8Bit().data());
 
     qmlRegisterType<LayoutType>("EmulatorComponent", 1, 0, "Layout");
 
@@ -180,15 +194,12 @@ void loadSkinLayoutFromXML(QFile *file, UIInformation *uiInfo/* out */)
     QQmlEngine *engine = new QQmlEngine();
     QQmlComponent *component = new QQmlComponent(engine);
 
-    QUrl qmlSource("qrc" + file->fileName());
-    // Other possible QML files that are used engine->addImportPath("qrc:/other");
-    component->loadUrl(qmlSource);
+    component->loadUrl(QUrl(file->fileName()));
     if (!component->isReady()) {
         qWarning("%s", qPrintable(component->errorString()));
-        //return -1;
     }
-    QObject *object = component->create();
 
+    QObject *object = component->create();
     if (object != NULL) {
         QFileInfo fileInfo(*file);
         qDebug() << "xml version :" << QQmlProperty::read(object, "version").toString();
@@ -238,19 +249,18 @@ void loadControllerLayoutFromXML(QFile *file, UIInformation *uiInfo/* out */)
         return;
     }
 
-    qDebug("load con layout from %s", file->fileName().toLocal8Bit().data());
+    qDebug("controller form is loaded from %s", file->fileName().toLocal8Bit().data());
 
     /* QML */
     QQmlEngine *engine = new QQmlEngine();
     QQmlComponent *component = new QQmlComponent(engine);
 
-    QUrl qmlSource("qrc" + file->fileName());
-    component->loadUrl(qmlSource);
+    component->loadUrl(QUrl(file->fileName()));
     if (!component->isReady()) {
         qWarning("%s", qPrintable(component->errorString()));
     }
-    QObject *object = component->create();
 
+    QObject *object = component->create();
     if (object != NULL) {
         QFileInfo fileInfo(*file);
         qDebug() << "xml version :" << QQmlProperty::read(object, "version").toString();
index 2137a62c70ec80deb9addde6f604d4907c0188a0..467123ae64c41793d70e5685a36e9a2b6f0fbcf8 100644 (file)
@@ -344,3 +344,16 @@ char* get_emul_vm_name(void)
     return _emul_info.vm_name;
 }
 
+/* emualtor skin path */
+void set_emul_skin_path(char *path)
+{
+    _emul_info.skin_path = path;
+
+    LOG_INFO("skin path : %s\n", _emul_info.skin_path);
+}
+
+char* get_emul_skin_path(void)
+{
+    return _emul_info.skin_path;
+}
+
index 865017eca0c107763dce8e3db621542144af0da6..e963c2fc46be6a43cd5ca1e0b13410a66a6a54e9 100644 (file)
@@ -93,6 +93,7 @@ typedef  struct EmulatorConfigInfo {
     int device_serial_number;
     int ecs_port;
     char *vm_name;
+    char *skin_path;
     /* add here */
 } EmulatorConfigInfo;
 
@@ -131,6 +132,7 @@ void set_emul_rotation(short rotation_type);
 void set_emul_caps_lock_state(int state);
 void set_emul_num_lock_state(int state);
 void set_emul_vm_name(char *vm_name);
+void set_emul_skin_path(char *path);
 
 /* getter */
 bool get_emul_skin_enable(void);
@@ -152,6 +154,7 @@ int get_host_lock_key_state_darwin(int key);
 int get_emul_caps_lock_state(void);
 int get_emul_num_lock_state(void);
 char* get_emul_vm_name(void);
+char* get_emul_skin_path(void);
 
 /* multi-touch */
 MultiTouchState *get_emul_multi_touch_state(void);
index 3b8194c95f667e31c03eb0498a462dd7778dc1b3..ac386277eb6a37a82a0f71b92637df1b6378b2b1 100644 (file)
@@ -64,6 +64,7 @@ MULTI_DEBUG_CHANNEL(qemu, main);
 #define LOGFILE             "emulator.log"
 #define DISPLAY_WIDTH_PREFIX "width="
 #define DISPLAY_HEIGHT_PREFIX "height="
+#define SKIN_PATH_PREFIX "skin.path="
 #define INPUT_TOUCH_PARAMETER "virtio-touchscreen-pci"
 
 #define MIDBUF  128
@@ -241,11 +242,14 @@ static void extract_skin_info(int skin_argc, char **skin_argv)
             h = atoi(height_arg);
 
             INFO("display height option : %d\n", h);
+        } else if (strstr(skin_argv[i], SKIN_PATH_PREFIX) != NULL) {
+            char *path = skin_argv[i] + strlen(SKIN_PATH_PREFIX);
+
+            set_emul_skin_path(path);
         }
 
         if (w != 0 && h != 0) {
             set_emul_resolution(w, h);
-            break;
         }
     }
 }
index 7cdce59b3f0669ff049a435664870f635bb5f451..433c064d38b12df7b531efdae7d5fa798f72ae11 100644 (file)
@@ -92,7 +92,6 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) :
         /* floated controller */
         ControllerLayout *conLayout = uiInfo->controllerList.at(0);
         con = new ControllerWidget(conLayout);
-        con->show();
     }
 
     QGLContext *wrapperContext = QGLContext::fromOpenGLContext(qt5GLContext);
@@ -178,7 +177,10 @@ void MainWindow::resizeEvent(QResizeEvent *event)
 {
     qDebug("resize main window");
 
-    resize(skinView->size());
+    resize(uiInfo->getLayoutSize().width(),
+        uiInfo->getLayoutSize().height());
+
+    setRegion(uiInfo->getLayout()->skinImg[SkinLayout::normal]);
 }
 
 void MainWindow::rotate(int angle)
@@ -207,7 +209,6 @@ void MainWindow::scale(int scale)
 
 void MainWindow::updateSkin() // TODO: temp
 {
-    setRegion(uiInfo->getLayout()->skinImg[SkinLayout::normal]);
 }
 
 void MainWindow::setRegion(QImage baseImage)
index 3a4b2f544c6fce95b6bceb39a7059101e5ab010a..d5618893706165b4b69efff6f9872620d017c858 100644 (file)
@@ -54,7 +54,6 @@ public:
 
     UIInformation *uiInfo;
     QLabel *getLabel();
-    QImage *image;
 
     void makeCurrent(bool value);