From 6848fc58b97d0c6c5379ee5979ca89a4103c0236 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Tue, 12 Jan 2016 16:28:59 +0900 Subject: controller: consider elided text for key buttons If the string text is wider than button width, use an elided version of the string. Change-Id: I458b04d794db717e6a428b78ddbe9e38a083db30 Signed-off-by: GiWoong Kim --- tizen/src/ui/controller/hwkeybutton.cpp | 9 +++++++++ tizen/src/ui/controller/hwkeybutton.h | 1 + 2 files changed, 10 insertions(+) (limited to 'tizen/src/ui') diff --git a/tizen/src/ui/controller/hwkeybutton.cpp b/tizen/src/ui/controller/hwkeybutton.cpp index 0bf298b1c7..d9f2b43209 100644 --- a/tizen/src/ui/controller/hwkeybutton.cpp +++ b/tizen/src/ui/controller/hwkeybutton.cpp @@ -58,6 +58,14 @@ HWKeyButton::HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size) : ); } +/* override */ +void HWKeyButton::showEvent(QShowEvent *event) +{ + // keep 10% space for margin + setText(fontMetrics().elidedText(text(), Qt::ElideRight, width() * 0.9)); +} + +/* override */ void HWKeyButton::mousePressEvent(QMouseEvent *event) { const int keycode = hwKey->getKeycode(); @@ -68,6 +76,7 @@ void HWKeyButton::mousePressEvent(QMouseEvent *event) QPushButton::mousePressEvent(event); } +/* override */ void HWKeyButton::mouseReleaseEvent(QMouseEvent *event) { const int keycode = hwKey->getKeycode(); diff --git a/tizen/src/ui/controller/hwkeybutton.h b/tizen/src/ui/controller/hwkeybutton.h index b758c2672f..790789f866 100644 --- a/tizen/src/ui/controller/hwkeybutton.h +++ b/tizen/src/ui/controller/hwkeybutton.h @@ -42,6 +42,7 @@ public: ~HWKeyButton(); protected: + void showEvent(QShowEvent *event); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); -- cgit v1.2.3