DB_LIST;
static const DB KEYMAP =
{
{KEY::ID, "id"},
{KEY::BODY, "body"},
{KEY::UPDATED, "updated"},
{KEY::TITLE, "title"},
{KEY::URL, "url"},
{KEY::FAV, "fav"},
+ {KEY::PIN, "pin"},
{KEY::COLOR, "color"},
{KEY::ADD_DATE, "addDate"},
{KEY::TAG, "tag"},
{KEY::PREVIEW, "preview"},
{KEY::IMAGE, "image"},
{KEY::LINK, "link"}
};
const QString CollectionDBPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/buho/";
const QString NotesPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/buho/notes/";
const QString BooksPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/buho/books/";
const QString LinksPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)+"/buho/links/";
const QString App = "Buho";
const QString version = "1.0";
const QString comment = "Notes taking and link collector manager";
const QString DBName = "collection.db";
inline bool fileExists(const QString &url)
{
QFileInfo path(url);
if (path.exists()) return true;
else return false;
}
inline void saveJson(QJsonDocument document, QString fileName)
{
QFile jsonFile(fileName);
jsonFile.open(QFile::WriteOnly);
jsonFile.write(document.toJson());
}
inline QVariantMap openJson(const QString &url)
{
QString val;
QFile file;
file.setFileName(url);
file.open(QIODevice::ReadOnly | QIODevice::Text);
val = file.readAll();
file.close();
QJsonDocument d = QJsonDocument::fromJson(val.toUtf8());
QJsonObject obj = d.object();
return obj.toVariantMap();
}
inline QString saveImage(QByteArray array, const QString &path)
{
if(!array.isNull()&&!array.isEmpty())
{
QImage img;
img.loadFromData(array);
QString name = path;
name.replace("/", "-");
name.replace("&", "-");
QString format = "JPEG";
if (img.save(path+".jpg", format.toLatin1(), 100))
return path+".jpg";
else qDebug() << "couldn't save artwork";
}else qDebug()<<"array is empty";
return QString();
}
}
#endif // OWL_H
diff --git a/src/views/links/LinksView.qml b/src/views/links/LinksView.qml
index 339b06a..bf67d3c 100644
--- a/src/views/links/LinksView.qml
+++ b/src/views/links/LinksView.qml
@@ -1,46 +1,89 @@
import QtQuick 2.9
import "../../widgets"
import org.kde.maui 1.0 as Maui
Maui.Page
{
id: control
property alias cardsView : cardsView
property alias previewer : previewer
property var currentLink : ({})
signal linkClicked(var link)
- headBarVisible: false
margins: isMobile ? space.big : space.enormus
+ headBarExit: false
+ headBar.leftContent: [
+ Maui.ToolButton
+ {
+ iconName: cardsView.gridView ? "view-list-icons" : "view-list-details"
+ onClicked:
+ {
+ cardsView.gridView = !cardsView.gridView
+ cardsView.refresh()
+ }
+ },
+ Maui.ToolButton
+ {
+ iconName: "view-sort-ascending"
+
+ },
+
+ Maui.ToolButton
+ {
+ iconName: "view-sort-descending"
+
+ }
+ ]
+
+ headBar.rightContent: [
+ Maui.ToolButton
+ {
+ iconName: "tag-recents"
+
+ },
+
+ Maui.ToolButton
+ {
+ iconName: "window-pin"
+
+ },
+
+ Maui.ToolButton
+ {
+ iconName: "view-calendar-day"
+
+ }
+ ]
+
Previewer
{
id: previewer
}
CardsView
{
id: cardsView
anchors.fill: parent
onItemClicked: linkClicked(cardsView.model.get(index))
holder.message: "No Links!
You can create new notes
links and books
"
}
function populate()
{
var data = owl.getLinks()
for(var i in data)
{
console.log("PREVIEW", data[i].preview)
append(data[i])
}
}
function append(link)
{
cardsView.model.append(link)
}
}
diff --git a/src/views/notes/NotesView.qml b/src/views/notes/NotesView.qml
index abefc5f..db76405 100644
--- a/src/views/notes/NotesView.qml
+++ b/src/views/notes/NotesView.qml
@@ -1,32 +1,116 @@
import QtQuick 2.9
+import QtQuick.Layouts 1.3
import "../../widgets"
import org.kde.maui 1.0 as Maui
+import org.kde.kirigami 2.2 as Kirigami
+
Maui.Page
{
property alias cardsView : cardsView
property var currentNote : ({})
signal noteClicked(var note)
- margins: isMobile ? space.big : space.enormus
+ margins: 0
+
+ headBarExit : false
+
+ headBar.leftContent: [
+ Maui.ToolButton
+ {
+ iconName: cardsView.gridView ? "view-list-icons" : "view-list-details"
+ onClicked:
+ {
+ cardsView.gridView = !cardsView.gridView
+ cardsView.refresh()
+ }
+ },
+ Maui.ToolButton
+ {
+ iconName: "view-sort-ascending"
+
+ },
+
+ Maui.ToolButton
+ {
+ iconName: "view-sort-descending"
+
+ }
+ ]
+
+ headBar.rightContent: [
+ Maui.ToolButton
+ {
+ iconName: "tag-recents"
+
+ },
+ Maui.ToolButton
+ {
+ id: pinButton
+ iconName: "window-pin"
+ checkable: true
+ iconColor: checked ? highlightColor : textColor
- headBarVisible: false
- CardsView
+ },
+
+ Maui.ToolButton
+ {
+ iconName: "view-calendar-day"
+
+ }
+ ]
+
+ ColumnLayout
{
- id: cardsView
anchors.fill: parent
- onItemClicked: noteClicked(cardsView.model.get(index))
+ spacing: 0
+ CardsList
+ {
+ id: pinnedList
+ visible: pinButton.checked
+ Layout.margins: isMobile ? space.big : space.enormus
+ Layout.alignment: Qt.AlignVCenter
+ Layout.fillWidth: true
+ height: cardsView.itemHeight
+ itemHeight: cardsView.itemHeight * 0.9
+ itemWidth: itemHeight
+ onItemClicked: noteClicked(cardsView.model.get(index))
+
+ }
+
+ Kirigami.Separator
+ {
+ visible: pinnedList.visible
+ Layout.fillWidth: true
+ height: unit
+ }
+
+ CardsView
+ {
+ id: cardsView
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ Layout.margins: isMobile ? space.big : space.enormus
+ onItemClicked: noteClicked(cardsView.model.get(index))
+ holder.message : "No notes!
Click here to create a new note
"
+
+ Connections
+ {
+ target: cardsView.holder
+ onActionTriggered: newNote()
+ }
+ }
}
function populate()
{
var data = owl.getNotes()
- for(var i in data)
+ for(var i in data)
append(data[i])
}
function append(note)
{
cardsView.model.append(note)
}
}
diff --git a/src/widgets/CardDelegate.qml b/src/widgets/CardDelegate.qml
index 8186118..affea08 100644
--- a/src/widgets/CardDelegate.qml
+++ b/src/widgets/CardDelegate.qml
@@ -1,156 +1,171 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import org.kde.kirigami 2.2 as Kirigami
ItemDelegate
{
id: control
- property string noteColor : color ? color : "pink"
- property int cardWidth: Kirigami.Units.devicePixelRatio*200
- property int cardHeight: Kirigami.Units.devicePixelRatio*120
- property int cardRadius: Kirigami.Units.devicePixelRatio*4
+ property string noteColor : color ? color : viewBackgroundColor
+ property int cardWidth: visible ? unit * 200 : 0
+ property int cardHeight: visible ? unit * 120 : 0
+ property int cardRadius: unit * 4
+
+ property bool condition : true
+
width: cardWidth
height: cardHeight
hoverEnabled: !isMobile
background: Rectangle
{
color: "transparent"
}
+ visible: condition
+
DropShadow
{
anchors.fill: card
visible: card.visible
horizontalOffset: 0
verticalOffset: 3
radius: 8.0
samples: 17
- color: "#80000000"
+ color: Qt.darker(noteColor, 1.5)
source: card
}
Rectangle
{
id: card
z: -999
anchors.centerIn: control
anchors.fill: control
border.color: Qt.darker(noteColor, 1.2)
color: noteColor
radius: cardRadius
}
Rectangle
{
anchors.fill: parent
color: hovered? "#333" : "transparent"
z: 999
opacity: 0.3
+ radius: cardRadius
}
ColumnLayout
{
- anchors.fill: parent
+ height: parent.height * 0.9
+ width: parent.width * 0.9
+ anchors.centerIn: parent
spacing: 0
clip: true
Label
{
id: title
visible: title.text.length > 0
Layout.leftMargin: space.medium
Layout.topMargin: space.medium
Layout.rightMargin: space.medium
+ Layout.alignment: Qt.AlignLeft
+
Layout.fillWidth: true
text: model.title
color: Qt.darker(model.color, 3)
elide: Qt.ElideRight
font.weight: Font.Bold
font.bold: true
font.pointSize: fontSizes.large
+
}
TextArea
{
id: body
+ padding: 0
visible: typeof model.body !== 'undefined'
Layout.leftMargin: visible ? space.medium : 0
Layout.bottomMargin: visible ? space.medium : 0
Layout.rightMargin: visible ? space.medium : 0
Layout.topMargin: title.visible ? 0 : space.medium
-
+ Layout.alignment: Qt.AlignLeft
Layout.fillHeight: visible
Layout.fillWidth: visible
enabled: false
text: model.body
color: Qt.darker(model.color, 3)
textFormat: TextEdit.RichText
font.pointSize: fontSizes.big
background: Rectangle
{
color: "transparent"
}
}
Item
{
id: preview
Layout.fillHeight: true
Layout.fillWidth: true
Layout.margins: unit
clip: true
Layout.topMargin: space.medium
visible: img.status === Image.Ready
Image
{
id: img
visible: status === Image.Ready
asynchronous: true
anchors.centerIn: parent
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
height: parent.height
width: parent.width
sourceSize.height: height
sourceSize.width: width
fillMode: Image.PreserveAspectCrop
source: "file://"+encodeURIComponent( model.preview ) || ""
layer.enabled: img.visible
layer.effect: OpacityMask
{
maskSource: Item
{
width: img.width
height: img.height
Rectangle
{
anchors.centerIn: parent
width: img.width
height: img.height
radius: cardRadius
// radius: Math.min(width, height)
}
}
}
}
}
}
function update(note)
{
- title.text = note.title
- body.text = note.body
- noteColor = note.color
+ console.log("UPDATE NOTES", note.pin)
+ model.title = note.title
+ model.body = note.body
+ model.color = note.color
+ model.pin = note.pin ? 1 : 0
+ model.fav = note.fav ? 1 : 0
}
}
diff --git a/src/widgets/CardsList.qml b/src/widgets/CardsList.qml
new file mode 100644
index 0000000..254f340
--- /dev/null
+++ b/src/widgets/CardsList.qml
@@ -0,0 +1,36 @@
+import QtQuick 2.0
+import org.kde.maui 1.0 as Maui
+
+ListView
+{
+ id: control
+ clip: true
+
+ property int itemWidth: unit * 200
+ property int itemHeight: unit * 200
+ signal itemClicked(int index)
+ boundsBehavior: !isMobile? Flickable.StopAtBounds : Flickable.DragAndOvershootBounds
+ orientation: ListView.Horizontal
+ spacing: space.large
+ Maui.Holder
+ {
+ id: holder
+ visible: count < 1
+ message: "No pinned notes!
You can pin your notes to see them here
"
+ }
+
+ model: notesView.cardsView.model
+ delegate: CardDelegate
+ {
+ cardWidth: model.pin == 1 ? itemWidth : 0
+ cardHeight: model.pin == 1 ? itemHeight : 0
+ condition: model.pin == 1
+
+ onClicked:
+ {
+ currentIndex = index
+ itemClicked(index)
+ }
+ }
+
+}
diff --git a/src/widgets/CardsView.qml b/src/widgets/CardsView.qml
index 2f56e3b..63486b9 100644
--- a/src/widgets/CardsView.qml
+++ b/src/widgets/CardsView.qml
@@ -1,64 +1,64 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import org.kde.kirigami 2.2 as Kirigami
import org.kde.maui 1.0 as Maui
GridView
{
property bool gridView : true
property alias holder : holder
readonly property int defaultSize : unit * 200
- property int itemWidth : !gridView ? parent.width :
+ property int itemWidth : !gridView ? parent.width * 0.9 :
isMobile? (width-itemSpacing) * 0.42 : unit * 200
property int itemHeight: unit * 120
property int itemSpacing: space.huge
signal itemClicked(int index)
boundsBehavior: !isMobile? Flickable.StopAtBounds : Flickable.DragAndOvershootBounds
cellWidth: itemWidth + itemSpacing
cellHeight: itemHeight + itemSpacing
-
+ clip : true
Maui.Holder
{
id: holder
visible: count < 1
- message: "No notes!
You can create new notes
links and books
"
+ message: "Nohing here!
You can create new notes
links and books
"
}
model: ListModel { id: cardsModel}
delegate: CardDelegate
{
id: delegate
cardWidth: itemWidth
cardHeight: itemHeight
onClicked:
{
currentIndex = index
itemClicked(index)
}
}
// onWidthChanged: if(!isMobile && gridView) adaptGrid()
function adaptGrid()
{
var amount = parseInt(width/(itemWidth + itemSpacing),10)
var leftSpace = parseInt(width-(amount*(itemWidth + itemSpacing)), 10)
var size = parseInt((itemWidth + itemSpacing)+(parseInt(leftSpace/amount, 10)), 10)
size = size > itemWidth + itemSpacing ? size : itemWidth + itemSpacing
cellWidth = size
}
function refresh()
{
model = cardsModel
}
}
diff --git a/src/widgets/ColorsBar.qml b/src/widgets/ColorsBar.qml
new file mode 100644
index 0000000..f168760
--- /dev/null
+++ b/src/widgets/ColorsBar.qml
@@ -0,0 +1,105 @@
+import QtQuick 2.0
+import QtQuick.Controls 2.2
+
+Row
+{
+ signal colorPicked(color color)
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: space.medium
+
+ Rectangle
+ {
+ color:"#ffded4"
+ anchors.verticalCenter: parent.verticalCenter
+ height: iconSizes.medium
+ width: height
+ radius: Math.max(height, width)
+ border.color: borderColor
+
+ MouseArea
+ {
+ anchors.fill: parent
+ onClicked: colorPicked(parent.color)
+ }
+ }
+
+ Rectangle
+ {
+ color:"#d3ffda"
+ anchors.verticalCenter: parent.verticalCenter
+ height: iconSizes.medium
+ width: height
+ radius: Math.max(height, width)
+ border.color: borderColor
+
+ MouseArea
+ {
+ anchors.fill: parent
+ onClicked: colorPicked(parent.color)
+ }
+ }
+
+ Rectangle
+ {
+ color:"#caf3ff"
+ anchors.verticalCenter: parent.verticalCenter
+ height: iconSizes.medium
+ width: height
+ radius: Math.max(height, width)
+ border.color: borderColor
+
+ MouseArea
+ {
+ anchors.fill: parent
+ onClicked: colorPicked(parent.color)
+ }
+ }
+
+ Rectangle
+ {
+ color:"#dbd8ff"
+ anchors.verticalCenter: parent.verticalCenter
+ height: iconSizes.medium
+ width: height
+ radius: Math.max(height, width)
+ border.color: borderColor
+
+ MouseArea
+ {
+ anchors.fill: parent
+ onClicked: colorPicked(parent.color)
+ }
+ }
+
+ Rectangle
+ {
+ color:"#ffcdf4"
+ anchors.verticalCenter: parent.verticalCenter
+ height: iconSizes.medium
+ width: height
+ radius: Math.max(height, width)
+ border.color: borderColor
+
+ MouseArea
+ {
+ anchors.fill: parent
+ onClicked: colorPicked(parent.color)
+ }
+ }
+
+ Rectangle
+ {
+ color: viewBackgroundColor
+ anchors.verticalCenter: parent.verticalCenter
+ height: iconSizes.medium
+ width: height
+ radius: Math.max(height, width)
+ border.color: borderColor
+
+ MouseArea
+ {
+ anchors.fill: parent
+ onClicked: colorPicked(parent.color)
+ }
+ }
+}
diff --git a/src/widgets/NewLinkDialog.qml b/src/widgets/NewLinkDialog.qml
index 24e2b7b..bb826ed 100644
--- a/src/widgets/NewLinkDialog.qml
+++ b/src/widgets/NewLinkDialog.qml
@@ -1,298 +1,219 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.0
import org.kde.maui 1.0 as Maui
import org.buho.editor 1.0
import org.kde.kirigami 2.2 as Kirigami
Popup
{
parent: ApplicationWindow.overlay
height: previewReady ? parent.height * (isMobile ? 0.8 : 0.7) :
contentLayout.implicitHeight
width: parent.width * (isMobile ? 0.9 : 0.7)
signal linkSaved(var note)
property string selectedColor : "#ffffe6"
property string fgColor: Qt.darker(selectedColor, 2.5)
property bool previewReady : false
x: (parent.width / 2) - (width / 2)
y: (parent.height /2 ) - (height / 2)
modal: true
padding: isAndroid ? 1 : "undefined"
Connections
{
target: linker
onPreviewReady:
{
previewReady = true
fill(link)
}
}
Maui.Page
{
id: content
margins: 0
anchors.fill: parent
Rectangle
{
id: bg
color: selectedColor
z: -1
anchors.fill: parent
}
onExit: clear()
headBarVisible: previewReady
footBarVisible: previewReady
- headBar.rightContent: Row
+ headBar.rightContent: ColorsBar
{
- spacing: space.medium
- Rectangle
- {
- color:"#ffded4"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
- }
-
- Rectangle
- {
- color:"#d3ffda"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
- }
-
- Rectangle
- {
- color:"#caf3ff"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
- }
-
- Rectangle
- {
- color:"#ccc1ff"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
- }
-
- Rectangle
- {
- color:"#ffcdf4"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
- }
+ onColorPicked: selectedColor = color
}
ColumnLayout
{
id: contentLayout
anchors.fill: parent
TextField
{
id: link
Layout.fillWidth: true
Layout.margins: space.medium
height: rowHeight
verticalAlignment: Qt.AlignVCenter
placeholderText: qsTr("URL")
font.weight: Font.Bold
font.bold: true
font.pointSize: fontSizes.large
color: fgColor
Layout.alignment: Qt.AlignCenter
background: Rectangle
{
color: "transparent"
}
onAccepted: linker.extract(link.text)
}
TextField
{
id: title
visible: previewReady
Layout.fillWidth: true
Layout.margins: space.medium
height: 24
placeholderText: qsTr("Title")
font.weight: Font.Bold
font.bold: true
font.pointSize: fontSizes.large
color: fgColor
background: Rectangle
{
color: "transparent"
}
}
Item
{
Layout.fillWidth: true
Layout.fillHeight: true
visible: previewReady
ListView
{
id: previewList
anchors.fill: parent
anchors.centerIn: parent
clip: true
snapMode: ListView.SnapOneItem
orientation: ListView.Horizontal
interactive: count > 1
highlightFollowsCurrentItem: true
model: ListModel{}
onMovementEnded:
{
var index = indexAt(contentX, contentY)
currentIndex = index
}
delegate: ItemDelegate
{
height: previewList.height
width: previewList.width
background: Rectangle
{
color: "transparent"
}
Image
{
id: img
source: model.url
fillMode: Image.PreserveAspectFit
asynchronous: true
width: parent.width
height: parent.height
sourceSize.height: height
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
}
}
}
}
Maui.TagsBar
{
id: tagBar
visible: previewReady
Layout.fillWidth: true
allowEditMode: true
onTagsEdited:
{
for(var i in tags)
append({tag : tags[i]})
}
}
}
footBar.rightContent: [
Button
{
id: save
text: qsTr("Save")
onClicked:
{
var data = ({
link : link.text,
title: title.text,
preview: previewList.model.get(previewList.currentIndex).url,
color: selectedColor,
tags: tagBar.getTags()
})
linkSaved(data)
clear()
}
},
Button
{
id: discard
text: qsTr("Discard")
onClicked: clear()
}
]
}
function clear()
{
title.clear()
link.clear()
previewList.model.clear()
previewReady = false
close()
}
function fill(note)
{
title.text = note.title[0]
populatePreviews(note.image)
open()
}
function populatePreviews(imgs)
{
for(var i in imgs)
previewList.model.append({url : imgs[i]})
}
}
diff --git a/src/widgets/NewNoteDialog.qml b/src/widgets/NewNoteDialog.qml
index 012e548..c46ec2d 100644
--- a/src/widgets/NewNoteDialog.qml
+++ b/src/widgets/NewNoteDialog.qml
@@ -1,323 +1,265 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.0
import org.kde.maui 1.0 as Maui
import org.buho.editor 1.0
Popup
{
parent: ApplicationWindow.overlay
height: parent.height * (isMobile ? 0.8 : 0.7)
width: parent.width * (isMobile ? 0.9 : 0.7)
property string selectedColor : "#ffffe6"
property string fgColor: Qt.darker(selectedColor, 2.5)
property bool showEditActions : false
signal noteSaved(var note)
x: (parent.width / 2) - (width / 2)
y: (parent.height /2 ) - (height / 2)
modal: true
padding: isAndroid ? 1 : "undefined"
Maui.Page
{
id: content
anchors.fill: parent
margins: 0
onExit: clear()
+
+
Rectangle
{
id: bg
color: selectedColor
z: -1
anchors.fill: parent
}
headBar.leftContent: [
Maui.ToolButton
{
iconName: "format-text-bold"
focusPolicy: Qt.TabFocus
iconColor: checked ? highlightColor : textColor
checkable: true
checked: document.bold
onClicked: document.bold = !document.bold
},
Maui.ToolButton
{
iconName: "format-text-italic-symbolic"
iconColor: checked ? highlightColor : textColor
focusPolicy: Qt.TabFocus
checkable: true
checked: document.italic
onClicked: document.italic = !document.italic
},
Maui.ToolButton
{
iconName: "format-text-underline-symbolic"
},
Maui.ToolButton
{
iconName: "format-text-uppercase"
},
Maui.ToolButton
{
iconName: "image"
}
]
headBar.rightContent: Row
{
spacing: space.medium
- Rectangle
- {
- color:"#ffded4"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
- }
-
- Rectangle
- {
- color:"#d3ffda"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
- }
-
- Rectangle
+ ColorsBar
{
- color:"#caf3ff"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
- }
-
- Rectangle
- {
- color:"#ccc1ff"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
- }
-
- Rectangle
- {
- color:"#ffcdf4"
- anchors.verticalCenter: parent.verticalCenter
- height: iconSizes.medium
- width: height
- radius: Math.max(height, width)
- border.color: borderColor
-
- MouseArea
- {
- anchors.fill: parent
- onClicked: selectedColor = parent.color
- }
+ onColorPicked: selectedColor = color
}
Maui.ToolButton
-
{
- iconName: "overflow-menu"
+ id: pinButton
+ iconName: "window-pin"
+ checkable: true
+ iconColor: checked ? highlightColor : textColor
+// onClicked: checked = !checked
}
}
ColumnLayout
{
anchors.fill: parent
TextField
{
id: title
Layout.fillWidth: true
Layout.margins: space.medium
height: 24
placeholderText: qsTr("Title")
font.weight: Font.Bold
font.bold: true
font.pointSize: fontSizes.large
color: fgColor
background: Rectangle
{
color: "transparent"
}
}
DocumentHandler
{
id: document
document: body.textDocument
cursorPosition: body.cursorPosition
selectionStart: body.selectionStart
selectionEnd: body.selectionEnd
// textColor: TODO
// onLoaded: {
// body.text = text
// }
onError:
{
body.text = message
body.visible = true
}
}
ScrollView
{
Layout.fillHeight: true
Layout.fillWidth: true
Layout.margins: space.medium
TextArea
{
id: body
width: parent.width
height: parent.height
placeholderText: qsTr("Body")
selectByKeyboard :!isMobile
selectByMouse : !isMobile
textFormat : TextEdit.AutoText
color: fgColor
font.pointSize: fontSizes.large
wrapMode: TextEdit.WrapAnywhere
background: Rectangle
{
color: "transparent"
}
}
}
Maui.TagsBar
{
id: tagBar
Layout.fillWidth: true
allowEditMode: true
onTagsEdited:
{
for(var i in tags)
append({tag : tags[i]})
}
}
}
footBar.leftContent: [
Maui.ToolButton
{
+ id: favButton
iconName: "love"
+ checkable: true
+ iconColor: checked ? "#ff007f" : textColor
},
Maui.ToolButton
{
iconName: "document-share"
onClicked: isAndroid ? Maui.Android.shareText(body.text) :
shareDialog.show(body.text)
},
Maui.ToolButton
{
iconName: "document-export"
},
Maui.ToolButton
{
iconName: "entry-delete"
}
]
footBar.rightContent: [
Button
{
id: save
text: qsTr("Save")
onClicked:
{
if(body.text.length > 0)
- noteSaved({
- title: title.text,
- body: body.text,
- color: selectedColor,
- tags: tagBar.getTags()
- })
+ packNote()
clear()
}
},
Button
{
id: discard
text: qsTr("Discard")
onClicked: clear()
}
]
}
onOpened: body.forceActiveFocus()
function clear()
{
title.clear()
body.clear()
close()
}
function fill(note)
{
- document.load("qrc:/texteditor.html")
title.text = note.title
body.text = note.body
selectedColor = note.color
+ pinButton.checked = note.pin == 1
+ favButton.checked = note.fav == 1
tagBar.populate(note.tags)
open()
}
+
+ function packNote()
+ {
+ noteSaved({
+ id: notesView.currentNote.id,
+ title: title.text.trim(),
+ body: body.text,
+ color: selectedColor,
+ tag: tagBar.getTags(),
+ pin: pinButton.checked,
+ fav: favButton.checked
+ })
+ }
}