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