Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Commit ba209e5

Browse files
committed
fixed prefs loading
1 parent ff82049 commit ba209e5

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

Demo/main.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,6 @@ int main(int argc, char *argv[])
1515

1616
qmlRegisterType<Opener>("de.skycoder42.androidutils", 1, 0, "Opener");
1717

18-
#ifdef Q_OS_ANDROID
19-
QUrl url("file:///sdcard/temp/baum");
20-
ContentDevice device(url);
21-
22-
if(device.open(QIODevice::WriteOnly)) {
23-
device.write("baum == 42");
24-
device.close();
25-
} else
26-
qCritical() << "ContentDevice:" << device.errorString();
27-
28-
if(device.open(QIODevice::ReadOnly)) {
29-
qDebug() << "ContentDevice:" << device.readAll();
30-
device.close();
31-
} else
32-
qCritical() << "ContentDevice:" << device.errorString();
33-
34-
auto prefs = SharedPreferences::getPreferences();
35-
QObject::connect(prefs, &SharedPreferences::loaded, prefs, [prefs](){
36-
qDebug() << "init state" << prefs->data();
37-
prefs->setValue("test1", "test2");
38-
prefs->setValue("test2", 42);
39-
prefs->remove("test2");
40-
});
41-
#endif
42-
4318
QQmlApplicationEngine engine;
4419
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
4520

sharedpreferences.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ void SharedPreferences::dispatched(const QString &message, const QVariantMap &da
9595
_data.insert(key, value);
9696
emit changed(key, value);
9797
}
98-
} else if(message == QStringLiteral("AndroidUtils.PrefHelper.loaded.") + _id)
98+
} else if(message == QStringLiteral("AndroidUtils.PrefHelper.loaded.") + _id) {
9999
_data = data;
100+
emit loaded();
101+
}
100102
}

0 commit comments

Comments
 (0)