From 5d7f2b5907af3cd2e1150f6e9af20e6a19a2796e Mon Sep 17 00:00:00 2001 From: syl Date: Thu, 9 Sep 2021 17:47:44 +0200 Subject: [PATCH 01/10] feat(dashboard): Add global WebEngineView to the Dashboard --- atomic_defi_design/qml/Screens/Dashboard.qml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/atomic_defi_design/qml/Screens/Dashboard.qml b/atomic_defi_design/qml/Screens/Dashboard.qml index 4a052936a3..04e60d1b71 100644 --- a/atomic_defi_design/qml/Screens/Dashboard.qml +++ b/atomic_defi_design/qml/Screens/Dashboard.qml @@ -3,6 +3,7 @@ import QtQuick.Layouts 1.15 import QtQuick.Controls 2.15 import QtGraphicalEffects 1.0 +import QtWebEngine 1.10 import "../Components" import "../Constants" import App 1.0 @@ -22,6 +23,8 @@ as SettingsPage Item { id: dashboard + property alias webEngineView: webEngineView + readonly property int idx_dashboard_portfolio: 0 readonly property int idx_dashboard_wallet: 1 readonly property int idx_dashboard_exchange: 2 @@ -194,6 +197,11 @@ Item { } } + WebEngineView + { + id: webEngineView + } + DefaultLoader { id: loader From b9ab699866d11c861636b42f641a1f866a956e3b Mon Sep 17 00:00:00 2001 From: syl Date: Thu, 9 Sep 2021 17:48:04 +0200 Subject: [PATCH 02/10] feat(style): Screens/Dashboard.qml --- atomic_defi_design/qml/Screens/Dashboard.qml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/atomic_defi_design/qml/Screens/Dashboard.qml b/atomic_defi_design/qml/Screens/Dashboard.qml index 04e60d1b71..94266ddfdc 100644 --- a/atomic_defi_design/qml/Screens/Dashboard.qml +++ b/atomic_defi_design/qml/Screens/Dashboard.qml @@ -1,13 +1,12 @@ import QtQuick 2.15 import QtQuick.Layouts 1.15 -import QtQuick.Controls 2.15 - +import QtQuick.Controls 2.1 import QtGraphicalEffects 1.0 import QtWebEngine 1.10 + import "../Components" import "../Constants" import App 1.0 - import "../Dashboard" import "../Portfolio" import "../Wallet" @@ -16,8 +15,7 @@ import "../Settings" import "../Support" import "../Sidebar" import "../Fiat" -import "../Settings" -as SettingsPage +import "../Settings" as SettingsPage Item { @@ -42,8 +40,7 @@ Item { readonly property int idx_exchange_orders: 1 readonly property int idx_exchange_history: 2 - property - var current_ticker + property var current_ticker Layout.fillWidth: true From 5ed6a654578235656bdb442c8e6abb17938cfdfb Mon Sep 17 00:00:00 2001 From: syl Date: Thu, 9 Sep 2021 17:49:07 +0200 Subject: [PATCH 03/10] feat(wallet): Use global WebEngineView from Dashboard for price graph --- atomic_defi_design/qml/Wallet/Main.qml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/atomic_defi_design/qml/Wallet/Main.qml b/atomic_defi_design/qml/Wallet/Main.qml index 70ce986286..47011fca4e 100644 --- a/atomic_defi_design/qml/Wallet/Main.qml +++ b/atomic_defi_design/qml/Wallet/Main.qml @@ -439,6 +439,13 @@ Item { // Price Graph InnerBackground { id: price_graph_bg + + function initGraph() + { + dashboard.webEngineView.parent = price_graph_bg + dashboard.webEngineView.anchors.fill = price_graph_bg + } + Layout.fillWidth: true Layout.fillHeight: true Layout.leftMargin: layout_margin @@ -448,9 +455,12 @@ Item { shadowOff: true color: DexTheme.contentColorTop + Component.onCompleted: initGraph() + Component.onDestruction: dashboard.webEngineView.visible = false + content: Item { property bool ticker_supported: false - readonly property bool is_fetching: chart.loadProgress < 100 + readonly property bool is_fetching: dashboard.webEngineView.loadProgress < 100 readonly property string chartTheme: DexTheme.theme ?? "dark" property color backgroundColor: DexTheme.contentColorTop property var ticker: api_wallet_page.ticker @@ -546,7 +556,7 @@ Item { } RowLayout { - visible: ticker_supported && !chart.visible + visible: ticker_supported && !dashboard.webEngineView.visible anchors.centerIn: parent DefaultBusyIndicator { @@ -566,14 +576,6 @@ Item { text_value: qsTr("There is no chart data for this ticker yet") anchors.centerIn: parent } - - WebEngineView { - id: chart - anchors.fill: parent - anchors.margins: -1 - backgroundColor: DexTheme.contentColorTop - visible: !is_fetching && ticker_supported - } } } From d9c5c41335ec5e059726bcd3c461d213be6c5bf8 Mon Sep 17 00:00:00 2001 From: syl Date: Fri, 10 Sep 2021 10:05:58 +0200 Subject: [PATCH 04/10] feat(wallet): Move some logs as warnings in Wallet/Main.qml --- atomic_defi_design/qml/Wallet/Main.qml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/atomic_defi_design/qml/Wallet/Main.qml b/atomic_defi_design/qml/Wallet/Main.qml index 47011fca4e..23c8365eef 100644 --- a/atomic_defi_design/qml/Wallet/Main.qml +++ b/atomic_defi_design/qml/Wallet/Main.qml @@ -476,37 +476,37 @@ Item { // Normal pair let symbol = General.supported_pairs[pair] if (!symbol) { - console.log("Symbol not found for", pair) + console.warn("Symbol not found for", pair) symbol = General.supported_pairs[pair_reversed] } // Reversed pair if (!symbol) { - console.log("Symbol not found for", pair_reversed) + console.warn("Symbol not found for", pair_reversed) symbol = General.supported_pairs[pair_usd] } // Pair with USD if (!symbol) { - console.log("Symbol not found for", pair_usd) + console.warn("Symbol not found for", pair_usd) symbol = General.supported_pairs[pair_usd_reversed] } // Reversed pair with USD if (!symbol) { - console.log("Symbol not found for", pair_usd_reversed) + console.warn("Symbol not found for", pair_usd_reversed) symbol = General.supported_pairs[pair_busd] } // Pair with BUSD if (!symbol) { - console.log("Symbol not found for", pair_busd) + console.warn("Symbol not found for", pair_busd) symbol = General.supported_pairs[pair_busd_reversed] } // Reversed pair with BUSD if (!symbol) { - console.log("Symbol not found for", pair_busd_reversed) + console.warn("Symbol not found for", pair_busd_reversed) ticker_supported = false return } From da443a039618ba8afacf982778e79a631175b72e Mon Sep 17 00:00:00 2001 From: syl Date: Thu, 9 Sep 2021 18:30:21 +0200 Subject: [PATCH 05/10] feat(trade): Remove WebEngineView from CandleStickChart and use Dashboard's one --- .../qml/Exchange/Trade/CandleStickChart.qml | 13 +++---------- atomic_defi_design/qml/Exchange/Trade/ProView.qml | 12 ++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/atomic_defi_design/qml/Exchange/Trade/CandleStickChart.qml b/atomic_defi_design/qml/Exchange/Trade/CandleStickChart.qml index f9e7e54ea7..5f12598889 100644 --- a/atomic_defi_design/qml/Exchange/Trade/CandleStickChart.qml +++ b/atomic_defi_design/qml/Exchange/Trade/CandleStickChart.qml @@ -25,10 +25,10 @@ DexBox { height: graph_bg.height property bool pair_supported: false - readonly property bool is_fetching: chart.loadProgress < 100 + readonly property bool is_fetching: dashboard.webEngineView.loadProgress < 100 RowLayout { - visible: pair_supported && !chart.visible + visible: pair_supported && !dashboard.webEngineView.visible anchors.centerIn: parent DefaultBusyIndicator { @@ -101,7 +101,7 @@ DexBox { chart_base = atomic_qt_utilities.retrieve_main_ticker(base) chart_rel = atomic_qt_utilities.retrieve_main_ticker(rel) - chart.loadHtml(` + dashboard.webEngineView.loadHtml(` @@ -128,12 +128,5 @@ DexBox { `) } - - WebEngineView { - id: chart - anchors.fill: parent - anchors.margins: -1 - visible: !is_fetching && pair_supported - } } } diff --git a/atomic_defi_design/qml/Exchange/Trade/ProView.qml b/atomic_defi_design/qml/Exchange/Trade/ProView.qml index 2fdd79ffc5..90c2018b74 100644 --- a/atomic_defi_design/qml/Exchange/Trade/ProView.qml +++ b/atomic_defi_design/qml/Exchange/Trade/ProView.qml @@ -171,6 +171,18 @@ ColumnLayout { color: 'transparent' anchors.fill: parent } + + Component.onCompleted: + { + dashboard.webEngineView.parent = chart_view; + dashboard.webEngineView.anchors.fill = chart_view; + dashboard.webEngineView.visible = true; + } + Component.onDestruction: + { + dashboard.webEngineView.visible = false; + dashboard.webEngineView.stop(); + } } } DexTradeBox { From 081c8147b0caca704d8f0ba31be956afd9e06f9a Mon Sep 17 00:00:00 2001 From: syl Date: Thu, 9 Sep 2021 18:31:01 +0200 Subject: [PATCH 06/10] feat(style): Exchange/Trade/ProView.qml --- atomic_defi_design/qml/Exchange/Trade/ProView.qml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/atomic_defi_design/qml/Exchange/Trade/ProView.qml b/atomic_defi_design/qml/Exchange/Trade/ProView.qml index 90c2018b74..4fe7cb1f20 100644 --- a/atomic_defi_design/qml/Exchange/Trade/ProView.qml +++ b/atomic_defi_design/qml/Exchange/Trade/ProView.qml @@ -2,11 +2,10 @@ import QtQuick 2.15 import QtQuick.Layouts 1.15 import QtQuick.Controls 2.15 import QtQuick.Controls.Material 2.15 - import QtGraphicalEffects 1.0 +import Qt.labs.settings 1.0 import Qaterial 1.0 as Qaterial -import Qt.labs.settings 1.0 import AtomicDEX.MarketMode 1.0 import AtomicDEX.TradingError 1.0 @@ -30,7 +29,7 @@ import "BestOrder/" as BestOrder // Orders (orders, history) import "Orders/" as OrdersView -import "./" as Here +import "../../Screens" ColumnLayout { id: form From 8a84a57a56fac7c87577711700ee1bf8db49623d Mon Sep 17 00:00:00 2001 From: syl Date: Fri, 10 Sep 2021 10:01:15 +0200 Subject: [PATCH 07/10] fix(wallet): Undefined reference error of WebEngineView in Wallet/Main.qml --- atomic_defi_design/qml/Wallet/Main.qml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/atomic_defi_design/qml/Wallet/Main.qml b/atomic_defi_design/qml/Wallet/Main.qml index 23c8365eef..72eb853166 100644 --- a/atomic_defi_design/qml/Wallet/Main.qml +++ b/atomic_defi_design/qml/Wallet/Main.qml @@ -456,7 +456,11 @@ Item { color: DexTheme.contentColorTop Component.onCompleted: initGraph() - Component.onDestruction: dashboard.webEngineView.visible = false + Component.onDestruction: + { + dashboard.webEngineView.visible = false; + dashboard.webEngineView.stop(); + } content: Item { property bool ticker_supported: false @@ -515,7 +519,7 @@ Item { console.debug("Wallet: Loading chart for %1".arg(symbol)) - chart.loadHtml(` + dashboard.webEngineView.loadHtml(` From d10d0643fa920372e804c512d58a0775537d0d26 Mon Sep 17 00:00:00 2001 From: syl Date: Fri, 10 Sep 2021 11:13:43 +0200 Subject: [PATCH 08/10] fix(wallet): Dashboard's WebEngineView was not displayed when opening the page --- atomic_defi_design/qml/Wallet/Main.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/atomic_defi_design/qml/Wallet/Main.qml b/atomic_defi_design/qml/Wallet/Main.qml index 72eb853166..26cc28e37a 100644 --- a/atomic_defi_design/qml/Wallet/Main.qml +++ b/atomic_defi_design/qml/Wallet/Main.qml @@ -444,6 +444,7 @@ Item { { dashboard.webEngineView.parent = price_graph_bg dashboard.webEngineView.anchors.fill = price_graph_bg + dashboard.webEngineView.visible = true } Layout.fillWidth: true From e41789c2e9e9c974701a956b1bed7a9aed6a5fd6 Mon Sep 17 00:00:00 2001 From: syl Date: Mon, 13 Sep 2021 13:47:57 +0200 Subject: [PATCH 09/10] fix(style): Missing whitespaces between op in Sidebar/Sidebar.qml --- atomic_defi_design/qml/Sidebar/Sidebar.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atomic_defi_design/qml/Sidebar/Sidebar.qml b/atomic_defi_design/qml/Sidebar/Sidebar.qml index 3f840b5651..801c04bed0 100644 --- a/atomic_defi_design/qml/Sidebar/Sidebar.qml +++ b/atomic_defi_design/qml/Sidebar/Sidebar.qml @@ -12,7 +12,7 @@ import Qaterial 1.0 as Qaterial Item { id: sidebar - property bool expanded: dashboard.current_page===dashboard.idx_dashboard_exchange? false : true + property bool expanded: dashboard.current_page === dashboard.idx_dashboard_exchange ? false : true readonly property alias app_logo: app_logo x: -top_rect.radius From 46a8511fad6ea6514879472f65b686f230ce4a5b Mon Sep 17 00:00:00 2001 From: syl Date: Mon, 13 Sep 2021 14:25:03 +0200 Subject: [PATCH 10/10] feat(dashboard): Allow page switching only when current page is fully loaded --- atomic_defi_design/qml/Dashboard/NotificationsModal.qml | 4 ++-- atomic_defi_design/qml/Portfolio/AssetsList.qml | 2 +- atomic_defi_design/qml/Portfolio/TableDex.qml | 2 +- atomic_defi_design/qml/Screens/Dashboard.qml | 9 +++++++++ atomic_defi_design/qml/Sidebar/SidebarLine.qml | 2 +- atomic_defi_design/qml/Wallet/Wallet.qml | 2 +- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/atomic_defi_design/qml/Dashboard/NotificationsModal.qml b/atomic_defi_design/qml/Dashboard/NotificationsModal.qml index e65b392dc5..f501aea027 100644 --- a/atomic_defi_design/qml/Dashboard/NotificationsModal.qml +++ b/atomic_defi_design/qml/Dashboard/NotificationsModal.qml @@ -62,10 +62,10 @@ DexPopup { break case "open_wallet_page": api_wallet_page.ticker = notification.params.ticker - dashboard.current_page = idx_dashboard_wallet + dashboard.switchPage(idx_dashboard_wallet) break case "open_swaps_page": - dashboard.current_page = idx_dashboard_exchange + dashboard.switchPage(idx_dashboard_exchange) dashboard.loader.onLoadComplete = () => { dashboard.current_component.current_page = dashboard.isSwapDone(notification.params.new_swap_status) ? idx_exchange_history : idx_exchange_orders diff --git a/atomic_defi_design/qml/Portfolio/AssetsList.qml b/atomic_defi_design/qml/Portfolio/AssetsList.qml index 53bd2e8caa..a6c38377b4 100644 --- a/atomic_defi_design/qml/Portfolio/AssetsList.qml +++ b/atomic_defi_design/qml/Portfolio/AssetsList.qml @@ -178,7 +178,7 @@ Dex.DefaultListView else { api_wallet_page.ticker = ticker - dashboard.current_page = idx_dashboard_wallet + dashboard.switchPage(idx_dashboard_wallet) } } onPressAndHold: diff --git a/atomic_defi_design/qml/Portfolio/TableDex.qml b/atomic_defi_design/qml/Portfolio/TableDex.qml index 181510b6f7..d2702c513d 100644 --- a/atomic_defi_design/qml/Portfolio/TableDex.qml +++ b/atomic_defi_design/qml/Portfolio/TableDex.qml @@ -172,7 +172,7 @@ Item { context_menu.popup() else { api_wallet_page.ticker = ticker - dashboard.current_page = idx_dashboard_wallet + dashboard.switchPage(idx_dashboard_wallet) } } onPressAndHold: { diff --git a/atomic_defi_design/qml/Screens/Dashboard.qml b/atomic_defi_design/qml/Screens/Dashboard.qml index 94266ddfdc..5b82735aae 100644 --- a/atomic_defi_design/qml/Screens/Dashboard.qml +++ b/atomic_defi_design/qml/Screens/Dashboard.qml @@ -57,6 +57,7 @@ Item { readonly property alias loader: loader readonly property alias current_component: loader.item property int current_page: idx_dashboard_portfolio + onCurrent_pageChanged: { app.deepPage = current_page * 10 } @@ -68,6 +69,14 @@ Item { return app.current_page === idx_dashboard } + function switchPage(page) + { + if (loader.status === Loader.Ready) + current_page = page + else + console.warn("Tried to switch to page %1 when loader is not ready yet.".arg(page)) + } + property var notifications_list: ([]) diff --git a/atomic_defi_design/qml/Sidebar/SidebarLine.qml b/atomic_defi_design/qml/Sidebar/SidebarLine.qml index 0cb176e8ae..ab8dd7166c 100644 --- a/atomic_defi_design/qml/Sidebar/SidebarLine.qml +++ b/atomic_defi_design/qml/Sidebar/SidebarLine.qml @@ -127,7 +127,7 @@ Item { else if(dashboard_index === idx_dashboard_privacy_mode) { togglePrivacyMode() } - else dashboard.current_page = dashboard_index + else dashboard.switchPage(dashboard_index) } } diff --git a/atomic_defi_design/qml/Wallet/Wallet.qml b/atomic_defi_design/qml/Wallet/Wallet.qml index 363664c0e9..96141edbb8 100644 --- a/atomic_defi_design/qml/Wallet/Wallet.qml +++ b/atomic_defi_design/qml/Wallet/Wallet.qml @@ -22,7 +22,7 @@ RowLayout // Local function onClickedSwap() { - dashboard.current_page = idx_dashboard_exchange + dashboard.switchPage(idx_dashboard_exchange) dashboard.current_ticker = api_wallet_page.ticker API.app.trading_pg.set_pair(true, api_wallet_page.ticker) }