Support save / load for the Animation Speed on the Preferences

User can now fine-tune the animation speed on the preferences,
a value of zero disables it completely.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-03-11 17:36:49 -03:00 committed by Dirk Hohndel
parent 9f37bac07a
commit 751c76a578
3 changed files with 128 additions and 51 deletions

View file

@ -105,6 +105,11 @@ void PreferencesDialog::setUiFromPrefs()
QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString()); QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString());
if (languages.count()) if (languages.count())
ui.languageView->setCurrentIndex(languages.first()); ui.languageView->setCurrentIndex(languages.first());
s.endGroup();
s.beginGroup("Animations");
int animVelocity = s.value("animation_speed",500).toInt();
ui.velocitySlider->setValue(animVelocity);
} }
void PreferencesDialog::restorePrefs() void PreferencesDialog::restorePrefs()
@ -218,6 +223,8 @@ void PreferencesDialog::syncSettings()
s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole)); s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole));
s.endGroup(); s.endGroup();
s.beginGroup("Animations");
s.setValue("animation_speed",ui.velocitySlider->value());
loadSettings(); loadSettings();
emit settingsChanged(); emit settingsChanged();
} }
@ -289,6 +296,10 @@ void PreferencesDialog::loadSettings()
prefs.font_size = defaultFont.pointSizeF(); prefs.font_size = defaultFont.pointSizeF();
GET_INT("displayinvalid", display_invalid_dives); GET_INT("displayinvalid", display_invalid_dives);
s.endGroup(); s.endGroup();
s.beginGroup("Animations");
int animVelocity = s.value("animation_speed",500).toInt();
ui.velocitySlider->setValue(animVelocity);
} }
void PreferencesDialog::buttonClicked(QAbstractButton *button) void PreferencesDialog::buttonClicked(QAbstractButton *button)

View file

@ -231,6 +231,39 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>Animations</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>Speed</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="velocitySlider">
<property name="maximum">
<number>500</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="velocitySpinBox">
<property name="maximum">
<number>500</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
@ -746,8 +779,8 @@
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>235</x> <x>247</x>
<y>511</y> <y>635</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>157</x> <x>157</x>
@ -762,8 +795,8 @@
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>303</x> <x>315</x>
<y>511</y> <y>635</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>286</x> <x>286</x>
@ -794,12 +827,12 @@
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>195</x> <x>845</x>
<y>39</y> <y>51</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>195</x> <x>308</x>
<y>39</y> <y>100</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -842,12 +875,12 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>504</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>623</x>
<y>20</y> <y>119</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -858,12 +891,12 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>319</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>385</x>
<y>20</y> <y>119</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -874,12 +907,12 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>504</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>623</x>
<y>20</y> <y>153</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -890,12 +923,12 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>319</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>385</x>
<y>20</y> <y>153</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -906,12 +939,12 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>504</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>623</x>
<y>20</y> <y>187</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -922,12 +955,12 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>319</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>385</x>
<y>20</y> <y>187</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -938,12 +971,12 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>504</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>623</x>
<y>20</y> <y>221</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -954,12 +987,12 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>319</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>385</x>
<y>20</y> <y>221</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -970,12 +1003,12 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>504</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>623</x>
<y>20</y> <y>255</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -986,23 +1019,55 @@
<slot>setChecked(bool)</slot> <slot>setChecked(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>20</x> <x>319</x>
<y>20</y> <y>46</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>20</x> <x>385</x>
<y>20</y> <y>255</y>
</hint>
</hints>
</connection>
<connection>
<sender>velocitySlider</sender>
<signal>valueChanged(int)</signal>
<receiver>velocitySpinBox</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>718</x>
<y>415</y>
</hint>
<hint type="destinationlabel">
<x>823</x>
<y>414</y>
</hint>
</hints>
</connection>
<connection>
<sender>velocitySpinBox</sender>
<signal>valueChanged(int)</signal>
<receiver>velocitySlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>790</x>
<y>400</y>
</hint>
<hint type="destinationlabel">
<x>580</x>
<y>417</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
</connections> </connections>
<buttongroups> <buttongroups>
<buttongroup name="buttonGroup_5"/>
<buttongroup name="buttonGroup_6"/>
<buttongroup name="buttonGroup"/>
<buttongroup name="verticalSpeed"/> <buttongroup name="verticalSpeed"/>
<buttongroup name="buttonGroup_2"/> <buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup_3"/> <buttongroup name="buttonGroup_3"/>
<buttongroup name="buttonGroup_4"/> <buttongroup name="buttonGroup_4"/>
<buttongroup name="buttonGroup_5"/>
<buttongroup name="buttonGroup_6"/>
<buttongroup name="buttonGroup"/>
</buttongroups> </buttongroups>
</ui> </ui>

View file

@ -26,6 +26,7 @@ namespace Animations
void moveTo(QObject *obj, qreal x, qreal y) void moveTo(QObject *obj, qreal x, qreal y)
{ {
QSettings s; QSettings s;
s.beginGroup("Animations");
int msecs = s.value("animation_speed", 500).toInt(); int msecs = s.value("animation_speed", 500).toInt();
if (msecs != 0){ if (msecs != 0){
QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos"); QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");