Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 14 additions & 31 deletions src/atomic.dex.app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ namespace atomic_dex
#endif
}

QObjectList
const QObjectList&
atomic_dex::application::get_enabled_coins() const noexcept
{
return m_enabled_coins;
}

QObjectList
const QObjectList&
atomic_dex::application::get_enableable_coins() const noexcept
{
return m_enableable_coins;
Expand Down Expand Up @@ -281,13 +281,6 @@ namespace atomic_dex
this->set_current_balance_fiat_all(QString::fromStdString(fiat_balance_std));
}

// auto second_fiat_balance_std = paprika.get_price_in_fiat_all(m_second_current_fiat.toStdString(), ec);

// if (!ec)
//{
// this->set_second_current_balance_fiat_all(QString::fromStdString(second_fiat_balance_std));
//}

if (not m_coin_info->get_ticker().isEmpty() && not m_enabled_coins.empty())
{
refresh_fiat_balance(mm2, paprika);
Expand Down Expand Up @@ -368,32 +361,19 @@ namespace atomic_dex
return m_coin_info;
}

QString
const QString&
atomic_dex::application::get_balance_fiat_all() const noexcept
{
return m_current_balance_all;
}

QString
application::get_second_balance_fiat_all() const noexcept
{
return m_second_current_balance_all;
}

void
atomic_dex::application::set_current_balance_fiat_all(QString current_fiat_all_balance) noexcept
{
this->m_current_balance_all = std::move(current_fiat_all_balance);
emit on_fiat_balance_all_changed();
}

void
application::set_second_current_balance_fiat_all(QString current_fiat_all_balance) noexcept
{
this->m_second_current_balance_all = std::move(current_fiat_all_balance);
emit on_second_fiat_balance_all_changed();
}

application::application(QObject* pParent) noexcept : QObject(pParent), m_coin_info(new current_coin_info(dispatcher_, this))
{
//! MM2 system need to be created before the GUI and give the instance to the gui
Expand Down Expand Up @@ -452,15 +432,16 @@ namespace atomic_dex
m_refresh_enabled_coin_event = true;
}

QString
const QString&
application::get_current_fiat() const noexcept
{
return QString::fromStdString(this->m_config.current_fiat);
return m_current_fiat;
}

