mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 00:03:16 +02:00
Initial version of TabletProxy.toolbarMode boolean
Copies all tablet buttons between the tablet and the system toolbar. To test type this in the console: Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode = true;
This commit is contained in:
parent
5e25d073f3
commit
4503923665
5 changed files with 185 additions and 8 deletions
48
interface/resources/icons/tablet-icons/blank.svg
Normal file
48
interface/resources/icons/tablet-icons/blank.svg
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 50 50"
|
||||
style="enable-background:new 0 0 50 50;"
|
||||
xml:space="preserve"
|
||||
id="svg2"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="blank.svg"><metadata
|
||||
id="metadata36"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs34" /><sodipodi:namedview
|
||||
pagecolor="#ff4900"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1149"
|
||||
inkscape:window-height="801"
|
||||
id="namedview32"
|
||||
showgrid="false"
|
||||
inkscape:zoom="4.72"
|
||||
inkscape:cx="25"
|
||||
inkscape:cy="25"
|
||||
inkscape:window-x="1336"
|
||||
inkscape:window-y="519"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg2" /><style
|
||||
type="text/css"
|
||||
id="style4">
|
||||
.st0{fill:#FFFFFF;}
|
||||
</style><g
|
||||
id="Layer_2" /></svg>
|
After Width: | Height: | Size: 1.6 KiB |
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 50 200.1"
|
||||
style="enable-background:new 0 0 50 200.1;"
|
||||
xml:space="preserve"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="empty-toolbar-button.svg"><metadata
|
||||
id="metadata116"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs114" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1379"
|
||||
inkscape:window-height="899"
|
||||
id="namedview112"
|
||||
showgrid="false"
|
||||
inkscape:zoom="4.717641"
|
||||
inkscape:cx="35.224327"
|
||||
inkscape:cy="131.18797"
|
||||
inkscape:window-x="490"
|
||||
inkscape:window-y="254"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="Layer_1" /><style
|
||||
type="text/css"
|
||||
id="style3">
|
||||
.st0{fill:#414042;}
|
||||
.st1{fill:#FFFFFF;}
|
||||
.st2{fill:#1E1E1E;}
|
||||
.st3{fill:#333333;}
|
||||
</style><g
|
||||
id="g6"
|
||||
style="fill:#ffffff;fill-opacity:1"><g
|
||||
id="g8"
|
||||
style="fill:#ffffff;fill-opacity:1"><path
|
||||
style="fill:#ffffff;fill-opacity:1"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path10"
|
||||
d="m 50.1,146.1 c 0,2.2 -1.8,4 -4,4 l -42,0 c -2.2,0 -4,-1.8 -4,-4 l 0,-42 c 0,-2.2 1.8,-4 4,-4 l 42,0 c 2.2,0 4,1.8 4,4 l 0,42 z"
|
||||
class="st0" /></g></g><g
|
||||
id="g12"><g
|
||||
id="g14"><path
|
||||
style="fill:#414042"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path16"
|
||||
d="m 50,196.1 c 0,2.2 -1.8,4 -4,4 l -42,0 c -2.2,0 -4,-1.8 -4,-4 l 0,-42 c 0,-2.2 1.8,-4 4,-4 l 42,0 c 2.2,0 4,1.8 4,4 l 0,42 z"
|
||||
class="st0" /></g></g><g
|
||||
id="g18"><g
|
||||
id="g20"><path
|
||||
style="fill:#ffffff"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path22"
|
||||
d="m 50,46 c 0,2.2 -1.8,4 -4,4 L 4,50 C 1.8,50 0,48.2 0,46 L 0,4 C 0,1.8 1.8,0 4,0 l 42,0 c 2.2,0 4,1.8 4,4 l 0,42 z"
|
||||
class="st1" /></g></g><g
|
||||
id="g24"><path
|
||||
style="fill:#1e1e1e"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path26"
|
||||
d="m 50,96.1 c 0,2.2 -1.8,4 -4,4 l -42,0 c -2.2,0 -4,-1.8 -4,-4 l 0,-42 c 0,-2.2 1.8,-4 4,-4 l 42,0 c 2.2,0 4,1.8 4,4 l 0,42 z"
|
||||
class="st2" /></g></svg>
|
After Width: | Height: | Size: 2.9 KiB |
|
@ -29,6 +29,7 @@ Item {
|
|||
id: image
|
||||
y: -parent.yOffset;
|
||||
width: parent.width
|
||||
source: "../../../icons/tablet-icons/empty-toolbar-button.svg"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,23 @@ StateImage {
|
|||
property int imageOnOut: 0
|
||||
property int imageOnIn: 2
|
||||
|
||||
property string text: ""
|
||||
property string icon: "icons/tablet-icons/blank.svg"
|
||||
|
||||
signal clicked()
|
||||
|
||||
function changeProperty(key, value) {
|
||||
button[key] = value;
|
||||
}
|
||||
|
||||
function urlHelper(src) {
|
||||
if (src.match(/\bhttp/)) {
|
||||
return src;
|
||||
} else {
|
||||
return "../../../" + src;
|
||||
}
|
||||
}
|
||||
|
||||
function updateState() {
|
||||
if (!button.isEntered && !button.isActive) {
|
||||
buttonState = imageOffOut;
|
||||
|
@ -38,7 +49,7 @@ StateImage {
|
|||
running: false
|
||||
onTriggered: button.clicked();
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
hoverEnabled: true
|
||||
|
@ -53,5 +64,28 @@ StateImage {
|
|||
updateState();
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: icon
|
||||
width: 28
|
||||
height: 28
|
||||
anchors.bottom: caption.top
|
||||
anchors.bottomMargin: 0
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
fillMode: Image.Stretch
|
||||
source: urlHelper(button.icon)
|
||||
}
|
||||
|
||||
Text {
|
||||
id: caption
|
||||
color: "#ffffff"
|
||||
text: button.text
|
||||
font.bold: false
|
||||
font.pixelSize: 9
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 5
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -166,6 +166,8 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
|
|||
return;
|
||||
}
|
||||
|
||||
_toolbarMode = toolbarMode;
|
||||
|
||||
if (toolbarMode) {
|
||||
removeButtonsFromHomeScreen();
|
||||
addButtonsToToolbar();
|
||||
|
@ -173,7 +175,6 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
|
|||
removeButtonsFromToolbar();
|
||||
addButtonsToHomeScreen();
|
||||
}
|
||||
_toolbarMode = toolbarMode;
|
||||
}
|
||||
|
||||
static void addButtonProxyToQmlTablet(QQuickItem* qmlTablet, TabletButtonProxy* buttonProxy) {
|
||||
|
@ -373,7 +374,7 @@ void TabletProxy::sendToQml(QVariant msg) {
|
|||
|
||||
void TabletProxy::addButtonsToHomeScreen() {
|
||||
auto tablet = getQmlTablet();
|
||||
if (!tablet) {
|
||||
if (!tablet || _toolbarMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -410,7 +411,11 @@ void TabletProxy::addButtonsToMenuScreen() {
|
|||
}
|
||||
|
||||
void TabletProxy::removeButtonsFromHomeScreen() {
|
||||
auto tablet = getQmlTablet();
|
||||
for (auto& buttonProxy : _tabletButtonProxies) {
|
||||
if (tablet) {
|
||||
QMetaObject::invokeMethod(tablet, "removeButtonProxy", Qt::AutoConnection, Q_ARG(QVariant, buttonProxy->getProperties()));
|
||||
}
|
||||
buttonProxy->setQmlButton(nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -418,12 +423,14 @@ void TabletProxy::removeButtonsFromHomeScreen() {
|
|||
void TabletProxy::addButtonsToToolbar() {
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
QObject* toolbarProxy = tabletScriptingInterface->getSystemToolbarProxy();
|
||||
|
||||
Qt::ConnectionType connectionType = Qt::AutoConnection;
|
||||
if (QThread::currentThread() != toolbarProxy->thread()) {
|
||||
connectionType = Qt::BlockingQueuedConnection;
|
||||
}
|
||||
|
||||
for (auto& buttonProxy : _tabletButtonProxies) {
|
||||
// copy properties from tablet button proxy to toolbar button proxy.
|
||||
Qt::ConnectionType connectionType = Qt::AutoConnection;
|
||||
if (QThread::currentThread() != toolbarProxy->thread()) {
|
||||
connectionType = Qt::BlockingQueuedConnection;
|
||||
}
|
||||
QObject* toolbarButtonProxy = nullptr;
|
||||
bool hasResult = QMetaObject::invokeMethod(toolbarProxy, "addButton", connectionType, Q_RETURN_ARG(QObject*, toolbarButtonProxy), Q_ARG(QVariant, buttonProxy->getProperties()));
|
||||
if (hasResult) {
|
||||
|
@ -435,7 +442,13 @@ void TabletProxy::addButtonsToToolbar() {
|
|||
}
|
||||
|
||||
void TabletProxy::removeButtonsFromToolbar() {
|
||||
//
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
QObject* toolbarProxy = tabletScriptingInterface->getSystemToolbarProxy();
|
||||
for (auto& buttonProxy : _tabletButtonProxies) {
|
||||
// remove button from toolbarProxy
|
||||
QMetaObject::invokeMethod(toolbarProxy, "removeButton", Qt::AutoConnection, Q_ARG(QVariant, buttonProxy->getUuid().toString()));
|
||||
buttonProxy->setToolbarButtonProxy(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
QQuickItem* TabletProxy::getQmlTablet() const {
|
||||
|
@ -483,12 +496,14 @@ QQuickItem* TabletProxy::getQmlMenu() const {
|
|||
//
|
||||
|
||||
const QString UUID_KEY = "uuid";
|
||||
const QString OBJECT_NAME_KEY = "objectName";
|
||||
const QString STABLE_ORDER_KEY = "stableOrder";
|
||||
static int s_stableOrder = 1;
|
||||
|
||||
TabletButtonProxy::TabletButtonProxy(const QVariantMap& properties) : _uuid(QUuid::createUuid()), _stableOrder(++s_stableOrder), _properties(properties) {
|
||||
// this is used to uniquely identify this button.
|
||||
_properties[UUID_KEY] = _uuid;
|
||||
_properties[OBJECT_NAME_KEY] = _uuid.toString();
|
||||
_properties[STABLE_ORDER_KEY] = _stableOrder;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue