Navigation stack refactorisation

simplifies the mainwindow ui stacked widget
removes the progamatic construction and replaces it
with the designer QML.
Also factorises the code of slidepage in Utils.h for
a consistent page switching at all levels of UI.

Change-Id: I75ee29b0b93de63978262db4da04dc6c96e0942e
Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
diff --git a/utils.cpp b/utils.cpp
index cc45a9f..03864d8 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -32,6 +32,8 @@
 #include <QObject>
 #include <QErrorMessage>
 #include <QPainter>
+#include <QStackedWidget>
+#include <QPropertyAnimation>
 
 bool
 Utils::CreateStartupLink()
@@ -208,3 +210,19 @@
     painter.drawImage(0, 0, scaledPhoto, margin, 0);
     return target;
 }
+
+void
+Utils::slidePage(QStackedWidget* stack, QWidget* widget, bool toRight)
+{
+    if (stack->indexOf(widget) != -1 && stack->currentWidget() != widget){
+        QPropertyAnimation* pageAnim = new QPropertyAnimation();
+        int dir = (toRight ? -1 : 1);
+        stack->setCurrentWidget(widget);
+        pageAnim->setTargetObject(widget);
+        pageAnim->setDuration(animDuration_);
+        pageAnim->setStartValue(QPoint(widget->width() * dir, widget->y()));
+        pageAnim->setEndValue(QPoint(widget->x(), widget->y()));
+        pageAnim->setEasingCurve(QEasingCurve::OutQuad);
+        pageAnim->start();
+    }
+}