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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • declarative
ZoomButtonInterceptor.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 2011 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include "ZoomButtonInterceptor.h"
12 
13 #include <QKeyEvent>
14 #include <QApplication>
15 
16 #ifdef HARMATTAN_ZOOMINTERCEPTOR
17 #include <policy/resource-set.h>
18 #endif // HARMATTAN_ZOOMINTERCEPTOR
19 
20 #include "MarbleDeclarativeWidget.h"
21 
22 class ZoomButtonInterceptorPrivate
23 {
24 public:
25  ZoomButtonInterceptorPrivate( MarbleWidget* widget );
26 
27  ~ZoomButtonInterceptorPrivate();
28 
29  MarbleWidget* m_widget;
30 
31 #ifdef HARMATTAN_ZOOMINTERCEPTOR
32  ResourcePolicy::ResourceSet* m_resourceSet;
33 #endif //HARMATTAN_ZOOMINTERCEPTOR
34 };
35 
36 ZoomButtonInterceptorPrivate::ZoomButtonInterceptorPrivate(MarbleWidget *widget)
37  : m_widget( widget )
38 #ifdef HARMATTAN_ZOOMINTERCEPTOR
39  , m_resourceSet( new ResourcePolicy::ResourceSet( "player" ) )
40 #endif //HARMATTAN_ZOOMINTERCEPTOR
41 {
42 #ifdef HARMATTAN_ZOOMINTERCEPTOR
43  m_resourceSet->addResourceObject( new ResourcePolicy::ScaleButtonResource );
44  m_resourceSet->acquire();
45 #endif //HARMATTAN_ZOOMINTERCEPTOR
46 }
47 
48 ZoomButtonInterceptorPrivate::~ZoomButtonInterceptorPrivate()
49 {
50 #ifdef HARMATTAN_ZOOMINTERCEPTOR
51  m_resourceSet->deleteResource( ResourcePolicy::ScaleButtonType );
52  delete m_resourceSet;
53 #endif //HARMATTAN_ZOOMINTERCEPTOR
54 }
55 
56 bool ZoomButtonInterceptor::eventFilter(QObject *object, QEvent *event)
57 {
58 #ifdef HARMATTAN_ZOOMINTERCEPTOR
59  if ( object == d->m_widget ) {
60  if ( event->type() == QEvent::Show ) {
61  d->m_resourceSet->acquire();
62  } else if ( event->type() == QEvent::Hide ) {
63  d->m_resourceSet->release();
64  }
65  return false;
66  }
67 
68  if ( event->type() == QEvent::KeyPress && d->m_widget->isVisible() ) {
69  QKeyEvent* keyEvent = static_cast<QKeyEvent*>( event );
70  if ( keyEvent->key() == Qt::Key_VolumeDown ) {
71  d->m_widget->zoomOut();
72  return true;
73  }
74 
75  if ( keyEvent->key() == Qt::Key_VolumeUp ) {
76  d->m_widget->zoomIn();
77  return true;
78  }
79  } else if ( event->type() == QEvent::ApplicationDeactivate ) {
80  d->m_resourceSet->release();
81  } else if ( event->type() == QEvent::ApplicationActivate ) {
82  d->m_resourceSet->acquire();
83  }
84 #else
85  Q_UNUSED( object )
86  Q_UNUSED( event )
87 #endif // HARMATTAN_ZOOMINTERCEPTOR
88 
89  return false;
90 }
91 
92 ZoomButtonInterceptor::ZoomButtonInterceptor( MarbleWidget *widget, QObject *parent )
93  : QObject( parent ),
94  d( new ZoomButtonInterceptorPrivate( widget ) )
95 {
96  QApplication::instance()->installEventFilter( this );
97  widget->installEventFilter( this );
98 }
99 
100 ZoomButtonInterceptor::~ZoomButtonInterceptor()
101 {
102  delete d;
103 }
104 
105 #include "ZoomButtonInterceptor.moc"
QEvent
QEvent::type
Type type() const
MarbleDeclarativeWidget.h
ZoomButtonInterceptor::eventFilter
virtual bool eventFilter(QObject *, QEvent *event)
Definition: ZoomButtonInterceptor.cpp:56
ZoomButtonInterceptor::~ZoomButtonInterceptor
~ZoomButtonInterceptor()
Definition: ZoomButtonInterceptor.cpp:100
QObject::installEventFilter
void installEventFilter(QObject *filterObj)
QObject
ZoomButtonInterceptor::ZoomButtonInterceptor
ZoomButtonInterceptor(MarbleWidget *widget, QObject *parent)
Definition: ZoomButtonInterceptor.cpp:92
QCoreApplication::instance
QCoreApplication * instance()
ZoomButtonInterceptor.h
QKeyEvent::key
int key() const
QKeyEvent
MarbleWidget
Wraps a Marble::MarbleWidget, providing access to important properties and methods.
Definition: MarbleDeclarativeWidget.h:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:42 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
  • 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