Skip to content

Commit 85e69fd

Browse files
committed
Merge branch 'dev' into add/order-info
2 parents af650fd + 8dbad10 commit 85e69fd

File tree

10 files changed

+242
-75
lines changed

10 files changed

+242
-75
lines changed

atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml

+2-8
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,11 @@ import "../../../Components"
1010
import "../../Trade"
1111
import "../../ProView"
1212

13-
Widget
13+
ColumnLayout
1414
{
15-
width: 450
15+
Layout.preferredWidth: 450
1616
property alias currentIndex: tabView.currentIndex
1717

18-
title: qsTr("Trading Information")
19-
20-
background: null
21-
margins: 0
22-
23-
2418
Qaterial.LatoTabBar
2519
{
2620
id: tabView
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import QtQuick 2.15
2+
import QtQuick.Layouts 1.15
3+
import QtQuick.Controls 2.15
4+
5+
import Qaterial 1.0 as Qaterial
6+
7+
import Dex.Themes 1.0 as Dex
8+
import "../../Components"
9+
import "../../Constants"
10+
11+
// OrderBook / Component import
12+
import "OrderBook/" as OrderBook
13+
14+
// Best Order
15+
import "BestOrder/" as BestOrder
16+
17+
18+
ColumnLayout
19+
{
20+
Layout.minimumWidth: 350
21+
Layout.fillWidth: true
22+
Layout.fillHeight: true
23+
Layout.alignment: Qt.AlignTop
24+
property alias currentIndex: marketTabView.currentIndex
25+
26+
Qaterial.LatoTabBar
27+
{
28+
id: marketTabView
29+
property int orderbook: 0
30+
property int best_orders: 1
31+
32+
background: null
33+
Layout.leftMargin: 6
34+
35+
Qaterial.LatoTabButton
36+
{
37+
text: qsTr("Orderbook")
38+
font.pixelSize: 14
39+
textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2
40+
textSecondaryColor: Dex.CurrentTheme.foregroundColor2
41+
indicatorColor: Dex.CurrentTheme.foregroundColor
42+
}
43+
Qaterial.LatoTabButton
44+
{
45+
text: qsTr("Best Orders")
46+
font.pixelSize: 14
47+
textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2
48+
textSecondaryColor: Dex.CurrentTheme.foregroundColor2
49+
indicatorColor: Dex.CurrentTheme.foregroundColor
50+
}
51+
}
52+
53+
Rectangle
54+
{
55+
Layout.fillHeight: true
56+
color: Dex.CurrentTheme.floatingBackgroundColor
57+
radius: 10
58+
Layout.preferredWidth: 350
59+
60+
Qaterial.SwipeView
61+
{
62+
id: marketSwipeView
63+
clip: true
64+
interactive: false
65+
currentIndex: marketTabView.currentIndex
66+
anchors.fill: parent
67+
68+
onCurrentIndexChanged:
69+
{
70+
marketSwipeView.currentItem.update();
71+
}
72+
73+
OrderBook.Vertical
74+
{
75+
id: orderBook
76+
Layout.fillHeight: true
77+
Layout.fillWidth: true
78+
}
79+
80+
// Best Orders
81+
BestOrder.List
82+
{
83+
id: bestOrders
84+
Layout.fillHeight: true
85+
Layout.fillWidth: true
86+
}
87+
}
88+
}
89+
}

atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Dex.Themes 1.0 as Dex
1212
Widget
1313
{
1414
title: qsTr("Order Book")
15+
readonly property string pair_trades_24hr: API.app.trading_pg.pair_trades_24hr
1516
readonly property string pair_volume_24hr: API.app.trading_pg.pair_volume_24hr
1617
readonly property string pair: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + "/" + atomic_qt_utilities.retrieve_main_ticker(right_ticker)
1718

@@ -61,7 +62,7 @@ Widget
6162
Layout.bottomMargin: 2
6263
Layout.alignment: Qt.AlignHCenter
6364
color: Dex.CurrentTheme.foregroundColor2
64-
text_value: pair + qsTr(" traded 24hrs: %1").arg("<b>" + General.convertUsd(pair_volume_24hr) + "</b>")
65+
text_value: pair + qsTr(" 24hrs | %1 | %2 trades").arg(General.convertUsd(pair_volume_24hr)).arg(pair_trades_24hr)
6566
font.pixelSize: Style.textSizeSmall1
6667
}
6768
}

atomic_defi_design/Dex/Exchange/Trade/ProView.qml

+6-39
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ RowLayout
4242

4343
property alias tickerSelectors: selectors
4444
property alias trInfo: tradingInfo
45-
property alias orderBook: orderBook
46-
property alias bestOrders: bestOrders
45+
property alias marketsOrderBook: marketsOrderBook
4746
property alias placeOrderForm: placeOrderForm
4847

4948
function selectOrder(
@@ -112,20 +111,15 @@ RowLayout
112111
ColumnLayout
113112
{
114113
Layout.alignment: Qt.AlignTop
115-
116114
Layout.minimumWidth: selectors.visible || tradingInfo.visible ? 450 : -1
117115
Layout.maximumWidth: (!orderBook.visible && !bestOrders.visible) || (!placeOrderForm.visible) ? -1 : 450
118-
Layout.fillWidth: true
119-
120116
Layout.fillHeight: true
121-
122117
spacing: 10
123118

124119
// Ticker selectors.
125120
TickerSelectors
126121
{
127122
id: selectors
128-
129123
Layout.fillWidth: true
130124
Layout.preferredHeight: 70
131125
}
@@ -134,47 +128,20 @@ RowLayout
134128
TradingInfo.Main
135129
{
136130
id: tradingInfo
137-
138-
Layout.fillWidth: true
131+
Layout.maximumWidth: 450
139132
Layout.fillHeight: true
140-
141-
resizable: false
142133
}
143134
}
144135

145-
WidgetContainer
136+
// Best Orders & Order Book
137+
Market
146138
{
147-
property real _orderBookHeightRatio: 0.65
148-
property real _bestOrdersHeightRatio: 0.35
149-
150-
Layout.minimumWidth: orderBook.visible || bestOrders.visible ? 350 : -1
139+
id: marketsOrderBook
140+
Layout.maximumWidth: 350
151141
Layout.fillWidth: true
152142
Layout.fillHeight: true
153143
Layout.alignment: Qt.AlignTop
154144
spacing: 4
155-
156-
onHeightChanged:
157-
{
158-
orderBook.height = getHeight(_orderBookHeightRatio);
159-
bestOrders.height = getHeight(_bestOrdersHeightRatio);
160-
}
161-
162-
OrderBook.Vertical
163-
{
164-
id: orderBook
165-
166-
width: parent.width
167-
minHeight: 320
168-
}
169-
170-
// Best Orders
171-
BestOrder.List
172-
{
173-
id: bestOrders
174-
175-
width: parent.width
176-
minHeight: 140
177-
}
178145
}
179146

180147
// Place order form.

atomic_defi_design/Dex/Exchange/Trade/Trade.qml

+1-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,7 @@ Item
172172

173173
proViewTickerSelectors: proView.tickerSelectors
174174
proViewTrInfo: proView.trInfo
175-
proViewOrderBook: proView.orderBook
176-
proViewBestOrders: proView.bestOrders
175+
proViewMarketsOrderBook: proView.marketsOrderBook
177176
proViewPlaceOrderForm: proView.placeOrderForm
178177
}
179178

atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml

+2-7
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ Item
2121
// property var proViewChart
2222
property var proViewTickerSelectors
2323
property var proViewTrInfo
24-
property var proViewOrderBook
25-
property var proViewBestOrders
24+
property var proViewMarketsOrderBook
2625
property var proViewPlaceOrderForm
2726

2827
Item
@@ -131,11 +130,7 @@ Item
131130

132131
HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 }
133132

