Skip to content

Commit

Permalink
a tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
smk762 committed Aug 26, 2022
1 parent 7316a6a commit 61b5067
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 34 deletions.
Expand Up @@ -80,17 +80,18 @@ ColumnLayout
anchors.top: input_price.bottom
anchors.left: input_price.left
anchors.topMargin: 7
reduce.onClicked:
visible: !API.app.trading_pg.invalid_cex_price
left_btn.onClicked:
{
let price = General.formatDouble(parseFloat(input_price.text) * 0.99)
let price = General.formatDouble(parseFloat(input_price.text) - (General.formatDouble(API.app.trading_pg.cex_price)*0.01))
setPrice(String(price))
}
increase.onClicked:
right_btn.onClicked:
{
let price = General.formatDouble(parseFloat(input_price.text) * 1.01)
let price = General.formatDouble(parseFloat(input_price.text) + (General.formatDouble(API.app.trading_pg.cex_price)*0.01))
setPrice(String(price))
}
market.onClicked:
middle_btn.onClicked:
{
if (input_price.text == "0") setPrice("1")
let price = General.formatDouble(API.app.trading_pg.cex_price)
Expand All @@ -100,6 +101,9 @@ ColumnLayout
left_label: "-1%"
middle_label: "0%"
right_label: "+1%"
left_tooltip_text: "Reduce 1% relative to CEX market price."
middle_tooltip_text: "Use CEX market price."
right_tooltip_text: "Increase 1% relative to CEX market price."
}
}

Expand Down Expand Up @@ -128,17 +132,17 @@ ColumnLayout
anchors.top: input_volume.bottom
anchors.left: input_volume.left
anchors.topMargin: 7
reduce.onClicked:
left_btn.onClicked:
{
let volume = General.formatDouble(API.app.trading_pg.max_volume * 0.25)
setVolume(String(volume))
}
market.onClicked:
middle_btn.onClicked:
{
let volume = General.formatDouble(API.app.trading_pg.max_volume * 0.5)
setVolume(String(volume))
}
increase.onClicked:
right_btn.onClicked:
{
let volume = General.formatDouble(API.app.trading_pg.max_volume)
setVolume(String(volume))
Expand All @@ -147,6 +151,9 @@ ColumnLayout
left_label: "25%"
middle_label: "50%"
right_label: "Max"
left_tooltip_text: "Swap 25% of your balance."
middle_tooltip_text: "Swap 50% of your balance."
right_tooltip_text: "Swap maximum balance."
}
}

Expand All @@ -167,7 +174,7 @@ ColumnLayout
right_text: left_ticker
placeholderText: sell_mode ? qsTr("Min amount to sell") : qsTr("Min amount to receive")
text: API.app.trading_pg.min_trade_vol
onTextChanged: setMinimumAmount(text)
onTextChanged: if (API.app.trading_pg.min_trade_vol != text) setMinimumAmount(text)
}

OrderFormSubfield
Expand All @@ -176,21 +183,21 @@ ColumnLayout
anchors.top: input_minvolume.bottom
anchors.left: input_minvolume.left
anchors.topMargin: 7
reduce.onClicked:
left_btn.onClicked:
{
let volume = API.app.trading_pg.max_volume * 0.05
if (volume > parseFloat(input_volume.text))
volume = parseFloat(input_volume.text)
setMinimumAmount(General.formatDouble(volume))
}
market.onClicked:
middle_btn.onClicked:
{
let volume = API.app.trading_pg.max_volume * 0.10
if (volume > parseFloat(input_volume.text))
volume = parseFloat(input_volume.text)
setMinimumAmount(General.formatDouble(volume))
}
increase.onClicked:
right_btn.onClicked:
{
let volume = API.app.trading_pg.max_volume * 0.20
if (volume > parseFloat(input_volume.text))
Expand All @@ -201,6 +208,9 @@ ColumnLayout
left_label: "5%"
middle_label: "10%"
right_label: "20%"
left_tooltip_text: "Minimum accepted trade equals 5% of your balance."
middle_tooltip_text: "Minimum accepted trade equals 10% of your balance."
right_tooltip_text: "Minimum accepted trade equals 20% of your balance."
}
}

