From: sungmin ha Date: Tue, 2 Jun 2015 07:30:04 +0000 (+0900) Subject: display: added blank guide image for qt X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~393^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fec35d470a3bb040b1329ebd3e7368bf73519657;p=sdk%2Femulator%2Fqemu.git display: added blank guide image for qt Change-Id: I013e3c83bffaadfb27017bfdef4640a60ad3bfde Signed-off-by: sungmin ha --- diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index 2b41034b5d..a9618f3e68 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -35,9 +35,11 @@ #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 *)) diff --git a/tizen/src/hw/pci/maru_brightness.c b/tizen/src/hw/pci/maru_brightness.c index 1db56ffd36..c0004d163a 100644 --- a/tizen/src/hw/pci/maru_brightness.c +++ b/tizen/src/hw/pci/maru_brightness.c @@ -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) diff --git a/tizen/src/hw/pci/maru_brightness.h b/tizen/src/hw/pci/maru_brightness.h index 581ae91177..3c74c33d66 100644 --- a/tizen/src/hw/pci/maru_brightness.h +++ b/tizen/src/hw/pci/maru_brightness.h @@ -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_ */ diff --git a/tizen/src/ui/displaybase.cpp b/tizen/src/ui/displaybase.cpp index 0a2150498f..385a5d0749 100644 --- a/tizen/src/ui/displaybase.cpp +++ b/tizen/src/ui/displaybase.cpp @@ -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(); diff --git a/tizen/src/ui/displaybase.h b/tizen/src/ui/displaybase.h index a43df941e7..674fbfef3e 100644 --- a/tizen/src/ui/displaybase.h +++ b/tizen/src/ui/displaybase.h @@ -32,6 +32,9 @@ #define DISPLAYBASE_H #include +#include +#include +#include #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 diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 6d5e099c11..442e9968f2 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -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)