summaryrefslogtreecommitdiff
path: root/tizen
diff options
context:
space:
mode:
authorjihye <jihye424.kim@samsung.com>2017-02-01 13:58:30 +0900
committerJiHye Kim <jihye424.kim@samsung.com>2017-02-01 19:54:31 +0900
commit359bac47796f112f77c8fe3ff7e9bd6535eb4251 (patch)
tree2e49c49a4cb8009563a4554ab990c822adadbb0b /tizen
parent2d0eeb30936260c22ce559ac390eb42ab479570f (diff)
downloadqemu-359bac47796f112f77c8fe3ff7e9bd6535eb4251.tar.gz
qemu-359bac47796f112f77c8fe3ff7e9bd6535eb4251.tar.bz2
qemu-359bac47796f112f77c8fe3ff7e9bd6535eb4251.zip
skin: check that image file of H/W button exist or not
- privite image file: if image file exist in controller directory of skin - default image file: if image file not exist Change-Id: Ide0e45db1f232a6c12bfb14721a668b129bab90d Signed-off-by: jihye <jihye424.kim@samsung.com>
Diffstat (limited to 'tizen')
-rw-r--r--tizen/src/ui/controller/hwkeybutton.cpp87
-rw-r--r--tizen/src/ui/controller/hwkeybutton.h3
-rw-r--r--tizen/src/ui/layout/hardwarekey.cpp40
-rw-r--r--tizen/src/ui/layout/hardwarekey.h8
-rw-r--r--tizen/src/ui/xmllayoutparser.cpp5
5 files changed, 122 insertions, 21 deletions
diff --git a/tizen/src/ui/controller/hwkeybutton.cpp b/tizen/src/ui/controller/hwkeybutton.cpp
index 16c109bc0c..0c8afa28c1 100644
--- a/tizen/src/ui/controller/hwkeybutton.cpp
+++ b/tizen/src/ui/controller/hwkeybutton.cpp
@@ -28,6 +28,7 @@
*/
#include <QDebug>
+#include <QFile>
#include "hwkeybutton.h"
@@ -36,30 +37,27 @@ extern "C" {
#include "util/ui_operations.h"
}
+#define DEFAULT_NAME "keybutton"
+
HWKeyButton::HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size) :
QPushButton(hwKey->getName(), parent)
{
this->hwKey = hwKey;
-
setText("");
setFocusPolicy(Qt::NoFocus);
- setStyleSheet(
- "QPushButton {"
- "width: " + QString::number(size.width()) + ";" +
- "height: " + QString::number(size.height()) + ";" +
- "border: none; color: white;"
- "background: url(\":images/controller-skin/" + hwKey->getName() +"_normal.png\");"
- "}"
- "QPushButton:hover {"
- "background: url(\":images/controller-skin/" + hwKey->getName() +"_hover.png\");"
- "}"
- "QPushButton:pressed {"
- "background: url(\":images/controller-skin/" + hwKey->getName() +"_pushed.png\");"
- "}"
- "QToolTip {"
- "color:#2E2E2E; background-color:#CCCCCC;"
- "}"
- );
+
+ if (!hwKey->getNormalImagePath().isEmpty()) {
+ initialize(size);
+ } else {
+ if (QFile::exists(":images/controller-skin/" + hwKey->getName() + "_normal.png")
+ && QFile::exists(":images/controller-skin/" + hwKey->getName() + "_hover.png")
+ && QFile::exists(":images/controller-skin/" + hwKey->getName() + "_pushed.png")) {
+ initialize(hwKey->getName(), size);
+ } else {
+ setText(hwKey->getName());
+ initialize(DEFAULT_NAME, size);
+ }
+ }
//FIXME: set slot for menu button
if (hwKey->getKeycode() == 0) {
@@ -80,6 +78,59 @@ HWKeyButton::HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size) :
}
}
+void HWKeyButton::initialize(QSize size)
+{
+ // use image file path
+ // path is absolute path
+ setStyleSheet(
+ "QPushButton {"
+ "width: " + QString::number(size.width()) + ";" +
+ "height: " + QString::number(size.height()) + ";" +
+ "border: none; color: black;"
+ "background: url(" + hwKey->getNormalImagePath() + ");"
+ "}"
+ "QPushButton:hover {"
+ "background: url(" + hwKey->getHoverImagePath() + ");"
+ "}"
+ "QPushButton:pressed {"
+ "background: url(" + hwKey->getPushImagePath() + ");"
+ "}"
+ "QToolTip {"
+ "color:#2E2E2E; background-color:#CCCCCC;"
+ "}"
+ );
+}
+
+void HWKeyButton::initialize(QString name, QSize size)
+{
+ // use key button name
+ // path is relative path
+ setStyleSheet(
+ "QPushButton {"
+ "width: " + QString::number(size.width()) + ";" +
+ "height: " + QString::number(size.height()) + ";" +
+ "border: none; color: black;"
+ "background: url(\":images/controller-skin/" + name +"_normal.png\");"
+ "}"
+ "QPushButton:hover {"
+ "background: url(\":images/controller-skin/" + name +"_hover.png\");"
+ "}"
+ "QPushButton:pressed {"
+ "background: url(\":images/controller-skin/" + name +"_pushed.png\");"
+ "}"
+ "QToolTip {"
+ "color:#2E2E2E; background-color:#CCCCCC;"
+ "}"
+ );
+}
+
+void HWKeyButton::showEvent(QShowEvent *event)
+{
+ if (!text().isEmpty()) {
+ setText(fontMetrics().elidedText(text(), Qt::ElideRight, width() * 1.2));
+ }
+}
+
/* override */
void HWKeyButton::mousePressEvent(QMouseEvent *event)
{
diff --git a/tizen/src/ui/controller/hwkeybutton.h b/tizen/src/ui/controller/hwkeybutton.h
index 807ae0aeaa..cba5ff0989 100644
--- a/tizen/src/ui/controller/hwkeybutton.h
+++ b/tizen/src/ui/controller/hwkeybutton.h
@@ -43,6 +43,9 @@ public:
virtual const char *getSlot();
protected:
+ virtual void initialize(QSize size);
+ virtual void initialize(QString name, QSize size);
+ void showEvent(QShowEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
diff --git a/tizen/src/ui/layout/hardwarekey.cpp b/tizen/src/ui/layout/hardwarekey.cpp
index 3c8ee3ea0d..9647a49b2c 100644
--- a/tizen/src/ui/layout/hardwarekey.cpp
+++ b/tizen/src/ui/layout/hardwarekey.cpp
@@ -26,7 +26,8 @@
* - S-Core Co., Ltd
*
*/
-
+#include <QFileInfo>
+#include <QDir>
#include "hardwarekey.h"
HardwareKey::HardwareKey(QString name, const KeycodeType &keycodeType,
@@ -37,6 +38,9 @@ HardwareKey::HardwareKey(QString name, const KeycodeType &keycodeType,
this->region = region;
this->tooltip = tooltip;
this->keySequence = keySequence;
+ this->normalImagePath = "";
+ this->hoverImagePath = "";
+ this->pushImagePath = "";
}
QString HardwareKey::getName()
@@ -74,6 +78,40 @@ QKeySequence HardwareKey::getKeySequence()
return keySequence;
}
+void HardwareKey::setImagePath(QString path)
+{
+ if (path == NULL || path.isEmpty()) {
+ return;
+ }
+
+ QFileInfo normalImage(path + QDir::separator() + name + "_normal.png");
+ QFileInfo hoverImage(path + QDir::separator() + name + "_hover.png");
+ QFileInfo pushImage(path + QDir::separator() + name + "_pushed.png");
+
+ if (normalImage.exists() && normalImage.isFile()
+ && hoverImage.exists() && hoverImage.isFile()
+ && pushImage.exists() && pushImage.isFile()) {
+ normalImagePath = normalImage.absoluteFilePath();
+ hoverImagePath = hoverImage.absoluteFilePath();
+ pushImagePath = pushImage.absoluteFilePath();
+ }
+}
+
+QString HardwareKey::getNormalImagePath()
+{
+ return normalImagePath;
+}
+
+QString HardwareKey::getHoverImagePath()
+{
+ return hoverImagePath;
+}
+
+QString HardwareKey::getPushImagePath()
+{
+ return pushImagePath;
+}
+
HardwareKey::~HardwareKey()
{
/* do nothing */
diff --git a/tizen/src/ui/layout/hardwarekey.h b/tizen/src/ui/layout/hardwarekey.h
index 3e20a02210..0efc1c5e10 100644
--- a/tizen/src/ui/layout/hardwarekey.h
+++ b/tizen/src/ui/layout/hardwarekey.h
@@ -48,13 +48,19 @@ public:
QRect &getRect();
QString getTooltip();
QKeySequence getKeySequence();
-
+ void setImagePath(QString path);
+ QString getNormalImagePath();
+ QString getHoverImagePath();
+ QString getPushImagePath();
private:
QString name;
KeycodeType keycodeType;
QRect region;
QString tooltip;
QKeySequence keySequence;
+ QString normalImagePath;
+ QString hoverImagePath;
+ QString pushImagePath;
};
#endif // HARDWAREKEY_H
diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp
index 25838d7f26..4d0ba95a76 100644
--- a/tizen/src/ui/xmllayoutparser.cpp
+++ b/tizen/src/ui/xmllayoutparser.cpp
@@ -258,7 +258,10 @@ HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml, const int depth)
token = xml.readNext();
}
- return new HardwareKey(keyName, keycodeType, keyRegion, keyTooptip, keySequence);
+ HardwareKey *key = new HardwareKey(keyName, keycodeType, keyRegion, keyTooptip, keySequence);
+ key->setImagePath(this->xmlPath);
+
+ return key;
}
int XmlLayoutParser::parseKeyList(QXmlStreamReader &xml,