QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgssymbolanimationsettingswidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolanimationsettingswidget.cpp
3  ---------------------
4  begin : April 2022
5  copyright : (C) 2022 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 #include "qgssymbol.h"
18 
19 #include <QDialogButtonBox>
20 
22  : QgsPanelWidget( parent )
23 {
24  setupUi( this );
25 
26  mFrameRateSpin->setClearValue( 10 );
27  mFrameRateSpin->setShowClearButton( true );
28 
29  connect( mFrameRateSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ this ]
30  {
31  if ( !mBlockUpdates )
32  emit widgetChanged();
33  } );
34  connect( mIsAnimatedGroup, &QGroupBox::toggled, this, [ this ]
35  {
36  if ( !mBlockUpdates )
37  emit widgetChanged();
38  } );
39 }
40 
42 {
43  mBlockUpdates = true;
44  mIsAnimatedGroup->setChecked( settings.isAnimated() );
45  mFrameRateSpin->setValue( settings.frameRate() );
46  mBlockUpdates = false;
47 }
48 
50 {
52  settings.setIsAnimated( mIsAnimatedGroup->isChecked() );
53  settings.setFrameRate( mFrameRateSpin->value() );
54  return settings;
55 }
56 
57 
58 //
59 // QgsSymbolAnimationSettingsDialog
60 //
61 
63  : QDialog( parent, f )
64 {
65  QVBoxLayout *vLayout = new QVBoxLayout();
66  mWidget = new QgsSymbolAnimationSettingsWidget( );
67  vLayout->addWidget( mWidget );
68  QDialogButtonBox *bbox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal );
69  connect( bbox, &QDialogButtonBox::accepted, this, &QgsSymbolAnimationSettingsDialog::accept );
70  connect( bbox, &QDialogButtonBox::rejected, this, &QgsSymbolAnimationSettingsDialog::reject );
71  vLayout->addWidget( bbox );
72  setLayout( vLayout );
73  setWindowTitle( tr( "Animation Settings" ) );
74 }
75 
77 {
78  mWidget->setAnimationSettings( settings );
79 }
80 
82 {
83  return mWidget->animationSettings();
84 }
85 
QgsSymbolAnimationSettings::setIsAnimated
void setIsAnimated(bool animated)
Sets whether the symbol is animated.
Definition: qgssymbol.h:52
QgsSymbolAnimationSettingsDialog::QgsSymbolAnimationSettingsDialog
QgsSymbolAnimationSettingsDialog(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Constructor for QgsSymbolAnimationSettingsDialog.
Definition: qgssymbolanimationsettingswidget.cpp:62
QgsSymbolAnimationSettings::frameRate
double frameRate() const
Returns the symbol animation frame rate (in frames per second).
Definition: qgssymbol.h:77
qgssymbolanimationsettingswidget.h
QgsSymbolAnimationSettingsDialog::animationSettings
QgsSymbolAnimationSettings animationSettings() const
Returns the animation settings as defined in the dialog.
Definition: qgssymbolanimationsettingswidget.cpp:81
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsSymbolAnimationSettingsWidget::QgsSymbolAnimationSettingsWidget
QgsSymbolAnimationSettingsWidget(QWidget *parent=nullptr)
Constructor for QgsSymbolAnimationSettingsWidget.
Definition: qgssymbolanimationsettingswidget.cpp:21
QgsSymbolAnimationSettings::isAnimated
bool isAnimated() const
Returns true if the symbol is animated.
Definition: qgssymbol.h:63
QgsPanelWidget::widgetChanged
void widgetChanged()
Emitted when the widget state changes.
QgsSymbolAnimationSettingsWidget::setAnimationSettings
void setAnimationSettings(const QgsSymbolAnimationSettings &settings)
Sets the animation settings to show in the widget.
Definition: qgssymbolanimationsettingswidget.cpp:41
QgsSymbolAnimationSettingsDialog::setAnimationSettings
void setAnimationSettings(const QgsSymbolAnimationSettings &settings)
Sets the animation settings to show in the dialog.
Definition: qgssymbolanimationsettingswidget.cpp:76
QgsSymbolAnimationSettingsWidget
A widget for customising animation settings for a symbol.
Definition: qgssymbolanimationsettingswidget.h:35
QgsSymbolAnimationSettings
Contains settings relating to symbol animation.
Definition: qgssymbol.h:39
QgsSymbolAnimationSettings::setFrameRate
void setFrameRate(double rate)
Sets the symbol animation frame rate (in frames per second).
Definition: qgssymbol.h:70
QgsSymbolAnimationSettingsWidget::animationSettings
QgsSymbolAnimationSettings animationSettings() const
Returns the animation settings as defined in the widget.
Definition: qgssymbolanimationsettingswidget.cpp:49
qgssymbol.h