Skip to content
Permalink
Browse files

updates on raster layer properties ui

  • Loading branch information
Samweli authored and nyalldawson committed Mar 11, 2020
1 parent dd129c1 commit d0aa808d2006d1b344a6ef4bf8c8cf1e1fa1c27d
@@ -72,9 +72,9 @@ QString QgsLayerTreeViewTemporalIndicatorProvider::tooltipText( QgsMapLayer *lay
{
if ( layer->temporalProperties()->temporalSource() ==
QgsMapLayerTemporalProperties::TemporalSource::Project )
return tr( "<b>Temporal layer using project's time range</b>" );
return tr( "<b>Temporal layer, currently using project's time range </b>" );

return tr( "<b>Temporal layer</b>" );
return tr( "<b>Temporal layer </b>");
}

void QgsLayerTreeViewTemporalIndicatorProvider::onLayerChanged( QgsMapLayer *layer )
@@ -237,8 +237,10 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
QgsDateTimeRange range = QgsProject::instance()->timeSettings()->temporalRange();
QLocale locale;

mStartDateTimeEdit->setDisplayFormat( locale.dateTimeFormat() );
mEndDateTimeEdit->setDisplayFormat( locale.dateTimeFormat() );
mStartDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
mEndDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );

if ( range.begin().isValid() && range.end().isValid() )
{
@@ -2525,7 +2527,7 @@ void QgsProjectProperties::calculateFromLayersButton_clicked()
{
QgsRasterLayer *rasterLayer = qobject_cast<QgsRasterLayer *>( currentLayer );

QgsDateTimeRange layerRange = rasterLayer->temporalProperties()->temporalRange();
QgsDateTimeRange layerRange = rasterLayer->temporalProperties()->fixedTemporalRange();

if ( !minDate.isValid() || layerRange.begin() < minDate )
minDate = layerRange.begin();
@@ -2542,8 +2544,10 @@ void QgsProjectProperties::calculateFromLayersButton_clicked()

QLocale locale;
mCurrentRangeLabel->setText( tr( "Current selected range: %1 to %2" ).arg(
mStartDateTimeEdit->dateTime().toString( locale.dateTimeFormat() ),
mEndDateTimeEdit->dateTime().toString( locale.dateTimeFormat() ) ) );
mStartDateTimeEdit->dateTime().toString(
locale.dateTimeFormat( QLocale::ShortFormat ) ),
mEndDateTimeEdit->dateTime().toString(
locale.dateTimeFormat( QLocale::ShortFormat ) ) ) );
}

QListWidgetItem *QgsProjectProperties::addScaleToScaleList( const QString &newScale )
@@ -107,7 +107,10 @@ QgsInterval QgsTemporalNavigationObject::frameDuration() const
void QgsTemporalNavigationObject::setFramesPerSeconds( double framesPerSeconds )
{
if ( framesPerSeconds > 0 )
{
mFramesPerSecond = framesPerSeconds;
mNewFrameTimer->setInterval( ( 1.0 / mFramesPerSecond ) * 1000 );
}
}

double QgsTemporalNavigationObject::framesPerSeconds() const
@@ -60,16 +60,16 @@ void QgsTemporalControllerDockWidget::init()
range = QgsProject::instance()->timeSettings()->temporalRange();
QLocale locale;

mStartDateTime->setDisplayFormat( locale.dateTimeFormat() );
mEndDateTime->setDisplayFormat( locale.dateTimeFormat() );
mStartDateTime->setDisplayFormat( locale.dateTimeFormat( QLocale::ShortFormat ) );
mEndDateTime->setDisplayFormat( locale.dateTimeFormat( QLocale::ShortFormat ) );

if ( range.begin().isValid() && range.end().isValid() )
{
mStartDateTime->setDateTime( range.begin() );
mEndDateTime->setDateTime( range.end() );
}

mSetToProjectTimeButton->setToolTip( tr( "Set to project time" ) );
mSetToProjectTimeButton->setToolTip( tr( "Set datetimes inputs to match project time" ) );

mTimeStepsComboBox->addItem( tr( "Seconds" ), QgsTemporalControllerDockWidget::Seconds );
mTimeStepsComboBox->addItem( tr( "Minutes" ), QgsTemporalControllerDockWidget::Minutes );
@@ -86,6 +86,12 @@ void QgsTemporalControllerDockWidget::init()
mSpinBox->setValue( 1 );
mSpinBox->setEnabled( true );

mForwardButton->setToolTip( tr( "Play" ) );
mBackButton->setToolTip( tr( "Reverse" ) );
mNextButton->setToolTip( tr( "Go to next frame" ) );
mPreviousButton->setToolTip( tr( "Go to previous frame" ) );
mStopButton->setToolTip( tr( "Pause" ) );

updateTemporalExtent();
updateFrameDuration();
}
@@ -130,12 +136,16 @@ void QgsTemporalControllerDockWidget::settings_clicked()

