KDEGames

kgamepopupitem.h
1 /*******************************************************************
2  Copyright 2007 Dmitry Suzdalev <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ********************************************************************/
18 #ifndef K_GAME_POPUP_ITEM_H
19 #define K_GAME_POPUP_ITEM_H
20 
21 #include <libkdegames_export.h>
22 
23 #include <QGraphicsItem>
24 #include <QObject>
25 
26 class KGamePopupItemPrivate;
27 
45 class KDEGAMES_EXPORT KGamePopupItem : public QObject, public QGraphicsItem
46 {
47  Q_OBJECT
49 public:
54  enum ReplaceMode { LeavePrevious, ReplacePrevious };
58  enum Sharpness { Square=0, Sharp=2, Soft=5, Softest=10 };
62  enum Position { TopLeft, TopRight, BottomLeft, BottomRight, Center };
66  explicit KGamePopupItem(QGraphicsItem * parent = nullptr);
70  ~KGamePopupItem();
86  void showMessage( const QString& text, Position pos, ReplaceMode mode = LeavePrevious);
98  void setMessageTimeout( int msec );
102  int messageTimeout() const;
108  void setMessageOpacity( qreal opacity );
112  qreal messageOpacity() const;
116  void setMessageIcon( const QPixmap& pix );
121  void setHideOnMouseClick( bool hide );
125  bool hidesOnMouseClick() const;
129  enum HideType { InstantHide, AnimatedHide };
133  void forceHide(HideType type=AnimatedHide);
139  void setBackgroundBrush( const QBrush& brush );
145  void setTextColor( const QColor& color );
149  QRectF boundingRect() const override;
153  void paint( QPainter* p, const QStyleOptionGraphicsItem *option, QWidget* widget ) override;
157  void setSharpness( Sharpness sharpness );
161  Sharpness sharpness() const;
162 Q_SIGNALS:
166  void linkActivated( const QString& link );
170  void linkHovered( const QString& link );
175  void hidden();
176 private Q_SLOTS:
177  void animationFrame(int);
178  void hideMe();
179  void playHideAnimation();
180  void onLinkHovered(const QString&);
181  void onTextItemClicked();
182 private:
183  void setupTimeline();
184  void mousePressEvent( QGraphicsSceneMouseEvent* ) override;
186  void hoverEnterEvent( QGraphicsSceneHoverEvent* ) override;
187  void hoverLeaveEvent( QGraphicsSceneHoverEvent* ) override;
188 
189  KGamePopupItemPrivate * const d;
190 };
191 
192 #endif
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
ReplaceMode
Possible values for message showing mode in respect to a previous message.
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)=0
QGraphicsItem capable of showing short popup messages which do not interrupt the gameplay.
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Position
The possible places in the scene where a message can be shown.
virtual QRectF boundingRect() const const =0
Q_INTERFACES(...)
Sharpness
Possible values for the popup angles sharpness.
HideType
Used to specify how to hide in forceHide() - instantly or animatedly.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 22:37:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.