#include "skinpainter.h"
#include "layout/keycodetype.h"
#include "controller/generalpurposecon.h"
+#include "resource/ui_strings.h"
/* Qt Qlayout has a minimum size */
#define QT_LAYOUT_MINIMUM (73)
-XmlLayoutParser::XmlLayoutParser(QString path, UiInformation *uiInfo)
+XmlLayoutParser::XmlLayoutParser(const QString &path, UiInformation *uiInfo)
{
this->xmlPath = path;
this->uiInfo = uiInfo;
HoverType *XmlLayoutParser::parseHover(QXmlStreamReader &xml)
{
- QColor color;
+ QColor color(255, 255, 255);
QXmlStreamReader::TokenType token = xml.readNext();
/* color */
color = parseColor(xml);
qDebug() << "hover color:" << color.name();
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
xmlPath + QDir::separator() + maskImageFileName) == false) {
qWarning() << "failed to load mask image";
}
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
} else if (xml.name() == SHORTCUT_KEYWORD) {
/* shortcut */
keySequence = QKeySequence::fromString(xml.readElementText());
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
if (hwKey != NULL) {
list.append(hwKey);
}
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
list.append(form);
}
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
if (xml.name() == FACTOR_KEYWORD) {
QString value = xml.attributes().value(NAME_ATTR_KEYWORD).toString();
map.insert(xml.readElementText().toInt(), value);
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
} else if (xml.name() == MENULIST_KEYWORD) {
int cnt = parseMenuList(xml, item->getMenuList());
qDebug("- advanced menuList: %d", cnt);
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
qDebug("- scale factorList: %d", cnt);
item->setDefaultScaleFactor(defaultFactor);
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == SHORTCUT_KEYWORD) {
parseShortcuts(xml, item->getShortcutMap());
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
item = parseGeneralMenuItem(xml, MenuItemType::forceCloseItem);
} else if (xml.name() == CLOSE_MENU_KEYWORD) {
item = parseGeneralMenuItem(xml, MenuItemType::closeItem);
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
if (item != NULL) {
QString XmlLayoutParser::parseEmulatorUI(QXmlStreamReader &xml)
{
- QString layoutVersion = "undefined";
+ QString layoutVersion = GENERIC_TEXT_UNDEFINED;
QXmlStreamReader::TokenType token;
while (xml.atEnd() == false && xml.hasError() == false) {
token = xml.readNext();
- /* If token is just StartDocument, go to next.*/
+
+ /* If token is just StartDocument, go to next. */
if (token == QXmlStreamReader::StartDocument) {
continue;
}
} else if (xml.name() == MENULIST_KEYWORD) {
int cnt = parseMenuList(xml, uiInfo->getMenuList());
qDebug() << MENULIST_KEYWORD << ":" << cnt;
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
}
QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml)
{
- QString layoutVersion = "undefined";
+ QString layoutVersion = GENERIC_TEXT_UNDEFINED;
ControllerForm *form = NULL;
QXmlStreamReader::TokenType token;
while (xml.atEnd() == false && xml.hasError() == false) {
token = xml.readNext();
- /* If token is just StartDocument, go to next.*/
+
+ /* If token is just StartDocument, go to next. */
if (token == QXmlStreamReader::StartDocument) {
continue;
}
/* image validation */
if (form->skinImg[LayoutForm::normal].size() == QSize(0, 0)) {
qDebug("- general purpose con form");
-
- int keyCount = form->getKeyList().count();
-
- int width = GPC_KEYBUTTON_WIDTH;
- int height = GPC_HEAD_SPACING;
- if (keyCount < GPC_KEYBUTTON_DEFAULT_CNT) {
- height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
- (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) +
- GPC_TAIL_SPACING;
- } else {
- width += (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING);
- height += (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT) +
- (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1)) +
- GPC_TAIL_SPACING;
- }
-
- SkinPainter painter("controller-skin",
- QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)),
- 0, QPoint(14, GPC_HEAD_SPACING - 1),
- uiInfo->getVMColor());
- form->setGeneralPurpose(true);
-
- form->skinImg[LayoutForm::normal] = painter.getSkinImage();
- form->setCenteralRect(painter.getCenteralRect());
+ makeGeneralCon(form);
}
uiInfo->getConFormList().append(form);
}
+ } else {
+ qWarning() << "undefined element:" << xml.name();
}
}
}
return layoutVersion;
}
+
+void XmlLayoutParser::makeGeneralCon(ControllerForm *form)
+{
+ const int keyCount = form->getKeyList().count();
+
+ int width = GPC_KEYBUTTON_WIDTH;
+ int height = GPC_HEAD_SPACING;
+ if (keyCount < GPC_KEYBUTTON_DEFAULT_CNT) {
+ height += (GPC_KEYBUTTON_HEIGHT * keyCount) +
+ (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) + GPC_TAIL_SPACING;
+ } else {
+ width += (GPC_SCROLLBAR_WIDTH + GPC_SCROLLBAR_HSPACING);
+ height += (GPC_KEYBUTTON_HEIGHT * GPC_KEYBUTTON_DEFAULT_CNT)
+ + (GPC_KEYBUTTON_VSPACING * (GPC_KEYBUTTON_DEFAULT_CNT - 1)) +
+ GPC_TAIL_SPACING;
+ }
+
+ SkinPainter painter("controller-skin",
+ QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)), 0,
+ QPoint(14, GPC_HEAD_SPACING - 1), uiInfo->getVMColor());
+
+ form->skinImg[LayoutForm::normal] = painter.getSkinImage();
+ form->setCenteralRect(painter.getCenteralRect());
+ form->setGeneralPurpose(true);
+}