Browse Source

UI/color tweaks from SD

onryo
fekt 1 year ago
parent
commit
4969275156
  1. BIN
      res/hushdlogo.png
  2. 1
      silentdragon-lite.pro
  3. 14
      src/balancestablemodel.cpp
  4. 23
      src/fillediconlabel.cpp
  5. 20
      src/guiconstants.h
  6. 23
      src/mainwindow.cpp
  7. 803
      src/mainwindow.ui
  8. 63
      src/txtablemodel.cpp
  9. 1
      src/txtablemodel.h

BIN
res/hushdlogo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 19 KiB

1
silentdragon-lite.pro

@ -88,6 +88,7 @@ SOURCES += \
src/Crypto/passwd.cpp src/Crypto/passwd.cpp
HEADERS += \ HEADERS += \
src/guiconstants.h \
src/firsttimewizard.h \ src/firsttimewizard.h \
src/mainwindow.h \ src/mainwindow.h \
src/precompiled.h \ src/precompiled.h \

14
src/balancestablemodel.cpp

@ -4,6 +4,7 @@
#include "addressbook.h" #include "addressbook.h"
#include "settings.h" #include "settings.h"
#include "camount.h" #include "camount.h"
#include "guiconstants.h"
BalancesTableModel::BalancesTableModel(QObject *parent): QAbstractTableModel(parent) BalancesTableModel::BalancesTableModel(QObject *parent): QAbstractTableModel(parent)
{} {}
@ -100,9 +101,16 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const
} }
// Else, just return the default brush // Get current theme name
QBrush b; QString theme_name = Settings::getInstance()->get_theme_name();
b.setColor(Qt::black); QBrush b;
QColor color;
if (theme_name == "Dark" || theme_name == "Midnight") {
color = COLOR_WHITE;
}else{
color = COLOR_BLACK;
}
b.setColor(color);
return b; return b;
} }

23
src/fillediconlabel.cpp

