diff options
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r-- | src/qt/guiutil.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index f1e8a5f1bc..fab97f91c4 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -17,6 +17,24 @@ #include <QDesktopServices> #include <QThread> +#include <boost/filesystem.hpp> + +#ifdef WIN32 +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif +#define _WIN32_WINNT 0x0501 +#ifdef _WIN32_IE +#undef _WIN32_IE +#endif +#define _WIN32_IE 0x0501 +#define WIN32_LEAN_AND_MEAN 1 +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include "shlwapi.h" +#endif + namespace GUIUtil { QString dateTimeStr(const QDateTime &date) @@ -214,5 +232,40 @@ bool isObscured(QWidget *w) && checkPoint(QPoint(w->width()/2, w->height()/2), w)); } +void openDebugLogfile() +{ + boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; + +#ifdef WIN32 + if (boost::filesystem::exists(pathDebug)) + /* Open debug.log with the associated application */ + ShellExecuteA((HWND)0, (LPCSTR)"open", (LPCSTR)pathDebug.string().c_str(), NULL, NULL, SW_SHOWNORMAL); +#endif +} + +ToolTipToRichTextFilter::ToolTipToRichTextFilter(int size_threshold, QObject *parent) : + QObject(parent), size_threshold(size_threshold) +{ + +} + +bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt) +{ + if(evt->type() == QEvent::ToolTipChange) + { + QWidget *widget = static_cast<QWidget*>(obj); + QString tooltip = widget->toolTip(); + if(!Qt::mightBeRichText(tooltip) && tooltip.size() > size_threshold) + { + // Prefix <qt/> to make sure Qt detects this as rich text + // Escape the current message as HTML and replace \n by <br> + tooltip = "<qt/>" + HtmlEscape(tooltip, true); + widget->setToolTip(tooltip); + return true; + } + } + return QObject::eventFilter(obj, evt); +} + } // namespace GUIUtil |