Skip to content

Commit

Permalink
[ubports-seabass] add ability to create new files (#53)
Browse files Browse the repository at this point in the history
* [ubports-seabass] add ability to create new files
* [ubports-seabass] add donation buttons
  • Loading branch information
milikhin authored Jun 8, 2020
1 parent be2a863 commit e8ddcc5
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 49 deletions.
9 changes: 8 additions & 1 deletion harbour-seabass/qml/generic/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ function getDefaultFilePath() {
return Qt.application.arguments[2] || ''
}

function getNormalPath(filePath) {
return filePath[filePath.length - 1] === '/'
? filePath.slice(0, -1)
: filePath
}

function getShortDirName(filePath, homeUrl) {
var dirName = filePath
var dirPath = getNormalPath(filePath)
var dirName = dirPath
.split('/')
.slice(0, -1)
.join('/') + '/'
Expand Down
23 changes: 9 additions & 14 deletions ubports-seabass/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,38 +95,33 @@
<body>
<div id="welcome">
<h1>
Seabass for UBports v0.2.0
Seabass for UBports v0.3.0
</h1>
<h2>
Release notes
</h2>
<p>
This release features code autocompletion and snippets (for some languages) and a new navigation toolbar to make it easier
to use the new features with on-screen keyboard!
This release adds ability to create new files!
</p>
<p>
Your feedback on <a href="https://github.com/milikhin/seabass2">github</a>
or in the dedicated <a href="https://forums.ubports.com/topic/4359/feedback-for-the-seabass/6">topic</a> on the UBports forum is very appreciated!
</p>
<h2>
Funding
A very important section 🐟
</h2>
<p>
Seabass is a free software.
If you'd like see the project growing, you might want to support the development.
</p>
<p>
The current goal is to have <b>$65 monthly</b> to keep the project development speed and fund a <b>full workday</b> once a month solely for the
awesome new features! It doesn't really matter how much you pay, the support is what matters:
The current goal is to have $65 monthly to keep the project development speed and fund a full workday once a month solely for the
awesome new features! It doesn't matter how much you pay, the support is what matters:
</p>
<ul class="very-important-links">
<li>
<a href="https://liberapay.com/mmmikhael/donate">Liberapay</a> (pay what you want)
</li>
<li>
<a href="https://www.patreon.com/mmmikhael">Patreon</a> (fixed $2 tier)
</li>
</ul>
<p>
<a href="https://paypal.me/mmmikhael/5"><img height="30" alt="PayPal" src="./paypal.gif" /></a>
<a href="https://liberapay.com/mmmikhael/donate"><img height="30" alt="Liberapay" src="./liberapay.svg" /></a>
<a href="https://www.patreon.com/mmmikhael"><img height="30" alt="Patreon" src="./patreon.png" /></a>
</p>
</div>
<div id="root"></div>
Expand Down
1 change: 1 addition & 0 deletions ubports-seabass/html/liberapay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ubports-seabass/html/patreon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ubports-seabass/manifest.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"desktop": "seabass2.desktop"
}
},
"version": "0.2.0",
"version": "0.3.0",
"maintainer": "Mikhael Milikhin <[email protected]>",
"framework" : "ubuntu-sdk-16.04"
}
60 changes: 44 additions & 16 deletions ubports-seabass/po/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: seabass2.mikhael\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-30 14:58+0000\n"
"PO-Revision-Date: 2020-05-30 22:11+0700\n"
"POT-Creation-Date: 2020-06-08 12:14+0000\n"
"PO-Revision-Date: 2020-06-08 19:24+0700\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand All @@ -19,7 +19,7 @@ msgstr ""
"%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
"Language: ru\n"

#: ../qml/About.qml:12 ../qml/Main.qml:173
#: ../qml/About.qml:12 ../qml/Main.qml:204
msgid "About"
msgstr "О программе"

Expand All @@ -31,44 +31,76 @@ msgstr ""
"Нажмите здесь, чтобы открыть сайт проекта. Там Вы найдете "
"документацию, техническую поддержку и список участников проекта!"

#: ../qml/Main.qml:26
#: ../qml/Main.qml:27
msgid "Welcome"
msgstr "Добро пожаловать"

