mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-16 15:58:11 +00:00
walletManager: coding conventions
Signed-off-by: Jaquee <jaquee.monero@gmail.com>
This commit is contained in:
parent
0ae3d67750
commit
01549a3040
5 changed files with 24 additions and 27 deletions
6
main.cpp
6
main.cpp
|
@ -108,10 +108,8 @@ int main(int argc, char *argv[])
|
|||
engine.rootContext()->setContextProperty("translationManager", TranslationManager::instance());
|
||||
|
||||
engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider());
|
||||
|
||||
engine.rootContext()->setContextProperty("daemonManager", DaemonManager::instance(QCoreApplication::arguments()));
|
||||
|
||||
DaemonManager * daemonManager = DaemonManager::instance(QCoreApplication::arguments());
|
||||
const QStringList arguments = QCoreApplication::arguments();
|
||||
DaemonManager * daemonManager = DaemonManager::instance(&arguments);
|
||||
QObject::connect(&app, SIGNAL(aboutToQuit()), daemonManager, SLOT(closing()));
|
||||
engine.rootContext()->setContextProperty("daemonManager", daemonManager);
|
||||
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
#include <QProcess>
|
||||
|
||||
DaemonManager * DaemonManager::m_instance = nullptr;
|
||||
QStringList DaemonManager::clArgs;
|
||||
QStringList DaemonManager::m_clArgs;
|
||||
|
||||
DaemonManager *DaemonManager::instance(QStringList args)
|
||||
DaemonManager *DaemonManager::instance(const QStringList *args)
|
||||
{
|
||||
if (!m_instance) {
|
||||
m_instance = new DaemonManager;
|
||||
// store command line arguments for later use
|
||||
clArgs = args;
|
||||
clArgs.removeFirst();
|
||||
m_clArgs = *args;
|
||||
m_clArgs.removeFirst();
|
||||
}
|
||||
|
||||
return m_instance;
|
||||
|
@ -25,7 +25,6 @@ DaemonManager *DaemonManager::instance(QStringList args)
|
|||
|
||||
bool DaemonManager::start()
|
||||
{
|
||||
|
||||
//
|
||||
QString process;
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -34,7 +33,7 @@ bool DaemonManager::start()
|
|||
process = QApplication::applicationDirPath() + "/monerod";
|
||||
#endif
|
||||
|
||||
if(process.length() == 0) {
|
||||
if (process.length() == 0) {
|
||||
qDebug() << "no daemon binary defined for current platform";
|
||||
return false;
|
||||
}
|
||||
|
@ -42,7 +41,7 @@ bool DaemonManager::start()
|
|||
|
||||
// prepare command line arguments and pass to monerod
|
||||
QStringList arguments;
|
||||
foreach (const QString &str, clArgs) {
|
||||
foreach (const QString &str, m_clArgs) {
|
||||
qDebug() << QString(" [%1] ").arg(str);
|
||||
arguments << str;
|
||||
}
|
||||
|
@ -64,7 +63,7 @@ bool DaemonManager::start()
|
|||
// add state changed listener
|
||||
connect(m_daemon,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(stateChanged(QProcess::ProcessState)));
|
||||
|
||||
if(!started){
|
||||
if (!started) {
|
||||
qDebug() << "Daemon start error: " + m_daemon->errorString();
|
||||
} else {
|
||||
emit daemonStarted();
|
||||
|
@ -75,7 +74,7 @@ bool DaemonManager::start()
|
|||
|
||||
bool DaemonManager::stop()
|
||||
{
|
||||
if(initialized){
|
||||
if (initialized) {
|
||||
qDebug() << "stopping daemon";
|
||||
// we can't use QProcess::terminate() on windows console process
|
||||
// write exit command to stdin
|
||||
|
@ -88,7 +87,7 @@ bool DaemonManager::stop()
|
|||
void DaemonManager::stateChanged(QProcess::ProcessState state)
|
||||
{
|
||||
qDebug() << "STATE CHANGED: " << state;
|
||||
if(state == QProcess::NotRunning) {
|
||||
if (state == QProcess::NotRunning) {
|
||||
emit daemonStopped();
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +97,7 @@ void DaemonManager::printOutput()
|
|||
QByteArray byteArray = m_daemon->readAllStandardOutput();
|
||||
QStringList strLines = QString(byteArray).split("\n");
|
||||
|
||||
foreach (QString line, strLines){
|
||||
foreach (QString line, strLines) {
|
||||
emit daemonConsoleUpdated(line);
|
||||
qDebug() << "Daemon: " + line;
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ void DaemonManager::printError()
|
|||
QByteArray byteArray = m_daemon->readAllStandardError();
|
||||
QStringList strLines = QString(byteArray).split("\n");
|
||||
|
||||
foreach (QString line, strLines){
|
||||
foreach (QString line, strLines) {
|
||||
emit daemonConsoleUpdated(line);
|
||||
qDebug() << "Daemon ERROR: " + line;
|
||||
}
|
||||
|
@ -117,7 +116,7 @@ void DaemonManager::printError()
|
|||
|
||||
bool DaemonManager::running() const
|
||||
{
|
||||
if(initialized){
|
||||
if (initialized) {
|
||||
qDebug() << m_daemon->state();
|
||||
qDebug() << QProcess::NotRunning;
|
||||
// m_daemon->write("status\n");
|
||||
|
@ -137,7 +136,7 @@ void DaemonManager::closing()
|
|||
qDebug() << __FUNCTION__;
|
||||
stop();
|
||||
// Wait for daemon to stop before exiting (max 10 secs)
|
||||
if(initialized){
|
||||
if (initialized) {
|
||||
m_daemon->waitForFinished(10000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class DaemonManager : public QObject
|
|||
|
||||
public:
|
||||
|
||||
static DaemonManager * instance(QStringList args);
|
||||
static DaemonManager * instance(const QStringList *args);
|
||||
|
||||
Q_INVOKABLE bool start();
|
||||
Q_INVOKABLE bool stop();
|
||||
|
@ -34,7 +34,7 @@ private:
|
|||
|
||||
explicit DaemonManager(QObject *parent = 0);
|
||||
static DaemonManager * m_instance;
|
||||
static QStringList clArgs;
|
||||
static QStringList m_clArgs;
|
||||
QProcess *m_daemon;
|
||||
bool initialized = false;
|
||||
|
||||
|
|
|
@ -88,13 +88,13 @@ Wallet::Status Wallet::status() const
|
|||
return static_cast<Status>(m_walletImpl->status());
|
||||
}
|
||||
|
||||
Wallet::ConnectionStatus Wallet::connected()
|
||||
Wallet::ConnectionStatus Wallet::connected() const
|
||||
{
|
||||
// cache connection status
|
||||
if(!m_initialized || m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl){
|
||||
if (!m_initialized || m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl) {
|
||||
m_initialized = true;
|
||||
ConnectionStatus newStatus = static_cast<ConnectionStatus>(m_walletImpl->connected());
|
||||
if(newStatus != m_connectionStatus) {
|
||||
if (newStatus != m_connectionStatus) {
|
||||
m_connectionStatus = newStatus;
|
||||
emit connectionStatusChanged();
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
Status status() const;
|
||||
|
||||
//! returns whether the wallet is connected, and version status
|
||||
ConnectionStatus connected();
|
||||
ConnectionStatus connected() const;
|
||||
|
||||
//! returns true if wallet was ever synchronized
|
||||
bool synchronized() const;
|
||||
|
@ -196,7 +196,7 @@ signals:
|
|||
// emitted when transaction is created async
|
||||
void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount);
|
||||
|
||||
void connectionStatusChanged();
|
||||
void connectionStatusChanged() const;
|
||||
|
||||
private:
|
||||
Wallet(QObject * parent = nullptr);
|
||||
|
@ -219,10 +219,10 @@ private:
|
|||
mutable QTime m_daemonBlockChainTargetHeightTime;
|
||||
mutable quint64 m_daemonBlockChainTargetHeight;
|
||||
int m_daemonBlockChainTargetHeightTtl;
|
||||
ConnectionStatus m_connectionStatus;
|
||||
mutable ConnectionStatus m_connectionStatus;
|
||||
int m_connectionStatusTtl;
|
||||
mutable QTime m_connectionStatusTime;
|
||||
bool m_initialized;
|
||||
mutable bool m_initialized;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue