display: fix off-guide image issues
authorJinhyung Jo <jinhyung.jo@samsung.com>
Fri, 11 Nov 2016 09:25:45 +0000 (18:25 +0900)
committerJinhyung Jo <jinhyung.jo@samsung.com>
Mon, 14 Nov 2016 07:57:09 +0000 (16:57 +0900)
The off-guide image does not scale and does not rotate
since "ui: reuse resource when it is reusable" commit has been applied.
Now showOffGuideImg() updates the geometry each time it is called.
And delete unnecessary code and clean up the off-guide image code.
The ancestor class of the QLabel, QWidget class, already has similar variable
and manipulation functions for the offGuideShown variable.

Change-Id: I5ae29e12ac2220842f312e3ae2d7cc0b19995d4c
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
tizen/src/ui/displaybase.cpp
tizen/src/ui/displaybase.h

index 1daff06..2d63aeb 100644 (file)
@@ -59,7 +59,6 @@ DisplayBase::DisplayBase(DisplayType *displayForm, QSize resolution, qreal scale
     this->mouseHelper = NULL;
 
     this->offGuide = NULL;
-    this->offGuideShown = false;
 
     this->movingMode = false;
     this->grabPos = SKINVIEW_NULLITY_POSITION;
@@ -108,24 +107,21 @@ bool DisplayBase::isOffGuideReady()
 
 void DisplayBase::showOffGuideImg()
 {
-    offGuideShown = true;
-
     if (!offGuide) {
         offGuide = new QLabel(win);
         offGuide->setStyleSheet(
                 "background-color: black; border-style: none;");
         offGuide->setAlignment(Qt::AlignCenter);
+    }
+    offGuide->setGeometry(getGeometry());
+    offGuide->setPixmap(offGuideImg.scaled(
+                getGeometry().width(), getGeometry().height(),
+                Qt::KeepAspectRatio, Qt::SmoothTransformation));
 
-        offGuide->setGeometry(getGeometry());
-        offGuide->setPixmap(offGuideImg.scaled(
-                    getGeometry().width(), getGeometry().height(),
-                    Qt::KeepAspectRatio, Qt::SmoothTransformation));
-
-        if (maskImage.size() != QSize(0, 0)) {
-            offGuide->setMask(maskImage.scaled(
-                        maskImage.width() * scaleFactor,
-                        maskImage.height() * scaleFactor).mask());
-        }
+    if (maskImage.size() != QSize(0, 0)) {
+        offGuide->setMask(maskImage.scaled(
+                    maskImage.width() * scaleFactor,
+                    maskImage.height() * scaleFactor).mask());
     }
 
     offGuide->show();
@@ -133,16 +129,14 @@ void DisplayBase::showOffGuideImg()
 
 void DisplayBase::hideOffGuideImg()
 {
-    if (offGuide != NULL) {
-        offGuide->close();
+    if (isOffGuideShown()) {
+        offGuide->hide();
     }
-
-    offGuideShown = false;
 }
 
 bool DisplayBase::isOffGuideShown()
 {
-    return offGuideShown;
+    return (offGuide && offGuide->isVisible());
 }
 
 void DisplayBase::switchForm(DisplayType *displayForm)
@@ -180,9 +174,7 @@ void DisplayBase::update()
 
 void DisplayBase::updateGeometry()
 {
-    if (isOffGuideShown() == true) {
-        hideOffGuideImg();
-    }
+    hideOffGuideImg();
 
     qreal sx = rect.x() * scaleFactor;
     qreal sy = rect.y() * scaleFactor;
@@ -590,7 +582,9 @@ DisplayBase::~DisplayBase()
 {
     qDebug("destroy display");
 
-    hideOffGuideImg();
+    if (offGuide != NULL) {
+        delete offGuide;
+    }
 
     if (tsHelper != NULL) {
         delete tsHelper;
index 73d96c6..7455890 100644 (file)
@@ -113,7 +113,6 @@ private:
     bool dropping;
     QLabel *offGuide;
     QPixmap offGuideImg;
-    bool offGuideShown;
 
     QPoint grabPos;
     QPoint grabWinPos;