#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"
static MainWindow *mainwindow;
static UIInformation *uiInfo;
+#define FORM_FILE_NAME "layout.qml"
+
void qt5_skin_init(void)
{
uiInfo = new UIInformation();
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
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 */
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)
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();
}
}
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");
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();
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();