mirror of
				https://git.wownero.com/wowlet/wowlet.git
				synced 2024-08-15 01:03:14 +00:00 
			
		
		
		
	Custom SuchWow donation tip amount
This commit is contained in:
		
							parent
							
								
									0d502f0e45
								
							
						
					
					
						commit
						624f13b2d9
					
				
					 7 changed files with 63 additions and 20 deletions
				
			
		| 
						 | 
					@ -274,6 +274,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
 | 
				
			||||||
    // settings connects
 | 
					    // settings connects
 | 
				
			||||||
    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, this, &MainWindow::onUpdateFiatBalanceWidget);
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, this, &MainWindow::onUpdateFiatBalanceWidget);
 | 
				
			||||||
    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, m_ctx, &AppContext::onPreferredFiatCurrencyChanged);
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, m_ctx, &AppContext::onPreferredFiatCurrencyChanged);
 | 
				
			||||||
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, ui->suchWowWidget, &SuchWowWidget::onPreferredFiatCurrencyChanged);
 | 
				
			||||||
    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, ui->sendWidget, QOverload<>::of(&SendWidget::onPreferredFiatCurrencyChanged));
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, ui->sendWidget, QOverload<>::of(&SendWidget::onPreferredFiatCurrencyChanged));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Skin
 | 
					    // Skin
 | 
				
			||||||
