diff --git a/contrib/debian/copyright b/contrib/debian/copyright index bbaa5b163..c039a7bae 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -21,6 +21,7 @@ License: GPL-3+ Files: src/qt/res/icons/add.png src/qt/res/icons/address-book.png + src/qt/res/icons/chevron.png src/qt/res/icons/configure.png src/qt/res/icons/debugwindow.png src/qt/res/icons/edit.png @@ -56,6 +57,8 @@ Comment: Inspired by Stephan Hutchings Typicons Files: src/qt/res/icons/tx_mined.png src/qt/res/src/mine.svg + src/qt/res/icons/fontbigger.png + src/qt/res/icons/fontsmaller.png Copyright: Jonas Schnelli License: Expat Comment: diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index a390d96a9..96b7adcbf 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -225,6 +225,7 @@ RES_ICONS = \ qt/res/icons/about_qt.png \ qt/res/icons/bitcoin.ico \ qt/res/icons/bitcoin.png \ + qt/res/icons/chevron.png \ qt/res/icons/clock1.png \ qt/res/icons/clock2.png \ qt/res/icons/clock3.png \ @@ -245,6 +246,8 @@ RES_ICONS = \ qt/res/icons/eye_minus.png \ qt/res/icons/eye_plus.png \ qt/res/icons/filesave.png \ + qt/res/icons/fontbigger.png \ + qt/res/icons/fontsmaller.png \ qt/res/icons/history.png \ qt/res/icons/info.png \ qt/res/icons/key.png \ diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index c899e9550..dcd3b4ae2 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -46,6 +46,9 @@ res/icons/about_qt.png res/icons/verify.png res/icons/warning.png + res/icons/fontbigger.png + res/icons/fontsmaller.png + res/icons/chevron.png res/movies/spinner-000.png diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 247147036..763128611 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -450,6 +450,125 @@ 3 + + 5 + + + + + 4 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 24 + 24 + + + + + + + Decrease font size + + + + :/icons/fontsmaller:/icons/fontsmaller + + + + 24 + 16 + + + + false + + + true + + + + + + + + 24 + 24 + + + + Increase font size + + + + + + + :/icons/fontbigger:/icons/fontbigger + + + + 24 + 16 + + + + false + + + true + + + + + + + + 24 + 24 + + + + Clear console + + + Qt::LeftToRight + + + + + + + :/icons/remove:/icons/remove + + + Ctrl+L + + + false + + + true + + + + + @@ -470,44 +589,48 @@ - + 3 - - - > + + + false - - - - - - - - 24 + 16 24 - - Clear console - - :/icons/remove:/icons/remove + :/icons/prompticon + :/icons/prompticon:/icons/prompticon - - Ctrl+L + + + 14 + 14 + false + + true + + + + + + + + diff --git a/src/qt/res/icons/chevron.png b/src/qt/res/icons/chevron.png new file mode 100644 index 000000000..ac985052c Binary files /dev/null and b/src/qt/res/icons/chevron.png differ diff --git a/src/qt/res/icons/fontbigger.png b/src/qt/res/icons/fontbigger.png new file mode 100644 index 000000000..5ca5c563b Binary files /dev/null and b/src/qt/res/icons/fontbigger.png differ diff --git a/src/qt/res/icons/fontsmaller.png b/src/qt/res/icons/fontsmaller.png new file mode 100644 index 000000000..1a6bb3a61 Binary files /dev/null and b/src/qt/res/icons/fontsmaller.png differ diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index fb3602031..dca34ed04 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -41,9 +42,9 @@ // TODO: receive errors and debug messages through ClientModel const int CONSOLE_HISTORY = 50; -const QSize ICON_SIZE(24, 24); - const int INITIAL_TRAFFIC_GRAPH_MINS = 30; +const QSize FONT_RANGE(4, 40); +const char fontSizeSettingsKey[] = "consoleFontSize"; const struct { const char *url; @@ -245,7 +246,8 @@ RPCConsole::RPCConsole(const PlatformStyle *platformStyle, QWidget *parent) : cachedNodeid(-1), platformStyle(platformStyle), peersTableContextMenu(0), - banTableContextMenu(0) + banTableContextMenu(0), + consoleFontSize(0) { ui->setupUi(this); GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this); @@ -254,12 +256,16 @@ RPCConsole::RPCConsole(const PlatformStyle *platformStyle, QWidget *parent) : ui->openDebugLogfileButton->setIcon(platformStyle->SingleColorIcon(":/icons/export")); } ui->clearButton->setIcon(platformStyle->SingleColorIcon(":/icons/remove")); + ui->fontBiggerButton->setIcon(platformStyle->SingleColorIcon(":/icons/fontbigger")); + ui->fontSmallerButton->setIcon(platformStyle->SingleColorIcon(":/icons/fontsmaller")); // Install event filter for up and down arrow ui->lineEdit->installEventFilter(this); ui->messagesWidget->installEventFilter(this); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); + connect(ui->fontBiggerButton, SIGNAL(clicked()), this, SLOT(fontBigger())); + connect(ui->fontSmallerButton, SIGNAL(clicked()), this, SLOT(fontSmaller())); connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear())); // set library version labels @@ -288,6 +294,8 @@ RPCConsole::RPCConsole(const PlatformStyle *platformStyle, QWidget *parent) : ui->detailWidget->hide(); ui->peerHeading->setText(tr("Select a peer to view detailed information.")); + QSettings settings; + consoleFontSize = settings.value(fontSizeSettingsKey, QFontInfo(QFont()).pointSize()).toInt(); clear(); } @@ -453,6 +461,41 @@ static QString categoryClass(int category) } } +void RPCConsole::fontBigger() +{ + setFontSize(consoleFontSize+1); +} + +void RPCConsole::fontSmaller() +{ + setFontSize(consoleFontSize-1); +} + +void RPCConsole::setFontSize(int newSize) +{ + QSettings settings; + + //don't allow a insane font size + if (newSize < FONT_RANGE.width() || newSize > FONT_RANGE.height()) + return; + + // temp. store the console content + QString str = ui->messagesWidget->toHtml(); + + // replace font tags size in current content + str.replace(QString("font-size:%1pt").arg(consoleFontSize), QString("font-size:%1pt").arg(newSize)); + + // store the new font size + consoleFontSize = newSize; + settings.setValue(fontSizeSettingsKey, consoleFontSize); + + // clear console (reset icon sizes, default stylesheet) and re-add the content + float oldPosFactor = 1.0 / ui->messagesWidget->verticalScrollBar()->maximum() * ui->messagesWidget->verticalScrollBar()->value(); + clear(); + ui->messagesWidget->setHtml(str); + ui->messagesWidget->verticalScrollBar()->setValue(oldPosFactor * ui->messagesWidget->verticalScrollBar()->maximum()); +} + void RPCConsole::clear() { ui->messagesWidget->clear(); @@ -468,26 +511,20 @@ void RPCConsole::clear() ui->messagesWidget->document()->addResource( QTextDocument::ImageResource, QUrl(ICON_MAPPING[i].url), - platformStyle->SingleColorImage(ICON_MAPPING[i].source).scaled(ICON_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + platformStyle->SingleColorImage(ICON_MAPPING[i].source).scaled(QSize(consoleFontSize*2, consoleFontSize*2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } // Set default style sheet QFontInfo fixedFontInfo(GUIUtil::fixedPitchFont()); - // Try to make fixed font adequately large on different OS -#ifdef WIN32 - QString ptSize = QString("%1pt").arg(QFontInfo(QFont()).pointSize() * 10 / 8); -#else - QString ptSize = QString("%1pt").arg(QFontInfo(QFont()).pointSize() * 8.5 / 9); -#endif ui->messagesWidget->document()->setDefaultStyleSheet( QString( "table { }" - "td.time { color: #808080; padding-top: 3px; } " + "td.time { color: #808080; font-size: %2; padding-top: 3px; } " "td.message { font-family: %1; font-size: %2; white-space:pre-wrap; } " "td.cmd-request { color: #006060; } " "td.cmd-error { color: red; } " "b { color: #006060; } " - ).arg(fixedFontInfo.family(), ptSize) + ).arg(fixedFontInfo.family(), QString("%1pt").arg(consoleFontSize)) ); message(CMD_REPLY, (tr("Welcome to the Bitcoin Core RPC console.") + "
" + diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 162d61cfd..648e32638 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -78,6 +78,9 @@ private Q_SLOTS: public Q_SLOTS: void clear(); + void fontBigger(); + void fontSmaller(); + void setFontSize(int newSize); /** Append the message to the message widget */ void message(int category, const QString &message, bool html = false); /** Set number of connections shown in the UI */ @@ -134,6 +137,7 @@ private: RPCTimerInterface *rpcTimerInterface; QMenu *peersTableContextMenu; QMenu *banTableContextMenu; + int consoleFontSize; }; #endif // BITCOIN_QT_RPCCONSOLE_H