• 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
  • render
  • inhibit-screensaver
InhibitScreensaverPlugin.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 2010 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include "InhibitScreensaverPlugin.h"
12 
13 #include "PositionTracking.h"
14 #include "MarbleDebug.h"
15 #include "MarbleModel.h"
16 
17 #include <QTimer>
18 #include <QDBusConnection>
19 #include <QDBusInterface>
20 
21 namespace Marble {
22 
23 class InhibitScreensaverPluginPrivate
24 {
25 public:
26  QDBusInterface *m_interface;
27 
28  QTimer m_timer;
29 
30  InhibitScreensaverPluginPrivate();
31 
32  ~InhibitScreensaverPluginPrivate();
33 };
34 
35 InhibitScreensaverPluginPrivate::InhibitScreensaverPluginPrivate() :
36  m_interface( 0 )
37 {
38  m_timer.setInterval( 10 * 1000 ); // timeout of 10 seconds
39 }
40 
41 InhibitScreensaverPluginPrivate::~InhibitScreensaverPluginPrivate()
42 {
43  delete m_interface;
44 }
45 
46 InhibitScreensaverPlugin::InhibitScreensaverPlugin() :
47  RenderPlugin( 0 ),
48  d( 0 )
49 {
50 }
51 
52 InhibitScreensaverPlugin::InhibitScreensaverPlugin( const MarbleModel *marbleModel ) :
53  RenderPlugin( marbleModel ),
54  d ( new InhibitScreensaverPluginPrivate() )
55 {
56  connect( &d->m_timer, SIGNAL(timeout()), this, SLOT(inhibitScreenSaver()) );
57 
58 #ifdef Q_WS_MAEMO_5
59  setEnabled( true );
60  setVisible( true );
61 #else
62  qDebug() << "The inhibit screensaver plugin is only useful on Maemo.";
63  setEnabled( false );
64  setVisible( false );
65 #endif
66 }
67 
68 InhibitScreensaverPlugin::~InhibitScreensaverPlugin()
69 {
70  delete d;
71 }
72 
73 QStringList InhibitScreensaverPlugin::backendTypes() const
74 {
75  return QStringList( nameId() );
76 }
77 
78 QStringList InhibitScreensaverPlugin::renderPosition() const
79 {
80  // We're invisible, but need to be initialized
81  return QStringList( "FLOAT_ITEM" );
82 }
83 
84 QString InhibitScreensaverPlugin::name() const
85 {
86  return tr( "Inhibit Screensaver" );
87 }
88 
89 QString InhibitScreensaverPlugin::guiString() const
90 {
91  return tr( "&Inhibit Screensaver" );
92 }
93 
94 QString InhibitScreensaverPlugin::nameId() const
95 {
96  return QString("inhibit-screensaver");
97 }
98 
99 QString InhibitScreensaverPlugin::version() const
100 {
101  return "1.0";
102 }
103 
104 QString InhibitScreensaverPlugin::description() const
105 {
106  return tr( "Inhibits the screensaver during turn-by-turn navigation" );
107 }
108 
109 QString InhibitScreensaverPlugin::copyrightYears() const
110 {
111  return "2010";
112 }
113 
114 QList<PluginAuthor> InhibitScreensaverPlugin::pluginAuthors() const
115 {
116  return QList<PluginAuthor>()
117  << PluginAuthor( QString::fromUtf8( "Dennis Nienhüser" ), "earthwings@gentoo.org" );
118 }
119 
120 QIcon InhibitScreensaverPlugin::icon() const
121 {
122  return QIcon();
123 }
124 
125 void InhibitScreensaverPlugin::initialize()
126 {
127  Q_ASSERT( marbleModel() && marbleModel()->positionTracking() );
128 
129  d->m_interface= new QDBusInterface( "com.nokia.mce", "/com/nokia/mce/request",
130  "com.nokia.mce.request", QDBusConnection::systemBus() );
131 
132  PositionTracking *tracking = marbleModel()->positionTracking();
133  connect( tracking, SIGNAL(positionProviderPluginChanged(PositionProviderPlugin*)),
134  this, SLOT(updateScreenSaverState(PositionProviderPlugin*)) );
135  updateScreenSaverState( tracking->positionProviderPlugin() );
136 }
137 
138 bool InhibitScreensaverPlugin::isInitialized() const
139 {
140  return d->m_interface;
141 }
142 
143 void InhibitScreensaverPlugin::updateScreenSaverState( PositionProviderPlugin *activePlugin )
144 {
145  if ( !enabled() ) {
146  return;
147  }
148 
149  if ( activePlugin ) {
150  d->m_timer.start(); // Inhibit screensaver
151  } else {
152  d->m_timer.stop();
153  }
154 }
155 
156 void InhibitScreensaverPlugin::inhibitScreenSaver()
157 {
158  if ( d->m_interface && d->m_interface->isValid() ) {
159  d->m_interface->call( "req_display_blanking_pause" );
160  }
161 }
162 
163 bool InhibitScreensaverPlugin::render( GeoPainter *, ViewportParams *, const QString&, GeoSceneLayer *)
164 {
165  // invisible
166  return true;
167 }
168 
169 QString InhibitScreensaverPlugin::renderPolicy() const
170 {
171  return "NEVER";
172 }
173 
174 }
175 
176 Q_EXPORT_PLUGIN2( InhibitScreensaverPlugin, Marble::InhibitScreensaverPlugin )
177 
178 #include "InhibitScreensaverPlugin.moc"
Marble::PositionTracking::positionProviderPlugin
PositionProviderPlugin positionProviderPlugin
Definition: PositionTracking.h:35
Marble::InhibitScreensaverPlugin::icon
QIcon icon() const
Returns an icon for the plugin.
Definition: InhibitScreensaverPlugin.cpp:120
tracking
Definition: position-tracking.qml:12
Marble::InhibitScreensaverPlugin::version
QString version() const
Definition: InhibitScreensaverPlugin.cpp:99
Marble::GeoPainter
A painter that allows to draw geometric primitives on the map.
Definition: GeoPainter.h:98
MarbleModel.h
This file contains the headers for MarbleModel.
Marble::PluginAuthor
Definition: PluginInterface.h:28
QDBusConnection::systemBus
QDBusConnection systemBus()
Marble::InhibitScreensaverPlugin::initialize
void initialize()
Definition: InhibitScreensaverPlugin.cpp:125
Marble::InhibitScreensaverPlugin::name
QString name() const
Returns the user-visible name of the plugin.
Definition: InhibitScreensaverPlugin.cpp:84
MarbleDebug.h
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
Marble::PositionProviderPlugin
The abstract class that provides position information.
Definition: PositionProviderPlugin.h:26
Marble::PositionTracking
Definition: PositionTracking.h:31
Marble::GeoSceneLayer
Layer of a GeoScene document.
Definition: GeoSceneLayer.h:43
QString::fromUtf8
QString fromUtf8(const char *str, int size)
Marble::InhibitScreensaverPlugin::renderPosition
virtual QStringList renderPosition() const
Preferred level in the layer stack for the rendering.
Definition: InhibitScreensaverPlugin.cpp:78
QTimer
Marble::InhibitScreensaverPlugin::guiString
QString guiString() const
String that should be displayed in GUI.
Definition: InhibitScreensaverPlugin.cpp:89
Marble::MarbleModel::positionTracking
PositionTracking * positionTracking() const
Definition: MarbleModel.cpp:512
Marble::InhibitScreensaverPlugin::backendTypes
QStringList backendTypes() const
Returns the name(s) of the backend that the plugin can render This method should return the name of t...
Definition: InhibitScreensaverPlugin.cpp:73
Marble::RenderPlugin::setVisible
void setVisible(bool visible)
settting visible
Definition: RenderPlugin.cpp:151
QString
QList
Marble::InhibitScreensaverPlugin::copyrightYears
QString copyrightYears() const
Definition: InhibitScreensaverPlugin.cpp:109
QStringList
Marble::ViewportParams
A public class that controls what is visible in the viewport of a Marble map.
Definition: ViewportParams.h:44
QDBusInterface
Q_EXPORT_PLUGIN2
#define Q_EXPORT_PLUGIN2(a, b)
Definition: marble_export.h:34
Marble::InhibitScreensaverPlugin::~InhibitScreensaverPlugin
~InhibitScreensaverPlugin()
Definition: InhibitScreensaverPlugin.cpp:68
Marble::InhibitScreensaverPlugin::description
QString description() const
Returns a user description of the plugin.
Definition: InhibitScreensaverPlugin.cpp:104
Marble::MarbleModel
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition: MarbleModel.h:97
Marble::InhibitScreensaverPlugin::isInitialized
bool isInitialized() const
Definition: InhibitScreensaverPlugin.cpp:138
Marble::RenderPlugin::setEnabled
void setEnabled(bool enabled)
settting enabled
Definition: RenderPlugin.cpp:139
Marble::InhibitScreensaverPlugin::nameId
QString nameId() const
Returns the unique name of the plugin.
Definition: InhibitScreensaverPlugin.cpp:94
InhibitScreensaverPlugin.h
Marble::InhibitScreensaverPlugin::InhibitScreensaverPlugin
InhibitScreensaverPlugin()
Definition: InhibitScreensaverPlugin.cpp:46
Marble::RenderPlugin::enabled
bool enabled() const
is enabled
Marble::InhibitScreensaverPlugin::renderPolicy
virtual QString renderPolicy() const
Return how the plugin settings should be used.
Definition: InhibitScreensaverPlugin.cpp:169
Marble::InhibitScreensaverPlugin::pluginAuthors
QList< PluginAuthor > pluginAuthors() const
Definition: InhibitScreensaverPlugin.cpp:114
PositionTracking.h
Marble::RenderPlugin::marbleModel
const MarbleModel * marbleModel() const
Access to the MarbleModel.
Definition: RenderPlugin.cpp:83
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Marble::InhibitScreensaverPlugin
A plugin that inhibits the screensaver as long as a position provider plugin is active.
Definition: InhibitScreensaverPlugin.h:25
Marble::RenderPlugin
The abstract class that creates a renderable item.
Definition: RenderPlugin.h:43
Marble::InhibitScreensaverPlugin::render
virtual bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos="NONE", GeoSceneLayer *layer=0)
Renders the content provided by the layer on the viewport.
Definition: InhibitScreensaverPlugin.cpp:163
QIcon
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 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