Browse Source

add code to open (display) debug.log on Windows with the associated application and add a button to the Information page in the Debug console

pull/1/head
Philip Kaufmann 10 years ago
parent
commit
4d3dda5d9f
  1. 36
      src/qt/forms/rpcconsole.ui
  2. 29
      src/qt/guiutil.cpp
  3. 3
      src/qt/guiutil.h
  4. 12
      src/qt/rpcconsole.cpp
  5. 2
      src/qt/rpcconsole.h

36
src/qt/forms/rpcconsole.ui

@ -204,6 +204,42 @@ @@ -204,6 +204,42 @@
</widget>
</item>
<item row="11" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="0">
<widget class="QLabel" name="labelDebugLogfile">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Debug logfile</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QPushButton" name="openDebugLogfileButton">
<property name="toolTip">
<string>Open the Bitcoin debug logfile from the current data directory. This can take a few seconds for large logfiles.</string>
</property>
<property name="text">
<string>&amp;Open</string>
</property>
</widget>
</item>
<item row="14" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>

29
src/qt/guiutil.cpp

@ -17,6 +17,24 @@ @@ -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,6 +232,17 @@ bool isObscured(QWidget *w) @@ -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)
{

3
src/qt/guiutil.h

@ -70,6 +70,9 @@ namespace GUIUtil @@ -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.

12
src/qt/rpcconsole.cpp

@ -90,6 +90,12 @@ RPCConsole::RPCConsole(QWidget *parent) : @@ -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) : @@ -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) @@ -310,3 +317,8 @@ void RPCConsole::on_tabWidget_currentChanged(int index)
ui->lineEdit->setFocus();
}
}
void RPCConsole::on_openDebugLogfileButton_clicked()
{
GUIUtil::openDebugLogfile();
}

2
src/qt/rpcconsole.h

@ -32,8 +32,8 @@ protected: @@ -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();

Loading…
Cancel
Save