Filer icon indicating copy to clipboard operation
Filer copied to clipboard

Add animation when objects are opened

Open probonopd opened this issue 5 years ago • 5 comments

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

probonopd avatar Dec 09 '20 18:12 probonopd

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:

  • Whatever is meant with QWidget* parent, it is not the icon in the list view that is being launched, and often it is nullptr
  • GList* file_infos can contain multiple files
  • Hence, we need to pass in a a list of QWidgets (the icon in the list view)? Hwo to do this?

cc @moochris

probonopd avatar Apr 05 '21 18:04 probonopd

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 avatar Nov 27 '22 18:11 probonopd

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

probonopd avatar Nov 27 '22 19:11 probonopd

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 avatar Dec 10 '22 12:12 probonopd

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

probonopd avatar Jul 29 '23 13:07 probonopd