QFileInfo fileInfo(*file);
QXmlStreamReader xml(file);
- XmlLayoutParser parser;
+ XmlLayoutParser parser(fileInfo.absolutePath());
- MainForm *form = NULL;
QXmlStreamReader::TokenType token;
while (xml.atEnd() == false && xml.hasError() == false) {
token = xml.readNext();
if (xml.name() == "version") {
qDebug() << "xml version :" << xml.readElementText();
continue;
- } else if (xml.name() == "form") { // TODO: formList
- form = parser.parseMainForm(xml, fileInfo.absolutePath());
- if (form != NULL) {
- uiInfo->mainFormList.append(form);
- }
+ } else if (xml.name() == "formList") {
+ int cnt = parser.parseMainFormList(xml, uiInfo->mainFormList);
+ qDebug("- formList : %d", cnt);
}
}
}
QFileInfo fileInfo(*file);
QXmlStreamReader xml(file);
- XmlLayoutParser parser;
+ XmlLayoutParser parser(fileInfo.absolutePath());
ControllerForm *form = NULL;
QXmlStreamReader::TokenType token;
qDebug() << "xml version :" << xml.readElementText();
continue;
} else if (xml.name() == "form") {
- form = parser.parseControllerForm(xml, fileInfo.absolutePath());
+ form = parser.parseControllerForm(xml);
if (form != NULL) {
uiInfo->conFormList.append(form);
}
#include "xmllayoutparser.h"
-XmlLayoutParser::XmlLayoutParser()
+XmlLayoutParser::XmlLayoutParser(QString path)
{
- /* do nothing */
+ xmlPath = path;
}
QRect XmlLayoutParser::parseRegion(QXmlStreamReader &xml)
return list.count();
}
-MainForm *XmlLayoutParser::parseMainForm(
- QXmlStreamReader &xml, QString skinPath)
+MainForm *XmlLayoutParser::parseMainForm(QXmlStreamReader &xml)
{
QString formName = "";
qDebug() << "- normalImage :" << normalImageFileName;
form->skinImg[MainForm::normal].load(
- skinPath + QDir::separator() + normalImageFileName);
+ xmlPath + QDir::separator() + normalImageFileName);
} else if (xml.name() == "pressedImage") {
/* key pressed image */
QString pressedImageFileName = xml.readElementText();
qDebug() << "- pressedImage :" << pressedImageFileName;
form->skinImg[MainForm::pressed].load(
- skinPath + QDir::separator() + pressedImageFileName);
+ xmlPath + QDir::separator() + pressedImageFileName);
} else if (xml.name() == "keyList") {
/* HW keys */
int cnt = parseKeyList(xml, form->keyList);
return form;
}
-ControllerForm *XmlLayoutParser::parseControllerForm(
- QXmlStreamReader &xml, QString skinPath)
+int XmlLayoutParser::parseMainFormList(
+ QXmlStreamReader &xml, QList<MainForm *> &list)
+{
+ MainForm *form = NULL;
+ QXmlStreamReader::TokenType token = xml.readNext();
+
+ while (xml.atEnd() == false && (xml.name() == "formList" &&
+ token == QXmlStreamReader::EndElement) == false) /* ~ </formList> */
+ {
+ if (token == QXmlStreamReader::StartElement) {
+ if (xml.name() == "form") {
+ form = parseMainForm(xml);
+ if (form != NULL) {
+ list.append(form);
+ }
+ }
+ }
+
+ token = xml.readNext();
+ }
+
+ return list.count();
+}
+
+ControllerForm *XmlLayoutParser::parseControllerForm(QXmlStreamReader &xml)
{
QString formName = "";
}
ControllerForm *form = new ControllerForm(
- formName.isEmpty() ? skinPath.section(QDir::separator(), -1) : formName);
+ formName.isEmpty() ? xmlPath.section(QDir::separator(), -1) : formName);
QXmlStreamReader::TokenType token = xml.readNext();
qDebug() << "- normalImage :" << normalImageFileName;
form->conImg[ControllerForm::normal].load(
- skinPath + QDir::separator() + normalImageFileName);
+ xmlPath + QDir::separator() + normalImageFileName);
} else if (xml.name() == "pressedImage") {
/* key pressed image */
QString pressedImageFileName = xml.readElementText();
qDebug() << "- pressedImage :" << pressedImageFileName;
form->conImg[ControllerForm::pressed].load(
- skinPath + QDir::separator() + pressedImageFileName);
+ xmlPath + QDir::separator() + pressedImageFileName);
} else if (xml.name() == "keyList") {
/* HW keys */
int cnt = parseKeyList(xml, form->keyList);
class XmlLayoutParser
{
public:
- XmlLayoutParser();
+ XmlLayoutParser(QString path);
QRect parseRegion(QXmlStreamReader &xml);
DisplayType *parseDisplay(QXmlStreamReader &xml);
HardwareKey *parseKey(QXmlStreamReader &xml);
int parseKeyList(QXmlStreamReader &xml, QList<HardwareKey *> &list);
- MainForm *parseMainForm(QXmlStreamReader &xml, QString skinPath);
- ControllerForm *parseControllerForm(QXmlStreamReader &xml, QString skinPath);
+ MainForm *parseMainForm(QXmlStreamReader &xml);
+ int parseMainFormList(QXmlStreamReader &xml, QList<MainForm *> &list);
+ ControllerForm *parseControllerForm(QXmlStreamReader &xml);
private:
-
+ QString xmlPath;
};
#endif // XMLLAYOUTPARSER_H
#include "controllerform.h"
-ControllerForm::ControllerForm(QString name)
+ControllerForm::ControllerForm(const QString &name)
{
this->name = name;
}
Q_ENUMS(ConImgType)
public:
- ControllerForm(QString name);
+ ControllerForm(const QString &name);
~ControllerForm();
QString getName();
#include "mainform.h"
-MainForm::MainForm(QString name)
+MainForm::MainForm(const QString &name)
{
this->name = name;
this->displayType = NULL;
Q_ENUMS(SkinImgType)
public:
- MainForm(QString name);
+ MainForm(const QString &name);
~MainForm();
QString getName();
QAction *action = NULL;
/* Detailed Info menu */
- actionDetailedInfo = addAction(vmName);
- actionDetailedInfo->setIcon(QIcon(QPixmap(":/icons/detailed_info.png")));
- connect(actionDetailedInfo, SIGNAL(triggered()), this, SLOT(slotDetailedInfo()));
+ actionDetailedInfo = addGeneralAction(this, vmName,
+ QIcon(QPixmap(":/icons/detailed_info.png")), SLOT(slotDetailedInfo()));
addSeparator();
/* = Controller menu = */
if (win->uiInfo->conFormList.isEmpty() == false) {
- QMenu *controllerMenu = addMenu("Controller");
+ QMenu *controllerMenu = addMenu("Con&troller");
QActionGroup *controllerGroup = new QActionGroup(this);
controllerMapper = new QSignalMapper(this);
connect(controllerMapper, SIGNAL(mapped(int)), this, SLOT(slotController(int)));
QMenu *advancedMenu = addMenu(QIcon(QPixmap(":/icons/advanced.png")), "Ad&vanced");
/* Advanced > Screen Shot menu */
- action = advancedMenu->addAction("Screen Shot");
- action->setIcon(QIcon(QPixmap(":/icons/screen_shot.png")));
- connect(action, SIGNAL(triggered()), this, SLOT(slotRequestScreenshot()));
+ action = addGeneralAction(advancedMenu, "&Screen Shot",
+ QIcon(QPixmap(":/icons/screen_shot.png")), SLOT(slotRequestScreenshot()));
/* = Host Keyboard menu = */
QMenu *keyboardMenu = advancedMenu->addMenu(
advancedMenu->addSeparator();
/* Advanced > About menu */
- actionAbout = advancedMenu->addAction("&About");
- actionAbout->setIcon(QIcon(QPixmap(":/icons/about.png")));
- connect(actionAbout, SIGNAL(triggered()), this, SLOT(slotAbout()));
+ actionAbout = addGeneralAction(advancedMenu, "&About",
+ QIcon(QPixmap(":/icons/about.png")), SLOT(slotAbout()));
/* Advanced > Force Close menu */
- actionForceClose = advancedMenu->addAction("&Force Close");
- actionForceClose->setIcon(QIcon(QPixmap(":/icons/force_close.png")));
- connect(actionForceClose, SIGNAL(triggered()), this, SLOT(slotForceClose()));
+ actionForceClose = addGeneralAction(advancedMenu, "&Force Close",
+ QIcon(QPixmap(":/icons/force_close.png")), SLOT(slotForceClose()));
/* ================= */
/* Shell menu */
- actionShell = addAction("S&hell");
- actionShell->setIcon(QIcon(QPixmap(":/icons/shell.png")));
- connect(actionShell, SIGNAL(triggered()), this, SLOT(slotShell()));
+ actionShell = addGeneralAction(this, "S&hell",
+ QIcon(QPixmap(":/icons/shell.png")), SLOT(slotShell()));
/* Control Panel menu */
- actionControlPanel = addAction("Control &Panel");
- actionControlPanel->setIcon(QIcon(QPixmap(":/icons/control_panel.png")));
- connect(actionControlPanel, SIGNAL(triggered()), this, SLOT(slotControlPanel()));
+ actionControlPanel = addGeneralAction(this, "Control &Panel",
+ QIcon(QPixmap(":/icons/control_panel.png")), SLOT(slotControlPanel()));
addSeparator();
/* Close menu */
- actionClose = addAction("&Close");
- actionClose->setIcon(QIcon(QPixmap(":/icons/close.png")));
- connect(actionClose, SIGNAL(triggered()), this, SLOT(slotClose()));
+ actionClose = addGeneralAction(this, "&Close",
+ QIcon(QPixmap(":/icons/close.png")), SLOT(slotClose()));
+}
+
+QAction *ContextMenu::addGeneralAction(QMenu *menu,
+ const QString &text, const QIcon &icon, const char *slot)
+{
+ QAction *action = menu->addAction(text);
+ action->setIcon(icon);
+ connect(action, SIGNAL(triggered()), this, slot);
+
+ return action;
}
bool ContextMenu::eventFilter(QObject *obj, QEvent *event)
try {
QProcess::startDetached(command, arguments);
- } catch (QString error) {
+ } catch (QString &error) {
QString msg = "Failed to open Shell : " + error;
qDebug() << msg;
try {
QProcess::startDetached(command, arguments);
- } catch (QString error) {
+ } catch (QString &error) {
showPopup("Failed to open Control Panel : " + error);
return;
}
QSignalMapper *getSwitchMapper();
QSignalMapper *getScaleMapper();
QSignalMapper *getControllerMapper();
+
Screenshot *screenshotDialog;
signals:
bool eventFilter(QObject *obj, QEvent *event);
private:
- MainWindow *parent;
+ QAction *addGeneralAction(QMenu *menu,
+ const QString &text, const QIcon &icon, const char *slot);
+ void showPopup(QString msg);
+ MainWindow *parent;
QString vmName;
DetailedInfoDialog *infoDialog;
AboutDialog *aboutDialog;
QAction *actionAbout;
QAction *actionForceClose;
QAction *actionClose;
-
- void showPopup(QString msg);
};
#endif // CONTEXTMENU_H
+++ /dev/null
-import EmulatorComponent 1.0
-
-EmulatorUI {
- property string version: "1.0"
-
- FormList {
- Form {
- objectName: "portrait"
- display: Region { left: 67; top: 116; width: 720; height: 1280 }
-
- mainImage: "default_0.png"
- pressedImage: "default_0_p.png"
-
- KeyList {
- Key { objectName: "Menu"; keycode: 169
- Region { left: 210; top: 1401; width: 84; height: 84 }
- tooltip: "Menu"
- }
- Key { objectName: "Home"; keycode: 139
- Region { left: 390; top: 1401; width: 84; height: 84 }
- tooltip: "Home"
- }
- Key { objectName: "Back"; keycode: 158
- Region { left: 570; top: 1401; width: 84; height: 84 }
- tooltip: "Back"
- }
- Key { objectName: "Power"; keycode: 116
- Region { left: 841; top: 1309; width: 24; height: 96 }
- tooltip: "Power"
- }
- Key { objectName: "Volume +"; keycode: 115
- Region { left: 841; top: 108; width: 24; height: 96 }
- tooltip: "Volume +"
- }
- Key { objectName: "Volume -"; keycode: 114
- Region { left: 841; top: 219; width: 24; height: 96 }
- tooltip: "Volume -"
- }
- }
- }
-
- Form {
- objectName: "landscape"
- display: Region { left: 116; top: 78; width: 1280; height: 720 }
-
- mainImage: "default_L90.png"
- pressedImage: "default_L90_p.png"
-
- KeyList {
- Key { objectName: "Menu"; keycode: 169
- Region { left: 1400; top: 570; width: 84; height: 84 }
- tooltip: "Menu"
- }
- Key { objectName: "Home"; keycode: 139
- Region { left: 1400; top: 392; width: 84; height: 84 }
- tooltip: "Home"
- }
- Key { objectName: "Back"; keycode: 158
- Region { left: 1400; top: 210; width: 84; height: 84 }
- tooltip: "Back"
- }
- Key { objectName: "Power"; keycode: 116
- Region { left: 1308; top: 2; width: 96; height: 24 }
- tooltip: "Power"
- }
- Key { objectName: "Volume +"; keycode: 115
- Region { left: 108; top: 2; width: 96; height: 24 }
- tooltip: "Volume +"
- }
- Key { objectName: "Volume -"; keycode: 114
- Region { left: 217; top: 2; width: 96; height: 24 }
- tooltip: "Volume -"
- }
- }
- }
-
- Form {
- objectName: "reverse portrait"
- display: Region { left: 78; top: 117; width: 720; height: 1280 }
-
- mainImage: "default_180.png"
- pressedImage: "default_180_p.png"
-
- KeyList {
- Key { objectName: "Menu"; keycode: 169
- Region { left: 570; top: 30; width: 84; height: 84 }
- tooltip: "Menu"
- }
- Key { objectName: "Home"; keycode: 139
- Region { left: 390; top: 30; width: 84; height: 84 }
- tooltip: "Home"
- }
- Key { objectName: "Back"; keycode: 158
- Region { left: 210; top: 30; width: 84; height: 84 }
- tooltip: "Back"
- }
- Key { objectName: "Power"; keycode: 116
- Region { left: 2; top: 110; width: 24; height: 96 }
- tooltip: "Power"
- }
- Key { objectName: "Volume +"; keycode: 115
- Region { left: 2; top: 1310; width: 24; height: 96 }
- tooltip: "Volume +"
- }
- Key { objectName: "Volume -"; keycode: 114
- Region { left: 2; top: 1200; width: 24; height: 96 }
- tooltip: "Volume -"
- }
- }
- }
-
- Form {
- objectName: "reverse landscape"
- display: Region { left: 117; top: 67; width: 1280; height: 720 }
-
- mainImage: "default_R90.png"
- pressedImage: "default_R90_p.png"
-
- KeyList {
- Key { objectName: "Menu"; keycode: 169
- Region { left: 28; top: 209; width: 84; height: 84 }
- tooltip: "Menu"
- }
- Key { objectName: "Home"; keycode: 139
- Region { left: 28; top: 391; width: 84; height: 84 }
- tooltip: "Home"
- }
- Key { objectName: "Back"; keycode: 158
- Region { left: 28; top: 568; width: 84; height: 84 }
- tooltip: "Back"
- }
- Key { objectName: "Power"; keycode: 116
- Region { left: 109; top: 841; width: 96; height: 24 }
- tooltip: "Power"
- }
- Key { objectName: "Volume +"; keycode: 115
- Region { left: 1309; top: 841; width: 96; height: 24 }
- tooltip: "Volume +"
- }
- Key { objectName: "Volume -"; keycode: 114
- Region { left: 1199; top: 841; width: 96; height: 24 }
- tooltip: "Volume -"
- }
- }
- }
- }
-}
+++ /dev/null
-import EmulatorComponent 1.0
-
-EmulatorUI {
- property string version: "1.0"
-
- FormList {
- Form {
- objectName: "portrait"
- display: Region { left: 26; top: 60; width: 320; height: 320 }
-
- mainImage: "default_0.png"
- pressedImage: "default_0_p.png"
-
- KeyList {
- Key { objectName: "Power"; keycode: 116
- Region { left: 372; top: 116; width: 12; height: 80 }
- tooltip: "Power"
- }
- }
- }
-
- Form {
- objectName: "landscape"
- display: Region { left: 60; top: 38; width: 320; height: 320 }
-
- mainImage: "default_L90.png"
- pressedImage: "default_L90_p.png"
-
- KeyList {
- Key { objectName: "Power"; keycode: 116
- Region { left: 116; top: 0; width: 80; height: 12 }
- tooltip: "Power"
- }
- }
- }
-
- Form {
- objectName: "reverse portrait"
- display: Region { left: 38; top: 60; width: 320; height: 320 }
-
- mainImage: "default_180.png"
- pressedImage: "default_180_p.png"
-
- KeyList {
- Key { objectName: "Power"; keycode: 116
- Region { left: 0; top: 244; width: 12; height: 80 }
- tooltip: "Power"
- }
- }
- }
-
- Form {
- objectName: "reverse landscape"
- display: Region { left: 60; top: 26; width: 320; height: 320 }
-
- mainImage: "default_R90.png"
- pressedImage: "default_R90_p.png"
-
- KeyList {
- Key { objectName: "Power"; keycode: 116
- Region { left: 244; top: 372; width: 80; height: 12 }
- tooltip: "Power"
- }
- }
- }
- }
-}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<EmulatorUI xmlns="http://www.tizen.org/emulator/ui/layout">
+ <dbi_version>2.4</dbi_version>
+ <formList>
+ <form name="Portrait">
+ <display>
+ <region left="26" top="60" width="320" height="320"/>
+ <angle>0</angle>
+ </display>
+ <normalImage>default_0.png</normalImage>
+ <pressedImage>default_0_p.png</pressedImage>
+ <keyList>
+ <key name="Power">
+ <region left="372" top="116" width="12" height="80"/>
+ <keycode>116</keycode>
+ <tooltip>Power</tooltip>
+ </key>
+ </keyList>
+ </form>
+ <form name="Landscape">
+ <display>
+ <region left="60" top="38" width="320" height="320"/>
+ <angle>270</angle>
+ </display>
+ <normalImage>default_L90.png</normalImage>
+ <pressedImage>default_L90_p.png</pressedImage>
+ <keyList>
+ <key name="Power">
+ <region left="116" top="0" width="80" height="12"/>
+ <keycode>116</keycode>
+ <tooltip>Power</tooltip>
+ </key>
+ </keyList>
+ </form>
+ <form name="Reverse Portrait">
+ <display>
+ <region left="38" top="60" width="320" height="320"/>
+ <angle>180</angle>
+ </display>
+ <normalImage>default_180.png</normalImage>
+ <pressedImage>default_180_p.png</pressedImage>
+ <keyList>
+ <key name="Power">
+ <region left="0" top="244" width="12" height="80"/>
+ <keycode>116</keycode>
+ <tooltip>Power</tooltip>
+ </key>
+ </keyList>
+ </form>
+ <form name="Reverse Landscape">
+ <display>
+ <region left="60" top="26" width="320" height="320"/>
+ <angle>90</angle>
+ </display>
+ <normalImage>default_R90.png</normalImage>
+ <pressedImage>default_R90_p.png</pressedImage>
+ <keyList>
+ <key name="Power">
+ <region left="244" top="372" width="80" height="12"/>
+ <keycode>116</keycode>
+ <tooltip>Power</tooltip>
+ </key>
+ </keyList>
+ </form>
+ </formList>
+</EmulatorUI>