diff options
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r-- | src/qt/guiutil.cpp | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 2a3063ba35..cb2473240e 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -19,31 +19,33 @@ #include <QDesktopServices> #include <QThread> -QString GUIUtil::dateTimeStr(qint64 nTime) +namespace GUIUtil { + +QString dateTimeStr(const QDateTime &date) { - return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); + return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm"); } -QString GUIUtil::dateTimeStr(const QDateTime &date) +QString dateTimeStr(qint64 nTime) { - return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm"); + return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); } -QFont GUIUtil::bitcoinAddressFont() +QFont bitcoinAddressFont() { QFont font("Monospace"); font.setStyleHint(QFont::TypeWriter); return font; } -void GUIUtil::setupAddressWidget(QLineEdit *widget, QWidget *parent) +void setupAddressWidget(QLineEdit *widget, QWidget *parent) { widget->setMaxLength(BitcoinAddressValidator::MaxAddressLength); widget->setValidator(new BitcoinAddressValidator(parent)); widget->setFont(bitcoinAddressFont()); } -void GUIUtil::setupAmountWidget(QLineEdit *widget, QWidget *parent) +void setupAmountWidget(QLineEdit *widget, QWidget *parent) { QDoubleValidator *amountValidator = new QDoubleValidator(parent); amountValidator->setDecimals(8); @@ -52,7 +54,7 @@ void GUIUtil::setupAmountWidget(QLineEdit *widget, QWidget *parent) widget->setAlignment(Qt::AlignRight|Qt::AlignVCenter); } -bool GUIUtil::parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) +bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) { if(uri.scheme() != QString("bitcoin")) return false; @@ -97,7 +99,7 @@ bool GUIUtil::parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) return true; } -bool GUIUtil::parseBitcoinURI(QString uri, SendCoinsRecipient *out) +bool parseBitcoinURI(QString uri, SendCoinsRecipient *out) { // Convert bitcoin:// to bitcoin: // @@ -111,7 +113,7 @@ bool GUIUtil::parseBitcoinURI(QString uri, SendCoinsRecipient *out) return parseBitcoinURI(uriInstance, out); } -QString GUIUtil::HtmlEscape(const QString& str, bool fMultiLine) +QString HtmlEscape(const QString& str, bool fMultiLine) { QString escaped = Qt::escape(str); if(fMultiLine) @@ -121,12 +123,12 @@ QString GUIUtil::HtmlEscape(const QString& str, bool fMultiLine) return escaped; } -QString GUIUtil::HtmlEscape(const std::string& str, bool fMultiLine) +QString HtmlEscape(const std::string& str, bool fMultiLine) { return HtmlEscape(QString::fromStdString(str), fMultiLine); } -void GUIUtil::copyEntryData(QAbstractItemView *view, int column, int role) +void copyEntryData(QAbstractItemView *view, int column, int role) { if(!view || !view->selectionModel()) return; @@ -139,7 +141,7 @@ void GUIUtil::copyEntryData(QAbstractItemView *view, int column, int role) } } -QString GUIUtil::getSaveFileName(QWidget *parent, const QString &caption, +QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut) @@ -185,7 +187,7 @@ QString GUIUtil::getSaveFileName(QWidget *parent, const QString &caption, return result; } -Qt::ConnectionType GUIUtil::blockingGUIThreadConnection() +Qt::ConnectionType blockingGUIThreadConnection() { if(QThread::currentThread() != QCoreApplication::instance()->thread()) { @@ -196,3 +198,23 @@ Qt::ConnectionType GUIUtil::blockingGUIThreadConnection() return Qt::DirectConnection; } } + +bool checkPoint(const QPoint &p, const QWidget *w) +{ + QWidget *atW = qApp->widgetAt(w->mapToGlobal(p)); + if(!atW) return false; + return atW->topLevelWidget() == w; +} + +bool isObscured(QWidget *w) +{ + + return !(checkPoint(QPoint(0, 0), w) + && checkPoint(QPoint(w->width() - 1, 0), w) + && checkPoint(QPoint(0, w->height() - 1), w) + && checkPoint(QPoint(w->width() - 1, w->height() - 1), w) + && checkPoint(QPoint(w->width()/2, w->height()/2), w)); +} + +} // namespace GUIUtil + |