[Marble-commits] KDE/kdeedu/marble/src

Dennis Nienhüser earthwings at gentoo.org
Sat Oct 16 00:19:31 CEST 2010


SVN commit 1186340 by nienhueser:

Use the zoom (volume) buttons of a Nokia N900 to zoom in/out.
RB: 5630

 M  +33 -0     QtMainWindow.cpp  
 M  +2 -0      QtMainWindow.h  


--- trunk/KDE/kdeedu/marble/src/QtMainWindow.cpp #1186339:1186340
@@ -63,6 +63,13 @@
 #include "routing/RoutingProfilesModel.h"
 #include "routing/RoutingWidget.h"
 
+// For zoom buttons on Maemo
+#ifdef Q_WS_MAEMO_5
+#include <QtGui/QX11Info>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#endif // Q_WS_MAEMO_5
+
 namespace
 {
     const char* POSITION_STRING = "Position:";
@@ -294,6 +301,8 @@
         m_controlView->marbleControl()->setCurrentLocationTabShown( false );
         m_controlView->marbleControl()->setRoutingTabShown( false );
 
+        setupZoomButtons();
+
         menuBar()->addAction( m_aboutMarbleAct );
         m_controlView->setSideBarShown( false );
         return;
@@ -1233,4 +1242,28 @@
     m_osmEditAction->setVisible( mapTheme == "earth/openstreetmap/openstreetmap.dgml" );
 }
 
+void MainWindow::setupZoomButtons()
+{
+#ifdef Q_WS_MAEMO_5
+    if ( winId() ) {
+        Atom atom = XInternAtom( QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False );
+        if ( atom ) {
+            unsigned long val = 1;
+            XChangeProperty ( QX11Info::display(), winId(), atom, XA_INTEGER, 32,
+                             PropModeReplace, reinterpret_cast<unsigned char *>( &val ), 1 );
+
+            QAction* zoomIn = new QAction( tr( "Zoom &In" ), this );
+            zoomIn->setShortcut( Qt::Key_F7 );
+            connect( zoomIn, SIGNAL( triggered() ), m_controlView->marbleWidget(), SLOT( zoomIn() ) );
+            addAction( zoomIn );
+
+            QAction* zoomOut = new QAction( tr( "Zoom &Out" ), this );
+            zoomOut->setShortcut( Qt::Key_F8 );
+            connect( zoomOut, SIGNAL( triggered() ), m_controlView->marbleWidget(), SLOT( zoomOut() ) );
+            addAction( zoomOut );
+        }
+    }
+#endif // Q_WS_MAEMO_5
+}
+
 #include "QtMainWindow.moc"
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.h #1186339:1186340
@@ -122,6 +122,8 @@
     void showRoutingDialog();
 
  private:
+    void setupZoomButtons();
+
     ControlView *m_controlView;
     SunControlWidget* m_sunControlDialog;
     TimeControlWidget* m_timeControlDialog;


More information about the Marble-commits mailing list