Skip to content

Commit

Permalink
Merge pull request #39 from nikwen/unifiedThreadPostCreationPage
Browse files Browse the repository at this point in the history
Unified thread/post creation page and drafts for posts
  • Loading branch information
nikwen committed Nov 27, 2014
2 parents 850d515 + e0c2f62 commit 0220e22
Show file tree
Hide file tree
Showing 15 changed files with 542 additions and 313 deletions.
2 changes: 1 addition & 1 deletion backend/ApiRequest.qml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Item {
} else {
notification.show((xhr.status === 404) ? i18n.tr("Error 404: Could not find Tapatalk API for given URL") : i18n.tr("Connection error"))
console.log((xhr.status === 404) ? "Error 404: Could not find Tapatalk API for given URL" : "Connection error")
queryExecuted(session, false, "")
queryExecuted(false, "")
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion backend/ForumBackend.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ Object {

property int postsPerPage: 10
property int topicsLoadCount: 20
property string signature: i18n.tr("Sent from my awesome Ubuntu Touch device using the Forum Browser app")
property alias signature: settingsBackend.signature

U1db.Index {
database: db
id: by_url
expression: ["url", "user", "password"]
}

SettingsBackend {
id: settingsBackend
}

Component {
id: sessionComponent

Expand All @@ -62,6 +66,8 @@ Object {
property alias configModel: configModel
property alias loginRequest: loginRequest

readonly property string user: (loginDbQuery.results[0].user !== undefined) ? loginDbQuery.results[0].user : ""

signal loginDone

ForumConfigModel {
Expand Down
32 changes: 32 additions & 0 deletions backend/SettingsBackend.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*************************************************************************
** Forum Browser
**
** Copyright (c) 2014 Niklas Wenzel <[email protected]>
**
** $QT_BEGIN_LICENSE:GPL$
** 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 2 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; see the file COPYING. If not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
** Boston, MA 02110-1301, USA.
**
**
** $QT_END_LICENSE$
**
*************************************************************************/

import QtQuick 2.2
import Qt.labs.settings 1.0

Settings {
property string signature: i18n.tr("Sent from my awesome Ubuntu Touch device using the Forum Browser app")
}
13 changes: 13 additions & 0 deletions forum-app.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ MainView {

useDeprecatedToolbar: false

anchorToKeyboard: true

U1db.Database {
id: db
path: "forums.u1db"
Expand All @@ -55,6 +57,17 @@ MainView {
defaults: { "name": "XDA Developers", "url": "forum.xda-developers.com", "user": "", "password": "" }
}

U1db.Database {
id: draftsDb
path: "drafts.u1db"
}

U1db.Index {
id: draftsIndex
database: draftsDb
expression: [ "forum_url", "username", "mode", "forum_id", "topic_id", "subject", "message" ]
}

PageStack {
id: pageStack

Expand Down
2 changes: 1 addition & 1 deletion ui/AddForumPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Page {
Action {
id: save
iconName: "ok"
text: docId !== ""?i18n.tr("Edit"):i18n.tr("Add")
text: docId !== "" ? i18n.tr("Edit") : i18n.tr("Add")
onTriggered: {
if (nameTextField.text !== "" && urlTextField.text !== "") {
//Remove protocol from url (so that there are no multiple instances of one forum but with different prefixes)
Expand Down
8 changes: 7 additions & 1 deletion ui/ForumsListPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

import QtQuick 2.2
import Ubuntu.Components 1.1
import U1db 1.0 as U1db
import Ubuntu.Components.ListItems 1.0 as ListItem
import U1db 1.0 as U1db

Page {
id: forumsListPage
Expand All @@ -40,6 +40,12 @@ Page {
iconName: "add"
onTriggered: pageStack.push(Qt.resolvedUrl("AddForumPage.qml"))
},
Action {
id: settingsAction
text: i18n.tr("Settings")
iconName: "settings"
onTriggered: pageStack.push(Qt.resolvedUrl("settings/SettingsPage.qml"))
},
Action {
id: aboutAction
text: i18n.tr("About")
Expand Down
67 changes: 67 additions & 0 deletions ui/components/OneLineSubtitledListItem.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2012 Canonical Ltd.
* Copyright 2014 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.2
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

Item {
id: middleVisuals
anchors {
left: parent.left
right: parent.right
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 (this is the only change to this file besides the removal of example code comments and fixing the imports)
}
}
}
85 changes: 85 additions & 0 deletions ui/settings/EditSignaturePage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*************************************************************************
** Forum Browser
**
** Copyright (c) 2014 Niklas Wenzel <[email protected]>
**
** $QT_BEGIN_LICENSE:GPL$
** 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 2 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; see the file COPYING. If not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
** Boston, MA 02110-1301, USA.
**
**
** $QT_END_LICENSE$
**
*************************************************************************/

import QtQuick 2.2
import Ubuntu.Components 1.1
import Ubuntu.Components.Popups 1.0
import Ubuntu.Components.ListItems 1.0 as ListItem
import Ubuntu.Components.Themes.Ambiance 0.1
import "../../stringutils.js" as StringUtils
import "../../backend"
import "../components"

Page {
id: editSignaturePage

title: i18n.tr("Edit Signature")

Component.onCompleted: {
signatureTextField.text = backend.signature
}

head.actions: [
Action {
id: saveAction
text: i18n.tr("Save")
iconName: "ok"

onTriggered: {
backend.signature = signatureTextField.text
pageStack.pop()
}
}
]

head.backAction: Action {
id: cancelAction
text: i18n.tr("Cancel")
iconName: "close"

onTriggered: {
pageStack.pop()
}
}

TextArea {
id: signatureTextField
autoSize: false
maximumLineCount: 0
placeholderText: i18n.tr("Enter signature or leave blank")

anchors {
fill: parent
margins: units.gu(2)
}

style: TextAreaStyle {
overlaySpacing: 0
frameSpacing: 0
background: Item {}
}
}
}
48 changes: 48 additions & 0 deletions ui/settings/SettingsPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*************************************************************************
** Forum Browser
**
** Copyright (c) 2014 Niklas Wenzel <[email protected]>
**
** $QT_BEGIN_LICENSE:GPL$
** 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 2 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; see the file COPYING. If not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
** Boston, MA 02110-1301, USA.
**
**
** $QT_END_LICENSE$
**
*************************************************************************/

import QtQuick 2.2
import Ubuntu.Components 1.1
import "../components"

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

Column {
anchors.fill: parent

OneLineSubtitledListItem {
text: i18n.tr("Signature")
subText: backend.signature
progression: true

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

0 comments on commit 0220e22

Please sign in to comment.