Remove duplicate setting; Make settings page open; button state

This commit is contained in:
Zach Fox 2017-04-26 13:01:02 -07:00
parent 3221214283
commit 6711e8cbc2
2 changed files with 35 additions and 34 deletions

View file

@ -116,11 +116,6 @@ void setupPreferences() {
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);
} }
{
auto getter = []()->bool { return SnapshotAnimated::alsoTakeAnimatedSnapshot.get(); };
auto setter = [](bool value) { SnapshotAnimated::alsoTakeAnimatedSnapshot.set(value); };
preferences->addPreference(new CheckPreference(SNAPSHOTS, "Take Animated GIF Snapshot", getter, setter));
}
{ {
auto getter = []()->float { return SnapshotAnimated::snapshotAnimatedDuration.get(); }; auto getter = []()->float { return SnapshotAnimated::snapshotAnimatedDuration.get(); };
auto setter = [](float value) { SnapshotAnimated::snapshotAnimatedDuration.set(value); }; auto setter = [](float value) { SnapshotAnimated::snapshotAnimatedDuration.set(value); };

View file

@ -24,6 +24,7 @@ var buttonConnected = false;
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({ var button = tablet.addButton({
icon: "icons/tablet-icons/snap-i.svg", icon: "icons/tablet-icons/snap-i.svg",
activeIcon: "icons/tablet-icons/snap-a.svg",
text: buttonName, text: buttonName,
sortOrder: 5 sortOrder: 5
}); });
@ -137,8 +138,7 @@ function onMessage(message) {
} }
break; break;
case 'openSettings': case 'openSettings':
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar")) if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", true)) || (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar", false))) {
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar"))) {
Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "General Preferences"); Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "General Preferences");
} else { } else {
tablet.loadQMLOnTop("TabletGeneralPreferences.qml"); tablet.loadQMLOnTop("TabletGeneralPreferences.qml");
@ -229,7 +229,11 @@ function onMessage(message) {
var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html"); var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html");
var isInSnapshotReview = false; var isInSnapshotReview = false;
function openSnapApp() { function onButtonClicked() {
if (isInSnapshotReview){
// for toolbar-mode: go back to home screen, this will close the window.
tablet.gotoHomeScreen();
} else {
var previousStillSnapPath = Settings.getValue("previousStillSnapPath"); var previousStillSnapPath = Settings.getValue("previousStillSnapPath");
var previousStillSnapStoryID = Settings.getValue("previousStillSnapStoryID"); var previousStillSnapStoryID = Settings.getValue("previousStillSnapStoryID");
var previousStillSnapSharingDisabled = Settings.getValue("previousStillSnapSharingDisabled"); var previousStillSnapSharingDisabled = Settings.getValue("previousStillSnapSharingDisabled");
@ -253,6 +257,7 @@ function openSnapApp() {
HMD.openTablet(); HMD.openTablet();
isInSnapshotReview = true; isInSnapshotReview = true;
} }
}
function snapshotUploaded(isError, reply) { function snapshotUploaded(isError, reply) {
if (!isError) { if (!isError) {
@ -315,7 +320,7 @@ function takeSnapshot() {
Window.stillSnapshotTaken.connect(stillSnapshotTaken); Window.stillSnapshotTaken.connect(stillSnapshotTaken);
} }
if (buttonConnected) { if (buttonConnected) {
button.clicked.disconnect(openSnapApp); button.clicked.disconnect(onButtonClicked);
buttonConnected = false; buttonConnected = false;
} }
@ -366,7 +371,7 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
} }
Window.stillSnapshotTaken.disconnect(stillSnapshotTaken); Window.stillSnapshotTaken.disconnect(stillSnapshotTaken);
if (!buttonConnected) { if (!buttonConnected) {
button.clicked.connect(openSnapApp); button.clicked.connect(onButtonClicked);
buttonConnected = true; buttonConnected = true;
} }
@ -430,7 +435,7 @@ function processingGifStarted(pathStillSnapshot) {
function processingGifCompleted(pathAnimatedSnapshot) { function processingGifCompleted(pathAnimatedSnapshot) {
Window.processingGifCompleted.disconnect(processingGifCompleted); Window.processingGifCompleted.disconnect(processingGifCompleted);
if (!buttonConnected) { if (!buttonConnected) {
button.clicked.connect(openSnapApp); button.clicked.connect(onButtonClicked);
buttonConnected = true; buttonConnected = true;
} }
@ -469,6 +474,7 @@ function maybeDeleteSnapshotStories() {
} }
} }
function onTabletScreenChanged(type, url) { function onTabletScreenChanged(type, url) {
button.editProperties({ isActive: !isInSnapshotReview });
if (isInSnapshotReview) { if (isInSnapshotReview) {
tablet.webEventReceived.disconnect(onMessage); tablet.webEventReceived.disconnect(onMessage);
isInSnapshotReview = false; isInSnapshotReview = false;
@ -482,14 +488,14 @@ function onUsernameChanged() {
} }
} }
button.clicked.connect(openSnapApp); 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);
Script.scriptEnding.connect(function () { Script.scriptEnding.connect(function () {
if (buttonConnected) { if (buttonConnected) {
button.clicked.disconnect(openSnapApp); button.clicked.disconnect(onButtonClicked);
buttonConnected = false; buttonConnected = false;
} }
if (tablet) { if (tablet) {