-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmyapplicationwindow.cpp
62 lines (50 loc) · 2.07 KB
/
myapplicationwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "myapplicationwindow.h"
#include <QStandardPaths>
#include <QDir>
#include <QSettings>
#include <QVariant>
#include <QQuickView>
#define DISPLAY_DURATION 10 * 1000
#define TRANSITION_DURATION 4 * 1000
#define BLUR_VALUE 99
myApplicationWindow::myApplicationWindow(QObject *parent) : QObject(parent)
{
}
myApplicationWindow::~myApplicationWindow()
{
QSettings settings;
settings.setValue("blurValue", QVariant(blurValue));
settings.setValue("displayDuration", QVariant(displayDuration));
settings.setValue("pictureDirectory", QVariant(pictureDirectory));
settings.setValue("transitionDuration", QVariant(transitionDuration));
}
void myApplicationWindow::Init()
{
// mainComponent = new QQmlComponent(&engine, "main.qml");
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
appWindow = engine.rootObjects().first();
QSettings settings;
QString pictureHomeDir = QStandardPaths::standardLocations(
QStandardPaths::PicturesLocation).first();
blurValue = settings.value("blurValue",BLUR_VALUE).toInt();
displayDuration = settings.value("displayDuration", DISPLAY_DURATION).toInt();
transitionDuration = settings.value("transitionDuration", TRANSITION_DURATION).toInt();
pictureDirectory = settings.value("pictureDirectory", pictureHomeDir).toString();
// QQuickView *v = new QQuickView(&engine,0);
// v->setScreen();
QDir d(pictureDirectory);
myImages = new imageFiles(this);
myImages->setupImageProvider(&engine);
myImages->readImageURLsFromDisk(d);
// myImages->ReadURLs();
engine.rootContext()->setContextProperty("myImages", myImages);
appWindow->setProperty("showImageDuration", displayDuration);
appWindow->setProperty("transitionDuration", transitionDuration);
appWindow->setProperty("blurValue",blurValue);
appWindow->setProperty("pictureHome", pictureHomeDir);
QVariant returnedValue;
QVariant msg = "Initialize";
QMetaObject::invokeMethod(appWindow, "setImageState",
Q_RETURN_ARG(QVariant, returnedValue),
Q_ARG(QVariant, msg));
}