[Marble-commits] KDE/kdeedu/marble/src
Bastian Holst
bastianholst at gmx.de
Tue Mar 23 22:24:56 CET 2010
SVN commit 1106756 by bholst:
Banning conditional compiling from NavigationFloatItem
M +2 -0 KdeMainWindow.cpp
M +1 -0 QtMainWindow.cpp
M +13 -0 lib/global.cpp
M +5 -8 lib/global.h
M +106 -70 plugins/render/navigation/NavigationFloatItem.cpp
M +4 -10 plugins/render/navigation/NavigationFloatItem.h
--- trunk/KDE/kdeedu/marble/src/KdeMainWindow.cpp #1106755:1106756
@@ -36,6 +36,8 @@
MainWindow::MainWindow( const QString& marbleDataPath, QWidget *parent )
: KXmlGuiWindow( parent )
{
+ MarbleGlobal::getInstance()->setProfile();
+
m_part = new MarblePart( this, this, QStringList() << marbleDataPath );
setCentralWidget( m_part->widget() );
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.cpp #1106755:1106756
@@ -60,6 +60,7 @@
MainWindow::MainWindow(const QString& marbleDataPath, QWidget *parent) : QMainWindow(parent), m_sunControlDialog(0)
{
+ MarbleGlobal::getInstance()->setProfile();
setUpdatesEnabled( false );
QString selectedPath = marbleDataPath.isEmpty() ? readMarbleDataPath() : marbleDataPath;
--- trunk/KDE/kdeedu/marble/src/lib/global.cpp #1106755:1106756
@@ -53,4 +53,17 @@
d->m_profile = profile;
}
+void MarbleGlobal::setProfile() {
+ MarbleGlobal::Profile profile = MarbleGlobal::Default;
+ // 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)
+ profile = MarbleGlobal::MobileInternetDevice;
+#endif
+#ifdef Q_WS_MAEMO_5
+ profile = MarbleGlobal::MobileInternetDevice;
+#endif
+
+ setProfile( profile );
}
+
+}
--- trunk/KDE/kdeedu/marble/src/lib/global.h #1106755:1106756
@@ -22,15 +22,7 @@
// #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
{
@@ -259,6 +251,11 @@
Profile profile() const;
void setProfile( Profile profile );
+ /**
+ * Automatically sets the profile to the default value for the device marble is running on.
+ */
+ void setProfile();
+
private:
MarbleGlobal();
--- trunk/KDE/kdeedu/marble/src/plugins/render/navigation/NavigationFloatItem.cpp #1106755:1106756
@@ -13,6 +13,7 @@
#include <QtCore/QRect>
#include <QtGui/QPixmap>
+#include <QtGui/QToolButton>
#include <QtGui/QSlider>
#include <QtGui/QWidget>
@@ -32,6 +33,7 @@
: AbstractFloatItem( point ),
m_marbleWidget( 0 ),
m_widgetItem( 0 ),
+ m_profile( MarbleGlobal::getInstance()->profile() ),
m_oldViewportRadius( 0 )
{
// Plugin is enabled by default
@@ -39,11 +41,12 @@
// Plugin is not visible by default
setVisible( false );
- #ifdef MARBLE_SMALL_SCREEN
- setFrame( FrameGraphicsItem::RectFrame );
- #else
- setFrame( FrameGraphicsItem::RoundedRectFrame );
- #endif
+ if( m_profile == MarbleGlobal::MobileInternetDevice ) {
+ setFrame( FrameGraphicsItem::RectFrame );
+ }
+ else {
+ setFrame( FrameGraphicsItem::RoundedRectFrame );
+ }
// This sets the padding to the minimum possible for this Frame
setPadding( 0 );
@@ -86,8 +89,14 @@
void NavigationFloatItem::initialize()
{
QWidget *navigationParent = new QWidget( 0 );
- m_navigationWidget.setupUi( navigationParent );
+ if( m_profile == MarbleGlobal::MobileInternetDevice ) {
+ m_navigationWidgetSmall.setupUi( navigationParent );
+ }
+ else {
+ m_navigationWidget.setupUi( navigationParent );
+ }
+
m_widgetItem = new WidgetGraphicsItem( this );
m_widgetItem->setWidget( navigationParent );
@@ -96,15 +105,15 @@
setLayout( layout );
- #ifndef MARBLE_SMALL_SCREEN
- connect( m_navigationWidget.zoomSlider, SIGNAL( sliderPressed() ),
- this, SLOT( adjustForAnimation() ) );
- connect( m_navigationWidget.zoomSlider, SIGNAL( sliderReleased() ),
- this, SLOT( adjustForStill() ) );
- 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
+ if( m_profile != MarbleGlobal::MobileInternetDevice ) {
+ connect( m_navigationWidget.zoomSlider, SIGNAL( sliderPressed() ),
+ this, SLOT( adjustForAnimation() ) );
+ connect( m_navigationWidget.zoomSlider, SIGNAL( sliderReleased() ),
+ this, SLOT( adjustForStill() ) );
+ connect( m_navigationWidget.zoomSlider, SIGNAL( valueChanged( int ) ),
+ this, SLOT( updateButtons( int ) ) );
+ // Other signal/slot connections will be initialized when the marble widget is known
+ }
}
bool NavigationFloatItem::isInitialized() const
@@ -121,11 +130,6 @@
}
}
-void NavigationFloatItem::paintContent( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer * layer )
-{
-}
-
bool NavigationFloatItem::eventFilter(QObject *object, QEvent *e)
{
if ( !enabled() || !visible() ) {
@@ -143,25 +147,46 @@
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.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() ) );
+
+ if( m_profile == MarbleGlobal::MobileInternetDevice ) {
+ connect( m_navigationWidgetSmall.zoomInButton, SIGNAL( clicked() ),
+ m_marbleWidget, SLOT( zoomIn() ) );
+ connect( m_navigationWidgetSmall.zoomOutButton, SIGNAL( clicked() ),
+ m_marbleWidget, SLOT( zoomOut() ) );
+ connect( m_navigationWidgetSmall.goHomeButton, SIGNAL( clicked() ),
+ m_marbleWidget, SLOT( goHome() ) );
+ }
+ else {
+ 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);
+
+ connect( m_navigationWidget.zoomInButton, SIGNAL( clicked() ),
+ m_marbleWidget, SLOT( zoomIn() ) );
+ connect( m_navigationWidget.zoomOutButton, SIGNAL( clicked() ),
+ m_marbleWidget, SLOT( zoomOut() ) );
+
+ 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() ) );
+
+ connect( m_navigationWidget.goHomeButton, SIGNAL( clicked() ),
+ m_marbleWidget, SLOT( goHome() ) );
+ }
+
+ connect( m_marbleWidget->map(), SIGNAL(zoomChanged(int)),
+ this, SLOT(zoomChanged(int)));
+ connect( m_marbleWidget, SIGNAL( themeChanged( QString ) ),
+ this, SLOT( selectTheme( QString ) ) );
+
updateButtons( m_marbleWidget->map()->zoom() );
}
@@ -170,9 +195,9 @@
void NavigationFloatItem::zoomChanged(int level)
{
- #ifndef MARBLE_SMALL_SCREEN
- m_navigationWidget.zoomSlider->setValue(level);
- #endif
+ if( m_profile != MarbleGlobal::MobileInternetDevice ) {
+ m_navigationWidget.zoomSlider->setValue(level);
+ }
}
void NavigationFloatItem::selectTheme(QString theme)
@@ -180,15 +205,16 @@
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
+ if( m_profile == MarbleGlobal::MobileInternetDevice ) {
+ updateButtons(m_marbleWidget->map()->zoom());
+ }
+ else {
+ 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());
+ }
}
}
@@ -219,43 +245,53 @@
{
int minZoom = defaultMinZoom;
int maxZoom = defaultMaxZoom;
+ QToolButton *zoomInButton;
+ QToolButton *zoomOutButton;
- #ifdef MARBLE_SMALL_SCREEN
- if ( m_marbleWidget ) {
- minZoom = m_marbleWidget->map()->minimumZoom();
- maxZoom = m_marbleWidget->map()->maximumZoom();
+ if( m_profile == MarbleGlobal::MobileInternetDevice ) {
+ if ( m_marbleWidget ) {
+ minZoom = m_marbleWidget->map()->minimumZoom();
+ maxZoom = m_marbleWidget->map()->maximumZoom();
+ }
+
+ zoomInButton = m_navigationWidgetSmall.zoomInButton;
+ zoomOutButton = m_navigationWidgetSmall.zoomOutButton;
}
- #else
- minZoom = m_navigationWidget.zoomSlider->minimum();
- maxZoom = m_navigationWidget.zoomSlider->maximum();
- #endif
+ else {
+ minZoom = m_navigationWidget.zoomSlider->minimum();
+ maxZoom = m_navigationWidget.zoomSlider->maximum();
+
+ zoomInButton = m_navigationWidget.zoomInButton;
+ zoomOutButton = m_navigationWidget.zoomOutButton;
+ }
if ( value <= minZoom ) {
- m_navigationWidget.zoomInButton->setEnabled( true );
- m_navigationWidget.zoomOutButton->setEnabled( false );
+ zoomInButton->setEnabled( true );
+ zoomOutButton->setEnabled( false );
} else if ( value >= maxZoom ) {
- m_navigationWidget.zoomInButton->setEnabled( false );
- m_navigationWidget.zoomOutButton->setEnabled( true );
+ zoomInButton->setEnabled( false );
+ zoomOutButton->setEnabled( true );
} else {
- m_navigationWidget.zoomInButton->setEnabled( true );
- m_navigationWidget.zoomOutButton->setEnabled( true );
+ zoomInButton->setEnabled( true );
+ zoomOutButton->setEnabled( true );
}
if (m_marbleWidget)
{
// Trigger a repaint of the float item. Otherwise button state updates
// are delayed
- QRectF floatItemRect = QRectF(positivePosition(), size()).toRect();
- QRegion dirtyRegion(floatItemRect.toRect());
+ QRectF floatItemRect = QRectF( positivePosition(), size() ).toRect();
+ QRegion dirtyRegion( floatItemRect.toRect() );
- m_marbleWidget->setAttribute( Qt::WA_NoSystemBackground, false );
+ m_marbleWidget->setAttribute( Qt::WA_NoSystemBackground, false );
update();
- m_marbleWidget->setAttribute( Qt::WA_NoSystemBackground, m_marbleWidget->map()->mapCoversViewport() );
+ m_marbleWidget->setAttribute( Qt::WA_NoSystemBackground,
+ m_marbleWidget->map()->mapCoversViewport() );
}
}
-Q_EXPORT_PLUGIN2(NavigationFloatItem, NavigationFloatItem)
+Q_EXPORT_PLUGIN2( NavigationFloatItem, NavigationFloatItem )
#include "NavigationFloatItem.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/render/navigation/NavigationFloatItem.h #1106755:1106756
@@ -19,11 +19,8 @@
#include "AbstractFloatItem.h"
-#ifdef MARBLE_SMALL_SCREEN
#include "ui_navigation_small.h"
-#else
#include "ui_navigation.h"
-#endif
namespace Marble
{
@@ -62,9 +59,6 @@
void changeViewport( ViewportParams *viewport );
- void paintContent( GeoPainter *painter, ViewportParams *viewport,
- const QString& renderPos, GeoSceneLayer *layer = 0 );
-
protected:
bool eventFilter( QObject *object, QEvent *e );
@@ -93,11 +87,11 @@
WidgetGraphicsItem *m_widgetItem;
/** Navigation controls */
- #ifdef MARBLE_SMALL_SCREEN
- Ui::NavigationSmall m_navigationWidget;
- #else
+ Ui::NavigationSmall m_navigationWidgetSmall;
Ui::Navigation m_navigationWidget;
- #endif
+
+ /** Used Profile */
+ MarbleGlobal::Profile m_profile;
/** Radius of the viewport last time */
int m_oldViewportRadius;
More information about the Marble-commits
mailing list