mirror of
https://github.com/wownero/wowlet.git
synced 2026-11-21 15:44:10 +01:00
Plugins
This commit is contained in:
@@ -1,101 +0,0 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// SPDX-FileCopyrightText: 2020-2023 The Monero Project
|
||||
|
||||
#include "CalcConfigDialog.h"
|
||||
#include "ui_CalcConfigDialog.h"
|
||||
|
||||
#include "AppData.h"
|
||||
#include "utils/config.h"
|
||||
|
||||
CalcConfigDialog::CalcConfigDialog(QWidget *parent)
|
||||
: WindowModalDialog(parent)
|
||||
, ui(new Ui::CalcConfigDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->fillListWidgets();
|
||||
|
||||
connect(ui->btn_selectAll, &QPushButton::clicked, this, &CalcConfigDialog::selectAll);
|
||||
connect(ui->btn_deselectAll, &QPushButton::clicked, this, &CalcConfigDialog::deselectAll);
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, [this]{
|
||||
conf()->set(Config::fiatSymbols, this->checkedFiat());
|
||||
conf()->set(Config::cryptoSymbols, this->checkedCrypto());
|
||||
this->accept();
|
||||
});
|
||||
|
||||
this->adjustSize();
|
||||
}
|
||||
|
||||
QStringList CalcConfigDialog::checkedFiat() {
|
||||
return this->getChecked(ui->list_fiat);
|
||||
}
|
||||
|
||||
QStringList CalcConfigDialog::checkedCrypto() {
|
||||
return this->getChecked(ui->list_crypto);
|
||||
}
|
||||
|
||||
void CalcConfigDialog::selectAll() {
|
||||
this->setCheckState(this->getVisibleListWidget(), Qt::Checked);
|
||||
}
|
||||
|
||||
void CalcConfigDialog::deselectAll() {
|
||||
this->setCheckState(this->getVisibleListWidget(), Qt::Unchecked);
|
||||
}
|
||||
|
||||
void CalcConfigDialog::setCheckState(QListWidget *widget, Qt::CheckState checkState) {
|
||||
QListWidgetItem *item;
|
||||
for (int i=0; i < widget->count(); i++) {
|
||||
item = widget->item(i);
|
||||
item->setCheckState(checkState);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList CalcConfigDialog::getChecked(QListWidget *widget) {
|
||||
QStringList checked;
|
||||
QListWidgetItem *item;
|
||||
for (int i=0; i < widget->count(); i++) {
|
||||
item = widget->item(i);
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
checked.append(item->text());
|
||||
}
|
||||
}
|
||||
return checked;
|
||||
}
|
||||
|
||||
QListWidget* CalcConfigDialog::getVisibleListWidget() {
|
||||
if (ui->tabWidget->currentIndex() == 0) {
|
||||
return ui->list_fiat;
|
||||
} else {
|
||||
return ui->list_crypto;
|
||||
}
|
||||
}
|
||||
|
||||
void CalcConfigDialog::fillListWidgets() {
|
||||
QStringList cryptoCurrencies = appData()->prices.markets.keys();
|
||||
QStringList fiatCurrencies = appData()->prices.rates.keys();
|
||||
|
||||
QStringList checkedCryptoCurrencies = conf()->get(Config::cryptoSymbols).toStringList();
|
||||
QStringList checkedFiatCurrencies = conf()->get(Config::fiatSymbols).toStringList();
|
||||
|
||||
ui->list_crypto->addItems(cryptoCurrencies);
|
||||
ui->list_fiat->addItems(fiatCurrencies);
|
||||
|
||||
auto setChecked = [](QListWidget *widget, const QStringList &checked){
|
||||
QListWidgetItem *item;
|
||||
for (int i=0; i < widget->count(); i++) {
|
||||
item = widget->item(i);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
if (checked.contains(item->text())) {
|
||||
item->setCheckState(Qt::Checked);
|
||||
} else {
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
setChecked(ui->list_crypto, checkedCryptoCurrencies);
|
||||
setChecked(ui->list_fiat, checkedFiatCurrencies);
|
||||
}
|
||||
|
||||
CalcConfigDialog::~CalcConfigDialog() = default;
|
||||
@@ -1,41 +0,0 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// SPDX-FileCopyrightText: 2020-2023 The Monero Project
|
||||
|
||||
#ifndef FEATHER_CALCCONFIGDIALOG_H
|
||||
#define FEATHER_CALCCONFIGDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QListWidget>
|
||||
|
||||
#include "components.h"
|
||||
|
||||
namespace Ui {
|
||||
class CalcConfigDialog;
|
||||
}
|
||||
|
||||
class CalcConfigDialog : public WindowModalDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CalcConfigDialog(QWidget *parent = nullptr);
|
||||
~CalcConfigDialog() override;
|
||||
|
||||
QStringList checkedFiat();
|
||||
QStringList checkedCrypto();
|
||||
|
||||
private slots:
|
||||
void selectAll();
|
||||
void deselectAll();
|
||||
|
||||
private:
|
||||
void setCheckState(QListWidget *widget, Qt::CheckState checkState);
|
||||
QStringList getChecked(QListWidget *widget);
|
||||
void fillListWidgets();
|
||||
QListWidget* getVisibleListWidget();
|
||||
|
||||
QScopedPointer<Ui::CalcConfigDialog> ui;
|
||||
};
|
||||
|
||||
|
||||
#endif //FEATHER_CALCCONFIGDIALOG_H
|
||||
@@ -1,153 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CalcConfigDialog</class>
|
||||
<widget class="QDialog" name="CalcConfigDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>509</width>
|
||||
<height>574</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Calc config</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Fiat</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<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>
|
||||
<widget class="QListWidget" name="list_fiat"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Crypto</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<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>
|
||||
<widget class="QListWidget" name="list_crypto"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_selectAll">
|
||||
<property name="text">
|
||||
<string>Select all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_deselectAll">
|
||||
<property name="text">
|
||||
<string>Deselect all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CalcConfigDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CalcConfigDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user