style(@desktop/cpp): apply clang-format on src-cpp/*
This commit is contained in:
parent
f27fd6ea61
commit
00156cc9c0
|
@ -10,7 +10,7 @@
|
||||||
BasedOnStyle: WebKit
|
BasedOnStyle: WebKit
|
||||||
TabWidth: 4
|
TabWidth: 4
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
UseTab: Always
|
UseTab: Never
|
||||||
ColumnLimit: 120
|
ColumnLimit: 120
|
||||||
|
|
||||||
# Other languages JavaScript, Proto
|
# Other languages JavaScript, Proto
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "app_controller.h"
|
#include "app_controller.h"
|
||||||
#include "accounts/service.h"
|
#include "accounts/service.h"
|
||||||
#include "app_service.h"
|
#include "app_service.h"
|
||||||
#include "modules/startup/module.h"
|
|
||||||
#include "modules/main/module.h"
|
#include "modules/main/module.h"
|
||||||
|
#include "modules/startup/module.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
AppController::AppController()
|
AppController::AppController()
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "accounts/service.h"
|
|
||||||
#include "wallet_accounts/service.h"
|
|
||||||
#include "../modules/main/interfaces/module_access_interface.h"
|
#include "../modules/main/interfaces/module_access_interface.h"
|
||||||
#include "../modules/startup/module_access_interface.h"
|
#include "../modules/startup/module_access_interface.h"
|
||||||
|
#include "accounts/service.h"
|
||||||
#include "app_controller_delegate.h"
|
#include "app_controller_delegate.h"
|
||||||
#include "app_service.h"
|
#include "app_service.h"
|
||||||
|
#include "wallet_accounts/service.h"
|
||||||
|
|
||||||
class AppController : public QObject, AppControllerDelegate
|
class AppController : public QObject, AppControllerDelegate
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,7 @@ public:
|
||||||
void start();
|
void start();
|
||||||
public slots:
|
public slots:
|
||||||
void mainDidLoad();
|
void mainDidLoad();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void connect();
|
void connect();
|
||||||
void startupDidLoad() override;
|
void startupDidLoad() override;
|
||||||
|
|
|
@ -21,4 +21,3 @@ public:
|
||||||
} // namespace Modules::Main
|
} // namespace Modules::Main
|
||||||
|
|
||||||
#endif // CONTROLLER_H
|
#endif // CONTROLLER_H
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
|
||||||
#include "module.h"
|
|
||||||
#include "singleton.h"
|
|
||||||
#include "modules/main/wallet/module.h"
|
|
||||||
#include "../shared/section_item.h"
|
#include "../shared/section_item.h"
|
||||||
|
#include "module.h"
|
||||||
|
#include "modules/main/wallet/module.h"
|
||||||
|
#include "singleton.h"
|
||||||
|
|
||||||
namespace Modules::Main
|
namespace Modules::Main
|
||||||
{
|
{
|
||||||
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent): QObject(parent)
|
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent)
|
||||||
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
m_controllerPtr = new Controller(this);
|
m_controllerPtr = new Controller(this);
|
||||||
m_viewPtr = new View(this);
|
m_viewPtr = new View(this);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "../global/app_sections_config.h"
|
#include "../global/app_sections_config.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Modules::Main
|
namespace Modules::Main
|
||||||
{
|
{
|
||||||
View::View(QObject* parent)
|
View::View(QObject* parent)
|
||||||
|
@ -13,7 +12,15 @@ View::View(QObject* parent)
|
||||||
void View::load()
|
void View::load()
|
||||||
{
|
{
|
||||||
// Add Wallet Section to Sections model
|
// Add Wallet Section to Sections model
|
||||||
auto walletSectionItem = new Shared::Models::SectionItem(WALLET_SECTION_ID, Shared::Models::SectionType::Wallet, WALLET_SECTION_NAME, "", "", WALLET_SECTION_ICON, "", false, this);
|
auto walletSectionItem = new Shared::Models::SectionItem(WALLET_SECTION_ID,
|
||||||
|
Shared::Models::SectionType::Wallet,
|
||||||
|
WALLET_SECTION_NAME,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
WALLET_SECTION_ICON,
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
this);
|
||||||
addItem(walletSectionItem);
|
addItem(walletSectionItem);
|
||||||
setActiveSection(WALLET_SECTION_ID);
|
setActiveSection(WALLET_SECTION_ID);
|
||||||
|
|
||||||
|
|
|
@ -36,4 +36,3 @@ private:
|
||||||
} // namespace Modules::Main
|
} // namespace Modules::Main
|
||||||
|
|
||||||
#endif // VIEW_H
|
#endif // VIEW_H
|
||||||
|
|
||||||
|
|
|
@ -4,21 +4,17 @@
|
||||||
|
|
||||||
namespace Modules::Main::Wallet::Accounts
|
namespace Modules::Main::Wallet::Accounts
|
||||||
{
|
{
|
||||||
Controller::Controller(std::shared_ptr<Wallets::ServiceInterface> walletService,
|
Controller::Controller(std::shared_ptr<Wallets::ServiceInterface> walletService, QObject* parent)
|
||||||
QObject* parent)
|
: m_walletServicePtr(walletService)
|
||||||
: m_walletServicePtr(walletService),
|
, QObject(parent)
|
||||||
QObject(parent)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void Controller::init()
|
void Controller::init() { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Wallets::WalletAccountDto> Controller::getWalletAccounts()
|
QList<Wallets::WalletAccountDto> Controller::getWalletAccounts()
|
||||||
{
|
{
|
||||||
QList<Wallets::WalletAccountDto> wallet_accounts;
|
QList<Wallets::WalletAccountDto> wallet_accounts;
|
||||||
if(nullptr != m_walletServicePtr)
|
if(nullptr != m_walletServicePtr) wallet_accounts = m_walletServicePtr->getWalletAccounts();
|
||||||
wallet_accounts = m_walletServicePtr->getWalletAccounts();
|
|
||||||
|
|
||||||
return wallet_accounts;
|
return wallet_accounts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "wallet_accounts/wallet_account.h"
|
|
||||||
#include "wallet_accounts/service_interface.h"
|
|
||||||
#include "interfaces/controller_interface.h"
|
#include "interfaces/controller_interface.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
|
#include "wallet_accounts/service_interface.h"
|
||||||
|
#include "wallet_accounts/wallet_account.h"
|
||||||
|
|
||||||
namespace Modules::Main::Wallet::Accounts
|
namespace Modules::Main::Wallet::Accounts
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,16 +2,24 @@
|
||||||
|
|
||||||
namespace Modules::Main::Wallet::Accounts
|
namespace Modules::Main::Wallet::Accounts
|
||||||
{
|
{
|
||||||
Item::Item(QString name, QString address, QString path, QString color, QString publicKey, QString walletType, bool isWallet, bool isChat, float currencyBalance)
|
Item::Item(QString name,
|
||||||
: m_name(name),
|
QString address,
|
||||||
m_address(address),
|
QString path,
|
||||||
m_path(path),
|
QString color,
|
||||||
m_color(color),
|
QString publicKey,
|
||||||
m_publicKey(publicKey),
|
QString walletType,
|
||||||
m_walletType(walletType),
|
bool isWallet,
|
||||||
m_isWallet(isWallet),
|
bool isChat,
|
||||||
m_isChat(isChat),
|
float currencyBalance)
|
||||||
m_currencyBalance(currencyBalance)
|
: m_name(name)
|
||||||
|
, m_address(address)
|
||||||
|
, m_path(path)
|
||||||
|
, m_color(color)
|
||||||
|
, m_publicKey(publicKey)
|
||||||
|
, m_walletType(walletType)
|
||||||
|
, m_isWallet(isWallet)
|
||||||
|
, m_isChat(isChat)
|
||||||
|
, m_currencyBalance(currencyBalance)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
const QString& Item::getName() const
|
const QString& Item::getName() const
|
||||||
|
|
|
@ -19,7 +19,15 @@ private:
|
||||||
float m_currencyBalance;
|
float m_currencyBalance;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Item(QString name, QString address, QString path, QString color, QString publicKey, QString walletType, bool isWallet, bool isChat, float currencyBalance);
|
Item(QString name,
|
||||||
|
QString address,
|
||||||
|
QString path,
|
||||||
|
QString color,
|
||||||
|
QString publicKey,
|
||||||
|
QString walletType,
|
||||||
|
bool isWallet,
|
||||||
|
bool isChat,
|
||||||
|
float currencyBalance);
|
||||||
~Item() = default;
|
~Item() = default;
|
||||||
|
|
||||||
const QString& getName() const;
|
const QString& getName() const;
|
||||||
|
|
|
@ -50,7 +50,8 @@ QVariant Model::data(const QModelIndex& index, int role) const
|
||||||
case PublicKey: return QVariant(item.getPublicKey());
|
case PublicKey: return QVariant(item.getPublicKey());
|
||||||
case WalletType: return QVariant(item.getWalletType());
|
case WalletType: return QVariant(item.getWalletType());
|
||||||
case IsWallet: return QVariant(item.getIsWallet());
|
case IsWallet: return QVariant(item.getIsWallet());
|
||||||
case IsChat: return QVariant(item.getIsChat());
|
case IsChat:
|
||||||
|
return QVariant(item.getIsChat());
|
||||||
// case Assets: return QVariant(item.ge());
|
// case Assets: return QVariant(item.ge());
|
||||||
case CurrencyBalance: return QVariant(item.getCurrencyBalance());
|
case CurrencyBalance: return QVariant(item.getCurrencyBalance());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
|
|
||||||
namespace Modules::Main::Wallet::Accounts
|
namespace Modules::Main::Wallet::Accounts
|
||||||
{
|
{
|
||||||
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject *parent): QObject(parent)
|
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent)
|
||||||
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
m_controllerPtr = new Controller(walletsService, this);
|
m_controllerPtr = new Controller(walletsService, this);
|
||||||
m_viewPtr = new View(this);
|
m_viewPtr = new View(this);
|
||||||
|
@ -49,7 +50,8 @@ void Module::refreshWalletAccounts()
|
||||||
QVector<Item> items;
|
QVector<Item> items;
|
||||||
foreach(const auto& acc, walletAccounts)
|
foreach(const auto& acc, walletAccounts)
|
||||||
{
|
{
|
||||||
items << Item(acc.name, acc.address, acc.path, acc.color, acc.publicKey, acc.walletType, acc.isWallet, acc.isChat, 0);
|
items << Item(
|
||||||
|
acc.name, acc.address, acc.path, acc.color, acc.publicKey, acc.walletType, acc.isWallet, acc.isChat, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_viewPtr->setModelItems(items);
|
m_viewPtr->setModelItems(items);
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "wallet_accounts/service_interface.h"
|
|
||||||
#include "interfaces/module_access_interface.h"
|
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
#include "interfaces/module_access_interface.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
#include "wallet_accounts/service_interface.h"
|
||||||
|
|
||||||
namespace Modules::Main::Wallet::Accounts
|
namespace Modules::Main::Wallet::Accounts
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,7 @@ private:
|
||||||
|
|
||||||
void connect();
|
void connect();
|
||||||
void refreshWalletAccounts();
|
void refreshWalletAccounts();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent);
|
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent);
|
||||||
~Module() = default;
|
~Module() = default;
|
||||||
|
|
|
@ -20,7 +20,8 @@ Model* View::getModel()
|
||||||
return m_modelPtr;
|
return m_modelPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::setModelItems(QVector<Item> &accounts) {
|
void View::setModelItems(QVector<Item>& accounts)
|
||||||
|
{
|
||||||
m_modelPtr->setItems(accounts);
|
m_modelPtr->setItems(accounts);
|
||||||
modelChanged();
|
modelChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,10 @@
|
||||||
|
|
||||||
namespace Modules::Main::Wallet
|
namespace Modules::Main::Wallet
|
||||||
{
|
{
|
||||||
Controller::Controller(std::shared_ptr<Wallets::ServiceInterface> walletService,
|
Controller::Controller(std::shared_ptr<Wallets::ServiceInterface> walletService, QObject* parent)
|
||||||
QObject* parent)
|
: m_walletService(walletService)
|
||||||
: m_walletService(walletService),
|
, QObject(parent)
|
||||||
QObject(parent)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void Controller::init()
|
void Controller::init() { }
|
||||||
{
|
|
||||||
}
|
|
||||||
} // namespace Modules::Main::Wallet
|
} // namespace Modules::Main::Wallet
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "wallet_accounts/service_interface.h"
|
|
||||||
#include "interfaces/controller_interface.h"
|
#include "interfaces/controller_interface.h"
|
||||||
#include "signals.h"
|
#include "signals.h"
|
||||||
|
#include "wallet_accounts/service_interface.h"
|
||||||
|
|
||||||
namespace Modules::Main::Wallet
|
namespace Modules::Main::Wallet
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
|
||||||
|
#include "accounts/module.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "singleton.h"
|
#include "singleton.h"
|
||||||
#include "accounts/module.h"
|
|
||||||
|
|
||||||
namespace Modules::Main::Wallet
|
namespace Modules::Main::Wallet
|
||||||
{
|
{
|
||||||
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject *parent): QObject(parent)
|
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent)
|
||||||
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
m_controllerPtr = new Controller(walletsService, this);
|
m_controllerPtr = new Controller(walletsService, this);
|
||||||
m_viewPtr = new View(this);
|
m_viewPtr = new View(this);
|
||||||
|
|
|
@ -24,6 +24,7 @@ private:
|
||||||
bool m_moduleLoaded;
|
bool m_moduleLoaded;
|
||||||
|
|
||||||
void connect();
|
void connect();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent);
|
explicit Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent);
|
||||||
~Module() = default;
|
~Module() = default;
|
||||||
|
|
|
@ -6,8 +6,7 @@ namespace Modules::Main::Wallet
|
||||||
{
|
{
|
||||||
View::View(QObject* parent)
|
View::View(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
|
|
||||||
void View::load()
|
void View::load()
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,4 +21,3 @@ signals:
|
||||||
} // namespace Modules::Main::Wallet
|
} // namespace Modules::Main::Wallet
|
||||||
|
|
||||||
#endif // WALLET_VIEW_H
|
#endif // WALLET_VIEW_H
|
||||||
|
|
||||||
|
|
|
@ -23,29 +23,28 @@ SectionItem::SectionItem(QString id,
|
||||||
bool canRequestAccess,
|
bool canRequestAccess,
|
||||||
int access,
|
int access,
|
||||||
bool ensOnly,
|
bool ensOnly,
|
||||||
QObject *parent):
|
QObject* parent)
|
||||||
QObject(parent),
|
: QObject(parent)
|
||||||
m_id(id),
|
, m_id(id)
|
||||||
m_sectionType(sectionType) ,
|
, m_sectionType(sectionType)
|
||||||
m_name(name),
|
, m_name(name)
|
||||||
m_amISectionAdmin(amISectionAdmin),
|
, m_amISectionAdmin(amISectionAdmin)
|
||||||
m_description(description),
|
, m_description(description)
|
||||||
m_image(image),
|
, m_image(image)
|
||||||
m_icon(icon),
|
, m_icon(icon)
|
||||||
m_color(color),
|
, m_color(color)
|
||||||
m_hasNotification(hasNotification),
|
, m_hasNotification(hasNotification)
|
||||||
m_notificationsCount(notificationsCount),
|
, m_notificationsCount(notificationsCount)
|
||||||
m_active(active),
|
, m_active(active)
|
||||||
m_enabled(enabled),
|
, m_enabled(enabled)
|
||||||
m_isMember(isMember),
|
, m_isMember(isMember)
|
||||||
m_joined(joined),
|
, m_joined(joined)
|
||||||
m_canJoin(canJoin),
|
, m_canJoin(canJoin)
|
||||||
m_canManageUsers(canManageUsers),
|
, m_canManageUsers(canManageUsers)
|
||||||
m_canRequestAccess(canRequestAccess),
|
, m_canRequestAccess(canRequestAccess)
|
||||||
m_access(access),
|
, m_access(access)
|
||||||
m_ensOnly(ensOnly)
|
, m_ensOnly(ensOnly)
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
|
|
||||||
SectionType SectionItem::getSectionType() const
|
SectionType SectionItem::getSectionType() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,8 @@ QVariant SectionModel::data(const QModelIndex& index, int role) const
|
||||||
case CanManageUsers: return QVariant(item->getCanManageUsers());
|
case CanManageUsers: return QVariant(item->getCanManageUsers());
|
||||||
case CanRequestAccess: return QVariant(item->getCanRequestAccess());
|
case CanRequestAccess: return QVariant(item->getCanRequestAccess());
|
||||||
case Access: return QVariant(item->getAccess());
|
case Access: return QVariant(item->getAccess());
|
||||||
case EnsOnly: return QVariant(item->getIsEnsOnly());
|
case EnsOnly:
|
||||||
|
return QVariant(item->getIsEnsOnly());
|
||||||
// To Do
|
// To Do
|
||||||
case MembersModel: return QVariant();
|
case MembersModel: return QVariant();
|
||||||
case PendingRequestsToJoinModel: return QVariant();
|
case PendingRequestsToJoinModel: return QVariant();
|
||||||
|
@ -92,13 +93,13 @@ void SectionModel::addItem(SectionItem* item)
|
||||||
void SectionModel::setActiveSection(const QString& Id)
|
void SectionModel::setActiveSection(const QString& Id)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i = 0; i < m_items.size(); ++i) {
|
for(int i = 0; i < m_items.size(); ++i)
|
||||||
|
{
|
||||||
auto newIndex = createIndex(i, 0, nullptr);
|
auto newIndex = createIndex(i, 0, nullptr);
|
||||||
if(m_items.at(i)->getIsActive())
|
if(m_items.at(i)->getIsActive())
|
||||||
{
|
{
|
||||||
m_items.at(i)->setIsActive(false);
|
m_items.at(i)->setIsActive(false);
|
||||||
dataChanged(newIndex, newIndex, QVector<int>(ModelRole::Active));
|
dataChanged(newIndex, newIndex, QVector<int>(ModelRole::Active));
|
||||||
|
|
||||||
}
|
}
|
||||||
if(m_items.at(i)->getId() == Id)
|
if(m_items.at(i)->getId() == Id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QPointer>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
#include "section_item.h"
|
#include "section_item.h"
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "item.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "item.h"
|
|
||||||
|
|
||||||
namespace Modules
|
namespace Modules
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "item.h"
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include "item.h"
|
|
||||||
|
|
||||||
namespace Modules
|
namespace Modules
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
// TODO: merge with constants from backend/
|
// TODO: merge with constants from backend/
|
||||||
|
|
||||||
|
|
||||||
QString Constants::applicationPath(QString path)
|
QString Constants::applicationPath(QString path)
|
||||||
{
|
{
|
||||||
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + path).absoluteFilePath();
|
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + path).absoluteFilePath();
|
||||||
|
@ -21,4 +20,3 @@ QString Constants::cachePath(QString path)
|
||||||
{
|
{
|
||||||
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + path).absoluteFilePath();
|
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + path).absoluteFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
namespace Accounts
|
namespace Accounts
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,6 @@ const QString Websocket = "websocket";
|
||||||
const QString DefaultNetworkName = "mainnet_rpc";
|
const QString DefaultNetworkName = "mainnet_rpc";
|
||||||
//const DEFAULT_NETWORKS_IDS* = @["mainnet_rpc", "testnet_rpc", "rinkeby_rpc", "goerli_rpc", "xdai_rpc", "poa_rpc" ]
|
//const DEFAULT_NETWORKS_IDS* = @["mainnet_rpc", "testnet_rpc", "rinkeby_rpc", "goerli_rpc", "xdai_rpc", "poa_rpc" ]
|
||||||
|
|
||||||
|
|
||||||
const QString DataDir = "/data";
|
const QString DataDir = "/data";
|
||||||
const QString Keystore = "/data/keystore";
|
const QString Keystore = "/data/keystore";
|
||||||
|
|
||||||
|
@ -36,5 +35,4 @@ QString applicationPath(QString path = "");
|
||||||
QString tmpPath(QString path = "");
|
QString tmpPath(QString path = "");
|
||||||
QString cachePath(QString path = "");
|
QString cachePath(QString path = "");
|
||||||
|
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
|
|
|
@ -2,38 +2,48 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
const std::array phrases{
|
const std::array phrases{
|
||||||
"area", "army", "atom", "aunt", "babe", "baby", "back", "bail", "bait", "bake", "ball", "band", "bank", "barn", "base", "bass", "bath", "bead",
|
"area", "army", "atom", "aunt", "babe", "baby", "back", "bail", "bait", "bake", "ball", "band", "bank", "barn",
|
||||||
"beak", "beam", "bean", "bear", "beat", "beef", "beer", "beet", "bell", "belt", "bend", "bike", "bill", "bird", "bite", "blow", "blue", "boar",
|
"base", "bass", "bath", "bead", "beak", "beam", "bean", "bear", "beat", "beef", "beer", "beet", "bell", "belt",
|
||||||
"boat", "body", "bolt", "bomb", "bone", "book", "boot", "bore", "boss", "bowl", "brow", "bulb", "bull", "burn", "bush", "bust", "cafe", "cake",
|
"bend", "bike", "bill", "bird", "bite", "blow", "blue", "boar", "boat", "body", "bolt", "bomb", "bone", "book",
|
||||||
"calf", "call", "calm", "camp", "cane", "cape", "card", "care", "carp", "cart", "case", "cash", "cast", "cave", "cell", "cent", "chap", "chef",
|
"boot", "bore", "boss", "bowl", "brow", "bulb", "bull", "burn", "bush", "bust", "cafe", "cake", "calf", "call",
|
||||||
"chin", "chip", "chop", "chub", "chug", "city", "clam", "clef", "clip", "club", "clue", "coal", "coat", "code", "coil", "coin", "coke", "cold",
|
"calm", "camp", "cane", "cape", "card", "care", "carp", "cart", "case", "cash", "cast", "cave", "cell", "cent",
|
||||||
"colt", "comb", "cone", "cook", "cope", "copy", "cord", "cork", "corn", "cost", "crab", "craw", "crew", "crib", "crop", "crow", "curl", "cyst",
|
"chap", "chef", "chin", "chip", "chop", "chub", "chug", "city", "clam", "clef", "clip", "club", "clue", "coal",
|
||||||
"dame", "dare", "dark", "dart", "dash", "data", "date", "dead", "deal", "dear", "debt", "deck", "deep", "deer", "desk", "dhow", "diet", "dill",
|
"coat", "code", "coil", "coin", "coke", "cold", "colt", "comb", "cone", "cook", "cope", "copy", "cord", "cork",
|
||||||
"dime", "dirt", "dish", "disk", "dock", "doll", "door", "dory", "drag", "draw", "drop", "drug", "drum", "duck", "dump", "dust", "duty", "ease",
|
"corn", "cost", "crab", "craw", "crew", "crib", "crop", "crow", "curl", "cyst", "dame", "dare", "dark", "dart",
|
||||||
"east", "eave", "eddy", "edge", "envy", "epee", "exam", "exit", "face", "fact", "fail", "fall", "fame", "fang", "farm", "fawn", "fear", "feed",
|
"dash", "data", "date", "dead", "deal", "dear", "debt", "deck", "deep", "deer", "desk", "dhow", "diet", "dill",
|
||||||
"feel", "feet", "file", "fill", "film", "find", "fine", "fire", "fish", "flag", "flat", "flax", "flow", "foam", "fold", "font", "food", "foot",
|
"dime", "dirt", "dish", "disk", "dock", "doll", "door", "dory", "drag", "draw", "drop", "drug", "drum", "duck",
|
||||||
"fork", "form", "fort", "fowl", "frog", "fuel", "full", "gain", "gale", "galn", "game", "garb", "gate", "gear", "gene", "gift", "girl", "give",
|
"dump", "dust", "duty", "ease", "east", "eave", "eddy", "edge", "envy", "epee", "exam", "exit", "face", "fact",
|
||||||
"glad", "glen", "glue", "glut", "goal", "goat", "gold", "golf", "gong", "good", "gown", "grab", "gram", "gray", "grey", "grip", "grit", "gyro",
|
"fail", "fall", "fame", "fang", "farm", "fawn", "fear", "feed", "feel", "feet", "file", "fill", "film", "find",
|
||||||
"hail", "hair", "half", "hall", "hand", "hang", "harm", "harp", "hate", "hawk", "head", "heat", "heel", "hell", "helo", "help", "hemp", "herb",
|
"fine", "fire", "fish", "flag", "flat", "flax", "flow", "foam", "fold", "font", "food", "foot", "fork", "form",
|
||||||
"hide", "high", "hill", "hire", "hive", "hold", "hole", "home", "hood", "hoof", "hook", "hope", "hops", "horn", "hose", "host", "hour", "hunt",
|
"fort", "fowl", "frog", "fuel", "full", "gain", "gale", "galn", "game", "garb", "gate", "gear", "gene", "gift",
|
||||||
"hurt", "icon", "idea", "inch", "iris", "iron", "item", "jail", "jeep", "jeff", "joey", "join", "joke", "judo", "jump", "junk", "jury", "jute",
|
"girl", "give", "glad", "glen", "glue", "glut", "goal", "goat", "gold", "golf", "gong", "good", "gown", "grab",
|
||||||
"kale", "keep", "kick", "kill", "kilt", "kind", "king", "kiss", "kite", "knee", "knot", "lace", "lack", "lady", "lake", "lamb", "lamp", "land",
|
"gram", "gray", "grey", "grip", "grit", "gyro", "hail", "hair", "half", "hall", "hand", "hang", "harm", "harp",
|
||||||
"lark", "lava", "lawn", "lead", "leaf", "leek", "lier", "life", "lift", "lily", "limo", "line", "link", "lion", "lisa", "list", "load", "loaf",
|
"hate", "hawk", "head", "heat", "heel", "hell", "helo", "help", "hemp", "herb", "hide", "high", "hill", "hire",
|
||||||
"loan", "lock", "loft", "long", "look", "loss", "lout", "love", "luck", "lung", "lute", "lynx", "lyre", "maid", "mail", "main", "make", "male",
|
"hive", "hold", "hole", "home", "hood", "hoof", "hook", "hope", "hops", "horn", "hose", "host", "hour", "hunt",
|
||||||
"mall", "manx", "many", "mare", "mark", "mask", "mass", "mate", "math", "meal", "meat", "meet", "menu", "mess", "mice", "midi", "mile", "milk",
|
"hurt", "icon", "idea", "inch", "iris", "iron", "item", "jail", "jeep", "jeff", "joey", "join", "joke", "judo",
|
||||||
"mime", "mind", "mine", "mini", "mint", "miss", "mist", "moat", "mode", "mole", "mood", "moon", "most", "moth", "move", "mule", "mutt", "nail",
|
"jump", "junk", "jury", "jute", "kale", "keep", "kick", "kill", "kilt", "kind", "king", "kiss", "kite", "knee",
|
||||||
"name", "neat", "neck", "need", "neon", "nest", "news", "node", "nose", "note", "oboe", "okra", "open", "oval", "oven", "oxen", "pace", "pack",
|
"knot", "lace", "lack", "lady", "lake", "lamb", "lamp", "land", "lark", "lava", "lawn", "lead", "leaf", "leek",
|
||||||
"page", "pail", "pain", "pair", "palm", "pard", "park", "part", "pass", "past", "path", "peak", "pear", "peen", "peer", "pelt", "perp", "pest",
|
"lier", "life", "lift", "lily", "limo", "line", "link", "lion", "lisa", "list", "load", "loaf", "loan", "lock",
|
||||||
"pick", "pier", "pike", "pile", "pimp", "pine", "ping", "pink", "pint", "pipe", "piss", "pith", "plan", "play", "plot", "plow", "poem", "poet",
|
"loft", "long", "look", "loss", "lout", "love", "luck", "lung", "lute", "lynx", "lyre", "maid", "mail", "main",
|
||||||
"pole", "polo", "pond", "pony", "poof", "pool", "port", "post", "prow", "pull", "puma", "pump", "pupa", "push", "quit", "race", "rack", "raft",
|
"make", "male", "mall", "manx", "many", "mare", "mark", "mask", "mass", "mate", "math", "meal", "meat", "meet",
|
||||||
"rage", "rail", "rain", "rake", "rank", "rate", "read", "rear", "reef", "rent", "rest", "rice", "rich", "ride", "ring", "rise", "risk", "road",
|
"menu", "mess", "mice", "midi", "mile", "milk", "mime", "mind", "mine", "mini", "mint", "miss", "mist", "moat",
|
||||||
"robe", "rock", "role", "roll", "roof", "room", "root", "rope", "rose", "ruin", "rule", "rush", "ruth", "sack", "safe", "sage", "sail", "sale",
|
"mode", "mole", "mood", "moon", "most", "moth", "move", "mule", "mutt", "nail", "name", "neat", "neck", "need",
|
||||||
"salt", "sand", "sari", "sash", "save", "scow", "seal", "seat", "seed", "self", "sell", "shed", "shin", "ship", "shoe", "shop", "shot", "show",
|
"neon", "nest", "news", "node", "nose", "note", "oboe", "okra", "open", "oval", "oven", "oxen", "pace", "pack",
|
||||||
"sick", "side", "sign", "silk", "sill", "silo", "sing", "sink", "site", "size", "skin", "sled", "slip", "smog", "snob", "snow", "soap", "sock",
|
"page", "pail", "pain", "pair", "palm", "pard", "park", "part", "pass", "past", "path", "peak", "pear", "peen",
|
||||||
"soda", "sofa", "soft", "soil", "song", "soot", "sort", "soup", "spot", "spur", "stag", "star", "stay", "stem", "step", "stew", "stop", "stud",
|
"peer", "pelt", "perp", "pest", "pick", "pier", "pike", "pile", "pimp", "pine", "ping", "pink", "pint", "pipe",
|
||||||
"suck", "suit", "swan", "swim", "tail", "tale", "talk", "tank", "tard", "task", "taxi", "team", "tear", "teen", "tell", "temp", "tent", "term",
|
"piss", "pith", "plan", "play", "plot", "plow", "poem", "poet", "pole", "polo", "pond", "pony", "poof", "pool",
|
||||||
"test", "text", "thaw", "tile", "till", "time", "tire", "toad", "toga", "togs", "tone", "tool", "toot", "tote", "tour", "town", "tram", "tray",
|
"port", "post", "prow", "pull", "puma", "pump", "pupa", "push", "quit", "race", "rack", "raft", "rage", "rail",
|
||||||
"tree", "trim", "trip", "tuba", "tube", "tuna", "tune", "turn", "tutu", "twig", "type", "unit", "user", "vane", "vase", "vast", "veal", "veil",
|
"rain", "rake", "rank", "rate", "read", "rear", "reef", "rent", "rest", "rice", "rich", "ride", "ring", "rise",
|
||||||
"vein", "vest", "vibe", "view", "vise", "wait", "wake", "walk", "wall", "wash", "wasp", "wave", "wear", "weed", "week", "well", "west", "whip",
|
"risk", "road", "robe", "rock", "role", "roll", "roof", "room", "root", "rope", "rose", "ruin", "rule", "rush",
|
||||||
"wife", "will", "wind", "wine", "wing", "wire", "wish", "wolf", "wood", "wool", "word", "work", "worm", "wrap", "wren", "yard", "yarn", "yawl",
|
"ruth", "sack", "safe", "sage", "sail", "sale", "salt", "sand", "sari", "sash", "save", "scow", "seal", "seat",
|
||||||
"year", "yoga", "yoke", "yurt", "zinc", "zone"};
|
"seed", "self", "sell", "shed", "shin", "ship", "shoe", "shop", "shot", "show", "sick", "side", "sign", "silk",
|
||||||
|
"sill", "silo", "sing", "sink", "site", "size", "skin", "sled", "slip", "smog", "snob", "snow", "soap", "sock",
|
||||||
|
"soda", "sofa", "soft", "soil", "song", "soot", "sort", "soup", "spot", "spur", "stag", "star", "stay", "stem",
|
||||||
|
"step", "stew", "stop", "stud", "suck", "suit", "swan", "swim", "tail", "tale", "talk", "tank", "tard", "task",
|
||||||
|
"taxi", "team", "tear", "teen", "tell", "temp", "tent", "term", "test", "text", "thaw", "tile", "till", "time",
|
||||||
|
"tire", "toad", "toga", "togs", "tone", "tool", "toot", "tote", "tour", "town", "tram", "tray", "tree", "trim",
|
||||||
|
"trip", "tuba", "tube", "tuna", "tune", "turn", "tutu", "twig", "type", "unit", "user", "vane", "vase", "vast",
|
||||||
|
"veal", "veil", "vein", "vest", "vibe", "view", "vise", "wait", "wake", "walk", "wall", "wash", "wasp", "wave",
|
||||||
|
"wear", "weed", "week", "well", "west", "whip", "wife", "will", "wind", "wine", "wing", "wire", "wish", "wolf",
|
||||||
|
"wood", "wool", "word", "work", "worm", "wrap", "wren", "yard", "yarn", "yawl", "year", "yoga", "yoke", "yurt",
|
||||||
|
"zinc", "zone"};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef WALLETACCOUNTSSERVICE_H
|
#ifndef WALLETACCOUNTSSERVICE_H
|
||||||
#define WALLETACCOUNTSSERVICE_H
|
#define WALLETACCOUNTSSERVICE_H
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include "wallet_account.h"
|
|
||||||
#include "service_interface.h"
|
#include "service_interface.h"
|
||||||
|
#include "wallet_account.h"
|
||||||
|
|
||||||
namespace Wallets
|
namespace Wallets
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef WALLETACCOUNTDTO_H
|
#ifndef WALLETACCOUNTDTO_H
|
||||||
#define WALLETACCOUNTDTO_H
|
#define WALLETACCOUNTDTO_H
|
||||||
|
|
||||||
|
#include "wallet_token.h"
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include "wallet_token.h"
|
|
||||||
|
|
||||||
namespace Wallets
|
namespace Wallets
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,6 @@ WalletAccountDto toWalletAccountDto(const QJsonValue jsonObj);
|
||||||
//WalletAccountDto getCurrencyBalance*(): float =
|
//WalletAccountDto getCurrencyBalance*(): float =
|
||||||
// return self.tokens.map(t => t.currencyBalance).foldl(a + b, 0.0)
|
// return self.tokens.map(t => t.currencyBalance).foldl(a + b, 0.0)
|
||||||
|
|
||||||
} // namespace Wallet
|
} // namespace Wallets
|
||||||
|
|
||||||
#endif // WALLETACCOUNTDTO_H
|
#endif // WALLETACCOUNTDTO_H
|
||||||
|
|
|
@ -21,6 +21,6 @@ public:
|
||||||
float currencyBalance;
|
float currencyBalance;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Wallet
|
} // namespace Wallets
|
||||||
|
|
||||||
#endif // WALLETTOKENDTO_H
|
#endif // WALLETTOKENDTO_H
|
||||||
|
|
|
@ -26,8 +26,7 @@ void Service::fetchAccounts()
|
||||||
foreach(const QJsonValue& value, response.m_result)
|
foreach(const QJsonValue& value, response.m_result)
|
||||||
{
|
{
|
||||||
auto account = toWalletAccountDto(value);
|
auto account = toWalletAccountDto(value);
|
||||||
if(!account.isChat)
|
if(!account.isChat) m_walletAccounts[account.address] = account;
|
||||||
m_walletAccounts[account.address] = account;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Backend::RpcException& e)
|
catch(Backend::RpcException& e)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#include "backend/accounts.h"
|
#include "backend/accounts.h"
|
||||||
#include "backend/types.h"
|
#include "backend/types.h"
|
||||||
#include "backend/utils.h"
|
#include "backend/utils.h"
|
||||||
|
#include "libstatus.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include "libstatus.h"
|
|
||||||
|
|
||||||
const int NUMBER_OF_ADDRESSES_TO_GENERATE = 5;
|
const int NUMBER_OF_ADDRESSES_TO_GENERATE = 5;
|
||||||
const int MNEMONIC_PHRASE_LENGTH = 12;
|
const int MNEMONIC_PHRASE_LENGTH = 12;
|
||||||
|
|
|
@ -16,6 +16,7 @@ struct RpcException : public std::exception
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string m_message;
|
std::string m_message;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RpcException(const std::string& message);
|
explicit RpcException(const std::string& message);
|
||||||
const char* what() const throw();
|
const char* what() const throw();
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
namespace Backend::Wallet::Accounts
|
namespace Backend::Wallet::Accounts
|
||||||
{
|
{
|
||||||
Backend::RpcResponse<QJsonArray> getAccounts();
|
Backend::RpcResponse<QJsonArray> getAccounts();
|
||||||
} // Backend::Wallet::Accounts
|
} // namespace Backend::Wallet::Accounts
|
||||||
|
|
||||||
#endif // WALLETACCOUNT_BACKEND_H
|
#endif // WALLETACCOUNT_BACKEND_H
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "backend/utils.h"
|
#include "backend/utils.h"
|
||||||
#include "backend/types.h"
|
#include "backend/types.h"
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
#include <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
QJsonArray Backend::Utils::toJsonArray(const QVector<QString>& value)
|
QJsonArray Backend::Utils::toJsonArray(const QVector<QString>& value)
|
||||||
{
|
{
|
||||||
|
@ -43,8 +43,10 @@ QString Backend::Utils::hashString(QString str)
|
||||||
return "0x" + QString::fromUtf8(QCryptographicHash::hash(str.toUtf8(), QCryptographicHash::Keccak_256).toHex());
|
return "0x" + QString::fromUtf8(QCryptographicHash::hash(str.toUtf8(), QCryptographicHash::Keccak_256).toHex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend::Utils::throwOnError(QJsonObject response) {
|
void Backend::Utils::throwOnError(QJsonObject response)
|
||||||
if(!response["error"].isUndefined() && !response["error"].toString().isEmpty()){
|
{
|
||||||
|
if(!response["error"].isUndefined() && !response["error"].toString().isEmpty())
|
||||||
|
{
|
||||||
qWarning() << "RpcException: " << response["error"].toString();
|
qWarning() << "RpcException: " << response["error"].toString();
|
||||||
throw Backend::RpcException(response["error"].toString().toStdString());
|
throw Backend::RpcException(response["error"].toString().toStdString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include "backend/wallet_accounts.h"
|
|
||||||
#include "backend/types.h"
|
#include "backend/types.h"
|
||||||
#include "backend/utils.h"
|
#include "backend/utils.h"
|
||||||
|
#include "backend/wallet_accounts.h"
|
||||||
#include "libstatus.h"
|
#include "libstatus.h"
|
||||||
|
|
||||||
namespace Backend::Wallet::Accounts
|
namespace Backend::Wallet::Accounts
|
||||||
|
@ -16,6 +16,4 @@ RpcResponse<QJsonArray> getAccounts()
|
||||||
return RpcResponse<QJsonArray>(result, QJsonDocument::fromJson(result)["result"].toArray());
|
return RpcResponse<QJsonArray>(result, QJsonDocument::fromJson(result)["result"].toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Backend::Wallet::Accounts
|
} // namespace Backend::Wallet::Accounts
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
// TODO: merge with constants from backend/
|
// TODO: merge with constants from backend/
|
||||||
|
|
||||||
|
|
||||||
QString Constants::applicationPath(QString path)
|
QString Constants::applicationPath(QString path)
|
||||||
{
|
{
|
||||||
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + path).absoluteFilePath();
|
return QFileInfo(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + path).absoluteFilePath();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class DOtherSide {
|
class DOtherSide
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
static void registerMetaTypes();
|
static void registerMetaTypes();
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,5 +28,4 @@ private:
|
||||||
QLocalServer* m_localServer;
|
QLocalServer* m_localServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SINGLEINSTANCE_H
|
#endif // SINGLEINSTANCE_H
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
# include "hunspell/hunspell.hxx"
|
# include "hunspell/hunspell.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QTextCodec>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFile>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
#include <QRegularExpression>
|
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include <QInputMethod>
|
#include <QInputMethod>
|
||||||
|
|
||||||
|
@ -21,9 +21,7 @@ SpellChecker::SpellChecker(QObject *parent)
|
||||||
, m_hunspell(nullptr)
|
, m_hunspell(nullptr)
|
||||||
#endif
|
#endif
|
||||||
, m_userDict("userDict_")
|
, m_userDict("userDict_")
|
||||||
{
|
{ }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SpellChecker::~SpellChecker()
|
SpellChecker::~SpellChecker()
|
||||||
{
|
{
|
||||||
|
@ -53,7 +51,8 @@ bool SpellChecker::isInit() const
|
||||||
void SpellChecker::initHunspell()
|
void SpellChecker::initHunspell()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
if (m_hunspell) {
|
if(m_hunspell)
|
||||||
|
{
|
||||||
delete m_hunspell;
|
delete m_hunspell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,24 +60,28 @@ void SpellChecker::initHunspell()
|
||||||
QString affixFile = QGuiApplication::applicationDirPath() + "/dictionaries/" + m_lang + "/index.aff";
|
QString affixFile = QGuiApplication::applicationDirPath() + "/dictionaries/" + m_lang + "/index.aff";
|
||||||
QByteArray dictFilePathBA = dictFile.toLocal8Bit();
|
QByteArray dictFilePathBA = dictFile.toLocal8Bit();
|
||||||
QByteArray affixFilePathBA = affixFile.toLocal8Bit();
|
QByteArray affixFilePathBA = affixFile.toLocal8Bit();
|
||||||
m_hunspell = new Hunspell(affixFilePathBA.constData(),
|
m_hunspell = new Hunspell(affixFilePathBA.constData(), dictFilePathBA.constData());
|
||||||
dictFilePathBA.constData());
|
|
||||||
|
|
||||||
// detect encoding analyzing the SET option in the affix file
|
// detect encoding analyzing the SET option in the affix file
|
||||||
auto encoding = QStringLiteral("ISO8859-15");
|
auto encoding = QStringLiteral("ISO8859-15");
|
||||||
QFile _affixFile(affixFile);
|
QFile _affixFile(affixFile);
|
||||||
if (_affixFile.open(QIODevice::ReadOnly)) {
|
if(_affixFile.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
QTextStream stream(&_affixFile);
|
QTextStream stream(&_affixFile);
|
||||||
QRegularExpression enc_detector(
|
QRegularExpression enc_detector(QStringLiteral("^\\s*SET\\s+([A-Z0-9\\-]+)\\s*"),
|
||||||
QStringLiteral("^\\s*SET\\s+([A-Z0-9\\-]+)\\s*"),
|
|
||||||
QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
QString sLine;
|
QString sLine;
|
||||||
QRegularExpressionMatch match;
|
QRegularExpressionMatch match;
|
||||||
while (!stream.atEnd()) {
|
while(!stream.atEnd())
|
||||||
|
{
|
||||||
sLine = stream.readLine();
|
sLine = stream.readLine();
|
||||||
if (sLine.isEmpty()) { continue; }
|
if(sLine.isEmpty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
match = enc_detector.match(sLine);
|
match = enc_detector.match(sLine);
|
||||||
if (match.hasMatch()) {
|
if(match.hasMatch())
|
||||||
|
{
|
||||||
encoding = match.captured(1);
|
encoding = match.captured(1);
|
||||||
qDebug() << "Encoding set to " + encoding;
|
qDebug() << "Encoding set to " + encoding;
|
||||||
break;
|
break;
|
||||||
|
@ -90,20 +93,23 @@ void SpellChecker::initHunspell()
|
||||||
|
|
||||||
QString userDict = m_userDict + m_lang + ".txt";
|
QString userDict = m_userDict + m_lang + ".txt";
|
||||||
|
|
||||||
if (!userDict.isEmpty()) {
|
if(!userDict.isEmpty())
|
||||||
|
{
|
||||||
QFile userDictonaryFile(userDict);
|
QFile userDictonaryFile(userDict);
|
||||||
if (userDictonaryFile.open(QIODevice::ReadOnly)) {
|
if(userDictonaryFile.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
QTextStream stream(&userDictonaryFile);
|
QTextStream stream(&userDictonaryFile);
|
||||||
for (QString word = stream.readLine();
|
for(QString word = stream.readLine(); !word.isEmpty(); word = stream.readLine())
|
||||||
!word.isEmpty();
|
|
||||||
word = stream.readLine())
|
|
||||||
ignoreWord(word);
|
ignoreWord(word);
|
||||||
userDictonaryFile.close();
|
userDictonaryFile.close();
|
||||||
} else {
|
|
||||||
qWarning() << "User dictionary in " << userDict
|
|
||||||
<< "could not be opened";
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "User dictionary in " << userDict << "could not be opened";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
qDebug() << "User dictionary not set.";
|
qDebug() << "User dictionary not set.";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -118,11 +124,12 @@ QVariantList SpellChecker::suggest(const QString &word)
|
||||||
wordlist = m_hunspell->suggest(m_codec->fromUnicode(word).toStdString());
|
wordlist = m_hunspell->suggest(m_codec->fromUnicode(word).toStdString());
|
||||||
|
|
||||||
numSuggestions = static_cast<int>(wordlist.size());
|
numSuggestions = static_cast<int>(wordlist.size());
|
||||||
if (numSuggestions > 0) {
|
if(numSuggestions > 0)
|
||||||
|
{
|
||||||
suggestions.reserve(numSuggestions);
|
suggestions.reserve(numSuggestions);
|
||||||
for (int i = 0; i < numSuggestions; i++) {
|
for(int i = 0; i < numSuggestions; i++)
|
||||||
suggestions << m_codec->toUnicode(
|
{
|
||||||
QByteArray::fromStdString(wordlist[i]));
|
suggestions << m_codec->toUnicode(QByteArray::fromStdString(wordlist[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -141,17 +148,22 @@ void SpellChecker::addToUserWordlist(const QString &word)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
QString userDict = m_userDict + m_lang + ".txt";
|
QString userDict = m_userDict + m_lang + ".txt";
|
||||||
if (!userDict.isEmpty()) {
|
if(!userDict.isEmpty())
|
||||||
|
{
|
||||||
QFile userDictonaryFile(userDict);
|
QFile userDictonaryFile(userDict);
|
||||||
if (userDictonaryFile.open(QIODevice::Append)) {
|
if(userDictonaryFile.open(QIODevice::Append))
|
||||||
|
{
|
||||||
QTextStream stream(&userDictonaryFile);
|
QTextStream stream(&userDictonaryFile);
|
||||||
stream << word << "\n";
|
stream << word << "\n";
|
||||||
userDictonaryFile.close();
|
userDictonaryFile.close();
|
||||||
} else {
|
|
||||||
qWarning() << "User dictionary in " << userDict
|
|
||||||
<< "could not be opened for appending a new word";
|
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "User dictionary in " << userDict << "could not be opened for appending a new word";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
qDebug() << "User dictionary not set.";
|
qDebug() << "User dictionary not set.";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -164,7 +176,8 @@ const QString& SpellChecker::lang() const
|
||||||
|
|
||||||
void SpellChecker::setLang(const QString& lang)
|
void SpellChecker::setLang(const QString& lang)
|
||||||
{
|
{
|
||||||
if (m_lang != lang) {
|
if(m_lang != lang)
|
||||||
|
{
|
||||||
m_lang = lang;
|
m_lang = lang;
|
||||||
initHunspell();
|
initHunspell();
|
||||||
emit langChanged();
|
emit langChanged();
|
||||||
|
@ -178,7 +191,8 @@ const QString& SpellChecker::userDict() const
|
||||||
|
|
||||||
void SpellChecker::setUserDict(const QString& userDict)
|
void SpellChecker::setUserDict(const QString& userDict)
|
||||||
{
|
{
|
||||||
if (m_userDict != userDict) {
|
if(m_userDict != userDict)
|
||||||
|
{
|
||||||
m_userDict = userDict;
|
m_userDict = userDict;
|
||||||
emit userDictChanged();
|
emit userDictChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
|
||||||
#include <QQuickTextDocument>
|
#include <QQuickTextDocument>
|
||||||
#include <QSyntaxHighlighter>
|
#include <QSyntaxHighlighter>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
class Hunspell;
|
class Hunspell;
|
||||||
|
|
|
@ -44,9 +44,11 @@ StatusSyntaxHighlighter::StatusSyntaxHighlighter(QTextDocument *parent)
|
||||||
|
|
||||||
void StatusSyntaxHighlighter::highlightBlock(const QString& text)
|
void StatusSyntaxHighlighter::highlightBlock(const QString& text)
|
||||||
{
|
{
|
||||||
for (const HighlightingRule &rule : qAsConst(highlightingRules)) {
|
for(const HighlightingRule& rule : qAsConst(highlightingRules))
|
||||||
|
{
|
||||||
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
|
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
|
||||||
while (matchIterator.hasNext()) {
|
while(matchIterator.hasNext())
|
||||||
|
{
|
||||||
QRegularExpressionMatch match = matchIterator.next();
|
QRegularExpressionMatch match = matchIterator.next();
|
||||||
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
|
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
|
||||||
}
|
}
|
||||||
|
@ -54,14 +56,16 @@ void StatusSyntaxHighlighter::highlightBlock(const QString &text)
|
||||||
setCurrentBlockState(0);
|
setCurrentBlockState(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QQuickTextDocument *StatusSyntaxHighlighterHelper::quickTextDocument() const {
|
QQuickTextDocument* StatusSyntaxHighlighterHelper::quickTextDocument() const
|
||||||
|
{
|
||||||
return m_quicktextdocument;
|
return m_quicktextdocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusSyntaxHighlighterHelper::setQuickTextDocument(
|
void StatusSyntaxHighlighterHelper::setQuickTextDocument(QQuickTextDocument* quickTextDocument)
|
||||||
QQuickTextDocument *quickTextDocument) {
|
{
|
||||||
m_quicktextdocument = quickTextDocument;
|
m_quicktextdocument = quickTextDocument;
|
||||||
if (m_quicktextdocument) {
|
if(m_quicktextdocument)
|
||||||
|
{
|
||||||
new StatusSyntaxHighlighter(m_quicktextdocument->textDocument());
|
new StatusSyntaxHighlighter(m_quicktextdocument->textDocument());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QSyntaxHighlighter>
|
#include <QSyntaxHighlighter>
|
||||||
#include <QTextCharFormat>
|
#include <QTextCharFormat>
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
class QQuickTextDocument;
|
class QQuickTextDocument;
|
||||||
|
|
||||||
|
@ -31,13 +31,16 @@ private:
|
||||||
QTextCharFormat multiLineCodeBlockFormat;
|
QTextCharFormat multiLineCodeBlockFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StatusSyntaxHighlighterHelper : public QObject {
|
class StatusSyntaxHighlighterHelper : public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QQuickTextDocument *quickTextDocument READ quickTextDocument WRITE
|
Q_PROPERTY(QQuickTextDocument* quickTextDocument READ quickTextDocument WRITE setQuickTextDocument NOTIFY
|
||||||
setQuickTextDocument NOTIFY quickTextDocumentChanged)
|
quickTextDocumentChanged)
|
||||||
public:
|
public:
|
||||||
StatusSyntaxHighlighterHelper(QObject* parent = nullptr)
|
StatusSyntaxHighlighterHelper(QObject* parent = nullptr)
|
||||||
: QObject(parent), m_quicktextdocument(nullptr) {}
|
: QObject(parent)
|
||||||
|
, m_quicktextdocument(nullptr)
|
||||||
|
{ }
|
||||||
QQuickTextDocument* quickTextDocument() const;
|
QQuickTextDocument* quickTextDocument() const;
|
||||||
void setQuickTextDocument(QQuickTextDocument* quickTextDocument);
|
void setQuickTextDocument(QQuickTextDocument* quickTextDocument);
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
#include "StatusWindow.h"
|
#include "StatusWindow.h"
|
||||||
|
|
||||||
StatusWindow::StatusWindow(QWindow* parent)
|
StatusWindow::StatusWindow(QWindow* parent)
|
||||||
: QQuickWindow(parent),
|
: QQuickWindow(parent)
|
||||||
m_isFullScreen(false)
|
, m_isFullScreen(false)
|
||||||
{
|
{
|
||||||
removeTitleBar();
|
removeTitleBar();
|
||||||
|
|
||||||
connect(this, &QQuickWindow::windowStateChanged, [&](Qt::WindowState windowState) {
|
connect(this, &QQuickWindow::windowStateChanged, [&](Qt::WindowState windowState) {
|
||||||
if (windowState == Qt::WindowNoState) {
|
if(windowState == Qt::WindowNoState)
|
||||||
|
{
|
||||||
removeTitleBar();
|
removeTitleBar();
|
||||||
m_isFullScreen = false;
|
m_isFullScreen = false;
|
||||||
emit isFullScreenChanged();
|
emit isFullScreenChanged();
|
||||||
} else if (windowState == Qt::WindowFullScreen) {
|
}
|
||||||
|
else if(windowState == Qt::WindowFullScreen)
|
||||||
|
{
|
||||||
m_isFullScreen = true;
|
m_isFullScreen = true;
|
||||||
emit isFullScreenChanged();
|
emit isFullScreenChanged();
|
||||||
showTitleBar();
|
showTitleBar();
|
||||||
|
@ -21,9 +24,12 @@ StatusWindow::StatusWindow(QWindow *parent)
|
||||||
|
|
||||||
void StatusWindow::toggleFullScreen()
|
void StatusWindow::toggleFullScreen()
|
||||||
{
|
{
|
||||||
if (m_isFullScreen) {
|
if(m_isFullScreen)
|
||||||
|
{
|
||||||
showNormal();
|
showNormal();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
showFullScreen();
|
showFullScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,16 +10,18 @@ class StatusWindow: public QQuickWindow
|
||||||
Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged)
|
Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit StatusWindow(QWindow* parent = nullptr);
|
explicit StatusWindow(QWindow* parent = nullptr);
|
||||||
|
|
||||||
Q_INVOKABLE void toggleFullScreen();
|
Q_INVOKABLE void toggleFullScreen();
|
||||||
|
|
||||||
bool isFullScreen() const;
|
bool isFullScreen() const;
|
||||||
|
|
||||||
Q_INVOKABLE void updatePosition() {
|
Q_INVOKABLE void updatePosition()
|
||||||
auto point = QPoint(screen()->geometry().center().x() - geometry().width() / 2, screen()->geometry().center().y() - geometry().height() / 2);
|
{
|
||||||
if (point != this->position()) {
|
auto point = QPoint(screen()->geometry().center().x() - geometry().width() / 2,
|
||||||
|
screen()->geometry().center().y() - geometry().height() / 2);
|
||||||
|
if(point != this->position())
|
||||||
|
{
|
||||||
this->setPosition(point);
|
this->setPosition(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,4 +38,3 @@ private:
|
||||||
private:
|
private:
|
||||||
bool m_isFullScreen;
|
bool m_isFullScreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#include "StatusWindow.h"
|
#include "StatusWindow.h"
|
||||||
|
|
||||||
void StatusWindow::removeTitleBar()
|
void StatusWindow::removeTitleBar() { }
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void StatusWindow::showTitleBar() { }
|
||||||
|
|
||||||
void StatusWindow::showTitleBar()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,7 +6,9 @@ void logFormatter(QtMsgType type, const QMessageLogContext& context, const QStri
|
||||||
{
|
{
|
||||||
QByteArray localMsg = msg.toLocal8Bit();
|
QByteArray localMsg = msg.toLocal8Bit();
|
||||||
const char* file = context.file ? context.file : "";
|
const char* file = context.file ? context.file : "";
|
||||||
QByteArray function = context.function ? (QString(QStringLiteral("\033[0;33mfunction=\033[94m") + QString(context.function)).toLocal8Bit())
|
QByteArray function =
|
||||||
|
context.function
|
||||||
|
? (QString(QStringLiteral("\033[0;33mfunction=\033[94m") + QString(context.function)).toLocal8Bit())
|
||||||
: QString("").toLocal8Bit();
|
: QString("").toLocal8Bit();
|
||||||
QByteArray timestamp = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toLocal8Bit();
|
QByteArray timestamp = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toLocal8Bit();
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ int main(int argc, char* argv[])
|
||||||
qRegisterMetaType<Signals::Signal>("Signal");
|
qRegisterMetaType<Signals::Signal>("Signal");
|
||||||
qRegisterMetaType<Signals::NodeSignal>("NodeSignal");
|
qRegisterMetaType<Signals::NodeSignal>("NodeSignal");
|
||||||
|
|
||||||
|
|
||||||
qInfo("starting application controller...");
|
qInfo("starting application controller...");
|
||||||
AppController appController = AppController();
|
AppController appController = AppController();
|
||||||
appController.start();
|
appController.start();
|
||||||
|
|
Loading…
Reference in New Issue