Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GUI] Tor topbar icon status. #1339

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ RES_ICONS = \
qt/pivx/res/img/dark/ic-transaction-cs-contract-inactive.svg \
qt/pivx/res/img/img-qr.svg \
qt/pivx/res/img/ic-check-connect-off.svg \
qt/pivx/res/img/ic-check-tor-off.svg \
qt/pivx/res/img/ic-check-tor.svg \
qt/pivx/res/img/ic-label.svg \
qt/pivx/res/img/ic-transaction-received.svg \
qt/pivx/res/img/dark/ic-transaction-received.svg \
Expand Down
2 changes: 2 additions & 0 deletions src/qt/pivx.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@
<file alias="ic-check-box-liliac-indeterminate">pivx/res/img/ic-check-box-liliac-indeterminate.svg</file>
<file alias="ic-check-connect-off">pivx/res/img/ic-check-connect-off.svg</file>
<file alias="ic-check-connect">pivx/res/img/ic-check-connect.svg</file>
<file alias="ic-check-tor-off">pivx/res/img/ic-check-tor-off.svg</file>
<file alias="ic-check-tor">pivx/res/img/ic-check-tor.svg</file>
<file alias="ic-check-dark">pivx/res/img/ic-check-dark.svg</file>
<file alias="ic-check-liliac-on">pivx/res/img/ic-check-liliac-on.svg</file>
<file alias="ic-check-locked-off">pivx/res/img/ic-check-locked-off.svg</file>
Expand Down
10 changes: 10 additions & 0 deletions src/qt/pivx/forms/topbar.ui
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@ border:none;</string>
</property>
</widget>
</item>
<item>
<widget class="ExpandableButton" name="pushButtonTor" native="true">
<property name="minimumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="ExpandableButton" name="pushButtonLock" native="true">
<property name="sizePolicy">
Expand Down
29 changes: 29 additions & 0 deletions src/qt/pivx/res/css/style_dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,35 @@ QPushButton[cssClass="btn-check-connect"]:checked {
border-bottom:2px solid #b088ff;
}

/* Tor status*/

QPushButton[cssClass="btn-check-tor"] {
qproperty-icon: url("://ic-check-tor") ;
qproperty-iconSize: 24px 24px;
color:#ffffff;
background-color:#505c4b7d;
border-bottom:2px solid #b088ff;
border-radius:2px;
}


QPushButton[cssClass="btn-check-tor-inactive"] {
qproperty-icon: url("://ic-check-tor-off");
qproperty-iconSize: 24px 24px;
color:#B3FFFFFF;
background-color:#405c4b7d;
border-bottom:2px solid #5C4B7D;
border-radius:2px;
}

QPushButton[cssClass="btn-check-tor"]:checked {
background-color:#505c4b7d;
color:#ffffff;
border-bottom:2px solid #b088ff;
}

/* End tor status*/

QPushButton[cssClass="btn-check-status-lock"] {
background-color:#505c4b7d;
border-bottom:2px solid #b088ff;
Expand Down
29 changes: 29 additions & 0 deletions src/qt/pivx/res/css/style_light.css
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,35 @@ QPushButton[cssClass="btn-check-connect"]:checked {
border-bottom:2px solid #b088ff;
}

/* Tor status*/

QPushButton[cssClass="btn-check-tor"] {
qproperty-icon: url("://ic-check-tor") ;
qproperty-iconSize: 24px 24px;
color:#ffffff;
background-color:#505c4b7d;
border-bottom:2px solid #b088ff;
border-radius:2px;
}


QPushButton[cssClass="btn-check-tor-inactive"] {
qproperty-icon: url("://ic-check-tor-off");
qproperty-iconSize: 24px 24px;
color:#B3FFFFFF;
background-color:#405c4b7d;
border-bottom:2px solid #5C4B7D;
border-radius:2px;
}

QPushButton[cssClass="btn-check-tor"]:checked {
background-color:#505c4b7d;
color:#ffffff;
border-bottom:2px solid #b088ff;
}

/* End tor status*/

QPushButton[cssClass="btn-check-status-lock"] {
background-color:#505c4b7d;
border-bottom:2px solid #b088ff;
Expand Down
35 changes: 35 additions & 0 deletions src/qt/pivx/res/img/ic-check-tor-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions src/qt/pivx/res/img/ic-check-tor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/qt/pivx/topbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ TopBar::TopBar(PIVXGUI* _mainWindow, QWidget *parent) :
ui->pushButtonConnection->setButtonClassStyle("cssClass", "btn-check-connect-inactive");
ui->pushButtonConnection->setButtonText("No Connection");

ui->pushButtonTor->setButtonClassStyle("cssClass", "btn-check-tor-inactive");
ui->pushButtonTor->setButtonText("Tor Disabled");
ui->pushButtonTor->setChecked(false);

ui->pushButtonStack->setButtonClassStyle("cssClass", "btn-check-stack-inactive");
ui->pushButtonStack->setButtonText("Staking Disabled");

Expand Down Expand Up @@ -361,6 +365,9 @@ void TopBar::updateStakingStatus(){
setStakingStatusActive(walletModel &&
!walletModel->isWalletLocked() &&
walletModel->isStakingStatusActive());

// Taking advantage of this timer to update Tor status if needed.
updateTorIcon();
}

void TopBar::setNumConnections(int count) {
Expand Down Expand Up @@ -484,6 +491,25 @@ void TopBar::loadWalletModel(){
isInitializing = false;
}

void TopBar::updateTorIcon() {
std::string ip_port;
bool torEnabled = clientModel->getTorInfo(ip_port);

if (torEnabled) {
if(!ui->pushButtonTor->isChecked()) {
ui->pushButtonTor->setChecked(true);
ui->pushButtonTor->setButtonClassStyle("cssClass", "btn-check-tor", true);
}
QString ip_port_q = QString::fromStdString(ip_port);
ui->pushButtonTor->setButtonText(tr("Tor is <b>enabled</b>: %1").arg(ip_port_q));
} else {
if (ui->pushButtonTor->isChecked()) {
ui->pushButtonTor->setChecked(false);
ui->pushButtonTor->setButtonClassStyle("cssClass", "btn-check-tor-inactive", true);
}
}
}

void TopBar::refreshStatus(){
// Check lock status
if (!this->walletModel)
Expand Down
2 changes: 2 additions & 0 deletions src/qt/pivx/topbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ private Q_SLOTS:
int nDisplayUnit = -1;
QTimer* timerStakingIcon = nullptr;
bool isInitializing = true;

void updateTorIcon();
};

#endif // TOPBAR_H