Mercurial > hg > octave-nkf
changeset 17764:811b5a562680
Format release notes as preformatted text in the GUI (bug #40367)
* libgui/src/main-window.cc (display_release_notes): Merge with
display_url_in_window. Read NEWS file into a string and wrap contents in
HTML <pre></pre> tags.
* libgui/src/main-window.h (display_url_in_window): Delete declaration.
* NEWS: Remove HTML <pre></pre> tags.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Sat, 26 Oct 2013 00:38:31 -0400 |
parents | 32344942ee6e |
children | 26a418799bc3 |
files | NEWS libgui/src/main-window.cc libgui/src/main-window.h |
diffstat | 3 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS +++ b/NEWS @@ -1,4 +1,3 @@ -<pre> Summary of important user-visible changes for version 3.8: --------------------------------------------------------- @@ -1477,4 +1476,3 @@ spchol2inv splu See NEWS.3 for old news. -</pre>
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -39,6 +39,7 @@ #include <QFileDialog> #include <QMessageBox> #include <QIcon> +#include <QTextStream> #include <utility> @@ -251,18 +252,31 @@ void main_window::display_release_notes (void) { - std::string news_file = "file://" + Voct_etc_dir + "/NEWS"; + std::string news_file = Voct_etc_dir + "/NEWS"; + + QString news; - display_url_in_window (QUrl (QString::fromStdString (news_file))); -} + QFile *file = new QFile (QString::fromStdString (news_file)); + if (file->open (QFile::ReadOnly)) + { + QTextStream *stream = new QTextStream (file); + news = stream->readAll (); + if (! news.isEmpty ()) + { + news.prepend ("<pre>"); + news.append ("</pre>"); + } + else + news = tr ("The release notes file is empty."); + } + else + news = tr ("The release notes file cannot be read."); -void -main_window::display_url_in_window (const QUrl& url) -{ + QWidget *w = new QWidget; QTextBrowser *browser = new QTextBrowser (w); - browser->setSource (url); + browser->setText (news); QVBoxLayout *vlayout = new QVBoxLayout; vlayout->addWidget (browser);