Skip to content

Commit

Permalink
Merge pull request #78 from nikwen/bbCodeParsing
Browse files Browse the repository at this point in the history
Introduce proper BB code parsing, visual updates for the ThreadPage
  • Loading branch information
nikwen committed Jul 4, 2015
2 parents 37d3eef + fc24a82 commit 4d11e52
Show file tree
Hide file tree
Showing 20 changed files with 1,331 additions and 274 deletions.
1 change: 1 addition & 0 deletions backend/ForumBackend.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Object {
property int postsPerPage: 10
property int topicsLoadCount: 20
property alias signature: settingsBackend.signature
property alias useAlternativeDateFormat: settingsBackend.useAlternativeDateFormat

U1db.Index {
database: db
Expand Down
1 change: 1 addition & 0 deletions backend/SettingsBackend.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ import Qt.labs.settings 1.0

Settings {
property string signature: i18n.tr("Sent from my awesome Ubuntu Touch device using the Forum Browser app")
property bool useAlternativeDateFormat: false
}
3 changes: 1 addition & 2 deletions ui/ForumsListPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ Page {
var page = component.createObject(mainView, {"current_forum": 0, "title": text})
if (page === null) console.log(component.errorString())
pageStack.push(page)
page.loadingSpinnerRunning = true
}

onPressAndHold: {
Expand Down Expand Up @@ -169,7 +168,7 @@ Page {
text: i18n.tr("Swipe up from the bottom to add a forum")
visible: listView.count === 0
elide: Text.ElideRight
wrapMode: Text.WordWrap
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
fontSize: "large"
anchors {
Expand Down
79 changes: 79 additions & 0 deletions ui/components/CheckboxSubtitledListItem.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright 2012 Canonical Ltd.
* Copyright 2015 Niklas Wenzel <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 2.3
import Ubuntu.Components 1.1
import Ubuntu.Components.ListItems 1.0 as ListItem

ListItem.Base {
id: subtitledListItem
__height: Math.max(middleVisuals.height, units.gu(6))

/*!
\preliminary
The list of strings that will be shown under the label text
\qmlproperty string subText
*/
property alias subText: subLabel.text

property alias checked: checkBox.checked

Item {
id: middleVisuals
anchors {
left: parent.left
right: checkBox.left //NOTE: Changed the anchor here (also removed the example code comments and fixed the imports)
rightMargin: units.gu(2) //NOTE: Added this margin
verticalCenter: parent.verticalCenter
}
height: childrenRect.height + label.anchors.topMargin + subLabel.anchors.bottomMargin

LabelVisual {
id: label
text: subtitledListItem.text
selected: subtitledListItem.selected
anchors {
top: parent.top
left: parent.left
right: parent.right
}
}
LabelVisual {
id: subLabel
selected: subtitledListItem.selected
secondary: true
anchors {

left: parent.left
right: parent.right
top: label.bottom
}
fontSize: "small"
wrapMode: Text.Wrap
maximumLineCount: 1 //NOTE: Changed the line count here
}
}

CheckBox { //NOTE: Added this CheckBox
id: checkBox

anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
}
}
2 changes: 1 addition & 1 deletion ui/components/Notification.qml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Rectangle {
fontSize: "medium"
color: textColor
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
wrapMode: Text.Wrap

property real wantedWidth: 0 //Needed for multi-line notifications

Expand Down
44 changes: 44 additions & 0 deletions ui/components/VerticalDivider.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Forum Browser
*
* Copyright (c) 2014-2015 Niklas Wenzel <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 2.3
import Ubuntu.Components 1.1

Rectangle {
id: verticalDivider

property alias dividerHeight: verticalDivider.width
property real dividerPadding: units.gu(1)
property bool rotateClockwise: true

height: (visible) ? units.dp(2) : 0

y: width / 2 + dividerPadding
rotation: (rotateClockwise ? 1 : -1) * 90
transformOrigin: Item.Center

property bool __lightBackground: ColorUtils.luminance(Theme.palette.normal.background) > 0.85

gradient: Gradient {
GradientStop { position: 0.0; color: __lightBackground ? Qt.rgba(0, 0, 0, 0.1) : Qt.rgba(0, 0, 0, 0.4) }
GradientStop { position: 0.49; color: __lightBackground ? Qt.rgba(0, 0, 0, 0.1) : Qt.rgba(0, 0, 0, 0.4) }
GradientStop { position: 0.5; color: __lightBackground ? Qt.rgba(1, 1, 1, 0.4) : Qt.rgba(1, 1, 1, 0.1) }
GradientStop { position: 1.0; color: __lightBackground ? Qt.rgba(1, 1, 1, 0.4) : Qt.rgba(1, 1, 1, 0.1) }
}
}
54 changes: 47 additions & 7 deletions ui/settings/SettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,62 @@

import QtQuick 2.3
import Ubuntu.Components 1.1
import Ubuntu.Components.ListItems 1.0 as ListItem
import "../components"

Page {
id: settingsPage
title: i18n.tr("Settings")

Column {
Flickable {
anchors.fill: parent

OneLineSubtitledListItem {
text: i18n.tr("Signature")
subText: (backend.signature !== "") ? backend.signature : i18n.tr("Displays a signature below all of your posts…")
progression: true
contentHeight: column.height

onClicked: {
pageStack.push(Qt.resolvedUrl("EditSignaturePage.qml"))
Column {
id: column
width: parent.width

// ListItem.Header {
// text: i18n.tr("Display settings")
// }

CheckboxSubtitledListItem {
id: useAlternativeDateFormatListItem
text: i18n.tr("Alternative date format")
//TRANSLATORS: Setting to switch between the date formats used in MessageDelegate.qml. Please format the example dates accordingly.
subText: backend.useAlternativeDateFormat ? i18n.tr("Current format: At 11:54, On March 7, On April 10, 2015") : i18n.tr("Current format: 28 minutes ago, 14 hours ago, March 2015")
checked: backend.useAlternativeDateFormat

onClicked: {
checked = !checked
}

onCheckedChanged: {
backend.useAlternativeDateFormat = checked
}

Connections {
target: backend

onUseAlternativeDateFormatChanged: {
useAlternativeDateFormatListItem.checked = backend.useAlternativeDateFormat
}
}
}

// ListItem.Header {
// text: i18n.tr("Identity settings")
// }

OneLineSubtitledListItem {
text: i18n.tr("Signature")
subText: (backend.signature !== "") ? backend.signature : i18n.tr("Displays a signature below all of your posts…")
progression: true

onClicked: {
pageStack.push(Qt.resolvedUrl("EditSignaturePage.qml"))
}
}
}
}
Expand Down
Loading

0 comments on commit 4d11e52

Please sign in to comment.