From: GiWoong Kim Date: Fri, 1 Aug 2014 11:58:51 +0000 (+0900) Subject: ui: read skin path from qemu startup option X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c891cd83474d863bc43b4e88e793f9d034c784d;p=sdk%2Femulator%2Fqemu.git ui: read skin path from qemu startup option layout.qml(tizen/ui/resource/[SKIN_NAME]/) file must exist in there Change-Id: I6588f2f3f34eda4b5c96584fc8fdae50415e99fd Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index 54af3bef0c..0b42d7fa0c 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -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("EmulatorComponent", 1, 0, "Key"); qmlRegisterType("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("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(); diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index 2137a62c70..467123ae64 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -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; +} + diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index 865017eca0..e963c2fc46 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -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); diff --git a/tizen/src/emulator_legacy.c b/tizen/src/emulator_legacy.c index 3b8194c95f..ac386277eb 100644 --- a/tizen/src/emulator_legacy.c +++ b/tizen/src/emulator_legacy.c @@ -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; } } } diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index 7cdce59b3f..433c064d38 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -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) diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index 3a4b2f544c..d561889370 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -54,7 +54,6 @@ public: UIInformation *uiInfo; QLabel *getLabel(); - QImage *image; void makeCurrent(bool value);