[Dev] Documenting Feathercoin Specific Software settings - Part 5
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
add qrcode : - commit
https://github.com/FeatherCoin/Feathercoin/commit/6f0ff3bb8b59d5955d1fcb9614ed9259061ca882
src/qt/addressbookpage.cpp
Include QR codes zxing.
+// Copyright (c) 2013-2015 The Feathercoin developers
Copyright - needs update
+ #include "optionsmodel.h" + #ifdef USE_QRCODE + #include "qrcodedialog.h" + #endif + #ifdef USE_ZXING + #include "snapwidget.h" + #endif + + optionsModel(0), + #ifndef USE_QRCODE + ui->showQRCode->setVisible(false); + #else + ui->showQRCode->setVisible(true); + #endif + #ifndef USE_ZXING + ui->importQRCodeButton->setVisible(false); + #endif + QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this); + #ifdef USE_QRCODE + contextMenu->addAction(showQRCodeAction); + #endif
Include zxing code for QRCodes
+ connect(showQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showQRCode_clicked()));
QR Code addition
+ void AddressBookPage::setOptionsModel(OptionsModel *optionsModel) + { + this->optionsModel = optionsModel; + } + ui->showQRCode->setEnabled(true); + ui->importQRCodeButton->setEnabled(true); + ui->showQRCode->setEnabled(false);
QR code additions
+ void AddressBookPage::on_showQRCode_clicked() + { + #ifdef USE_QRCODE + if(!model) + return; + + QTableView *table = ui->tableView; + QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); + + foreach (QModelIndex index, indexes) + { + QString address = index.data().toString(); + QString label = index.sibling(index.row(), 0).data(Qt::EditRole).toString(); + + QRCodeDialog *dialog = new QRCodeDialog(address, label, tab == ReceivingTab, this); + dialog->setModel(optionsModel); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); + } + #endif + } + + void AddressBookPage::on_importQRCodeButton_clicked() + { + #ifdef USE_ZXING + SnapWidget* snap = new SnapWidget(this); + connect(snap, SIGNAL(finished(QString)), this, SLOT(onSnapClosed(QString))); + #endif + } +
QR code additions
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
add qrcode : - commit
https://github.com/FeatherCoin/Feathercoin/commit/6f0ff3bb8b59d5955d1fcb9614ed9259061ca882
src/qt/addressbookpage.h
Include QR codes zxing.
+ void setOptionsModel(OptionsModel *optionsModel);
Additional code
+ OptionsModel *optionsModel;
Additional code
+ /** Generate a QR Code from the currently selected address */ + void on_showQRCode_clicked(); + /** Import from a QR Code into your wallet */ + void on_importQRCodeButton_clicked();
Additional code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
add qrcode : - commit
https://github.com/FeatherCoin/Feathercoin/commit/6f0ff3bb8b59d5955d1fcb9614ed9259061ca882
src/qt/forms/aboutdialog.ui
Include QR codes zxing.
+ <width>525</width> - <height>319</height> + <height>317</height>
Code relaced
+ <pixmap resource="../feathercoin.qrc">:/images/about</pixmap> + <string notr="true">0.9.3.0-Standard</string> + <string><html><head/><body><p><br/>This is not experiment,This is our real life and great history.Our goal is to let you have a good time.</p><p><br/>Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php.</p><p>This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young ([email protected]) and UPnP software written by Thomas Bernard.</p></body></html></string>
Code replaced
+ <include location="../feathercoin.qrc"/> + <include location="C:/Users/lizhi.lizhi-PC/.designer/feathercoin.qrc"/>
Code replaced.
Is this include correct?
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
add qrcode : - commit
https://github.com/FeatherCoin/Feathercoin/commit/6f0ff3bb8b59d5955d1fcb9614ed9259061ca882
src/qt/forms/addressbookpage.ui
Include QR codes zxing.
+ <iconset resource="../feathercoin.qrc"> + <iconset resource="../feathercoin.qrc">
Code replaced
+ <widget class="QPushButton" name="showQRCode"> + <property name="text"> + <string>Show &QR Code</string> + </property> + <property name="icon"> + <iconset resource="../feathercoin.qrc"> + <normaloff>:/icons/qrcode</normaloff>:/icons/qrcode</iconset> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="importQRCodeButton"> + <property name="text"> + <string>&Import QR</string> + </property> + <property name="icon"> + <iconset resource="../feathercoin.qrc"> + <normaloff>:/icons/qrcode</normaloff>:/icons/qrcode</iconset> + </property> + </widget> + </item> + <item>
Code added
+ <iconset resource="../feathercoin.qrc"> + <iconset resource="../feathercoin.qrc"> + <include location="../feathercoin.qrc"/>
Code replaced name
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
add qrcode : - commit
https://github.com/FeatherCoin/Feathercoin/commit/6f0ff3bb8b59d5955d1fcb9614ed9259061ca882
src/qt/forms/qrcodedialog.ui
Include QR codes zxing.
New file 235 lines of code.
+ <?xml version="1.0" encoding="UTF-8"?> + <ui version="4.0"> + <class>QRCodeDialog</class> + <widget class="QDialog" name="QRCodeDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>340</width> + <height>543</height> + </rect> + </property> + <property name="windowTitle"> + <string>QR Code Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item>
Start of new code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
add qrcode : - commit
https://github.com/FeatherCoin/Feathercoin/commit/6f0ff3bb8b59d5955d1fcb9614ed9259061ca882
src/qt/forms/snapwidget.ui
Include QR codes zxing.
New file 51 lines of code.
+ <?xml version="1.0" encoding="UTF-8"?> + <ui version="4.0"> + <class>SnapWidget</class> + <widget class="QWidget" name="SnapWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>434</width> + <height>365</height> + </rect> + </property> + <property name="windowTitle"> + <string/> + </property> + <widget class="QPushButton" name="snapButton">
Start of new file
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
add qrcode : - commit
https://github.com/FeatherCoin/Feathercoin/commit/6f0ff3bb8b59d5955d1fcb9614ed9259061ca882
src/qt/qrcodedialog.cpp
Include QR codes zxing.
New file 173 lines of code.
+ #include "qrcodedialog.h" + #include "ui_qrcodedialog.h" + + #include "bitcoinunits.h" + #include "guiconstants.h" + #include "guiutil.h" + #include "optionsmodel.h" + + #include <QPixmap> + #if QT_VERSION < 0x050000 + #include <QUrl> + #endif + + #include <qrencode.h> + + QRCodeDialog::QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent) : + QDialog(parent),
Start of code on new file
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
Include QR codes zxing.
+define(_USE_ZXING,1)
Add zxing code
+AC_DEFINE(USE_ZXING, _USE_ZXING,[Define to 1 libzxing must be available for support])
Code added
+AC_SUBST(USE_ZXING, _USE_ZXING)
zxing code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/Makefile.am
Include QR codes zxing.
+ forms/qrcodedialog.ui \ + forms/snapwidget.ui \ + moc_qrcodedialog.cpp \ + moc_snapwidget.cpp \ + qrcodedialog.h \ + snapwidget.h \ + qimagesource.h \ + qrcodedialog.cpp \ + snapwidget.cpp \ + qimagesource.cpp \
zxing Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/feathercoin.qrc
Include QR codes zxing.
+ <file alias="merchant_bit">res/images/bittrex.png</file>
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/forms/merchantlist.ui
Include QR codes zxing.
+ <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QLabel" name="label_left_5"> + <property name="cursor"> + <cursorShape>PointingHandCursor</cursorShape> + </property> + <property name="toolTip"> + <string>a altcoin currency exchange</string> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="../feathercoin.qrc">:/images/merchant_bit</pixmap> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_left_6"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item>
Code included
- <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> - <widget class="QLabel" name="label_left_5"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_left_6"> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item>
Code removed
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/forms/sendcoinsdialog.ui
Include QR codes zxing. User interface changes
+ <property name="margin">
Code added
- <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin">
Code removed
+ <height>177</height>
Code added
- <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin">
Code removed
+ <iconset resource="../feathercoin.qrc"> + <iconset resource="../feathercoin.qrc"> + <iconset resource="../feathercoin.qrc">
Code replaced
+ <widget class="QPushButton" name="sendQRButton"> + <property name="text"> + <string>Send To &QR</string> + </property> + <property name="icon"> + <iconset resource="../feathercoin.qrc"> + <normaloff>:/icons/qrcode</normaloff>:/icons/qrcode</iconset> + </property> + </widget> + </item> + <item>
Code added
+ <include location="../feathercoin.qrc"/>
Code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/merchantlist.cpp
+ ui->label_left_5->installEventFilter(this); + ui->label_left_6->installEventFilter(this);
Code replaced
+ if (obj == ui->label_left_5) { + QDesktopServices::openUrl(QUrl("https://bittrex.com/Market/?MarketName=BTC-FTC")); + return true; + }
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/qimagesource.cpp
New file addition
+ #include "qimagesource.h" + #include <QColor> + + QImageLuminanceSource::QImageLuminanceSource(QImage& _image) : LuminanceSource(_image.width(), _image.height()) + { + image = _image.copy(); + } + + + ArrayRef<char> QImageLuminanceSource::getRow(int y, ArrayRef<char> _row) const + { + for (int x = 0; x < this->getWidth(); x + + ) + _row[x] = qGray(image.pixel(x, y)); + return _row; + } + + ArrayRef<char> QImageLuminanceSource::getMatrix() const + { + ArrayRef<char> mymatrix(width*height); + for (int y = 0; y < height; y + + ) + { + for (int x = 0; x < width; x + + ) { + mymatrix[y*width + x] = qGray(image.pixel(x, y)); + } + } + return mymatrix; + } +
New file code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/qimagesource.h
New file addition
+ #ifndef QIMAGELUMINANCESOURCE_H + #define QIMAGELUMINANCESOURCE_H + + #include <QImage> + #include <QString> + #include <zxing/LuminanceSource.h> + + using namespace zxing; + + class QImageLuminanceSource : public LuminanceSource + { + public: + QImageLuminanceSource(QImage& image); + ArrayRef<char> getMatrix() const; + ArrayRef<char> getRow(int y, ArrayRef<char> row) const; + + private: + QImage image; + }; + + #endif //QIMAGELUMINANCESOURCE_H
New file code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/res/images/*
+ src/qt/res/images/bittrex.png
New image file addition
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/sendcoinsdialog.cpp*
+ #include <QClipboard> + #ifdef USE_ZXING + #include "snapwidget.h" + #endif +
New code
+ ui->sendQRButton->setIcon(QIcon());
Code replaced
+ #ifndef USE_ZXING + this->ui->sendQRButton->hide(); + #endif +
Code added
+ void SendCoinsDialog::on_sendQRButton_clicked() + { + #ifdef USE_ZXING + SnapWidget* snap = new SnapWidget(this); + connect(snap, SIGNAL(finished(QString)), this, SLOT(onSnapClosed(QString))); + #endif + } + + void SendCoinsDialog::onSnapClosed(QString s) + { + emit sendCoins(s); + } +
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/sendcoinsdialog.h*
+ /** Scan of QR code finished */ + void onSnapClosed(QString s); + + void on_sendQRButton_clicked(); + void signMessage(QString addr); + void verifyMessage(QString addr); + void sendCoins(QString addr);
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
qt/sendcoinsentry.cpp*
- ui->payTo->setText(address);
Code removed
+ //may have been scanned in so it must be parsed first + if (address.size() > 34) { + QString _address; + QString _label; + QString _amount; + int x = address.indexOf(":", 0, Qt::CaseInsensitive); + if (x) + _address = address.mid(x + 1, 34); + //Todo: parse out label and amount from incoming string + ui->payTo->setText(_address); + } + else { + ui->payTo->setText(address); + }
Code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add QR-Snap : - commit
https://github.com/FeatherCoin/Feathercoin/commit/8ba72918a0710ef66df39a5df97725b1a7b740b4
src/qt/snapwidget.cpp
New file
+ // Copyright (c) 2013-2014 The Feathercoin developers + + #include "snapwidget.h" + #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + #include <QtWidgets> + #include <QDialog> + #else + #include <QDesktopWidget> + #endif + #include <zxing/common/GlobalHistogramBinarizer.h> + #include <zxing/Binarizer.h> + #include <zxing/BinaryBitmap.h> + #include <zxing/MultiFormatReader.h> + #include "qimagesource.h" + + + ////////////////// SnapWidget Class + SnapWidget::SnapWidget(QWidget* _parent) + #ifdef Q_OS_MAC
Start of new file code 114 lines