ui: clean up some source code
authorGiWoong Kim <giwoong.kim@samsung.com>
Fri, 31 Jul 2015 08:25:57 +0000 (17:25 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 4 Aug 2015 05:13:34 +0000 (14:13 +0900)
- add getter/setter for hardwarekey class
- extract texts from context menu

Change-Id: I7f3c8ee6599d7a6d01191746677cba0e9fd6e5a6
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
13 files changed:
tizen/src/ui/controller/dockingconview.cpp
tizen/src/ui/controller/floatingconview.cpp
tizen/src/ui/controller/generalpurposecon.cpp
tizen/src/ui/controller/hwkeybutton.cpp
tizen/src/ui/input/keyboardshortcut.cpp
tizen/src/ui/layout/hardwarekey.cpp
tizen/src/ui/layout/hardwarekey.h
tizen/src/ui/menu/contextmenu.cpp
tizen/src/ui/menu/contextmenu.h
tizen/src/ui/menu/detailedinfodialog.cpp
tizen/src/ui/resource/maru_strings.h
tizen/src/ui/skinkeyitem.cpp
tizen/src/ui/skinview.cpp

index e23876d76b27bb0a694a8eef07b3342fe7d6e670..65aa01dec3110b51a545ff34a6c9d6e0bec31c2e 100644 (file)
@@ -67,7 +67,7 @@ void DockingConView::createItems(ControllerForm *conForm)
             hwKey = keyList.at(i);
             if (hwKey != NULL) {
                 new SkinKeyItem(bezelItem, hwKey,
-                    conForm->conImg[ControllerForm::pressed].copy(hwKey->region),
+                    conForm->conImg[ControllerForm::pressed].copy(hwKey->getRegion()),
                     conForm->getHoverType());
             }
         }
index a4630a727f999f92ecf2a6c344c45cd6d8c9c975..db550baa91981a20c2b3e4dbdb6ee5d2abeac4d9 100644 (file)
@@ -68,7 +68,7 @@ void FloatingConView::createItems(ControllerForm *conForm)
             hwKey = keyList.at(i);
             if (hwKey != NULL) {
                 new SkinKeyItem(bezelItem, hwKey,
-                    conForm->conImg[ControllerForm::pressed].copy(hwKey->region),
+                    conForm->conImg[ControllerForm::pressed].copy(hwKey->getRegion()),
                     conForm->getHoverType());
             }
         }
index deee54959f6970ef161296425353e97b622fbdfc..bd35c3df68f5182732c6d30062479217564cbe47 100644 (file)
@@ -62,8 +62,8 @@ void GeneralPurposeCon::createItems(QList<HardwareKey *> keyList, QSize size)
             keyButton = new HWKeyButton(buttonGroup, hwKey,
                 QSize(GPC_KEYBUTTON_WIDTH, GPC_KEYBUTTON_HEIGHT));
 
-            if (!hwKey->keySequence.isEmpty()) {
-                keyButton->setToolTip(hwKey->keySequence);
+            if (!hwKey->getKeySequence().isEmpty()) {
+                keyButton->setToolTip(hwKey->getKeySequence());
             }
 
             layout->addWidget(keyButton);
index d443b54d9a8730fa8da8bde15d2b91627a3b3785..66a5a986c18f4013d584bc91687a4771608f3e1d 100644 (file)
@@ -37,7 +37,7 @@ extern "C" {
 }
 
 HWKeyButton::HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size) :
-    QPushButton(hwKey->name, parent)
+    QPushButton(hwKey->getName(), parent)
 {
     this->hwKey = hwKey;
 
@@ -62,7 +62,7 @@ void HWKeyButton::mousePressEvent(QMouseEvent *event)
 {
     const int keycode = hwKey->getKeycodeType()->getShortPressKeycode();
 
-    qDebug() << hwKey->name << "key button pressed:" << keycode;
+    qDebug() << hwKey->getName() << "key button pressed:" << keycode;
     do_hw_key_event(KEY_PRESSED, keycode);
 
     QPushButton::mousePressEvent(event);
@@ -72,7 +72,7 @@ void HWKeyButton::mouseReleaseEvent(QMouseEvent *event)
 {
     const int keycode = hwKey->getKeycodeType()->getShortPressKeycode();
 
-    qDebug() << hwKey->name << "key button released:" << keycode;
+    qDebug() << hwKey->getName() << "key button released:" << keycode;
     do_hw_key_event(KEY_RELEASED, keycode);
 
     QPushButton::mouseReleaseEvent(event);
index 9b71be3d72fcaa46b28dfb4cf04fac0f335ff1c8..f0bf60bead6ca6cb542fce8a9e6d9c389a917127 100644 (file)
@@ -105,12 +105,14 @@ void KeyboardShortcut::setKeyboardShortcutController()
     for (int index = 0; index < controllerKeyList.count(); index++) {
         HardwareKey *controllerKey = controllerKeyList.at(index);
         if (controllerKey) {
-            if (!controllerKey->keySequence.isEmpty()) {
-                QShortcut *shortcut = new QShortcut(QKeySequence::fromString(controllerKey->keySequence), parent);
-                registShortcutKey(shortcut, controllerKey->name);
+            if (!controllerKey->getKeySequence().isEmpty()) {
+                QShortcut *shortcut = new QShortcut(
+                    QKeySequence::fromString(controllerKey->getKeySequence()), parent);
+                registShortcutKey(shortcut, controllerKey->getName());
 
                 controllerShortcutList.append(shortcut);
-                controllerShortcutMap.insert(controllerKey->name, controllerKey->keySequence);
+                controllerShortcutMap.insert(
+                    controllerKey->getName(), controllerKey->getKeySequence());
             }
         } else {
             qDebug() << "controllerKeyList.at(" << index << ") is NULL";
@@ -145,12 +147,13 @@ void KeyboardShortcut::setKeyboardShortcutHwKey()
     for (int index = 0; index < hwKeyList.count(); index++) {
         HardwareKey *hwKey = hwKeyList.at(index);
         if (hwKey) {
-            if (!hwKey->keySequence.isEmpty()) {
-                QShortcut *shortcut = new QShortcut(QKeySequence::fromString(hwKey->keySequence), parent);
-                registShortcutKey(shortcut, hwKey->name);
+            if (!hwKey->getKeySequence().isEmpty()) {
+                QShortcut *shortcut = new QShortcut(
+                    QKeySequence::fromString(hwKey->getKeySequence()), parent);
+                registShortcutKey(shortcut, hwKey->getName());
 
                 hwKeyShortcutList.append(shortcut);
-                hwKeyShortcutMap.insert(hwKey->name, hwKey->keySequence);
+                hwKeyShortcutMap.insert(hwKey->getName(), hwKey->getKeySequence());
             }
         } else {
             qDebug() << "hwKeyList.at(" << index << ") is NULL";
@@ -158,7 +161,8 @@ void KeyboardShortcut::setKeyboardShortcutHwKey()
     }
 }
 
-void KeyboardShortcut::setKeyboardShortcutContextMenu(MenuItem *item, QString property, QString keySequence)
+void KeyboardShortcut::setKeyboardShortcutContextMenu(
+    MenuItem *item, QString property, QString keySequence)
 {
     QShortcut *shortcut = new QShortcut(QKeySequence::fromString(keySequence), parent);
     int itemType = item->getType();
@@ -388,15 +392,15 @@ void KeyboardShortcut::slotShortcutHostKeyboard()
     }
 
     int index = 0;
-    if (action->text().contains(KEYBOARD_ON)) {
+    if (action->text().contains(MENU_ON_ITEM_TEXT)) {
         for (index = 0; index < keyboardStatusList.count(); index++) {
-            if (keyboardStatusList.at(index)->text().contains(KEYBOARD_OFF)) {
+            if (keyboardStatusList.at(index)->text().contains(MENU_OFF_ITEM_TEXT)) {
                 break;
             }
         }
     } else {
         for (index = 0; index < keyboardStatusList.count(); index++) {
-            if (keyboardStatusList.at(index)->text().contains(KEYBOARD_ON)) {
+            if (keyboardStatusList.at(index)->text().contains(MENU_ON_ITEM_TEXT)) {
                 break;
             }
         }
@@ -410,7 +414,7 @@ int KeyboardShortcut::getHwKeyCode(QString item)
     int index = 0, keyCode = 0;
 
     for (index = 0; index < hwKeyList.count(); index++) {
-        if (hwKeyList.at(index)->name.compare(item) == 0) {
+        if (hwKeyList.at(index)->getName().compare(item) == 0) {
             keyCode = hwKeyList.at(index)->
                 getKeycodeType()->getShortPressKeycode();
             break;
@@ -419,7 +423,7 @@ int KeyboardShortcut::getHwKeyCode(QString item)
 
     if (index == hwKeyList.count()) {
         for (index = 0; index < controllerKeyList.count(); index++) {
-            if (controllerKeyList.at(index)->name.compare(item) == 0) {
+            if (controllerKeyList.at(index)->getName().compare(item) == 0) {
                 keyCode = controllerKeyList.at(index)->
                     getKeycodeType()->getShortPressKeycode();
                 break;
index 4c087ec3e7d6f841f94fd1eace4105d892ee3e85..6020a8ddcd15bf0ea9350d648f32ac7f43e9722f 100644 (file)
@@ -43,6 +43,11 @@ HardwareKey::HardwareKey(QString name, KeycodeType *keycodeType,
     }
 }
 
+QString HardwareKey::getName()
+{
+    return name;
+}
+
 KeycodeType *HardwareKey::getKeycodeType()
 {
     return keycodeType;
@@ -53,6 +58,21 @@ bool HardwareKey::hasLongPressKeycode()
     return (keycodeType->getLongPressKeycode() > 0);
 }
 
+QRect HardwareKey::getRegion()
+{
+    return region;
+}
+
+QString HardwareKey::getTooltip()
+{
+    return tooltip;
+}
+
+QString HardwareKey::getKeySequence()
+{
+    return keySequence;
+}
+
 HardwareKey::~HardwareKey()
 {
     if (keycodeType != NULL) {
index ac1a38a20cc593cb8da550c268ba3194999f1664..451dc173dfea00f5bcfbed3d2e392f95aa324bd1 100644 (file)
@@ -41,16 +41,19 @@ public:
         QRect region, QString tooltip, QString keySequence);
     ~HardwareKey();
 
+    QString getName();
     KeycodeType *getKeycodeType();
     bool hasLongPressKeycode();
+    QRect getRegion();
+    QString getTooltip();
+    QString getKeySequence();
 
+private:
     QString name;
+    KeycodeType *keycodeType;
     QRect region;
     QString tooltip;
     QString keySequence;
-
-private:
-    KeycodeType *keycodeType;
 };
 
 #endif // HARDWAREKEY_H
index 6b9e4110abef2f709209767a24288eb8b3043725..65ae1338470316c88a320e3830cac2c5c7b4828a 100644 (file)
@@ -211,7 +211,8 @@ void ContextMenu::createOnTopItem(QMenu *menu, MenuItem *item)
     }
 
     QString menuName = item->getName();
-    actionTopMost = menu->addAction(menuName.isEmpty() ? "Always on Top" : menuName);
+    actionTopMost = menu->addAction(
+        menuName.isEmpty() ? MENU_ONTOP_ITEM_TEXT : menuName);
     actionTopMost->setShortcut(getShortcutKeySeq(menuName));
     actionTopMost->setCheckable(true);
     connect(actionTopMost, SIGNAL(triggered(bool)), this, SLOT(slotTopMost(bool)));
@@ -227,8 +228,9 @@ void ContextMenu::createSwitchItem(QMenu *menu, MenuItem *item)
 
     if (mainFormList.isEmpty() == false) {
         QString menuName = item->getName();
-        switchMenu = menu->addMenu(
-            QIcon(QPixmap(":/icons/rotate.png")), menuName.isEmpty() ? "Switch" : menuName);
+        switchMenu = menu->addMenu(QIcon(QPixmap(":/icons/rotate.png")),
+            menuName.isEmpty() ? MENU_SWITCH_ITEM_TEXT : menuName);
+
         QAction *menuAction = switchMenu->menuAction();
         menuAction->setShortcut(getShortcutKeySeq(menuName));
         switchGroup = new QActionGroup(this);
@@ -262,8 +264,9 @@ void ContextMenu::createScaleItem(QMenu *menu, MenuItem *item)
 
     if (factorMap.isEmpty() == false) {
         QString menuName = item->getName();
-        scaleMenu = menu->addMenu(
-            QIcon(QPixmap(":/icons/scale.png")), menuName.isEmpty() ? "Scale" : menuName);
+        scaleMenu = menu->addMenu(QIcon(QPixmap(":/icons/scale.png")),
+            menuName.isEmpty() ? MENU_SCALE_ITEM_TEXT : menuName);
+
         QAction *menuAction = scaleMenu->menuAction();
         menuAction->setShortcut(getShortcutKeySeq(menuName));
         scaleGroup = new QActionGroup(this);
@@ -306,7 +309,9 @@ void ContextMenu::createControllerItem(QMenu *menu, MenuItem *item)
 
     if (conFormList.isEmpty() == false) {
         QString menuName = item->getName();
-        controllerMenu = menu->addMenu(menuName.isEmpty() ? "Controller" : menuName);
+        controllerMenu = menu->addMenu(
+            menuName.isEmpty() ? MENU_CONTROLLER_ITEM_TEXT : menuName);
+
         QAction *menuAction = controllerMenu->menuAction();
         menuAction->setShortcut(getShortcutKeySeq(menuName));
         controllerGroup = new QActionGroup(this);
@@ -341,17 +346,17 @@ void ContextMenu::createHostKeyboardItem(QMenu *menu, MenuItem *item)
 
     QString menuName = item->getName();
     QMenu *keyboardMenu = menu->addMenu(QIcon(QPixmap(":/icons/host_keyboard.png")),
-        menuName.isEmpty() ? "Host keyboard" : menuName);
+        menuName.isEmpty() ? MENU_HOSTKBD_ITEM_TEXT : menuName);
     QAction *menuAction = keyboardMenu->menuAction();
     menuAction->setShortcut(getShortcutKeySeq(menuName));
     keyboardGroup = new QActionGroup(this);
 
-    QAction *action = keyboardMenu->addAction(KEYBOARD_ON);
+    QAction *action = keyboardMenu->addAction(MENU_ON_ITEM_TEXT);
     action->setActionGroup(keyboardGroup);
     action->setCheckable(true);
     connect(action, SIGNAL(toggled(bool)), this, SLOT(slotHostKeyboard(bool)));
 
-    action = keyboardMenu->addAction(KEYBOARD_OFF);
+    action = keyboardMenu->addAction(MENU_OFF_ITEM_TEXT);
     action->setActionGroup(keyboardGroup);
     action->setCheckable(true);
     action->setChecked(true);
@@ -365,7 +370,7 @@ void ContextMenu::createShellItem(QMenu *menu, MenuItem *item)
 
     QString menuName = item->getName();
     actionShell = addGeneralAction(menu, QIcon(QPixmap(":/icons/shell.png")),
-        menuName.isEmpty() ? "Shell" : menuName, SLOT(slotShell()),
+        menuName.isEmpty() ? MENU_SHELL_ITEM_TEXT : menuName, SLOT(slotShell()),
         getShortcutKeySeq(menuName));
 }
 
@@ -376,8 +381,10 @@ void ContextMenu::createControlPanelItem(QMenu *menu, MenuItem *item)
     }
 
     QString menuName = item->getName();
-    actionControlPanel = addGeneralAction(menu, QIcon(QPixmap(":/icons/control_panel.png")),
-        menuName.isEmpty() ? "Control Panel" : menuName, SLOT(slotControlPanel()),
+    actionControlPanel = addGeneralAction(
+        menu, QIcon(QPixmap(":/icons/control_panel.png")),
+        menuName.isEmpty() ? MENU_ECP_ITEM_TEXT : menuName,
+        SLOT(slotControlPanel()),
         getShortcutKeySeq(menuName));
 }
 
@@ -388,8 +395,10 @@ void ContextMenu::createScreenShotItem(QMenu *menu, MenuItem *item)
     }
 
     QString menuName = item->getName();
-    actionScreenShot = addGeneralAction(menu, QIcon(QPixmap(":/icons/screen_shot.png")),
-        menuName.isEmpty() ? "Screen Shot" : menuName, SLOT(slotRequestScreenshot()),
+    actionScreenShot = addGeneralAction(
+        menu, QIcon(QPixmap(":/icons/screen_shot.png")),
+        menuName.isEmpty() ? MENU_SCREENSHOT_ITEM_TEXT : menuName,
+        SLOT(slotRequestScreenshot()),
         getShortcutKeySeq(menuName));
 }
 
@@ -401,7 +410,7 @@ void ContextMenu::createAboutItem(QMenu *menu, MenuItem *item)
 
     QString menuName = item->getName();
     actionAbout = addGeneralAction(menu, QIcon(QPixmap(":/icons/about.png")),
-        menuName.isEmpty() ? "About" : menuName, SLOT(slotAbout()),
+        menuName.isEmpty() ? MENU_ABOUT_ITEM_TEXT : menuName, SLOT(slotAbout()),
         getShortcutKeySeq(menuName));
 }
 
@@ -412,8 +421,10 @@ void ContextMenu::createForceCloseItem(QMenu *menu, MenuItem *item)
     }
 
     QString menuName = item->getName();
-    actionForceClose = addGeneralAction(menu, QIcon(QPixmap(":/icons/force_close.png")),
-        menuName.isEmpty() ? "Force Close" : menuName, SLOT(slotForceClose()),
+    actionForceClose = addGeneralAction(
+        menu, QIcon(QPixmap(":/icons/force_close.png")),
+        menuName.isEmpty() ? MENU_FORCECLOSE_ITEM_TEXT : menuName,
+        SLOT(slotForceClose()),
         getShortcutKeySeq(menuName));
 }
 
@@ -425,7 +436,7 @@ void ContextMenu::createCloseItem(QMenu *menu, MenuItem *item)
 
     QString menuName = item->getName();
     actionClose = addGeneralAction(menu, QIcon(QPixmap(":/icons/close.png")),
-        menuName.isEmpty() ? "Close" : menuName, SLOT(slotClose()),
+        menuName.isEmpty() ? MENU_CLOSE_ITEM_TEXT : menuName, SLOT(slotClose()),
         getShortcutKeySeq(menuName));
 }
 
index 8eb684a960871a31430ac4f0d691bc0729d8e0fa..991b4e6c0a4f72677b07beeb40d3792a5538c04e 100644 (file)
@@ -50,8 +50,6 @@ extern "C" {
 }
 
 #define CLOSE_POWER_KEY_INTERVAL 1200 /* milli-seconds */
-#define KEYBOARD_ON "On"
-#define KEYBOARD_OFF "Off"
 
 class ContextMenu : public QMenu
 {
index 21dec96f21868929cfa2448003bc40e2ef8b4f74..8a913dfce97d9099f1a0c7b38272f818932f2fd2 100644 (file)
@@ -289,9 +289,10 @@ void DetailedInfoDialog::slotDoubleClicked(int nRow, int nCol)
         QDesktopServices::openUrl(QUrl("file:///" + item->text(), QUrl::TolerantMode));
     } else if (QFileInfo(item->text()).isFile() == true) {
         /* path name is a file name */
-        QDesktopServices::openUrl(QUrl("file:///" + QFileInfo(item->text()).absolutePath(), QUrl::TolerantMode));
+        QDesktopServices::openUrl(QUrl(
+            "file:///" + QFileInfo(item->text()).absolutePath(), QUrl::TolerantMode));
     } else {
-        qDebug("wrong path name");
+        qWarning("wrong path name");
     }
 
     return;
index f249f07d4b481ce2f7e923b060627c197e23396a..b31aadaf5101593c64760663d33578ee05819c75 100644 (file)
 #define SDK_VERSION_FILE "sdk.version"
 #define DISPLAY_OFF_GUIDE_IMAGE_FILE "display_off_guide.png"
 
+/* context menu */
+#define MENU_ONTOP_ITEM_TEXT "Always on Top"
+#define MENU_SWITCH_ITEM_TEXT "Switch"
+#define MENU_SCALE_ITEM_TEXT "Scale"
+#define MENU_CONTROLLER_ITEM_TEXT "Controller"
+#define MENU_HOSTKBD_ITEM_TEXT "Host keyboard"
+#define MENU_SHELL_ITEM_TEXT "Shell"
+#define MENU_ECP_ITEM_TEXT "Control Panel"
+#define MENU_SCREENSHOT_ITEM_TEXT "Screen Shot"
+#define MENU_ABOUT_ITEM_TEXT "About"
+#define MENU_FORCECLOSE_ITEM_TEXT "Force Close"
+#define MENU_CLOSE_ITEM_TEXT "Close"
+
+#define MENU_ON_ITEM_TEXT "On"
+#define MENU_OFF_ITEM_TEXT "OFF"
+
 /* detailed info dialog */
 #define DETAILED_INFO_TITLE "Detailed Info"
 #define DETAILED_INFO_VMTAB_TITLE "VM Info"
index 8431c0f90d9426c1ada9be9961285fd657c8f1ea..ddaf15cea1a85b6f23b191c4ec9674d0c335d6e6 100644 (file)
@@ -33,7 +33,7 @@
 
 SkinKeyItem::SkinKeyItem(SkinBezelItem *parent,
     HardwareKey *hwKey, QImage pressedImg, HoverType *hover) :
-    QGraphicsRectItem(hwKey->region, (QGraphicsItem *)parent)
+    QGraphicsRectItem(hwKey->getRegion(), (QGraphicsItem *)parent)
 {
     this->bezelParent = parent;
     this->pressedImg = pressedImg;
@@ -54,7 +54,7 @@ SkinKeyItem::SkinKeyItem(SkinBezelItem *parent,
     connect(longPressTimer, SIGNAL(timeout()), this, SLOT(longPressHook()));
 
     setToolTip("<span style=background-color:white><font color=black>"
-        + hwKey->tooltip + "</font></span>");
+        + hwKey->getTooltip() + "</font></span>");
 
     setAcceptHoverEvents(true);
 }
@@ -72,7 +72,7 @@ void SkinKeyItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
 
     const int keycode = hwKey->getKeycodeType()->getShortPressKeycode();
 
-    qDebug() << hwKey->name << "key pressed:" << keycode;
+    qDebug() << hwKey->getName() << "key pressed:" << keycode;
     do_hw_key_event(KEY_PRESSED, keycode);
 
     hoverPen.setColor(Qt::transparent);
@@ -90,18 +90,18 @@ void SkinKeyItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
         if (longPressTimer->remainingTime() <= 0) {
             /* long press */
             keycode = hwKey->getKeycodeType()->getLongPressKeycode();
-            qDebug() << hwKey->name << "key long pressed:" << keycode;
+            qDebug() << hwKey->getName() << "key long pressed:" << keycode;
         } else {
             /* short press */
             longPressTimer->stop();
 
-           qDebug() << hwKey->name << "key short pressed:" << keycode;
+           qDebug() << hwKey->getName() << "key short pressed:" << keycode;
         }
 
         do_hw_key_event(KEY_PRESSED, keycode);
     }
 
-    qDebug() << hwKey->name << "key released:" << keycode;
+    qDebug() << hwKey->getName() << "key released:" << keycode;
     do_hw_key_event(KEY_RELEASED, keycode);
 
     update();
index 92152e2952d6a489b58cdb853cc72479935b1178..4bd8d578782d7634de561a862d80e3e8bfaa25af 100644 (file)
@@ -63,7 +63,7 @@ void SkinView::createItems(MainForm *form)
         hwKey = keyList.at(i);
         if (hwKey != NULL) {
             new SkinKeyItem(bezelItem, hwKey,
-                form->skinImg[MainForm::pressed].copy(hwKey->region),
+                form->skinImg[MainForm::pressed].copy(hwKey->getRegion()),
                 form->getHoverType());
         }
     }