display: added blank guide image for qt
authorsungmin ha <sungmin82.ha@samsung.com>
Tue, 2 Jun 2015 07:30:04 +0000 (16:30 +0900)
committersung min Ha <sungmin82.ha@samsung.com>
Tue, 2 Jun 2015 08:20:36 +0000 (17:20 +0900)
Change-Id: I013e3c83bffaadfb27017bfdef4640a60ad3bfde
Signed-off-by: sungmin ha <sungmin82.ha@samsung.com>
tizen/src/display/qt5_supplement.cpp
tizen/src/hw/pci/maru_brightness.c
tizen/src/hw/pci/maru_brightness.h
tizen/src/ui/displaybase.cpp
tizen/src/ui/displaybase.h
tizen/src/ui/menu/contextmenu.cpp

index 2b41034..a9618f3 100644 (file)
 #include "layout/hardwarekey.h"
 #include "xmllayoutparser.h"
 #include "uiutil.h"
+#include "displaybase.h"
 
 extern "C" {
 #include "emul_state.h"
+bool is_display_off(void);
 }
 
 //using namespace std;
@@ -51,6 +53,9 @@ QApplication *qt5App = NULL;
 static int argc = 0;
 static char *argv[0];
 
+#define MAX_BLANK_FRAME_CNT 10
+static unsigned int blank_cnt;
+
 static void *captureRequestListener;
 static void (*captureRequestHandler)(void *);
 
@@ -316,6 +321,30 @@ void qt5_switch_internal(void)
 void qt5_refresh_internal(void)
 {
     qt5App->processEvents();
+
+    DisplayBase *db = mainwindow->getDisplay();
+    if (db) {
+        if (db->getIsGimgReady()) {
+            if (is_display_off()) {
+                if (db->getGimgState() == false) {
+                    if (blank_cnt > MAX_BLANK_FRAME_CNT) {
+                        db->startGuideImg();
+                        blank_cnt = 0;
+                    } else {
+                        blank_cnt++;
+                    }
+                }
+            } else {
+                if (db->getGimgState() == true) {
+                    db->stopGuideImg();
+                }
+
+                blank_cnt = 0;
+            }
+        }
+    } else {
+        qDebug() << "Display is not ready.";
+    }
 }
 
 void qt5_register_capture_request_listener(void *listener, void (*handler)(void *))
index 1db56ff..c0004d1 100644 (file)
@@ -107,6 +107,11 @@ void composite_brightness_image_to_pixel(void *pixels,
     }
 }
 
+bool is_display_off(void)
+{
+    return display_off;
+}
+
 static uint64_t brightness_reg_read(void *opaque,
                                     hwaddr addr,
                                     unsigned size)
index 581ae91..3c74c33 100644 (file)
@@ -48,4 +48,5 @@ void composite_brightness_image_to_pixel(void *pixels,
                                          uint32_t width,
                                          uint32_t height);
 
+bool is_display_off(void);
 #endif /* MARU_BRIGHTNESS_H_ */
index 0a21504..385a5d0 100644 (file)
@@ -31,6 +31,9 @@
 #include "displaybase.h"
 #include "mainwindow.h"
 
+#define BLANK_GUIDE_IMAGE_PATH "../images/"
+#define BLANK_GUIDE_IMAGE_NAME "blank-guide.png"
+
 uint32_t qt5_window_width = 0;
 uint32_t qt5_window_height = 0;
 int qt5_window_angle = 0;
@@ -43,14 +46,72 @@ DisplayBase::DisplayBase(DisplayType *displayForm, qreal scaleFactor,
     this->rotateAngle = displayForm->getAngle();
     this->scaleFactor = scaleFactor;
     this->isDragging = false;
+    this->gImgState = false;
 
     this->tsHelper = new TouchScreenHelper(this);
+    this->gImg = new QImage();
+    this->gPxmImg = new QPixmap();
+
+    loadGuideImg();
+
     MainWindow *win = (MainWindow *)widget->parentWidget();
     win->getSkinView()->getKbdHelper()->setMtTracker(tsHelper->getMtTracker());
 
     updateGeometry();
 }
 
