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. 12
      src/balancestablemodel.cpp
  4. 23
      src/fillediconlabel.cpp
  5. 20
      src/guiconstants.h
  6. 23
      src/mainwindow.cpp
  7. 61
      src/mainwindow.ui
  8. 49
      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
HEADERS += \
src/guiconstants.h \
src/firsttimewizard.h \
src/mainwindow.h \
src/precompiled.h \

12
src/balancestablemodel.cpp

@ -4,6 +4,7 @@
#include "addressbook.h"
#include "settings.h"
#include "camount.h"
#include "guiconstants.h"
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
QString theme_name = Settings::getInstance()->get_theme_name();
QBrush b;
b.setColor(Qt::black);
QColor color;
if (theme_name == "Dark" || theme_name == "Midnight") {
color = COLOR_WHITE;
}else{
color = COLOR_BLACK;
}
b.setColor(color);
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
#include "fillediconlabel.h"
#include "settings.h"
#include "guiconstants.h"
FilledIconLabel::FilledIconLabel(QWidget* parent) :
QLabel(parent) {
@ -20,8 +22,25 @@ void FilledIconLabel::resizeEvent(QResizeEvent*) {
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);
p.fill(Qt::white);
p.fill(color);
QPainter painter(&p);
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) {
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
QString saved_theme_name;
try
{
try {
saved_theme_name = Settings::getInstance()->get_theme_name();
}
catch (...)
{
} catch (const std::exception& e) {
qDebug() << QString("Ignoring theme change Exception! : ");
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))
{
QString styleSheet = QLatin1String(qFile.readAll());
this->setStyleSheet(""); // resets styles, makes app restart unnecessary
this->setStyleSheet(""); // reset styles
this->setStyleSheet(styleSheet);
}

61
src/mainwindow.ui

@ -55,11 +55,11 @@
<normaloff>:/icons/res/icon.ico</normaloff>:/icons/res/icon.ico</iconset>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>5</number>
</property>
<widget class="QWidget" name="tab_6">
<attribute name="title">
@ -1493,25 +1493,55 @@
<attribute name="title">
<string>Information about Hush</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="FilledIconLabel" name="hushdlogo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>300</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<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>
@ -1528,19 +1558,6 @@
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<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>
<widget class="QLabel" name="label_16">
<property name="font">
@ -1917,8 +1934,6 @@
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>

49
src/txtablemodel.cpp

@ -3,6 +3,7 @@
#include "txtablemodel.h"
#include "settings.h"
#include "controller.h"
#include "guiconstants.h"
TxTableModel::TxTableModel(QObject *parent)
: QAbstractTableModel(parent) {
@ -87,6 +88,17 @@ QString TxTableModel::concatMultipleMemos(const TransactionItem& dat) 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
if (role == Qt::TextAlignmentRole &&
(index.column() == Column::Confirmations || index.column() == Column::Amount))
@ -95,14 +107,10 @@ QVariant TxTableModel::data(const QModelIndex &index, int role) const {
auto dat = modeldata->at(index.row());
if (role == Qt::ForegroundRole) {
if (dat.confirmations <= 0) {
QBrush b;
b.setColor(Qt::red);
return b;
}
// Else, just return the default brush
QBrush b;
b.setColor(Qt::black);
b.setColor(color);
return b;
}
@ -198,24 +206,25 @@ QVariant TxTableModel::data(const QModelIndex &index, int role) const {
// If the memo is a Payment URI, then show a payment request icon
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));
} else if (hasMemo) {
// Return the info pixmap to indicate memo
QIcon icon(":/icons/res/mail.png");
return QVariant(icon.pixmap(16, 16));
} else {
if (dat.type == "Receive"){
// Empty pixmap to make it align
QPixmap p(16, 16);
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_ArrowLeft);
QImage image = colorizeIcon(QIcon(":/icons/res/tx_input.png"), color);
QIcon icon;
icon.addPixmap(QPixmap::fromImage(image));
return QVariant(icon.pixmap(16, 16));
}
if (dat.type == "send"){
// Empty pixmap to make it align
QPixmap p(16, 16);
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_ArrowForward);
QImage image = colorizeIcon(QIcon(":/icons/res/tx_output.png"), color);
QIcon icon;
icon.addPixmap(QPixmap::fromImage(image));
return QVariant(icon.pixmap(16, 16));
}
}
@ -278,3 +287,17 @@ QString TxTableModel::getAmt(int row) const {
}
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;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QImage colorizeIcon(const QIcon icon, const QColor color) const;
private:
QString concatMultipleMemos(const TransactionItem&) const;

Loading…
Cancel
Save