Browser in left panel

remove toolbar text when doesn't fit
frameworks
Marco Martin 11 years ago
parent ab700b2453
commit 933e72ec03
  1. 369
      mobile/app/package/contents/ui/Browser.qml
  2. 4
      mobile/app/package/contents/ui/Documents.qml

@ -26,221 +26,225 @@ import org.kde.kquickcontrolsaddons 2.0
import org.kde.okular 2.0 as Okular import org.kde.okular 2.0 as Okular
MobileComponents.OverlayDrawer { MobileComponents.SplitDrawer {
id: resourceBrowser id: mainDrawer
property string currentUdi
anchors.fill: parent anchors.fill: parent
visible: true
drawer: Documents {
implicitWidth: mainDrawer.width/4 * 3
}
MouseEventListener { MobileComponents.OverlayDrawer {
id: pageArea id: resourceBrowser
anchors.fill: parent anchors.fill: parent
//enabled: !delegate.interactive visible: true
property Item delegate: delegate1
property Item oldDelegate: delegate2 MouseEventListener {
property bool incrementing: delegate.delta > 0 id: pageArea
Connections { anchors.fill: parent
target: pageArea.delegate clip: true
onDeltaChanged: { //enabled: !delegate.interactive
pageArea.oldDelegate.delta = pageArea.delegate.delta property Item delegate: delegate1
if (pageArea.delegate.delta > 0) { property Item oldDelegate: delegate2
pageArea.oldDelegate.visible = true property bool incrementing: delegate.delta > 0
pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber + 1 Connections {
documentItem.currentPage = pageArea.oldDelegate.pageNumber target: pageArea.delegate
pageArea.oldDelegate.visible = !(pageArea.delegate.pageNumber == documentItem.pageCount-1) onDeltaChanged: {
} else if (pageArea.delegate.delta < 0) { pageArea.oldDelegate.delta = pageArea.delegate.delta
pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber - 1 if (pageArea.delegate.delta > 0) {
documentItem.currentPage = pageArea.oldDelegate.pageNumber pageArea.oldDelegate.visible = true
pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber + 1
pageArea.oldDelegate.visible = pageArea.delegate.pageNumber != 0 documentItem.currentPage = pageArea.oldDelegate.pageNumber
pageArea.oldDelegate.visible = !(pageArea.delegate.pageNumber == documentItem.pageCount-1)
} else if (pageArea.delegate.delta < 0) {
pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber - 1
documentItem.currentPage = pageArea.oldDelegate.pageNumber
pageArea.oldDelegate.visible = pageArea.delegate.pageNumber != 0
}
} }
} }
}
property int startMouseScreenX property int startMouseScreenX
property int startMouseScreenY property int startMouseScreenY
onPressed: { onPressed: {
startMouseScreenX = mouse.screenX startMouseScreenX = mouse.screenX
startMouseScreenY = mouse.screenY startMouseScreenY = mouse.screenY
}
onPositionChanged: {
if (Math.abs(mouse.screenX - startMouseScreenX) > width/5) {
delegate.pageSwitchEnabled = true
} }
} onPositionChanged: {
onReleased: { if (Math.abs(mouse.screenX - startMouseScreenX) > width/5) {
delegate.pageSwitchEnabled = false delegate.pageSwitchEnabled = true
if (Math.abs(mouse.screenX - startMouseScreenX) < 20 &&
Math.abs(mouse.screenY - startMouseScreenY) < 20) {
if (browserFrame.state == "Closed") {
browserFrame.state = "Hidden"
} else {
browserFrame.state = "Closed"
} }
} else if (oldDelegate.visible && delegate.delta != 0 &&
(Math.abs(mouse.screenX - startMouseScreenX) > width/5) &&
Math.abs(mouse.screenX - startMouseScreenX) > Math.abs(mouse.screenY - startMouseScreenY)) {
oldDelegate = delegate
delegate = (delegate == delegate1) ? delegate2 : delegate1
switchAnimation.running = true
} }
} onReleased: {
FullScreenDelegate { delegate.pageSwitchEnabled = false
id: delegate2 if (Math.abs(mouse.screenX - startMouseScreenX) < 20 &&
width: parent.width Math.abs(mouse.screenY - startMouseScreenY) < 20) {
height: parent.height if (browserFrame.state == "Closed") {
} browserFrame.state = "Hidden"
FullScreenDelegate { } else {
id: delegate1 browserFrame.state = "Closed"
width: parent.width }
height: parent.height
Component.onCompleted: pageNumber = documentItem.currentPage
}
SequentialAnimation { } else if (oldDelegate.visible && delegate.delta != 0 &&
id: switchAnimation (Math.abs(mouse.screenX - startMouseScreenX) > width/5) &&
NumberAnimation { Math.abs(mouse.screenX - startMouseScreenX) > Math.abs(mouse.screenY - startMouseScreenY)) {
target: pageArea.oldDelegate oldDelegate = delegate
properties: "x" delegate = (delegate == delegate1) ? delegate2 : delegate1
to: pageArea.incrementing ? -pageArea.oldDelegate.width : pageArea.oldDelegate.width switchAnimation.running = true
easing.type: Easing.InQuad
duration: 250
}
ScriptAction {
script: {
pageArea.oldDelegate.z = 0
pageArea.delegate.z = 10
pageArea.oldDelegate.x = 0
pageArea.delegate.x = 0
} }
} }
ScriptAction { FullScreenDelegate {
script: delegate1.delta = delegate2.delta = 0 id: delegate2
width: parent.width
height: parent.height
} }
} FullScreenDelegate {
} id: delegate1
PlasmaComponents.ScrollBar { width: parent.width
flickableItem: pageArea.delegate.flickable height: parent.height
orientation: Qt.Vertical Component.onCompleted: pageNumber = documentItem.currentPage
anchors {
right: pageArea.right
top: pageArea.top
bottom: pageArea.bottom
left: undefined
}
}
PlasmaComponents.ScrollBar {
flickableItem: pageArea.delegate.flickable
orientation: Qt.Horizontal
anchors {
left: pageArea.left
right: pageArea.right
bottom: pageArea.bottom
top: undefined
}
}
drawer: 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 { SequentialAnimation {
id: switchAnimation
NumberAnimation { NumberAnimation {
target: pageArea.oldDelegate
properties: "x"
to: pageArea.incrementing ? -pageArea.oldDelegate.width : pageArea.oldDelegate.width
easing.type: Easing.InQuad
duration: 250 duration: 250
} }
ScriptAction {
script: {
pageArea.oldDelegate.z = 0
pageArea.delegate.z = 10
pageArea.oldDelegate.x = 0
pageArea.delegate.x = 0
}
}
ScriptAction {
script: delegate1.delta = delegate2.delta = 0
}
} }
}
PlasmaComponents.ScrollBar {
flickableItem: pageArea.delegate.flickable
orientation: Qt.Vertical
anchors { anchors {
left: parent.left right: pageArea.right
right: parent.right top: pageArea.top
bottom: pageArea.bottom
left: undefined
} }
} }
PlasmaComponents.ScrollBar {
flickableItem: pageArea.delegate.flickable
PlasmaComponents.PageStack { orientation: Qt.Horizontal
id: pageStack
anchors { anchors {
left: parent.left left: pageArea.left
top: mainToolBar.bottom right: pageArea.right
right: parent.right bottom: pageArea.bottom
bottom: tabsToolbar.top top: undefined
} }
clip: true
toolBar: mainToolBar
} }
Connections { drawer: Item {
id: scrollConnection id: browserFrame
property int oldContentY:0 anchors.fill: parent
target: pageStack.currentPage state: "Hidden"
PlasmaComponents.ToolBar {
id: mainToolBar
onContentYChanged: { height: units.gridUnit * 2
scrollConnection.oldContentY = pageStack.currentPage.contentY 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.ToolBar {
id: tabsToolbar PlasmaComponents.PageStack {
y: parent.height - tabsToolbar.height*5 id: pageStack
height: mainTabBar.height anchors {
anchors { left: parent.left
top: undefined top: mainToolBar.bottom
bottom: browserFrame.bottom right: parent.right
left: parent.left bottom: tabsToolbar.top
right: parent.right }
clip: true
toolBar: mainToolBar
} }
tools: Item {
width: parent.width Connections {
height: childrenRect.height id: scrollConnection
PlasmaComponents.TabBar { property int oldContentY:0
id: mainTabBar target: pageStack.currentPage
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(parent.width, implicitWidth) onContentYChanged: {
tabPosition: Qt.BottomEdge scrollConnection.oldContentY = pageStack.currentPage.contentY
PlasmaComponents.TabButton { }
id: documentsButton }
text: i18n("Documents")
onCheckedChanged: { PlasmaComponents.ToolBar {
if (checked) { id: tabsToolbar
pageStack.replace(Qt.createComponent("Documents.qml")) y: parent.height - tabsToolbar.height*5
} height: mainTabBar.height
} anchors {
} top: undefined
PlasmaComponents.TabButton { bottom: browserFrame.bottom
id: thumbnailsButton left: parent.left
text: i18n("Thumbnails") right: parent.right
onCheckedChanged: { }
if (checked) { tools: Item {
pageStack.replace(Qt.createComponent("Thumbnails.qml")) 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 {
PlasmaComponents.TabButton { id: tocButton
id: tocButton enabled: documentItem.tableOfContents.count > 0
enabled: documentItem.tableOfContents.count > 0 text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Table of contents") : ""
text: i18n("Table of contents") iconSource: "view-table-of-contents-ltr"
onCheckedChanged: { onCheckedChanged: {
if (checked) { if (checked) {
pageStack.replace(Qt.createComponent("TableOfContents.qml")) pageStack.replace(Qt.createComponent("TableOfContents.qml"))
}
} }
} }
} PlasmaComponents.TabButton {
PlasmaComponents.TabButton { id: bookmarksButton
id: bookmarksButton enabled: documentItem.bookmarkedPages.length > 0
enabled: documentItem.bookmarkedPages.length > 0 text: tabsToolbar.width > units.gridUnit * 30 ? i18n("Bookmarks") : ""
text: i18n("Bookmarks") iconSource: "bookmarks-organize"
onCheckedChanged: { onCheckedChanged: {
if (checked) { if (checked) {
pageStack.replace(Qt.createComponent("Bookmarks.qml")) pageStack.replace(Qt.createComponent("Bookmarks.qml"))
}
} }
} }
} }
@ -249,4 +253,3 @@ MobileComponents.OverlayDrawer {
} }
} }
} }

@ -27,6 +27,7 @@ import Qt.labs.folderlistmodel 2.1
PlasmaComponents.Page { PlasmaComponents.Page {
id: root id: root
anchors.fill: parent anchors.fill: parent
visible: true
property Item view: filesView property Item view: filesView
property alias contentY: filesView.contentY property alias contentY: filesView.contentY
property alias contentHeight: filesView.contentHeight property alias contentHeight: filesView.contentHeight
@ -38,7 +39,6 @@ PlasmaComponents.Page {
height: searchField.height height: searchField.height
PlasmaComponents.TextField { PlasmaComponents.TextField {
id: searchField id: searchField
enabled: documentItem.supportsSearch
anchors.centerIn: parent anchors.centerIn: parent
onTextChanged: { onTextChanged: {
if (text.length > 2) { if (text.length > 2) {
@ -96,7 +96,7 @@ PlasmaComponents.Page {
} }
onClicked: { onClicked: {
documentItem.path = model.filePath; documentItem.path = model.filePath;
resourceBrowser.open = false; mainDrawer.open = false;
mainTabBar.currentTab = thumbnailsButton; mainTabBar.currentTab = thumbnailsButton;
} }
} }

Loading…
Cancel
Save