![]() |
Bitcoin Core
21.99.0
P2P Digital Currency
|
Utility functions used by the Bitcoin Qt UI. More...
Classes | |
class | ClickableLabel |
class | ClickableProgressBar |
class | ItemDelegate |
class | LabelOutOfFocusEventFilter |
Qt event filter that intercepts QEvent::FocusOut events for QLabel objects, and resets their ‘textInteractionFlags’ property to get rid of the visible cursor. More... | |
class | ToolTipToRichTextFilter |
Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text representation if needed. More... | |
Typedefs | |
typedef ClickableProgressBar | ProgressBar |
Functions | |
QString | dateTimeStr (const QDateTime &date) |
QString | dateTimeStr (qint64 nTime) |
QFont | fixedPitchFont (bool use_embedded_font) |
static std::string | DummyAddress (const CChainParams ¶ms) |
void | setupAddressWidget (QValidatedLineEdit *widget, QWidget *parent) |
bool | parseBitcoinURI (const QUrl &uri, SendCoinsRecipient *out) |
bool | parseBitcoinURI (QString uri, SendCoinsRecipient *out) |
QString | formatBitcoinURI (const SendCoinsRecipient &info) |
bool | isDust (interfaces::Node &node, const QString &address, const CAmount &amount) |
QString | HtmlEscape (const QString &str, bool fMultiLine) |
QString | HtmlEscape (const std::string &str, bool fMultiLine) |
void | copyEntryData (const QAbstractItemView *view, int column, int role=Qt::EditRole) |
Copy a field of the currently selected entry of a view to the clipboard. More... | |
QList< QModelIndex > | getEntryData (const QAbstractItemView *view, int column) |
Return a field of the currently selected entry as a QString. More... | |
bool | hasEntryData (const QAbstractItemView *view, int column, int role) |
Returns true if the specified field of the currently selected view entry is not empty. More... | |
QString | getDefaultDataDirectory () |
Determine default data directory for operating system. More... | |
QString | getSaveFileName (QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut) |
Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix when no suffix is provided by the user. More... | |
QString | getOpenFileName (QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut) |
Get open filename, convenience wrapper for QFileDialog::getOpenFileName. More... | |
Qt::ConnectionType | blockingGUIThreadConnection () |
Get connection type to call object slot in GUI thread with invokeMethod. More... | |
bool | checkPoint (const QPoint &p, const QWidget *w) |
bool | isObscured (QWidget *w) |
void | bringToFront (QWidget *w) |
void | handleCloseWindowShortcut (QWidget *w) |
void | openDebugLogfile () |
bool | openBitcoinConf () |
bool | GetStartOnSystemStartup () |
bool | SetStartOnSystemStartup (bool fAutoStart) |
void | setClipboard (const QString &str) |
fs::path | qstringToBoostPath (const QString &path) |
Convert QString to OS specific boost path through UTF-8. More... | |
QString | boostPathToQString (const fs::path &path) |
Convert OS specific boost path to QString through UTF-8. More... | |
QString | NetworkToQString (Network net) |
Convert enum Network to QString. More... | |
QString | ConnectionTypeToQString (ConnectionType conn_type, bool prepend_direction) |
Convert enum ConnectionType to QString. More... | |
QString | formatDurationStr (int secs) |
Convert seconds into a QString with days, hours, mins, secs. More... | |
QString | formatServicesStr (quint64 mask) |
Format CNodeStats.nServices bitmask into a user-readable string. More... | |
QString | formatPingTime (std::chrono::microseconds ping_time) |
Format a CNodeStats.m_last_ping_time into a user-readable string or display N/A, if 0. More... | |
QString | formatTimeOffset (int64_t nTimeOffset) |
Format a CNodeCombinedStats.nTimeOffset into a user-readable string. More... | |
QString | formatNiceTimeOffset (qint64 secs) |
QString | formatBytes (uint64_t bytes) |
qreal | calculateIdealFontSize (int width, const QString &text, QFont font, qreal minPointSize, qreal font_size) |
void | PolishProgressDialog (QProgressDialog *dialog) |
int | TextWidth (const QFontMetrics &fm, const QString &text) |
Returns the distance in pixels appropriate for drawing a subsequent character after text. More... | |
void | LogQtInfo () |
Writes to debug.log short info about the used Qt and the host system. More... | |
void | PopupMenu (QMenu *menu, const QPoint &point, QAction *at_action=nullptr) |
Call QMenu::popup() only on supported QT_QPA_PLATFORM. More... | |
QDateTime | StartOfDay (const QDate &date) |
Returns the start-moment of the day in local time. More... | |
bool | HasPixmap (const QLabel *label) |
Returns true if pixmap has been set. More... | |
QImage | GetImage (const QLabel *label) |
template<typename SeparatorType > | |
QStringList | SplitSkipEmptyParts (const QString &string, const SeparatorType &separator) |
Splits the string into substrings wherever separator occurs, and returns the list of those strings. More... | |
template<typename Fn > | |
void | ObjectInvoke (QObject *object, Fn &&function, Qt::ConnectionType connection=Qt::QueuedConnection) |
Queue a function to run in an object's event loop. More... | |
Variables | |
static const uint8_t | dummydata [] = {0xeb,0x15,0x23,0x1d,0xfc,0xeb,0x60,0x92,0x58,0x86,0xb6,0x7d,0x06,0x52,0x99,0x92,0x59,0x15,0xae,0xb1,0x72,0xc0,0x66,0x47} |
constexpr auto | dialog_flags = Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint |
Utility functions used by the Bitcoin Qt UI.
Qt::ConnectionType GUIUtil::blockingGUIThreadConnection | ( | ) |
Get connection type to call object slot in GUI thread with invokeMethod.
The call will be blocking.
Definition at line 347 of file guiutil.cpp.
QString GUIUtil::boostPathToQString | ( | const fs::path & | path | ) |
Convert OS specific boost path to QString through UTF-8.
Definition at line 640 of file guiutil.cpp.
void GUIUtil::bringToFront | ( | QWidget * | w | ) |
Definition at line 375 of file guiutil.cpp.
qreal GUIUtil::calculateIdealFontSize | ( | int | width, |
const QString & | text, | ||
QFont | font, | ||
qreal | minPointSize, | ||
qreal | font_size | ||
) |
Definition at line 772 of file guiutil.cpp.
bool GUIUtil::checkPoint | ( | const QPoint & | p, |
const QWidget * | w | ||
) |
QString GUIUtil::ConnectionTypeToQString | ( | ConnectionType | conn_type, |
bool | prepend_direction | ||
) |
Convert enum ConnectionType to QString.
Definition at line 660 of file guiutil.cpp.
void GUIUtil::copyEntryData | ( | const QAbstractItemView * | view, |
int | column, | ||
int | role = Qt::EditRole |
||
) |
Copy a field of the currently selected entry of a view to the clipboard.
Does nothing if nothing is selected.
[in] | column | Data column to extract from the model |
[in] | role | Data role to extract from the model |
Definition at line 238 of file guiutil.cpp.
QString GUIUtil::dateTimeStr | ( | const QDateTime & | date | ) |
QString GUIUtil::dateTimeStr | ( | qint64 | nTime | ) |
|
static |
Definition at line 95 of file guiutil.cpp.
QFont GUIUtil::fixedPitchFont | ( | bool | use_embedded_font | ) |
QString GUIUtil::formatBitcoinURI | ( | const SendCoinsRecipient & | info | ) |
Definition at line 185 of file guiutil.cpp.
QString GUIUtil::formatBytes | ( | uint64_t | bytes | ) |
QString GUIUtil::formatDurationStr | ( | int | secs | ) |
Convert seconds into a QString with days, hours, mins, secs.
Definition at line 677 of file guiutil.cpp.
QString GUIUtil::formatNiceTimeOffset | ( | qint64 | secs | ) |
QString GUIUtil::formatPingTime | ( | std::chrono::microseconds | ping_time | ) |
Format a CNodeStats.m_last_ping_time into a user-readable string or display N/A, if 0.
Definition at line 711 of file guiutil.cpp.
QString GUIUtil::formatServicesStr | ( | quint64 | mask | ) |
Format CNodeStats.nServices bitmask into a user-readable string.
Definition at line 697 of file guiutil.cpp.
QString GUIUtil::formatTimeOffset | ( | int64_t | nTimeOffset | ) |
Format a CNodeCombinedStats.nTimeOffset into a user-readable string.
Definition at line 718 of file guiutil.cpp.
QString GUIUtil::getDefaultDataDirectory | ( | ) |
Determine default data directory for operating system.
Definition at line 265 of file guiutil.cpp.
QList< QModelIndex > GUIUtil::getEntryData | ( | const QAbstractItemView * | view, |
int | column | ||
) |
Return a field of the currently selected entry as a QString.
Does nothing if nothing is selected.
[in] | column | Data column to extract from the model |
Definition at line 251 of file guiutil.cpp.
QImage GUIUtil::GetImage | ( | const QLabel * | label | ) |
Definition at line 883 of file guiutil.cpp.
QString GUIUtil::getOpenFileName | ( | QWidget * | parent, |
const QString & | caption, | ||
const QString & | dir, | ||
const QString & | filter, | ||
QString * | selectedSuffixOut | ||
) |
Get open filename, convenience wrapper for QFileDialog::getOpenFileName.
[in] | parent | Parent window (or 0) |
[in] | caption | Window caption (or empty, for default) |
[in] | dir | Starting directory (or empty, to default to documents directory) |
[in] | filter | Filter specification such as "Comma Separated Files (*.csv)" |
[out] | selectedSuffixOut | Pointer to return the suffix (file type) that was selected (or 0). Can be useful when choosing the save file format based on suffix. |
Definition at line 316 of file guiutil.cpp.
QString GUIUtil::getSaveFileName | ( | QWidget * | parent, |
const QString & | caption, | ||
const QString & | dir, | ||
const QString & | filter, | ||
QString * | selectedSuffixOut | ||
) |
Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix when no suffix is provided by the user.
[in] | parent | Parent window (or 0) |
[in] | caption | Window caption (or empty, for default) |
[in] | dir | Starting directory (or empty, to default to documents directory) |
[in] | filter | Filter specification such as "Comma Separated Files (*.csv)" |
[out] | selectedSuffixOut | Pointer to return the suffix (file type) that was selected (or 0). Can be useful when choosing the save file format based on suffix. |
Definition at line 270 of file guiutil.cpp.
bool GUIUtil::GetStartOnSystemStartup | ( | ) |
void GUIUtil::handleCloseWindowShortcut | ( | QWidget * | w | ) |
bool GUIUtil::hasEntryData | ( | const QAbstractItemView * | view, |
int | column, | ||
int | role | ||
) |
Returns true if the specified field of the currently selected view entry is not empty.
[in] | column | Data column to extract from the model |
[in] | role | Data role to extract from the model |
Definition at line 258 of file guiutil.cpp.
bool GUIUtil::HasPixmap | ( | const QLabel * | label | ) |
Returns true if pixmap has been set.
QPixmap* QLabel::pixmap() is deprecated since Qt 5.15.
Definition at line 874 of file guiutil.cpp.
QString GUIUtil::HtmlEscape | ( | const QString & | str, |
bool | fMultiLine | ||
) |
QString GUIUtil::HtmlEscape | ( | const std::string & | str, |
bool | fMultiLine | ||
) |
bool GUIUtil::isDust | ( | interfaces::Node & | node, |
const QString & | address, | ||
const CAmount & | amount | ||
) |
Definition at line 215 of file guiutil.cpp.
bool GUIUtil::isObscured | ( | QWidget * | w | ) |
Definition at line 366 of file guiutil.cpp.
void GUIUtil::LogQtInfo | ( | ) |
Writes to debug.log short info about the used Qt and the host system.
Definition at line 825 of file guiutil.cpp.
QString GUIUtil::NetworkToQString | ( | Network | net | ) |
Convert enum Network to QString.
Definition at line 645 of file guiutil.cpp.
void GUIUtil::ObjectInvoke | ( | QObject * | object, |
Fn && | function, | ||
Qt::ConnectionType | connection = Qt::QueuedConnection |
||
) |
Queue a function to run in an object's event loop.
This can be replaced by a call to the QMetaObject::invokeMethod functor overload after Qt 5.10, but for now use a QObject::connect for compatibility with older Qt versions, based on https://stackoverflow.com/questions/21646467/how-to-execute-a-functor-or-a-lambda-in-a-given-thread-in-qt-gcd-style
Definition at line 324 of file guiutil.h.
bool GUIUtil::openBitcoinConf | ( | ) |
Definition at line 407 of file guiutil.cpp.
void GUIUtil::openDebugLogfile | ( | ) |
Definition at line 398 of file guiutil.cpp.
bool GUIUtil::parseBitcoinURI | ( | const QUrl & | uri, |
SendCoinsRecipient * | out | ||
) |
Definition at line 122 of file guiutil.cpp.
bool GUIUtil::parseBitcoinURI | ( | QString | uri, |
SendCoinsRecipient * | out | ||
) |
void GUIUtil::PolishProgressDialog | ( | QProgressDialog * | dialog | ) |
Definition at line 804 of file guiutil.cpp.
void GUIUtil::PopupMenu | ( | QMenu * | menu, |
const QPoint & | point, | ||
QAction * | at_action | ||
) |
Call QMenu::popup() only on supported QT_QPA_PLATFORM.
Definition at line 858 of file guiutil.cpp.
fs::path GUIUtil::qstringToBoostPath | ( | const QString & | path | ) |
Convert QString to OS specific boost path through UTF-8.
Definition at line 635 of file guiutil.cpp.
void GUIUtil::setClipboard | ( | const QString & | str | ) |
bool GUIUtil::SetStartOnSystemStartup | ( | bool | fAutoStart | ) |
void GUIUtil::setupAddressWidget | ( | QValidatedLineEdit * | widget, |
QWidget * | parent | ||
) |
Definition at line 109 of file guiutil.cpp.
QStringList GUIUtil::SplitSkipEmptyParts | ( | const QString & | string, |
const SeparatorType & | separator | ||
) |
Splits the string into substrings wherever separator occurs, and returns the list of those strings.
Empty strings do not appear in the result.
QString::split() signature differs in different Qt versions:
Definition at line 308 of file guiutil.h.
QDateTime GUIUtil::StartOfDay | ( | const QDate & | date | ) |
Returns the start-moment of the day in local time.
QDateTime::QDateTime(const QDate& date) is deprecated since Qt 5.15. QDate::startOfDay() was introduced in Qt 5.14.
Definition at line 865 of file guiutil.cpp.
int GUIUtil::TextWidth | ( | const QFontMetrics & | fm, |
const QString & | text | ||
) |
Returns the distance in pixels appropriate for drawing a subsequent character after text.
In Qt 5.12 and before the QFontMetrics::width() is used and it is deprecated since Qt 5.13. In Qt 5.11 the QFontMetrics::horizontalAdvance() was introduced.
Definition at line 816 of file guiutil.cpp.
|
constexpr |
|
static |
Definition at line 92 of file guiutil.cpp.