From fb1f352332605d2598275d87a460f4c0fa69b5e0 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 12 Aug 2024 17:02:45 +0800 Subject: [PATCH 1/2] limit decimals on large numbers --- atomic_defi_design/Dex/Constants/General.qml | 9 +++++++++ .../Dex/Exchange/Trade/OrderBook/ListDelegate.qml | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/atomic_defi_design/Dex/Constants/General.qml b/atomic_defi_design/Dex/Constants/General.qml index 8f626296f7..7cfea9c828 100644 --- a/atomic_defi_design/Dex/Constants/General.qml +++ b/atomic_defi_design/Dex/Constants/General.qml @@ -434,6 +434,15 @@ QtObject { return feetype + " " + amount + " " + ticker + " (" + fiat_text + ")" } + function reducedBignum(text, decimals=8, max_length=12) { + let val = new BigNumber(text).toFixed(decimals) + if (val.length > max_length) + { + return val.substring(0, max_length) + "..." + } + return val + } + function getSimpleFromPlaceholder(selectedTicker, selectedOrder, sell_ticker_balance) { if (sell_ticker_balance == 0) { diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml index 03819d17fe..25eca66c04 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml @@ -185,7 +185,7 @@ Item Layout.fillHeight: true Layout.minimumWidth: 90 Layout.alignment: Qt.AlignVCenter - text: { new BigNumber(price).toFixed(8) } + text: General.reducedBignum(price) font.family: DexTypo.fontFamily font.pixelSize: 12 color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor @@ -200,7 +200,7 @@ Item Layout.fillHeight: true Layout.minimumWidth: 90 Layout.alignment: Qt.AlignVCenter - text: { new BigNumber(base_max_volume).toFixed(6) } + text: General.reducedBignum(base_max_volume) font.family: DexTypo.fontFamily font.pixelSize: 12 horizontalAlignment: Text.AlignRight @@ -219,7 +219,7 @@ Item Layout.alignment: Qt.AlignVCenter font.family: DexTypo.fontFamily font.pixelSize: 12 - text: { new BigNumber(total).toFixed(6) } + text: General.reducedBignum(total) horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter wrapMode: Text.NoWrap From f9e8dada71e78ce0431b40f43d27d781a0dc13ce Mon Sep 17 00:00:00 2001 From: smk762 Date: Fri, 23 Aug 2024 12:23:35 +0800 Subject: [PATCH 2/2] rm dots, 6dp for middle and right cols --- atomic_defi_design/Dex/Constants/General.qml | 2 +- .../Exchange/Trade/OrderBook/ListDelegate.qml | 28 +++++++++---------- .../Dex/Exchange/Trade/OrderBook/Vertical.qml | 4 +-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/atomic_defi_design/Dex/Constants/General.qml b/atomic_defi_design/Dex/Constants/General.qml index d54a8dbd7d..34c89b8fcf 100644 --- a/atomic_defi_design/Dex/Constants/General.qml +++ b/atomic_defi_design/Dex/Constants/General.qml @@ -446,7 +446,7 @@ QtObject { let val = new BigNumber(text).toFixed(decimals) if (val.length > max_length) { - return val.substring(0, max_length) + "..." + return val.substring(0, max_length) } return val } diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml index b812cb792f..43b16d0c7b 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml @@ -21,11 +21,11 @@ Item DefaultTooltip { visible: mouse_area.containsMouse && (tooltip_text.text_value != "") - width: 300 + width: 340 contentItem: RowLayout { - width: 290 + width: 330 Qaterial.ColorIcon { @@ -175,12 +175,12 @@ Item // Dot on the left side of the row to indicate own order Rectangle { - Layout.leftMargin: 6 + Layout.leftMargin: 4 Layout.alignment: Qt.AlignVCenter opacity: is_mine ? 1 : 0 - width: 6 - height: 6 - radius: 3 + width: 4 + height: 4 + radius: 2 color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor } @@ -188,9 +188,9 @@ Item Dex.ElidableText { Layout.fillHeight: true - Layout.minimumWidth: 90 + Layout.minimumWidth: 100 Layout.alignment: Qt.AlignVCenter - text: General.reducedBignum(price) + text: General.reducedBignum(price, 8) font.family: DexTypo.fontFamily font.pixelSize: 12 color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor @@ -203,9 +203,9 @@ Item Dex.ElidableText { Layout.fillHeight: true - Layout.minimumWidth: 90 + Layout.minimumWidth: 100 Layout.alignment: Qt.AlignVCenter - text: General.reducedBignum(base_max_volume) + text: General.reducedBignum(base_max_volume, 6) font.family: DexTypo.fontFamily font.pixelSize: 12 horizontalAlignment: Text.AlignRight @@ -219,12 +219,12 @@ Item { id: total_text Layout.fillHeight: true - Layout.minimumWidth: 90 + Layout.minimumWidth: 100 Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter font.family: DexTypo.fontFamily font.pixelSize: 12 - text: General.reducedBignum(total) + text: General.reducedBignum(total, 6) horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter wrapMode: Text.NoWrap @@ -236,7 +236,7 @@ Item { id: cancel_flat_btn Layout.fillHeight: true - width: 30 + width: 20 Layout.alignment: Qt.AlignVCenter MouseArea @@ -261,7 +261,7 @@ Item Qaterial.ColorIcon { anchors.centerIn: parent - iconSize: 16 + iconSize: 14 color: Dex.CurrentTheme.warningColor source: Qaterial.Icons.close visible: is_mine diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml index a32347e739..0c8918e6fc 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml @@ -16,8 +16,8 @@ Widget readonly property string pair_volume_24hr: API.app.trading_pg.pair_volume_24hr readonly property string pair: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + "/" + atomic_qt_utilities.retrieve_main_ticker(right_ticker) - margins: 10 - spacing: 10 + margins: 8 + spacing: 8 collapsable: false Header