From e6b27769fab9968b311b16e4bb1911a0c94fa076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renaud=20Casenave-P=C3=A9r=C3=A9?= Date: Thu, 9 Oct 2025 09:25:45 +0200 Subject: [PATCH] WIP Backup --- lisp/bundle-info.sexp | 2 +- lisp/local-projects/cockpit/cockpit.asd | 5 +- lisp/local-projects/cockpit/cockpit.lisp | 67 +++++--- .../cockpit/models/filelist.lisp | 54 +++++++ lisp/local-projects/cockpit/options/all.lisp | 4 + .../cockpit/options/options.lisp | 8 + lisp/local-projects/sextant/config/all.lisp | 4 - lisp/local-projects/sextant/files/all.lisp | 6 + .../sextant/{config => files}/config.lisp | 21 +-- lisp/local-projects/sextant/files/files.lisp | 40 +++++ lisp/local-projects/sextant/files/paths.lisp | 11 ++ lisp/local-projects/sextant/sextant.asd | 4 +- lisp/local-projects/sextant/sextant.lisp | 9 ++ qml/components/qmldir | 3 + qml/harbour-sextant.qml | 3 +- qml/pages-/Files.qml | 152 ++++++++++++++++++ qml/{pages => pages-}/FirstPage.qml | 0 qml/{pages => pages-}/Org.qml | 0 qml/{pages => pages-}/SecondPage.qml | 0 qml/{pages => pages-}/SelectFileDialog.qml | 0 qml/{pages => pages-}/Settings.qml | 0 qml/pages-/qmldir | 1 + qml/pages/Editor.qml | 43 +++++ qml/pages/Files.qml | 67 ++------ qml/pages/qmldir | 2 + qml/test.qml | 10 ++ sextant-app.pro | 7 + src/harbour-sextant.cc | 9 +- welcome.org | 3 + 29 files changed, 434 insertions(+), 101 deletions(-) create mode 100644 lisp/local-projects/cockpit/models/filelist.lisp create mode 100644 lisp/local-projects/cockpit/options/all.lisp create mode 100644 lisp/local-projects/cockpit/options/options.lisp delete mode 100644 lisp/local-projects/sextant/config/all.lisp create mode 100644 lisp/local-projects/sextant/files/all.lisp rename lisp/local-projects/sextant/{config => files}/config.lisp (84%) create mode 100644 lisp/local-projects/sextant/files/files.lisp create mode 100644 lisp/local-projects/sextant/files/paths.lisp create mode 100644 qml/components/qmldir create mode 100644 qml/pages-/Files.qml rename qml/{pages => pages-}/FirstPage.qml (100%) rename qml/{pages => pages-}/Org.qml (100%) rename qml/{pages => pages-}/SecondPage.qml (100%) rename qml/{pages => pages-}/SelectFileDialog.qml (100%) rename qml/{pages => pages-}/Settings.qml (100%) create mode 100644 qml/pages-/qmldir create mode 100644 qml/pages/Editor.qml create mode 100644 qml/pages/qmldir create mode 100644 qml/test.qml create mode 100644 welcome.org diff --git a/lisp/bundle-info.sexp b/lisp/bundle-info.sexp index 54e123a..de5080c 100644 --- a/lisp/bundle-info.sexp +++ b/lisp/bundle-info.sexp @@ -1,4 +1,4 @@ -(:CREATION-TIME "2025-08-26T20:29:46Z" :REQUESTED-SYSTEMS ("alexandria" "uiop") +(:CREATION-TIME "2025-09-07T21:02:42Z" :REQUESTED-SYSTEMS ("alexandria" "uiop") :LISP-INFO (:MACHINE-INSTANCE "lpt-pf3r3138-ln" :MACHINE-TYPE "x86_64" :MACHINE-VERSION NIL :LISP-IMPLEMENTATION-TYPE "ECL" :LISP-IMPLEMENTATION-VERSION "24.5.10") diff --git a/lisp/local-projects/cockpit/cockpit.asd b/lisp/local-projects/cockpit/cockpit.asd index 4104c8f..4b65086 100644 --- a/lisp/local-projects/cockpit/cockpit.asd +++ b/lisp/local-projects/cockpit/cockpit.asd @@ -5,5 +5,8 @@ :around-compile (lambda (thunk) (proclaim '(optimize (debug 3) (safety 3) (speed 0))) (funcall thunk)) - :depends-on ("sextant") + :depends-on ("sextant" + "cockpit/options/all") :components ((:file "cockpit"))) + +(register-system-packages "cockpit/options/all" '(:options)) diff --git a/lisp/local-projects/cockpit/cockpit.lisp b/lisp/local-projects/cockpit/cockpit.lisp index 5e8533a..10b029a 100644 --- a/lisp/local-projects/cockpit/cockpit.lisp +++ b/lisp/local-projects/cockpit/cockpit.lisp @@ -1,40 +1,53 @@ (uiop:define-package :cockpit - (:use :cl :eql :sextant :config)) + (:use :cl :eql :qml-lisp :sextant :config :options) + (:export + #:show-welcome-screen-p + #:data-path)) (in-package :cockpit) (qrequire :quick) +(defconstant +cockpit-version+ 0) + (defun initialize () - (load-config-file "harbour-sextant" "config.lisp")) - -(defun finalize () - (save-config-file "harbour-sextant" "config.lisp")) - -(defun start () - (initialize) (ext:catch-signal ext:+SIGTERM+ :catch) (ext:set-signal-handler ext:+SIGTERM+ #'terminate) - (qconnect qml:*quick-view* "statusChanged(QQuickView::Status)" - (lambda (status) - (case status - (#.|QQuickView.Ready| (qml-reloaded))))) - (qconnect qml:*quick-view* "closing(QQuickCloseEvent*)" - (lambda (close) - (declare (ignore close)) - (finalize)))) + (load-config-file "harbour-sextant" "config.lisp") + (when (and (not (slynkp)) (get-slynk-at-startup-p)) + (start-slynk)) + ;; (when (< (get-last-seen-version) +cockpit-version+) + ;; (qjs |showWelcomeScreen| "filesPage" + ;; (qlet ((root-url "QUrl(QString)" qml:*root*)) + ;; (|path| root-url)) + ;; "welcome.org")) + ) + +(defun finalize () + (save-config-file "harbour-sextant" "config.lisp") + (when (slynkp) + (stop-slynk))) + +;; (defun start () +;; (qconnect qml:*quick-view* "statusChanged(QQuickView::Status)" +;; (lambda (status) +;; (case status +;; (#.|QQuickView.Ready| (qml-reloaded))))) +;; (qconnect qml:*quick-view* "closing(QQuickCloseEvent*)" +;; (lambda (close) +;; (declare (ignore close)) +;; (finalize)))) (defun terminate () (finalize) (qrun #'qquit)) -(defun reload-qml (&optional (url "http://localhost:8000/")) +(defun reload-qml (&optional url) "Reload QML file from an url, directly on the device." (qrun* - (let ((src (|toString| (|source| qml:*quick-view*)))) - (if (x:starts-with qml:*root* src) - (|setSource| qml:*quick-view* (qnew "QUrl(QString)" (x:string-substitute url qml:*root* src))) - (qml:reload)) - (|toString| (|source| qml:*quick-view*))))) + (if url + (|setSource| qml:*quick-view* (qnew "QUrl(QString)" url)) + (qml:reload)) + (|toString| (|source| qml:*quick-view*)))) (defun set-qml (url) (|setSource| qml:*quick-view* (qnew "QUrl(QString)" url)) @@ -42,4 +55,12 @@ (defun qml-reloaded ()) -(qlater #'start) +(defun show-welcome-screen-p () (< (get-last-seen-version) +cockpit-version+)) + +(defun data-path () + (qlet ((root-url "QUrl(QString)" qml:*root*)) + (|path| root-url))) + +(initialize) + +;; (qlater #'start) diff --git a/lisp/local-projects/cockpit/models/filelist.lisp b/lisp/local-projects/cockpit/models/filelist.lisp new file mode 100644 index 0000000..b28f7f5 --- /dev/null +++ b/lisp/local-projects/cockpit/models/filelist.lisp @@ -0,0 +1,54 @@ +(uiop:define-package :cockpit/models/files-list + (:use :cl :eql)) +(in-package :cockpit/models/files-list) + +(define-roles #.|Qt.UserRole| + +filename-role+ + +directory-role+ + +section-role+) + +(defvar *recent-files-list* nil) +(defvar *files-list* nil) +(defvar *files-list-model nil) +(defvar *empty-model-index* (qnew "QModelIndex")) + +(defun refresh-files-list (agenda-files) + (setf *recent-files-list* (limit-list-size *recent-files-list* options:recent-files-size)) + (setf *files-list* + (cons (cons "recentf" *recent-files-list*) + (loop for dir-or-file in agenda-files + append (if (uiop:directory-exists-p dir-or-file) + (collect-org-files dir-or-file) + (list (directory-namestring dir-or-file) + dir-or-file)))))) + +(defun refresh-files-list-model (agenda-files) + (unless (null *files-list-model*) + (|beginResetModel| *files-list-model*) + (refresh-files-list agenda-files) + (|endResetModel| *files-list-model*))) + +(defun construct-files-list-model () + (let ((model (qnew "QAbstractListModel"))) + (qoverride model "rowCount(QModelIndex)" + (lambda (index) + (declare (ignore index)) + (let ((len 0)) + (mapc (lambda (list) + (incf len (legnth (cdr list)))) + *files-list*)))) + (qoverride model "data(QModelIndex,int)" + (lambda (index role) + (let* ((row (|row| index)) + section + (item (when (> row -1) + (loop for list = *files-list* then (cdr list) + while list + do (progn + (setf section (caar list)) + (if (>= row (length (cdar list)))))))))))))) + +(defun make-filelist-model (agenda-files &optional force) + (when (or (null *files-list-model*) force) + (construct-files-list-model)) + (refresh-files-list-model agenda-files)) diff --git a/lisp/local-projects/cockpit/options/all.lisp b/lisp/local-projects/cockpit/options/all.lisp new file mode 100644 index 0000000..889d8ec --- /dev/null +++ b/lisp/local-projects/cockpit/options/all.lisp @@ -0,0 +1,4 @@ +(uiop:define-package :cockpit/options/all + (:nicknames :options) + (:use-reexport + :cockpit/options/options)) diff --git a/lisp/local-projects/cockpit/options/options.lisp b/lisp/local-projects/cockpit/options/options.lisp new file mode 100644 index 0000000..7ed5a4b --- /dev/null +++ b/lisp/local-projects/cockpit/options/options.lisp @@ -0,0 +1,8 @@ +(uiop:define-package :cockpit/options/options + (:use :cl :config)) +(in-package :cockpit/options/options) + +(set-config-package :cockpit/options/options) + +(defconfig last-seen-version -1) +(defconfig slynk-at-startup-p nil) diff --git a/lisp/local-projects/sextant/config/all.lisp b/lisp/local-projects/sextant/config/all.lisp deleted file mode 100644 index 5bb1ddb..0000000 --- a/lisp/local-projects/sextant/config/all.lisp +++ /dev/null @@ -1,4 +0,0 @@ -(uiop:define-package :sextant/config/all - (:nicknames :config) - (:use-reexport - :sextant/config/config)) diff --git a/lisp/local-projects/sextant/files/all.lisp b/lisp/local-projects/sextant/files/all.lisp new file mode 100644 index 0000000..1cfa496 --- /dev/null +++ b/lisp/local-projects/sextant/files/all.lisp @@ -0,0 +1,6 @@ +(uiop:define-package :sextant/files/all + (:nicknames :files) + (:use-reexport + :sextant/files/paths + :sextant/files/config + :sextant/files/files)) diff --git a/lisp/local-projects/sextant/config/config.lisp b/lisp/local-projects/sextant/files/config.lisp similarity index 84% rename from lisp/local-projects/sextant/config/config.lisp rename to lisp/local-projects/sextant/files/config.lisp index 9c60205..ddfea16 100644 --- a/lisp/local-projects/sextant/config/config.lisp +++ b/lisp/local-projects/sextant/files/config.lisp @@ -1,18 +1,14 @@ -(uiop:define-package :sextant/config/config - (:use :cl) +(uiop:define-package :sextant/files/config + (:use :cl :sextant/files/paths) (:export #:set-config-package #:defconfig #:load-config-file #:save-config-file)) -(in-package :sextant/config/config) +(in-package :sextant/files/config) (defvar config-package nil) (defvar config-probe ";;; Auto generated from here, do not edit") -(defun config-filepath (appname filename) - (merge-pathnames (concatenate 'string appname "/" filename) - (uiop:xdg-config-pathname))) - (defun set-config-package (package) (setf config-package package)) @@ -45,15 +41,15 @@ ,(when doc `(setf (documentation ,symbol 'variable) ,doc)))) -(defun load-config-file (appname filename) +(defun load-config-file (filename) "Load `filename' from standard config path." - (let ((config-pathname (config-filepath appname filename))) + (let ((config-pathname (config-filepath filename))) (when (probe-file config-pathname) (load config-pathname)))) -(defun save-config-file (appname filename) +(defun save-config-file (filename) "Save config values to `filename'." - (let* ((config-pathname (config-filepath appname filename)) + (let* ((config-pathname (config-filepath filename)) (config-string (with-open-file (stream config-pathname :if-does-not-exist nil) (when stream (let ((str (make-string (file-length stream)))) @@ -65,8 +61,7 @@ (let ((pos (search config-probe config-string))) (princ (subseq config-string 0 pos) stream)) (progn - (princ ";;; Configuration file for " stream) - (print appname stream) + (princ (concatenate 'string ";;; Configuration file for Sextant") stream) (terpri stream) (princ ";;; You are free to edit this section" stream) (terpri stream) diff --git a/lisp/local-projects/sextant/files/files.lisp b/lisp/local-projects/sextant/files/files.lisp new file mode 100644 index 0000000..2bda648 --- /dev/null +++ b/lisp/local-projects/sextant/files/files.lisp @@ -0,0 +1,40 @@ +(uiop:define-package :sextant/files/files + (:use :cl :sextant/files/paths)) + +(defun load-recentf (filename maxsize) + (let ((recentf-pathname (cache-filepath filename))) + (when (probe-file recentf-pathname) + (subseq (uiop:safe-read-file-form recentf-pathname :package :sextant/files/recentf) 0 maxsize)))) + +(defun save-recentf (filename recentf-lst) + (let ((recentf-pathname (cache-filepath filename))) + (with-open-file (stream (ensure-directories-exist recentf-pathname) + :direction :output :if-exists :supersede) + (prin1 recentf-lst stream)))) + +(defun push-to-recentf (recentf-lst pathname agenda-files maxsize) + (when (notany (lambda (files-lst) + (uiop:subpathp pathname (truename (parse-namestring (car files-lst))))) + agenda-files) + (subseq (remove-duplicates (push pathname recentf-lst) + :from-end t + :test #'uiop:pathname-equal) + 0 maxsize))) + +(defun collect-files (directory &optional (filter "*.*")) + (mapcar (lambda (dir) + (cons dir + (sort (remove-if #'uiop:hidden-pathname-p (uiop:directory-files dir filter)) + #'string< :key #'pathname-name))) + (flatten (labels ((collect-dirs (dir) + (let ((subdirs (remove-if + (lambda (d) + (uiop:hidden-pathname-p + (merge-pathnames + (car (last (pathname-directory d))) + (uiop:pathname-parent-directory-pathname d)))) + (uiop:subdirectories dir)))) + (cons (concatenate 'string directory + (enough-namestring dir (truename directory))) + (mapcar #'collect-dirs subdirs))))) + (collect-dirs (truename directory)))))) diff --git a/lisp/local-projects/sextant/files/paths.lisp b/lisp/local-projects/sextant/files/paths.lisp new file mode 100644 index 0000000..d605540 --- /dev/null +++ b/lisp/local-projects/sextant/files/paths.lisp @@ -0,0 +1,11 @@ +(uiop:define-package :sextant/files/paths + (:use :cl) + (:export #:config-filepath + #:cache-filepath)) +(in-package :sextant/files/paths) + +(defun config-home () (merge-pathnames "sextant/" (uiop:xdg-config-home))) +(defun config-filepath (filename) (merge-pathnames filename (config-home))) + +(defun cache-home () (merge-pathnames "sextant/" (uiop:xdg-cache-home))) +(defun cache-filepath (filename) (merge-pathnames filename (cache-home))) diff --git a/lisp/local-projects/sextant/sextant.asd b/lisp/local-projects/sextant/sextant.asd index 00a1cc7..f75137d 100644 --- a/lisp/local-projects/sextant/sextant.asd +++ b/lisp/local-projects/sextant/sextant.asd @@ -7,8 +7,8 @@ (funcall thunk)) :depends-on #.(append (uiop:read-file-form (merge-pathnames #p"../../../dependencies.sexp" (or *load-pathname* *compile-file-pathname*))) '("sextant/editor/all") - '("sextant/config/all")) + '("sextant/files/all")) :components ((:file "sextant"))) (register-system-packages "sextant/editor/all" '(:editor)) -(register-system-packages "sextant/config/all" '(:config)) +(register-system-packages "sextant/files/all" '(:config)) diff --git a/lisp/local-projects/sextant/sextant.lisp b/lisp/local-projects/sextant/sextant.lisp index 21cb17b..b4bf7fb 100644 --- a/lisp/local-projects/sextant/sextant.lisp +++ b/lisp/local-projects/sextant/sextant.lisp @@ -23,3 +23,12 @@ (setf slynkp nil))) (defun slynkp () slynkp)) + +(defparameter *current-file-pathname* nil) +(defparameter *current-file-gb* nil) + +(defun open-file (filepath) + (let* ((pathname (parse-namestring filepath)) + (gb (make-gap-buffer (read-file-into-string pathname)))) + (setf *current-file-pathname* pathname + *current-file-gb* gb))) diff --git a/qml/components/qmldir b/qml/components/qmldir new file mode 100644 index 0000000..78aa45c --- /dev/null +++ b/qml/components/qmldir @@ -0,0 +1,3 @@ +OrgDelegate 1.0 OrgDelegate.qml +OrgLine 1.0 OrgLine.qml +OrgEdit 1.0 OrgEdit.qml \ No newline at end of file diff --git a/qml/harbour-sextant.qml b/qml/harbour-sextant.qml index e83426a..631ffdc 100644 --- a/qml/harbour-sextant.qml +++ b/qml/harbour-sextant.qml @@ -1,10 +1,9 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 -import "pages/" ApplicationWindow { - initialPage: Component { Files { } } + initialPage: Qt.resolvedUrl("pages/Files.qml") cover: Qt.resolvedUrl("cover/CoverPage.qml") allowedOrientations: defaultAllowedOrientations } diff --git a/qml/pages-/Files.qml b/qml/pages-/Files.qml new file mode 100644 index 0000000..0927eaa --- /dev/null +++ b/qml/pages-/Files.qml @@ -0,0 +1,152 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import Sailfish.Pickers 1.0 +import EQL5 1.0 + +Page { + id: files + allowedOrientations: Orientation.All + + SilicaListView { + id: listView + anchors.fill: parent + + header: PageHeader { + title: qsTr("Files") + } + + model: agendaFilesModel + + section { + property: 'section' + + delegate: SectionHeader { + text: section == "recentf" ? qsTr("Recent files") : section + height: Theme.itemSizeExtraSmall + } + } + + delegate: ListItem { + id: fileItem + + anchors { + left: parent.left + right: parent.right + } + contentHeight: Theme.itemSizeSmall + + Label { + text: section == "recentf" ? directory + filename : filename + elide: Text.ElideMiddle + width: parent.width - Theme.horizontalPageMargin * 2 + font.pixelSize: Theme.fontSizeMedium + anchors { + top: parent.top + left: parent.left + leftMargin: Theme.horizontalPageMargin + rightMargin: Theme.horizontalPageMargin + centerIn: parent + } + } + + onClicked: { + var filepath = directory + filename + Lisp.call("sextant:open-file", filepath) + pageStack.push(Qt.resolvedUrl("Org.qml"), {filepath: filepath, filename: filename}) + } + + RemorseItem { id: remorse } + + menu: ContextMenu { + MenuItem { + visible: section == "recentf" + text: qsTr("Remove from list") + onClicked: { + remorse.execute(fileItem, "", function () { + var filepath = directory + filename + Lisp.call("models:remove-from-files-list", filepath) + }) + } + } + + MenuItem { + text: qsTr("Delete file") + onClicked: { + remorse.execute(fileItem, "", function () { + var filepath = directory + filename + Lisp.call("sextant:delete-file*", filepath) + }) + } + } + } + } + + ViewPlaceholder { + id: placeholder + enabled: listView.count == 0 + text: qsTr("Pull down to open a file") + } + + PullDownMenu { + MenuItem { + text: qsTr("Settings") + onClicked: pageStack.push(Qt.resolvedUrl("Settings.qml")) + } + + MenuItem { + text: qsTr("Open file") + onClicked: pageStack.push(filePickerPage) + } + + MenuItem { + text: qsTr("New file") + onClicked: { + var dialog = pageStack.push(Qt.resolvedUrl("SelectFileDialog.qml"), + {text: qsTr("Create new file"), + filename: ".org", pos0: true, + acceptDestination: Qt.resolvedUrl("Org.qml"), + acceptDestinationAction: PageStackAction.Replace}) + dialog.accepted.connect(function() { + var filepath = dialog.directory + dialog.filename + Lisp.call("sextant:open-file", filepath) + dialog.acceptDestinationInstance.filepath = filepath + dialog.acceptDestinationInstance.filename = dialog.filename + }) + } + } + } + + PushUpMenu { + MenuItem { + text: qsTr("Scroll to top") + onClicked: scrollToTop() + } + } + + Component { + id: filePickerPage + FilePickerPage { + popOnSelection: false + onSelectedContentPropertiesChanged: { + if (selectedContentProperties.filePath) { + Lisp.call("sextant:open-file", selectedContentProperties.filePath) + pageStack.replaceAbove(files, Qt.resolvedUrl("Org.qml"), + {filepath: selectedContentProperties.filePath, + filename: selectedContentProperties.fileName}) + } + } + } + } + } + + Component.onCompleted { + if (Lisp.call("cockpit:show-welcome-screen-p")) + console.log("show welcome screen") + } + + onStatusChanged: { + if (status == PageStatus.Activating) { + Lisp.call("sextant:refresh-agenda-files") + } + } +} diff --git a/qml/pages/FirstPage.qml b/qml/pages-/FirstPage.qml similarity index 100% rename from qml/pages/FirstPage.qml rename to qml/pages-/FirstPage.qml diff --git a/qml/pages/Org.qml b/qml/pages-/Org.qml similarity index 100% rename from qml/pages/Org.qml rename to qml/pages-/Org.qml diff --git a/qml/pages/SecondPage.qml b/qml/pages-/SecondPage.qml similarity index 100% rename from qml/pages/SecondPage.qml rename to qml/pages-/SecondPage.qml diff --git a/qml/pages/SelectFileDialog.qml b/qml/pages-/SelectFileDialog.qml similarity index 100% rename from qml/pages/SelectFileDialog.qml rename to qml/pages-/SelectFileDialog.qml diff --git a/qml/pages/Settings.qml b/qml/pages-/Settings.qml similarity index 100% rename from qml/pages/Settings.qml rename to qml/pages-/Settings.qml diff --git a/qml/pages-/qmldir b/qml/pages-/qmldir new file mode 100644 index 0000000..b55ff5f --- /dev/null +++ b/qml/pages-/qmldir @@ -0,0 +1 @@ +Org 1.0 Org.qml \ No newline at end of file diff --git a/qml/pages/Editor.qml b/qml/pages/Editor.qml new file mode 100644 index 0000000..08b2adf --- /dev/null +++ b/qml/pages/Editor.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import EQL5 1.0 + +Page { + id: editor + objectName: "editorPage" + allowedOrientations: Orientation.All + + property string filepath + property string filename + property bool readonly: false + + SilicaListView { + id: listView + anchors { + top: parent.top + left: parent.left + right: parent.right + bottom: toolbar.top + } + + clip: true + + header: PageHeader { + title: filename + } + } + + DockedPanel { + id: toolbar + + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + + height: Theme.itemSizeMedium + dock: Dock.Bottom + open: true + } +} diff --git a/qml/pages/Files.qml b/qml/pages/Files.qml index 96b47b4..bcef418 100644 --- a/qml/pages/Files.qml +++ b/qml/pages/Files.qml @@ -1,10 +1,10 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 -import Sailfish.Pickers 1.0 import EQL5 1.0 Page { id: files + objectName: "filesPage" allowedOrientations: Orientation.All SilicaListView { @@ -15,7 +15,7 @@ Page { title: qsTr("Files") } - model: agendaFilesModel + model: fileListModel section { property: 'section' @@ -49,13 +49,7 @@ Page { } } - onClicked: { - var filepath = directory + filename - Lisp.call("sextant:open-file", filepath) - pageStack.push(Qt.resolvedUrl("Org.qml"), {filepath: filepath, filename: filename}) - } - - RemorseItem { id: remorse } + onClicked: openEditor(directory, filename) menu: ContextMenu { MenuItem { @@ -63,8 +57,7 @@ Page { text: qsTr("Remove from list") onClicked: { remorse.execute(fileItem, "", function () { - var filepath = directory + filename - Lisp.call("models:remove-from-files-list", filepath) + console.log("Remove file from list: " + filename) }) } } @@ -73,8 +66,7 @@ Page { text: qsTr("Delete file") onClicked: { remorse.execute(fileItem, "", function () { - var filepath = directory + filename - Lisp.call("sextant:delete-file*", filepath) + console.log("Delete file: " + filename) }) } } @@ -90,58 +82,25 @@ Page { PullDownMenu { MenuItem { text: qsTr("Settings") - onClicked: pageStack.push(Qt.resolvedUrl("Settings.qml")) } MenuItem { text: qsTr("Open file") - onClicked: pageStack.push(filePickerPage) } MenuItem { text: qsTr("New file") - onClicked: { - var dialog = pageStack.push(Qt.resolvedUrl("SelectFileDialog.qml"), - {text: qsTr("Create new file"), - filename: ".org", pos0: true, - acceptDestination: Qt.resolvedUrl("Org.qml"), - acceptDestinationAction: PageStackAction.Replace}) - dialog.accepted.connect(function() { - var filepath = dialog.directory + dialog.filename - Lisp.call("sextant:open-file", filepath) - dialog.acceptDestinationInstance.filepath = filepath - dialog.acceptDestinationInstance.filename = dialog.filename - }) - } - } - } - - PushUpMenu { - MenuItem { - text: qsTr("Scroll to top") - onClicked: scrollToTop() - } - } - - Component { - id: filePickerPage - FilePickerPage { - popOnSelection: false - onSelectedContentPropertiesChanged: { - if (selectedContentProperties.filePath) { - Lisp.call("sextant:open-file", selectedContentProperties.filePath) - pageStack.replaceAbove(files, Qt.resolvedUrl("Org.qml"), - {filepath: selectedContentProperties.filePath, - filename: selectedContentProperties.fileName}) - } - } } } } - onStatusChanged: { - if (status == PageStatus.Activating) { - Lisp.call("sextant:refresh-agenda-files") - } + Component.onCompleted: { + if (Lisp.call("cockpit:show-welcome-screen-p")) + openFile(Lisp.call("cockpit:data-path"), "welcome.org") + } + + function openEditor(directory, filename) { + var filepath = directory + filename + pageStack.push(Qt.resolvedUrl("Editor.qml"), {filepath: filepath, filename: filename}) } } diff --git a/qml/pages/qmldir b/qml/pages/qmldir new file mode 100644 index 0000000..8be0bbd --- /dev/null +++ b/qml/pages/qmldir @@ -0,0 +1,2 @@ +Editor Editor.qml +Files Files.qml \ No newline at end of file diff --git a/qml/test.qml b/qml/test.qml new file mode 100644 index 0000000..68bbad9 --- /dev/null +++ b/qml/test.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "pages/" as Pages + +ApplicationWindow +{ + initialPage: Component { Pages.Org { filename: "org.org" } } + cover: Qt.resolvedUrl("cover/CoverPage.qml") + allowedOrientations: defaultAllowedOrientations +} diff --git a/sextant-app.pro b/sextant-app.pro index 10bf15f..f9b3547 100644 --- a/sextant-app.pro +++ b/sextant-app.pro @@ -14,10 +14,14 @@ CONFIG += debug SEXTANT_FILES = make.lisp \ dependencies.sexp \ lisp/system-index.txt \ + lisp/local-projects/sextant/config/all.lisp \ + lisp/local-projects/sextant/config/config.lisp \ lisp/local-projects/sextant/editor/all.lisp \ lisp/local-projects/sextant/editor/gap-buffer.lisp \ lisp/local-projects/sextant/sextant.lisp \ lisp/local-projects/sextant/sextant.asd \ + lisp/local-projects/cockpit/options/all.lisp \ + lisp/local-projects/cockpit/options/options.lisp \ lisp/local-projects/cockpit/cockpit.lisp \ lisp/local-projects/cockpit/cockpit.asd @@ -40,11 +44,14 @@ SOURCES += src/harbour-sextant.cc DISTFILES += qml/harbour-sextant.qml \ qml/cover/CoverPage.qml \ + qml/pages/Files.qml \ + qml/pages/Editor.qml \ rpm/harbour-sextant.changes.in \ rpm/harbour-sextant.changes.run.in \ rpm/harbour-sextant.spec \ # rpm/harbour-sextant.yaml \ # translations/*.ts \ + welcome.org harbour-sextant.desktop SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172 diff --git a/src/harbour-sextant.cc b/src/harbour-sextant.cc index 4ffcf6b..5b8a1a1 100644 --- a/src/harbour-sextant.cc +++ b/src/harbour-sextant.cc @@ -37,7 +37,14 @@ int main(int argc, char *argv[]) sextant::parser::init_parser_lib(); eql.exec (init_sextant); - eql_fun ("qml:ini-sailfish", Q_ARG (QUrl, SailfishApp::pathToMainQml()), + QUrl pathToMainQml = SailfishApp::pathToMainQml(); + + QStringList args(QCoreApplication::arguments()); + int index = args.indexOf("-qml"); + if (index != -1) + pathToMainQml = args.at(index + 1); + + eql_fun ("qml:ini-sailfish", Q_ARG (QUrl, pathToMainQml), Q_ARG (QUrl, SailfishApp::pathTo ("")), Q_ARG (QQuickView*, view.data ()), Q_ARG(bool, true)); } diff --git a/welcome.org b/welcome.org new file mode 100644 index 0000000..c3e41ef --- /dev/null +++ b/welcome.org @@ -0,0 +1,3 @@ +* Sextant +** Introduction +** Changelog