From 209de29b2afdc0590a11fd67bd6ce3fc35cd0775 Mon Sep 17 00:00:00 2001
From: Vladyslav Stelmakhovskyi <vladyslav.stelmakhovski@volvocars.com>
Date: Wed, 29 Mar 2017 17:36:05 +0200
Subject: [PATCH] Intial commit. Basically works. Need some testing

---
 .../dialogs/TabletConnectionFailureDialog.qml | 32 +++++++++++++++++++
 interface/src/ui/DialogsManager.cpp           | 21 ++++++++++--
 2 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 interface/resources/qml/dialogs/TabletConnectionFailureDialog.qml

diff --git a/interface/resources/qml/dialogs/TabletConnectionFailureDialog.qml b/interface/resources/qml/dialogs/TabletConnectionFailureDialog.qml
new file mode 100644
index 0000000000..6d2ff36550
--- /dev/null
+++ b/interface/resources/qml/dialogs/TabletConnectionFailureDialog.qml
@@ -0,0 +1,32 @@
+//
+//  TabletConnectionFailureDialog.qml
+//
+//  Created by Vlad Stelmahovsky on 29 Mar 2017
+//  Copyright 2017 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
+//
+
+import Hifi 1.0
+import QtQuick 2.5
+import QtQuick.Controls 1.4
+import QtQuick.Dialogs 1.2 as OriginalDialogs
+
+Item {
+    Component.onCompleted: {
+        var object = tabletRoot.messageBox({
+                                            icon: OriginalDialogs.StandardIcon.Warning,
+                                            buttons: OriginalDialogs.StandardButton.Ok,
+                                            defaultButton: OriginalDialogs.StandardButton.NoButton,
+                                            title: "No Connection",
+                                            text: "Unable to connect to this domain. Click the 'GO TO' button on the toolbar to visit another domain."
+                                        });
+        object.selected.connect(function(button) {
+            if (button === OriginalDialogs.StandardButton.Ok) {
+                var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
+                tablet.gotoHomeScreen()
+            }
+        });
+    }
+}
diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp
index 0f7acc7c64..402e27e256 100644
--- a/interface/src/ui/DialogsManager.cpp
+++ b/interface/src/ui/DialogsManager.cpp
@@ -60,10 +60,25 @@ void DialogsManager::showFeed() {
 }
 
 void DialogsManager::setDomainConnectionFailureVisibility(bool visible) {
-    if (visible) {
-        ConnectionFailureDialog::show();
+    qDebug() << "DialogsManager::setDomainConnectionFailureVisibility: visible" << visible;
+    auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
+    auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
+
+    if (tablet->getToolbarMode()) {
+        if (visible) {
+            ConnectionFailureDialog::show();
+        } else {
+            ConnectionFailureDialog::hide();
+        }
     } else {
-        ConnectionFailureDialog::hide();
+        static const QUrl url("../../dialogs/TabletConnectionFailureDialog.qml");
+        auto hmd = DependencyManager::get<HMDScriptingInterface>();
+        if (visible) {
+            tablet->initialScreen(url);
+            if (!hmd->getShouldShowTablet()) {
+                hmd->openTablet();
+            }
+        }
     }
 }