mirror of
https://github.com/overte-org/overte.git
synced 2025-06-23 05:20:06 +02:00
Snapshot JS interface for better Settings handling
This commit is contained in:
parent
794751abfa
commit
3ce81844da
5 changed files with 23 additions and 4 deletions
|
@ -535,6 +535,7 @@ bool setupEssentials(int& argc, char** argv) {
|
||||||
DependencyManager::set<OctreeStatsProvider>(nullptr, qApp->getOcteeSceneStats());
|
DependencyManager::set<OctreeStatsProvider>(nullptr, qApp->getOcteeSceneStats());
|
||||||
DependencyManager::set<AvatarBookmarks>();
|
DependencyManager::set<AvatarBookmarks>();
|
||||||
DependencyManager::set<LocationBookmarks>();
|
DependencyManager::set<LocationBookmarks>();
|
||||||
|
DependencyManager::set<Snapshot>();
|
||||||
|
|
||||||
return previousSessionCrashed;
|
return previousSessionCrashed;
|
||||||
}
|
}
|
||||||
|
@ -2052,6 +2053,7 @@ void Application::initializeUi() {
|
||||||
rootContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data());
|
rootContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data());
|
||||||
rootContext->setContextProperty("Render", _renderEngine->getConfiguration().get());
|
rootContext->setContextProperty("Render", _renderEngine->getConfiguration().get());
|
||||||
rootContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface());
|
rootContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface());
|
||||||
|
rootContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
|
||||||
|
|
||||||
rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor());
|
rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor());
|
||||||
|
|
||||||
|
@ -5504,6 +5506,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Stats", Stats::getInstance());
|
scriptEngine->registerGlobalObject("Stats", Stats::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
||||||
|
scriptEngine->registerGlobalObject("Snapshot", DependencyManager::get<Snapshot>().data());
|
||||||
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
|
scriptEngine->registerGlobalObject("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
|
||||||
scriptEngine->registerGlobalObject("AudioScope", DependencyManager::get<AudioScope>().data());
|
scriptEngine->registerGlobalObject("AudioScope", DependencyManager::get<AudioScope>().data());
|
||||||
|
|
|
@ -194,3 +194,10 @@ void Snapshot::uploadSnapshot(const QString& filename, const QUrl& href) {
|
||||||
multiPart);
|
multiPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Snapshot::getSnapshotsLocation() {
|
||||||
|
return snapshotsLocation.get("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Snapshot::setSnapshotsLocation(const QString& location) {
|
||||||
|
snapshotsLocation.set(location);
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include <SettingHandle.h>
|
#include <SettingHandle.h>
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
|
||||||
class QFile;
|
class QFile;
|
||||||
class QTemporaryFile;
|
class QTemporaryFile;
|
||||||
|
@ -32,7 +33,9 @@ private:
|
||||||
QUrl _URL;
|
QUrl _URL;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Snapshot {
|
class Snapshot : public QObject, public Dependency {
|
||||||
|
Q_OBJECT
|
||||||
|
SINGLETON_DEPENDENCY
|
||||||
public:
|
public:
|
||||||
static QString saveSnapshot(QImage image);
|
static QString saveSnapshot(QImage image);
|
||||||
static QTemporaryFile* saveTempSnapshot(QImage image);
|
static QTemporaryFile* saveTempSnapshot(QImage image);
|
||||||
|
@ -40,6 +43,10 @@ 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(""));
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
Q_INVOKABLE QString getSnapshotsLocation();
|
||||||
|
Q_INVOKABLE void setSnapshotsLocation(const QString& location);
|
||||||
private:
|
private:
|
||||||
static QFile* savedFileForSnapshot(QImage & image, bool isTemporary);
|
static QFile* savedFileForSnapshot(QImage & image, bool isTemporary);
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#include "ui/AvatarInputs.h"
|
#include "ui/AvatarInputs.h"
|
||||||
#include "avatar/AvatarManager.h"
|
#include "avatar/AvatarManager.h"
|
||||||
#include "scripting/GlobalServicesScriptingInterface.h"
|
#include "scripting/GlobalServicesScriptingInterface.h"
|
||||||
|
#include "ui/Snapshot.h"
|
||||||
|
|
||||||
static const float DPI = 30.47f;
|
static const float DPI = 30.47f;
|
||||||
static const float INCHES_TO_METERS = 1.0f / 39.3701f;
|
static const float INCHES_TO_METERS = 1.0f / 39.3701f;
|
||||||
|
@ -177,6 +178,7 @@ void Web3DOverlay::loadSourceURL() {
|
||||||
_webSurface->getRootContext()->setContextProperty("Quat", new Quat());
|
_webSurface->getRootContext()->setContextProperty("Quat", new Quat());
|
||||||
_webSurface->getRootContext()->setContextProperty("MyAvatar", DependencyManager::get<AvatarManager>()->getMyAvatar().get());
|
_webSurface->getRootContext()->setContextProperty("MyAvatar", DependencyManager::get<AvatarManager>()->getMyAvatar().get());
|
||||||
_webSurface->getRootContext()->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
_webSurface->getRootContext()->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
||||||
|
_webSurface->getRootContext()->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
|
||||||
|
|
||||||
if (_webSurface->getRootItem() && _webSurface->getRootItem()->objectName() == "tabletRoot") {
|
if (_webSurface->getRootItem() && _webSurface->getRootItem()->objectName() == "tabletRoot") {
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
// Distributed under the Apache License, Version 2.0
|
// Distributed under the Apache License, Version 2.0
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
/* globals Tablet, Script, HMD, Settings, DialogsManager, Menu, Reticle, OverlayWebWindow, Desktop, Account, MyAvatar */
|
/* globals Tablet, Script, HMD, Settings, DialogsManager, Menu, Reticle, OverlayWebWindow, Desktop, Account, MyAvatar, Snapshot */
|
||||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||||
|
|
||||||
(function() { // BEGIN LOCAL_SCOPE
|
(function() { // BEGIN LOCAL_SCOPE
|
||||||
|
@ -116,7 +116,7 @@ function onMessage(message) {
|
||||||
action: "captureSettings",
|
action: "captureSettings",
|
||||||
setting: Settings.getValue("alsoTakeAnimatedSnapshot", true)
|
setting: Settings.getValue("alsoTakeAnimatedSnapshot", true)
|
||||||
}));
|
}));
|
||||||
if (Settings.getValue("snapshotsLocation", "") !== "") {
|
if (Snapshot.getSnapshotsLocation() !== "") {
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
tablet.emitScriptEvent(JSON.stringify({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "showPreviousImages",
|
action: "showPreviousImages",
|
||||||
|
@ -141,7 +141,7 @@ function onMessage(message) {
|
||||||
var snapshotPath = Window.browseDir("Choose Snapshots Directory", "", "");
|
var snapshotPath = Window.browseDir("Choose Snapshots Directory", "", "");
|
||||||
|
|
||||||
if (snapshotPath) { // not cancelled
|
if (snapshotPath) { // not cancelled
|
||||||
Settings.setValue("snapshotsLocation", snapshotPath);
|
Snapshot.setSnapshotsLocation(snapshotPath);
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
tablet.emitScriptEvent(JSON.stringify({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "snapshotLocationChosen"
|
action: "snapshotLocationChosen"
|
||||||
|
|
Loading…
Reference in a new issue