Commit 835e96c4 authored by Michael Bonani's avatar Michael Bonani
Browse files

Merge branch 'master' of https://github.com/mobsya/aseba

parents 5ed1bc34 9ab73f25
......@@ -36,8 +36,8 @@ int main(int argc, char* argv[]) {
Q_INIT_RESOURCE(asebaqtabout);
Q_INIT_RESOURCE(asebastudio);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
mobsya::MobsyaApplication app(argc, argv);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// Information used by QSettings with default constructor
......
......@@ -36,8 +36,8 @@ int main(int argc, char* argv[]) {
Q_INIT_RESOURCE(asebaqtabout);
Q_INIT_RESOURCE(asebastudio);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
mobsya::MobsyaApplication app(argc, argv);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// Information used by QSettings with default constructor
QCoreApplication::setOrganizationName(ASEBA_ORGANIZATION_NAME);
......
......@@ -21,6 +21,17 @@ namespace mobsya {
Launcher::Launcher(ThymioDeviceManagerClient* client, QObject* parent) : QObject(parent), m_client(client) {
connect(m_client, &ThymioDeviceManagerClient::zeroconfBrowserStatusChanged, this, &Launcher::zeroconfStatusChanged);
useLocalBrowser = false;
// On mac we use the native web view since chromium is not app-store compatible.
// But on versions prior to High Sierra, the WebKit version shipped with
// the OS cannot handle webassembly, which we require to run all of our web apps
// So, instead, defer to the system browser - which is more likely to work
// because the version of safari shipped with an up-to-date Sierra is more current
// than the system's webkit
#ifdef Q_OS_OSX
useLocalBrowser = true;
#endif
}
......@@ -157,16 +168,9 @@ bool Launcher::openUrl(const QUrl& url) {
qDebug() << url;
// On mac we use the native web view since chromium is not app-store compatible.
// But on versions prior to High Sierra, the WebKit version shipped with
// the OS cannot handle webassembly, which we require to run all of our web apps
// So, instead, defer to the system browser - which is more likely to work
// because the version of safari shipped with an up-to-date Sierra is more current
// than the system's webkit
/*#ifdef Q_OS_OSX
return openUrlWithParameters(url);
#endif*/
if ( useLocalBrowser ){
return openUrlWithParameters(url);
}
#ifdef Q_OS_IOS
OpenUrlInNativeWebView(url);
return true;
......@@ -178,6 +182,8 @@ bool Launcher::openUrl(const QUrl& url) {
QUrl source("qrc:/qml/webview_native.qml");
#endif
auto e = new QQmlApplicationEngine(qobject_cast<QObject*>(this));
disconnect(e, &QQmlApplicationEngine::quit, nullptr, nullptr);
......@@ -194,6 +200,14 @@ bool Launcher::openUrl(const QUrl& url) {
return true;
}
void Launcher::setUseLocalBrowser(bool checked){
useLocalBrowser = checked;
}
bool Launcher::getUseLocalBrowser(){
return useLocalBrowser;
}
QString Launcher::getDownloadPath(const QUrl& url) {
QFileDialog d;
const auto name = url.fileName();
......
......@@ -23,6 +23,8 @@ public:
Q_INVOKABLE bool platformIsIos() const;
Q_INVOKABLE bool platformIsLinux() const;
Q_INVOKABLE bool platformHasSerialPorts() const;
Q_INVOKABLE void setUseLocalBrowser(bool checked);
Q_INVOKABLE bool getUseLocalBrowser();
#ifdef Q_OS_OSX
......@@ -60,6 +62,7 @@ private:
mobsya::ThymioDeviceManagerClient* m_client;
QStringList applicationsSearchPaths() const;
QStringList webappsFolderSearchPaths() const;
bool useLocalBrowser;
};
......
import QtQuick.Controls 2.3
import QtQuick 2.11
Rectangle {
color: "#535353"
id:pane
width: 350
width: getBackPanelWidth()
property ListModel entries: ListModel {}
function getBackPanelWidth(){
return 350
}
function thymio2PairingWizard(valiseMode) {
var component = Qt.createComponent("qrc:/qml/wirelessconfigurator/WirelessWizardWarningDialog.qml");
var dialog = component.createObject(launcher);
......@@ -46,7 +52,7 @@ Rectangle {
}
function anchorToParent() {
x = launcher.width - (visible ? 350 : 0)
x = launcher.width - (visible ? getBackPanelWidth() : 0)
}
Component.onCompleted: {
......@@ -62,6 +68,7 @@ Rectangle {
}
Item {
id: settings_wrapper
anchors.fill: parent
anchors.margins: 10
Item {
......@@ -91,16 +98,20 @@ Rectangle {
}
ListView {
id: settings_list_view
anchors.topMargin: 20
orientation: ListView.Vertical
anchors.top: top.bottom
anchors.bottom: parent.bottom
anchors.right: parent.right
width: 350
anchors.left: parent.left
anchors.bottom: parent.bottom
width: getBackPanelWidth()
model: entries
delegate: Item {
height: 30
width: 350
width: getBackPanelWidth()
anchors.right:parent.right
anchors.left:parent.left
Text {
anchors.right: parent.right
width: contentWidth
......@@ -117,6 +128,55 @@ Rectangle {
}
}
}
footer: Item {
id: local_browser_switch
visible: !Utils.platformIsLinux()
height: 30
width: getBackPanelWidth()
anchors.right:parent.right
anchors.left:parent.left
anchors.bottom: parent.bottom
anchors.leftMargin: 10
CheckBox {
id: local_browser_checkbox
text: qsTr("Use your system default browser")
anchors.right: local_browser_switch.right
onClicked: {
Utils.setUseLocalBrowser(checked )
}
checked: Utils.getUseLocalBrowser()
indicator: Rectangle {
implicitWidth: 18
implicitHeight: 18
y: parent.height / 2 - height / 2
radius: 3
anchors.right: local_browser_checkbox_text.left
border.color: local_browser_checkbox.down ? "#276fa5" : "#389EEC"
Rectangle {
width: 10
height: 10
x: 4
y: 4
radius: 2
color: local_browser_checkbox.down ? "#276fa5" : "#389EEC"
visible: local_browser_checkbox.checked
}
}
contentItem: Text {
id: local_browser_checkbox_text
text: local_browser_checkbox.text
width: contentWidth
font: local_browser_checkbox.font
anchors.right: parent.right
opacity: enabled ? 1.0 : 0.3
color: local_browser_checkbox.down ? "#ededed" : "#fff"
verticalAlignment: Text.AlignVCenter
leftPadding: 10
horizontalAlignment: Text.AlignRight
}
}
}
}
PropertyAnimation {
......@@ -124,7 +184,7 @@ Rectangle {
property: "x"
target: pane
from: launcher.width
to: launcher.width - 350
to: launcher.width - getBackPanelWidth()
duration: 200
easing.type: Easing.InOutQuad
}
......@@ -141,3 +201,10 @@ Rectangle {
anchors.fill: parent
}
}
......@@ -118,14 +118,7 @@ Item {
onDoubleClicked: {
if(!selectable)
return
const selectedAppLauncher = launcher.selectedAppLauncher;
if(!selectedAppLauncher) {
console.error("No launch function")
}
else if(!selectedAppLauncher(device)) {
console.error("could not launch app with device %2".arg(device))
}
updateSelectable()
selection_view.launchSelectedAppWithSelectedDevice()
}
onPressAndHold: {
......
......@@ -14,20 +14,62 @@ Item {
|| device.type === ThymioNode.SimulatedThymio2
}
/* ****************************
* Given access to the local current view, the function retrieves the one or several devices selected by the user. If the selected app supports watch functionalities and the device is Busy, is considered to be Ready
* return: boolean
* true if
* the device is ready and fully binded
* false otherwise
* 2do: add group management - add non thymio devices support
**************************** */
function isSelectedDeviceReady() {
var the_device = selection_view.selectedDevice
if (the_device == null)
return false
if( launcher.selectedApp.supportsWatchMode && the_device.status === ThymioNode.Busy )
return true
if(the_device.status === ThymioNode.Available || the_device.status === ThymioNode.Ready )
return true
return false
}
function launchSelectedAppWithSelectedDevice() {
const device = selection_view.selectedDevice
const selectedAppLauncher = launcher.selectedAppLauncher;
if(!selectedAppLauncher) {
console.error("No launch function")
return
}
else if(!selectedAppLauncher(device)) {
console.error("could not launch %1 with device %2".arg(selectedAppLauncher.name).arg(device))
if(launcher.selectedApp.appId == "studio" ){
if( isSelectedDeviceReady())
if(!selectedAppLauncher(device))
console.error("could not launch %1 with device %2".arg(selectedAppLauncher.name).arg(device))
}
else{
if(!selectedAppLauncher(device))
console.error("could not launch %1 with device %2".arg(selectedAppLauncher.name).arg(device))
}
if(!(device.status === ThymioNode.Available || selectedAppLauncher.supportsWatchMode)
&& (!device.isInGroup || selectedAppLauncher.supportsGroups)
&& (isThymio(device) || selectedAppLauncher.supportsNonThymioDevices))
device_view.selectedDevice = null
}
/* ****************************
* The function set the content for the id:button button depending on if the launched app supports watch functionality - in this case and if is there a watchable device available the string would differs
* return: translatable string
* "Watch with APPNAME" if we support watchable and the device is ready as defined in isSelectedDeviceReady()
* "Program with APPNAME" otherwise
******************************* */
function launchButtonText(){
if(launcher.selectedApp.supportsWatchMode && selection_view.selectedDevice
&& selection_view.selectedDevice.status === ThymioNode.Busy){
return qsTr("Watch with %1").arg(launcher.selectedApp.name)
}
return qsTr("Program with %1").arg(launcher.selectedApp.name)
}
Rectangle {
id: app_titlebar
......@@ -217,37 +259,41 @@ Item {
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
}
}
}
Rectangle {
id:button
anchors.horizontalCenter: parent.horizontalCenter
height: 40;
width : 220;
height: 40
width : 250
radius: 20
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.topMargin: Style.window_margin
anchors.bottomMargin: 30
color: mouse_area.containsMouse ? "#57c6ff" : "#0a9eeb"
opacity: isSelectedDeviceReady() ? 1.0 : 0.3
Text {
font.family: "Roboto Bold"
font.pointSize: 12
color : "white"
anchors.centerIn: parent
text : qsTr("Launch %1").arg(launcher.selectedApp.name)
text : launchButtonText()
}
MouseArea {
enabled: !!(launcher.selectedApp && selection_view.selectedDevice)
enabled: isSelectedDeviceReady()
anchors.fill: parent
hoverEnabled: true
id: mouse_area
cursorShape: Qt.PointingHandCursor
cursorShape: isSelectedDeviceReady() ? Qt.PointingHandCursor : Qt.ForbiddenCursor
onClicked: launchSelectedAppWithSelectedDevice()
}
anchors.bottomMargin: 30
}
Item {
id:grid_container
anchors.left: parent.left
......@@ -308,4 +354,4 @@ Item {
}
}
}
}
}
\ No newline at end of file
......@@ -105,8 +105,8 @@ struct RobotType {
int main(int argc, char* argv[]) {
Q_INIT_RESOURCE(asebaqtabout);
QApplication app(argc, argv);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("mobsya");
QCoreApplication::setOrganizationDomain(ASEBA_ORGANIZATION_DOMAIN);
app.setApplicationName("Playground");
......
......@@ -230,7 +230,61 @@ jobs:
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'ThymioSuite.dmg'
artifactName: 'ThymioSuite13.dmg'
- job: BuildOnOsX2
pool:
vmImage: 'macOS-10.14'
steps:
- task: NodeTool@0
inputs:
versionSpec: '9.x'
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'Mobsya.p12'
certPwd: $(mobsya-mac-p12)
- script: |
curl -sL $(blockly_url) | tar xzf - -C .
curl -sL $(scratch_url) | tar xzf - -C .
displayName: 'Extract scratch and blockly'
- script: |
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/224d82c09d0bbeda99b4ee9b5ccdf56773e5d513/Formula/qt.rb
brew switch qt 5.13.2
displayName: 'Forcing Qt version to 5.13.2'
- script: |
brew update
brew bundle
displayName: 'Install dependencies with HomeBrew'
- script: |
git submodule update --init --recursive
displayName: 'Clone submodules'
- script: |
sudo xcode-select -s /Applications/Xcode_10.1.app/Contents/Developer
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:$(brew --prefix qt)"
(mkdir build && cd build && cmake .. -GNinja -DBoost_DEBUG=ON -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF && ninja)
displayName: 'Build with cmake'
- script: |
osx/createbundle.sh $(Build.ArtifactStagingDirectory)/ThymioSuite.dmg build/bin '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
displayName: 'Signing and create dmg'
condition: ne(variables['Build.Reason'], 'PullRequest')
- script: |
osx/createbundle.sh $(Build.ArtifactStagingDirectory)/ThymioSuite.dmg build/bin
displayName: 'Create Unsigned DMG'
condition: eq(variables['Build.Reason'], 'PullRequest')
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'ThymioSuite14.dmg'
- job: BuildForIOs
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment