//using namespace std;
void qMessageOutput(QtMsgType, const QMessageLogContext &, const QString &);
-void loadSkinFormFromXML(QFile *, UIInformation *);
-void loadControllerFormFromXML(QFile *, UIInformation *);
+void loadMainFormFromXML(QFile *, UIInformation *);
+void loadConFormFromXML(QFile *, UIInformation *);
int getControlIndex();
int getPriority(QFile *file);
}
uiInfo->skinName = skinName;
- uiInfo->uiState.formScale = 50;
+ uiInfo->uiState.mainFormScale = 50;
/* XML */
// TODO: convert QML to XML
qmlRegisterType<HardwareKeyType>("EmulatorComponent", 1, 0, "Key");
qmlRegisterType<KeyListType>("EmulatorComponent", 1, 0, "KeyList");
- /* load skin form */
- QFile skinXMLFile(uiInfo->skinPath + FORM_FILE_NAME);
- loadSkinFormFromXML(&skinXMLFile, uiInfo);
+ /* load main form */
+ QFile mainXMLFile(uiInfo->skinPath + FORM_FILE_NAME);
+ loadMainFormFromXML(&mainXMLFile, uiInfo);
/* 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);
- loadControllerFormFromXML(&conXMLFile, uiInfo);
+ loadConFormFromXML(&conXMLFile, uiInfo);
}
/* GUI */
}
}
-void loadSkinFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
+void loadMainFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
{
if (file->exists() == false) {
qFatal("%s is not found", qPrintable(file->fileName()));
}
- qDebug("skin form is loaded from %s", qPrintable(file->fileName()));
+ qDebug("main form is loaded from %s", qPrintable(file->fileName()));
qmlRegisterType<EmulatorUIType>("EmulatorComponent", 1, 0, "EmulatorUI");
qmlRegisterType<FormListType>("EmulatorComponent", 1, 0, "FormList");
FormListType *formListType = uiType->formListType();
for (int index = 0; index < formListType->getFormList()->count(); index++) {
- SkinForm *form = new SkinForm(); /* dst */
+ MainForm *mainForm = new MainForm(); /* dst */
formType = (FormType *)formListType->getFormList()->at(index); /* src */
- form->displayRegion = formType->getDisplayRegion();
- form->skinImg[SkinForm::normal].load(fileInfo.absolutePath()
+ mainForm->displayRegion = formType->getDisplayRegion();
+ mainForm->skinImg[MainForm::normal].load(fileInfo.absolutePath()
+ QDir::separator() + formType->mainImageName());
- form->skinImg[SkinForm::pressed].load(fileInfo.absolutePath()
+ mainForm->skinImg[MainForm::pressed].load(fileInfo.absolutePath()
+ QDir::separator() + formType->pressedImageName());
keyListType = formType->keyListType();
for (int i = 0; i < keyListType->getKeyList()->count(); i++) {
hwKeyType = keyListType->getKeyList()->at(i);
if (hwKeyType != NULL) {
- form->keyList.append(new HardwareKey(hwKeyType->objectName(),
+ mainForm->keyList.append(new HardwareKey(hwKeyType->objectName(),
hwKeyType->keycode(), hwKeyType->region(), hwKeyType->tooltip()));
}
}
}
- uiInfo->formList.append(form);
+ uiInfo->mainFormList.append(mainForm);
}
delete object;
delete engine;
}
-void loadControllerFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
+void loadConFormFromXML(QFile *file, UIInformation *uiInfo/* out */)
{
if (file->exists() == false) {
qWarning("%s is not found", qPrintable(file->fileName()));
KeyListType *keyListType = NULL;
HardwareKeyType *hwKeyType = NULL;
- ControllerForm *form = new ControllerForm(fileInfo.dir().dirName());
- form->conImg[ControllerForm::normal].load(fileInfo.absolutePath()
+ ControllerForm *conForm = new ControllerForm(fileInfo.dir().dirName());
+ conForm->conImg[ControllerForm::normal].load(fileInfo.absolutePath()
+ QDir::separator() + formType->mainImageName());
- form->conImg[ControllerForm::pressed].load(fileInfo.absolutePath()
+ conForm->conImg[ControllerForm::pressed].load(fileInfo.absolutePath()
+ QDir::separator() + formType->pressedImageName());
keyListType = formType->keyListType();
for (int i = 0; i < keyListType->getKeyList()->count(); i++) {
hwKeyType = keyListType->getKeyList()->at(i);
if (hwKeyType != NULL) {
- form->keyList.append(new HardwareKey(hwKeyType->objectName(),
+ conForm->keyList.append(new HardwareKey(hwKeyType->objectName(),
hwKeyType->keycode(), hwKeyType->region(), hwKeyType->tooltip()));
}
}
}
- uiInfo->controllerList.append(form);
+ uiInfo->conFormList.append(conForm);
delete object;
}
int controlPriority = 0;
int priority = CONTROL_PRIORITY_MAX;
- if (!uiInfo)
+ if (!uiInfo) {
return controlIndex;
+ }
/* find high priority*/
QString line;
obj-$(CONFIG_QT) += skinbezelitem.o
obj-$(CONFIG_QT) += skincontrollerview.o
obj-$(CONFIG_QT) += skinkeyitem.o
-obj-$(CONFIG_QT) += skinform.o
+obj-$(CONFIG_QT) += mainform.o
obj-$(CONFIG_QT) += keyboardhelper.o
obj-$(CONFIG_QT) += skinview.o
obj-$(CONFIG_QT) += uiinformation.o
// TODO: compare display region with resolution
MainWindow *win = ((MainWindow *)w->parent()->parent());
- rotateAngle = win->getUIState()->formAngle;
+ rotateAngle = win->getUIState()->mainFormAngle;
scaleFactor = win->getUIState()->getScaleFactor();
}
qDebug("resize display");
MainWindow *win = ((MainWindow *)w->parent()->parent());
- SkinForm *form = win->uiInfo->getForm();
+ MainForm *form = win->uiInfo->getMainForm();
const qreal sx = scaleFactor;
const qreal sy = scaleFactor;
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "mainform.h"
+
+MainForm::MainForm() :
+ displayRegion(0, 0, 0, 0)
+{
+}
+
+MainForm::~MainForm()
+{
+ qDebug("destroy main form");
+
+ for (int i = 0; i < keyList.count(); i++) {
+ delete keyList.at(i);
+ }
+ keyList.clear();
+}
--- /dev/null
+/*
+ * Qt UI
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef MAINFORM_H
+#define MAINFORM_H
+
+#include <QtWidgets>
+
+#include "hardwarekey.h"
+
+class MainForm
+{
+ Q_ENUMS(SkinImgType)
+
+public:
+ MainForm();
+ ~MainForm();
+
+ QImage skinImg[2];
+ QRect displayRegion;
+ QList<HardwareKey *> keyList;
+
+ enum SkinImgType {
+ normal = 0,
+ pressed = 1
+ };
+};
+
+#endif // MAINFORM_H
*/
#include "mainwindow.h"
-#include "skinform.h"
+#include "mainform.h"
#include "displayglwidget.h"
#include "displayswwidget.h"
closeController();
- if (uiInfo->controllerList.count() <= index) {
+ if (uiInfo->conFormList.count() <= index) {
qWarning("controller index out of range");
return;
}
- ControllerForm *conForm = uiInfo->controllerList.at(index);
+ ControllerForm *conForm = uiInfo->conFormList.at(index);
if (conForm == NULL) {
qWarning("controller is null");
return;
{
qDebug("resize main window");
- resize(uiInfo->getFormSize().width(),
- uiInfo->getFormSize().height());
+ resize(uiInfo->getMainFormSize().width(),
+ uiInfo->getMainFormSize().height());
- SkinForm *form = uiInfo->getForm();
- if (form != NULL) {
- setRegion(form->skinImg[SkinForm::normal]);
+ MainForm *mainForm = uiInfo->getMainForm();
+ if (mainForm != NULL) {
+ setRegion(mainForm->skinImg[MainForm::normal]);
}
}
{
qDebug("window rotate : %d", angle);
- getUIState()->formAngle = angle;
+ getUIState()->mainFormAngle = angle;
skinView->rotate();
- display->rotate(getUIState()->formAngle);
+ display->rotate(getUIState()->mainFormAngle);
adjustSize();
}
{
qDebug("window scale : %d", scale);
- getUIState()->formScale = scale;
+ getUIState()->mainFormScale = scale;
skinView->adjustSize();
- display->scale(getUIState()->formScale);
+ display->scale(getUIState()->mainFormScale);
adjustSize();
}
#endif
/* = Rotate menu = */
- if (win->uiInfo->formList.count() > 1) {
+ if (win->uiInfo->mainFormList.count() > 1) {
QMenu *rotateMenu = addMenu(QIcon(QPixmap(":/icons/rotate.png")), "&Rotate");
QActionGroup *rotateGroup = new QActionGroup(this);
rotateMapper = new QSignalMapper(this);
rotateMapper->setMapping(action, 90);
connect(action, SIGNAL(triggered()), rotateMapper, SLOT(map()));
- action = (QAction *)rotateMapper->mapping(win->getUIState()->formAngle);
+ action = (QAction *)rotateMapper->mapping(win->getUIState()->mainFormAngle);
action->setChecked(true);
}
/* =============== */
// TODO: interpolation
- action = (QAction *)scaleMapper->mapping(win->getUIState()->formScale);
+ action = (QAction *)scaleMapper->mapping(win->getUIState()->mainFormScale);
action->setChecked(true);
/* ============== */
/* = Controller menu = */
QMenu *controllerMenu = NULL;
- if (win->uiInfo->controllerList.isEmpty() == false) {
+ if (win->uiInfo->conFormList.isEmpty() == false) {
controllerMenu = addMenu("Controller");
QActionGroup *controllerGroup = new QActionGroup(this);
controllerMapper = new QSignalMapper(this);
connect(controllerMapper, SIGNAL(mapped(int)), this, SLOT(slotController(int)));
- for (int i = 0; i < win->uiInfo->controllerList.count(); i++) {
- action = controllerMenu->addAction(win->uiInfo->controllerList.at(i)->name);
+ for (int i = 0; i < win->uiInfo->conFormList.count(); i++) {
+ action = controllerMenu->addAction(win->uiInfo->conFormList.at(i)->name);
action->setActionGroup(controllerGroup);
action->setCheckable(true);
controllerMapper->setMapping(action, i);
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include "skinform.h"
-
-SkinForm::SkinForm() :
- displayRegion(0, 0, 0, 0)
-{
-}
-
-SkinForm::~SkinForm()
-{
- qDebug("destroy skin form");
-
- for (int i = 0; i < keyList.count(); i++) {
- delete keyList.at(i);
- }
- keyList.clear();
-}
+++ /dev/null
-/*
- * Qt UI
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * GiWoong Kim <giwoong.kim@samsung.com>
- * Sangho Park <sangho1206.park@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#ifndef SKINFORM_H
-#define SKINFORM_H
-
-#include <QtWidgets>
-
-#include "hardwarekey.h"
-
-class SkinForm
-{
- Q_ENUMS(SkinImgType)
-
-public:
- SkinForm();
- ~SkinForm();
-
- QImage skinImg[2];
- QRect displayRegion;
- QList<HardwareKey *> keyList;
-
- enum SkinImgType {
- normal = 0,
- pressed = 1
- };
-};
-
-#endif // SKINFORM_H
void SkinView::createItems()
{
MainWindow *win = ((MainWindow *)this->parent());
- SkinForm *form = win->uiInfo->getForm();
+ MainForm *form = win->uiInfo->getMainForm();
/* bezel */
- SkinBezelItem *bezelItem = new SkinBezelItem(form->skinImg[SkinForm::normal]);
+ SkinBezelItem *bezelItem = new SkinBezelItem(form->skinImg[MainForm::normal]);
scene()->addItem(bezelItem);
/* HW keys */
for (int i = 0; i < keyList.count(); i++) {
hwKey = keyList.at(i);
if (hwKey != NULL) {
- new SkinKeyItem(form->skinImg[SkinForm::pressed].copy(hwKey->region),
+ new SkinKeyItem(form->skinImg[MainForm::pressed].copy(hwKey->region),
hwKey, bezelItem);
}
}
MainWindow *win = ((MainWindow *)this->parent());
/* geometry */
- const int width = win->uiInfo->getFormSize().width();
- const int height = win->uiInfo->getFormSize().height();
+ const int width = win->uiInfo->getMainFormSize().width();
+ const int height = win->uiInfo->getMainFormSize().height();
setGeometry(0, 0, width, height);
/* scaling */
skinPath = "./";
}
-SkinForm *UIInformation::getForm()
+MainForm *UIInformation::getMainForm()
{
- if (uiState.getFormIndex() > (formList.count() - 1)
- || uiState.getFormIndex() < 0) {
+ if (uiState.getMainFormIndex() > (mainFormList.count() - 1)
+ || uiState.getMainFormIndex() < 0) {
qWarning("invalid form found");
- uiState.formAngle = 0;
+ uiState.mainFormAngle = 0;
}
- return formList.at(uiState.getFormIndex());
+ return mainFormList.at(uiState.getMainFormIndex());
}
-QSize UIInformation::getFormSize()
+QSize UIInformation::getMainFormSize()
{
- SkinForm *form = getForm();
+ MainForm *form = getMainForm();
if (form == NULL) {
return QSize(0, 0);
}
- return form->skinImg[SkinForm::normal].size() * uiState.getScaleFactor();
+ return form->skinImg[MainForm::normal].size() * uiState.getScaleFactor();
}
UIInformation::~UIInformation()
{
qDebug("destroy UI info");
- for (int i = 0; i < formList.count(); i++) {
- delete formList.at(i);
+ for (int i = 0; i < mainFormList.count(); i++) {
+ delete mainFormList.at(i);
}
- formList.clear();
+ mainFormList.clear();
- for (int i = 0; i < controllerList.count(); i++) {
- delete controllerList.at(i);
+ for (int i = 0; i < conFormList.count(); i++) {
+ delete conFormList.at(i);
}
- controllerList.clear();
+ conFormList.clear();
}
#include <QtWidgets>
-#include "skinform.h"
+#include "mainform.h"
#include "uistate.h"
#include "controllerform.h"
QString skinPath;
QString skinName;
- QList<SkinForm *> formList;
- QList<ControllerForm *> controllerList;
+ QList<MainForm *> mainFormList;
+ QList<ControllerForm *> conFormList;
QColor hoverColor;
UIState uiState; /* runtime information */
- SkinForm *getForm(); /* current */
- QSize getFormSize(); /* current */
+ MainForm *getMainForm(); /* current */
+ QSize getMainFormSize(); /* current */
};
#endif // UIINFORMATION_H
#include "uistate.h"
UIState::UIState() :
- formAngle(0), formScale(100)
+ mainFormAngle(0), mainFormScale(100)
{
conState.floatingCon = NULL;
}
-int UIState::getFormIndex(int angle)
+int UIState::getMainFormIndex(int angle)
{
// TODO: map
return index;
}
-int UIState::getFormIndex()
+int UIState::getMainFormIndex()
{
- return getFormIndex(formAngle);
+ return getMainFormIndex(mainFormAngle);
}
qreal UIState::getScaleFactor(int scale)
qreal UIState::getScaleFactor()
{
- return getScaleFactor(this->formScale);
+ return getScaleFactor(this->mainFormScale);
}
public:
UIState();
- int getFormIndex(int angle);
- int getFormIndex(); /* current */
+ int getMainFormIndex(int angle);
+ int getMainFormIndex(); /* current */
qreal getScaleFactor(int scale);
qreal getScaleFactor(); /* current */
- int formAngle;
- int formScale; /* percentage */
+ int mainFormAngle;
+ int mainFormScale; /* percentage */
ControllerState conState;
};