Compare Show Animation

.. need to fix hide timeout animation but do that
   later tonight.
This commit is contained in:
Mark Liversedge
2013-11-29 07:20:35 +01:00
parent c10b9c89c1
commit d16b86ba68
2 changed files with 25 additions and 3 deletions

View File

@@ -64,6 +64,9 @@ TabView::TabView(Context *context, int type) :
mainSplitter->setContentsMargins(0, 0, 0, 0); // attempting to follow some UI guides
mainSplitter->setOpaqueResize(true); // redraw when released, snappier UI
// the animator
anim = new QPropertyAnimation(mainSplitter, "hpos");
connect(splitter,SIGNAL(splitterMoved(int,int)), this, SLOT(splitterMoved(int,int)));
}
@@ -138,12 +141,28 @@ TabView::setShowBottom(bool x)
// basic version for now .. remembers and sets horizontal position precisely
// adding animation should be easy from here
if (bottom_) {
if (x) {
// set to the last value....
bottom_->show();
mainSplitter->setProperty("hpos", mainSplitter->maxhpos() - (lastHeight+22));
anim->setDuration(200);
anim->setEasingCurve(QEasingCurve(QEasingCurve::Linear));
anim->setKeyValueAt(0,mainSplitter->maxhpos()-22);
anim->setKeyValueAt(1,mainSplitter->maxhpos()-(lastHeight+22));
anim->start();
} else {
// need a hide animator to hide on timeout
//anim->setDuration(200);
//anim->setEasingCurve(QEasingCurve(QEasingCurve::Linear));
//anim->setKeyValueAt(0,mainSplitter->maxhpos()-(lastHeight+22));
//anim->setKeyValueAt(1,mainSplitter->maxhpos()-22);
//anim->start();
bottom_->hide();
}
}

View File

@@ -121,6 +121,7 @@ class TabView : public QWidget
QStackedWidget *stack;
QSplitter *splitter;
ViewSplitter *mainSplitter;
QPropertyAnimation *anim;
QWidget *sidebar_;
QWidget *bottom_;
HomeWindow *page_;
@@ -135,7 +136,9 @@ class ViewSplitter : public QSplitter
public:
ViewSplitter(Qt::Orientation orientation, QString name, QWidget *parent=0) :
orientation(orientation), name(name), QSplitter(orientation, parent) {}
orientation(orientation), name(name), QSplitter(orientation, parent) {
qRegisterMetaType<ViewSplitter*>("hpos");
}
protected:
QSplitterHandle *createHandle() {
@@ -147,7 +150,7 @@ public:
Q_PROPERTY(int hpos READ hpos WRITE sethpos USER true)
// handle position
int hpos() const { return sizes()[0]; }
int hpos() const { if (sizes().count() == 2) return sizes()[0]; else return 0; }
void sethpos(int x) {
if (x<0) return; //r requested size too small!