diff options
Diffstat (limited to 'rbutil/rbutilqt/gui/changelog.cpp')
-rw-r--r-- | rbutil/rbutilqt/gui/changelog.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/gui/changelog.cpp b/rbutil/rbutilqt/gui/changelog.cpp new file mode 100644 index 0000000000..d8361023b1 --- /dev/null +++ b/rbutil/rbutilqt/gui/changelog.cpp | |||
@@ -0,0 +1,70 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2013 by Dominik Riebeling | ||
10 | * | ||
11 | * All files in this archive are subject to the GNU General Public License. | ||
12 | * See the file COPYING in the source tree root for full license agreement. | ||
13 | * | ||
14 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
15 | * KIND, either express or implied. | ||
16 | * | ||
17 | ****************************************************************************/ | ||
18 | |||
19 | #include "changelog.h" | ||
20 | #include "rbsettings.h" | ||
21 | #include "ui_changelogfrm.h" | ||
22 | |||
23 | Changelog::Changelog(QWidget *parent) : QDialog(parent) | ||
24 | { | ||
25 | ui.setupUi(this); | ||
26 | ui.browserChangelog->setOpenExternalLinks(true); | ||
27 | ui.browserChangelog->setHtml(parseChangelogFile(":/docs/changelog.txt")); | ||
28 | ui.browserChangelog->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); | ||
29 | ui.checkBoxShowAlways->setChecked(RbSettings::value(RbSettings::ShowChangelog).toBool()); | ||
30 | connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept())); | ||
31 | } | ||
32 | |||
33 | |||
34 | void Changelog::accept(void) | ||
35 | { | ||
36 | RbSettings::setValue(RbSettings::ShowChangelog, ui.checkBoxShowAlways->isChecked()); | ||
37 | this->hide(); | ||
38 | this->deleteLater(); | ||
39 | } | ||
40 | |||
41 | |||
42 | QString Changelog::parseChangelogFile(QString filename) | ||
43 | { | ||
44 | QFile changelog(filename); | ||
45 | changelog.open(QIODevice::ReadOnly); | ||
46 | QTextStream c(&changelog); | ||
47 | QString text; | ||
48 | while(!c.atEnd()) { | ||
49 | QString line = c.readLine(); | ||
50 | if(line.startsWith("#")) | ||
51 | continue; | ||
52 | if(line.startsWith("Version")) { | ||
53 | text.append(QString("<h4>Rockbox Utility %1</h4>").arg(line.remove("Version"))); | ||
54 | line = c.readLine(); | ||
55 | text.append("<ul>"); | ||
56 | while(line.startsWith("*")) { | ||
57 | QString t = line.remove(QRegExp("^\\*")); | ||
58 | t.replace(QRegExp("FS#(\\d+)"), | ||
59 | "<a href='http://www.rockbox.org/tracker/task/\\1'>FS#\\1</a>"); | ||
60 | text.append(QString("<li>%1</li>").arg(t)); | ||
61 | line = c.readLine(); | ||
62 | if(line.startsWith("#")) | ||
63 | line = c.readLine(); | ||
64 | } | ||
65 | text.append("</ul>"); | ||
66 | } | ||
67 | } | ||
68 | changelog.close(); | ||
69 | return text; | ||
70 | } | ||