Merge branch '0.5.0.x' into 0.5.x
[novacoin.git] / src / qt / guiutil.h
1 #ifndef GUIUTIL_H
2 #define GUIUTIL_H
3
4 #include <QString>
5
6 QT_BEGIN_NAMESPACE
7 class QFont;
8 class QLineEdit;
9 class QWidget;
10 class QDateTime;
11 class QUrl;
12 QT_END_NAMESPACE
13 class SendCoinsRecipient;
14
15 /** Static utility functions used by the Bitcoin Qt UI.
16  */
17 class GUIUtil
18 {
19 public:
20     // Create human-readable string from date
21     static QString dateTimeStr(qint64 nTime);
22     static QString dateTimeStr(const QDateTime &datetime);
23
24     // Render bitcoin addresses in monospace font
25     static QFont bitcoinAddressFont();
26
27     // Set up widgets for address and amounts
28     static void setupAddressWidget(QLineEdit *widget, QWidget *parent);
29     static void setupAmountWidget(QLineEdit *widget, QWidget *parent);
30
31     // Parse "bitcoin:" URL into recipient object, return true on succesful parsing
32     // See Bitcoin URL definition discussion here: https://bitcointalk.org/index.php?topic=33490.0
33     static bool parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out);
34     static bool parseBitcoinURL(QString url, SendCoinsRecipient *out);
35
36     /** Get save file name, mimics QFileDialog::getSaveFileName, except that it appends a default suffix
37         when no suffix is provided by the user.
38
39       @param[in] parent  Parent window (or 0)
40       @param[in] caption Window caption (or empty, for default)
41       @param[in] dir     Starting directory (or empty, to default to documents directory)
42       @param[in] filter  Filter specification such as "Comma Separated Files (*.csv)"
43       @param[out] selectedSuffixOut  Pointer to return the suffix (file type) that was selected (or 0).
44                   Can be useful when choosing the save file format based on suffix.
45      */
46     static QString getSaveFileName(QWidget *parent=0, const QString &caption=QString(),
47                                    const QString &dir=QString(), const QString &filter=QString(),
48                                    QString *selectedSuffixOut=0);
49
50 };
51
52 #endif // GUIUTIL_H