Skip to content

Commit

Permalink
Make using specific date/time an option, use current date/time otherwise
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Jun 2, 2016
1 parent 6293315 commit 30813f9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
16 changes: 15 additions & 1 deletion src/plugins/globe/qgsglobeplugindialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget* parent, Qt::WFlags fl )
#endif

connect( checkBoxSkyAutoAmbient, SIGNAL( toggled( bool ) ), horizontalSliderMinAmbient, SLOT( setEnabled( bool ) ) );
connect( checkBoxDateTime, SIGNAL( toggled( bool ) ), dateTimeEditSky, SLOT( setEnabled( bool ) ) );
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked( bool ) ), this, SLOT( apply() ) );

restoreSavedSettings();
Expand Down Expand Up @@ -121,6 +122,9 @@ void QgsGlobePluginDialog::restoreSavedSettings()
groupBoxAntiAliasing->setChecked( settings.value( "/Plugin-Globe/anti-aliasing", false ).toBool() );
lineEditAASamples->setText( settings.value( "/Plugin-Globe/anti-aliasing-level", "" ).toString() );

horizontalSliderMinAmbient->setEnabled( checkBoxSkyAutoAmbient->isChecked() );
dateTimeEditSky->setEnabled( checkBoxDateTime->isChecked() );

// Advanced
sliderScrollSensitivity->setValue( settings.value( "/Plugin-Globe/scrollSensitivity", 20 ).toInt() );
checkBoxInvertScroll->setChecked( settings.value( "/Plugin-Globe/invertScrollWheel", 0 ).toInt() );
Expand Down Expand Up @@ -224,6 +228,7 @@ void QgsGlobePluginDialog::readProjectSettings()

// Map settings
groupBoxSky->setChecked( QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/skyEnabled", true ) );
checkBoxDateTime->setChecked( QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/overrideDateTime", false ) );
dateTimeEditSky->setDateTime( QDateTime::fromString( QgsProject::instance()->readEntry( "Globe-Plugin", "/skyDateTime", QDateTime::currentDateTime().toString() ) ) );
checkBoxSkyAutoAmbient->setChecked( QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/skyAutoAmbient", true ) );
horizontalSliderMinAmbient->setValue( QgsProject::instance()->readDoubleEntry( "Globe-Plugin", "/skyMinAmbient", 30. ) );
Expand Down Expand Up @@ -257,6 +262,7 @@ void QgsGlobePluginDialog::writeProjectSettings()

// Map settings
QgsProject::instance()->writeEntry( "Globe-Plugin", "/skyEnabled/", groupBoxSky->isChecked() );
QgsProject::instance()->writeEntry( "Globe-Plugin", "/overrideDateTime/", checkBoxDateTime->isChecked() );
QgsProject::instance()->writeEntry( "Globe-Plugin", "/skyDateTime/", dateTimeEditSky->dateTime().toString() );
QgsProject::instance()->writeEntry( "Globe-Plugin", "/skyAutoAmbient/", checkBoxSkyAutoAmbient->isChecked() );
QgsProject::instance()->writeEntry( "Globe-Plugin", "/skyMinAmbient/", horizontalSliderMinAmbient->value() );
Expand Down Expand Up @@ -460,7 +466,15 @@ bool QgsGlobePluginDialog::getSkyEnabled() const

QDateTime QgsGlobePluginDialog::getSkyDateTime() const
{
return QDateTime::fromString( QgsProject::instance()->readEntry( "Globe-Plugin", "/skyDateTime", QDateTime::currentDateTime().toString() ) );
bool overrideDateTime = QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/overrideDateTime", false );
if ( overrideDateTime )
{
return QDateTime::fromString( QgsProject::instance()->readEntry( "Globe-Plugin", "/skyDateTime", QDateTime::currentDateTime().toString() ) );
}
else
{
return QDateTime::currentDateTime();
}
}

bool QgsGlobePluginDialog::getSkyAutoAmbience() const
Expand Down
24 changes: 18 additions & 6 deletions src/plugins/globe/qgsglobeplugindialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,27 @@
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="labelDateTime">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxDateTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Date / Time (UTC):</string>
<string>Override Date / Time (UTC):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QDateTimeEdit" name="dateTimeEditSky">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="displayFormat">
<string>dd.MM.yyyy HH:mm</string>
</property>
Expand All @@ -76,14 +88,14 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxSkyAutoAmbient">
<property name="text">
<string>Ambient lighting</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QSlider" name="horizontalSliderMinAmbient">
<property name="enabled">
<bool>false</bool>
Expand Down

0 comments on commit 30813f9

Please sign in to comment.