QgsTemporalMapSettingsDialog *dialog = new QgsTemporalMapSettingsDialog( this );
dialog->setAttribute( Qt::WA_DeleteOnClose );

if ( dialog->mapSettingsWidget() )
dialog->mapSettingsWidget()->setFrameRateValue(
mNavigationObject->framesPerSeconds() );

dialog->setVisible( true );

connect( dialog->mapSettingsWidget(), &QgsTemporalMapSettingsWidget::frameRateChanged, this, [ this, dialog ]()
{
mNavigationObject->setFramesPerSeconds( dialog->mapSettingsWidget()->frameRateValue() );
mSlider->setValue( 0 );
} );
}

@@ -27,9 +27,10 @@ QgsTemporalMapSettingsDialog::QgsTemporalMapSettingsDialog( QWidget *parent, Qt:
connect( this, &QDialog::accepted, this, &QgsTemporalMapSettingsDialog::apply );
connect( this, &QDialog::rejected, this, &QgsTemporalMapSettingsDialog::onCancel );

QVBoxLayout *layout = new QVBoxLayout();
mTemporalMapSettingsWidget = new QgsTemporalMapSettingsWidget( this );
QVBoxLayout *layout = new QVBoxLayout( frame );
layout->addWidget( mTemporalMapSettingsWidget );

setWindowTitle( tr( "Temporal Map Settings" ) );

mTemporalMapSettingsWidget->setFrameRateValue( 1 );
@@ -27,8 +27,9 @@ QgsRasterLayerTemporalPropertiesWidget::QgsRasterLayerTemporalPropertiesWidget(
setupUi( this );
connect( mSetEndAsStartNormalButton, &QPushButton::clicked, this, &QgsRasterLayerTemporalPropertiesWidget::setEndAsStartNormalButton_clicked );
connect( mSetEndAsStartReferenceButton, &QPushButton::clicked, this, &QgsRasterLayerTemporalPropertiesWidget::setEndAsStartReferenceButton_clicked );
connect( mLayerRadioButton, &QRadioButton::clicked, this, &QgsRasterLayerTemporalPropertiesWidget::layerRadioButton_clicked );
connect( mProjectRadioButton, &QRadioButton::clicked, this, &QgsRasterLayerTemporalPropertiesWidget::projectRadioButton_clicked );
connect( mResetDatesButton, &QPushButton::clicked, this, &QgsRasterLayerTemporalPropertiesWidget::resetDatesButton_clicked );
connect( mLayerRadioButton, &QRadioButton::toggled, this, &QgsRasterLayerTemporalPropertiesWidget::layerRadioButton_toggled );
connect( mProjectRadioButton, &QRadioButton::toggled, this, &QgsRasterLayerTemporalPropertiesWidget::projectRadioButton_toggled );
connect( mReferenceCheckBox, &QCheckBox::clicked, this, &QgsRasterLayerTemporalPropertiesWidget::referenceCheckBox_clicked );

init();
@@ -53,7 +54,16 @@ void QgsRasterLayerTemporalPropertiesWidget::init()
mFetchModeComboBox->setCurrentIndex( mFetchModeComboBox->findData(
QgsRasterLayerTemporalProperties::Earliest ) );

updateRangeLabel( mRangeLabel );
if ( mLayer->temporalProperties()->temporalSource() ==
QgsMapLayerTemporalProperties::TemporalSource::Project )
mProjectRadioButton->setChecked( true );

updateRangeLabel( mLabel );

mSetEndAsStartNormalButton->setToolTip( tr( "Set the end datetime same as the start datetime" ) );
mSetEndAsStartReferenceButton->setToolTip( tr( "Set the end datetime same as the start datetime" ) );
mResetDatesButton->setToolTip( tr( "Reset the start and end datetime inputs" ) );
mDisableTime->setToolTip( "Use only the date in the datetime inputs to update the temporal range" );
}

void QgsRasterLayerTemporalPropertiesWidget::setInputWidgetState( TemporalDimension dimension, bool enabled )
@@ -71,18 +81,19 @@ void QgsRasterLayerTemporalPropertiesWidget::setInputWidgetState( TemporalDimens
mSetEndAsStartReferenceButton->setEnabled( enabled );
}

if ( mLayer->temporalProperties()->temporalSource() ==
QgsMapLayerTemporalProperties::TemporalSource::Project )
mProjectRadioButton->setChecked( true );
}

void QgsRasterLayerTemporalPropertiesWidget::setDateTimeInputsLocale()
{
QLocale locale;
mStartTemporalDateTimeEdit->setDisplayFormat( locale.dateTimeFormat() );
mEndTemporalDateTimeEdit->setDisplayFormat( locale.dateTimeFormat() );
mStartReferenceDateTimeEdit->setDisplayFormat( locale.dateTimeFormat() );
mEndReferenceDateTimeEdit->setDisplayFormat( locale.dateTimeFormat() );
mStartTemporalDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
mEndTemporalDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
mStartReferenceDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
mEndReferenceDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
}