#: ../qml/Main.qml:53
#: ../qml/Main.qml:61
msgid "Unable to read file. Please ensure that you have read access to the %1"
msgstr ""
"Ошибка чтения файла. Пожалуйста, убедитесь, что у Вас есть права на чтение "
"из %1"

#: ../qml/Main.qml:54
#: ../qml/Main.qml:62
msgid ""
"Unable to write the file. Please ensure that you have write access to %1"
msgstr ""
"Ошибка записи файла. Пожалуйста, убедитесь, что у Вас есть права на запись "
"в %1"

#: ../qml/Main.qml:165 ../qml/components/FileList.qml:25
#: ../qml/Main.qml:196 ../qml/components/FileList.qml:26
msgid "Files"
msgstr "Файлы"

#: ../qml/Main.qml:181 ../qml/components/SaveDialog.qml:26
#: ../qml/Main.qml:212 ../qml/components/SaveDialog.qml:26
msgid "Save"
msgstr "Сохранить"

#: ../qml/Main.qml:223
msgid "Toggle keyboard extension"
msgstr "Расширение виртуальной клавиатуры"

#: ../qml/components/ErrorDialog.qml:7
msgid "unknown error"
msgstr "неизвестная ошибка"
msgstr ""

#: ../qml/components/ErrorDialog.qml:19
msgid "Error occured"
msgstr "Ошибка"

#: ../qml/components/ErrorDialog.qml:22 ../qml/components/FileList.qml:31
#: ../qml/components/FileList.qml:40 ../qml/components/SaveDialog.qml:34
#: ../qml/components/ErrorDialog.qml:22 ../qml/components/FileList.qml:32
#: ../qml/components/FileList.qml:41 ../qml/components/SaveDialog.qml:34
msgid "Close"
msgstr "Закрыть"

#: ../qml/components/FileList.qml:46
msgid "New file..."
msgstr "Новый файл..."

#: ../qml/components/KeyboardExtension.qml:33
msgid "Tab"
msgstr ""

#: ../qml/components/KeyboardExtension.qml:37
msgid "Esc"
msgstr ""

#: ../qml/components/NewFileDialog.qml:20
msgid "Create new file"
msgstr "Создать файл"

#: ../qml/components/NewFileDialog.qml:25
msgid "file.txt"
msgstr ""

#: ../qml/components/NewFileDialog.qml:35
msgid "Create"
msgstr "Создать"

#: ../qml/components/NewFileDialog.qml:43 ../qml/components/SaveDialog.qml:42
msgid "Cancel"
msgstr "Отмена"

#: ../qml/components/SaveDialog.qml:23
msgid "Save changes in %1?"
msgstr "Сохранить изменения в %1?"
Expand All @@ -77,10 +109,6 @@ msgstr "Сохранить изменения в %1?"
msgid "Changes will be lost if you close the file without saving."
msgstr "Изменения будут потеряны, если Вы закроете файл без сохранения."

#: ../qml/components/SaveDialog.qml:42
msgid "Cancel"
msgstr "Отмена"

#: seabass2.desktop.in.h:1
msgid "Seabass2"
msgstr "Seabass2"
msgstr ""
38 changes: 27 additions & 11 deletions ubports-seabass/po/seabass2.mikhael.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: seabass2.mikhael\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-08 07:38+0000\n"
"POT-Creation-Date: 2020-06-08 15:35+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -17,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../qml/About.qml:12 ../qml/Main.qml:181
#: ../qml/About.qml:12 ../qml/Main.qml:215
msgid "About"
msgstr ""

Expand All @@ -40,15 +40,15 @@ msgid ""
"Unable to write the file. Please ensure that you have write access to %1"
msgstr ""

#: ../qml/Main.qml:173 ../qml/components/FileList.qml:25
#: ../qml/Main.qml:207 ../qml/components/FileList.qml:26
msgid "Files"
msgstr ""

#: ../qml/Main.qml:189 ../qml/components/SaveDialog.qml:26
#: ../qml/Main.qml:223 ../qml/components/SaveDialog.qml:26
msgid "Save"
msgstr ""

#: ../qml/Main.qml:200
#: ../qml/Main.qml:234
msgid "Toggle keyboard extension"
msgstr ""

