some bugfixes for today. :)
From f45606b22ece4d63e232d7cecbb3de6f1a8aa466 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Tue, 11 Mar 2014 18:54:28 -0300
Subject: [PATCH 4/4] Only anim if not first dive when openning subsurface with
 a divelog.

The animation appeared when the user started subsurface with a default
file, wich was a little annoying since it didn't had a 'from' position
to go and it was also increasing it's size on some window managers
that do subtle windows animations when a program starts. This patch
treats the first dive opened when the program loads with a divelog pa
rameter differently as the following ones storing the velocity value
on a temporary, and reassigning it later.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 main.cpp                         |  6 ++++--
 qt-ui/mainwindow.cpp             | 10 ++++++++++
 qt-ui/mainwindow.h               |  3 +++
 qt-ui/profile/profilewidget2.cpp | 16 ++++++++++++++++
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/main.cpp b/main.cpp
index 2296960..e5a53a3 100644
--- a/main.cpp
+++ b/main.cpp
@@ -48,8 +48,10 @@ int main(int argc, char **argv)
 			files.push_back(QString(prefs.default_filename));
 	}
 	parse_xml_exit();
-	MainWindow::instance()->loadFiles(files);
-	MainWindow::instance()->importFiles(importedFiles);
+	MainWindow *m = MainWindow::instance();
+	m->setLoadedWithFiles( !files.isEmpty() || !importedFiles.isEmpty());
+	m->loadFiles(files);
+	m->importFiles(importedFiles);
 	if (!quit)
 		run_ui();
 	exit_ui();
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 20f463c..eb0f377 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -85,6 +85,16 @@ MainWindow::~MainWindow()
 	m_Instance = NULL;
 }
 
+void MainWindow::setLoadedWithFiles(bool f)
+{
+	filesAsArguments = f;
+}
+
+bool MainWindow::filesFromCommandLine() const
+{
+	return filesAsArguments;
+}
+
 MainWindow *MainWindow::instance()
 {
 	return m_Instance;
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 40f22dd..003279d 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -77,6 +77,8 @@ public:
 	void importFiles(const QStringList importFiles);
 	void cleanUpEmpty();
 	ProfileWidget2 *graphics() const;
+	void setLoadedWithFiles(bool filesFromCommandLine);
+	bool filesFromCommandLine() const;
 private
 slots:
 	/* file menu action */
@@ -164,6 +166,7 @@ private:
 	void saveSplitterSizes();
 	QString lastUsedDir();
 	void updateLastUsedDir(const QString &s);
+	bool filesAsArguments;
 };
 
 MainWindow *mainWindow();
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 822f1bc..2f03d8f 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -316,12 +316,23 @@ void ProfileWidget2::setupSceneAndFlags()
 // Currently just one dive, but the plan is to enable All of the selected dives.
 void ProfileWidget2::plotDives(QList<dive *> dives)
 {
+	static bool firstCall = true;
+
 	// I Know that it's a list, but currently we are
 	// using just the first.
 	struct dive *d = dives.first();
 	if (!d)
 		return;
 
+	int animSpeedBackup = -1;
+	if(firstCall && MainWindow::instance()->filesFromCommandLine()){
+		QSettings s;
+		s.beginGroup("Animations");
+		animSpeedBackup = s.value("animation_speed",500).toInt();
+		s.setValue("animation_speed",0);
+		firstCall = false;
+	}
+
 	// restore default zoom level and tooltip position
 	if (zoomLevel) {
 		const qreal defScale = 1.0 / qPow(zoomFactor, (qreal)zoomLevel);
@@ -431,6 +442,11 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
 		// qDebug() << event->getEvent()->name << "@" << event->getEvent()->time.seconds;
 	}
 	diveComputerText->setText(currentdc->model);
+	if (MainWindow::instance()->filesFromCommandLine() && animSpeedBackup != -1){
+		QSettings s;
+		s.beginGroup("Animations");
+		s.setValue("animation_speed",animSpeedBackup);
+	}
 }
 
 void ProfileWidget2::settingsChanged()
-- 
1.9.0

From f150a82503879d5bb461a7b1cd0ec54e6d6a8a47 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Tue, 11 Mar 2014 18:11:34 -0300
Subject: [PATCH 3/4] Defer mainwindow->show()

The mainwindow->show(); was being called before we parsed
the dives, so in the case of a large dive file, we got a
very quick, but spottable, gray background on the profile.