134-
CheckEye { text: qsTr("Order Book"); target: proViewOrderBook }
135-
136-
HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 }
137-
138-
CheckEye { text: qsTr("Best Orders"); target: proViewBestOrders }
133+
CheckEye { text: qsTr("Markets"); target: proViewMarketsOrderBook }
139134

140135
HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 }
141136

src/core/atomicdex/pages/qt.trading.page.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ namespace atomic_dex
708708
this->m_preferred_order = std::nullopt;
709709
this->m_fees = QVariantMap();
710710
this->m_cex_price = "0";
711+
this->m_pair_trades_24hr = "0";
711712
this->m_pair_volume_24hr = "0";
712713
this->m_post_clear_forms = true;
713714
this->set_selected_order_status(SelectedOrderStatus::None);
@@ -1394,15 +1395,24 @@ namespace atomic_dex
13941395
const auto* market_selector = get_market_pairs_mdl();
13951396
const auto& base = utils::retrieve_main_ticker(market_selector->get_left_selected_coin().toStdString(), true);
13961397
const auto& rel = utils::retrieve_main_ticker(market_selector->get_right_selected_coin().toStdString(), true);
1398+
QString trades = QString::fromStdString(defi_stats_service.get_trades_24h(base, rel));
13971399
QString vol = QString::fromStdString(defi_stats_service.get_volume_24h_usd(base, rel));
13981400

