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

Dennis Nienhüser earthwings at gentoo.org
Wed Aug 25 17:44:05 CEST 2010


SVN commit 1167890 by nienhueser:

Move oxygen color constants to global.h and replace other usages of oxygen colors with these constants.

 M  +2 -1      geodata/handlers/gpx/GPXgpxTagHandler.cpp  
 M  +13 -0     global.h  
 M  +1 -1      gps/PositionTracking.cpp  
 M  +1 -1      routing/RouteSkeleton.cpp  
 M  +20 -21    routing/RoutingLayer.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/gpx/GPXgpxTagHandler.cpp #1167889:1167890
@@ -29,6 +29,7 @@
 #include "GeoDataDocument.h"
 #include "GeoDataStyle.h"
 #include "GeoDataStyleMap.h"
+#include "global.h"
 
 namespace Marble
 {
@@ -42,7 +43,7 @@
 
     GeoDataStyle style;
     GeoDataLineStyle lineStyle;
-    lineStyle.setColor(QColor("#37A42C")); // Oxygen green
+    lineStyle.setColor( oxygenForestGreen4 );
     lineStyle.setWidth(2);
     style.setLineStyle(lineStyle);
     style.setStyleId("track");
--- trunk/KDE/kdeedu/marble/src/lib/global.h #1167889:1167890
@@ -16,6 +16,7 @@
 #include <math.h>
 
 #include <QtCore/QString>
+#include <QtGui/QColor>
 
 #include "marble_export.h"
 
@@ -219,6 +220,18 @@
 const qreal HOUR2SEC = 3600.0;
 const qreal SEC2HOUR = 1.0 / HOUR2SEC;
 
+// Colors taken from the oxygen palette
+// When extending, please use the names and rgb values as defined in
+// http://websvn.kde.org/*checkout*/trunk/playground/artwork/Oxygen/utils/oxygen.gpl
+QColor const oxygenBrownOrange4 = QColor::fromRgb( 191, 94, 0 );
+QColor const oxygenAluminumGray4 = QColor::fromRgb( 136, 138, 133 );
+QColor const oxygenSkyBlue4 = QColor::fromRgb( 0, 87, 174 );
+QColor const oxygenSunYellow6 = QColor::fromRgb( 227, 173, 0 );
+QColor const oxygenSeaBlue2 = QColor::fromRgb( 0, 196, 204 );
+QColor const oxygenHotOrange4 = QColor::fromRgb( 236, 115, 49 );
+QColor const oxygenBrickRed4 = QColor::fromRgb( 226, 8, 0 );
+QColor const oxygenForestGreen4 = QColor::fromRgb( 55, 164, 44 );
+
 // Version definitions to use with an external application (as digiKam)
 
 // String for about dialog and http user agent
--- trunk/KDE/kdeedu/marble/src/lib/gps/PositionTracking.cpp #1167889:1167890
@@ -47,7 +47,7 @@
 
     GeoDataStyle style;
     GeoDataLineStyle lineStyle;
-    lineStyle.setColor(QColor("#E20700")); // Oxygen Red
+    lineStyle.setColor( oxygenBrickRed4 );
     lineStyle.setWidth(2);
     style.setLineStyle(lineStyle);
     style.setStyleId("track");
--- trunk/KDE/kdeedu/marble/src/lib/routing/RouteSkeleton.cpp #1167889:1167890
@@ -154,7 +154,7 @@
     QPainter painter( &result );
     painter.setRenderHint( QPainter::Antialiasing, true );
     painter.setPen( QColor( Qt::black ) );
-    painter.setBrush( QBrush( QColor::fromRgb( 55, 164, 44 ) ) );  // green, oxygen palette
+    painter.setBrush( QBrush( oxygenForestGreen4 ) );
     painter.drawEllipse( 1, 1, 13, 13 );
     painter.setBrush( QColor( Qt::black ) );
 
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingLayer.cpp #1167889:1167890
@@ -39,17 +39,6 @@
 namespace Marble
 {
 
-namespace
-{
-    QColor const oxygenBrown = QColor::fromRgb( 204, 51, 0 );
-    QColor const oxygenGray = QColor::fromRgb( 136, 138, 133, 200 );
-    QColor const oxygenBlue = QColor::fromRgb( 0, 87, 174, 200 );
-    QColor const oxygenYellow = QColor::fromRgb( 227, 173, 0 );
-    QColor const oxygenBrightBlue = QColor::fromRgb( 102, 255, 255, 200 );
-    QColor const oxygenOrange = QColor::fromRgb( 236, 115, 49, 200 );
-    QColor const oxygenRed = QColor::fromRgb( 226, 8, 0, 200 );
-}
-
 class RoutingLayerPrivate
 {
     template<class T>
@@ -133,6 +122,9 @@
     // Inlined to avoid the function call overhead. Having functions here is just to
     // keep the code clean
 
+    /** Returns the same color as the given one with its alpha channel adjusted to the given value */
+    inline QColor alphaAdjusted( const QColor &color, int alpha ) const;
+
     /**
       * Returns the start or destination position if Ctrl key is among the
       * provided modifiers, the cached insert position otherwise
@@ -240,7 +232,7 @@
 {
     m_alternativeRouteRegions.clear();
 
-    QPen grayPen( oxygenGray );
+    QPen grayPen( alphaAdjusted( oxygenAluminumGray4, 200 ) );
     grayPen.setWidth( 5 );
     painter->setPen( grayPen );
 
@@ -270,7 +262,7 @@
         }
     }
 
-    QPen bluePen( oxygenBlue );
+    QPen bluePen( alphaAdjusted( oxygenSkyBlue4, 200 ) );
     bluePen.setWidth( 5 );
     if ( m_routeDirty ) {
         bluePen.setStyle( Qt::DotLine );
@@ -282,7 +274,7 @@
 
     bluePen.setWidth( 2 );
     painter->setPen( bluePen );
-    painter->setBrush( QBrush( oxygenGray ) );
+    painter->setBrush( QBrush( alphaAdjusted( oxygenAluminumGray4, 200 ) ) );
 
     if ( !m_dropStopOver.isNull() ) {
         int dx = 1 + m_pixmapSize.width() / 2;
@@ -319,16 +311,16 @@
 
         if ( type == RoutingModel::Instruction ) {
 
-            painter->setBrush( QBrush( oxygenGray ) );
+            painter->setBrush( QBrush( alphaAdjusted( oxygenAluminumGray4, 200 ) ) );
             QModelIndex proxyIndex = m_proxyModel->mapFromSource( index );
             if ( m_selectionModel->selection().contains( proxyIndex ) ) {
                 painter->setPen( QColor( Qt::black ) );
-                painter->setBrush( QBrush( oxygenYellow ) );
+                painter->setBrush( QBrush( oxygenSunYellow6 ) );
                 painter->drawAnnotation( pos, index.data().toString(), QSize( 120, 60 ), 10, 30, 15, 15 );
 
                 GeoDataLineString currentRoutePoints = qVariantValue<GeoDataLineString>( index.data( RoutingModel::InstructionWayPointRole ) );
 
-                QPen brightBluePen( oxygenBrightBlue );
+                QPen brightBluePen( alphaAdjusted( oxygenSeaBlue2, 200 ) );
 
                 brightBluePen.setWidth( 6 );
                 if ( m_routeDirty ) {
@@ -339,7 +331,7 @@
                 painter->drawPolyline( currentRoutePoints );
 
                 painter->setPen( bluePen );
-                painter->setBrush( QBrush( oxygenOrange ) );
+                painter->setBrush( QBrush( alphaAdjusted( oxygenHotOrange4, 200 ) ) );
             }
 
             QRegion region = painter->regionFromEllipse( pos, 12, 12 );
@@ -348,7 +340,7 @@
 
         } else if ( !m_routeDirty && type == RoutingModel::Error ) {
             painter->setPen( QColor( Qt::white ) );
-            painter->setBrush( QBrush( oxygenRed ) );
+            painter->setBrush( QBrush( alphaAdjusted( oxygenBrickRed4, 200 ) ) );
             painter->drawAnnotation( pos, index.data().toString(), QSize( 180, 80 ), 10, 30, 15, 15 );
         }
 
@@ -358,10 +350,10 @@
             GeoDataCoordinates location = m_routingModel->instructionPoint();
             QString nextInstruction = m_routingModel->instructionText();
             if( timeRemaining < thresholdMinimum && !nextInstruction.isEmpty() ) {
-                painter->setBrush( QBrush( oxygenBrown ) );
+                painter->setBrush( QBrush( oxygenBrownOrange4 ) );
                 painter->drawEllipse( location, 20, 20 );
             } else {
-                painter->setBrush( QBrush( oxygenYellow ) );
+                painter->setBrush( QBrush( oxygenSunYellow6 ) );
                 painter->drawEllipse( location, 12, 12 );
             }
         }
@@ -395,6 +387,13 @@
     }
 }
 
+QColor RoutingLayerPrivate::alphaAdjusted( const QColor &color, int alpha ) const
+{
+    QColor result( color );
+    result.setAlpha( alpha );
+    return result;
+}
+
 bool RoutingLayerPrivate::handleMouseButtonPress( QMouseEvent *e )
 {
     if ( m_pointSelection ) {


More information about the Marble-commits mailing list