Expand All @@ -60,11 +60,15 @@ msgstr ""
msgid "Error occured"
msgstr ""

#: ../qml/components/ErrorDialog.qml:22 ../qml/components/FileList.qml:31
#: ../qml/components/FileList.qml:40 ../qml/components/SaveDialog.qml:34
#: ../qml/components/ErrorDialog.qml:22 ../qml/components/FileList.qml:32
#: ../qml/components/FileList.qml:41 ../qml/components/SaveDialog.qml:34
msgid "Close"
msgstr ""

#: ../qml/components/FileList.qml:46
msgid "New file..."
msgstr ""

#: ../qml/components/KeyboardExtension.qml:33
msgid "Tab"
msgstr ""
Expand All @@ -73,6 +77,22 @@ msgstr ""
msgid "Esc"
msgstr ""

#: ../qml/components/NewFileDialog.qml:21
msgid "Create new file"
msgstr ""

#: ../qml/components/NewFileDialog.qml:26
msgid "file.txt"
msgstr ""

#: ../qml/components/NewFileDialog.qml:36
msgid "Create"
msgstr ""

#: ../qml/components/NewFileDialog.qml:44 ../qml/components/SaveDialog.qml:42
msgid "Cancel"
msgstr ""

#: ../qml/components/SaveDialog.qml:23
msgid "Save changes in %1?"
msgstr ""
Expand All @@ -81,10 +101,6 @@ msgstr ""
msgid "Changes will be lost if you close the file without saving."
msgstr ""

#: ../qml/components/SaveDialog.qml:42
msgid "Cancel"
msgstr ""

#: seabass2.desktop.in.h:1
msgid "Seabass2"
msgstr ""
38 changes: 36 additions & 2 deletions ubports-seabass/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MainView {
readonly property bool isWide: width >= units.gu(100)
readonly property string defaultTitle: i18n.tr("Welcome")
readonly property string defaultSubTitle: "Seabass"
readonly property string version: "0.2.0"
readonly property string version: "0.3.0"

Settings {
id: settings
Expand Down Expand Up @@ -99,6 +99,10 @@ MainView {
id: errorDialog
}

CustomComponents.NewFileDialog {
id: newFileDialog
}

CustomComponents.SaveDialog {
id: saveDialog
}
Expand Down Expand Up @@ -132,12 +136,42 @@ MainView {
Layout.fillWidth: true
Layout.fillHeight: true

onFileCreationInitialised: function(dirPath) {
const normalDirPath = QmlJs.getNormalPath(dirPath)
newFileDialog.show(normalDirPath, function(fileName) {
const filePath = QmlJs.getNormalPath(Qt.resolvedUrl(normalDirPath + '/' + fileName))
const existingTabIndex = filesModel.open(filePath)
if (existingTabIndex !== undefined) {
tabBar.currentIndex = existingTabIndex
} else {
api.createFile(filePath, function(err) {
if (err) {
filesModel.remove(filesModel.count - 1, 1)
if (!filesModel.count) {
api.filePath = ''
}
}
})
}

if (!isWide) {
navBar.visible = false
}
})
}
onFileSelected: function(filePath) {
const existingTabIndex = filesModel.open(filePath)
if (existingTabIndex !== undefined) {
tabBar.currentIndex = existingTabIndex
} else {
api.loadFile(filePath)
api.loadFile(filePath, false, function(err) {
if (err) {
filesModel.remove(filesModel.count - 1, 1)
if (!filesModel.count) {
api.filePath = ''
}
}
})
}

if (!isWide) {
Expand Down
6 changes: 6 additions & 0 deletions ubports-seabass/qml/components/FileList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ListView {
readonly property string textColor: theme.palette.normal.backgroundText

signal closed()
signal fileCreationInitialised(string dirPath)
signal fileSelected(string filePath)

ScrollBar.vertical: ScrollBar {}
Expand All @@ -39,6 +40,11 @@ ListView {
iconName: "close"
text: i18n.tr("Close")
onTriggered: closed()
},
Action {
iconName: "add"
text: i18n.tr("New file...")
onTriggered: fileCreationInitialised(folderModel.folder.toString().replace('file://', ''))
}
]
}
Expand Down
Loading

0 comments on commit e8ddcc5

Please sign in to comment.