diff --git a/src/views/links/Previewer.qml b/src/views/links/Previewer.qml index 9c82052..0e4cf46 100644 --- a/src/views/links/Previewer.qml +++ b/src/views/links/Previewer.qml @@ -1,163 +1,164 @@ import QtQuick 2.0 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.0 import org.kde.mauikit 1.0 as Maui import "../../widgets" Maui.Dialog { parent: parent heightHint: 0.97 widthHint: 0.97 maxWidth: 800*unit maxHeight: maxWidth page.margins: 0 property color selectedColor : "transparent" property alias webView: webViewer.item signal linkSaved(var link) headBar.leftContent: [ Maui.ToolButton { id: pinButton iconName: "edit-pin" checkable: true iconColor: checked ? highlightColor : textColor // onClicked: checked = !checked }, Maui.ToolButton { iconName: "document-save" }, Maui.ToolButton { iconName: "document-launch" onClicked: Maui.FM.openUrl(webView.url) } ] headBar.rightContent: ColorsBar { id: colorBar onColorPicked: selectedColor = color } footBar.leftContent: [ Maui.ToolButton { id: favButton iconName: "love" checkable: true iconColor: checked ? "#ff007f" : textColor }, Maui.ToolButton { iconName: "document-share" onClicked: isAndroid ? Maui.Android.shareLink(webView.url) : shareDialog.show(webView.url) }, Maui.ToolButton { iconName: "document-export" }, Maui.ToolButton { iconName: "entry-delete" } ] onAccepted: { packLink() close() } onRejected: close() acceptText: qsTr("Save") rejectText: qsTr("Discard") colorScheme.backgroundColor: selectedColor ColumnLayout { anchors.fill: parent // Item // { // Layout.fillWidth: true // height: rowHeightAlt // Label // { // clip: true // text: webView.title // width: parent.width // height: parent.height // horizontalAlignment: Qt.AlignHCenter // verticalAlignment: Qt.AlignVCenter // font.bold: true // font.pointSize: fontSizes.big // font.weight: Font.Bold // elide: Label.ElideRight // } // } Loader { id: webViewer Layout.fillWidth: true Layout.fillHeight: true Layout.margins: 0 source: isAndroid ? "qrc:/src/views/links/WebViewAndroid.qml" : "qrc:/src/views/links/WebViewLinux.qml" onVisibleChanged: { if(!visible) webView.url = "about:blank" } } Maui.TagsBar { id: tagBar Layout.fillWidth: true allowEditMode: true list.abstract: true list.key: "links" onTagsEdited: list.updateToAbstract(tags) + onTagRemovedClicked: list.removeFromAbstract(index) } } function show(link) { console.log("STATE:" , link.fav) webView.url = link.link tagBar.list.lot = link.link pinButton.checked = link.pin == 1 favButton.checked = link.fav == 1 selectedColor = link.color open() } function packLink() { console.log(favButton.checked) linkSaved({ title: webView.title, link: webView.url, color: selectedColor, tag: tagBar.getTags(), pin: pinButton.checked ? 1 : 0, fav: favButton.checked ? 1 : 0, updated: new Date() }) } } diff --git a/src/widgets/NewLinkDialog.qml b/src/widgets/NewLinkDialog.qml index 230d35a..6f36fd9 100644 --- a/src/widgets/NewLinkDialog.qml +++ b/src/widgets/NewLinkDialog.qml @@ -1,233 +1,234 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.0 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.2 as Kirigami Maui.Dialog { parent: parent heightHint: 0.95 widthHint: 0.95 maxHeight: previewReady ? unit * 800 : contentLayout.implicitHeight maxWidth: unit *700 signal linkSaved(var link) 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) } } headBar.visible: previewReady footBar.visible: previewReady headBar.leftContent: Maui.ToolButton { id: pinButton iconName: "window-pin" checkable: true iconColor: checked ? highlightColor : textColor // onClicked: checked = !checked } headBar.rightContent: ColorsBar { onColorPicked: selectedColor = color } footBar.leftContent: [ Maui.ToolButton { id: favButton iconName: "love" checkable: true iconColor: checked ? "#ff007f" : textColor }, Maui.ToolButton { iconName: "document-share" onClicked: isAndroid ? Maui.Android.shareText(link.text) : shareDialog.show(link.text) }, Maui.ToolButton { iconName: "document-export" } ] acceptText: qsTr("Save") rejectText: qsTr("Discard") onAccepted: { packLink() clear() } onRejected: clear() 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 visible: count > 0 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 list.abstract: true list.key: "links" onTagsEdited: list.updateToAbstract(tags) + onTagRemovedClicked: list.removeFromAbstract(index) } } function clear() { title.clear() link.clear() previewList.model.clear() tagBar.clear() previewReady = false close() } function fill(link) { title.text = link.title populatePreviews(link.image) tagBar.list.lot= link.url open() } function populatePreviews(imgs) { for(var i in imgs) { console.log("PREVIEW:", imgs[i]) previewList.model.append({url : imgs[i]}) } } function packLink() { var data = ({ link : link.text, title: title.text, preview: previewList.count > 0 ? previewList.model.get(previewList.currentIndex).url : "", color: selectedColor, tag: tagBar.getTags(), pin: pinButton.checked, fav: favButton.checked }) linkSaved(data) } } diff --git a/src/widgets/NewNoteDialog.qml b/src/widgets/NewNoteDialog.qml index 22a6268..0a85b23 100644 --- a/src/widgets/NewNoteDialog.qml +++ b/src/widgets/NewNoteDialog.qml @@ -1,217 +1,218 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.0 import org.kde.mauikit 1.0 as Maui Maui.Dialog { parent: parent heightHint: 0.95 widthHint: 0.95 maxWidth: 700*unit maxHeight: maxWidth property string selectedColor : "#ffffe6" property string fgColor: Qt.darker(selectedColor, 2.5) property bool showEditActions : false rejectButton.visible: false signal noteSaved(var note) page.margins: 0 colorScheme.backgroundColor: selectedColor headBar.leftContent: [ Maui.ToolButton { iconName: "edit-undo" enabled: editor.body.canUndo onClicked: editor.body.undo() opacity: enabled ? 1 : 0.5 }, Maui.ToolButton { iconName: "edit-redo" enabled: editor.body.canRedo onClicked: editor.body.redo() opacity: enabled ? 1 : 0.5 }, Maui.ToolButton { iconName: "format-text-bold" focusPolicy: Qt.TabFocus iconColor: checked ? highlightColor : textColor checkable: true checked: editor.document.bold onClicked: editor.document.bold = !editor.document.bold }, Maui.ToolButton { iconName: "format-text-italic" iconColor: checked ? highlightColor : textColor focusPolicy: Qt.TabFocus checkable: true checked: editor.document.italic onClicked: editor.document.italic = !editor.document.italic }, Maui.ToolButton { iconName: "format-text-underline" iconColor: checked ? highlightColor : textColor focusPolicy: Qt.TabFocus checkable: true checked: editor.document.underline onClicked: editor.document.underline = !editor.document.underline }, Maui.ToolButton { iconName: "format-text-uppercase" iconColor: checked ? highlightColor : textColor focusPolicy: Qt.TabFocus checkable: true checked: editor.document.uppercase onClicked: editor.document.uppercase = !editor.document.uppercase }, Maui.ToolButton { iconName: "image" } ] headBar.rightContent: ColorsBar { onColorPicked: selectedColor = color } footBar.leftContent: [ Maui.ToolButton { id: pinButton iconName: "edit-pin" checkable: true iconColor: checked ? highlightColor : textColor // onClicked: checked = !checked }, Maui.ToolButton { id: favButton iconName: "love" checkable: true iconColor: checked ? "#ff007f" : textColor }, Maui.ToolButton { iconName: "document-share" onClicked: isAndroid ? Maui.Android.shareText(editor.body.text) : shareDialog.show(editor.body.text) }, Maui.ToolButton { iconName: "document-export" }, Maui.ToolButton { iconName: "entry-delete" } ] acceptText: qsTr("Save") rejectText: qsTr("Discard") onAccepted: { if(editor.body.text.length > 0) packNote() clear() } onRejected: clear() 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" } } Maui.Editor { id: editor Layout.fillHeight: true Layout.fillWidth: true colorScheme.backgroundColor: selectedColor headBar.visible: false } Maui.TagsBar { id: tagBar Layout.fillWidth: true allowEditMode: true list.abstract: true list.key: "notes" onTagsEdited: list.updateToAbstract(tags) + onTagRemovedClicked: list.removeFromAbstract(index) } } onOpened: if(isMobile) editor.body.forceActiveFocus() function clear() { title.clear() editor.body.clear() close() } function fill(note) { title.text = note.title editor.body.text = note.body selectedColor = note.color pinButton.checked = note.pin == 1 favButton.checked = note.fav == 1 tagBar.list.lot= note.id open() } function packNote() { noteSaved({ id: notesView.currentNote.id, title: title.text.trim(), body: editor.body.text, color: selectedColor, tag: tagBar.getTags(), pin: pinButton.checked ? 1 : 0, fav: favButton.checked ? 1 : 0, updated: new Date() }) } }