helloSystem / Filer

A file manager that can also render the desktop
GNU General Public License v2.0
32 stars 8 forks source link

Add animation when objects are opened #20

Open probonopd opened 3 years ago

probonopd commented 3 years ago

E.g., Open animation like in https://user-images.githubusercontent.com/900690/51821977-24acd700-22db-11e9-865a-17490e445f35.gif

probonopd commented 3 years ago

In the Dock we have implemented this and it was actually very easy, but the Dock is written in Qml.

How do we do this in Filer? https://doc.qt.io/qt-5/qpropertyanimation.html

Something in libfm-qt/filelauncher.cpp along the lines of

#include <QPropertyAnimation>

bool FileLauncher::launchFiles(QWidget* parent, GList* file_infos) {
    qDebug() << "probono: FileLauncher::launchFiles called";
    qDebug() << "probono: parent:" << parent;

    QPropertyAnimation *animation = new QPropertyAnimation(parent, "pos");
    animation->setTargetObject(parent);
    animation->setDuration(1500);
    animation->setEndValue(QPoint(400, 400)); // Actually we want to increase the size, as we do in the Dock
    animation->start();
    // FIXME: QPropertyAnimation::updateState (pos): Changing state of an animation without target

maybe?

I think our bool FileLauncher::launchFiles(QWidget* parent, GList* file_infos) method needs to be changed:

cc @moochris

probonopd commented 1 year ago

In desktopitemdelegate.cpp, we may need to add a Q_PROPERTY for what we want to animate (e.g., size and/or opacity)

https://stackoverflow.com/a/52856454

Then we can use a QPropertyAnimation https://felgo.com/doc/qt/qpropertyanimation/

or a QVariantAnimation to animate that property similar to

    auto moveAnimation = new QPropertyAnimation( &t,  "pos" );
    moveAnimation->setDuration( 10000 );
    moveAnimation->setStartValue( QPointF(640, 680) );
    moveAnimation->setEndValue(  QPointF(0, 0) );
    moveAnimation->setEasingCurve( QEasingCurve::Linear );
    moveAnimation->start(QAbstractAnimation::DeleteWhenStopped);

https://stackoverflow.com/q/52853322

Need to play with https://github.com/kimtaikee/resizeAnimation examples.

probonopd commented 1 year ago

While the icon is increased, we can slowly fade it out; maybe using https://doc.qt.io/qt-5/qgraphicsopacityeffect.html?

probonopd commented 1 year ago

If the opened item is a folder, the folder's window appears instantly; we might use a KWin animatin for it.

If the launched item is an application, we may need to animate the application icon instead because a window may or may not appear immediately.

probonopd commented 1 year ago

It looks like it can be done using QTimeLine Property Animation. Proof-of-concept is here.