From 3a3a9273255f1caa68c96c327489938f7f310806 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 22 Jan 2016 18:00:36 +0100 Subject: [PATCH 1/3] [Qt] Add option to increase/decrease font size in the console window --- src/Makefile.qt.include | 2 + src/qt/bitcoin.qrc | 2 + src/qt/forms/debugwindow.ui | 136 +++++++++++++++++++++++++------ src/qt/res/icons/fontbigger.png | Bin 0 -> 1180 bytes src/qt/res/icons/fontsmaller.png | Bin 0 -> 951 bytes src/qt/rpcconsole.cpp | 59 +++++++++++--- src/qt/rpcconsole.h | 4 + 7 files changed, 168 insertions(+), 35 deletions(-) create mode 100644 src/qt/res/icons/fontbigger.png create mode 100644 src/qt/res/icons/fontsmaller.png diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index a390d96a9..82e95abcf 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -245,6 +245,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..3c9b9d283 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -46,6 +46,8 @@ res/icons/about_qt.png res/icons/verify.png res/icons/warning.png + res/icons/fontbigger.png + res/icons/fontsmaller.png res/movies/spinner-000.png diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 247147036..045eb80d9 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -450,39 +450,90 @@ 3 - - - - - 0 - 100 - - - - true - - - false - - - 2 - - - + + 5 + - 3 + 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 + + @@ -495,6 +546,9 @@ Clear console + + Qt::LeftToRight + @@ -508,6 +562,42 @@ false + + true + + + + + + + + + + 0 + 100 + + + + true + + + false + + + 2 + + + + + + + 3 + + + + + > + diff --git a/src/qt/res/icons/fontbigger.png b/src/qt/res/icons/fontbigger.png new file mode 100644 index 0000000000000000000000000000000000000000..5ca5c563b25ecc2b90a064db3f86e02aa759bb66 GIT binary patch literal 1180 zcmV;N1Y`S&P)qpXJ000DINklA_IpxrUdgwZ&!Liq~JNrkPfg#{Xt6lxPqy2VvWi(9#@%Fmh1OY5AfW-x{xBwOp z5wHcT0W?JKn_gT1^8(Hc;5Gn80yu2IV?)3-fJ6X?2{GvJjqu>iIQICTJbWlb!A?Ex+v0j>nFAHX&7naZk( z1+X2!nSt!7IW@5WwgZ@=ea8l&U0V}7TD1ZIuK^4Jd{91ApBbBPz*Oy~*=NXy6j?4uJ0(b-aiX zaAx_r*&~)$cm%u+;H<5HDcX10$d?kPYma~v0H221V2`op}Ph3E*2B0aHOF z8a;wi?${IH7XXgi2)MKf;ekzTet8_oq@%V0PHl(L2R5)7{+R(k2QY0LVAkY-L6|N* z&18MlsN1<3aYq4|HN9srLZ7RNiEUg{J#LZjs=uE#>h%-An|tRh@-?4;soHndMeEe- z6o!CP0Podv^Oz3p0B{E2+R?Hj9lxH9 zTU-H7z%bLaz(zI(bDC}318@}(+?ihi*mDJ#Wv-YZOpghGhXKN!`Op<$mTV70GUGo@ ztl7qcfB_%40L+%JWeU@|0A3An0iLPJWky}ERZ56n4R9Us4OsZ>mqFI@#%B@2y&JuY zOj_RfaioB23lklcO6Z@ewBU&f|5E^;02~7Ntx=a-0AJL!=2Vq`4B)FO`%GQS?L-Io z_xo~tW;j*3qvntk09z_OxS^5^&y*jokZgFW&Rth!ZK|@j)wSGCRf2!NFSn1FlMPQ) z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1` #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,39 @@ 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 + clear(); + ui->messagesWidget->setHtml(str); +} + void RPCConsole::clear() { ui->messagesWidget->clear(); @@ -468,26 +509,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 8a48179c5..83b543e54 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 From 56c9e66a6d7c798394478660f6088b943fe4e96d Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 23 Jan 2016 00:05:14 +0100 Subject: [PATCH 2/3] [Qt] keep scroll position in GUI console after changing font size --- src/qt/forms/debugwindow.ui | 4 ++-- src/qt/rpcconsole.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 045eb80d9..2f4613099 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -480,7 +480,7 @@ - Decrease Font Size + Decrease font size @@ -512,7 +512,7 @@ - Increase Font Size + Increase font size diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 40c54225f..dca34ed04 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -490,8 +490,10 @@ void RPCConsole::setFontSize(int 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() From 43abb02aa20bd32795478236b20b45d3b4087138 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 23 Jan 2016 10:00:10 +0100 Subject: [PATCH 3/3] [Qt] Add a new chevron/arrow icon for the console prompt line --- contrib/debian/copyright | 3 +++ src/Makefile.qt.include | 1 + src/qt/bitcoin.qrc | 1 + src/qt/forms/debugwindow.ui | 41 +++++++++++++++++++++++++++++++---- src/qt/res/icons/chevron.png | Bin 0 -> 1923 bytes 5 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 src/qt/res/icons/chevron.png 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 82e95abcf..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 \ diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index 3c9b9d283..dcd3b4ae2 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -48,6 +48,7 @@ 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 2f4613099..763128611 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -479,12 +479,12 @@ 24 - - Decrease font size - + + Decrease font size + :/icons/fontsmaller:/icons/fontsmaller @@ -593,10 +593,43 @@ 3 + + + + false + + + + 16 + 24 + + + + + + + + :/icons/prompticon + :/icons/prompticon:/icons/prompticon + + + + 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 0000000000000000000000000000000000000000..ac985052c1527a9a687cc1acbb53f940a7df375b GIT binary patch literal 1923 zcmaJ?dr%YS77vlw@M@$)D2*d)C{}Fqf;>pZG$jdv6oLXlP(cmZg`|+|k}PKBC4z+O zwNItfiq)bPMQIUleV|lG=pAe&lwijxVp~?Y1!}p%?WAB4uHC5E`-iEtE1JiOSY&02HtV0t9RUOV5qr0U|M*C*X^DyjOr2E-#kD<8oreEFMq7 z7fEU}D)Rl5^`IO&iTF0tr|#^pzPQy~(C1=69gMGM14i>J830Hd(g z03(1x0j$yJ^hUGSj(!NxXe4U071f#bkXk8a5)^Es5tJxnxO@RWjxQI-iFmvOfmke8 zsZ;`Pypk)I^Mry$tP<9jm>@H{hz0+|3jPx7odpv@WL82J;|>T^Szr_Jux5$zDOzHM z3G!Hhis0kNK3&TrEcg^HkFmnP#BvBR9B*g;r_+lrVtl;YCv!^}PbMES6XR|n<~ls{ zR}XPrX4J}fEjBcHxIZ~Fo_=+FD5I@W7@9EB)5y*BWYkg%gMEX+v^?m%;r6!eEyDAL z%-%N`N@bU0^Pb)I4Pck>lHuq8ZJ&c$e|^pMZ+hvw|NOC{8AJwkf9Y!mU#(=2F>O{vc%kRxQ zih-^zOu}*o`InpVmsrjteie!dM@X18dRddUTLwE`X30ude6i1d3OG*BD#lut4A#PO zT5Wy9J(v5{I+JRm0zd3O|M7)5vn?tr$r*1G*w?4kk8D1G3lZC-9vk`j%Gr~{zEf{i zBpsZ-_v}x;3)@|eZDp0TJ(WS_aU1c9lqn0PJcVDJc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