[Kstars-devel] [kstars] kstars/widgets: Make sure SkyMap gets to track the mouse, so it can update the coordinates in the status bar.

Akarsh Simha akarsh.simha at kdemail.net
Sun Oct 14 02:10:34 UTC 2012


Git commit c796525a6f3d706c06558416683dafdf5095c36a by Akarsh Simha.
Committed on 14/10/2012 at 04:03.
Pushed by asimha into branch 'master'.

Make sure SkyMap gets to track the mouse, so it can update the coordinates in the status bar.

Firstly, many thanks to ozzzy on IRC (##astronomy on irc.freenode.org)
for pointing out this bug, and pursuing its case with me.

"InfoBoxes" is a transparent "container" widget occupying the entire
screen area, and having the individual InfoBox widgets as
children. InfoBoxes is a child of the painting widget (SkyMapQDraw or
SkyMapGLDraw as the case may be), which is in turn a child of SkyMap.

Although InfoBoxes and SkyMapFooDraw do not need to track the mouse,
they need to have mouseTracking enabled, because no mouse move events
will be initiated and passed up the stack otherwise.

There is a Qt::WA_TransparentForMouseEvents widget attribute, but
this, according to the documentation, blocks mouse events to the child
InfoBox widgets as well.

This is not optimal -- any overlaying widgets that are translucent
would need to have mouse tracking set to true in order to pass the
mouse move events up to the SkyMap.

Is there a better solution?

CCMAIL: kstars-devel at kde.org

M  +5    -0    kstars/widgets/infoboxwidget.cpp
M  +1    -1    kstars/widgets/infoboxwidget.h

http://commits.kde.org/kstars/c796525a6f3d706c06558416683dafdf5095c36a

diff --git a/kstars/widgets/infoboxwidget.cpp b/kstars/widgets/infoboxwidget.cpp
index d6c80e1..e94dc54 100644
--- a/kstars/widgets/infoboxwidget.cpp
+++ b/kstars/widgets/infoboxwidget.cpp
@@ -30,6 +30,11 @@ const int InfoBoxWidget::padY = 2;
 InfoBoxes::~InfoBoxes()
 {}
 
+InfoBoxes::InfoBoxes(QWidget* parent) : QWidget(parent) {
+    setMouseTracking( true );
+}
+
+
 void InfoBoxes::addInfoBox(InfoBoxWidget* ibox)
 {
     ibox->setParent(this);
diff --git a/kstars/widgets/infoboxwidget.h b/kstars/widgets/infoboxwidget.h
index fdfe2bd..7defae5 100644
--- a/kstars/widgets/infoboxwidget.h
+++ b/kstars/widgets/infoboxwidget.h
@@ -33,7 +33,7 @@ class InfoBoxes : public QWidget
     Q_OBJECT
 public:
 
-    InfoBoxes(QWidget* parent = 0) : QWidget(parent) {}
+    InfoBoxes(QWidget* parent = 0);
     virtual ~InfoBoxes();
 
     void addInfoBox(InfoBoxWidget* ibox);


More information about the Kstars-devel mailing list