diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui index 7e496a5c..02164f76 100644 --- a/src/qt/forms/rpcconsole.ui +++ b/src/qt/forms/rpcconsole.ui @@ -204,6 +204,42 @@ + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + 75 + true + + + + Debug logfile + + + + + + + Open the Bitcoin debug logfile from the current data directory. This can take a few seconds for large logfiles. + + + &Open + + + + Qt::Vertical diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 3b8f8c76..9a7d42fa 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -17,6 +17,24 @@ #include #include +#include + +#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,6 +232,17 @@ 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): size_threshold(size_threshold), QObject(parent) { diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 8e9aae1c..92d0f9ee 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -70,6 +70,9 @@ namespace GUIUtil // Determine whether a widget is hidden behind other windows bool isObscured(QWidget *w); + // Open debug.log + void openDebugLogfile(); + /** Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text representation if needed. This assures that Qt can word-wrap long tooltip messages. Tooltips longer than the provided size threshold (in characters) are wrapped. diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 6d983989..85f79309 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -90,6 +90,12 @@ RPCConsole::RPCConsole(QWidget *parent) : ui->messagesWidget->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch); ui->messagesWidget->setContextMenuPolicy(Qt::ActionsContextMenu); +#ifndef WIN32 + // Show Debug logfile label and Open button only for Windows + ui->labelDebugLogfile->setVisible(false); + ui->openDebugLogfileButton->setVisible(false); +#endif + // Install event filter for up and down arrow ui->lineEdit->installEventFilter(this); @@ -101,6 +107,7 @@ RPCConsole::RPCConsole(QWidget *parent) : ui->messagesWidget->addAction(copyMessageAction); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); + connect(ui->openDebugLogfileButton, SIGNAL(clicked()), this, SLOT(on_openDebugLogfileButton_clicked())); startExecutor(); @@ -310,3 +317,8 @@ void RPCConsole::on_tabWidget_currentChanged(int index) ui->lineEdit->setFocus(); } } + +void RPCConsole::on_openDebugLogfileButton_clicked() +{ + GUIUtil::openDebugLogfile(); +} diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 2ec47b0c..30948eaa 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -32,8 +32,8 @@ protected: private slots: void on_lineEdit_returnPressed(); - void on_tabWidget_currentChanged(int index); + void on_openDebugLogfileButton_clicked(); public slots: void clear();