mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-23 10:08:47 +02:00
build: fix -DWITH_SCANNER=Off
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// SPDX-FileCopyrightText: 2020-2023 The Monero Project
|
||||
|
||||
#include "URWidget.h"
|
||||
#include "ui_URWidget.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QMenu>
|
||||
|
||||
#include "dialog/URSettingsDialog.h"
|
||||
#include "utils/config.h"
|
||||
|
||||
URWidget::URWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::URWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(&m_timer, &QTimer::timeout, this, &URWidget::nextQR);
|
||||
connect(ui->btn_options, &QPushButton::clicked, this, &URWidget::setOptions);
|
||||
}
|
||||
|
||||
void URWidget::setData(const QString &type, const std::string &data) {
|
||||
m_type = type;
|
||||
m_data = data;
|
||||
|
||||
m_timer.stop();
|
||||
allParts.clear();
|
||||
|
||||
if (m_data.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string type_std = m_type.toStdString();
|
||||
|
||||
ur::ByteVector a = ur::string_to_bytes(m_data);
|
||||
ur::ByteVector cbor;
|
||||
ur::CborLite::encodeBytes(cbor, a);
|
||||
ur::UR h = ur::UR(type_std, cbor);
|
||||
|
||||
int bytesPerFragment = conf()->get(Config::URfragmentLength).toInt();
|
||||
|
||||
delete m_urencoder;
|
||||
m_urencoder = new ur::UREncoder(h, bytesPerFragment);
|
||||
|
||||
for (int i=0; i < m_urencoder->seq_len(); i++) {
|
||||
allParts.append(m_urencoder->next_part());
|
||||
}
|
||||
|
||||
m_timer.setInterval(conf()->get(Config::URmsPerFragment).toInt());
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
void URWidget::nextQR() {
|
||||
currentIndex = currentIndex % m_urencoder->seq_len();
|
||||
|
||||
std::string data;
|
||||
if (conf()->get(Config::URfountainCode).toBool()) {
|
||||
data = m_urencoder->next_part();
|
||||
} else {
|
||||
data = allParts[currentIndex];
|
||||
}
|
||||
|
||||
ui->label_seq->setText(QString("%1/%2").arg(QString::number(currentIndex % m_urencoder->seq_len() + 1), QString::number(m_urencoder->seq_len())));
|
||||
|
||||
m_code = new QrCode{QString::fromStdString(data), QrCode::Version::AUTO, QrCode::ErrorCorrectionLevel::MEDIUM};
|
||||
ui->qrWidget->setQrCode(m_code);
|
||||
|
||||
currentIndex += 1;
|
||||
}
|
||||
|
||||
void URWidget::setOptions() {
|
||||
URSettingsDialog dialog{this};
|
||||
dialog.exec();
|
||||
this->setData(m_type, m_data);
|
||||
}
|
||||
|
||||
URWidget::~URWidget() {
|
||||
delete m_urencoder;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// SPDX-FileCopyrightText: 2020-2023 The Monero Project
|
||||
|
||||
#ifndef FEATHER_URWIDGET_H
|
||||
#define FEATHER_URWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
#include "qrcode/QrCode.h"
|
||||
#include "widgets/QrCodeWidget.h"
|
||||
#include <bcur/bc-ur.hpp>
|
||||
|
||||
namespace Ui {
|
||||
class URWidget;
|
||||
}
|
||||
|
||||
class URWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit URWidget(QWidget *parent = nullptr);
|
||||
~URWidget();
|
||||
|
||||
void setData(const QString &type, const std::string &data);
|
||||
|
||||
private slots:
|
||||
void nextQR();
|
||||
void setOptions();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::URWidget> ui;
|
||||
QTimer m_timer;
|
||||
ur::UREncoder *m_urencoder = nullptr;
|
||||
QrCode *m_code = nullptr;
|
||||
QList<std::string> allParts;
|
||||
qsizetype currentIndex = 0;
|
||||
|
||||
std::string m_data;
|
||||
QString m_type;
|
||||
};
|
||||
|
||||
#endif //FEATHER_URWIDGET_H
|
||||
@@ -1,85 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>URWidget</class>
|
||||
<widget class="QWidget" name="URWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QrCodeWidget" name="qrWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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="QLabel" name="label_seq">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_options">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../assets.qrc">
|
||||
<normaloff>:/assets/images/preferences.svg</normaloff>:/assets/images/preferences.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QrCodeWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/QrCodeWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../assets.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user