[Marble-commits] KDE/kdeedu/marble
Dennis Nienhüser
earthwings at gentoo.org
Mon Aug 23 22:49:30 CEST 2010
SVN commit 1167172 by nienhueser:
Replace the mng animation with an in-memory animation very similar to the oxygen busy cursor (two white balls rotating around each other). Provides a more consistent look and should fix missing animations where mng support is not there (windows, maemo).
D data/bitmaps/progress.mng
M +0 -1 src/lib/libmarble.qrc
M +17 -9 src/lib/routing/RoutingInputWidget.cpp
M +6 -0 src/lib/routing/RoutingInputWidget.h
M +43 -6 src/lib/routing/RoutingWidget.cpp
--- trunk/KDE/kdeedu/marble/src/lib/libmarble.qrc #1167171:1167172
@@ -3,7 +3,6 @@
<file>../../data/bitmaps/routing_remove.png</file>
<file>../../data/bitmaps/routing_pick.png</file>
<file>../../data/bitmaps/routing_step.png</file>
- <file>../../data/bitmaps/progress.mng</file>
<file>../../data/bitmaps/cursor_bc.xpm</file>
<file>../../data/bitmaps/cursor_bl.xpm</file>
<file>../../data/bitmaps/cursor_br.xpm</file>
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingInputWidget.cpp #1167171:1167172
@@ -10,7 +10,6 @@
#include "RoutingInputWidget.h"
-#include "MarbleDebug.h"
#include "MarbleLocale.h"
#include "MarblePlacemarkModel.h"
#include "MarbleRunnerManager.h"
@@ -23,7 +22,6 @@
#include <QtGui/QIcon>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
-#include <QtGui/QMovie>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QtXml/QDomDocument>
@@ -46,8 +44,6 @@
MarblePlacemarkModel *m_placemarkModel;
- QMovie m_progress;
-
QTimer m_progressTimer;
RouteSkeleton *m_route;
@@ -60,6 +56,10 @@
bool m_workOffline;
+ QVector<QIcon> m_progressAnimation;
+
+ int m_currentFrame;
+
/** Constructor */
RoutingInputWidgetPrivate( RouteSkeleton *skeleton, int index, PluginManager* manager, QWidget *parent );
@@ -69,9 +69,9 @@
RoutingInputWidgetPrivate::RoutingInputWidgetPrivate( RouteSkeleton *skeleton, int index, PluginManager* manager, QWidget *parent ) :
m_lineEdit( 0 ), m_runnerManager( new MarbleRunnerManager( manager, parent ) ),
- m_placemarkModel( 0 ), m_progress( ":/data/bitmaps/progress.mng" ),
- m_route( skeleton ), m_index( index ), m_manager( new QNetworkAccessManager( parent ) ),
- m_workOffline( false )
+ m_placemarkModel( 0 ), m_route( skeleton ), m_index( index ),
+ m_manager( new QNetworkAccessManager( parent ) ), m_workOffline( false ),
+ m_currentFrame( 0 )
{
m_stateButton = new QPushButton( parent );
m_stateButton->setToolTip( QObject::tr( "Center Map here" ) );
@@ -205,6 +205,7 @@
} else {
d->m_pickButton->setVisible( false );
d->m_stateButton->setVisible( true );
+ updateProgress();
d->m_progressTimer.start();
d->m_runnerManager->findPlacemarks( text );
}
@@ -239,10 +240,12 @@
void RoutingInputWidget::updateProgress()
{
- d->m_progress.jumpToNextFrame();
- QPixmap frame = d->m_progress.currentPixmap();
+ if ( !d->m_progressAnimation.isEmpty() ) {
+ d->m_currentFrame = ( d->m_currentFrame + 1 ) % d->m_progressAnimation.size();
+ QIcon frame = d->m_progressAnimation[d->m_currentFrame];
d->m_stateButton->setIcon( frame );
}
+}
void RoutingInputWidget::finishSearch()
{
@@ -310,6 +313,11 @@
d->m_lineEdit->setCursorPosition( 0 );
}
+void RoutingInputWidget::setProgressAnimation( const QVector<QIcon> &animation )
+{
+ d->m_progressAnimation = animation;
+}
+
} // namespace Marble
#include "RoutingInputWidget.moc"
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingInputWidget.h #1167171:1167172
@@ -82,6 +82,12 @@
*/
void clear();
+ /**
+ * Set the progress animation to use. Each icon in the vector is displayed
+ * sequentially to create the animation, the animation loops endlessly.
+ */
+ void setProgressAnimation( const QVector<QIcon> &animation );
+
public Q_SLOTS:
/**
* Search for placemarks matching the current input text. Does nothing
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.cpp #1167171:1167172
@@ -28,8 +28,8 @@
#include <QtCore/QTimer>
#include <QtGui/QFileDialog>
#include <QtGui/QSortFilterProxyModel>
-#include <QtGui/QMovie>
#include <QtGui/QComboBox>
+#include <QtGui/QPainter>
#include "ui_RoutingWidget.h"
@@ -61,10 +61,12 @@
bool m_workOffline;
- QMovie m_progress;
-
QTimer m_progressTimer;
+ QVector<QIcon> m_progressAnimation;
+
+ int m_currentFrame;
+
/** Constructor */
RoutingWidgetPrivate();
@@ -83,14 +85,18 @@
* a runner search result or the current route
*/
void setActiveInput( RoutingInputWidget* widget );
+
+private:
+ void createProgressAnimation();
};
RoutingWidgetPrivate::RoutingWidgetPrivate() :
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_progress( ":/data/bitmaps/progress.mng" )
+ m_workOffline( false ), m_currentFrame( 0 )
{
+ createProgressAnimation();
m_progressTimer.setInterval( 100 );
}
@@ -139,6 +145,33 @@
m_routingLayer->synchronizeWith( m_routingProxyModel, m_ui.directionsListView->selectionModel() );
}
+void RoutingWidgetPrivate::createProgressAnimation()
+{
+ // Size parameters
+ int const iconSize = 16;
+ qreal const h = 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 );
+ QPainter painter( &canvas );
+ painter.setRenderHint( QPainter::Antialiasing, true );
+ painter.setPen( QColor ( Qt::gray ) );
+ painter.setBrush( QColor( Qt::white ) );
+
+ // Create all frames
+ for( double t = 0.0; t < 2 * M_PI; t += M_PI / 8.0 ) {
+ canvas.fill( Qt::transparent );
+ QRectF firstCircle( h - r + q * cos( t ), h - r + q * sin( t ), d, d );
+ QRectF secondCircle( h - r + q * cos( t + M_PI ), h - r + q * sin( t + M_PI ), d, d );
+ painter.drawEllipse( firstCircle );
+ painter.drawEllipse( secondCircle );
+ m_progressAnimation.push_back( QIcon( QPixmap::fromImage( canvas ) ) );
+ }
+}
+
RoutingWidget::RoutingWidget( MarbleWidget *marbleWidget, QWidget *parent ) :
QWidget( parent ), d( new RoutingWidgetPrivate )
{
@@ -337,6 +370,7 @@
{
if ( index >= 0 && index <= d->m_inputWidgets.size() ) {
RoutingInputWidget *input = new RoutingInputWidget( d->m_routeSkeleton, index, d->m_widget->model()->pluginManager(), this );
+ input->setProgressAnimation( d->m_progressAnimation );
input->setWorkOffline( d->m_workOffline );
d->m_inputWidgets.insert( index, input );
connect( input, SIGNAL( searchFinished( RoutingInputWidget* ) ),
@@ -399,6 +433,7 @@
d->m_routingLayer->setRouteDirty( state == RoutingManager::Downloading );
if ( state == RoutingManager::Downloading ) {
+ updateProgress();
d->m_progressTimer.start();
} else {
d->m_progressTimer.stop();
@@ -479,10 +514,12 @@
void RoutingWidget::updateProgress()
{
- d->m_progress.jumpToNextFrame();
- QPixmap frame = d->m_progress.currentPixmap();
+ if ( !d->m_progressAnimation.isEmpty() ) {
+ d->m_currentFrame = ( d->m_currentFrame + 1 ) % d->m_progressAnimation.size();
+ QIcon frame = d->m_progressAnimation[d->m_currentFrame];
d->m_ui.searchButton->setIcon( frame );
}
+}
void RoutingWidget::switchRoute( int index )
{
More information about the Marble-commits
mailing list