diff --git a/src/models/books/booklet.h b/src/models/books/booklet.h index 94807c2..c4b56c3 100644 --- a/src/models/books/booklet.h +++ b/src/models/books/booklet.h @@ -1,61 +1,80 @@ #ifndef BOOKLET_H #define BOOKLET_H #include "owl.h" #ifdef STATIC_MAUIKIT #include "fmh.h" #include "mauilist.h" #else #include #include #endif class Booklet : public MauiList { Q_OBJECT Q_PROPERTY(SORTBY sortBy READ getSortBy WRITE setSortBy NOTIFY sortByChanged) Q_PROPERTY(ORDER order READ getOrder WRITE setOrder NOTIFY orderChanged) + Q_PROPERTY(QString book READ getBook WRITE setBook NOTIFY bookChanged) public: Booklet(QObject *parent = nullptr); enum ORDER : uint8_t { DESC, ASC }; Q_ENUM(ORDER) enum SORTBY : uint8_t { TITLE = FMH::MODEL_KEY::TITLE, ADDDATE = FMH::MODEL_KEY::ADDDATE, MODIFIED = FMH::MODEL_KEY::MODIFIED, COLOR = FMH::MODEL_KEY::COLOR, FAVORITE = FMH::MODEL_KEY::FAVORITE, PIN = FMH::MODEL_KEY::PIN }; Q_ENUM(SORTBY) FMH::MODEL_LIST items() const override final; void setSortBy(const SORTBY &sort); SORTBY getSortBy() const; void setOrder(const ORDER &order); ORDER getOrder() const; + QString getBook() const + { + return m_book; + } + +public slots: + void setBook(QString book) + { + if (m_book == book) + return; + + m_book = book; + emit bookChanged(m_book); + } + private: FMH::MODEL_LIST m_list; void sortList(); SORTBY sort = SORTBY::MODIFIED; ORDER order = ORDER::DESC; + QString m_book; + signals: void sortByChanged(); void orderChanged(); + void bookChanged(QString book); }; #endif // BOOKLET_H diff --git a/src/views/books/BookletPage.qml b/src/views/books/BookletPage.qml index ddb5e1a..35061ca 100644 --- a/src/views/books/BookletPage.qml +++ b/src/views/books/BookletPage.qml @@ -1,28 +1,93 @@ import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.7 as Kirigami -Maui.Page +Item { -id: control + id: control -signal exit() + signal exit() -headBar.leftContent: ToolButton -{ - icon.name: "go-previous" - onClicked: control.exit() -} + Maui.Page + { + id: _page + anchors.fill: parent + anchors.rightMargin: _drawer.modal === false ? _drawer.contentItem.width * _drawer.position : 0 -Kirigami.OverlayDrawer -{ - edge: Qt.RightEdge - width: Kirigami.Units.gridUnit * 16 - height: parent.height - headBar.height - y: headBar.height - modal: true -} + headBar.leftContent: [ + ToolButton + { + icon.name: "go-previous" + onClicked: control.exit() + }, + + TextField + { + id: title + Layout.fillWidth: true + Layout.margins: space.medium + placeholderText: qsTr("New chapter...") + font.weight: Font.Bold + font.bold: true + font.pointSize: fontSizes.large + // Kirigami.Theme.backgroundColor: selectedColor + // Kirigami.Theme.textColor: Qt.darker(selectedColor, 2.5) + // color: fgColor + background: Rectangle + { + color: "transparent" + } + } + ] + + + Maui.Editor + { + anchors.fill: parent + } + + Maui.Dialog + { + id: _newChapter + + title: qsTr("New Chapter") + message: qsTr("Create a new chapter for your current book. Give it a title") + entryField: true + } + + Kirigami.OverlayDrawer + { + id: _drawer + edge: Qt.RightEdge + width: Kirigami.Units.gridUnit * 16 + height: parent.height - headBar.height + y: headBar.height + modal: !isWide + + Rectangle + { + z: 999 + anchors.bottom: parent.bottom + anchors.margins: toolBarHeight + anchors.horizontalCenter: parent.horizontalCenter + height: toolBarHeight + width: height + + color: Kirigami.Theme.highlightColor + radius: radiusV + + ToolButton + { + anchors.centerIn: parent + icon.name: "list-add" + icon.color: Qt.darker(parent.color, 2) + + onClicked: _newChapter.open() + } + } + } + } }