void
application::set_current_fiat(QString current_fiat) noexcept
{
this->m_current_fiat = current_fiat;
if (current_fiat.toStdString() != m_config.current_fiat)
{
spdlog::info("change lang {} to {}", m_config.current_fiat, current_fiat.toStdString());
Expand All @@ -480,7 +461,7 @@ namespace atomic_dex
application::refresh_address(mm2& mm2)
{
std::error_code ec;
auto address = QString::fromStdString(mm2.address(m_coin_info->get_ticker().toStdString(), ec));
QString address = QString::fromStdString(mm2.address(m_coin_info->get_ticker().toStdString(), ec));
this->m_coin_info->set_address(address);
}

Expand All @@ -505,6 +486,7 @@ namespace atomic_dex
{
atomic_dex::t_withdraw_request req{
.to = address.toStdString(), .coin = m_coin_info->get_ticker().toStdString(), .max = max, .amount = amount.toStdString()};
//! If req max is set to true, amount is ignored
if (req.max == true)
{
req.amount = "0";
Expand Down Expand Up @@ -660,7 +642,7 @@ namespace atomic_dex
this->dispatcher_.trigger<gui_leave_trading>();
}

QString
const QString&
application::get_status() const noexcept
{
return m_current_status;
Expand Down Expand Up @@ -892,7 +874,7 @@ namespace atomic_dex
return out;
}

QString
const QString&
application::get_current_lang() const noexcept
{
return m_current_lang;
Expand Down Expand Up @@ -1138,13 +1120,14 @@ namespace atomic_dex
QString
application::get_mm2_version() const
{
return QString::fromStdString(::mm2::api::rpc_version());
auto res = QString::fromStdString(::mm2::api::rpc_version());
return res;
}

QString
application::get_export_folder() const
{
return QString::fromStdString(get_atomic_dex_export_folder().string().c_str());
return QString::fromStdString(get_atomic_dex_export_folder().string());
}

QString
Expand Down Expand Up @@ -1209,7 +1192,7 @@ namespace atomic_dex
//! Wallet manager QML API
namespace atomic_dex
{
QString
const QString&
application::get_wallet_default_name() const noexcept
{
return m_wallet_manager.get_wallet_default_name();
Expand Down
45 changes: 20 additions & 25 deletions src/atomic.dex.app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ namespace atomic_dex
Q_PROPERTY(QList<QObject*> enableable_coins READ get_enableable_coins NOTIFY enableableCoinsChanged)
Q_PROPERTY(QObject* current_coin_info READ get_current_coin_info NOTIFY coinInfoChanged)
Q_PROPERTY(QString fiat READ get_current_fiat WRITE set_current_fiat NOTIFY on_fiat_changed)
// Q_PROPERTY(QString second_fiat READ get_second_current_fiat WRITE set_second_current_fiat NOTIFY on_second_fiat_changed)
Q_PROPERTY(QString lang READ get_current_lang WRITE set_current_lang NOTIFY on_lang_changed)
Q_PROPERTY(QString wallet_default_name READ get_wallet_default_name WRITE set_wallet_default_name NOTIFY on_wallet_default_name_changed)
Q_PROPERTY(QString balance_fiat_all READ get_balance_fiat_all WRITE set_current_balance_fiat_all NOTIFY on_fiat_balance_all_changed)
Q_PROPERTY(QString second_balance_fiat_all READ get_second_balance_fiat_all WRITE set_second_current_balance_fiat_all NOTIFY
on_second_fiat_balance_all_changed)
Q_PROPERTY(QString initial_loading_status READ get_status WRITE set_status NOTIFY on_status_changed)

private:
Expand Down Expand Up @@ -87,22 +84,20 @@ namespace atomic_dex
coinpaprika_provider& get_paprika() noexcept;
entt::dispatcher& get_dispatcher() noexcept;
QObject* get_current_coin_info() const noexcept;
QObjectList get_enabled_coins() const noexcept;
QObjectList get_enableable_coins() const noexcept;
QString get_current_fiat() const noexcept;
QString get_current_lang() const noexcept;
QString get_balance_fiat_all() const noexcept;
QString get_second_balance_fiat_all() const noexcept;
QString get_wallet_default_name() const noexcept;
QString get_status() const noexcept;
const QObjectList& get_enabled_coins() const noexcept;
const QObjectList& get_enableable_coins() const noexcept;
const QString& get_current_fiat() const noexcept;
const QString& get_current_lang() const noexcept;
const QString& get_balance_fiat_all() const noexcept;
const QString& get_wallet_default_name() const noexcept;
const QString& get_status() const noexcept;
Q_INVOKABLE QString get_version() const noexcept;

//! Properties Setter
void set_current_fiat(QString current_fiat) noexcept;
void set_current_lang(const QString& current_lang) noexcept;
void set_wallet_default_name(QString wallet_default_name) noexcept;
void set_current_balance_fiat_all(QString current_fiat_all_balance) noexcept;
void set_second_current_balance_fiat_all(QString current_fiat_all_balance) noexcept;
void set_status(QString status) noexcept;
void set_qt_app(std::shared_ptr<QApplication> app) noexcept;

Expand Down Expand Up @@ -190,11 +185,9 @@ namespace atomic_dex
void enableableCoinsChanged();
void coinInfoChanged();
void on_fiat_changed();
void on_second_fiat_changed();
void on_lang_changed();
void lang_changed();
void on_fiat_balance_all_changed();
void on_second_fiat_balance_all_changed();
void on_status_changed();
void on_wallet_default_name_changed();
void myOrdersUpdated();
Expand All @@ -211,21 +204,23 @@ namespace atomic_dex
atomic_dex::qt_wallet_manager m_wallet_manager;

//! Private members
std::atomic_bool m_refresh_enabled_coin_event{false};
std::atomic_bool m_refresh_current_ticker_infos{false};
std::atomic_bool m_refresh_orders_needed{false};
std::atomic_bool m_refresh_ohlc_needed{false};
std::atomic_bool m_refresh_transaction_only{false};
bool m_need_a_full_refresh_of_mm2{false};
QObjectList m_enabled_coins;
QObjectList m_enableable_coins;
QTranslator m_translator;
// QString m_current_fiat{"USD"};
// QString m_second_current_fiat{"BTC"};
std::atomic_bool m_refresh_enabled_coin_event{false};
std::atomic_bool m_refresh_current_ticker_infos{false};
std::atomic_bool m_refresh_orders_needed{false};
std::atomic_bool m_refresh_ohlc_needed{false};
std::atomic_bool m_refresh_transaction_only{false};
bool m_need_a_full_refresh_of_mm2{false};
QObjectList m_enabled_coins;
QObjectList m_enableable_coins;
QTranslator m_translator;
QString m_current_fiat{QString::fromStdString(m_config.current_fiat)};
QString m_current_lang{QString::fromStdString(m_config.current_lang)};
QString m_current_status{"None"};
QString m_current_balance_all{"0.00"};
QString m_second_current_balance_all{"0.00"};
current_coin_info* m_coin_info;

//! Object reusable
QVariantList m_portfolio_informations;
};
} // namespace atomic_dex
33 changes: 19 additions & 14 deletions src/atomic.dex.qt.current.coin.infos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ namespace atomic_dex
return this->selected_coin_fname;
}

QString
const QString&
atomic_dex::current_coin_info::get_balance() const noexcept
{
return selected_coin_balance;
}

void
atomic_dex::current_coin_info::set_balance(QString balance) noexcept
atomic_dex::current_coin_info::set_balance(const QString& balance) noexcept
{
this->selected_coin_balance = std::move(balance);
this->selected_coin_balance = balance;
emit balance_changed();
}

QString
const QString&
atomic_dex::current_coin_info::get_ticker() const noexcept
{
return selected_coin_name;
}

void
atomic_dex::current_coin_info::set_ticker(QString ticker) noexcept
atomic_dex::current_coin_info::set_ticker(const QString& ticker) noexcept
{
selected_coin_name = std::move(ticker);
selected_coin_name = ticker;
this->m_dispatcher.trigger<change_ticker_event>();
emit ticker_changed();
}
Expand All @@ -70,7 +70,7 @@ namespace atomic_dex
return selected_coin_url;
}

QString
const QString&
current_coin_info::get_fiat_amount() const noexcept
{
return this->selected_coin_fiat_amount;
Expand All @@ -91,11 +91,12 @@ namespace atomic_dex


void
current_coin_info::set_fiat_amount(QString fiat_amount) noexcept
current_coin_info::set_fiat_amount(const QString& fiat_amount) noexcept
{
this->selected_coin_fiat_amount = std::move(fiat_amount);
this->selected_coin_fiat_amount = fiat_amount;
emit fiat_amount_changed();
}

QObjectList
current_coin_info::get_transactions() const noexcept
{
Expand All @@ -109,17 +110,21 @@ namespace atomic_dex
this->selected_coin_transactions = std::move(transactions);
emit transactionsChanged();
}
QString

const QString&
current_coin_info::get_address() const noexcept
{
return selected_coin_address;
}

void
current_coin_info::set_address(QString address) noexcept
current_coin_info::set_address(const QString& address) noexcept
{
this->selected_coin_address = std::move(address);
emit address_changed();
if (address != selected_coin_address)
{
this->selected_coin_address = address;
emit address_changed();
}
}

void
Expand Down Expand Up @@ -210,7 +215,7 @@ namespace atomic_dex
QString
atomic_dex::current_coin_info::get_paprika_id() const noexcept
{
return this->selected_coin_paprika_id;
return this->selected_coin_paprika_id;
}

void
Expand Down
61 changes: 31 additions & 30 deletions src/atomic.dex.qt.current.coin.infos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,37 @@ namespace atomic_dex

public:
explicit current_coin_info(entt::dispatcher& dispatcher, QObject* pParent = nullptr) noexcept;
[[nodiscard]] bool is_claimable_ticker() const noexcept;
void set_claimable(bool claimable) noexcept;
[[nodiscard]] QString get_minimal_balance_for_asking_rewards() const noexcept;
void set_minimal_balance_for_asking_rewards(QString amount) noexcept;
[[nodiscard]] QString get_tx_state() const noexcept;
void set_tx_state(QString state) noexcept;
[[nodiscard]] unsigned int get_tx_current_block() const noexcept;
void set_tx_current_block(unsigned int block) noexcept;
[[nodiscard]] unsigned int get_txs_left() const noexcept;
void set_txs_left(unsigned int txs) noexcept;
[[nodiscard]] unsigned int get_blocks_left() const noexcept;
void set_blocks_left(unsigned int blocks) noexcept;
[[nodiscard]] QObjectList get_transactions() const noexcept;
void set_transactions(QObjectList transactions) noexcept;
[[nodiscard]] QString get_ticker() const noexcept;
void set_ticker(QString ticker) noexcept;
[[nodiscard]] QString get_name() const noexcept;
void set_name(QString ticker) noexcept;
[[nodiscard]] QString get_paprika_id() const noexcept;
void set_paprika_id(QString ticker) noexcept;
[[nodiscard]] QString get_address() const noexcept;
void set_address(QString address) noexcept;
[[nodiscard]] QString get_balance() const noexcept;
void set_balance(QString balance) noexcept;
[[nodiscard]] QString get_explorer_url() const noexcept;
void set_explorer_url(QString url) noexcept;
[[nodiscard]] QString get_fiat_amount() const noexcept;
void set_fiat_amount(QString fiat_amount) noexcept;
[[nodiscard]] QString get_type() const noexcept;
void set_type(QString type) noexcept;;
[[nodiscard]] bool is_claimable_ticker() const noexcept;
void set_claimable(bool claimable) noexcept;
[[nodiscard]] QString get_minimal_balance_for_asking_rewards() const noexcept;
void set_minimal_balance_for_asking_rewards(QString amount) noexcept;
[[nodiscard]] QString get_tx_state() const noexcept;
void set_tx_state(QString state) noexcept;
[[nodiscard]] unsigned int get_tx_current_block() const noexcept;
void set_tx_current_block(unsigned int block) noexcept;
[[nodiscard]] unsigned int get_txs_left() const noexcept;
void set_txs_left(unsigned int txs) noexcept;
[[nodiscard]] unsigned int get_blocks_left() const noexcept;
void set_blocks_left(unsigned int blocks) noexcept;
[[nodiscard]] QObjectList get_transactions() const noexcept;
void set_transactions(QObjectList transactions) noexcept;
[[nodiscard]] const QString& get_ticker() const noexcept;
void set_ticker(const QString& ticker) noexcept;
[[nodiscard]] QString get_name() const noexcept;
void set_name(QString ticker) noexcept;
[[nodiscard]] QString get_paprika_id() const noexcept;
void set_paprika_id(QString ticker) noexcept;
[[nodiscard]] const QString& get_address() const noexcept;
void set_address(const QString& address) noexcept;
[[nodiscard]] const QString& get_balance() const noexcept;
void set_balance(const QString& balance) noexcept;
[[nodiscard]] QString get_explorer_url() const noexcept;
void set_explorer_url(QString url) noexcept;
[[nodiscard]] const QString& get_fiat_amount() const noexcept;
void set_fiat_amount(const QString& fiat_amount) noexcept;
[[nodiscard]] QString get_type() const noexcept;
void set_type(QString type) noexcept;
;

signals:
void ticker_changed();
Expand Down
Loading