| 
						 | 
					@ -1078,7 +1079,9 @@ void MainWindow::showSendScreen(const CCSEntry &entry) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MainWindow::suchDonate(const QString address) {
 | 
					void MainWindow::suchDonate(const QString address) {
 | 
				
			||||||
    double donation = AppContext::prices->convert("EUR", "WOW", 2);
 | 
					    double tipAmount = config()->get(Config::suchWowTipAmount).toDouble();
 | 
				
			||||||
 | 
					    QString preferredCurrency = config()->get(Config::preferredFiatCurrency).toString();
 | 
				
			||||||
 | 
					    double donation = AppContext::prices->convert(preferredCurrency, "WOW", tipAmount);
 | 
				
			||||||
    ui->sendWidget->fill(address, "SuchWow contribution :-)", donation);
 | 
					    ui->sendWidget->fill(address, "SuchWow contribution :-)", donation);
 | 
				
			||||||
    ui->tabWidget->setCurrentIndex(Tabs::SEND);
 | 
					    ui->tabWidget->setCurrentIndex(Tabs::SEND);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,8 +64,6 @@ void SendWidget::addressEdited() {
 | 
				
			||||||
    if (outputs.size() > 0) {
 | 
					    if (outputs.size() > 0) {
 | 
				
			||||||
        ui->lineAmount->setText(WalletManager::displayAmount(ui->lineAddress->getTotal()));
 | 
					        ui->lineAmount->setText(WalletManager::displayAmount(ui->lineAddress->getTotal()));
 | 
				
			||||||
        ui->comboCurrencySelection->setCurrentIndex(0);
 | 
					        ui->comboCurrencySelection->setCurrentIndex(0);
 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        ui->lineAmount->setText("");
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ui->btn_openAlias->setVisible(ui->lineAddress->isOpenAlias());
 | 
					    ui->btn_openAlias->setVisible(ui->lineAddress->isOpenAlias());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,8 +48,9 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
 | 
				
			||||||
        {Config::hideBalance, {QS("hideBalance"), false}},
 | 
					        {Config::hideBalance, {QS("hideBalance"), false}},
 | 
				
			||||||
        {Config::hideFiatBalance, {QS("hideFiatBalance"), false}},
 | 
					        {Config::hideFiatBalance, {QS("hideFiatBalance"), false}},
 | 
				
			||||||
        {Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}},
 | 
					        {Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}},
 | 
				
			||||||
 | 
					        {Config::showHistorySyncNotice, {QS("showHistorySyncNotice"), true}},
 | 
				
			||||||
        {Config::ignoreUpdateWarning, {QS("ignoreUpdateWarning"), ""}},
 | 
					        {Config::ignoreUpdateWarning, {QS("ignoreUpdateWarning"), ""}},
 | 
				
			||||||
        {Config::showHistorySyncNotice, {QS("showHistorySyncNotice"), true}}
 | 
					        {Config::suchWowTipAmount, {QS("suchWowTipAmount"), 0.75}}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,8 @@ public:
 | 
				
			||||||
        hideFiatBalance,
 | 
					        hideFiatBalance,
 | 
				
			||||||
        redditFrontend,
 | 
					        redditFrontend,
 | 
				
			||||||
        showHistorySyncNotice,
 | 
					        showHistorySyncNotice,
 | 
				
			||||||
        ignoreUpdateWarning
 | 
					        ignoreUpdateWarning,
 | 
				
			||||||
 | 
					        suchWowTipAmount
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ~Config() override;
 | 
					    ~Config() override;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,6 +47,16 @@ SuchWowWidget::SuchWowWidget(QWidget *parent) :
 | 
				
			||||||
    m_contextMenu->addAction("Donate", this, &SuchWowWidget::suchDonate);
 | 
					    m_contextMenu->addAction("Donate", this, &SuchWowWidget::suchDonate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &SuchWowWidget::showContextMenu);
 | 
					    connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &SuchWowWidget::showContextMenu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // tip amount slider
 | 
				
			||||||
 | 
					    ui->slider_tipAmount->setMinimum(1);
 | 
				
			||||||
 | 
					    ui->slider_tipAmount->setMaximum(60);
 | 
				
			||||||
 | 
					    ui->slider_tipAmount->setTickInterval(1);
 | 
				
			||||||
 | 
					    ui->slider_tipAmount->setSingleStep(1);
 | 
				
			||||||
 | 
					    double tipAmount = config()->get(Config::suchWowTipAmount).toDouble();
 | 
				
			||||||
 | 
					    ui->slider_tipAmount->setValue((int)(tipAmount * 10));
 | 
				
			||||||
 | 
					    connect(ui->slider_tipAmount, &QSlider::valueChanged, this, &SuchWowWidget::onTipSliderChanged);
 | 
				
			||||||
 | 
					    this->setTipAmountLabel();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SuchWowWidget::setupTable() {
 | 
					void SuchWowWidget::setupTable() {
 | 
				
			||||||
| 
						 | 
					@ -136,6 +146,24 @@ SuchWowPost *SuchWowWidget::itemToPost() {
 | 
				
			||||||
    return nullptr;
 | 
					    return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void SuchWowWidget::setTipAmountLabel(double tipAmount) {
 | 
				
			||||||
 | 
					    if(tipAmount == 0.0)
 | 
				
			||||||
 | 
					        tipAmount = config()->get(Config::suchWowTipAmount).toDouble();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QString amount_fmt = Utils::amountToCurrencyString(tipAmount, config()->get(Config::preferredFiatCurrency).toString());
 | 
				
			||||||
 | 
					    ui->label_tipAmount->setText(QString("Default tip amount (%1)").arg(amount_fmt));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void SuchWowWidget::onTipSliderChanged(int value) {
 | 
				
			||||||
 | 
					    double amount = (double)value / 10;
 | 
				
			||||||
 | 
					    config()->set(Config::suchWowTipAmount, amount);
 | 
				
			||||||
 | 
					    setTipAmountLabel(amount);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void SuchWowWidget::onPreferredFiatCurrencyChanged(const QString &symbol) {
 | 
				
			||||||
 | 
					    this->setTipAmountLabel();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SuchWowWidget::~SuchWowWidget() {
 | 
					SuchWowWidget::~SuchWowWidget() {
 | 
				
			||||||
    delete ui;
 | 
					    delete ui;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,10 +76,12 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public slots:
 | 
					public slots:
 | 
				
			||||||
    void onWS(QJsonArray such_data);
 | 
					    void onWS(QJsonArray such_data);
 | 
				
			||||||
 | 
					    void onPreferredFiatCurrencyChanged(const QString &symbol);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private slots:
 | 
					private slots:
 | 
				
			||||||
    void addThumb(SuchWowPost *post);
 | 
					    void addThumb(SuchWowPost *post);
 | 
				
			||||||
    void showImage(SuchWowPost *post);
 | 
					    void showImage(SuchWowPost *post);
 | 
				
			||||||
 | 
					    void onTipSliderChanged(int value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
    void donate(QString donate);
 | 
					    void donate(QString donate);
 | 
				
			||||||
| 
						 | 
					@ -89,6 +91,7 @@ private:
 | 
				
			||||||
    void setupTable();
 | 
					    void setupTable();
 | 
				
			||||||
    void suchDonate();
 | 
					    void suchDonate();
 | 
				
			||||||
    void suchImage();
 | 
					    void suchImage();
 | 
				
			||||||
 | 
					    void setTipAmountLabel(double tipAmount = 0.0);
 | 
				
			||||||
    SuchWowPost* itemToPost();
 | 
					    SuchWowPost* itemToPost();
 | 
				
			||||||
    void showContextMenu(const QPoint &pos);
 | 
					    void showContextMenu(const QPoint &pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,24 +14,33 @@
 | 
				
			||||||
   <string>Form</string>
 | 
					   <string>Form</string>
 | 
				
			||||||
  </property>
 | 
					  </property>
 | 
				
			||||||
  <layout class="QVBoxLayout" name="verticalLayout">
 | 
					  <layout class="QVBoxLayout" name="verticalLayout">
 | 
				
			||||||
   <property name="spacing">
 | 
					 | 
				
			||||||
    <number>4</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="leftMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="topMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="rightMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="bottomMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <item>
 | 
					   <item>
 | 
				
			||||||
    <widget class="QListWidget" name="listWidget"/>
 | 
					    <widget class="QListWidget" name="listWidget"/>
 | 
				
			||||||
   </item>
 | 
					   </item>
 | 
				
			||||||
 | 
					   <item>
 | 
				
			||||||
 | 
					    <layout class="QFormLayout" name="formLayout">
 | 
				
			||||||
 | 
					     <item row="0" column="0">
 | 
				
			||||||
 | 
					      <widget class="QLabel" name="label_tipAmount">
 | 
				
			||||||
 | 
					       <property name="text">
 | 
				
			||||||
 | 
					        <string>Default tip amount</string>
 | 
				
			||||||
 | 
					       </property>
 | 
				
			||||||
 | 
					      </widget>
 | 
				
			||||||
 | 
					     </item>
 | 
				
			||||||
 | 
					     <item row="0" column="1">
 | 
				
			||||||
 | 
					      <widget class="QSlider" name="slider_tipAmount">
 | 
				
			||||||
 | 
					       <property name="maximumSize">
 | 
				
			||||||
 | 
					        <size>
 | 
				
			||||||
 | 
					         <width>280</width>
 | 
				
			||||||
 | 
					         <height>16777215</height>
 | 
				
			||||||
 | 
					        </size>
 | 
				
			||||||
 | 
					       </property>
 | 
				
			||||||
 | 
					       <property name="orientation">
 | 
				
			||||||
 | 
					        <enum>Qt::Horizontal</enum>
 | 
				
			||||||
 | 
					       </property>
 | 
				
			||||||
 | 
					      </widget>
 | 
				
			||||||
 | 
					     </item>
 | 
				
			||||||
 | 
					    </layout>
 | 
				
			||||||
 | 
					   </item>
 | 
				
			||||||
  </layout>
 | 
					  </layout>
 | 
				
			||||||
 </widget>
 | 
					 </widget>
 | 
				
			||||||
 <resources/>
 | 
					 <resources/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue