5 #ifndef BITCOIN_QT_GUIUTIL_H 6 #define BITCOIN_QT_GUIUTIL_H 14 #include <QHeaderView> 15 #include <QItemDelegate> 17 #include <QMessageBox> 19 #include <QProgressBar> 32 class QAbstractItemView;
39 class QProgressDialog;
67 QString
HtmlEscape(
const QString& str,
bool fMultiLine=
false);
68 QString
HtmlEscape(
const std::string& str,
bool fMultiLine=
false);
76 void copyEntryData(
const QAbstractItemView *view,
int column,
int role=Qt::EditRole);
83 QList<QModelIndex>
getEntryData(
const QAbstractItemView *view,
int column);
90 bool hasEntryData(
const QAbstractItemView *view,
int column,
int role);
109 QString
getSaveFileName(QWidget *parent,
const QString &caption,
const QString &dir,
110 const QString &filter,
111 QString *selectedSuffixOut);
122 QString
getOpenFileName(QWidget *parent,
const QString &caption,
const QString &dir,
123 const QString &filter,
124 QString *selectedSuffixOut);
160 bool eventFilter(QObject *obj, QEvent *evt)
override;
178 bool eventFilter(QObject* watched, QEvent* event)
override;
197 void stretchColumnWidth(
int column);
207 void adjustTableColumnsWidth();
208 int getAvailableWidthForColumn(
int column);
209 int getColumnsWidth();
210 void connectViewHeadersSignals();
211 void disconnectViewHeadersSignals();
212 void setViewHeaderResizeMode(
int logicalIndex, QHeaderView::ResizeMode resizeMode);
213 void resizeColumn(
int nColumnIndex,
int width);
216 void on_sectionResized(
int logicalIndex,
int oldSize,
int newSize);
217 void on_geometriesChanged();
251 qreal
calculateIdealFontSize(
int width,
const QString& text, QFont font, qreal minPointSize = 4, qreal startPointSize = 14);
261 void clicked(
const QPoint& point);
263 void mouseReleaseEvent(QMouseEvent *event)
override;
274 void clicked(
const QPoint& point);
276 void mouseReleaseEvent(QMouseEvent *event)
override;
288 void keyEscapePressed();
291 bool eventFilter(QObject *
object, QEvent *event)
override;
303 int TextWidth(
const QFontMetrics& fm,
const QString& text);
313 void PopupMenu(QMenu* menu,
const QPoint& point, QAction* at_action =
nullptr);
329 QImage
GetImage(
const QLabel* label);
341 template <
typename SeparatorType>
344 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) 345 return string.split(separator, Qt::SkipEmptyParts);
347 return string.split(separator, QString::SkipEmptyParts);
357 template <
typename Fn>
361 QObject::connect(&source, &QObject::destroyed,
object, std::forward<Fn>(
function), connection);
366 #endif // BITCOIN_QT_GUIUTIL_H QString ConnectionTypeToQString(ConnectionType conn_type)
Convert enum ConnectionType to QString.
QDateTime StartOfDay(const QDate &date)
Returns the start-moment of the day in local time.
Utility functions used by the Bitcoin Qt UI.
void LogQtInfo()
Writes to debug.log short info about the used Qt and the host system.
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut)
Get open filename, convenience wrapper for QFileDialog::getOpenFileName.
void PopupMenu(QMenu *menu, const QPoint &point, QAction *at_action)
Call QMenu::popup() only on supported QT_QPA_PLATFORM.
int TextWidth(const QFontMetrics &fm, const QString &text)
Returns the distance in pixels appropriate for drawing a subsequent character after text...
bool isDust(interfaces::Node &node, const QString &address, const CAmount &amount)
int secondToLastColumnIndex
QString dateTimeStr(const QDateTime &date)
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
QString formatBytes(uint64_t bytes)
QString formatTimeOffset(int64_t nTimeOffset)
Format a CNodeCombinedStats.nTimeOffset into a user-readable string.
bool GetStartOnSystemStartup()
QString HtmlEscape(const QString &str, bool fMultiLine)
Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text repre...
Line edit that can be marked as "invalid" to show input validation feedback.
Qt event filter that intercepts QEvent::FocusOut events for QLabel objects, and resets their `textInt...
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
QString formatBitcoinURI(const SendCoinsRecipient &info)
void bringToFront(QWidget *w)
int64_t CAmount
Amount in satoshis (Can be negative)
QString NetworkToQString(Network net)
Convert enum Network to QString.
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
bool isObscured(QWidget *w)
QString formatPingTime(int64_t ping_usec)
Format a CNodeStats.m_ping_usec into a user-readable string or display N/A, if 0. ...
qreal calculateIdealFontSize(int width, const QString &text, QFont font, qreal minPointSize, qreal font_size)
QString formatDurationStr(int secs)
Convert seconds into a QString with days, hours, mins, secs.
void ObjectInvoke(QObject *object, Fn &&function, Qt::ConnectionType connection=Qt::QueuedConnection)
Queue a function to run in an object's event loop.
void setClipboard(const QString &str)
bool HasPixmap(const QLabel *label)
Returns true if pixmap has been set.
void handleCloseWindowShortcut(QWidget *w)
int lastColumnMinimumWidth
Makes a QTableView last column feel as if it was being resized from its left border.
bool hasEntryData(const QAbstractItemView *view, int column, int role)
Returns true if the specified field of the currently selected view entry is not empty.
void copyEntryData(const QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
void PolishProgressDialog(QProgressDialog *dialog)
ClickableProgressBar ProgressBar
QStringList SplitSkipEmptyParts(const QString &string, const SeparatorType &separator)
Splits the string into substrings wherever separator occurs, and returns the list of those strings...
QImage GetImage(const QLabel *label)
int allColumnsMinimumWidth
fs::path qstringToBoostPath(const QString &path)
Convert QString to OS specific boost path through UTF-8.
ConnectionType
Different types of connections to a peer.
QString formatServicesStr(quint64 mask)
Format CNodeStats.nServices bitmask into a user-readable string.
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 ...
bool SetStartOnSystemStartup(bool fAutoStart)
QString formatNiceTimeOffset(qint64 secs)
QString getDefaultDataDirectory()
Determine default data directory for operating system.
QString boostPathToQString(const fs::path &path)
Convert OS specific boost path to QString through UTF-8.
Top-level interface for a bitcoin node (bitcoind process).
ItemDelegate(QObject *parent)
QList< QModelIndex > getEntryData(const QAbstractItemView *view, int column)
Return a field of the currently selected entry as a QString.