mirror of
				https://git.wownero.com/wowlet/wowlet.git
				synced 2024-08-15 01:03:14 +00:00 
			
		
		
		
	Calc: update exchange icon on skin change
This commit is contained in:
		
							parent
							
								
									e0f7473ed4
								
							
						
					
					
						commit
						904432ea82
					
				
					 7 changed files with 54 additions and 4 deletions
				
			
		| 
						 | 
					@ -6,6 +6,8 @@
 | 
				
			||||||
#include "calcwidget.h"
 | 
					#include "calcwidget.h"
 | 
				
			||||||
#include "ui_calcwidget.h"
 | 
					#include "ui_calcwidget.h"
 | 
				
			||||||
#include "mainwindow.h"
 | 
					#include "mainwindow.h"
 | 
				
			||||||
 | 
					#include "components.h"
 | 
				
			||||||
 | 
					#include "utils/ColorScheme.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CalcWidget::CalcWidget(QWidget *parent) :
 | 
					CalcWidget::CalcWidget(QWidget *parent) :
 | 
				
			||||||
        QWidget(parent),
 | 
					        QWidget(parent),
 | 
				
			||||||
| 
						 | 
					@ -15,8 +17,7 @@ CalcWidget::CalcWidget(QWidget *parent) :
 | 
				
			||||||
    m_ctx = MainWindow::getContext();
 | 
					    m_ctx = MainWindow::getContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ui->imageExchange->setBackgroundRole(QPalette::Base);
 | 
					    ui->imageExchange->setBackgroundRole(QPalette::Base);
 | 
				
			||||||
    QPixmap pm(":/assets/images/exchange.png");
 | 
					    ui->imageExchange->setAssets(":/assets/images/exchange.png", ":/assets/images/exchange_white.png");
 | 
				
			||||||
    ui->imageExchange->setPixmap(pm);
 | 
					 | 
				
			||||||
    ui->imageExchange->setScaledContents(true);
 | 
					    ui->imageExchange->setScaledContents(true);
 | 
				
			||||||
    ui->imageExchange->setFixedSize(26, 26);
 | 
					    ui->imageExchange->setFixedSize(26, 26);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -134,6 +135,10 @@ void CalcWidget::initComboBox() {
 | 
				
			||||||
    this->m_comboBoxInit = true;
 | 
					    this->m_comboBoxInit = true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CalcWidget::skinChanged() {
 | 
				
			||||||
 | 
					    ui->imageExchange->setMode(ColorScheme::hasDarkBackground(this));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CalcWidget::~CalcWidget() {
 | 
					CalcWidget::~CalcWidget() {
 | 
				
			||||||
    delete ui;
 | 
					    delete ui;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,7 @@ public slots:
 | 
				
			||||||
    void toComboChanged(const QString& data);
 | 
					    void toComboChanged(const QString& data);
 | 
				
			||||||
    void initFiat();
 | 
					    void initFiat();
 | 
				
			||||||
    void initCrypto();
 | 
					    void initCrypto();
 | 
				
			||||||
 | 
					    void skinChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    Ui::CalcWidget *ui;
 | 
					    Ui::CalcWidget *ui;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,7 +84,7 @@
 | 
				
			||||||
            </layout>
 | 
					            </layout>
 | 
				
			||||||
           </item>
 | 
					           </item>
 | 
				
			||||||
           <item row="0" column="1">
 | 
					           <item row="0" column="1">
 | 
				
			||||||
            <widget class="QLabel" name="imageExchange">
 | 
					            <widget class="DoublePixmapLabel" name="imageExchange">
 | 
				
			||||||
             <property name="text">
 | 
					             <property name="text">
 | 
				
			||||||
              <string>exchange image</string>
 | 
					              <string>exchange image</string>
 | 
				
			||||||
             </property>
 | 
					             </property>
 | 
				
			||||||
| 
						 | 
					@ -159,6 +159,13 @@
 | 
				
			||||||
   </item>
 | 
					   </item>
 | 
				
			||||||
  </layout>
 | 
					  </layout>
 | 
				
			||||||
 </widget>
 | 
					 </widget>
 | 
				
			||||||
 | 
					 <customwidgets>
 | 
				
			||||||
 | 
					  <customwidget>
 | 
				
			||||||
 | 
					   <class>DoublePixmapLabel</class>
 | 
				
			||||||
 | 
					   <extends>QLabel</extends>
 | 
				
			||||||
 | 
					   <header>components.h</header>
 | 
				
			||||||
 | 
					  </customwidget>
 | 
				
			||||||
 | 
					 </customwidgets>
 | 
				
			||||||
 <resources/>
 | 
					 <resources/>
 | 
				
			||||||
 <connections>
 | 
					 <connections>
 | 
				
			||||||
  <connection>
 | 
					  <connection>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,24 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QtWidgets>
 | 
					#include <QtWidgets>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DoublePixmapLabel::DoublePixmapLabel(QWidget *parent)
 | 
				
			||||||
 | 
					        : QLabel(parent)
 | 
				
			||||||
 | 
					{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DoublePixmapLabel::setAssets(const QString &firstAsset, const QString &secondAsset)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    m_first.load(firstAsset);
 | 
				
			||||||
 | 
					    m_second.load(secondAsset);
 | 
				
			||||||
 | 
					    this->setPixmap(m_first);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DoublePixmapLabel::setMode(bool mode) {
 | 
				
			||||||
 | 
					    if (mode != m_mode) {
 | 
				
			||||||
 | 
					        this->setPixmap(mode ? m_second : m_first);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    m_mode = mode;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
StatusBarButton::StatusBarButton(const QIcon &icon, const QString &tooltip, QWidget *parent) : QPushButton(parent) {
 | 
					StatusBarButton::StatusBarButton(const QIcon &icon, const QString &tooltip, QWidget *parent) : QPushButton(parent) {
 | 
				
			||||||
    setIcon(icon);
 | 
					    setIcon(icon);
 | 
				
			||||||
    setToolTip(tooltip);
 | 
					    setToolTip(tooltip);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,23 @@
 | 
				
			||||||
#include <QPlainTextEdit>
 | 
					#include <QPlainTextEdit>
 | 
				
			||||||
#include <QLineEdit>
 | 
					#include <QLineEdit>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class DoublePixmapLabel : public QLabel
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    explicit DoublePixmapLabel(QWidget *parent = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public slots:
 | 
				
			||||||
 | 
					    void setAssets(const QString &firstAsset, const QString &secondAsset);
 | 
				
			||||||
 | 
					    void setMode(bool mode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    bool m_mode = false;
 | 
				
			||||||
 | 
					    QPixmap m_first;
 | 
				
			||||||
 | 
					    QPixmap m_second;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class StatusBarButton : public QPushButton
 | 
					class StatusBarButton : public QPushButton
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Q_OBJECT
 | 
					    Q_OBJECT
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1019,6 +1019,8 @@ void MainWindow::skinChanged(const QString &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);
 | 
					    ColorScheme::updateFromWidget(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ui->conversionWidget->skinChanged();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MainWindow::closeEvent(QCloseEvent *event) {
 | 
					void MainWindow::closeEvent(QCloseEvent *event) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,7 @@ bool ColorScheme::hasDarkBackground(QWidget *widget) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ColorScheme::updateFromWidget(QWidget *widget, bool forceDark) {
 | 
					void ColorScheme::updateFromWidget(QWidget *widget, bool forceDark) {
 | 
				
			||||||
    darkScheme = forceDark or ColorScheme::hasDarkBackground(widget);
 | 
					    darkScheme = forceDark || ColorScheme::hasDarkBackground(widget);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString ColorSchemeItem::asStylesheet(bool background) {
 | 
					QString ColorSchemeItem::asStylesheet(bool background) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue