Fix splash cannot be closed (still hidden by default)

parent 5a390968
Pipeline #1763 passed with stage
in 14 minutes and 55 seconds
......@@ -24,31 +24,50 @@
#include <KDeclarative/KDeclarative>
#include <QQmlContext>
#include <QQuickItem>
#include <QQuickWindow>
#include <QStandardPaths>
Splash::Splash()
: QObject()
Splash::Splash(QObject *parent)
: QObject(parent)
, m_engine(new QQmlEngine())
, childItem(nullptr)
{
KDeclarative::KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(m_engine);
kdeclarative.setupEngine(m_engine);
kdeclarative.setupContext();
QQmlComponent component(m_engine);
component.loadUrl(QUrl(QStringLiteral("qrc:/qml/splash.qml")));
if (component.isReady()) {
auto *root = component.create();
connect(this, SIGNAL(sigEndSplash()), root, SIGNAL(endSplash()));
component = new QQmlComponent(m_engine);
QQuickWindow::setDefaultAlphaBuffer(true);
component->loadUrl(QUrl(QStringLiteral("qrc:/qml/splash.qml")));
if (component->isLoading())
QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)),
this, SLOT(continueLoading()));
else {
continueLoading();
}
}
void Splash::continueLoading()
{
if (component->isReady()) {
childItem = qobject_cast<QQuickWindow*>(component->create());
} else {
qWarning() << component.errorString();
qWarning() << component->errorString();
}
}
Splash::~Splash()
{
delete childItem;
delete component;
delete m_engine;
}
void Splash::endSplash()
{
if (childItem) {
QMetaObject::invokeMethod(childItem, "endSplash");
} else {
qDebug()<<"** ERROR NO SPLASH COMPO";
}
emit sigEndSplash();
}
......@@ -23,15 +23,18 @@
#define SPLASH_H
#include <QObject>
#include <memory>
class QQmlEngine;
class QQmlComponent;
class QQuickWindow;
class Splash : public QObject
{
Q_OBJECT
public:
Splash();
Splash(QObject *parent);
~Splash();
void endSplash();
......@@ -39,8 +42,13 @@ public:
signals:
void sigEndSplash();
private slots:
void continueLoading();
protected:
QQmlEngine *m_engine;
QQmlComponent* component;
QQuickWindow *childItem;
};
#endif
......@@ -52,10 +52,6 @@
#include <QUrl> //new
#include <klocalizedstring.h>
int fact(int n)
{
return n < 2 ? n : fact(n - 1) + fact(n - 2);
}
int main(int argc, char *argv[])
{
#ifdef USE_DRMINGW
......@@ -172,7 +168,7 @@ int main(int argc, char *argv[])
KCrash::initialize();
#endif
//auto splash = new Splash();
//auto splash = new Splash(&app);
//splash->show();
//qApp->processEvents();
......@@ -202,13 +198,12 @@ int main(int argc, char *argv[])
}
//qApp->processEvents();
Core::build(mltPath);
//qApp->processEvents();
pCore->initGUI(url);
//delete splash;
//splash->endSplash();
//qApp->processEvents();
int result = app.exec();
Core::clean();
//delete splash;
if (EXIT_RESTART == result) {
qCDebug(KDENLIVE_LOG) << "restarting app";
......
......@@ -44,11 +44,11 @@ Window {
property int border: 10
property bool splashing: true
signal endSplash
onEndSplash: {
function endSplash()
{
console.log("ending splash")
splash.splashing = false;
splash.close();
}
Rectangle {
......@@ -204,14 +204,18 @@ Window {
}
}
/*MouseArea {
anchors.fill: parent
MouseArea {
id: clickZone
anchors.fill: splashContent
onClicked: {
console.log("clic");
splash.close();
}
}*/
}
}
Component.onCompleted: {
visible = true
clickZone.focus = true;
}
Component.onCompleted: visible = true
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment