toolbar to open sidepanels

fix bookmarks management
This commit is contained in:
Marco Martin 2015-09-18 18:22:28 +02:00
parent 933e72ec03
commit 8d8665582c
6 changed files with 78 additions and 8 deletions

View file

@ -27,11 +27,20 @@ import org.kde.okular 2.0 as Okular
MobileComponents.SplitDrawer {
id: mainDrawer
id: splitDrawer
anchors.fill: parent
visible: true
property alias splitDrawerOpen: splitDrawer.open
property alias overlayDrawerOpen: resourceBrowser.open
//An alias doesn't work
property bool bookmarked: pageArea.delegate.bookmarked
onBookmarkedChanged: {
pageArea.delegate.bookmarked = bookmarked
}
drawer: Documents {
implicitWidth: mainDrawer.width/4 * 3
implicitWidth: splitDrawer.width/4 * 3
}
MobileComponents.OverlayDrawer {
@ -47,6 +56,12 @@ MobileComponents.SplitDrawer {
property Item delegate: delegate1
property Item oldDelegate: delegate2
property bool incrementing: delegate.delta > 0
property bool bookmarked: delegate.bookmarked
onBookmarkedChanged: {
splitDrawer.bookmarked = delegate.bookmarked;
}
Connections {
target: pageArea.delegate
onDeltaChanged: {

View file

@ -96,7 +96,7 @@ PlasmaComponents.Page {
}
onClicked: {
documentItem.path = model.filePath;
mainDrawer.open = false;
splitDrawer.open = false;
mainTabBar.currentTab = thumbnailsButton;
}
}

View file

@ -39,6 +39,7 @@ MouseEventListener {
property alias document: mainPage.document
property alias pageNumber: mainPage.pageNumber
property Item pageItem: mainPage
property alias bookmarked: mainPage.bookmarked
onWheelMoved: {
if (wheel.modifiers == Qt.ControlModifier) {

View file

@ -37,6 +37,55 @@ ApplicationWindow {
uri: documentItem.path
}*/
statusBar: PlasmaComponents.ToolBar {
id: toolbar
tools: PlasmaComponents.ToolBarLayout {
//TODO: those buttons should support drag to open the menus as well
PlasmaComponents.ToolButton {
id: openButton
iconSource: "document-open"
checkable: true
onCheckedChanged: {
mainStack.currentPage.splitDrawerOpen = checked
if (checked) {
mainStack.currentPage.overlayDrawerOpen = false;
}
}
}
PlasmaComponents.ToolButton {
id: bookmarkButton
iconSource: "bookmarks-organize"
checkable: true
onCheckedChanged: {
mainStack.currentPage.bookmarked = checked
}
}
PlasmaComponents.ToolButton {
id: exploreButton
iconSource: "view-list-icons"
checkable: true
onCheckedChanged: {
mainStack.currentPage.overlayDrawerOpen = checked
if (checked) {
mainStack.currentPage.splitDrawerOpen = false;
}
}
}
}
Connections {
target: mainStack.currentPage
onSplitDrawerOpenChanged: {
openButton.checked = mainStack.currentPage.splitDrawerOpen;
}
onOverlayDrawerOpenChanged: {
exploreButton.checked = mainStack.currentPage.overlayDrawerOpen;
}
onBookmarkedChanged: {
bookmarkButton.checked = mainStack.currentPage.bookmarked
}
}
}
Okular.DocumentItem {
id: documentItem
onWindowTitleForDocumentChanged: {
@ -47,7 +96,6 @@ ApplicationWindow {
PlasmaComponents.PageStack {
id: mainStack
clip: false
anchors.fill: parent
}
//FIXME: this is due to global vars being binded after the parse is done, do the 2 steps parsing

View file

@ -73,6 +73,7 @@ void DocumentItem::setPath(const QString &path)
emit openedChanged();
emit supportsSearchingChanged();
emit windowTitleForDocumentChanged();
emit bookmarkedPagesChanged();
}
QString DocumentItem::windowTitleForDocument() const
@ -130,7 +131,7 @@ TOCModel *DocumentItem::tableOfContents() const
return m_tocModel;
}
QList<int> DocumentItem::bookmarkedPages() const
QVariantList DocumentItem::bookmarkedPages() const
{
QList<int> list;
QSet<int> pages;
@ -140,7 +141,12 @@ QList<int> DocumentItem::bookmarkedPages() const
}
list = pages.toList();
qSort(list);
return list;
QVariantList variantList;
foreach (const int page, list) {
variantList << page;
}
return variantList;
}
QStringList DocumentItem::bookmarks() const

View file

@ -86,7 +86,7 @@ class DocumentItem : public QObject
/**
* List of pages that contain a bookmark
*/
Q_PROPERTY(QList<int> bookmarkedPages READ bookmarkedPages NOTIFY bookmarkedPagesChanged)
Q_PROPERTY(QVariantList bookmarkedPages READ bookmarkedPages NOTIFY bookmarkedPagesChanged)
/**
* list of bookmarks urls valid on this page
@ -118,7 +118,7 @@ public:
TOCModel *tableOfContents() const;
QList<int> bookmarkedPages() const;
QVariantList bookmarkedPages() const;
QStringList bookmarks() const;