mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +02:00
Subscribe to changes to snapshotsLocation setter for better UX
This commit is contained in:
parent
f453df36cf
commit
c9e0679b70
3 changed files with 14 additions and 1 deletions
|
@ -111,7 +111,7 @@ void setupPreferences() {
|
||||||
static const QString SNAPSHOTS { "Snapshots" };
|
static const QString SNAPSHOTS { "Snapshots" };
|
||||||
{
|
{
|
||||||
auto getter = []()->QString { return Snapshot::snapshotsLocation.get(); };
|
auto getter = []()->QString { return Snapshot::snapshotsLocation.get(); };
|
||||||
auto setter = [](const QString& value) { Snapshot::snapshotsLocation.set(value); };
|
auto setter = [](const QString& value) { Snapshot::snapshotsLocation.set(value); emit DependencyManager::get<Snapshot>()->snapshotLocationSet(value); };
|
||||||
auto preference = new BrowsePreference(SNAPSHOTS, "Put my snapshots here", getter, setter);
|
auto preference = new BrowsePreference(SNAPSHOTS, "Put my snapshots here", getter, setter);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,9 @@ public:
|
||||||
static Setting::Handle<QString> snapshotsLocation;
|
static Setting::Handle<QString> snapshotsLocation;
|
||||||
static void uploadSnapshot(const QString& filename, const QUrl& href = QUrl(""));
|
static void uploadSnapshot(const QString& filename, const QUrl& href = QUrl(""));
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void snapshotLocationSet(const QString& value);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
Q_INVOKABLE QString getSnapshotsLocation();
|
Q_INVOKABLE QString getSnapshotsLocation();
|
||||||
Q_INVOKABLE void setSnapshotsLocation(const QString& location);
|
Q_INVOKABLE void setSnapshotsLocation(const QString& location);
|
||||||
|
|
|
@ -582,12 +582,21 @@ function onUsernameChanged() {
|
||||||
shareAfterLogin = false;
|
shareAfterLogin = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function snapshotLocationSet(location) {
|
||||||
|
if (location !== "") {
|
||||||
|
tablet.emitScriptEvent(JSON.stringify({
|
||||||
|
type: "snapshot",
|
||||||
|
action: "snapshotLocationChosen"
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
button.clicked.connect(onButtonClicked);
|
button.clicked.connect(onButtonClicked);
|
||||||
buttonConnected = true;
|
buttonConnected = true;
|
||||||
Window.snapshotShared.connect(snapshotUploaded);
|
Window.snapshotShared.connect(snapshotUploaded);
|
||||||
tablet.screenChanged.connect(onTabletScreenChanged);
|
tablet.screenChanged.connect(onTabletScreenChanged);
|
||||||
Account.usernameChanged.connect(onUsernameChanged);
|
Account.usernameChanged.connect(onUsernameChanged);
|
||||||
|
Snapshot.snapshotLocationSet.connect(snapshotLocationSet);
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
if (buttonConnected) {
|
if (buttonConnected) {
|
||||||
button.clicked.disconnect(onButtonClicked);
|
button.clicked.disconnect(onButtonClicked);
|
||||||
|
@ -598,6 +607,7 @@ Script.scriptEnding.connect(function () {
|
||||||
}
|
}
|
||||||
Window.snapshotShared.disconnect(snapshotUploaded);
|
Window.snapshotShared.disconnect(snapshotUploaded);
|
||||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
||||||
|
Snapshot.snapshotLocationSet.disconnect(snapshotLocationSet);
|
||||||
});
|
});
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
Loading…
Reference in a new issue