void QgsRasterLayerTemporalPropertiesWidget::setDateTimeInputsLimit()
@@ -180,30 +191,49 @@ void QgsRasterLayerTemporalPropertiesWidget::updateRangeLabel( QLabel *label )
void QgsRasterLayerTemporalPropertiesWidget::setEndAsStartNormalButton_clicked()
{
mEndTemporalDateTimeEdit->setDateTime( mStartTemporalDateTimeEdit->dateTime() );
updateRangeLabel( mRangeLabel );
updateRangeLabel( mLabel );
}

void QgsRasterLayerTemporalPropertiesWidget::setEndAsStartReferenceButton_clicked()
{
mEndReferenceDateTimeEdit->setDateTime( mStartReferenceDateTimeEdit->dateTime() );
}

void QgsRasterLayerTemporalPropertiesWidget::layerRadioButton_clicked()
void QgsRasterLayerTemporalPropertiesWidget::layerRadioButton_toggled( bool checked )
{
setInputWidgetState( TemporalDimension::NormalTemporal, true );
mLayer->temporalProperties()->setTemporalSource(
QgsMapLayerTemporalProperties::TemporalSource::Layer );
updateRangeLabel( mRangeLabel );
mLayerRadioButton->setChecked( true );
mProjectRadioButton->setChecked( false );
if ( checked )
{
mLayer->temporalProperties()->setTemporalSource(
QgsMapLayerTemporalProperties::TemporalSource::Layer );
updateRangeLabel( mLabel );
}
}

void QgsRasterLayerTemporalPropertiesWidget::projectRadioButton_clicked()
void QgsRasterLayerTemporalPropertiesWidget::projectRadioButton_toggled( bool checked )
{
setInputWidgetState( TemporalDimension::NormalTemporal, false );
mLayer->temporalProperties()->setTemporalSource(
QgsMapLayerTemporalProperties::TemporalSource::Project );
updateRangeLabel( mRangeLabel );
if ( checked )
{
mLayer->temporalProperties()->setTemporalSource(
QgsMapLayerTemporalProperties::TemporalSource::Project );
updateRangeLabel( mLabel );
}
}

void QgsRasterLayerTemporalPropertiesWidget::resetDatesButton_clicked()
{
QgsRasterLayer *layer = qobject_cast<QgsRasterLayer *>( mLayer );
QgsDateTimeRange layerFixedRange;

if ( layer && layer->temporalProperties() )
layerFixedRange = layer->temporalProperties()->fixedTemporalRange();
if ( layerFixedRange.begin().isValid() && layerFixedRange.end().isValid() )
{
mStartTemporalDateTimeEdit->setDateTime( layerFixedRange.begin() );
mEndTemporalDateTimeEdit->setDateTime( layerFixedRange.end() );
}
else
mLabel->setText( tr( "Cant reset dates, there is no valid layer's "
"capabilities temporal range" ) );
}

void QgsRasterLayerTemporalPropertiesWidget::referenceCheckBox_clicked()
@@ -87,17 +87,23 @@ class GUI_EXPORT QgsRasterLayerTemporalPropertiesWidget : public QWidget, privat
void setEndAsStartReferenceButton_clicked();

/**
* Handles actions to follow when layer radio button is clicked.
* Handles actions to follow when layer radio button is toggled.
**/
void layerRadioButton_clicked();
void layerRadioButton_toggled( bool checked );

/**
* Handles actions to follow when project radio button is clicked.
* Updates the ui states to show current project temporal range, which is
* intended to be assigned to the layer
**/
void projectRadioButton_clicked();
void projectRadioButton_toggled( bool checked );

/**
* Handles actions to follow when reference checkbox is clicked.
* Resets the datetimes inputs to the layer's fixed temporal range.
**/
void resetDatesButton_clicked();

/**
* Enabled inputs in reference datetimes group.
**/
void referenceCheckBox_clicked();

@@ -92,6 +92,9 @@
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="currentRow">
<number>0</number>
</property>
<item>
<property name="text">
<string>Information</string>
@@ -1338,7 +1341,7 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>86</width>
<width>98</width>
<height>45</height>
</rect>
</property>
@@ -14,6 +14,16 @@
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@@ -43,32 +53,32 @@
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<signal>rejected()</signal>
<receiver>QgsTemporalMapSettingsDialogBase</receiver>
<slot>accept()</slot>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<signal>accepted()</signal>
<receiver>QgsTemporalMapSettingsDialogBase</receiver>
<slot>reject()</slot>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<x>157</x>
<y>274</y>
</hint>
</hints>
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>231</width>
<height>134</height>
<width>354</width>
<height>194</height>
</rect>
</property>
<property name="windowTitle">
@@ -19,7 +19,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Frame rate</string>
<string>Frame rate (frames per second)</string>
</property>
</widget>
</item>

0 comments on commit d0aa808

Please sign in to comment.
You can’t perform that action at this time.