[Kde-games-devel] KDE/kdegames/libkdegames

Dmitry Suzdalev dimsuz at gmail.com
Wed Apr 16 22:28:19 CEST 2008


SVN commit 797744 by dimsuz:

Add a possibility to specify whether a KGamePopupItem should
hide itself when clicked.

Before this change it was always hidden on click.
Now I added setHideOnMouseClick(bool) function which can be used
to toggle this behaviour.

This can be useful in e.g. kdiamond (for its "Game paused" message) and in an upcoming
patch for kmines from Gnushi.

CC-ing kde-games-devel in case some other games might find this addition useful.

CCMAIL: kde-games-devel at kde.org


 M  +18 -2     kgamepopupitem.cpp  
 M  +9 -1      kgamepopupitem.h  


--- trunk/KDE/kdegames/libkdegames/kgamepopupitem.cpp #797743:797744
@@ -67,7 +67,8 @@
 public:
     KGamePopupItemPrivate()
         : m_position( KGamePopupItem::BottomLeft ), m_timeout(2000),
-          m_opacity(1.0), m_animOpacity(-1), m_hoveredByMouse(false), m_textChildItem(0),
+          m_opacity(1.0), m_animOpacity(-1), m_hoveredByMouse(false),
+          m_hideOnClick(false), m_textChildItem(0),
           m_sharpness(KGamePopupItem::Square) {}
     /**
      * Timeline for animations
@@ -106,6 +107,10 @@
      */
     bool m_hoveredByMouse;
     /**
+     * Set to true if this popup item hides on mouse click.
+     */
+    bool m_hideOnClick;
+    /**
      * Child of KGamePopupItem used to display text
      */
     TextItemWithOpacity* m_textChildItem;
@@ -312,6 +317,16 @@
     d->m_timeout = msec;
 }
 
+void KGamePopupItem::setHideOnMouseClick( bool hide )
+{
+    d->m_hideOnClick = hide;
+}
+
+bool KGamePopupItem::hidesOnMouseClick() const
+{
+    return d->m_hideOnClick;
+}
+
 void KGamePopupItem::setMessageOpacity( qreal opacity )
 {
     d->m_opacity = opacity;
@@ -432,7 +447,8 @@
 
 void KGamePopupItem::mouseReleaseEvent( QGraphicsSceneMouseEvent* )
 {
-    forceHide();
+    if (d->m_hideOnClick)
+        forceHide();
 }
 
 
--- trunk/KDE/kdegames/libkdegames/kgamepopupitem.h #797743:797744
@@ -111,8 +111,16 @@
      * Sets custom pixmap to show instead of default icon on the left
      */
     void setMessageIcon( const QPixmap& pix );
-
     /**
+     * Sets whether to hide this popup item on mouse click.
+     * By default a mouse click will cause an item to hide
+     */
+    void setHideOnMouseClick( bool hide );
+    /**
+     * @return whether this popup item hides on mouse click.
+     */
+    bool hidesOnMouseClick() const;
+    /**
      * Used to specify how to hide in forceHide() - instantly or animatedly
      */
     enum HideType { InstantHide, AnimatedHide };


More information about the kde-games-devel mailing list