style(@desktop/cpp): apply clang-format on src-cpp/*

This commit is contained in:
Patryk Osmaczko 2022-02-21 19:03:38 +01:00 committed by osmaczko
parent f27fd6ea61
commit 00156cc9c0
111 changed files with 1679 additions and 1630 deletions

View File

@ -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

View File

@ -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()

View File

@ -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;

View File

@ -2,7 +2,7 @@
#include "controller.h" #include "controller.h"
namespace Modules:: Main namespace Modules::Main
{ {
Controller::Controller(QObject* parent) Controller::Controller(QObject* parent)
: QObject(parent) : QObject(parent)

View File

@ -21,4 +21,3 @@ public:
} // namespace Modules::Main } // namespace Modules::Main
#endif // CONTROLLER_H #endif // CONTROLLER_H

View File

@ -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);

View File

@ -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,7 +43,7 @@ Shared::Models::SectionItem* View::getActiveSection()
return m_sectionModelPtr->getActiveItem(); return m_sectionModelPtr->getActiveItem();
} }
void View::setActiveSection(const QString &Id) void View::setActiveSection(const QString& Id)
{ {
if(m_sectionModelPtr->getActiveItem().isNull() || (m_sectionModelPtr->getActiveItem()->getId() != Id)) if(m_sectionModelPtr->getActiveItem().isNull() || (m_sectionModelPtr->getActiveItem()->getId() != Id))
{ {

View File

@ -19,7 +19,7 @@ public:
~View() = default; ~View() = default;
void load(); void load();
void addItem(Shared::Models::SectionItem *item); void addItem(Shared::Models::SectionItem* item);
Shared::Models::SectionModel* getSectionsModel(); Shared::Models::SectionModel* getSectionsModel();
Shared::Models::SectionItem* getActiveSection(); Shared::Models::SectionItem* getActiveSection();
@ -36,4 +36,3 @@ private:
} // namespace Modules::Main } // namespace Modules::Main
#endif // VIEW_H #endif // VIEW_H

View File

@ -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;
} }

View File

@ -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
{ {

View File

@ -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

View File

@ -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;

View File

@ -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());
} }
@ -58,7 +59,7 @@ QVariant Model::data(const QModelIndex& index, int role) const
return QVariant(); return QVariant();
} }
void Model::setItems(QVector<Item> &items) void Model::setItems(QVector<Item>& items)
{ {
beginResetModel(); beginResetModel();
m_items = items; m_items = items;

View File

@ -34,7 +34,7 @@ public:
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex&) const override; int rowCount(const QModelIndex&) const override;
QVariant data(const QModelIndex& index, int role) const override; QVariant data(const QModelIndex& index, int role) const override;
void setItems(QVector<Item> &items); void setItems(QVector<Item>& items);
private: private:
QVector<Item> m_items; QVector<Item> m_items;

View File

@ -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,14 +50,15 @@ 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);
} }
else else
{ {
qWarning()<<"No accounts found!"; qWarning() << "No accounts found!";
} }
} }
} // namespace Modules::Main::Wallet::Accounts } // namespace Modules::Main::Wallet::Accounts

View File

@ -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;

View File

@ -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();
} }

View File

@ -18,7 +18,7 @@ public:
~View() = default; ~View() = default;
void load(); void load();
void setModelItems(QVector<Item> &accounts); void setModelItems(QVector<Item>& accounts);
private: private:
Model* m_modelPtr; Model* m_modelPtr;

View File

@ -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

View File

@ -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
{ {

View File

@ -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);

View File

@ -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;

View File

@ -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()
{ {

View File

@ -21,4 +21,3 @@ signals:
} // namespace Modules::Main::Wallet } // namespace Modules::Main::Wallet
#endif // WALLET_VIEW_H #endif // WALLET_VIEW_H

View File

@ -23,41 +23,40 @@ 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
{ {
return m_sectionType; return m_sectionType;
} }
const QString& SectionItem::getId() const const QString& SectionItem::getId() const
{ {
return m_id; return m_id;
} }
const QString& SectionItem::getName() const const QString& SectionItem::getName() const
{ {
return m_name; return m_name;
} }
@ -67,22 +66,22 @@ bool SectionItem::getAmISectionAdmin() const
return m_amISectionAdmin; return m_amISectionAdmin;
} }
const QString& SectionItem::getDescription() const const QString& SectionItem::getDescription() const
{ {
return m_description; return m_description;
} }
const QString& SectionItem::getImage() const const QString& SectionItem::getImage() const
{ {
return m_image; return m_image;
} }
const QString& SectionItem::getIcon() const const QString& SectionItem::getIcon() const
{ {
return m_icon; return m_icon;
} }
const QString& SectionItem::getColor() const const QString& SectionItem::getColor() const
{ {
return m_color; return m_color;
} }

View File

@ -15,7 +15,7 @@ enum SectionType
ProfileSettings, ProfileSettings,
NodeManagement NodeManagement
}; };
class SectionItem: public QObject class SectionItem : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString id READ getId) Q_PROPERTY(QString id READ getId)

View File

@ -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();
@ -89,18 +90,18 @@ void SectionModel::addItem(SectionItem* item)
endInsertRows(); endInsertRows();
} }
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)
{ {
m_items.at(i)->setIsActive(true); m_items.at(i)->setIsActive(true);
dataChanged(newIndex, newIndex, QVector<int>(ModelRole::Active)); dataChanged(newIndex, newIndex, QVector<int>(ModelRole::Active));

View File

@ -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"
@ -49,7 +49,7 @@ public:
QVariant data(const QModelIndex& index, int role) const override; QVariant data(const QModelIndex& index, int role) const override;
void addItem(SectionItem* item); void addItem(SectionItem* item);
void setActiveSection(const QString &Id); void setActiveSection(const QString& Id);
QPointer<SectionItem> getActiveItem(); QPointer<SectionItem> getActiveItem();
// To add other api's later as needed // To add other api's later as needed

View File

@ -30,7 +30,7 @@ public:
// keychainService // keychainService
Accounts::ServiceInterface* accountsService); Accounts::ServiceInterface* accountsService);
~Module(); ~Module();
void extractImages(Accounts::AccountDto account, QString &thumbnailImage, QString &largeImage); void extractImages(Accounts::AccountDto account, QString& thumbnailImage, QString& largeImage);
void load() override; void load() override;
bool isLoaded() override; bool isLoaded() override;
void viewDidLoad() override; void viewDidLoad() override;

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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();
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <QString>
#include <QJsonDocument> #include <QJsonDocument>
#include <QString>
namespace Accounts namespace Accounts
{ {

View File

@ -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

View File

@ -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"};

View File

@ -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
{ {

View File

@ -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

View File

@ -21,6 +21,6 @@ public:
float currencyBalance; float currencyBalance;
}; };
} // namespace Wallet } // namespace Wallets
#endif // WALLETTOKENDTO_H #endif // WALLETTOKENDTO_H

View File

@ -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)

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -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());
} }

View File

@ -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

View File

@ -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();

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
class DOtherSide { class DOtherSide
public: {
public:
static void registerMetaTypes(); static void registerMetaTypes();
}; };

View File

@ -12,21 +12,20 @@ class SingleInstance : public QObject
public: public:
// uniqueName - the name of named pipe // uniqueName - the name of named pipe
// eventStr - optional event to send if another instance is detected // eventStr - optional event to send if another instance is detected
explicit SingleInstance(const QString &uniqueName, const QString &eventStr, QObject *parent = nullptr); explicit SingleInstance(const QString& uniqueName, const QString& eventStr, QObject* parent = nullptr);
~SingleInstance() override; ~SingleInstance() override;
bool isFirstInstance() const; bool isFirstInstance() const;
signals: signals:
void secondInstanceDetected(); void secondInstanceDetected();
void eventReceived(const QString &eventStr); void eventReceived(const QString& eventStr);
private slots: private slots:
void handleNewConnection(); void handleNewConnection();
private: private:
QLocalServer *m_localServer; QLocalServer* m_localServer;
}; };
#endif // SINGLEINSTANCE_H #endif // SINGLEINSTANCE_H

View File

@ -1,29 +1,27 @@
#include "SpellChecker.h" #include "SpellChecker.h"
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
#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>
SpellChecker::SpellChecker(QObject *parent) SpellChecker::SpellChecker(QObject* parent)
: QObject(parent) : QObject(parent)
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
, m_hunspell(nullptr) , m_hunspell(nullptr)
#endif #endif
, m_userDict("userDict_") , m_userDict("userDict_")
{ { }
}
SpellChecker::~SpellChecker() SpellChecker::~SpellChecker()
{ {
@ -32,7 +30,7 @@ SpellChecker::~SpellChecker()
#endif #endif
} }
bool SpellChecker::spell(const QString &word) bool SpellChecker::spell(const QString& word)
{ {
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
return m_hunspell->spell(m_codec->fromUnicode(word).toStdString()); return m_hunspell->spell(m_codec->fromUnicode(word).toStdString());
@ -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,26 +93,29 @@ 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
} }
QVariantList SpellChecker::suggest(const QString &word) QVariantList SpellChecker::suggest(const QString& word)
{ {
int numSuggestions = 0; int numSuggestions = 0;
QVariantList suggestions; QVariantList suggestions;
@ -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
@ -130,28 +137,33 @@ QVariantList SpellChecker::suggest(const QString &word)
return suggestions; return suggestions;
} }
void SpellChecker::ignoreWord(const QString &word) void SpellChecker::ignoreWord(const QString& word)
{ {
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
m_hunspell->add(m_codec->fromUnicode(word).constData()); m_hunspell->add(m_codec->fromUnicode(word).constData());
#endif #endif
} }
void SpellChecker::addToUserWordlist(const QString &word) 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();
} }

View File

@ -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;
@ -17,13 +17,13 @@ class SpellChecker : public QObject
Q_PROPERTY(QString userDict READ userDict WRITE setUserDict NOTIFY userDictChanged) Q_PROPERTY(QString userDict READ userDict WRITE setUserDict NOTIFY userDictChanged)
public: public:
explicit SpellChecker(QObject *parent = nullptr); explicit SpellChecker(QObject* parent = nullptr);
~SpellChecker(); ~SpellChecker();
Q_INVOKABLE bool spell(const QString& word); Q_INVOKABLE bool spell(const QString& word);
Q_INVOKABLE QVariantList suggest(const QString &word); Q_INVOKABLE QVariantList suggest(const QString& word);
Q_INVOKABLE void ignoreWord(const QString &word); Q_INVOKABLE void ignoreWord(const QString& word);
Q_INVOKABLE void addToUserWordlist(const QString &word); Q_INVOKABLE void addToUserWordlist(const QString& word);
Q_INVOKABLE bool isInit() const; Q_INVOKABLE bool isInit() const;
const QString& lang() const; const QString& lang() const;
@ -43,9 +43,9 @@ private:
QString m_lang; QString m_lang;
QString m_userDict; QString m_userDict;
QQuickTextDocument *m_document; QQuickTextDocument* m_document;
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
Hunspell *m_hunspell; Hunspell* m_hunspell;
#endif #endif
QTextCodec *m_codec; QTextCodec* m_codec;
}; };

View File

@ -1,52 +1,54 @@
#include "StatusSyntaxHighlighter.h" #include "StatusSyntaxHighlighter.h"
#include <QQuickTextDocument> #include <QQuickTextDocument>
StatusSyntaxHighlighter::StatusSyntaxHighlighter(QTextDocument *parent) StatusSyntaxHighlighter::StatusSyntaxHighlighter(QTextDocument* parent)
: QSyntaxHighlighter(parent) : QSyntaxHighlighter(parent)
{ {
HighlightingRule rule; HighlightingRule rule;
//BOLD //BOLD
singlelineBoldFormat.setFontWeight(QFont::Bold); singlelineBoldFormat.setFontWeight(QFont::Bold);
rule.pattern = QRegularExpression(QStringLiteral("\\*\\*(.*?)\\*\\*")); rule.pattern = QRegularExpression(QStringLiteral("\\*\\*(.*?)\\*\\*"));
rule.format = singlelineBoldFormat; rule.format = singlelineBoldFormat;
highlightingRules.append(rule); highlightingRules.append(rule);
//BOLD //BOLD
//ITALIC //ITALIC
singleLineItalicFormat.setFontItalic(true); singleLineItalicFormat.setFontItalic(true);
rule.pattern = QRegularExpression(QStringLiteral("\\*(.*?)\\*")); rule.pattern = QRegularExpression(QStringLiteral("\\*(.*?)\\*"));
rule.format = singleLineItalicFormat; rule.format = singleLineItalicFormat;
highlightingRules.append(rule); highlightingRules.append(rule);
//ITALIC //ITALIC
//CODE //CODE
singlelineCodeBlockFormat.setFontFamily("Roboto Mono"); singlelineCodeBlockFormat.setFontFamily("Roboto Mono");
rule.pattern = QRegularExpression(QStringLiteral("\\`(.*?)\\`")); rule.pattern = QRegularExpression(QStringLiteral("\\`(.*?)\\`"));
rule.format = singlelineCodeBlockFormat; rule.format = singlelineCodeBlockFormat;
highlightingRules.append(rule); highlightingRules.append(rule);
//CODE //CODE
//STRIKETHROUGH //STRIKETHROUGH
singleLineStrikeThroughFormat.setFontStrikeOut(true); singleLineStrikeThroughFormat.setFontStrikeOut(true);
rule.pattern = QRegularExpression(QStringLiteral("\\~+(.*?)\\~+")); rule.pattern = QRegularExpression(QStringLiteral("\\~+(.*?)\\~+"));
rule.format = singleLineStrikeThroughFormat; rule.format = singleLineStrikeThroughFormat;
highlightingRules.append(rule); highlightingRules.append(rule);
//STRIKETHROUGH //STRIKETHROUGH
//CODE BLOCK //CODE BLOCK
multiLineCodeBlockFormat.setFontFamily("Roboto Mono"); multiLineCodeBlockFormat.setFontFamily("Roboto Mono");
rule.pattern = QRegularExpression(QStringLiteral("\\`\\`\\`(.*?)\\`\\`\\`")); rule.pattern = QRegularExpression(QStringLiteral("\\`\\`\\`(.*?)\\`\\`\\`"));
rule.format = multiLineCodeBlockFormat; rule.format = multiLineCodeBlockFormat;
highlightingRules.append(rule); highlightingRules.append(rule);
//CODE BLOCK //CODE BLOCK
} }
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());
} }
} }

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <QRegularExpression>
#include <QSyntaxHighlighter> #include <QSyntaxHighlighter>
#include <QTextCharFormat> #include <QTextCharFormat>
#include <QRegularExpression>
class QQuickTextDocument; class QQuickTextDocument;
@ -11,10 +11,10 @@ class StatusSyntaxHighlighter : public QSyntaxHighlighter
Q_OBJECT Q_OBJECT
public: public:
StatusSyntaxHighlighter(QTextDocument *parent = nullptr); StatusSyntaxHighlighter(QTextDocument* parent = nullptr);
protected: protected:
void highlightBlock(const QString &text) override; void highlightBlock(const QString& text) override;
private: private:
struct HighlightingRule struct HighlightingRule
@ -31,18 +31,21 @@ 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)
QQuickTextDocument *quickTextDocument() const; , m_quicktextdocument(nullptr)
void setQuickTextDocument(QQuickTextDocument *quickTextDocument); { }
QQuickTextDocument* quickTextDocument() const;
void setQuickTextDocument(QQuickTextDocument* quickTextDocument);
signals: signals:
void quickTextDocumentChanged(); void quickTextDocumentChanged();
private: private:
QQuickTextDocument *m_quicktextdocument; QQuickTextDocument* m_quicktextdocument;
}; };

View File

@ -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();
} }
} }

View File

@ -3,23 +3,25 @@
#include <QQuickWindow> #include <QQuickWindow>
#include <QScreen> #include <QScreen>
class StatusWindow: public QQuickWindow class StatusWindow : public QQuickWindow
{ {
Q_OBJECT Q_OBJECT
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;
}; };

View File

@ -1,11 +1,5 @@
#include "StatusWindow.h" #include "StatusWindow.h"
void StatusWindow::removeTitleBar() void StatusWindow::removeTitleBar() { }
{
} void StatusWindow::showTitleBar() { }
void StatusWindow::showTitleBar()
{
}

View File

@ -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();

View File

@ -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();