13991401
if (vol != m_pair_volume_24hr)
14001402
{
1403+
m_pair_trades_24hr = trades;
1404+
emit pairTrades24hrChanged();
14011405
m_pair_volume_24hr = vol;
14021406
emit pairVolume24hrChanged();
14031407
}
14041408
}
14051409

1410+
QString
1411+
trading_page::get_pair_trades_24hr() const
1412+
{
1413+
return m_pair_trades_24hr;
1414+
}
1415+
14061416
QString
14071417
trading_page::get_pair_volume_24hr() const
14081418
{

src/core/atomicdex/pages/qt.trading.page.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ namespace atomic_dex
5959
Q_PROPERTY(SelectedOrderStatus selected_order_status READ get_selected_order_status WRITE set_selected_order_status NOTIFY selectedOrderStatusChanged)
6060
Q_PROPERTY(QString price_reversed READ get_price_reversed NOTIFY priceReversedChanged)
6161
Q_PROPERTY(QString pair_volume_24hr READ get_pair_volume_24hr NOTIFY pairVolume24hrChanged)
62+
Q_PROPERTY(QString pair_trades_24hr READ get_pair_trades_24hr NOTIFY pairTrades24hrChanged)
6263
Q_PROPERTY(QString cex_price READ get_cex_price NOTIFY cexPriceChanged)
6364
Q_PROPERTY(QString cex_price_reversed READ get_cex_price_reversed NOTIFY cexPriceReversedChanged)
6465
Q_PROPERTY(QString cex_price_diff READ get_cex_price_diff NOTIFY cexPriceDiffChanged)
@@ -115,6 +116,7 @@ namespace atomic_dex
115116
QString m_total_amount{"0.00777"};
116117
QString m_cex_price{"0"};
117118
QString m_pair_volume_24hr{"0"};
119+
QString m_pair_trades_24hr{"0"};
118120
QString m_minimal_trading_amount{"0.0001"};
119121
std::optional<nlohmann::json> m_preferred_order;
120122
boost::synchronized_value<QVariantMap> m_fees;
@@ -197,6 +199,7 @@ namespace atomic_dex
197199
void set_total_amount(QString total_amount);
198200
[[nodiscard]] QString get_base_amount() const;
199201
[[nodiscard]] QString get_rel_amount() const;
202+
[[nodiscard]] QString get_pair_trades_24hr() const;
200203
[[nodiscard]] QString get_pair_volume_24hr() const;
201204
[[nodiscard]] QString get_cex_price() const;
202205
[[nodiscard]] QString get_cex_price_reversed() const;
@@ -238,6 +241,7 @@ namespace atomic_dex
238241
void baseAmountChanged();
239242
void relAmountChanged();
240243
void feesChanged();
244+
void pairTrades24hrChanged();
241245
void pairVolume24hrChanged();
242246
void cexPriceChanged();
243247
void cexPriceReversedChanged();

0 commit comments

Comments
 (0)