answered
2019-03-10 12:26:45 +0200
I found a solution by using a C++ or Python class. Here are the simplified code snippets:
At first write a simple Python class:
import pyotherside
import os
class SuperAppSwitcher:
def __init__(self):
pass
def activateSuperAppMode(self):
os.system('dconf write /desktop/lipstick-jolla-home/partnerspace/applications \"[\'/usr/share/applications/Volla.desktop\']\"')
def deactivateSuperAppMode(self):
os.system('dconf write /desktop/lipstick-jolla-home/partnerspace/applications \"[\'\']\"')
appmodeswitcher = SuperAppSwitcher()
Then import the required modules in the QML file and add a Python QML component:
import io.thp.pyotherside 1.4
Python {
id: superPython
Component.onCompleted: {
console.log("Will import super app switcher module")
addImportPath(Qt.resolvedUrl('.'));
importModule('superappswitcher', function () {});
}
function activateSuperMode() {
console.log("Will activate super mode")
call('superappswitcher.appmodeswitcher.activateSuperAppMode', function() {})
}
function deactivateSuperMode() {
console.log("Will deactivate super mode")
call('superappswitcher.appmodeswitcher.deactivateSuperAppMode', function() {})
}
}
Finally call the method somerwhere in your QML code:
MenuItem {
text: qsTr("Activate super mode")
onClicked: {
superPython.activateSuperMode()
}
}
Deactivating would be similar.