+void DisplayBase::loadGuideImg()
+{
+    QString guide_img_path(BLANK_GUIDE_IMAGE_PATH);
+    guide_img_path.append(BLANK_GUIDE_IMAGE_NAME);
+
+    bool ret = gImg->load(guide_img_path);
+    if (ret == false) {
+        qDebug() << guide_img_path << ": No such file";
+        isGimgReady = false;
+    } else {
+        isGimgReady = true;
+    }
+}
+
+void DisplayBase::startGuideImg()
+{
+    MainWindow *win = (MainWindow *)widget->parentWidget();
+    int rWidth = rect.width() * scaleFactor;
+    int rHeight = rect.height() * scaleFactor;
+    int x = rect.x() * scaleFactor;
+    int y = rect.y() * scaleFactor;
+
+    gLabel = new QLabel(win);
+    gLabel->setAttribute(Qt::WA_DeleteOnClose);
+
+    *gPxmImg = QPixmap::fromImage(*gImg);
+    *gPxmImg = gPxmImg->scaled(rWidth, rHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+
+    gLabel->setPixmap(*gPxmImg);
+    gLabel->setGeometry(x, y, rWidth, rHeight);
+    gLabel->setAlignment(Qt::AlignCenter);
+    gLabel->show();
+
+    gImgState = true;
+}
+
+void DisplayBase::stopGuideImg()
+{
+    gLabel->close();
+    gImgState = false;
+}
+
+bool DisplayBase::getIsGimgReady()
+{
+    return isGimgReady;
+}
+
+bool DisplayBase::getGimgState()
+{
+    return gImgState;
+}
+
 void DisplayBase::switchForm(DisplayType *displayForm)
 {
     qDebug() << "display switch angle :" << displayForm->getAngle();
index a43df94..674fbfe 100644 (file)
@@ -32,6 +32,9 @@
 #define DISPLAYBASE_H
 
 #include <QWidget>
+#include <QLabel>
+#include <QImage>
+#include <QPixmap>
 
 #include "layout/displaytype.h"
 #include "input/touchscreenhelper.h"
@@ -43,6 +46,11 @@ void qt5_graphic_hw_invalidate(void);
 class DisplayBase
 {
 public:
+    void loadGuideImg();
+    void startGuideImg();
+    void stopGuideImg();
+    bool getIsGimgReady();
+    bool getGimgState();
     void switchForm(DisplayType *displayForm);
     void scaleForm(qreal scaleFactor);
     void update();
@@ -69,11 +77,16 @@ protected:
     bool isDragging;
 
 private:
+    QLabel *gLabel;
+    QPixmap *gPxmImg;
+    QImage *gImg;
     QWidget *widget;
     TouchScreenHelper *tsHelper;
 
     QRect rect;
     QPixmap maskImage;
+    bool isGimgReady;
+    bool gImgState;
 };
 
 #endif
index 6d5e099..442e996 100644 (file)
@@ -461,6 +461,15 @@ void ContextMenu::slotSwitch(int index)
 
     parent->switchForm(index);
 
+    DisplayBase *db = parent->getDisplay();
+    if (db) {
+        if (db->getGimgState() == true) {
+            db->stopGuideImg();
+        }
+    } else {
+        qDebug() << "Display is not ready.";
+    }
+
     /* reset HwKey shortcut */
     KeyboardShortcut *keyboardShortcut = parent->getKeyboardShortcut();
     keyboardShortcut->removeHwKeyShortcut();
@@ -472,6 +481,15 @@ void ContextMenu::slotScale(int scale)
     qDebug("scale : %d", scale);
 
     parent->scaleForm(scale);
+
+    DisplayBase *db = parent->getDisplay();
+    if (db) {
+        if (db->getGimgState() == true) {
+            db->stopGuideImg();
+        }
+    } else {
+        qDebug() << "Display is not ready.";
+    }
 }
 
 void ContextMenu::slotController(int index)