@ -1,6 +1,8 @@
// Copyright 2019-2023 The Hush developers // Copyright 2019-2022 The Hush developers
// Released under the GPLv3 // Released under the GPLv3
#include "fillediconlabel.h" #include "fillediconlabel.h"
#include "settings.h"
#include "guiconstants.h"
FilledIconLabel::FilledIconLabel(QWidget* parent) : FilledIconLabel::FilledIconLabel(QWidget* parent) :
QLabel(parent) { QLabel(parent) {
@ -20,8 +22,25 @@ void FilledIconLabel::resizeEvent(QResizeEvent*) {
QPixmap scaled = basePm.scaled(sz, Qt::KeepAspectRatio, Qt::SmoothTransformation); QPixmap scaled = basePm.scaled(sz, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QString theme_name = Settings::getInstance()->get_theme_name();
QColor color;
if (theme_name == "Blue"){
color = COLOR_BLUE_BG;
}else if(theme_name == "Light"){
color = COLOR_LIGHT_BG;
}else if(theme_name == "Dark"){
color = COLOR_DARK_BG;
}else if(theme_name =="Midnight"){
color = COLOR_MIDNIGHT_BG;
}else if(theme_name =="dragonx"){
color = COLOR_DRAGONX_BG;
}else{
color = COLOR_DEFAULT_BG;
}
QPixmap p(sz); QPixmap p(sz);
p.fill(Qt::white); p.fill(color);
QPainter painter(&p); QPainter painter(&p);
painter.drawPixmap((sz.width() - scaled.width()) / 2, (sz.height() - scaled.height()) / 2, scaled); painter.drawPixmap((sz.width() - scaled.width()) / 2, (sz.height() - scaled.height()) / 2, scaled);

20
src/guiconstants.h

@ -0,0 +1,20 @@
// Copyright 2019-2022 The Hush developers
// Released under the GPLv3
#ifndef GUICONSTANTS_H
#define GUICONSTANTS_H
// Generic colors
#define COLOR_BLACK QColor(0, 0, 0)
#define COLOR_WHITE QColor(255, 255, 255)
#define COLOR_UNCONFIRMED_TX QColor(255, 0, 0)
#define COLOR_DRAGONX_TEXT QColor(145, 164, 184)
// Theme background colors
#define COLOR_DEFAULT_BG QColor(229, 229, 229)
#define COLOR_BLUE_BG QColor(229, 229, 229)
#define COLOR_LIGHT_BG QColor(218, 218, 218)
#define COLOR_DARK_BG QColor(48, 51, 53)
#define COLOR_MIDNIGHT_BG QColor(17, 17, 17)
#define COLOR_DRAGONX_BG QColor(35, 40, 52)
#endif // GUICONSTANTS_H

23
src/mainwindow.cpp

@ -2680,23 +2680,32 @@ void MainWindow::slot_change_currency(const QString& currency_name) {
void MainWindow::slot_change_theme(const QString& theme_name) { void MainWindow::slot_change_theme(const QString& theme_name) {
Settings::getInstance()->set_theme_name(theme_name); Settings::getInstance()->set_theme_name(theme_name);
qDebug() << __func__ << ": theme_name=" << theme_name;
if (theme_name == "Dark" || theme_name == "Default" || theme_name == "Light" ||
theme_name == "Midnight" || theme_name == "Blue" || theme_name == "dragonx") {
Settings::getInstance()->set_theme_name(theme_name);
} else {
qDebug() << __func__ << ": ignoring invalid theme_name=" << theme_name;
Settings::getInstance()->set_theme_name("Dark");
}
// Include css // Include css
QString saved_theme_name; QString saved_theme_name;
try try {
{
saved_theme_name = Settings::getInstance()->get_theme_name(); saved_theme_name = Settings::getInstance()->get_theme_name();
} } catch (const std::exception& e) {
catch (...) qDebug() << QString("Ignoring theme change Exception! : ");
{
saved_theme_name = "Dark"; saved_theme_name = "Dark";
} }
QFile qFile(":/css/res/css/" + saved_theme_name +".css"); QString filename = ":/css/res/css/" + saved_theme_name +".css";
QFile qFile(filename);
qDebug() << __func__ << ": attempting to open filename=" << filename;
if (qFile.open(QFile::ReadOnly)) if (qFile.open(QFile::ReadOnly))
{ {
QString styleSheet = QLatin1String(qFile.readAll()); QString styleSheet = QLatin1String(qFile.readAll());
this->setStyleSheet(""); // resets styles, makes app restart unnecessary this->setStyleSheet(""); // reset styles
this->setStyleSheet(styleSheet); this->setStyleSheet(styleSheet);
} }

803
src/mainwindow.ui

@ -55,11 +55,11 @@
<normaloff>:/icons/res/icon.ico</normaloff>:/icons/res/icon.ico</iconset> <normaloff>:/icons/res/icon.ico</normaloff>:/icons/res/icon.ico</iconset>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QFormLayout" name="formLayout"> <layout class="QHBoxLayout" name="horizontalLayout_14">
<item row="0" column="0" colspan="2"> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>5</number>
</property> </property>
<widget class="QWidget" name="tab_6"> <widget class="QWidget" name="tab_6">
<attribute name="title"> <attribute name="title">
@ -1493,432 +1493,447 @@
<attribute name="title"> <attribute name="title">
<string>Information about Hush</string> <string>Information about Hush</string>
</attribute> </attribute>
<layout class="QHBoxLayout" name="horizontalLayout_14"> <widget class="FilledIconLabel" name="hushdlogo">
<item> <property name="enabled">
<widget class="FilledIconLabel" name="hushdlogo"> <bool>true</bool>
<property name="sizePolicy"> </property>
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <property name="geometry">
<horstretch>0</horstretch> <rect>
<verstretch>0</verstretch> <x>20</x>
</sizepolicy> <y>20</y>
</property> <width>300</width>
<property name="text"> <height>300</height>
<string/> </rect>
</property> </property>
<property name="scaledContents"> <property name="sizePolicy">
<bool>false</bool> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
</property> <horstretch>0</horstretch>
</widget> <verstretch>0</verstretch>
</item> </sizepolicy>
<item> </property>
<widget class="QGroupBox" name="groupBox_5"> <property name="minimumSize">
<property name="minimumSize"> <size>
<size> <width>300</width>
<width>650</width> <height>300</height>
<height>650</height> </size>
</size> </property>
</property> <property name="maximumSize">
<property name="maximumSize"> <size>
<size> <width>300</width>
<width>16777215</width> <height>300</height>
<height>16777215</height> </size>
</size> </property>
</property> <property name="text">
<property name="title"> <string/>
<string/> </property>
</property> <property name="scaledContents">
<layout class="QVBoxLayout" name="verticalLayout_5"> <bool>false</bool>
<item> </property>
<spacer name="verticalSpacer_3"> <property name="alignment">
<property name="orientation"> <set>Qt::AlignHCenter|Qt::AlignTop</set>
<enum>Qt::Vertical</enum> </property>
</widget>
<widget class="QGroupBox" name="groupBox_5">
<property name="geometry">
<rect>
<x>336</x>
<y>12</y>
<width>1001</width>
<height>650</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>650</width>
<height>650</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_16">
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Hush Blockchain Information&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="2" column="1">
<widget class="QLabel" name="label_20">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>20</width> <item row="9" column="2">
<height>40</height> <widget class="QLabel" name="supply_total">
</size> <property name="text">
<string>Loading...</string>
</property> </property>
</spacer> </widget>
</item> </item>
<item> <item row="9" column="1">
<widget class="QLabel" name="label_16"> <widget class="QLabel" name="label_38">
<property name="font"> <property name="text">
<font> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<pointsize>15</pointsize>
</font>
</property> </property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_32">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Hush Blockchain Information&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>Next Halving</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="7" column="2">
<widget class="Line" name="line_3"> <widget class="QLabel" name="supply_taddr">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Loading...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="6" column="1">
<layout class="QGridLayout" name="gridLayout_5"> <widget class="QLabel" name="label_18">
<item row="2" column="1"> <property name="text">
<widget class="QLabel" name="label_20"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="text"> </property>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> </widget>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLabel" name="supply_total">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLabel" name="label_38">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_32">
<property name="text">
<string>Next Halving</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="supply_taddr">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_18">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="blockHeight">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Vendor</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="halvingTime">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="Vendor">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="last_notarized">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="difficulty">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_28">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="label_34">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_33">
<property name="text">
<string>Difficulty</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_23">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Last Notarized Block</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="Version">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_26">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_37">
<property name="text">
<string>Total Supply</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="current_server_label">
<property name="text">
<string>Current Server</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLabel" name="label_23">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="10" column="2">
<widget class="QLabel" name="current_server">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="sticky_server_label">
<property name="text">
<string>Sticky Server</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLabel" name="label_23">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="11" column="2">
<widget class="QLabel" name="sticky_server">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_13">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Longestchain</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_29">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Version hushlightd</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_30">
<property name="text">
<string>BlockHeight</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_35">
<property name="text">
<string>Supply zAddr</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_22">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="supply_zaddr">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="longestchain">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_36">
<property name="text">
<string>Supply tAddr</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item row="0" column="2">
<widget class="Line" name="line_2"> <widget class="QLabel" name="blockHeight">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Loading...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="0">
<widget class="QLabel" name="label_24"> <widget class="QLabel" name="label_8">
<property name="font"> <property name="text">
<font> <string>Vendor</string>
<pointsize>15</pointsize>
</font>
</property> </property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="halvingTime">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Hush Market Information&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>Loading...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="2">
<widget class="Line" name="line_5"> <widget class="QLabel" name="Vendor">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Loading...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="4" column="2">
<layout class="QGridLayout" name="gridLayout_6"> <widget class="QLabel" name="last_notarized">
<item row="0" column="2"> <property name="text">
<widget class="QLabel" name="marketcapTab"> <string>Loading...</string>
<property name="text"> </property>
<string>Loading...</string> </widget>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_31">
<property name="text">
<string>Market Cap</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="volumeExchange">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Volume on Exchanges</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_11">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item row="6" column="2">
<widget class="Line" name="line_4"> <widget class="QLabel" name="difficulty">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Loading...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="5" column="1">
<widget class="QLabel" name="label_14"> <widget class="QLabel" name="label_28">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt; &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="8" column="1">
<spacer name="verticalSpacer_4"> <widget class="QLabel" name="label_34">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>20</width> <item row="6" column="0">
<height>40</height> <widget class="QLabel" name="label_33">
</size> <property name="text">
<string>Difficulty</string>
</property> </property>
</spacer> </widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_23">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Last Notarized Block</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="Version">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_26">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_37">
<property name="text">
<string>Total Supply</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="current_server_label">
<property name="text">
<string>Current Server</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLabel" name="label_23">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="10" column="2">
<widget class="QLabel" name="current_server">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="sticky_server_label">
<property name="text">
<string>Sticky Server</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLabel" name="label_23">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="11" column="2">
<widget class="QLabel" name="sticky_server">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_13">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Longestchain</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_29">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Version hushlightd</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_30">
<property name="text">
<string>BlockHeight</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_35">
<property name="text">
<string>Supply zAddr</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_22">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="supply_zaddr">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="longestchain">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_36">
<property name="text">
<string>Supply tAddr</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </item>
</item> <item>
</layout> <widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_24">
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Hush Market Information&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="2">
<widget class="QLabel" name="marketcapTab">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_31">
<property name="text">
<string>Market Cap</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="volumeExchange">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Volume on Exchanges</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_11">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;|&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt; &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<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>
</layout>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>

63
src/txtablemodel.cpp

@ -3,6 +3,7 @@
#include "txtablemodel.h" #include "txtablemodel.h"
#include "settings.h" #include "settings.h"
#include "controller.h" #include "controller.h"
#include "guiconstants.h"
TxTableModel::TxTableModel(QObject *parent) TxTableModel::TxTableModel(QObject *parent)
: QAbstractTableModel(parent) { : QAbstractTableModel(parent) {
@ -87,6 +88,17 @@ QString TxTableModel::concatMultipleMemos(const TransactionItem& dat) const {
}; };
QVariant TxTableModel::data(const QModelIndex &index, int role) const { QVariant TxTableModel::data(const QModelIndex &index, int role) const {
// Get current theme name
QString theme_name = Settings::getInstance()->get_theme_name();
QBrush b;
QColor color;
if (theme_name == "Dark" || theme_name == "Midnight") {
color = COLOR_WHITE;
}else{
color = COLOR_BLACK;
}
// Align numeric columns (confirmations, amount) right // Align numeric columns (confirmations, amount) right
if (role == Qt::TextAlignmentRole && if (role == Qt::TextAlignmentRole &&
(index.column() == Column::Confirmations || index.column() == Column::Amount)) (index.column() == Column::Confirmations || index.column() == Column::Amount))
@ -95,15 +107,11 @@ QVariant TxTableModel::data(const QModelIndex &index, int role) const {
auto dat = modeldata->at(index.row()); auto dat = modeldata->at(index.row());
if (role == Qt::ForegroundRole) { if (role == Qt::ForegroundRole) {
if (dat.confirmations <= 0) { if (dat.confirmations <= 0) {
QBrush b;
b.setColor(Qt::red); b.setColor(Qt::red);
return b; return b;
} }
b.setColor(color);
// Else, just return the default brush return b;
QBrush b;
b.setColor(Qt::black);
return b;
} }
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
@ -195,29 +203,30 @@ QVariant TxTableModel::data(const QModelIndex &index, int role) const {
hasMemo = true; hasMemo = true;
} }
} }
// If the memo is a Payment URI, then show a payment request icon // If the memo is a Payment URI, then show a payment request icon
if (dat.items.length() == 1 && dat.items[0].memo.startsWith("hush:")) { if (dat.items.length() == 1 && dat.items[0].memo.startsWith("hush:")) {
QIcon icon(":/icons/res/paymentreq.gif"); QImage image = colorizeIcon(QIcon(":/icons/res/paymentreq.gif"), color);
QIcon icon;
icon.addPixmap(QPixmap::fromImage(image));
return QVariant(icon.pixmap(16, 16)); return QVariant(icon.pixmap(16, 16));
} else if (hasMemo) { } else if (hasMemo) {
// Return the info pixmap to indicate memo // Return the info pixmap to indicate memo
QIcon icon(":/icons/res/mail.png"); QIcon icon(":/icons/res/mail.png");
return QVariant(icon.pixmap(16, 16)); return QVariant(icon.pixmap(16, 16));
} else { } else {
if (dat.type == "Receive"){
if (dat.type == "Receive"){ QImage image = colorizeIcon(QIcon(":/icons/res/tx_input.png"), color);
// Empty pixmap to make it align QIcon icon;
QPixmap p(16, 16); icon.addPixmap(QPixmap::fromImage(image));
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_ArrowLeft); return QVariant(icon.pixmap(16, 16));
return QVariant(icon.pixmap(16, 16)); }
}
if (dat.type == "send"){ if (dat.type == "send"){
// Empty pixmap to make it align QImage image = colorizeIcon(QIcon(":/icons/res/tx_output.png"), color);
QPixmap p(16, 16); QIcon icon;
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_ArrowForward); icon.addPixmap(QPixmap::fromImage(image));
return QVariant(icon.pixmap(16, 16)); return QVariant(icon.pixmap(16, 16));
} }
} }
} }
@ -278,3 +287,17 @@ QString TxTableModel::getAmt(int row) const {
} }
return total.toDecimalString(); return total.toDecimalString();
} }
QImage TxTableModel::colorizeIcon(QIcon icon, QColor color) const{
QImage img(icon.pixmap(16, 16).toImage());
img = img.convertToFormat(QImage::Format_ARGB32);
for (int x = img.width(); x--; )
{
for (int y = img.height(); y--; )
{
const QRgb rgb = img.pixel(x, y);
img.setPixel(x, y, qRgba(color.red(), color.green(), color.blue(), qAlpha(rgb)));
}
}
return img;
}

1
src/txtablemodel.h

@ -38,6 +38,7 @@ public:
int columnCount(const QModelIndex &parent) const; int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const; QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QImage colorizeIcon(const QIcon icon, const QColor color) const;
private: private:
QString concatMultipleMemos(const TransactionItem&) const; QString concatMultipleMemos(const TransactionItem&) const;

Loading…
Cancel
Save