Commit eb1f7380 authored by Marco Martin's avatar Marco Martin
Browse files

port to kirigami

port away from plasma-framework dependencies
parent f9917aa9
/*
* Copyright 2012 Marco Martin <mart@kde.org>
*
* 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,
* 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, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
import org.kde.kquickcontrolsaddons 2.0
import org.kde.okular 2.0 as Okular
MobileComponents.SplitDrawer {
id: splitDrawer
anchors.fill: parent
visible: true
property alias splitDrawerOpen: splitDrawer.opened
property alias overlayDrawerOpen: resourceBrowser.opened
property Item globalDrawer: splitDrawer
property Item contextDrawer: resourceDrawer
//An alias doesn't work
property bool bookmarked: false
onBookmarkedChanged: {
pageArea.page.bookmarked = bookmarked
}
contentItem: Documents {
implicitWidth: units.gridUnit * 25
}
MobileComponents.OverlayDrawer {
id: resourceBrowser
anchors.fill: parent
edge: Qt.RightEdge
Okular.DocumentView {
id: pageArea
document: documentItem
anchors.fill: parent
onPageChanged: {
bookmarkConnection.target = page
splitDrawer.bookmarked = page.bookmarked
}
}
//HACK
Connections {
id: bookmarkConnection
target: pageArea.page
onBookmarkedChanged: splitDrawer.bookmarked = pageArea.page.bookmarked
}
contentItem: Item {
id: browserFrame
anchors.fill: parent
state: "Hidden"
PlasmaComponents.ToolBar {
id: mainToolBar
height: units.gridUnit * 2
y: pageStack.currentPage.contentY <= 0 ? 0 : -height
transform: Translate {
y: Math.max(0, -pageStack.currentPage.contentY)
}
tools: pageStack.currentPage.tools
Behavior on y {
NumberAnimation {
duration: 250
}
}
anchors {
left: parent.left
right: parent.right
}
}
PlasmaComponents.PageStack {
id: pageStack
anchors {
left: parent.left
top: mainToolBar.bottom
right: parent.right
bottom: tabsToolbar.top
}
clip: true
toolBar: mainToolBar
}
Connections {
id: scrollConnection
property int oldContentY:0
target: pageStack.currentPage
onContentYChanged: {
scrollConnection.oldContentY = pageStack.currentPage.contentY
}
}
PlasmaComponents.ToolBar {
id: tabsToolbar
y: parent.height - tabsToolbar.height*5
height: mainTabBar.height
anchors {
top: undefined
bottom: browserFrame.bottom
left: parent.left
right: parent.right
}
tools: Item {
width: parent.width
height: childrenRect.height
PlasmaComponents.TabBar {
id: mainTabBar
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(parent.width, implicitWidth)
tabPosition: Qt.BottomEdge
PlasmaComponents.TabButton {
id: thumbnailsButton
text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Thumbnails") : ""
iconSource: "view-preview"
onCheckedChanged: {
if (checked) {
pageStack.replace(Qt.createComponent("Thumbnails.qml"))
}
}
}
PlasmaComponents.TabButton {
id: tocButton
enabled: documentItem.tableOfContents.count > 0
text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Table of contents") : ""
iconSource: "view-table-of-contents-ltr"
onCheckedChanged: {
if (checked) {
pageStack.replace(Qt.createComponent("TableOfContents.qml"))
}
}
}
PlasmaComponents.TabButton {
id: bookmarksButton
enabled: documentItem.bookmarkedPages.length > 0
text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Bookmarks") : ""
iconSource: "bookmarks-organize"
onCheckedChanged: {
if (checked) {
pageStack.replace(Qt.createComponent("Bookmarks.qml"))
}
}
}
}
}
}
}
}
}
......@@ -18,45 +18,36 @@
*/
import QtQuick 2.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
import QtQuick.Controls 1.3
import org.kde.kirigami 1.0 as Kirigami
import Qt.labs.folderlistmodel 2.1
MobileComponents.Page {
Item {
id: root
anchors.fill: parent
color: theme.viewBackgroundColor
visible: true
property Item view: filesView
property alias contentY: filesView.contentY
property alias contentHeight: filesView.contentHeight
property alias model: filesView.model
tools: Item {
Item {
id: toolBarContent
width: root.width
height: searchField.height
PlasmaComponents.TextField {
height: searchField.height + Kirigami.Units.gridUnit
TextField {
id: searchField
anchors.centerIn: parent
onTextChanged: {
if (text.length > 2) {
filterModel.filterRegExp = ".*" + text + ".*";
} else {
filterModel.filterRegExp = "";
}
}
focus: true
}
}
MobileComponents.Label {
Kirigami.Label {
z: 2
visible: filesView.count == 0
anchors {
fill: parent
margins: MobileComponents.Units.gridUnit
margins: Kirigami.Units.gridUnit
}
text: i18n("No Documents found. To start to read, put some files in the Documents folder of your device.")
wrapMode: Text.WordWrap
......@@ -64,31 +55,28 @@ MobileComponents.Page {
verticalAlignment: Text.AlignVCenter
}
PlasmaExtras.ScrollArea {
anchors.fill: parent
ScrollView {
anchors {
top: toolBarContent.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
ListView {
id: filesView
anchors.fill: parent
model: PlasmaCore.SortFilterModel {
id: filterModel
filterRole: "fileName"
sourceModel: FolderListModel {
id: folderModel
folder: userPaths.documents
nameFilters: ["*.pdf", "*.txt", "*.chm", "*.epub"]
showDirs: false
}
model: FolderListModel {
id: folderModel
folder: userPaths.documents
nameFilters: ["*.pdf", "*.txt", "*.chm", "*.epub"]
showDirs: false
}
delegate: MobileComponents.ListItem {
enabled: true
PlasmaComponents.Label {
text: model.fileName
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
elide: Text.ElideRight
}
delegate: Kirigami.BasicListItem {
label: model.fileName
visible: model.fileName.indexOf(searchField.text) !== -1
height: visible ? implicitHeight : 0
onClicked: {
documentItem.path = model.filePath;
globalDrawer.opened = false;
......
/*
* Copyright 2012 Marco Martin <mart@kde.org>
*
* 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,
* 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, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import org.kde.okular 2.0 as Okular
import org.kde.kirigami 1.0 as Kirigami
Kirigami.Page {
property alias document: pageArea.document
leftPadding: 0
topPadding: 0
rightPadding: 0
bottomPadding: 0
actions.main: Kirigami.Action {
iconName: "bookmarks-organize"
checkable: true
onCheckedChanged: pageArea.page.bookmarked = checked;
}
Okular.DocumentView {
id: pageArea
anchors.fill: parent
onPageChanged: {
bookmarkConnection.target = page
actions.main.checked = page.bookmarked
}
onClicked: fileBrowserRoot.controlsVisible = !fileBrowserRoot.controlsVisible
}
Connections {
id: bookmarkConnection
target: pageArea.page
onBookmarkedChanged: actions.main.checked = pageArea.page.bookmarked
}
}
......@@ -18,68 +18,43 @@
*/
import QtQuick 2.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
import QtQuick.Controls 1.3
import org.kde.kirigami 1.0 as Kirigami
import org.kde.kquickcontrolsaddons 2.0
import org.kde.okular 2.0 as Okular
MobileComponents.OverlayDrawer {
Kirigami.OverlayDrawer {
edge: Qt.RightEdge
contentItem: Item {
id: browserFrame
implicitWidth: MobileComponents.Units.gridUnit * 25
implicitWidth: Kirigami.Units.gridUnit * 25
implicitHeight: implicitWidth
state: "Hidden"
PlasmaComponents.ToolBar {
id: mainToolBar
height: units.gridUnit * 2
y: pageStack.currentPage.contentY <= 0 ? 0 : -height
transform: Translate {
y: Math.max(0, -pageStack.currentPage.contentY)
}
tools: pageStack.currentPage.tools
Behavior on y {
NumberAnimation {
duration: 250
}
}
anchors {
left: parent.left
right: parent.right
}
}
PlasmaComponents.PageStack {
StackView {
id: pageStack
anchors {
left: parent.left
top: mainToolBar.bottom
top: parent.top
right: parent.right
bottom: tabsToolbar.top
}
clip: true
toolBar: mainToolBar
}
Connections {
id: scrollConnection
property int oldContentY:0
target: pageStack.currentPage
target: pageStack.currentItem
onContentYChanged: {
scrollConnection.oldContentY = pageStack.currentPage.contentY
scrollConnection.oldContentY = pageStack.currentItem.contentY
}
}
PlasmaComponents.ToolBar {
ToolBar {
id: tabsToolbar
y: parent.height - tabsToolbar.height*5
height: mainTabBar.height
anchors {
top: undefined
......@@ -87,45 +62,52 @@ MobileComponents.OverlayDrawer {
left: parent.left
right: parent.right
}
tools: Item {
Component.onCompleted: thumbnailsButton.checked = true;
Item {
width: parent.width
height: childrenRect.height
PlasmaComponents.TabBar {
Row {
id: mainTabBar
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(parent.width, implicitWidth)
tabPosition: Qt.BottomEdge
PlasmaComponents.TabButton {
ExclusiveGroup { id: tabPositionGroup }
ToolButton {
id: thumbnailsButton
text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Thumbnails") : ""
iconSource: "view-preview"
iconName: "view-preview"
checkable: true
onCheckedChanged: {
if (checked) {
pageStack.replace(Qt.createComponent("Thumbnails.qml"))
}
}
exclusiveGroup: tabPositionGroup
}
PlasmaComponents.TabButton {
ToolButton {
id: tocButton
enabled: documentItem.tableOfContents.count > 0
text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Table of contents") : ""
iconSource: "view-table-of-contents-ltr"
iconName: "view-table-of-contents-ltr"
checkable: true
onCheckedChanged: {
if (checked) {
pageStack.replace(Qt.createComponent("TableOfContents.qml"))
}
}
exclusiveGroup: tabPositionGroup
}
PlasmaComponents.TabButton {
ToolButton {
id: bookmarksButton
enabled: documentItem.bookmarkedPages.length > 0
text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Bookmarks") : ""
iconSource: "bookmarks-organize"
iconName: "bookmarks-organize"
checkable: true
onCheckedChanged: {
if (checked) {
pageStack.replace(Qt.createComponent("Bookmarks.qml"))
}
}
exclusiveGroup: tabPositionGroup
}
}
}
......
......@@ -18,28 +18,34 @@
*/
import QtQuick 2.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
import QtQuick.Controls 1.3
import org.kde.kirigami 1.0 as Kirigami
PlasmaComponents.Page {
Kirigami.Page {
id: root
leftPadding: 0
topPadding: 0
rightPadding: 0
bottomPadding: 0
property alias contentY: flickable.contentY
property alias contentHeight: flickable.contentHeight
tools: Item {
ToolBar {
id: toolBarContent
width: root.width
height: searchField.height
PlasmaComponents.TextField {
TextField {
id: searchField
clearButtonShown: true
anchors.centerIn: parent
}
}
PlasmaExtras.ScrollArea {
anchors.fill: parent
ScrollView {
anchors {
left: parent.left
top: toolBarContent.bottom
right: parent.right
bottom: parent.bottom
}
Flickable {
id: flickable
......
......@@ -18,22 +18,20 @@
*/
import QtQuick 2.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
import QtQuick.Controls 1.3
import org.kde.kirigami 1.0 as Kirigami
ThumbnailsBase {
id: root
model: documentItem.matchingPages
anchors.fill: parent
tools: Item {
ToolBar {
id: toolBarContent
width: root.width
height: searchField.height
PlasmaComponents.TextField {
TextField {
id: searchField
clearButtonShown: true
enabled: documentItem.supportsSearch
anchors.centerIn: parent
onTextChanged: {
......@@ -45,7 +43,7 @@ ThumbnailsBase {
}
}
}
PlasmaComponents.Label {
Kirigami.Label {
anchors {
left: searchField.right
verticalCenter: searchField.verticalCenter
......
</
......@@ -18,14 +18,16 @@
*/
import QtQuick 2.1
import QtQuick.Controls 1.3
import org.kde.okular 2.0 as Okular
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
import org.kde.kirigami 1.0 as Kirigami
PlasmaComponents.Page {
Kirigami.Page {
id: root
leftPadding: 0
topPadding: 0
rightPadding: 0
bottomPadding: 0
property alias contentY: resultsGrid.contentY
property alias contentHeight: resultsGrid.contentHeight
property alias model: resultsGrid.model
......@@ -34,8 +36,11 @@ PlasmaComponents.Page {
anchors.fill: parent
PlasmaExtras.ScrollArea {
anchors.fill: parent
ScrollView {
anchors {
fill: parent
topMargin: Kirigami.Units.gridUnit * 2
}
GridView {
id: resultsGrid
......@@ -54,20 +59,18 @@ PlasmaComponents.Page {
resultsGrid.currentIndex = index
}
}
PlasmaCore.FrameSvgItem {
Rectangle {
anchors.centerIn: parent
imagePath: "widgets/media-delegate"
prefix: "picture"
width: thumbnail.width + margins.left + margins.right
width: thumbnail.width + Kirigami.Units.smallSpacing * 2
//FIXME: why bindings with thumbnail.height doesn't work?
height: thumbnail.height + margins.top + margins.bottom