Browse Source

zcashd pane on main tab widget

import_zecw
Aditya Kulkarni 6 years ago
parent
commit
5fc905c926
  1. 5
      application.qrc
  2. BIN
      res/zcashdlogo.gif
  3. 1
      src/connection.cpp
  4. 15
      src/fillediconlabel.cpp
  5. 3
      src/fillediconlabel.h
  6. 5
      src/mainwindow.cpp
  7. 1
      src/mainwindow.h
  8. 156
      src/mainwindow.ui
  9. 22
      src/rpc.cpp
  10. 1
      src/rpc.h

5
application.qrc

@ -6,5 +6,8 @@
<file>res/connected.png</file> <file>res/connected.png</file>
<file>res/loading.gif</file> <file>res/loading.gif</file>
<file>res/icon.ico</file> <file>res/icon.ico</file>
</qresource> </qresource>
<qresource prefix="/img">
<file>res/zcashdlogo.gif</file>
</qresource>
</RCC> </RCC>

BIN
res/zcashdlogo.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

1
src/connection.cpp

@ -15,6 +15,7 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) {
d = new QDialog(main); d = new QDialog(main);
connD = new Ui_ConnectionDialog(); connD = new Ui_ConnectionDialog();
connD->setupUi(d); connD->setupUi(d);
connD->topIcon->setBasePixmap(QIcon(":/icons/res/icon.ico").pixmap(256, 256));
// Center on screen // Center on screen
QRect screenGeometry = QApplication::desktop()->screenGeometry(d); QRect screenGeometry = QApplication::desktop()->screenGeometry(d);

15
src/fillediconlabel.cpp

@ -6,17 +6,20 @@ FilledIconLabel::FilledIconLabel(QWidget* parent) :
setScaledContents(false); setScaledContents(false);
} }
void FilledIconLabel::setBasePixmap(QPixmap pm) {
basePm = pm;
}
void FilledIconLabel::resizeEvent(QResizeEvent*) { void FilledIconLabel::resizeEvent(QResizeEvent*) {
// Top pixmap // Top pixmap
QIcon icon(":/icons/res/icon.ico"); QSize sz = size();
QSize sz = size();
qDebug() << sz; QPixmap scaled = basePm.scaled(sz, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap p(sz); QPixmap p(sz);
p.fill(Qt::white); p.fill(Qt::white);
QPainter painter(&p); QPainter painter(&p);
painter.drawPixmap((sz.width() - sz.height()) / 2, 0, painter.drawPixmap((sz.width() - scaled.width()) / 2, (sz.height() - scaled.height()) / 2, scaled);
icon.pixmap(sz.height(), sz.height()));
QLabel::setPixmap(p); QLabel::setPixmap(p);
} }

3
src/fillediconlabel.h

@ -8,10 +8,13 @@ class FilledIconLabel : public QLabel
Q_OBJECT Q_OBJECT
public: public:
explicit FilledIconLabel(QWidget *parent = 0); explicit FilledIconLabel(QWidget *parent = 0);
void setBasePixmap(QPixmap pm);
public slots: public slots:
void resizeEvent(QResizeEvent *); void resizeEvent(QResizeEvent *);
private:
QPixmap basePm;
}; };

5
src/mainwindow.cpp

@ -75,6 +75,7 @@ MainWindow::MainWindow(QWidget *parent) :
setupRecieveTab(); setupRecieveTab();
setupBalancesTab(); setupBalancesTab();
setupTurnstileDialog(); setupTurnstileDialog();
setupZcashdTab();
rpc = new RPC(this); rpc = new RPC(this);
@ -700,6 +701,10 @@ void MainWindow::setupBalancesTab() {
}); });
} }
void MainWindow::setupZcashdTab() {
ui->zcashdlogo->setBasePixmap(QPixmap(":/img/res/zcashdlogo.gif"));
}
void MainWindow::setupTransactionsTab() { void MainWindow::setupTransactionsTab() {
// Set up context menu on transactions tab // Set up context menu on transactions tab
ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu); ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu);

1
src/mainwindow.h

@ -49,6 +49,7 @@ private:
void setupTransactionsTab(); void setupTransactionsTab();
void setupRecieveTab(); void setupRecieveTab();
void setupBalancesTab(); void setupBalancesTab();
void setupZcashdTab();
void setupTurnstileDialog(); void setupTurnstileDialog();
void setupSettingsModal(); void setupSettingsModal();

156
src/mainwindow.ui

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>889</width> <width>968</width>
<height>603</height> <height>616</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -22,7 +22,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>4</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -316,8 +316,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>841</width> <width>920</width>
<height>321</height> <height>334</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="sendToLayout"> <layout class="QVBoxLayout" name="sendToLayout">
@ -715,6 +715,145 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>zcashd</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="FilledIconLabel" name="zcashdlogo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="5" column="0" colspan="3">
<widget class="QLabel" name="label_14">
<property name="text">
<string>You are currently not mining</string>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QLabel" name="numconnections">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Block Height</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="solrate">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Network Solution Rate</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Connections</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="blockheight">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>|</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_11">
<property name="text">
<string>|</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_13">
<property name="text">
<string>|</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -724,7 +863,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>889</width> <width>968</width>
<height>22</height> <height>22</height>
</rect> </rect>
</property> </property>
@ -835,6 +974,11 @@
<extends>QLabel</extends> <extends>QLabel</extends>
<header>qrcodelabel.h</header> <header>qrcodelabel.h</header>
</customwidget> </customwidget>
<customwidget>
<class>FilledIconLabel</class>
<extends>QLabel</extends>
<header>fillediconlabel.h</header>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>tabWidget</tabstop> <tabstop>tabWidget</tabstop>

22
src/rpc.cpp

@ -477,6 +477,28 @@ void RPC::getInfoThenRefresh(bool force) {
refreshTransactions(); refreshTransactions();
} }
// Get network sol/s
if (ezcashd != nullptr) {
int conns = reply["connections"].get<json::number_integer_t>();
json payload = {
{"jsonrpc", "1.0"},
{"id", "someid"},
{"method", "getnetworksolps"}
};
conn->doRPCIgnoreError(payload, [=](const json& reply) {
qint64 solrate = reply.get<json::number_unsigned_t>();
ui->blockheight->setText(QString::number(curBlock));
ui->numconnections->setText(QString::number(conns));
ui->solrate->setText(QString::number(solrate) % " Sol/s");
});
} else {
ui->tabWidget->removeTab(4);
}
// Call to see if the blockchain is syncing. // Call to see if the blockchain is syncing.
json payload = { json payload = {
{"jsonrpc", "1.0"}, {"jsonrpc", "1.0"},

1
src/rpc.h

@ -33,6 +33,7 @@ public:
void setConnection(Connection* c); void setConnection(Connection* c);
void setEZcashd(QProcess* p); void setEZcashd(QProcess* p);
const QProcess* getEZcashD() { return ezcashd; }
void refresh(bool force = false); void refresh(bool force = false);

Loading…
Cancel
Save