The mainwindow->show(); now is called just before the
Qt main-loop starts.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-gui.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qt-gui.cpp b/qt-gui.cpp
index ff875f0..2b16c2d 100644
--- a/qt-gui.cpp
+++ b/qt-gui.cpp
@@ -151,7 +151,6 @@ void init_ui(int *argcp, char ***argvp)
 
 	window = new MainWindow();
 	window->loadRecentFiles(&s);
-	window->show();
 	if (existing_filename && existing_filename[0] != '\0')
 		window->setTitle(MWTF_FILENAME);
 	else
@@ -162,6 +161,7 @@ void init_ui(int *argcp, char ***argvp)
 
 void run_ui(void)
 {
+	window->show();
 	application->exec();
 }
 
-- 
1.9.0

From 4a1e8c20715f6d9916aa901523fcf7fb13e11966 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Tue, 11 Mar 2014 17:36:49 -0300
Subject: [PATCH 2/4] 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.canabr...@intel.com>
---
 qt-ui/preferences.cpp                |  11 +++
 qt-ui/preferences.ui                 | 167 ++++++++++++++++++++++++-----------
 qt-ui/profile/animationfunctions.cpp |   1 +
 3 files changed, 128 insertions(+), 51 deletions(-)

diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 2c72ceb..e3057b2 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -104,6 +104,11 @@ void PreferencesDialog::setUiFromPrefs()
 	QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString());
 	if (languages.count())
 		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()
@@ -216,6 +221,8 @@ void PreferencesDialog::syncSettings()
 	s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole));
 	s.endGroup();
 
+	s.beginGroup("Animations");
+	s.setValue("animation_speed",ui.velocitySlider->value());
 	loadSettings();
 	emit settingsChanged();
 }
@@ -286,6 +293,10 @@ void PreferencesDialog::loadSettings()
 		prefs.font_size = defaultFont.pointSizeF();
 	GET_INT("displayinvalid", display_invalid_dives);
 	s.endGroup();
+
+	s.beginGroup("Animations");
+	int animVelocity = s.value("animation_speed",500).toInt();
+	ui.velocitySlider->setValue(animVelocity);
 }
 
 void PreferencesDialog::buttonClicked(QAbstractButton *button)
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index 988c548..e9b0f8b 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -232,6 +232,39 @@
           </widget>
          </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>
           <spacer name="verticalSpacer_2">
            <property name="orientation">
             <enum>Qt::Vertical</enum>
@@ -732,8 +765,8 @@
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>235</x>
-     <y>511</y>
+     <x>247</x>
+     <y>635</y>
     </hint>
     <hint type="destinationlabel">
      <x>157</x>
@@ -748,8 +781,8 @@
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>303</x>
-     <y>511</y>
+     <x>315</x>
+     <y>635</y>
     </hint>
     <hint type="destinationlabel">
      <x>286</x>
@@ -780,12 +813,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>195</x>
-     <y>39</y>
+     <x>845</x>
+     <y>51</y>
     </hint>
     <hint type="destinationlabel">
-     <x>195</x>
-     <y>39</y>
+     <x>308</x>
+     <y>100</y>
     </hint>
    </hints>
   </connection>
@@ -828,12 +861,12 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>504</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>623</x>
+     <y>119</y>
     </hint>
    </hints>
   </connection>
@@ -844,12 +877,12 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>319</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>385</x>
+     <y>119</y>
     </hint>
    </hints>
   </connection>
@@ -860,12 +893,12 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>504</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>623</x>
+     <y>153</y>
     </hint>
    </hints>
   </connection>
@@ -876,12 +909,12 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>319</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>385</x>
+     <y>153</y>
     </hint>
    </hints>
   </connection>
@@ -892,12 +925,12 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>504</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>623</x>
+     <y>187</y>
     </hint>
    </hints>
   </connection>
@@ -908,12 +941,12 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>319</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>385</x>
+     <y>187</y>
     </hint>
    </hints>
   </connection>
@@ -924,12 +957,12 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>504</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>623</x>
+     <y>221</y>
     </hint>
    </hints>
   </connection>
@@ -940,12 +973,12 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>319</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>385</x>
+     <y>221</y>
     </hint>
    </hints>
   </connection>
@@ -956,12 +989,12 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>504</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>623</x>
+     <y>255</y>
     </hint>
    </hints>
   </connection>
@@ -972,23 +1005,55 @@
    <slot>setChecked(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
+     <x>319</x>
+     <y>46</y>
     </hint>
     <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
+     <x>385</x>
+     <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>
    </hints>
   </connection>
  </connections>
  <buttongroups>
+  <buttongroup name="buttonGroup_5"/>
+  <buttongroup name="buttonGroup_6"/>
+  <buttongroup name="buttonGroup"/>
   <buttongroup name="verticalSpeed"/>
   <buttongroup name="buttonGroup_2"/>
   <buttongroup name="buttonGroup_3"/>
   <buttongroup name="buttonGroup_4"/>
-  <buttongroup name="buttonGroup_5"/>
-  <buttongroup name="buttonGroup_6"/>
-  <buttongroup name="buttonGroup"/>
  </buttongroups>
 </ui>
diff --git a/qt-ui/profile/animationfunctions.cpp b/qt-ui/profile/animationfunctions.cpp
index 608c4c0..81fbf5e 100644
--- a/qt-ui/profile/animationfunctions.cpp
+++ b/qt-ui/profile/animationfunctions.cpp
@@ -26,6 +26,7 @@ namespace Animations
 	void moveTo(QObject *obj, qreal x, qreal y)
 	{
 		QSettings s;
+		s.beginGroup("Animations");
 		int msecs = s.value("animation_speed", 500).toInt();
 		if (msecs != 0){
 			QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
-- 
1.9.0

From 24a489650ca8029f20502d71d5cead629e1a89ff Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Tue, 11 Mar 2014 17:27:05 -0300
Subject: [PATCH 1/4] Support Animation Speed via Settings.

This is very userfull for a ( yet to be implemented )
preference dialog about the animation speed, so the
user can enable / disable the animations or make it a bit
faster for it's taste.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/animationfunctions.cpp | 24 ++++++++++++++++--------
 qt-ui/profile/animationfunctions.h   |  4 ++--
 qt-ui/profile/diveeventitem.cpp      |  2 +-
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/qt-ui/profile/animationfunctions.cpp b/qt-ui/profile/animationfunctions.cpp
index 8cccf61..608c4c0 100644
--- a/qt-ui/profile/animationfunctions.cpp
+++ b/qt-ui/profile/animationfunctions.cpp
@@ -1,6 +1,7 @@
 #include "animationfunctions.h"
 #include <QPropertyAnimation>
 #include <QPointF>
+#include <QSettings>
 
 namespace Animations
 {
@@ -22,17 +23,24 @@ namespace Animations
 		animation->start(QAbstractAnimation::DeleteWhenStopped);
 	}
 
-	void moveTo(QObject *obj, qreal x, qreal y, int msecs)
+	void moveTo(QObject *obj, qreal x, qreal y)
 	{
-		QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
-		animation->setDuration(msecs);
-		animation->setStartValue(obj->property("pos").toPointF());
-		animation->setEndValue(QPointF(x, y));
-		animation->start(QAbstractAnimation::DeleteWhenStopped);
+		QSettings s;
+		int msecs = s.value("animation_speed", 500).toInt();
+		if (msecs != 0){
+			QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
+			animation->setDuration(msecs);
+			animation->setStartValue(obj->property("pos").toPointF());
+			animation->setEndValue(QPointF(x, y));
+			animation->start(QAbstractAnimation::DeleteWhenStopped);
+		}
+		else{
+			obj->setProperty("pos", QPointF(x,y));
+		}
 	}
 
-	void moveTo(QObject *obj, const QPointF &pos, int msecs)
+	void moveTo(QObject *obj, const QPointF &pos)
 	{
-		moveTo(obj, pos.x(), pos.y(), msecs);
+		moveTo(obj, pos.x(), pos.y());
 	}
 }
diff --git a/qt-ui/profile/animationfunctions.h b/qt-ui/profile/animationfunctions.h
index f6c93c7..e033839 100644
--- a/qt-ui/profile/animationfunctions.h
+++ b/qt-ui/profile/animationfunctions.h
@@ -9,8 +9,8 @@ class QObject;
 namespace Animations
 {
 	void hide(QObject *obj);
-	void moveTo(QObject *obj, qreal x, qreal y, int msecs = 500);
-	void moveTo(QObject *obj, const QPointF &pos, int msecs = 500);
+	void moveTo(QObject *obj, qreal x, qreal y);
+	void moveTo(QObject *obj, const QPointF &pos);
 	void animDelete(QObject *obj);
 }
 
diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index 40d9e72..1fd4ef0 100644
--- a/qt-ui/profile/diveeventitem.cpp
+++ b/qt-ui/profile/diveeventitem.cpp
@@ -123,7 +123,7 @@ void DiveEventItem::recalculatePos(bool instant)
 	qreal x = hAxis->posAtValue(internalEvent->time.seconds);
 	qreal y = vAxis->posAtValue(depth);
 	if (!instant)
-		Animations::moveTo(this, x, y, 500);
+		Animations::moveTo(this, x, y);
 	else
 		setPos(x, y);
 }
-- 
1.9.0

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to