[Marble-commits] KDE/kdeedu/marble
Torsten Rahn
tackat at kde.org
Wed Jan 5 23:28:59 CET 2011
SVN commit 1212150 by rahn:
- 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
--- trunk/KDE/kdeedu/marble/CMakeLists.txt #1212149:1212150
@@ -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 )
--- trunk/KDE/kdeedu/marble/src/plugins/render/earthquake/EarthquakeConfigWidget.ui #1212149:1212150
@@ -6,53 +6,38 @@
<rect>
<x>0</x>
<y>0</y>
- <width>466</width>
- <height>326</height>
+ <width>379</width>
+ <height>265</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Filter</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout_2">
+ <item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Maximum number of results:</string>
</property>
</widget>
</item>
- <item>
+ <item row="0" column="1">
<widget class="QSpinBox" name="m_numResults"/>
</item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
+ <item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Minimum magnitude:</string>
</property>
</widget>
</item>
- <item>
+ <item row="1" column="1">
<widget class="QDoubleSpinBox" name="m_minMagnitude">
<property name="maximum">
<double>10.000000000000000</double>
@@ -62,31 +47,23 @@
</property>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
+ </widget>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Time Range</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
- <string>Occured between</string>
+ <string>Start:</string>
</property>
</widget>
</item>
- <item>
+ <item row="0" column="1">
<widget class="QDateTimeEdit" name="m_startDate">
<property name="dateTime">
<datetime>
@@ -103,14 +80,14 @@
</property>
</widget>
</item>
- <item>
+ <item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
- <string>and</string>
+ <string>End:</string>
</property>
</widget>
</item>
- <item>
+ <item row="1" column="1">
<widget class="QDateTimeEdit" name="m_endDate">
<property name="dateTime">
<datetime>
@@ -127,23 +104,9 @@
</property>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
+ </widget>
</item>
- </layout>
- </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
--- trunk/KDE/kdeedu/marble/src/plugins/render/graticule/CMakeLists.txt #1212149:1212150
@@ -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} )
--- trunk/KDE/kdeedu/marble/src/plugins/render/graticule/GraticulePlugin.cpp #1212149:1212150
@@ -9,8 +9,8 @@
//
#include "GraticulePlugin.h"
+#include "ui_GraticuleConfigWidget.h"
-#include <QtGui/QBrush>
#include "MarbleDebug.h"
#include "MarbleDirs.h"
#include "GeoPainter.h"
@@ -25,15 +25,28 @@
// Qt
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
+#include <QtCore/QRect>
+#include <QtGui/QColor>
+#include <QtGui/QPixmap>
+#include <QtSvg/QSvgRenderer>
+#include <QtGui/QBrush>
+#include <QColorDialog>
+
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<QString,QVariant>() );
}
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<QString,QVariant> GraticulePlugin::settings() const
+{
+ return m_settings;
+}
+
+void GraticulePlugin::setSettings( QHash<QString,QVariant> 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<QColor>() );
+ QPalette gridPalette;
+ gridPalette.setColor( QPalette::Button, QColor( gridColor ) );
+ ui_configWidget->gridPushButton->setPalette( gridPalette );
+
+ QColor tropicsColor = QColor( m_settings.value( "tropicsColor" ).value<QColor>() );
+ QPalette tropicsPalette;
+ tropicsPalette.setColor( QPalette::Button, QColor( tropicsColor ) );
+ ui_configWidget->tropicsPushButton->setPalette( tropicsPalette );
+
+
+ QColor equatorColor = QColor( m_settings.value( "equatorColor" ).value<QColor>() );
+ 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<QColor>();
+
+ qDebug() << m_gridColor;
+
+ m_tropicsColor = m_settings.value( "tropicsColor" ).value<QColor>();
+ m_equatorColor = m_settings.value( "equatorColor" ).value<QColor>();
+
+ 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 );
--- trunk/KDE/kdeedu/marble/src/plugins/render/graticule/GraticulePlugin.h #1212149:1212150
@@ -21,6 +21,7 @@
#include <QtGui/QPen>
#include <QtCore/QHash>
#include <QtGui/QIcon>
+#include <QColorDialog>
#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<QString,QVariant> settings() const;
+
+// void setSettings( QHash<QString,QVariant> settings );
+
+ virtual QHash<QString,QVariant> settings() const;
+
+ virtual void setSettings( QHash<QString,QVariant> 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<qreal,qreal> m_boldLineMap;
QMap<qreal,qreal> 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<QString,QVariant> m_settings;
+
mutable QIcon m_icon;
mutable PluginAboutDialog *m_aboutDialog;
+ mutable Ui::GraticuleConfigWidget *ui_configWidget;
+ mutable QDialog *m_configDialog;
+
};
}
More information about the Marble-commits
mailing list