fix(filemanager): prevent properties dialog flicker

main
reionwong 3 weeks ago
parent 7296204c4b
commit fe13eb4809

@ -100,10 +100,6 @@ QString FilePropertiesDialog::accessedTime() const
void FilePropertiesDialog::init()
{
rootContext()->setContextProperty("main", this);
load(QUrl("qrc:/qml/Dialogs/PropertiesDialog.qml"));
m_multiple = m_items.count() > 1;
QList<QUrl> list;
@ -111,12 +107,6 @@ void FilePropertiesDialog::init()
list.append(item.url());
}
m_sizeJob = std::shared_ptr<CFileSizeJob>(new CFileSizeJob);
m_sizeJob->start(list);
connect(m_sizeJob.get(), &CFileSizeJob::sizeChanged, this, &FilePropertiesDialog::updateTotalSize);
connect(m_sizeJob.get(), &CFileSizeJob::result, this, &FilePropertiesDialog::updateTotalSize);
if (!m_multiple) {
KFileItem item = m_items.first();
QFileInfo info(item.url().toLocalFile());
@ -154,6 +144,17 @@ void FilePropertiesDialog::init()
emit locationChanged();
emit iconNameChanged();
}
// Populate the properties before loading the QML window. Its size is
// derived from the content, so changing these values after load can
// resize the window during its first expose.
rootContext()->setContextProperty("main", this);
load(QUrl("qrc:/qml/Dialogs/PropertiesDialog.qml"));
m_sizeJob = std::shared_ptr<CFileSizeJob>(new CFileSizeJob);
connect(m_sizeJob.get(), &CFileSizeJob::sizeChanged, this, &FilePropertiesDialog::updateTotalSize);
connect(m_sizeJob.get(), &CFileSizeJob::result, this, &FilePropertiesDialog::updateTotalSize);
m_sizeJob->start(list);
}
void FilePropertiesDialog::updateTotalSize()

@ -91,7 +91,7 @@ private:
std::shared_ptr<CFileSizeJob> m_sizeJob;
bool m_multiple;
bool m_multiple = false;
};
#endif // FILEPROPERTIESDIALOG_H

@ -64,6 +64,11 @@ FishUI.Window {
Layout.preferredWidth: 48
Layout.preferredHeight: 48
source: main.iconName
// The source is available while the item is being created.
// Refresh after completion so IconItem can load it once its
// component lifecycle is ready.
Component.onCompleted: updateIcon()
}
Label {

@ -21,8 +21,10 @@
#include "qmltypes.h"
#include <QEvent>
#include <QDebug>
#include <QPointer>
#include <QQuickWindow>
#include <QPixmapCache>
#include <QTimer>
Window::Window(QObject *parent)
: QQmlApplicationEngine(parent)
@ -48,9 +50,19 @@ void Window::load(const QUrl &url)
void Window::show()
{
if (QQuickWindow *w = quickWindow()) {
w->show();
w->raise();
w->requestActivate();
QPointer<QQuickWindow> window(w);
// Let QML finish its initial layout pass before the native window is
// exposed. Showing it in the same call stack can expose the initial
// size for one frame and then resize it, which appears as a flash.
QTimer::singleShot(0, w, [window] {
if (!window)
return;
window->show();
window->raise();
window->requestActivate();
});
}
}

Loading…
Cancel
Save