• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • navigation
NavigationButton.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2013 Mohammed Nafees <nafees.technocool@gmail.com>
9 //
10 
11 #include "NavigationButton.h"
12 
13 #include <QPainter>
14 #include <QMouseEvent>
15 
16 namespace Marble
17 {
18 
19 NavigationButton::NavigationButton( QWidget *parent )
20  : QAbstractButton( parent ),
21  m_iconMode( QIcon::Normal )
22 {
23  // nothing to do
24 }
25 
26 void NavigationButton::mousePressEvent ( QMouseEvent *mouseEvent )
27 {
28  if ( isEnabled() ) {
29  if ( mouseEvent->button() == Qt::LeftButton ) {
30  m_iconMode = QIcon::Selected;
31  }
32  }
33  emit repaintNeeded();
34 }
35 
36 void NavigationButton::mouseReleaseEvent ( QMouseEvent * )
37 {
38  if ( isEnabled() ) {
39  m_iconMode = QIcon::Active;
40  emit clicked();
41  }
42  emit repaintNeeded();
43 }
44 
45 void NavigationButton::enterEvent(QEvent *)
46 {
47  if ( isEnabled() ) {
48  m_iconMode = QIcon::Active;
49  }
50  emit repaintNeeded();
51 }
52 
53 void NavigationButton::leaveEvent( QEvent * )
54 {
55  if ( isEnabled() ) {
56  m_iconMode = QIcon::Normal;
57  }
58  emit repaintNeeded();
59 }
60 
61 void NavigationButton::changeEvent( QEvent *e )
62 {
63  if ( e->type() == QEvent::EnabledChange ) {
64  m_iconMode = isEnabled() ? QIcon::Normal : QIcon::Disabled;
65  }
66  emit repaintNeeded();
67 }
68 
69 void NavigationButton::paintEvent( QPaintEvent * )
70 {
71  QPainter painter( this );
72  painter.drawPixmap( 0, 0, icon().pixmap( iconSize(), m_iconMode ) );
73 }
74 
75 }
76 
77 #include "NavigationButton.moc"
QAbstractButton
QPainter
Marble::NavigationButton::changeEvent
void changeEvent(QEvent *e)
Definition: NavigationButton.cpp:61
Marble::NavigationButton::paintEvent
void paintEvent(QPaintEvent *)
Definition: NavigationButton.cpp:69
Marble::NavigationButton::leaveEvent
void leaveEvent(QEvent *e)
Definition: NavigationButton.cpp:53
NavigationButton.h
Marble::NavigationButton::repaintNeeded
void repaintNeeded()
QWidget
Marble::NavigationButton::mousePressEvent
void mousePressEvent(QMouseEvent *mouseEvent)
Definition: NavigationButton.cpp:26
Marble::NavigationButton::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *mouseEvent)
Definition: NavigationButton.cpp:36
Marble::NavigationButton::clicked
void clicked()
Marble::NavigationButton::enterEvent
void enterEvent(QEvent *e)
Definition: NavigationButton.cpp:45
Marble::NavigationButton::NavigationButton
NavigationButton(QWidget *parent=0)
Definition: NavigationButton.cpp:19
iconSize
const QSize iconSize(16, 16)
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal