SVN commit 1212152 by rahn: Backports: rahn * r1212150 trunk/KDE/kdeedu/marble/ (6 files in 3 dirs) - Committed: http://reviewboard.kde.org/r/6281/ by Cezar Mocan. - Tweaks for the Graticule and Earthquake ui file. M +5 -0 CMakeLists.txt M +24 -61 src/plugins/render/earthquake/EarthquakeConfigWidget.ui M +5 -2 src/plugins/render/graticule/CMakeLists.txt A src/plugins/render/graticule/GraticuleConfigWidget.ui M +167 -13 src/plugins/render/graticule/GraticulePlugin.cpp M +44 -6 src/plugins/render/graticule/GraticulePlugin.h --- branches/marble/marble-1.1/CMakeLists.txt #1212151:1212152 @@ -29,6 +29,11 @@ #################################################### # build unit tests + +INCLUDE (CTest) +ENABLE_TESTING() + + if( QTONLY ) option( BUILD_MARBLE_TESTS "build marble tests if building QTONLY " ON ) if( BUILD_MARBLE_TESTS ) --- branches/marble/marble-1.1/src/plugins/render/earthquake/EarthquakeConfigWidget.ui #1212151:1212152 @@ -6,53 +6,38 @@ 0 0 - 466 - 326 + 379 + 265 Dialog - - - - + + + Filter + + + Maximum number of results: - + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - + Minimum magnitude: - + 10.000000000000000 @@ -62,31 +47,23 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - + - - + + + Time Range + + + - Occured between + Start: - + @@ -103,14 +80,14 @@ - + - and + End: - + @@ -127,23 +104,9 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - + - - --- branches/marble/marble-1.1/src/plugins/render/graticule/CMakeLists.txt #1212151:1212152 @@ -7,6 +7,9 @@ ) INCLUDE(${QT_USE_FILE}) -set( marblegraticule_SRCS GraticulePlugin.cpp ) +set( graticule_SRCS GraticulePlugin.cpp ) +set( graticule_UI GraticuleConfigWidget.ui ) +qt4_wrap_ui( graticule_SRCS ${graticule_UI} ) -marble_add_plugin( GraticulePlugin ${marblegraticule_SRCS} ) + +marble_add_plugin( GraticulePlugin ${graticule_SRCS} ) --- branches/marble/marble-1.1/src/plugins/render/graticule/GraticulePlugin.cpp #1212151:1212152 @@ -9,8 +9,8 @@ // #include "GraticulePlugin.h" +#include "ui_GraticuleConfigWidget.h" -#include #include "MarbleDebug.h" #include "MarbleDirs.h" #include "GeoPainter.h" @@ -25,15 +25,28 @@ // Qt #include #include +#include +#include +#include +#include +#include +#include + namespace Marble { GraticulePlugin::GraticulePlugin() : m_isInitialized( false ), - m_aboutDialog( 0 ) + m_settings(), + m_aboutDialog( 0 ), + ui_configWidget( 0 ), + m_configDialog( 0 ) { + connect( this, SIGNAL( settingsChanged( QString ) ), + this, SLOT( updateSettings() ) ); + setSettings( QHash() ); } QStringList GraticulePlugin::backendTypes() const @@ -79,11 +92,11 @@ void GraticulePlugin::initialize () { // Initialize range maps that map the zoom to the number of coordinate grid lines. + initLineMaps( GeoDataCoordinates::defaultNotation() ); - m_majorCirclePen = QPen( QColor( Qt::yellow ) ); - m_minorCirclePen = QPen( QColor( Qt::white ) ); m_shadowPen = QPen( Qt::NoPen ); -// m_shadowPen = QPen( QColor( 0, 0, 0, 128 ) ); + + readSettings(); m_isInitialized = true; } @@ -92,6 +105,146 @@ return m_isInitialized; } +QDialog *GraticulePlugin::configDialog () const +{ + if ( !m_configDialog ) { + m_configDialog = new QDialog(); + ui_configWidget = new Ui::GraticuleConfigWidget; + ui_configWidget->setupUi( m_configDialog ); + + readSettings(); + + connect( ui_configWidget->gridPushButton, SIGNAL( clicked() ), this, + SLOT( gridGetColor() ) ); + connect( ui_configWidget->tropicsPushButton, SIGNAL( clicked() ), this, + SLOT( tropicsGetColor() ) ); + connect( ui_configWidget->equatorPushButton, SIGNAL( clicked() ), this, + SLOT( equatorGetColor() ) ); + + + connect( ui_configWidget->m_buttonBox, SIGNAL( accepted() ), this, + SLOT( writeSettings() ) ); + connect( ui_configWidget->m_buttonBox, SIGNAL( rejected() ), this, + SLOT( readSettings() ) ); + QPushButton *applyButton = ui_configWidget->m_buttonBox->button( QDialogButtonBox::Apply ); + connect( applyButton, SIGNAL( clicked() ), + this, SLOT( writeSettings() ) ); + } + + return m_configDialog; +} + + +QHash GraticulePlugin::settings() const +{ + return m_settings; +} + +void GraticulePlugin::setSettings( QHash settings ) +{ + if ( !settings.contains( "gridColor" ) ) { + settings.insert( "gridColor", QColor( Qt::white ) ); + m_gridCirclePen = QPen( QColor ( Qt::white ) ); + } + + if ( !settings.contains( "tropicsColor" ) ) { + settings.insert( "tropicsColor", QColor( Qt::yellow ) ); + m_tropicsCirclePen = QPen( QColor ( Qt::yellow ) ); + } + + if ( !settings.contains( "equatorColor" ) ) { + settings.insert( "equatorColor", QColor( Qt::yellow ) ); + m_equatorCirclePen = QPen( QColor ( Qt::yellow ) ); + } + + m_settings = settings; + readSettings(); + emit settingsChanged( nameId() ); +} + + +void GraticulePlugin::readSettings() const +{ + if ( !m_configDialog ) + return; + + QColor gridColor = QColor( m_settings.value( "gridColor" ).value() ); + QPalette gridPalette; + gridPalette.setColor( QPalette::Button, QColor( gridColor ) ); + ui_configWidget->gridPushButton->setPalette( gridPalette ); + + QColor tropicsColor = QColor( m_settings.value( "tropicsColor" ).value() ); + QPalette tropicsPalette; + tropicsPalette.setColor( QPalette::Button, QColor( tropicsColor ) ); + ui_configWidget->tropicsPushButton->setPalette( tropicsPalette ); + + + QColor equatorColor = QColor( m_settings.value( "equatorColor" ).value() ); + QPalette equatorPalette; + equatorPalette.setColor( QPalette::Button, QColor( equatorColor ) ); + ui_configWidget->equatorPushButton->setPalette( equatorPalette ); + +} + +void GraticulePlugin::gridGetColor() +{ + QColor c = QColorDialog::getColor( m_gridColor, 0, tr("Please choose the color for the coordinate grid.") ); + + if ( c.isValid() ) { + m_gridColor = c; + QPalette gridPalette = ui_configWidget->gridPushButton->palette(); + gridPalette.setColor( QPalette::Button, QColor( m_gridColor ) ); + } +} + +void GraticulePlugin::tropicsGetColor() +{ + QColor c = QColorDialog::getColor( m_tropicsColor, 0, tr("Please choose the color for the tropic circles.") ); + + if ( c.isValid() ) { + m_tropicsColor = c; + QPalette tropicsPalette = ui_configWidget->tropicsPushButton->palette(); + tropicsPalette.setColor( QPalette::Button, QColor( m_tropicsColor ) ); + } +} + +void GraticulePlugin::equatorGetColor() +{ + QColor c = QColorDialog::getColor( m_equatorColor, 0, tr("Please choose the color for the equator.") ); + + if ( c.isValid() ) { + m_equatorColor = c; + QPalette equatorPalette = ui_configWidget->equatorPushButton->palette(); + equatorPalette.setColor( QPalette::Button, QColor( m_equatorColor ) ); + } +} + +void GraticulePlugin::writeSettings() +{ + + m_settings.insert( "gridColor", m_gridColor.name() ); + m_settings.insert( "tropicsColor", m_tropicsColor.name() ); + m_settings.insert( "equatorColor", m_equatorColor.name() ); + + readSettings(); + + emit settingsChanged( nameId() ); +} + +void GraticulePlugin::updateSettings() +{ + m_gridColor = m_settings.value( "gridColor" ).value(); + + qDebug() << m_gridColor; + + m_tropicsColor = m_settings.value( "tropicsColor" ).value(); + m_equatorColor = m_settings.value( "equatorColor" ).value(); + + m_equatorCirclePen = QPen( m_equatorColor ); + m_tropicsCirclePen = QPen( m_tropicsColor ); + m_gridCirclePen = QPen( m_gridColor ); +} + QDialog *GraticulePlugin::aboutDialog() const { if ( !m_aboutDialog ) { @@ -146,10 +299,10 @@ if ( m_shadowPen != Qt::NoPen ) { painter->translate( +1.0, +1.0 ); - renderGrid( painter, viewport, m_shadowPen, m_shadowPen ); + renderGrid( painter, viewport, m_shadowPen, m_shadowPen, m_shadowPen ); painter->translate( -1.0, -1.0 ); } - renderGrid( painter, viewport, m_majorCirclePen, m_minorCirclePen ); + renderGrid( painter, viewport, m_equatorCirclePen, m_tropicsCirclePen, m_gridCirclePen ); painter->restore(); @@ -157,12 +310,13 @@ } void GraticulePlugin::renderGrid( GeoPainter *painter, ViewportParams *viewport, - const QPen& majorCirclePen, - const QPen& minorCirclePen ) + const QPen& equatorCirclePen, + const QPen& tropicsCirclePen, + const QPen& gridCirclePen ) { // Render the normal grid - painter->setPen( minorCirclePen ); + painter->setPen( gridCirclePen ); // painter->setPen( QPen( QBrush( Qt::white ), 0.75 ) ); // calculate the angular distance between coordinate lines of the normal grid @@ -185,7 +339,7 @@ if ( painter->mapQuality() == HighQuality || painter->mapQuality() == PrintQuality ) { - QPen boldPen = minorCirclePen; + QPen boldPen = gridCirclePen; boldPen.setWidthF( 1.5 ); painter->setPen( boldPen ); @@ -200,7 +354,7 @@ NoLabel ); } - painter->setPen( majorCirclePen ); + painter->setPen( equatorCirclePen ); // Render the equator renderLatitudeLine( painter, 0.0, viewLatLonAltBox, tr( "Equator" ) ); @@ -209,7 +363,7 @@ renderLongitudeLine( painter, 0.0, viewLatLonAltBox, 0.0, tr( "Prime Meridian" ) ); renderLongitudeLine( painter, 180.0, viewLatLonAltBox, 0.0, tr( "Antimeridian" ) ); - QPen tropicsPen = majorCirclePen; + QPen tropicsPen = tropicsCirclePen; if ( painter->mapQuality() != OutlineQuality && painter->mapQuality() != LowQuality ) { tropicsPen.setStyle( Qt::DotLine ); --- branches/marble/marble-1.1/src/plugins/render/graticule/GraticulePlugin.h #1212151:1212152 @@ -21,6 +21,7 @@ #include #include #include +#include #include "AbstractDataPlugin.h" @@ -31,6 +32,12 @@ #include "GeoDataCoordinates.h" #include "GeoDataLatLonAltBox.h" + +namespace Ui +{ + class GraticuleConfigWidget; +} + namespace Marble { @@ -70,16 +77,37 @@ QIcon icon () const; + QDialog *configDialog() const; + QDialog *aboutDialog() const; - void initialize (); bool isInitialized () const; - bool render( GeoPainter *painter, ViewportParams *viewport, const QString& renderPos, GeoSceneLayer * layer = 0 ); +// QHash settings() const; + +// void setSettings( QHash settings ); + + virtual QHash settings() const; + + virtual void setSettings( QHash settings ); + + + + public Q_SLOTS: + void readSettings() const; + void writeSettings(); + + void gridGetColor(); + void tropicsGetColor(); + void equatorGetColor(); + + void updateSettings(); + + private: /** * @brief Renders the coordinate grid within the defined view bounding box. @@ -87,8 +115,9 @@ * @param viewport the viewport */ void renderGrid( GeoPainter *painter, ViewportParams *viewport, - const QPen& majorCirclePen, - const QPen& minorCirclePen ); + const QPen& equatorCirclePen, + const QPen& tropicsCirclePen, + const QPen& gridCirclePen ); /** * @brief Renders a latitude line within the defined view bounding box. @@ -159,14 +188,23 @@ QMap m_boldLineMap; QMap m_normalLineMap; - QPen m_majorCirclePen; - QPen m_minorCirclePen; + QPen m_equatorCirclePen; + QPen m_tropicsCirclePen; + QPen m_gridCirclePen; QPen m_shadowPen; + QColor m_gridColor, m_tropicsColor, m_equatorColor; + bool m_isInitialized; + + QHash m_settings; + mutable QIcon m_icon; mutable PluginAboutDialog *m_aboutDialog; + mutable Ui::GraticuleConfigWidget *ui_configWidget; + mutable QDialog *m_configDialog; + }; }