[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/kstars/kstars/widgets
From:       Alexey Khudyakov <alexey.skladnoy () gmail ! com>
Date:       2009-12-10 2:52:24
Message-ID: 1260413544.044068.20910.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1060839 by khudyakov:

Adjust coordinates of infoboxes only if they are visible. This should
prevent infoboxes from stickying to wrong border at startup

Thanks to Lukas Middendorf for spotting this.

 M  +10 -0     infoboxwidget.cpp  
 M  +2 -0      infoboxwidget.h  


--- trunk/KDE/kdeedu/kstars/kstars/widgets/infoboxwidget.cpp #1060838:1060839
@@ -48,6 +48,7 @@
 InfoBoxWidget::InfoBoxWidget(bool shade, QPoint pos, int anchor, QStringList str, QWidget* parent) :
     QWidget(parent),
     m_strings(str),
+    m_adjusted(false),
     m_grabbed(false),
     m_shaded(shade),
     m_anchor(anchor)
@@ -132,6 +133,8 @@
 }
 
 void InfoBoxWidget::adjust() {
+    if( !isVisible() )
+        return;
     // X axis
     int newX = x();
     int maxX = parentWidget()->width() - width();
@@ -153,6 +156,7 @@
             m_anchor |= AnchorBottom;
     }
     // Do move
+    m_adjusted = true;
     move(newX, newY);
 }
 
@@ -212,9 +216,15 @@
         m_anchor &= ~AnchorBottom;
     }
     // Do move
+    m_adjusted = true;
     move(newX, newY);
 }
 
+void InfoBoxWidget::showEvent(QShowEvent*) {
+    if( !m_adjusted )
+        adjust();
+}
+
 void InfoBoxWidget::mouseDoubleClickEvent(QMouseEvent*) {
     m_shaded = !m_shaded;
     updateSize();
--- trunk/KDE/kdeedu/kstars/kstars/widgets/infoboxwidget.h #1060838:1060839
@@ -84,6 +84,7 @@
     virtual void mouseDoubleClickEvent(QMouseEvent * event );
     virtual void mouseMoveEvent(QMouseEvent* event );
     virtual void mouseReleaseEvent(QMouseEvent* event);
+    virtual void showEvent(QShowEvent* event);
 private:
     /** Uset to set information about object. */
     void setPoint(QString name, SkyPoint* p);
@@ -91,6 +92,7 @@
     void updateSize();
     
     QStringList m_strings;  // list of string to show
+    bool m_adjusted;        // True if widget coordinates were adjusted
     bool m_grabbed;         // True if widget is dragged around
     bool m_shaded;          // True if widget if shaded
     int  m_anchor;          // Vertical alignment of widget
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic