[Marble-commits] KDE/kdeedu/marble/src
Bastian Holst
bastianholst at gmx.de
Sun Feb 21 16:07:15 CET 2010
SVN commit 1093840 by bholst:
Added small version of the marble NavigationFloatItem to be used on small
screen devices, for example on Maemo devices
AM icons/go-home-large.png
AM icons/zoom-in-large.png
AM icons/zoom-out-large.png
M +9 -0 lib/global.h
M +3 -0 marble.qrc
M +1 -1 plugins/render/navigation/CMakeLists.txt
M +39 -3 plugins/render/navigation/NavigationFloatItem.cpp
M +15 -1 plugins/render/navigation/NavigationFloatItem.h
A plugins/render/navigation/navigation_small.ui
** trunk/KDE/kdeedu/marble/src/icons/go-home-large.png #property svn:mime-type
+ application/octet-stream
** trunk/KDE/kdeedu/marble/src/icons/zoom-in-large.png #property svn:mime-type
+ application/octet-stream
** trunk/KDE/kdeedu/marble/src/icons/zoom-out-large.png #property svn:mime-type
+ application/octet-stream
--- trunk/KDE/kdeedu/marble/src/lib/global.h #1093839:1093840
@@ -22,6 +22,15 @@
// #define QT_STRICT_ITERATORS
+// Checking Qt for maemo flags to find out if we are on a small screen device.
+#ifdef Q_WS_HILDON // flag for Qt 4.5 (diablo and fremantle)
+ #define MARBLE_SMALL_SCREEN
+#endif
+#ifdef Q_WS_MAEMO_5
+ #define MARBLE_SMALL_SCREEN
+#endif
+
+
namespace Marble
{
--- trunk/KDE/kdeedu/marble/src/marble.qrc #1093839:1093840
@@ -10,6 +10,7 @@
<file>icons/document-save-as.png</file>
<file>icons/edit-copy.png</file>
<file>icons/go-home.png</file>
+ <file>icons/go-home-large.png</file>
<file>icons/get-hot-new-stuff.png</file>
<file>icons/help-contents.png</file>
<file>icons/help-whatsthis.png</file>
@@ -22,5 +23,7 @@
<file>icons/user-offline.png</file>
<file>icons/zoom-in.png</file>
<file>icons/zoom-out.png</file>
+ <file>icons/zoom-in-large.png</file>
+ <file>icons/zoom-out-large.png</file>
</qresource>
</RCC>
--- trunk/KDE/kdeedu/marble/src/plugins/render/navigation/CMakeLists.txt #1093839:1093840
@@ -8,7 +8,7 @@
INCLUDE(${QT_USE_FILE})
set( navigation_SRCS NavigationFloatItem.cpp )
-set (navigation_UI navigation.ui)
+set (navigation_UI navigation.ui navigation_small.ui)
qt4_add_resources(navigation_SRCS navigation.qrc)
--- trunk/KDE/kdeedu/marble/src/plugins/render/navigation/NavigationFloatItem.cpp #1093839:1093840
@@ -10,6 +10,7 @@
#include "NavigationFloatItem.h"
+#include <QtCore/QDebug>
#include <QtCore/QRect>
#include <QtGui/QMouseEvent>
#include <QtGui/QPixmap>
@@ -23,6 +24,9 @@
using namespace Marble;
+const int defaultMinZoom = 900;
+const int defaultMaxZoom = 2400;
+
NavigationFloatItem::NavigationFloatItem(const QPointF &point,
const QSizeF &size) :
AbstractFloatItem(point, size), m_marbleWidget(0),
@@ -33,7 +37,14 @@
// Plugin is not visible by default
setVisible( false );
+ #ifdef MARBLE_SMALL_SCREEN
+ setFrame( FrameGraphicsItem::RectFrame );
+ #else
setFrame( FrameGraphicsItem::RoundedRectFrame );
+ #endif
+
+ // This sets the padding to the minimum possible for this Frame
+ setPadding( 0 );
}
NavigationFloatItem::~NavigationFloatItem()
@@ -78,6 +89,7 @@
* padding()));
m_navigationWidget.setupUi(m_navigationParent);
+ #ifndef MARBLE_SMALL_SCREEN
connect( m_navigationWidget.zoomSlider, SIGNAL( sliderPressed() ),
this, SLOT( adjustForAnimation() ) );
connect( m_navigationWidget.zoomSlider, SIGNAL( sliderReleased() ),
@@ -85,6 +97,7 @@
connect( m_navigationWidget.zoomSlider, SIGNAL( valueChanged( int ) ),
this, SLOT( updateButtons( int ) ) );
// Other signal/slot connections will be initialized when the marble widget is known
+ #endif
}
bool NavigationFloatItem::isInitialized() const
@@ -130,20 +143,24 @@
int minZoom = m_marbleWidget->map()->minimumZoom();
int maxZoom = m_marbleWidget->map()->maximumZoom();
//m_navigationWidget.zoomSlider->setRange(minZoom, maxZoom);
+ #ifndef MARBLE_SMALL_SCREEN
m_navigationWidget.zoomSlider->setMinimum(minZoom);
m_navigationWidget.zoomSlider->setMaximum(maxZoom);
m_navigationWidget.zoomSlider->setValue(m_marbleWidget->map()->zoom());
m_navigationWidget.zoomSlider->setTickInterval((maxZoom - minZoom) / 15);
+ #endif
updateButtons(m_marbleWidget->map()->zoom());
connect(m_marbleWidget->map(), SIGNAL(zoomChanged(int)), this, SLOT(zoomChanged(int)));
connect(m_marbleWidget, SIGNAL( themeChanged( QString ) ), this, SLOT( selectTheme( QString ) ) );
- connect(m_navigationWidget.zoomSlider, SIGNAL(sliderMoved(int)), m_marbleWidget, SLOT(zoomView(int)));
connect(m_navigationWidget.zoomInButton, SIGNAL( clicked() ), m_marbleWidget, SLOT( zoomIn() ) );
connect(m_navigationWidget.zoomOutButton, SIGNAL( clicked() ), m_marbleWidget, SLOT( zoomOut() ) );
+ #ifndef MARBLE_SMALL_SCREEN
+ connect(m_navigationWidget.zoomSlider, SIGNAL(sliderMoved(int)), m_marbleWidget, SLOT(zoomView(int)));
connect(m_navigationWidget.moveLeftButton, SIGNAL( clicked() ), m_marbleWidget, SLOT( moveLeft() ) );
connect(m_navigationWidget.moveRightButton, SIGNAL( clicked() ), m_marbleWidget, SLOT( moveRight() ) );
connect(m_navigationWidget.moveUpButton, SIGNAL( clicked() ), m_marbleWidget, SLOT( moveUp() ) );
connect(m_navigationWidget.moveDownButton, SIGNAL( clicked() ), m_marbleWidget, SLOT( moveDown() ) );
+ #endif
connect(m_navigationWidget.goHomeButton, SIGNAL( clicked() ), m_marbleWidget, SLOT( goHome() ) );
}
@@ -178,7 +195,9 @@
void NavigationFloatItem::zoomChanged(int level)
{
+ #ifndef MARBLE_SMALL_SCREEN
m_navigationWidget.zoomSlider->setValue(level);
+ #endif
}
void NavigationFloatItem::selectTheme(QString theme)
@@ -186,11 +205,15 @@
Q_UNUSED(theme);
if ( m_marbleWidget ) {
+ #ifndef MARBLE_SMALL_SCREEN
int minZoom = m_marbleWidget->map()->minimumZoom();
int maxZoom = m_marbleWidget->map()->maximumZoom();
m_navigationWidget.zoomSlider->setRange(minZoom, maxZoom);
m_navigationWidget.zoomSlider->setValue(m_marbleWidget->map()->zoom());
updateButtons(m_navigationWidget.zoomSlider->value());
+ #else
+ updateButtons(m_marbleWidget->map()->zoom());
+ #endif
}
}
@@ -219,10 +242,23 @@
void NavigationFloatItem::updateButtons( int value )
{
- if ( value <= m_navigationWidget.zoomSlider->minimum() ) {
+ int minZoom = defaultMinZoom;
+ int maxZoom = defaultMaxZoom;
+
+ #ifdef MARBLE_SMALL_SCREEN
+ if ( m_marbleWidget ) {
+ int minZoom = m_marbleWidget->map()->minimumZoom();
+ int maxZoom = m_marbleWidget->map()->maximumZoom();
+ }
+ #else
+ int minZoom = m_navigationWidget.zoomSlider->minimum();
+ int maxZoom = m_navigationWidget.zoomSlider->maximum();
+ #endif
+
+ if ( value <= minZoom ) {
m_navigationWidget.zoomInButton->setEnabled( true );
m_navigationWidget.zoomOutButton->setEnabled( false );
- } else if ( value >= m_navigationWidget.zoomSlider->maximum() ) {
+ } else if ( value >= maxZoom ) {
m_navigationWidget.zoomInButton->setEnabled( false );
m_navigationWidget.zoomOutButton->setEnabled( true );
} else {
--- trunk/KDE/kdeedu/marble/src/plugins/render/navigation/NavigationFloatItem.h #1093839:1093840
@@ -13,11 +13,17 @@
#include <QtCore/QObject>
+#include "global.h"
+
// forward declarations
#include "AbstractFloatItem.h"
+#ifdef MARBLE_SMALL_SCREEN
+#include "ui_navigation_small.h"
+#else
#include "ui_navigation.h"
+#endif
namespace Marble
{
@@ -35,7 +41,11 @@
MARBLE_PLUGIN( NavigationFloatItem )
public:
explicit NavigationFloatItem( const QPointF &point = QPointF( -10, -10 ),
- const QSizeF &size = QSizeF( 100.0, 250.0 ) );
+#ifdef MARBLE_SMALL_SCREEN
+ const QSizeF &size = QSizeF( 88.0, 141.0 ) );
+#else
+ const QSizeF &size = QSizeF( 104.0, 254.0 ) );
+#endif
~NavigationFloatItem();
QStringList backendTypes() const;
@@ -83,7 +93,11 @@
MarbleWidget *m_marbleWidget;
/** Navigation controls */
+ #ifdef MARBLE_SMALL_SCREEN
+ Ui::NavigationSmall m_navigationWidget;
+ #else
Ui::Navigation m_navigationWidget;
+ #endif
/** Navigation controls embedding widget */
QWidget *m_navigationParent;
More information about the Marble-commits
mailing list