17 class QAbstractItemView;
19 class SendCoinsRecipient;
21 /** Utility functions used by the Bitcoin Qt UI.
25 // Create human-readable string from date
26 QString dateTimeStr(const QDateTime &datetime);
27 QString dateTimeStr(qint64 nTime);
29 // Render Bitcoin addresses in monospace font
30 QFont bitcoinAddressFont();
32 // Set up widgets for address and amounts
33 void setupAddressWidget(QLineEdit *widget, QWidget *parent);
34 void setupAmountWidget(QLineEdit *widget, QWidget *parent);
36 // Parse "novacoin:" URI into recipient object, return true on successful parsing
37 // See Bitcoin URI definition discussion here: https://bitcointalk.org/index.php?topic=33490.0
38 bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out);
39 bool parseBitcoinURI(QString uri, SendCoinsRecipient *out);
41 // HTML escaping for rich text controls
42 QString HtmlEscape(const QString& str, bool fMultiLine=false);
43 QString HtmlEscape(const std::string& str, bool fMultiLine=false);
45 /** Copy a field of the currently selected entry of a view to the clipboard. Does nothing if nothing
47 @param[in] column Data column to extract from the model
48 @param[in] role Data role to extract from the model
49 @see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress
51 void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole);
53 /** Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix
54 when no suffix is provided by the user.
56 @param[in] parent Parent window (or 0)
57 @param[in] caption Window caption (or empty, for default)
58 @param[in] dir Starting directory (or empty, to default to documents directory)
59 @param[in] filter Filter specification such as "Comma Separated Files (*.csv)"
60 @param[out] selectedSuffixOut Pointer to return the suffix (file type) that was selected (or 0).
61 Can be useful when choosing the save file format based on suffix.
63 QString getSaveFileName(QWidget *parent=0, const QString &caption=QString(),
64 const QString &dir=QString(), const QString &filter=QString(),
65 QString *selectedSuffixOut=0);
67 /** Get connection type to call object slot in GUI thread with invokeMethod. The call will be blocking.
69 @returns If called from the GUI thread, return a Qt::DirectConnection.
70 If called from another thread, return a Qt::BlockingQueuedConnection.
72 Qt::ConnectionType blockingGUIThreadConnection();
74 // Determine whether a widget is hidden behind other windows
75 bool isObscured(QWidget *w);
78 void openDebugLogfile();
80 void openConfigfile();
81 /** Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text
82 representation if needed. This assures that Qt can word-wrap long tooltip messages.
83 Tooltips longer than the provided size threshold (in characters) are wrapped.
85 class ToolTipToRichTextFilter : public QObject
90 explicit ToolTipToRichTextFilter(int size_threshold, QObject *parent = 0);
93 bool eventFilter(QObject *obj, QEvent *evt);
99 bool GetStartOnSystemStartup();
100 bool SetStartOnSystemStartup(bool fAutoStart);
102 /** Help message for Bitcoin-Qt, shown with --help. */
103 class HelpMessageBox : public QMessageBox
108 HelpMessageBox(QWidget *parent = 0);
110 /** Show message box or print help message to standard output, based on operating system. */
113 /** Print help message to console */
114 void printToConsole();
121 virtual bool event(QEvent *e)
123 bool res = QMessageBox::event(e);
124 if (e->type() == QEvent::MouseMove || e->type() == QEvent::MouseButtonPress)
126 setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
127 if (QWidget *textEdit = findChild<QTextEdit *>())
129 textEdit->setMaximumHeight(QWIDGETSIZE_MAX);
136 /* Convert seconds into a QString with days, hours, mins, secs */
137 QString formatDurationStr(int secs);
139 } // namespace GUIUtil