mirror of
				https://git.wownero.com/wowlet/wowlet.git
				synced 2024-08-15 01:03:14 +00:00 
			
		
		
		
	Improve color scheme
This commit is contained in:
		
							parent
							
								
									68a5469b97
								
							
						
					
					
						commit
						f05435d694
					
				
					 11 changed files with 165 additions and 21 deletions
				
			
		| 
						 | 
					@ -8,6 +8,7 @@
 | 
				
			||||||
#include "libwalletqt/Transfer.h"
 | 
					#include "libwalletqt/Transfer.h"
 | 
				
			||||||
#include "libwalletqt/Input.h"
 | 
					#include "libwalletqt/Input.h"
 | 
				
			||||||
#include "model/ModelUtils.h"
 | 
					#include "model/ModelUtils.h"
 | 
				
			||||||
 | 
					#include "utils/ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QFileDialog>
 | 
					#include <QFileDialog>
 | 
				
			||||||
#include <QMessageBox>
 | 
					#include <QMessageBox>
 | 
				
			||||||
| 
						 | 
					@ -52,7 +53,7 @@ void TxConfAdvDialog::setTransaction(PendingTransaction *tx) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_tx = tx;
 | 
					    m_tx = tx;
 | 
				
			||||||
    m_tx->refresh();
 | 
					    m_tx->refresh();
 | 
				
			||||||
    PendingTransactionInfo *ptx = m_tx->transaction(0);
 | 
					    PendingTransactionInfo *ptx = m_tx->transaction(0); //Todo: support split transactions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ui->txid->setText(tx->txid().first());
 | 
					    ui->txid->setText(tx->txid().first());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,12 +103,16 @@ void TxConfAdvDialog::setupConstructionData(ConstructionInfo *ci) {
 | 
				
			||||||
    ui->inputs->setText(inputs_str);
 | 
					    ui->inputs->setText(inputs_str);
 | 
				
			||||||
    ui->label_inputs->setText(QString("Inputs (%1)").arg(QString::number(inputs.size())));
 | 
					    ui->label_inputs->setText(QString("Inputs (%1)").arg(QString::number(inputs.size())));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QString outputs_str;
 | 
					 | 
				
			||||||
    auto outputs = ci->outputs();
 | 
					    auto outputs = ci->outputs();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QTextCursor cursor = ui->outputs->textCursor();
 | 
				
			||||||
    for (const auto& o: outputs) {
 | 
					    for (const auto& o: outputs) {
 | 
				
			||||||
        outputs_str += QString("%1 %2\n").arg(o->address(), WalletManager::displayAmount(o->amount()));
 | 
					        auto address = o->address();
 | 
				
			||||||
 | 
					        auto amount = WalletManager::displayAmount(o->amount());
 | 
				
			||||||
 | 
					        cursor.insertText(address, textFormat(address));
 | 
				
			||||||
 | 
					        cursor.insertText(QString(" %1").arg(amount), QTextCharFormat());
 | 
				
			||||||
 | 
					        cursor.insertBlock();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    ui->outputs->setText(outputs_str);
 | 
					 | 
				
			||||||
    ui->label_outputs->setText(QString("Outputs (%1)").arg(QString::number(outputs.size())));
 | 
					    ui->label_outputs->setText(QString("Outputs (%1)").arg(QString::number(outputs.size())));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ui->label_ringSize->setText(QString("Ring size: %1").arg(QString::number(ci->minMixinCount() + 1)));
 | 
					    ui->label_ringSize->setText(QString("Ring size: %1").arg(QString::number(ci->minMixinCount() + 1)));
 | 
				
			||||||
| 
						 | 
					@ -178,6 +183,23 @@ void TxConfAdvDialog::closeDialog() {
 | 
				
			||||||
    QDialog::reject();
 | 
					    QDialog::reject();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QTextCharFormat TxConfAdvDialog::textFormat(const QString &address) {
 | 
				
			||||||
 | 
					    auto index = m_ctx->currentWallet->subaddressIndex(address);
 | 
				
			||||||
 | 
					    if (index.first == 0 && index.second == 0) {
 | 
				
			||||||
 | 
					        QTextCharFormat rec;
 | 
				
			||||||
 | 
					        rec.setBackground(QBrush(ColorScheme::YELLOW.asColor(true)));
 | 
				
			||||||
 | 
					        rec.setToolTip("Wallet change/primary address");
 | 
				
			||||||
 | 
					        return rec;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (index.first >= 0) {
 | 
				
			||||||
 | 
					        QTextCharFormat rec;
 | 
				
			||||||
 | 
					        rec.setBackground(QBrush(ColorScheme::GREEN.asColor(true)));
 | 
				
			||||||
 | 
					        rec.setToolTip("Wallet receive address");
 | 
				
			||||||
 | 
					        return rec;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return QTextCharFormat();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TxConfAdvDialog::~TxConfAdvDialog() {
 | 
					TxConfAdvDialog::~TxConfAdvDialog() {
 | 
				
			||||||
    delete ui;
 | 
					    delete ui;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@
 | 
				
			||||||
#include <QStandardItemModel>
 | 
					#include <QStandardItemModel>
 | 
				
			||||||
#include <QAbstractButton>
 | 
					#include <QAbstractButton>
 | 
				
			||||||
#include <QMenu>
 | 
					#include <QMenu>
 | 
				
			||||||
 | 
					#include <QTextCharFormat>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "libwalletqt/PendingTransaction.h"
 | 
					#include "libwalletqt/PendingTransaction.h"
 | 
				
			||||||
#include "appcontext.h"
 | 
					#include "appcontext.h"
 | 
				
			||||||
| 
						 | 
					@ -41,6 +42,8 @@ private:
 | 
				
			||||||
    void signedQrCode();
 | 
					    void signedQrCode();
 | 
				
			||||||
    void signedSaveFile();
 | 
					    void signedSaveFile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QTextCharFormat textFormat(const QString &address);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ui::TxConfAdvDialog *ui;
 | 
					    Ui::TxConfAdvDialog *ui;
 | 
				
			||||||
    AppContext *m_ctx;
 | 
					    AppContext *m_ctx;
 | 
				
			||||||
    PendingTransaction *m_tx = nullptr;
 | 
					    PendingTransaction *m_tx = nullptr;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@
 | 
				
			||||||
#include "model/ModelUtils.h"
 | 
					#include "model/ModelUtils.h"
 | 
				
			||||||
#include "txconfadvdialog.h"
 | 
					#include "txconfadvdialog.h"
 | 
				
			||||||
#include "globals.h"
 | 
					#include "globals.h"
 | 
				
			||||||
 | 
					#include "utils/ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QMessageBox>
 | 
					#include <QMessageBox>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,21 +43,33 @@ TxConfDialog::TxConfDialog(AppContext *ctx, PendingTransaction *tx, const QStrin
 | 
				
			||||||
    int maxLengthFiat = Utils::maxLength(amounts_fiat);
 | 
					    int maxLengthFiat = Utils::maxLength(amounts_fiat);
 | 
				
			||||||
    std::for_each(amounts_fiat.begin(), amounts_fiat.end(), [maxLengthFiat](QString& amount){amount = amount.rightJustified(maxLengthFiat, ' ');});
 | 
					    std::for_each(amounts_fiat.begin(), amounts_fiat.end(), [maxLengthFiat](QString& amount){amount = amount.rightJustified(maxLengthFiat, ' ');});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ui->label_amount->setFont(ModelUtils::getMonospaceFont());
 | 
				
			||||||
 | 
					    ui->label_fee->setFont(ModelUtils::getMonospaceFont());
 | 
				
			||||||
 | 
					    ui->label_total->setFont(ModelUtils::getMonospaceFont());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ui->label_amount->setText(QString("%1 (%2 %3)").arg(amounts[0], amounts_fiat[0], preferredCur));
 | 
					    ui->label_amount->setText(QString("%1 (%2 %3)").arg(amounts[0], amounts_fiat[0], preferredCur));
 | 
				
			||||||
    ui->label_fee->setText(QString("%1 (%2 %3)").arg(amounts[1], amounts_fiat[1], preferredCur));
 | 
					    ui->label_fee->setText(QString("%1 (%2 %3)").arg(amounts[1], amounts_fiat[1], preferredCur));
 | 
				
			||||||
    ui->label_total->setText(QString("%1 (%2 %3)").arg(amounts[2], amounts_fiat[2], preferredCur));
 | 
					    ui->label_total->setText(QString("%1 (%2 %3)").arg(amounts[2], amounts_fiat[2], preferredCur));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    auto subaddressIndex = m_ctx->currentWallet->subaddressIndex(address);
 | 
					    auto subaddressIndex = m_ctx->currentWallet->subaddressIndex(address);
 | 
				
			||||||
    QString addressExtra;
 | 
					    QString addressExtra;
 | 
				
			||||||
    if (subaddressIndex.first >= 0) {
 | 
					 | 
				
			||||||
        ui->label_note->setText("Note: this is a churn transaction.");
 | 
					 | 
				
			||||||
        ui->label_note->show();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ui->label_address->setText(ModelUtils::displayAddress(address, 2));
 | 
					    ui->label_address->setText(ModelUtils::displayAddress(address, 2));
 | 
				
			||||||
    ui->label_address->setFont(ModelUtils::getMonospaceFont());
 | 
					    ui->label_address->setFont(ModelUtils::getMonospaceFont());
 | 
				
			||||||
    ui->label_address->setToolTip(address);
 | 
					    ui->label_address->setToolTip(address);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (subaddressIndex.first >= 0) {
 | 
				
			||||||
 | 
					        ui->label_note->setText("Note: this is a churn transaction.");
 | 
				
			||||||
 | 
					        ui->label_note->show();
 | 
				
			||||||
 | 
					        ui->label_address->setStyleSheet(ColorScheme::GREEN.asStylesheet(true));
 | 
				
			||||||
 | 
					        ui->label_address->setToolTip("Wallet receive address");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (subaddressIndex.first == 0 && subaddressIndex.second == 0) {
 | 
				
			||||||
 | 
					        ui->label_address->setStyleSheet(ColorScheme::YELLOW.asStylesheet(true));
 | 
				
			||||||
 | 
					        ui->label_address->setToolTip("Wallet change/primary address");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Send");
 | 
					    ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Send");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@
 | 
				
			||||||
#include "dialog/WalletCacheDebugDialog.h"
 | 
					#include "dialog/WalletCacheDebugDialog.h"
 | 
				
			||||||
#include "ui_mainwindow.h"
 | 
					#include "ui_mainwindow.h"
 | 
				
			||||||
#include "globals.h"
 | 
					#include "globals.h"
 | 
				
			||||||
 | 
					#include "utils/ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// libwalletqt
 | 
					// libwalletqt
 | 
				
			||||||
#include "libwalletqt/AddressBook.h"
 | 
					#include "libwalletqt/AddressBook.h"
 | 
				
			||||||
| 
						 | 
					@ -365,6 +366,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
 | 
				
			||||||
    this->initMenu();
 | 
					    this->initMenu();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(&m_updateBytes, &QTimer::timeout, this, &MainWindow::updateNetStats);
 | 
					    connect(&m_updateBytes, &QTimer::timeout, this, &MainWindow::updateNetStats);
 | 
				
			||||||
 | 
					    ColorScheme::updateFromWidget(this);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MainWindow::initMain() {
 | 
					void MainWindow::initMain() {
 | 
				
			||||||
| 
						 | 
					@ -1041,6 +1043,7 @@ void MainWindow::skinChanged(const QString &skinName) {
 | 
				
			||||||
    config()->set(Config::skin, skinName);
 | 
					    config()->set(Config::skin, skinName);
 | 
				
			||||||
    qApp->setStyleSheet(m_skins[skinName]);
 | 
					    qApp->setStyleSheet(m_skins[skinName]);
 | 
				
			||||||
    qDebug() << QString("Skin changed to %1").arg(skinName);
 | 
					    qDebug() << QString("Skin changed to %1").arg(skinName);
 | 
				
			||||||
 | 
					    ColorScheme::updateFromWidget(this);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MainWindow::closeEvent(QCloseEvent *event) {
 | 
					void MainWindow::closeEvent(QCloseEvent *event) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@
 | 
				
			||||||
#include "Coins.h"
 | 
					#include "Coins.h"
 | 
				
			||||||
#include "ModelUtils.h"
 | 
					#include "ModelUtils.h"
 | 
				
			||||||
#include "globals.h"
 | 
					#include "globals.h"
 | 
				
			||||||
 | 
					#include "utils/ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QBrush>
 | 
					#include <QBrush>
 | 
				
			||||||
#include <QFont>
 | 
					#include <QFont>
 | 
				
			||||||
| 
						 | 
					@ -67,13 +68,13 @@ QVariant CoinsModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (role == Qt::BackgroundRole) {
 | 
					        else if (role == Qt::BackgroundRole) {
 | 
				
			||||||
            if (cInfo.spent()) {
 | 
					            if (cInfo.spent()) {
 | 
				
			||||||
                result = QBrush(QColor(255, 100, 100));
 | 
					                result = QBrush(ColorScheme::RED.asColor(true));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else if (cInfo.frozen()) {
 | 
					            else if (cInfo.frozen()) {
 | 
				
			||||||
                result = QBrush(QColor(173, 216, 230));
 | 
					                result = QBrush(ColorScheme::BLUE.asColor(true));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else if (!cInfo.unlocked()) {
 | 
					            else if (!cInfo.unlocked()) {
 | 
				
			||||||
                result = QBrush(QColor("#60993E"));
 | 
					                result = QBrush(ColorScheme::YELLOW.asColor(true));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (role == Qt::TextAlignmentRole) {
 | 
					        else if (role == Qt::TextAlignmentRole) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,8 @@
 | 
				
			||||||
// Copyright (c) 2020-2021, The Monero Project.
 | 
					// Copyright (c) 2020-2021, The Monero Project.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "NodeModel.h"
 | 
					#include "NodeModel.h"
 | 
				
			||||||
#include <utils/nodes.h>
 | 
					#include "utils/nodes.h"
 | 
				
			||||||
 | 
					#include "utils/ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NodeModel::NodeModel(int nodeSource, QObject *parent)
 | 
					NodeModel::NodeModel(int nodeSource, QObject *parent)
 | 
				
			||||||
        : QAbstractTableModel(parent)
 | 
					        : QAbstractTableModel(parent)
 | 
				
			||||||
| 
						 | 
					@ -69,9 +70,9 @@ QVariant NodeModel::data(const QModelIndex &index, int role) const {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(role == Qt::BackgroundRole) {
 | 
					    else if(role == Qt::BackgroundRole) {
 | 
				
			||||||
        if (node.isConnecting)
 | 
					        if (node.isConnecting)
 | 
				
			||||||
            return QBrush(QColor("#A9DEF9"));
 | 
					            return QBrush(ColorScheme::YELLOW.asColor(true));
 | 
				
			||||||
        else if (node.isActive)
 | 
					        else if (node.isActive)
 | 
				
			||||||
            return QBrush(QColor("#78BC61"));
 | 
					            return QBrush(ColorScheme::GREEN.asColor(true));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return QVariant();
 | 
					    return QVariant();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,7 @@
 | 
				
			||||||
#include "SubaddressModel.h"
 | 
					#include "SubaddressModel.h"
 | 
				
			||||||
#include "Subaddress.h"
 | 
					#include "Subaddress.h"
 | 
				
			||||||
#include "ModelUtils.h"
 | 
					#include "ModelUtils.h"
 | 
				
			||||||
 | 
					#include "utils/ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QPoint>
 | 
					#include <QPoint>
 | 
				
			||||||
#include <QColor>
 | 
					#include <QColor>
 | 
				
			||||||
| 
						 | 
					@ -56,8 +57,13 @@ QVariant SubaddressModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
            result = parseSubaddressRow(subaddress, index, role);
 | 
					            result = parseSubaddressRow(subaddress, index, role);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (role == Qt::BackgroundRole) {
 | 
					        else if (role == Qt::BackgroundRole) {
 | 
				
			||||||
 | 
					            switch(index.column()) {
 | 
				
			||||||
 | 
					                case Address:
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    if (subaddress.isUsed()) {
 | 
					                    if (subaddress.isUsed()) {
 | 
				
			||||||
                result = QBrush(QColor(255,100,100));
 | 
					                        result = QBrush(ColorScheme::RED.asColor(true));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (role == Qt::FontRole) {
 | 
					        else if (role == Qt::FontRole) {
 | 
				
			||||||
| 
						 | 
					@ -68,6 +74,16 @@ QVariant SubaddressModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        else if (role == Qt::ToolTipRole) {
 | 
				
			||||||
 | 
					            switch(index.column()) {
 | 
				
			||||||
 | 
					                case Address:
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (subaddress.isUsed()) {
 | 
				
			||||||
 | 
					                        result = "This address is used.";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!found)
 | 
					    if (!found)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,7 @@
 | 
				
			||||||
#include "TransactionHistory.h"
 | 
					#include "TransactionHistory.h"
 | 
				
			||||||
#include "TransactionInfo.h"
 | 
					#include "TransactionInfo.h"
 | 
				
			||||||
#include "globals.h"
 | 
					#include "globals.h"
 | 
				
			||||||
 | 
					#include "utils/ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TransactionHistoryModel::TransactionHistoryModel(QObject *parent)
 | 
					TransactionHistoryModel::TransactionHistoryModel(QObject *parent)
 | 
				
			||||||
    : QAbstractTableModel(parent),
 | 
					    : QAbstractTableModel(parent),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,7 @@
 | 
				
			||||||
#include "XmrToModel.h"
 | 
					#include "XmrToModel.h"
 | 
				
			||||||
#include "model/ModelUtils.h"
 | 
					#include "model/ModelUtils.h"
 | 
				
			||||||
#include "utils/xmrto.h"
 | 
					#include "utils/xmrto.h"
 | 
				
			||||||
 | 
					#include "utils/ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
XmrToModel::XmrToModel(QList<XmrToOrder*> *orders, QObject *parent)
 | 
					XmrToModel::XmrToModel(QList<XmrToOrder*> *orders, QObject *parent)
 | 
				
			||||||
        : QAbstractTableModel(parent),
 | 
					        : QAbstractTableModel(parent),
 | 
				
			||||||
| 
						 | 
					@ -61,15 +62,15 @@ QVariant XmrToModel::data(const QModelIndex &index, int role) const {
 | 
				
			||||||
    else if(role == Qt::BackgroundRole) {
 | 
					    else if(role == Qt::BackgroundRole) {
 | 
				
			||||||
        if (_col == 0) {
 | 
					        if (_col == 0) {
 | 
				
			||||||
            if (order->state == OrderState::Status_OrderPaid || order->state == OrderState::Status_OrderPaidUnconfirmed)
 | 
					            if (order->state == OrderState::Status_OrderPaid || order->state == OrderState::Status_OrderPaidUnconfirmed)
 | 
				
			||||||
                return QBrush(Qt::darkGreen);
 | 
					                return QBrush(ColorScheme::GREEN.asColor(true));
 | 
				
			||||||
            else if (order->state == OrderState::Status_OrderCreating || order->state == OrderState::Status_OrderToBeCreated)
 | 
					            else if (order->state == OrderState::Status_OrderCreating || order->state == OrderState::Status_OrderToBeCreated)
 | 
				
			||||||
                return QBrush(Qt::yellow);
 | 
					                return QBrush(ColorScheme::YELLOW.asColor(true));
 | 
				
			||||||
            else if (order->state == OrderState::Status_OrderUnpaid)
 | 
					            else if (order->state == OrderState::Status_OrderUnpaid)
 | 
				
			||||||
                return QBrush(Qt::cyan);
 | 
					                return QBrush(ColorScheme::YELLOW.asColor(true));
 | 
				
			||||||
            else if (order->state == OrderState::Status_OrderBTCSent)
 | 
					            else if (order->state == OrderState::Status_OrderBTCSent)
 | 
				
			||||||
                return QBrush(Qt::green);
 | 
					                return QBrush(ColorScheme::GREEN.asColor(true));
 | 
				
			||||||
            else if (order->state == OrderState::Status_OrderFailed || order->state == OrderState::Status_OrderTimedOut)
 | 
					            else if (order->state == OrderState::Status_OrderFailed || order->state == OrderState::Status_OrderTimedOut)
 | 
				
			||||||
                return QBrush(QColor(191, 255, 0)); // lime
 | 
					                return QBrush(ColorScheme::RED.asColor(true));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if (role == Qt::FontRole) {
 | 
					    else if (role == Qt::FontRole) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										39
									
								
								src/utils/ColorScheme.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/utils/ColorScheme.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,39 @@
 | 
				
			||||||
 | 
					// SPDX-License-Identifier: BSD-3-Clause
 | 
				
			||||||
 | 
					// Copyright (c) 2020-2021, The Monero Project.
 | 
				
			||||||
 | 
					// Copyright (c) 2012 thomasv@gitorious
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool ColorScheme::darkScheme = false;
 | 
				
			||||||
 | 
					ColorSchemeItem ColorScheme::GREEN   = ColorSchemeItem("#117c11", "#8af296");
 | 
				
			||||||
 | 
					ColorSchemeItem ColorScheme::YELLOW  = ColorSchemeItem("#897b2a", "#ffff00");
 | 
				
			||||||
 | 
					ColorSchemeItem ColorScheme::RED     = ColorSchemeItem("#7c1111", "#f18c8c");
 | 
				
			||||||
 | 
					ColorSchemeItem ColorScheme::BLUE    = ColorSchemeItem("#123b7c", "#8cb3f2");
 | 
				
			||||||
 | 
					ColorSchemeItem ColorScheme::DEFAULT = ColorSchemeItem("black", "white");
 | 
				
			||||||
 | 
					ColorSchemeItem ColorScheme::GRAY    = ColorSchemeItem("gray", "gray");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool ColorScheme::hasDarkBackground(QWidget *widget) {
 | 
				
			||||||
 | 
					    int r, g, b;
 | 
				
			||||||
 | 
					    widget->palette().color(QPalette::Background).getRgb(&r, &g, &b);
 | 
				
			||||||
 | 
					    auto brightness = r + g + b;
 | 
				
			||||||
 | 
					    return brightness < (255*3/2);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void ColorScheme::updateFromWidget(QWidget *widget, bool forceDark) {
 | 
				
			||||||
 | 
					    darkScheme = forceDark or ColorScheme::hasDarkBackground(widget);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString ColorSchemeItem::asStylesheet(bool background) {
 | 
				
			||||||
 | 
					    auto cssPrefix = background ? "background-" : "";
 | 
				
			||||||
 | 
					    auto color = this->getColor(background);
 | 
				
			||||||
 | 
					    return QString("QWidget { %1color : %2; }").arg(cssPrefix, color);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QColor ColorSchemeItem::asColor(bool background) {
 | 
				
			||||||
 | 
					    auto color = this->getColor(background);
 | 
				
			||||||
 | 
					    return QColor(color);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString ColorSchemeItem::getColor(bool background) {
 | 
				
			||||||
 | 
					    return m_colors[(int(background) + int(ColorScheme::darkScheme)) % 2];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										44
									
								
								src/utils/ColorScheme.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/utils/ColorScheme.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,44 @@
 | 
				
			||||||
 | 
					// SPDX-License-Identifier: BSD-3-Clause
 | 
				
			||||||
 | 
					// Copyright (c) 2020-2021, The Monero Project.
 | 
				
			||||||
 | 
					// Copyright (c) 2012 thomasv@gitorious
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef FEATHER_COLORSCHEME_H
 | 
				
			||||||
 | 
					#define FEATHER_COLORSCHEME_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QString>
 | 
				
			||||||
 | 
					#include <QVector>
 | 
				
			||||||
 | 
					#include <QColor>
 | 
				
			||||||
 | 
					#include <QWidget>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ColorSchemeItem {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    explicit ColorSchemeItem(const QString &fgColor, const QString &bgColor)
 | 
				
			||||||
 | 
					            : m_colors({fgColor, bgColor}) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QString asStylesheet(bool background = false);
 | 
				
			||||||
 | 
					    QColor asColor(bool background = false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    QString getColor(bool background);
 | 
				
			||||||
 | 
					    QVector<QString> m_colors;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ColorScheme {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    static bool darkScheme;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static ColorSchemeItem GREEN;
 | 
				
			||||||
 | 
					    static ColorSchemeItem YELLOW;
 | 
				
			||||||
 | 
					    static ColorSchemeItem RED;
 | 
				
			||||||
 | 
					    static ColorSchemeItem BLUE;
 | 
				
			||||||
 | 
					    static ColorSchemeItem DEFAULT;
 | 
				
			||||||
 | 
					    static ColorSchemeItem GRAY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static bool hasDarkBackground(QWidget *widget);
 | 
				
			||||||
 | 
					    static void updateFromWidget(QWidget *widget, bool forceDark = false);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif //FEATHER_COLORSCHEME_H
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue