defd3950f0
The CAmount name is not helpful as its just an int64_t and not a class, like the name implies. There were a handful of places where it was passed in as const-ref, as a good example of this actually creating sub-par code.
90 lines
2.5 KiB
C++
90 lines
2.5 KiB
C++
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (C) 2011-2015 The Bitcoin Core developers
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef FLOWEE_QT_BITCOINAMOUNTFIELD_H
|
|
#define FLOWEE_QT_BITCOINAMOUNTFIELD_H
|
|
|
|
#include "amount.h"
|
|
|
|
#include <QWidget>
|
|
|
|
class AmountSpinBox;
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class QValueComboBox;
|
|
QT_END_NAMESPACE
|
|
|
|
/** Widget for entering bitcoin amounts.
|
|
*/
|
|
class BitcoinAmountField: public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
// ugly hack: for some unknown reason int64_t (instead of qint64) does not work here as expected
|
|
// discussion: https://github.com/bitcoin/bitcoin/pull/5117
|
|
Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY valueChanged USER true)
|
|
|
|
public:
|
|
explicit BitcoinAmountField(QWidget *parent = 0);
|
|
|
|
int64_t value(bool *value=0) const;
|
|
void setValue(const int64_t& value);
|
|
|
|
/** Set single step in satoshis **/
|
|
void setSingleStep(const int64_t& step);
|
|
|
|
/** Make read-only **/
|
|
void setReadOnly(bool fReadOnly);
|
|
|
|
/** Mark current value as invalid in UI. */
|
|
void setValid(bool valid);
|
|
/** Perform input validation, mark field as invalid if entered value is not valid. */
|
|
bool validate();
|
|
|
|
/** Change unit used to display amount. */
|
|
void setDisplayUnit(int unit);
|
|
|
|
/** Make field empty and ready for new input. */
|
|
void clear();
|
|
|
|
/** Enable/Disable. */
|
|
void setEnabled(bool fEnabled);
|
|
|
|
/** Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907),
|
|
in these cases we have to set it up manually.
|
|
*/
|
|
QWidget *setupTabChain(QWidget *prev);
|
|
|
|
Q_SIGNALS:
|
|
void valueChanged();
|
|
|
|
protected:
|
|
/** Intercept focus-in event and ',' key presses */
|
|
bool eventFilter(QObject *object, QEvent *event);
|
|
|
|
private:
|
|
AmountSpinBox *amount;
|
|
QValueComboBox *unit;
|
|
|
|
private Q_SLOTS:
|
|
void unitChanged(int idx);
|
|
|
|
};
|
|
|
|
#endif
|