Skip to content

Commit f4e4f2b

Browse files
committed
Merge branch 'develop'
2 parents aebe218 + 6ebcba6 commit f4e4f2b

File tree

91 files changed

+2462
-1150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2462
-1150
lines changed

appveyor.yml .appveyor.yml

File renamed without changes.

.mailmap

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
22
3+
Pier Luigi Fiorini <[email protected]> <[email protected]>
4+
Pier Luigi Fiorini <[email protected]> <[email protected]>

.project/screenshots/text1.png

57.1 KB
Loading

.project/screenshots/text2.png

149 KB
Loading

.tx/config

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[main]
2+
host = https://www.transifex.com
3+
4+
[liri-text.app]
5+
type = QT
6+
source_lang = en
7+
source_file = src/translations/liri-text.ts
8+
file_filter = src/translations/liri-text_<lang>.ts
9+
10+
[liri-text.desktop-file]
11+
type = DESKTOP
12+
source_lang = en
13+
source_file = data/io.liri.Text.desktop.in
14+
file_filter = src/translations/io.liri.Text_<lang>.desktop

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Liri Text
1111

1212
Liri Text is a cross-platform text editor made in accordance with Material Design.
1313

14+
![Screenshot](https://raw.githubusercontent.com/lirios/text/develop/.project/screenshots/text1.png)
15+
1416
## Dependencies
1517

1618
Qt >= 5.10.0 with at least the following modules is required:

data/io.liri.Text.appdata.xml

+61-6
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,82 @@
66
<metadata_license>CC0-1.0</metadata_license>
77
<project_license>GPL-3.0+</project_license>
88
<description>
9-
<p>Liri Text is a cross-platform text editor made in accordance with Material Design.</p>
9+
<p>
10+
Liri Text is a cross-platform text editor made in accordance with Material Design,
11+
aiming at simplicity and ease of use.
12+
</p>
13+
<p>
14+
It is best suited for taking notes, writing text documents or
15+
quick programming with its syntax highlighting feature.
16+
</p>
1017
</description>
1118
<launchable type="desktop-id">io.liri.Text.desktop</launchable>
1219
<provides>
1320
<binary>liri-text</binary>
1421
</provides>
1522
<screenshots>
1623
<screenshot type="default">
17-
<image>https://liri.io/images/apps/text/text1.png</image>
24+
<image>https://raw.githubusercontent.com/lirios/text/develop/.project/screenshots/text1.png</image>
1825
</screenshot>
1926
<screenshot>
20-
<image>https://liri.io/images/apps/text/text2.png</image>
27+
<image>https://raw.githubusercontent.com/lirios/text/develop/.project/screenshots/text2.png</image>
2128
</screenshot>
2229
</screenshots>
2330
<kudos>
31+
<kudo>HiDpiIcon</kudo>
2432
<kudo>ModernToolkit</kudo>
2533
</kudos>
2634
<releases>
27-
<release date="2018-05-13" version="0.3.0"/>
28-
<release date="2017-04-16" version="0.2.0"/>
29-
<release date="2016-05-08" version="0.1.0"/>
35+
<release date="2018-10-18" version="0.4.0">
36+
<description>
37+
<ul>
38+
<li>Add versioning to the languages database.</li>
39+
<li>Read language metadata only for new and changed spec files.</li>
40+
<li>Generate resources with qbs.</li>
41+
<li>Fix icons installation.</li>
42+
<li>Fix translations installation.</li>
43+
<li>Fix build on WinRT.</li>
44+
<li>Update translations.</li>
45+
</ul>
46+
</description>
47+
</release>
48+
<release date="2018-05-13" version="0.3.0">
49+
<description>
50+
<ul>
51+
<li>Fix errors discovered by Clazy.</li>
52+
<li>Fix memory leaks.</li>
53+
<li>Follow Fluid 1.0 changes.</li>
54+
<li>Allow cross-language references to define-regexes with %{lang:id}.</li>
55+
<li>Experimental QML highlighting.</li>
56+
<li>Update appdata file.</li>
57+
<li>Update desktop file.</li>
58+
<li>Fix context menu positioning.</li>
59+
<li>Enable text selection by mouse in search overlay.</li>
60+
<li>Backward search (Shift+Enter in search field).</li>
61+
<li>Use fixed line heights for file previews.</li>
62+
<li>Add Next/Prev buttons to search overlay.</li>
63+
<li>Add 8dp margin to the right of search overlay.</li>
64+
<li>Hide search overlay after 5 seconds without focus.</li>
65+
</ul>
66+
</description>
67+
</release>
68+
<release date="2017-04-16" version="0.2.0">
69+
<description>
70+
<ul>
71+
<li>Transition to Qt Quick Controls 2 and Fluid framework.</li>
72+
<li>New icon by Corbin Crutchley.</li>
73+
<li>Syntax highlighting.</li>
74+
<li>Search through file (Ctrl+F shortcut available).</li>
75+
<li>Add translations.</li>
76+
<li>Several minor improvements and bugfixes.</li>
77+
</ul>
78+
</description>
79+
</release>
80+
<release date="2016-05-08" version="0.1.0">
81+
<description>
82+
<p>The first release of Liri Text, providing only the basic functionality essential for a text editor.</p>
83+
</description>
84+
</release>
3085
</releases>
3186
<url type="homepage">https://liri.io</url>
3287
<url type="bugtracker">https://github.com/lirios/text/issues/new</url>

data/io.liri.Text.desktop data/io.liri.Text.desktop.in

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Name=Liri Text
33
GenericName=Text Editor
44
Comment=Edit text files
5+
#TRANSLATIONS
56
Exec=liri-text %f
67
Terminal=false
78
Type=Application

scripts/txpull.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# Fetch translations
4+
tx pull --force --all --minimum-perc=5
5+
6+
# Commit to git
7+
if [ "$CI" = "true" ]; then
8+
AUTHOR="Liri CI <[email protected]>"
9+
SUBJECT="Automatic merge of Transifex translations"
10+
git config --global push.default simple
11+
git add --verbose src/translations/liri-text_*.ts
12+
git commit --author="$AUTHOR" --message="$SUBJECT"
13+
git push
14+
fi

scripts/txpush.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
LUPDATE=${LUPDATE-lupdate}
4+
5+
###
6+
# Update source translation files
7+
###
8+
9+
appdir=src
10+
mkdir -p $appdir/translations
11+
$LUPDATE $appdir -ts -no-obsolete $appdir/translations/liri-text.ts
12+
13+
tx push --source --no-interactive
14+
tx push --translations --no-interactive

src/documenthandler.cpp

+62-37
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,46 @@
2727
#include "languageloader.h"
2828
#include "languagemanager.h"
2929

30-
DocumentHandler::DocumentHandler(QObject *parent) :
31-
QObject(parent),
32-
m_target(0),
33-
m_document(0),
34-
m_highlighter(0) {
35-
30+
DocumentHandler::DocumentHandler(QObject *parent)
31+
: QObject(parent)
32+
, m_target(0)
33+
, m_document(0)
34+
, m_highlighter(0)
35+
{
36+
37+
#ifndef QT_NO_FILESYSTEMWATCHER
3638
m_watcher = new QFileSystemWatcher(this);
3739
connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &DocumentHandler::fileChanged);
40+
#else
41+
qWarning() << "Document change notification is not available on this platform";
42+
#endif
3843

3944
m_defStyles = QSharedPointer<LanguageDefaultStyles>::create();
4045
}
4146

42-
DocumentHandler::~DocumentHandler() {
47+
DocumentHandler::~DocumentHandler()
48+
{
49+
#ifndef QT_NO_FILESYSTEMWATCHER
4350
delete m_watcher;
51+
#endif
4452
delete m_highlighter;
4553
}
4654

47-
void DocumentHandler::setTarget(QQuickItem *target) {
55+
void DocumentHandler::setTarget(QQuickItem *target)
56+
{
4857
m_document = nullptr;
4958
m_target = target;
50-
if(!m_target)
59+
if (!m_target)
5160
return;
5261

5362
QVariant doc = m_target->property("textDocument");
54-
if(doc.canConvert<QQuickTextDocument*>()) {
55-
QQuickTextDocument *qqdoc = doc.value<QQuickTextDocument*>();
56-
if(qqdoc) {
63+
if (doc.canConvert<QQuickTextDocument *>()) {
64+
QQuickTextDocument *qqdoc = doc.value<QQuickTextDocument *>();
65+
if (qqdoc) {
5766
m_document = qqdoc->textDocument();
58-
connect(m_document, &QTextDocument::modificationChanged, this, &DocumentHandler::modifiedChanged);
59-
if(m_highlighter != nullptr)
67+
connect(m_document, &QTextDocument::modificationChanged, this,
68+
&DocumentHandler::modifiedChanged);
69+
if (m_highlighter != nullptr)
6070
delete m_highlighter;
6171
m_highlighter = new LiriSyntaxHighlighter(m_document);
6272
m_highlighter->setDefaultStyles(m_defStyles);
@@ -65,28 +75,31 @@ void DocumentHandler::setTarget(QQuickItem *target) {
6575
emit targetChanged();
6676
}
6777

68-
bool DocumentHandler::setFileUrl(const QUrl &fileUrl) {
69-
if(fileUrl != m_fileUrl) {
70-
if(m_watcher->files().contains(m_fileUrl.toLocalFile()))
78+
bool DocumentHandler::setFileUrl(const QUrl &fileUrl)
79+
{
80+
if (fileUrl != m_fileUrl) {
81+
#ifndef QT_NO_FILESYSTEMWATCHER
82+
if (m_watcher->files().contains(m_fileUrl.toLocalFile()))
7183
m_watcher->removePath(m_fileUrl.toLocalFile());
7284
m_watcher->addPath(fileUrl.toLocalFile());
85+
#endif
7386
m_fileUrl = fileUrl;
7487
QString filename = m_fileUrl.toLocalFile();
7588
qDebug() << m_fileUrl << filename;
7689
QFile file(filename);
77-
if(!file.open(QFile::ReadOnly)) {
90+
if (!file.open(QFile::ReadOnly)) {
7891
emit error(file.errorString());
7992
return false;
8093
}
8194
QByteArray data = file.readAll();
82-
if(file.error() != QFileDevice::NoError) {
95+
if (file.error() != QFileDevice::NoError) {
8396
emit error(file.errorString());
8497
file.close();
8598
return false;
8699
}
87100
QTextCodec *codec = QTextCodec::codecForUtfText(data, QTextCodec::codecForLocale());
88101
setText(codec->toUnicode(data));
89-
if(m_document) {
102+
if (m_document) {
90103
m_document->setModified(false);
91104

92105
// Enable syntax highlighting
@@ -96,7 +109,7 @@ bool DocumentHandler::setFileUrl(const QUrl &fileUrl) {
96109
auto language = ll.loadMainContextByMimeType(mimeType, m_fileUrl.fileName());
97110
m_highlighter->setLanguage(language, ll.styleMap());
98111
}
99-
if(m_fileUrl.isEmpty())
112+
if (m_fileUrl.isEmpty())
100113
m_documentTitle = QStringLiteral("New Document");
101114
else
102115
m_documentTitle = QFileInfo(filename).fileName();
@@ -107,15 +120,17 @@ bool DocumentHandler::setFileUrl(const QUrl &fileUrl) {
107120
return true;
108121
}
109122

110-
void DocumentHandler::setDocumentTitle(const QString &title) {
111-
if(title != m_documentTitle) {
123+
void DocumentHandler::setDocumentTitle(const QString &title)
124+
{
125+
if (title != m_documentTitle) {
112126
m_documentTitle = title;
113127
emit documentTitleChanged();
114128
}
115129
}
116130

117-
QString DocumentHandler::textFragment(int position, int blockCount) {
118-
if(m_highlighter) {
131+
QString DocumentHandler::textFragment(int position, int blockCount)
132+
{
133+
if (m_highlighter) {
119134
return m_highlighter->highlightedFragment(position, blockCount, m_document->defaultFont());
120135
} else {
121136
QTextCursor cursor(m_document->findBlock(position));
@@ -132,26 +147,30 @@ QString DocumentHandler::textFragment(int position, int blockCount) {
132147
}
133148
}
134149

135-
void DocumentHandler::setText(const QString &text) {
136-
if(text != m_text) {
150+
void DocumentHandler::setText(const QString &text)
151+
{
152+
if (text != m_text) {
137153
m_text = text;
138154
emit textChanged();
139155
}
140156
}
141157

142-
bool DocumentHandler::saveAs(const QUrl &filename) {
158+
bool DocumentHandler::saveAs(const QUrl &filename)
159+
{
160+
#ifndef QT_NO_FILESYSTEMWATCHER
143161
// Stop monitoring file while saving
144-
if(m_watcher->files().contains(m_fileUrl.toLocalFile()))
162+
if (m_watcher->files().contains(m_fileUrl.toLocalFile()))
145163
m_watcher->removePath(m_fileUrl.toLocalFile());
164+
#endif
146165

147166
bool success = true;
148167
QString localPath = filename.toLocalFile();
149168
QFile file(localPath);
150-
if(!file.open(QFile::WriteOnly | QFile::Truncate | QFile::Text)) {
169+
if (!file.open(QFile::WriteOnly | QFile::Truncate | QFile::Text)) {
151170
emit error(file.errorString());
152171
success = false;
153172
} else {
154-
if(file.write(m_document->toPlainText().toLocal8Bit()) == -1) {
173+
if (file.write(m_document->toPlainText().toLocal8Bit()) == -1) {
155174
emit error(file.errorString());
156175
success = false;
157176
}
@@ -162,24 +181,27 @@ bool DocumentHandler::saveAs(const QUrl &filename) {
162181
m_document->setModified(false);
163182
}
164183

184+
#ifndef QT_NO_FILESYSTEMWATCHER
165185
// Restart file watcher back after saving completes
166-
if(!m_watcher->files().contains(m_fileUrl.toLocalFile()))
186+
if (!m_watcher->files().contains(m_fileUrl.toLocalFile()))
167187
m_watcher->addPath(m_fileUrl.toLocalFile());
188+
#endif
168189

169190
return success;
170191
}
171192

172-
bool DocumentHandler::reloadText() {
193+
bool DocumentHandler::reloadText()
194+
{
173195
QString filename = m_fileUrl.toLocalFile();
174196
QFile file(filename);
175-
if(!file.open(QFile::ReadOnly)) {
197+
if (!file.open(QFile::ReadOnly)) {
176198
emit error(file.errorString());
177199
return false;
178200
}
179201
QByteArray data = file.readAll();
180202
QTextCodec *codec = QTextCodec::codecForUtfText(data, QTextCodec::codecForLocale());
181203
setText(codec->toUnicode(data));
182-
if(file.error() == QFileDevice::NoError) {
204+
if (file.error() == QFileDevice::NoError) {
183205
file.close();
184206
return true;
185207
} else {
@@ -189,8 +211,11 @@ bool DocumentHandler::reloadText() {
189211
}
190212
}
191213

192-
void DocumentHandler::fileChanged(const QString &file) {
214+
void DocumentHandler::fileChanged(const QString &file)
215+
{
193216
emit fileChangedOnDisk();
194-
if(!m_watcher->files().contains(file))
217+
#ifndef QT_NO_FILESYSTEMWATCHER
218+
if (!m_watcher->files().contains(file))
195219
m_watcher->addPath(file);
220+
#endif
196221
}

0 commit comments

Comments
 (0)