Gav Wood
10 years ago
8 changed files with 332 additions and 204 deletions
@ -0,0 +1,98 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file LogPanel.h
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2015 |
|||
*/ |
|||
|
|||
#include "LogPanel.h" |
|||
#include <sstream> |
|||
#include <QClipboard> |
|||
#include <QSettings> |
|||
#include <libdevcore/Log.h> |
|||
#include <libdevcore/SHA3.h> |
|||
#include <libevmcore/Instruction.h> |
|||
#include <libethereum/Client.h> |
|||
#include "ui_LogPanel.h" |
|||
using namespace std; |
|||
using namespace dev; |
|||
using namespace az; |
|||
using namespace eth; |
|||
|
|||
static QString filterOutTerminal(QString _s) |
|||
{ |
|||
return _s.replace(QRegExp("\x1b\\[(\\d;)?\\d+m"), ""); |
|||
} |
|||
|
|||
LogPanel::LogPanel(MainFace* _m): |
|||
Plugin(_m, "LogPanel"), |
|||
m_ui(new Ui::LogPanel) |
|||
{ |
|||
dock(Qt::RightDockWidgetArea, "Log")->setWidget(new QWidget); |
|||
m_ui->setupUi(dock()->widget()); |
|||
connect(m_ui->verbosity, SIGNAL(valueChanged(int)), SLOT(on_verbosity_valueChanged())); |
|||
|
|||
g_logPost = [=](string const& s, char const* c) |
|||
{ |
|||
simpleDebugOut(s, c); |
|||
m_logLock.lock(); |
|||
m_logHistory.append(filterOutTerminal(QString::fromStdString(s)) + "\n"); |
|||
m_logChanged = true; |
|||
m_logLock.unlock(); |
|||
// ui->log->addItem(QString::fromStdString(s));
|
|||
}; |
|||
|
|||
// TODO: refactor
|
|||
{ |
|||
QSettings s("ethereum", "alethzero"); |
|||
m_ui->verbosity->setValue(s.value("verbosity", 1).toInt()); |
|||
} |
|||
|
|||
on_verbosity_valueChanged(); |
|||
} |
|||
|
|||
LogPanel::~LogPanel() |
|||
{ |
|||
// Must do this here since otherwise m_ethereum'll be deleted (and therefore clearWatches() called by the destructor)
|
|||
// *after* the client is dead.
|
|||
g_logPost = simpleDebugOut; |
|||
|
|||
// TODO: refactor
|
|||
{ |
|||
QSettings s("ethereum", "alethzero"); |
|||
s.setValue("verbosity", m_ui->verbosity->value()); |
|||
} |
|||
} |
|||
|
|||
void LogPanel::timerEvent(QTimerEvent*) |
|||
{ |
|||
if (m_logChanged) |
|||
{ |
|||
m_logLock.lock(); |
|||
m_logChanged = false; |
|||
m_ui->log->appendPlainText(m_logHistory.mid(0, m_logHistory.length() - 1)); |
|||
m_logHistory.clear(); |
|||
m_logLock.unlock(); |
|||
} |
|||
} |
|||
|
|||
void LogPanel::on_verbosity_valueChanged() |
|||
{ |
|||
g_logVerbosity = m_ui->verbosity->value(); |
|||
m_ui->verbosityLabel->setText(QString::number(g_logVerbosity)); |
|||
} |
|||
|
@ -0,0 +1,62 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file AllAccounts.h
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2015 |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <QMutex> |
|||
#include <QString> |
|||
#include <QPair> |
|||
#include <QList> |
|||
#include "MainFace.h" |
|||
|
|||
namespace Ui |
|||
{ |
|||
class LogPanel; |
|||
} |
|||
|
|||
namespace dev |
|||
{ |
|||
namespace az |
|||
{ |
|||
|
|||
class LogPanel: public QObject, public Plugin |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
LogPanel(MainFace* _m); |
|||
~LogPanel(); |
|||
|
|||
private slots: |
|||
void on_verbosity_valueChanged(); |
|||
|
|||
private: |
|||
void timerEvent(QTimerEvent*); |
|||
|
|||
Ui::LogPanel* m_ui; |
|||
|
|||
QMutex m_logLock; |
|||
QString m_logHistory; |
|||
bool m_logChanged = true; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,99 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ui version="4.0"> |
|||
<class>LogPanel</class> |
|||
<widget class="QWidget" name="LogPanel"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>834</width> |
|||
<height>265</height> |
|||
</rect> |
|||
</property> |
|||
<property name="windowTitle"> |
|||
<string>Form</string> |
|||
</property> |
|||
<layout class="QHBoxLayout" name="horizontalLayout"> |
|||
<property name="spacing"> |
|||
<number>0</number> |
|||
</property> |
|||
<property name="leftMargin"> |
|||
<number>0</number> |
|||
</property> |
|||
<property name="topMargin"> |
|||
<number>0</number> |
|||
</property> |
|||
<property name="rightMargin"> |
|||
<number>0</number> |
|||
</property> |
|||
<property name="bottomMargin"> |
|||
<number>0</number> |
|||
</property> |
|||
<item> |
|||
<widget class="QPlainTextEdit" name="log"> |
|||
<property name="font"> |
|||
<font> |
|||
<family>Ubuntu Mono</family> |
|||
</font> |
|||
</property> |
|||
<property name="frameShape"> |
|||
<enum>QFrame::NoFrame</enum> |
|||
</property> |
|||
<property name="frameShadow"> |
|||
<enum>QFrame::Plain</enum> |
|||
</property> |
|||
<property name="lineWidth"> |
|||
<number>0</number> |
|||
</property> |
|||
<property name="lineWrapMode"> |
|||
<enum>QPlainTextEdit::NoWrap</enum> |
|||
</property> |
|||
<property name="readOnly"> |
|||
<bool>true</bool> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<layout class="QVBoxLayout" name="verticalLayout_6"> |
|||
<property name="spacing"> |
|||
<number>6</number> |
|||
</property> |
|||
<item> |
|||
<widget class="QSlider" name="verbosity"> |
|||
<property name="maximum"> |
|||
<number>20</number> |
|||
</property> |
|||
<property name="value"> |
|||
<number>1</number> |
|||
</property> |
|||
<property name="orientation"> |
|||
<enum>Qt::Vertical</enum> |
|||
</property> |
|||
<property name="tickPosition"> |
|||
<enum>QSlider::TicksBothSides</enum> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QLabel" name="verbosityLabel"> |
|||
<property name="minimumSize"> |
|||
<size> |
|||
<width>20</width> |
|||
<height>0</height> |
|||
</size> |
|||
</property> |
|||
<property name="text"> |
|||
<string>20</string> |
|||
</property> |
|||
<property name="alignment"> |
|||
<set>Qt::AlignCenter</set> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
</layout> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
<resources/> |
|||
<connections/> |
|||
</ui> |
Loading…
Reference in new issue