mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:58:09 +02:00
Merge pull request #5658 from ctrlaltdavid/20653
Add Desktop object to JavaScript with width and height properties
This commit is contained in:
commit
b19f1e0631
3 changed files with 60 additions and 0 deletions
|
@ -126,6 +126,7 @@
|
||||||
#include "scripting/AccountScriptingInterface.h"
|
#include "scripting/AccountScriptingInterface.h"
|
||||||
#include "scripting/AudioDeviceScriptingInterface.h"
|
#include "scripting/AudioDeviceScriptingInterface.h"
|
||||||
#include "scripting/ClipboardScriptingInterface.h"
|
#include "scripting/ClipboardScriptingInterface.h"
|
||||||
|
#include "scripting/DesktopScriptingInterface.h"
|
||||||
#include "scripting/HMDScriptingInterface.h"
|
#include "scripting/HMDScriptingInterface.h"
|
||||||
#include "scripting/GlobalServicesScriptingInterface.h"
|
#include "scripting/GlobalServicesScriptingInterface.h"
|
||||||
#include "scripting/LocationScriptingInterface.h"
|
#include "scripting/LocationScriptingInterface.h"
|
||||||
|
@ -284,6 +285,7 @@ bool setupEssentials(int& argc, char** argv) {
|
||||||
auto dialogsManager = DependencyManager::set<DialogsManager>();
|
auto dialogsManager = DependencyManager::set<DialogsManager>();
|
||||||
auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>();
|
auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>();
|
||||||
auto resourceCacheSharedItems = DependencyManager::set<ResourceCacheSharedItems>();
|
auto resourceCacheSharedItems = DependencyManager::set<ResourceCacheSharedItems>();
|
||||||
|
auto desktopScriptingInterface = DependencyManager::set<DesktopScriptingInterface>();
|
||||||
auto entityScriptingInterface = DependencyManager::set<EntityScriptingInterface>();
|
auto entityScriptingInterface = DependencyManager::set<EntityScriptingInterface>();
|
||||||
auto windowScriptingInterface = DependencyManager::set<WindowScriptingInterface>();
|
auto windowScriptingInterface = DependencyManager::set<WindowScriptingInterface>();
|
||||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||||
|
@ -3970,6 +3972,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
|
qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
|
||||||
RayToOverlayIntersectionResultFromScriptValue);
|
RayToOverlayIntersectionResultFromScriptValue);
|
||||||
|
|
||||||
|
scriptEngine->registerGlobalObject("Desktop", DependencyManager::get<DesktopScriptingInterface>().data());
|
||||||
|
|
||||||
QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
||||||
scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
|
scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
|
||||||
LocationScriptingInterface::locationSetter, windowValue);
|
LocationScriptingInterface::locationSetter, windowValue);
|
||||||
|
|
27
interface/src/scripting/DesktopScriptingInterface.cpp
Normal file
27
interface/src/scripting/DesktopScriptingInterface.cpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
//
|
||||||
|
// DesktopScriptingInterface.h
|
||||||
|
// interface/src/scripting
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 25 Aug 2015.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "DesktopScriptingInterface.h"
|
||||||
|
|
||||||
|
#include <QWindow>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
int DesktopScriptingInterface::getWidth() {
|
||||||
|
QSize size = Application::getInstance()->getWindow()->windowHandle()->screen()->virtualSize();
|
||||||
|
return size.width();
|
||||||
|
}
|
||||||
|
int DesktopScriptingInterface::getHeight() {
|
||||||
|
QSize size = Application::getInstance()->getWindow()->windowHandle()->screen()->virtualSize();
|
||||||
|
return size.height();
|
||||||
|
}
|
29
interface/src/scripting/DesktopScriptingInterface.h
Normal file
29
interface/src/scripting/DesktopScriptingInterface.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// DesktopScriptingInterface.h
|
||||||
|
// interface/src/scripting
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 25 Aug 2015.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_DesktopScriptingInterface_h
|
||||||
|
#define hifi_DesktopScriptingInterface_h
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
|
||||||
|
class DesktopScriptingInterface : public QObject, public Dependency {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int width READ getWidth) // Physical width of screen(s) including task bars and system menus
|
||||||
|
Q_PROPERTY(int height READ getHeight) // Physical height of screen(s) including task bars and system menus
|
||||||
|
|
||||||
|
public:
|
||||||
|
int getWidth();
|
||||||
|
int getHeight();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_DesktopScriptingInterface_h
|
Loading…
Reference in a new issue