Expand Down
Expand Up @@ -10,13 +10,16 @@ import Dex.Themes 1.0 as Dex
RowLayout
{
id: control
property alias fiat_value: fiat_label.text_value
property alias fiat_value: _fiat_label.text_value
property alias left_label: _left_label.text
property alias middle_label: _middle_label.text
property alias right_label: _right_label.text
property alias market: _market
property alias increase: _increase
property alias reduce: _reduce
property string left_tooltip_text: ""
property string middle_tooltip_text: ""
property string right_tooltip_text: ""
property alias left_btn: _left_btn
property alias middle_btn: _middle_btn
property alias right_btn: _right_btn
property int pixel_size: 12
property int btn_width: 33
spacing: 2
Expand Down Expand Up @@ -46,10 +49,23 @@ RowLayout
text: "-1%"
}

DexTooltip
{
id: _left_tooltip
visible: _left_btn.containsMouse && left_tooltip_text != ""
contentItem: DefaultText
{
text: left_tooltip_text
font: Dex.DexTypo.caption
padding: 5
}
}

DefaultMouseArea
{
id: _reduce
id: _left_btn
anchors.fill: parent
hoverEnabled: true
}
}

Expand All @@ -66,21 +82,34 @@ RowLayout
width: parent.width
height: parent.height
color: Dex.CurrentTheme.tradeMarketModeSelectorNotSelectedBackgroundColor
}

DefaultText
{
id: _middle_label
anchors.centerIn: parent
font.pixelSize: pixel_size
color: Dex.CurrentTheme.foregroundColor2
text: "0%"
}

DefaultMouseArea
{
id: _market
anchors.fill: parent
DefaultMouseArea
{
id: _middle_btn
anchors.fill: parent
hoverEnabled: true
}

DefaultText
{
id: _middle_label
anchors.centerIn: parent
font.pixelSize: pixel_size
color: Dex.CurrentTheme.foregroundColor2
text: "0%"
}

DexTooltip
{
id: _middle_tooltip
visible: _middle_btn.containsMouse && middle_tooltip_text != ""
contentItem: DefaultText
{
text: middle_tooltip_text
font: Dex.DexTypo.caption
padding: 5
}
}
}
}
Item
Expand All @@ -107,19 +136,31 @@ RowLayout
text: "+1%"
}

DexTooltip
{
id: _right_tooltip
visible: _right_btn.containsMouse && right_tooltip_text != ""
contentItem: DefaultText
{
text: right_tooltip_text
font: Dex.DexTypo.caption
padding: 5
}
}

DefaultMouseArea
{
id: _increase
id: _right_btn
anchors.fill: parent
hoverEnabled: true
}
}

Item { Layout.fillWidth: true }

DefaultText
{
id: fiat_label
text_value: _fiat_text
id: _fiat_label
font.pixelSize: pixel_size
color: Dex.CurrentTheme.foregroundColor2

Expand Down
6 changes: 6 additions & 0 deletions src/core/atomicdex/pages/qt.trading.page.cpp
Expand Up @@ -683,11 +683,14 @@ namespace atomic_dex
this->m_post_clear_forms = true;
this->set_selected_order_status(SelectedOrderStatus::None);
this->reset_fees();
this->determine_cex_rates();
emit cexPriceChanged();
emit invalidCexPriceChanged();
emit cexPriceReversedChanged();
emit feesChanged();
emit prefferedOrderChanged();
emit priceChanged();
emit priceReversedChanged();
}

QString
Expand Down Expand Up @@ -1011,6 +1014,9 @@ namespace atomic_dex
set_current_orderbook(base, rel);
}
}
this->determine_cex_rates();
emit priceChanged();
emit priceReversedChanged();
return true;
}

Expand Down

0 comments on commit 61b5067

Please sign in to comment.