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

Dennis Nienhüser earthwings at gentoo.org
Sun Aug 29 10:30:49 CEST 2010


SVN commit 1169428 by nienhueser:

Larger icons on small screen devices.

 M  +6 -4      RouteSkeleton.cpp  
 M  +7 -2      RoutingInputWidget.cpp  
 M  +5 -2      RoutingLayer.cpp  
 M  +9 -4      RoutingWidget.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/routing/RouteSkeleton.cpp #1169427:1169428
@@ -147,7 +147,9 @@
     }
 
     // Transparent background
-    QImage result( 16, 16, QImage::Format_ARGB32_Premultiplied );
+    bool smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
+    int const iconSize = smallScreen ? 32 : 16;
+    QImage result( iconSize, iconSize, QImage::Format_ARGB32_Premultiplied );
     result.fill( qRgba( 0, 0, 0, 0 ) );
 
     // Paint a green circle
@@ -155,7 +157,7 @@
     painter.setRenderHint( QPainter::Antialiasing, true );
     painter.setPen( QColor( Qt::black ) );
     painter.setBrush( QBrush( oxygenForestGreen4 ) );
-    painter.drawEllipse( 1, 1, 13, 13 );
+    painter.drawEllipse( 1, 1, iconSize-2, iconSize-2 );
     painter.setBrush( QColor( Qt::black ) );
 
     char text = char( 'A' + position );
@@ -167,7 +169,7 @@
         while ( d->m_fontSize-- > 0 ) {
             font.setPointSize( d->m_fontSize );
             QFontMetrics fontMetric( font );
-            if ( fontMetric.width( text ) <= 12 && fontMetric.height( ) <= 12 ) {
+            if ( fontMetric.width( text ) <= iconSize-3 && fontMetric.height( ) <= iconSize-3 ) {
                 break;
             }
         }
@@ -179,7 +181,7 @@
     painter.setFont( font );
 
     // Paint a character denoting the position (0=A, 1=B, 2=C, ...)
-    painter.drawText( 2, 2, 12, 12, Qt::AlignCenter, QString( text ) );
+    painter.drawText( 2, 2, iconSize-3, iconSize-3, Qt::AlignCenter, QString( text ) );
 
     d->m_pixmapCache.insert( position, QPixmap::fromImage( result ) );
     return pixmap( position );
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingInputWidget.cpp #1169427:1169428
@@ -70,12 +70,16 @@
         m_placemarkModel( 0 ), m_route( skeleton ), m_index( index ),
         m_manager( new QNetworkAccessManager( parent ) ), m_currentFrame( 0 )
 {
+    bool smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
+    int const iconSize = smallScreen ? 32 : 16;
+
     m_stateButton = new QPushButton( parent );
     m_stateButton->setToolTip( QObject::tr( "Center Map here" ) );
     m_stateButton->setVisible( false );
     m_stateButton->setIcon( QIcon( m_route->pixmap( m_index ) ) );
     m_stateButton->setFlat( true );
-    m_stateButton->setMaximumWidth( 22 );
+    m_stateButton->setMaximumWidth( iconSize + 6 );
+    m_stateButton->setIconSize( QSize( iconSize, iconSize ) );
     m_stateButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
 
     m_lineEdit = new QLineEdit( parent );
@@ -91,8 +95,9 @@
     m_pickButton->setToolTip( QObject::tr( "Choose position from the map" ) );
     m_pickButton->setCheckable( true );
     m_pickButton->setFlat( true );
-    m_pickButton->setMaximumWidth( 22 );
+    m_pickButton->setMaximumWidth( iconSize + 6 );
     m_pickButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
+    m_pickButton->setIconSize( QSize( iconSize, iconSize ) );
 
     m_progressTimer.setInterval( 100 );
     m_nominatimTimer.setInterval( 1000 );
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingLayer.cpp #1169427:1169428
@@ -180,6 +180,9 @@
     QAction *exportAction = new QAction( QObject::tr( "&Export route..." ), q );
     QObject::connect( exportAction, SIGNAL( triggered() ), q, SIGNAL( exportRequested() ) );
     m_contextMenu->addAction( Qt::RightButton, exportAction );
+    if ( MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
+        m_pixmapSize = QSize( 38, 38 );
+    }
 
 }
 
@@ -544,8 +547,8 @@
             // Repaint only that region of the map that is affected by the change
             m_dragStopOverRightIndex = viaInsertPosition( e->modifiers() );
             QRect dirty = m_routeRegion.boundingRect();
-            dirty |= QRect( m_dropStopOver, QSize( 22, 22 ) );
-            dirty |= QRect( e->pos(), QSize( 22, 22 ) );
+            dirty |= QRect( m_dropStopOver, m_pixmapSize );
+            dirty |= QRect( e->pos(), m_pixmapSize );
             if ( e->buttons() & Qt::LeftButton ) {
                 m_dropStopOver = e->pos();
             } else {
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.cpp #1169427:1169428
@@ -67,6 +67,8 @@
 
     int m_currentFrame;
 
+    int m_iconSize;
+
     /** Constructor */
     RoutingWidgetPrivate();
 
@@ -94,11 +96,15 @@
         m_widget( 0 ), m_routingManager( 0 ), m_routingLayer( 0 ),
         m_activeInput( 0 ), m_inputRequest( 0 ), m_routingProxyModel( 0 ),
         m_routeSkeleton( 0 ), m_zoomRouteAfterDownload( false ),
-        m_workOffline( false ), m_currentFrame( 0 )
+        m_workOffline( false ), m_currentFrame( 0 ),
+        m_iconSize( 16 )
 {
     createProgressAnimation();
     m_progressTimer.setInterval( 100 );
+    if ( MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
+        m_iconSize = 32;
 }
+}
 
 void RoutingWidgetPrivate::adjustInputWidgets()
 {
@@ -148,14 +154,13 @@
 void RoutingWidgetPrivate::createProgressAnimation()
 {
     // Size parameters
-    int const iconSize = 16;
-    qreal const h = iconSize / 2.0; // Half of the icon size
+    qreal const h = m_iconSize / 2.0; // Half of the icon size
     qreal const q = h / 2.0; // Quarter of the icon size
     qreal const d = 7.5; // Circle diameter
     qreal const r = d / 2.0; // Circle radius
 
     // Canvas parameters
-    QImage canvas( iconSize, iconSize, QImage::Format_ARGB32 );
+    QImage canvas( m_iconSize, m_iconSize, QImage::Format_ARGB32 );
     QPainter painter( &canvas );
     painter.setRenderHint( QPainter::Antialiasing, true );
     painter.setPen( QColor ( Qt::gray ) );


More information about the Marble-commits mailing list