[-]
[+]
|
Changed |
_service:tar_git:openrepos-books.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/harbour-books.git</param>
<param name="branch">master</param>
- <param name="revision">b78e790</param>
+ <param name="revision">c90af8f</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/app.pro
^
|
@@ -213,7 +213,7 @@
INSTALLS += qml_components
# Icons
-ICON_SIZES = 86 108 128 256
+ICON_SIZES = 86 108 128 172 256
for(s, ICON_SIZES) {
icon_target = icon$${s}
icon_dir = icons/$${s}x$${s}
@@ -252,6 +252,7 @@
}
# Translations
+TRANSLATION_IDBASED=-idbased
TRANSLATION_SOURCES = \
$${_PRO_FILE_PWD_}/qml \
$${_PRO_FILE_PWD_}/settings
@@ -259,33 +260,33 @@
defineTest(addTrFile) {
rel = translations/harbour-$${1}
OTHER_FILES += $${rel}.ts
+ export(OTHER_FILES)
- in = $${_PRO_FILE_PWD_}/$$rel
- out = $${OUT_PWD}/translations/$${PREFIX}-$$1
+ in = $${_PRO_FILE_PWD_}/$${rel}
+ out = $${OUT_PWD}/translations/$${PREFIX}-$${1}
s = $$replace(1,-,_)
lupdate_target = lupdate_$$s
- lrelease_target = lrelease_$$s
+ qm_target = qm_$$s
- $${lupdate_target}.commands = lupdate -noobsolete $${TRANSLATION_SOURCES} -ts \"$${in}.ts\" && \
+ $${lupdate_target}.commands = lupdate -noobsolete -locations none $${TRANSLATION_SOURCES} -ts \"$${in}.ts\" && \
mkdir -p \"$${OUT_PWD}/translations\" && [ \"$${in}.ts\" != \"$${out}.ts\" ] && \
cp -af \"$${in}.ts\" \"$${out}.ts\" || :
- $${lrelease_target}.target = $${out}.qm
- $${lrelease_target}.depends = $${lupdate_target}
- $${lrelease_target}.commands = lrelease -idbased \"$${out}.ts\"
-
- QMAKE_EXTRA_TARGETS += $${lrelease_target} $${lupdate_target}
- PRE_TARGETDEPS += $${out}.qm
- qm.files += $${out}.qm
+ $${qm_target}.path = $$TRANSLATIONS_PATH
+ $${qm_target}.depends = $${lupdate_target}
+ $${qm_target}.commands = lrelease $$TRANSLATION_IDBASED \"$${out}.ts\" && \
+ $(INSTALL_FILE) \"$${out}.qm\" $(INSTALL_ROOT)$${TRANSLATIONS_PATH}/
+
+ QMAKE_EXTRA_TARGETS += $${lupdate_target} $${qm_target}
+ INSTALLS += $${qm_target}
+
export($${lupdate_target}.commands)
- export($${lrelease_target}.target)
- export($${lrelease_target}.depends)
- export($${lrelease_target}.commands)
+ export($${qm_target}.path)
+ export($${qm_target}.depends)
+ export($${qm_target}.commands)
export(QMAKE_EXTRA_TARGETS)
- export(PRE_TARGETDEPS)
- export(OTHER_FILES)
- export(qm.files)
+ export(INSTALLS)
}
LANGUAGES = de fi hu nl pl pt ru sv es zh_CN
@@ -294,7 +295,3 @@
for(l, LANGUAGES) {
addTrFile($${NAME}-$$l)
}
-
-qm.path = $$TRANSLATIONS_PATH
-qm.CONFIG += no_check_exist
-INSTALLS += qm
|
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/icons/172x172/harbour-books.png
^
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/icons/harbour-books.svg
^
|
@@ -1,13 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Generator: Adobe Illustrator 17.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
-
<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
x="0px"
@@ -17,36 +11,34 @@
viewBox="0 0 86 86"
enable-background="new 0 0 86 86"
xml:space="preserve"
- id="svg2"
- inkscape:version="0.48.2 r9819"><metadata
- id="metadata25"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata>
-<g
- id="Layer_1">
- <linearGradient
- id="SVGID_1_"
- gradientUnits="userSpaceOnUse"
- x1="79.2383"
- y1="91.3279"
- x2="6.7619"
- y2="18.8514">
- <stop
- offset="0"
- style="stop-color:#f5d9a8;stop-opacity:1;"
- id="stop7" />
- <stop
- offset="0.99510002"
- style="stop-color:#cc9933;stop-opacity:1;"
- id="stop9" />
- </linearGradient>
- <path
- fill="url(#SVGID_1_)"
- d="M43,0.3C19.417,0.3,0.3,19.418,0.3,43c0,0.408,0,41.277,0,41.277c0,0.786,0.637,1.423,1.423,1.423 h82.553c0.786,0,1.423-0.637,1.423-1.423c0,0,0-40.908,0-41.277C85.7,19.418,66.583,0.3,43,0.3z"
- id="path11" />
-</g>
-<path
- inkscape:connector-curvature="0"
- d="m 65.244239,25.145325 2.755924,0 0,52.854675 -39.567187,0 C 22.625852,78 17.999837,73.964541 17.999837,67.960564 l 0,-45.768014 c 0,-3.248053 2.657498,-5.90555 5.905551,-5.90555 l 36.614411,0 0,45.374311 -32.086823,0 c -4.035459,0 -6.889809,2.165368 -6.889809,6.102402 l 0,0.196851 c 0,3.937034 2.85435,6.496106 6.889809,6.496106 l 36.811263,0 0,-49.311345 z m -4.72444,44.193201 -31.69312,0 c -0.885832,0 -1.673239,-0.492128 -1.673239,-1.476387 0,-0.787407 0.787407,-1.279537 1.673239,-1.279537 l 31.69312,0 0,2.755924 z"
- id="path4"
- style="fill:#cc0000;fill-opacity:1" /></svg>
+ inkscape:version="0.48.2 r9819">
+ <rect
+ y="0"
+ x="0"
+ style="opacity:0;fill:#ffffff"
+ width="86"
+ height="86"/>
+ <g>
+ <linearGradient
+ id="SVGID_1_"
+ gradientUnits="userSpaceOnUse"
+ x1="79.2383"
+ y1="91.3279"
+ x2="6.7619"
+ y2="18.8514">
+ <stop
+ offset="0"
+ style="stop-color:#f5d9a8;stop-opacity:1;"/>
+ <stop
+ offset="1"
+ style="stop-color:#cc9933;stop-opacity:1;"/>
+ </linearGradient>
+ <path
+ fill="url(#SVGID_1_)"
+ d="M43,0.3C19.417,0.3,0.3,19.418,0.3,43c0,0.408,0,41.277,0,41.277c0,0.786,0.637,1.423,1.423,1.423 h82.553c0.786,0,1.423-0.637,1.423-1.423c0,0,0-40.908,0-41.277C85.7,19.418,66.583,0.3,43,0.3z"/>
+ </g>
+ <path
+ inkscape:connector-curvature="0"
+ d="m 65.244239,25.145325 2.755924,0 0,52.854675 -39.567187,0 C 22.625852,78 17.999837,73.964541 17.999837,67.960564 l 0,-45.768014 c 0,-3.248053 2.657498,-5.90555 5.905551,-5.90555 l 36.614411,0 0,45.374311 -32.086823,0 c -4.035459,0 -6.889809,2.165368 -6.889809,6.102402 l 0,0.196851 c 0,3.937034 2.85435,6.496106 6.889809,6.496106 l 36.811263,0 0,-49.311345 z m -4.72444,44.193201 -31.69312,0 c -0.885832,0 -1.673239,-0.492128 -1.673239,-1.476387 0,-0.787407 0.787407,-1.279537 1.673239,-1.279537 l 31.69312,0 0,2.755924 z"
+ style="fill:#cc0000;fill-opacity:1"/>
+ </svg>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/qml/Books.js
^
|
@@ -1,5 +1,7 @@
.pragma library
+var version = "1.0.44"
+
function contentOpacity(brightness) {
return 0.4 + brightness * 0.6
}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/qml/BooksBookView.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2020 Jolla Ltd.
- Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2021 Jolla Ltd.
+ Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -166,7 +166,7 @@
pageStack.push(settingsComponent, {
"title" : text,
"allowedOrientations": window.allowedOrientations,
- "followOrientationChanges": true
+ "inApp": true
})
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/qml/BooksCoverPage.qml
^
|
@@ -1,20 +1,21 @@
/*
- Copyright (C) 2015 Jolla Ltd.
- Contact: Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2021 Jolla Ltd.
+ Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
- You may use this file under the terms of BSD license as follows:
+ You may use this file under the terms of the BSD license as follows:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
+
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- * Neither the name of the Jolla Ltd nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
+ * Neither the names of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -60,7 +61,7 @@
width: grid.cellWidth
height: grid.cellHeight
borderWidth: 0
- stretch: true
+ mode: BookCover.Stretch
}
}
@@ -95,7 +96,7 @@
synchronous: true
book: root.book ? root.book : null
defaultCover: "images/default-cover.jpg"
- stretch: true
+ mode: BookCover.Fill
}
BooksTitleText {
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/qml/BooksShelfItem.qml
^
|
@@ -103,6 +103,7 @@
borderRadius: _borderRadius
borderWidth: book ? _borderWidth : 0
borderColor: _borderColor
+ mode: BookCover.Bottom
opacity: (copyingIn || copyingOut) ? 0.1 : 1
Behavior on opacity { FadeAnimation { } }
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/qml/BooksShelfView.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2020 Jolla Ltd.
- Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2021 Jolla Ltd.
+ Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -51,6 +51,8 @@
property alias shelf: shelfModel
property alias device: shelfModel.device
property alias dummyItemIndex: shelfModel.dummyItemIndex
+ property alias bookCount: shelfModel.bookCount
+ property alias bookCountVisible: storageHeader.needed
signal openBook(var book)
signal dropItem(var mouseX, var mouseY)
@@ -60,10 +62,10 @@
signal scrollRight()
signal scrollLeft()
- property bool _haveBooks: shelfModel && shelfModel.count
- property int _cellsPerRow: Math.floor(width/cellWidth)
+ readonly property bool _haveBooks: shelfModel.count > 0
+ readonly property int _cellsPerRow: Math.floor(width/cellWidth)
readonly property int _remorseTimeout: 5000
- property bool _loading: !shelfModel || shelfModel.loading || startAnimationTimer.running
+ readonly property bool _loading: shelfModel.loading || startAnimationTimer.running
property var _remorse
on_HaveBooksChanged: if (!_haveBooks) shelfView.stopEditing()
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/qml/BooksStorageView.qml
^
|
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2015-2020 Jolla Ltd.
- Copyright (C) 2015-2020 Slava Monich <slava.monich@jolla.com>
+ Copyright (C) 2015-2021 Jolla Ltd.
+ Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows:
@@ -112,7 +112,7 @@
pageStack.push(_settingsComponent, {
"title" : text,
"allowedOrientations": window.allowedOrientations,
- "followOrientationChanges": true
+ "inApp": true
})
}
}
@@ -131,6 +131,14 @@
enabled: currentShelf && (currentShelf.count > 0)
onClicked: storageModel.setDeleteAllRequest(storageListWatcher.currentIndex, true)
}
+ MenuLabel {
+ //: Number of books in the storage header
+ //% "%0 book(s)"
+ text: qsTrId("harbour-books-storage-book_count",bookCount).arg(bookCount)
+ visible: !bookCountVisible && bookCount > 0
+ readonly property int bookCount: storageList.currentItem ? storageList.currentItem.bookCount : 0
+ readonly property bool bookCountVisible: storageList.currentItem && storageList.currentItem.bookCountVisible
+ }
}
onEditModeChanged: {
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/settings/BooksSettings.qml
^
|
@@ -41,11 +41,13 @@
Page {
id: page
- property bool followOrientationChanges
+ property bool inApp
property alias title: pageHeader.title
readonly property string rootPath: "/apps/" + appName() + "/"
readonly property bool darkOnLight: ('colorScheme' in Theme) && Theme.colorScheme === 1
- readonly property bool landscapeLayout: (width > height && Screen.sizeCategory > Screen.Small) || Screen.sizeCategory > Screen.Medium
+ readonly property int screenWidth: isPortrait ? Screen.width : Screen.height
+ readonly property int screenHeight: isPortrait ? Screen.height : Screen.width
+ readonly property bool landscapeLayout: (screenWidth > screenHeight && Screen.sizeCategory > Screen.Small) || Screen.sizeCategory > Screen.Medium
// jolla-settings expects these properties:
property var applicationName
@@ -64,7 +66,7 @@
}
Loader {
- active: followOrientationChanges
+ active: inApp // Follow orientation changes
Connections {
target: orientation
onValueChanged: allowedOrientations =
@@ -123,9 +125,28 @@
PageHeader {
id: pageHeader
- //: Settings page header
- //% "Books"
- title: qsTrId("harbour-books-settings-page-header")
+ rightMargin: Theme.horizontalPageMargin + (appIcon.visible ? (height - appIcon.padding) : 0)
+ title: applicationName ? applicationName :
+ //: Settings page header (app name)
+ //% "Books"
+ qsTrId("harbour-books-settings-page-header")
+ description: inApp ? "" :
+ //: Settings page header description (app version)
+ //% "Version %1"
+ qsTrId("harbour-books-settings-version").arg(Books.version)
+
+ Image {
+ id: appIcon
+ readonly property int padding: Theme.paddingLarge
+ readonly property int size: pageHeader.height - 2 * padding
+ x: pageHeader.width - width - Theme.horizontalPageMargin
+ y: padding
+ width: size
+ height: size
+ sourceSize: Qt.size(size,size)
+ source: applicationIcon ? applicationIcon : ""
+ visible: appIcon.status === Image.Ready
+ }
}
// =============== Display ===============
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/src/BooksCoverWidget.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2018 Jolla Ltd.
- * Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2021 Jolla Ltd.
+ * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,15 +8,15 @@
* modification, are permitted provided that the following conditions
* are met:
*
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -50,19 +50,28 @@
ScaleTask(QThreadPool* aPool, QImage aImage, int aWidth, int aHeight,
bool aStretch);
static QImage scale(QImage aImage, int aWidth, int aHeight, bool aStretch);
+ static QColor leftBackground(const QImage& aImage);
+ static QColor rightBackground(const QImage& aImage);
+ static QColor topBackground(const QImage& aImage);
+ static QColor bottomBackground(const QImage& aImage);
+ static QColor pickColor(const QHash<QRgb,int>& aColorCounts);
void performTask();
public:
QImage iImage;
QImage iScaledImage;
+ QColor iBackground1; // Left or top
+ QColor iBackground2; // Right or bottom
int iWidth;
int iHeight;
bool iStretch;
};
BooksCoverWidget::ScaleTask::ScaleTask(QThreadPool* aPool, QImage aImage,
- int aWidth, int aHeight, bool aStretch) : HarbourTask(aPool),
- iImage(aImage), iWidth(aWidth), iHeight(aHeight), iStretch(aStretch)
+ int aWidth, int aHeight, bool aStretch) : HarbourTask(aPool), iImage(aImage),
+ iBackground1(Qt::transparent), iBackground2(Qt::transparent),
+ iWidth(aWidth), iHeight(aHeight),
+ iStretch(aStretch)
{
}
@@ -79,10 +88,106 @@
}
}
+// The idea is to pick the colors which occur more often
+// at the edges of the picture.
+QColor BooksCoverWidget::ScaleTask::leftBackground(const QImage& aImage)
+{
+ QHash<QRgb,int> counts;
+ if (aImage.width() > 0) {
+ const int h = aImage.height();
+ for (int y = 0; y < h; y++) {
+ const QRgb left(aImage.pixel(0, y));
+ counts.insert(left, counts.value(left) + 1);
+ }
+ }
+ const QColor color(pickColor(counts));
+ HDEBUG(color << "left" << counts.count());
+ return color;
+}
+
+QColor BooksCoverWidget::ScaleTask::rightBackground(const QImage& aImage)
+{
+ QHash<QRgb,int> counts;
+ const int w = aImage.width();
+ if (w > 0) {
+ const int h = aImage.height();
+ for (int y = 0; y < h; y++) {
+ const QRgb right(aImage.pixel(w - 1, y));
+ counts.insert(right, counts.value(right) + 1);
+ }
+ }
+ const QColor color(pickColor(counts));
+ HDEBUG(color << "right" << counts.count());
+ return color;
+}
+
+QColor BooksCoverWidget::ScaleTask::topBackground(const QImage& aImage)
+{
+ QHash<QRgb,int> counts;
+ if (aImage.height() > 0) {
+ const int w = aImage.width();
+ for (int x = 0; x < w; x++) {
+ const QRgb left(aImage.pixel(x, 0));
+ counts.insert(left, counts.value(left) + 1);
+ }
+ }
+ const QColor color(pickColor(counts));
+ HDEBUG(color << "top" << counts.count());
+ return color;
+}
+
+QColor BooksCoverWidget::ScaleTask::bottomBackground(const QImage& aImage)
+{
+ QHash<QRgb,int> counts;
+ const int h = aImage.height();
+ if (h > 0) {
+ const int w = aImage.width();
+ for (int x = 0; x < w; x++) {
+ const QRgb left(aImage.pixel(x, h - 1));
+ counts.insert(left, counts.value(left) + 1);
+ }
+ }
+ const QColor color(pickColor(counts));
+ HDEBUG(color << "bottom" << counts.count());
+ return color;
+}
+
+QColor BooksCoverWidget::ScaleTask::pickColor(const QHash<QRgb,int>& aCounts)
+{
+ if (aCounts.size() > 0) {
+ QRgb rgb;
+ int max;
+ QHashIterator<QRgb,int> it(aCounts);
+ for (max = 0; it.hasNext();) {
+ it.next();
+ const int count = it.value();
+ if (max < count) {
+ max = count;
+ rgb = it.key();
+ }
+ }
+ return QColor(rgb);
+ }
+ return QColor();
+}
+
void BooksCoverWidget::ScaleTask::performTask()
{
if (!iImage.isNull() && !isCanceled()) {
iScaledImage = scale(iImage, iWidth, iHeight, iStretch);
+ if (!isCanceled()) {
+ if (iScaledImage.width() < iWidth) {
+ iBackground1 = leftBackground(iScaledImage);
+ if (!isCanceled()) {
+ iBackground2 = rightBackground(iScaledImage);
+ }
+ } else if (iScaledImage.height() < iHeight) {
+ iBackground1 = topBackground(iScaledImage);
+ if (!isCanceled()) {
+ iBackground2 = bottomBackground(iScaledImage);
+ }
+ }
+ }
}
}
@@ -204,7 +309,7 @@
iBorderWidth(0),
iBorderRadius(0),
iBorderColor(Qt::transparent),
- iStretch(false),
+ iMode(Bottom),
iSynchronous(false)
{
setFlag(ItemHasContents, true);
@@ -264,13 +369,13 @@
scaleImage(wasEmpty);
}
-void BooksCoverWidget::setStretch(bool aValue)
+void BooksCoverWidget::setMode(Mode aMode)
{
- if (iStretch != aValue) {
- iStretch = aValue;
- HDEBUG(aValue);
+ if (iMode != aMode) {
+ iMode = aMode;
+ HDEBUG(aMode);
scaleImage();
- Q_EMIT stretchChanged();
+ Q_EMIT modeChanged();
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/src/BooksCoverWidget.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2018 Jolla Ltd.
- * Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2021 Jolla Ltd.
+ * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,15 +8,15 @@
* modification, are permitted provided that the following conditions
* are met:
*
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -49,8 +49,8 @@
Q_OBJECT
Q_PROPERTY(bool empty READ empty NOTIFY emptyChanged)
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
- Q_PROPERTY(bool stretch READ stretch WRITE setStretch NOTIFY stretchChanged)
Q_PROPERTY(bool synchronous READ synchronous WRITE setSynchronous NOTIFY synchronousChanged)
+ Q_PROPERTY(Mode mode READ mode WRITE setMode NOTIFY modeChanged)
Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged)
Q_PROPERTY(qreal borderRadius READ borderRadius WRITE setBorderRadius NOTIFY borderRadiusChanged)
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
@@ -59,8 +59,15 @@
Q_PROPERTY(qreal centerX READ centerX NOTIFY centerXChanged)
Q_PROPERTY(qreal centerY READ centerY NOTIFY centerYChanged)
Q_PROPERTY(QPoint center READ center NOTIFY centerChanged)
+ Q_ENUMS(Mode)
public:
+ enum Mode {
+ Fill,
+ Stretch,
+ Bottom
+ };
+
BooksCoverWidget(QQuickItem* aParent = NULL);
~BooksCoverWidget();
@@ -82,8 +89,8 @@
BooksBook* book() const { return iBook; }
void setBook(BooksBook* aBook);
- bool stretch() const { return iStretch; }
- void setStretch(bool aValue);
+ Mode mode() const { return iMode; }
+ void setMode(Mode aMode);
bool synchronous() const { return iSynchronous; }
void setSynchronous(bool aValue);
@@ -96,8 +103,8 @@
void bookChanged();
void emptyChanged();
void loadingChanged();
- void stretchChanged();
void synchronousChanged();
+ void modeChanged();
void borderWidthChanged();
void borderRadiusChanged();
void borderColorChanged();
@@ -124,6 +131,8 @@
ScaleTask* iScaleTask;
QImage iScaledImage;
QImage iCoverImage;
+ QColor iBackground1;
+ QColor iBackground2;
BooksBook* iBook;
QImage* iDefaultImage;
qreal iBorderWidth;
@@ -132,7 +141,7 @@
QUrl iDefaultCover;
QString iTitle;
QPoint iCenter;
- bool iStretch;
+ Mode iMode;
bool iSynchronous;
};
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-de.ts
^
|
@@ -126,9 +126,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Bücher</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation type="unfinished">Version %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-es.ts
^
|
@@ -126,9 +126,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Libros</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation type="unfinished">Versión %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-fi.ts
^
|
@@ -126,9 +126,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Kirjat</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation>Versio %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-hu.ts
^
|
@@ -124,9 +124,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Könyvek</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation type="unfinished">%1 verzió</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-nl.ts
^
|
@@ -126,9 +126,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Boeken</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation type="unfinished">Versie %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-pl.ts
^
|
@@ -128,9 +128,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Książki</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation type="unfinished">Wersja %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-pt.ts
^
|
@@ -126,9 +126,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Livros</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation type="unfinished">Versão %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-ru.ts
^
|
@@ -128,9 +128,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Книги</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation>Версия %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-sv.ts
^
|
@@ -126,9 +126,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Böcker</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation type="unfinished">Version %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books-zh_CN.ts
^
|
@@ -124,9 +124,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>书籍</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation type="unfinished">版本 %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/app/translations/harbour-books.ts
^
|
@@ -126,9 +126,14 @@
</message>
<message id="harbour-books-settings-page-header">
<source>Books</source>
- <extracomment>Settings page header</extracomment>
+ <extracomment>Settings page header (app name)</extracomment>
<translation>Books</translation>
</message>
+ <message id="harbour-books-settings-version">
+ <source>Version %1</source>
+ <extracomment>Settings page header description (app version)</extracomment>
+ <translation>Version %1</translation>
+ </message>
<message id="harbour-books-settings-page-display-section_header">
<source>Display</source>
<extracomment>Section header for display settings</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/fbreader/fbreader/fbreader/src/formats/css/StyleSheetTable.cpp
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
- * Copyright (C) 2015 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -330,12 +330,12 @@
entry.setFontSizeMag(-mag);
}
} else if (size > 100) {
- if (size < 120) {
+ if (size <= 120) {
entry.setFontSizeMag(1);
} else {
int mag;
unsigned int x1 = 6*100, x2 = 5*size;
- for (mag=1; mag<=6 && x1<x2; ++mag) {
+ for (mag=1; mag<=6 && 6*x1<5*x2; ++mag) {
x1 *= 6; x2 *= 5;
}
entry.setFontSizeMag(mag);
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/fbreader/fbreader/fbreader/src/formats/oeb/OCFContainerReader.cpp
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2021 Slava Monich <slava.monich@jolla.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@
}
}
}
- /* no break */
+ /* fallthrough */
default:
myStateStack.push(STATE_IGNORE);
break;
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/fbreader/fbreader/zlibrary/text/src/hyphenation/ZLTextHyphenator.h
^
|
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,11 +31,12 @@
private:
ZLTextHyphenationInfo(int length);
- const ZLTextHyphenationInfo &operator = (ZLTextHyphenationInfo &info);
+ const ZLTextHyphenationInfo &operator = (const ZLTextHyphenationInfo &info);
public:
+ ZLTextHyphenationInfo(const ZLTextHyphenationInfo &info) : myMask(info.myMask) { }
~ZLTextHyphenationInfo() {}
- bool isHyphenationPossible(size_t position);
+ bool isHyphenationPossible(size_t position) const;
private:
std::vector<unsigned char> myMask;
@@ -70,7 +72,7 @@
inline ZLTextHyphenationInfo::ZLTextHyphenationInfo(int length) : myMask(length - 1, false) {
}
-inline bool ZLTextHyphenationInfo::isHyphenationPossible(size_t position) {
+inline bool ZLTextHyphenationInfo::isHyphenationPossible(size_t position) const {
return (position < myMask.size()) && myMask[position];
}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/harbour-lib.pro
^
|
@@ -24,14 +24,18 @@
SOURCES += \
src/HarbourBase32.cpp \
+ src/HarbourBase45.cpp \
src/HarbourClipboard.cpp \
+ src/HarbourColorEditorModel.cpp \
src/HarbourDisplayBlanking.cpp \
src/HarbourJson.cpp \
src/HarbourLib.cpp \
src/HarbourMce.cpp \
src/HarbourMediaPlugin.cpp \
+ src/HarbourObject.cpp \
src/HarbourOrganizeListModel.cpp \
src/HarbourPolicyPlugin.cpp \
+ src/HarbourProcessState.cpp \
src/HarbourSelectionListModel.cpp \
src/HarbourSigChildHandler.cpp \
src/HarbourSingleImageProvider.cpp \
@@ -54,14 +58,18 @@
INCLUDEPATH += include
PUBLIC_HEADERS += \
include/HarbourBase32.h \
+ include/HarbourBase45.h \
include/HarbourClipboard.h \
+ include/HarbourColorEditorModel.h \
include/HarbourDebug.h \
include/HarbourDisplayBlanking.h \
include/HarbourJson.h \
include/HarbourLib.h \
include/HarbourMediaPlugin.h \
+ include/HarbourObject.h \
include/HarbourOrganizeListModel.h \
include/HarbourPolicyPlugin.h \
+ include/HarbourProcessState.h \
include/HarbourSelectionListModel.h \
include/HarbourSigChildHandler.h \
include/HarbourSingleImageProvider.h \
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/include/HarbourAztecCodeGenerator.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -39,25 +39,42 @@
class HarbourAztecCodeGenerator : public QObject {
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(int ecLevel READ ecLevel WRITE setEcLevel NOTIFY ecLevelChanged)
Q_PROPERTY(QString code READ code NOTIFY codeChanged)
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
+ Q_ENUMS(ECLevel)
public:
+ enum ECLevel {
+ ECLevelDefault = -1,
+ ECLevelLowest = 5,
+ ECLevelLow = 10,
+ ECLevelMedium = 23,
+ ECLevelHigh = 36,
+ ECLevelVeryHigh = 50,
+ ECLevelHighest = 95,
+ ECLevelCount
+ };
+
HarbourAztecCodeGenerator(QObject* aParent = Q_NULLPTR);
QString text() const;
void setText(QString aValue);
+ int ecLevel() const;
+ void setEcLevel(int aValue);
+
QString code() const;
bool running() const;
- static QByteArray generate(QString aText);
+ static QByteArray generate(QString aText, int aEcLevel = ECLevelDefault);
// Callback for qmlRegisterSingletonType<HarbourAztecCodeGenerator>
static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
Q_SIGNALS:
void textChanged();
+ void ecLevelChanged();
void codeChanged();
void runningChanged();
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/include/HarbourBase32.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -31,8 +31,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef HARBOUR_IMAGE_BASE32_H
-#define HARBOUR_IMAGE_BASE32_H
+#ifndef HARBOUR_BASE32_H
+#define HARBOUR_BASE32_H
#include <QString>
#include <QByteArray>
@@ -46,4 +46,4 @@
static bool isValidBase32(QString aBase32);
};
-#endif // HARBOUR_IMAGE_BASE32_H
+#endif // HARBOUR_BASE32_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/include/HarbourBase45.h
^
|
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_BASE45_H
+#define HARBOUR_BASE45_H
+
+#include <QString>
+#include <QByteArray>
+
+class HarbourBase45 {
+ class Private;
+ HarbourBase45();
+public:
+ static bool isValidBase45(QString aBase45);
+ static QByteArray fromBase45(QString aBase45);
+ static QString toBase45(QByteArray aBinary);
+};
+
+#endif // HARBOUR_BASE45_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/include/HarbourColorEditorModel.h
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_COLOR_EDITOR_MODEL_H
+#define HARBOUR_COLOR_EDITOR_MODEL_H
+
+#include <QList>
+#include <QColor>
+#include <QAbstractListModel>
+
+class HarbourColorEditorModel : public QAbstractListModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList colors READ getColors WRITE setColors NOTIFY colorsChanged)
+ Q_PROPERTY(int dragPos READ getDragPos WRITE setDragPos NOTIFY dragPosChanged)
+ Q_ENUMS(ItemType)
+
+public:
+ enum ItemType {
+ ColorItem,
+ TrashedItem,
+ AddItem
+ };
+
+ HarbourColorEditorModel(QObject* aParent = Q_NULLPTR);
+
+ QStringList getColors() const;
+ void setColors(QStringList aColors);
+
+ int getDragPos() const;
+ void setDragPos(int pos);
+
+ Q_INVOKABLE void addColor(QColor aColor);
+ Q_INVOKABLE int indexOf(QColor aColor) const;
+
+ // QAbstractListModel
+ QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE;
+ int rowCount(const QModelIndex& aParent) const Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex& aIndex, int aRole) const Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void colorsChanged();
+ void dragPosChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_COLOR_EDITOR_MODEL_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/include/HarbourObject.h
^
|
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#ifndef HARBOUR_OBJECT_H
+#define HARBOUR_OBJECT_H
+
+#include <QObject>
+#include <QList>
+#include <QQmlListProperty>
+
+// Fixes the "Cannot assign to non-existent default property" problem
+// with QtObject in QML.
+class HarbourObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<QObject> children READ children)
+ Q_CLASSINFO("DefaultProperty", "children")
+
+public:
+ HarbourObject(QObject* aParent = Q_NULLPTR);
+
+ QQmlListProperty<QObject> children();
+
+private:
+ QList<QObject*> iChidren;
+};
+
+#endif // HARBOUR_OBJECT_H
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/include/HarbourProcessState.h
^
|
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_PROCESS_STATE_H
+#define HARBOUR_PROCESS_STATE_H
+
+#include <QObject>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourProcessState: public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HarbourProcessState)
+ Q_PROPERTY(bool jailedApp READ isJailedApp CONSTANT)
+ Q_PROPERTY(bool privileged READ isPrivileged CONSTANT)
+
+public:
+ explicit HarbourProcessState(QObject* aParent = Q_NULLPTR);
+
+ // Callback for qmlRegisterSingletonType<HarbourProcessState>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ static bool isJailedApp();
+ static bool isPrivileged();
+};
+
+#endif // HARBOUR_PROCESS_STATE_H
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/include/HarbourQrCodeGenerator.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -39,26 +39,43 @@
class HarbourQrCodeGenerator : public QObject {
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(int ecLevel READ ecLevel WRITE setEcLevel NOTIFY ecLevelChanged)
Q_PROPERTY(QString code READ code NOTIFY codeChanged)
Q_PROPERTY(QString qrcode READ code NOTIFY codeChanged)
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
+ Q_ENUMS(ECLevel)
public:
+ enum ECLevel {
+ ECLevelDefault = -1,
+ ECLevelLowest = 0,
+ ECLevel_L = ECLevelLowest,
+ ECLevel_M,
+ ECLevel_Q,
+ ECLevel_H,
+ ECLevelHighest = ECLevel_H,
+ ECLevelCount
+ };
+
HarbourQrCodeGenerator(QObject* aParent = Q_NULLPTR);
QString text() const;
void setText(QString aValue);
+ ECLevel ecLevel() const;
+ void setEcLevel(int aValue);
+
QString code() const;
bool running() const;
- static QByteArray generate(QString aText);
+ static QByteArray generate(QString aText, ECLevel aEcLevel = ECLevelDefault);
// Callback for qmlRegisterSingletonType<HarbourQrCodeGenerator>
static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
Q_SIGNALS:
void textChanged();
+ void ecLevelChanged();
void codeChanged();
void runningChanged();
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/include/HarbourSystemInfo.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2020 Jolla Ltd.
- * Copyright (C) 2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2020-2021 Jolla Ltd.
+ * Copyright (C) 2020-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -61,7 +61,11 @@
QString osName() const;
QString osVersion() const;
+ Q_INVOKABLE QString packageVersion(QString aPackage);
Q_INVOKABLE int osVersionCompare(QString aVersion);
+ Q_INVOKABLE static int compareVersions(QString aVersion1, QString aVersion2);
+
+ static QString queryPackageVersion(QString aVersion);
static int osVersionCompareWith(QString aVersion);
private:
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/qml/HarbourColorEditorDialog.qml
^
|
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Dialog {
+ id: thisDialog
+
+ readonly property color selectedColor: sampleItem.color
+ property color initialColor: Theme.highlightColor
+ property string acceptText: "Add color"
+ property alias hueSliderText: hueSlider.label // "Color"
+ property alias brightnessSliderText: brightnessSlider.label // "Brightness"
+ property string hexNotationText: "Hex notation"
+
+ canAccept: hexText.acceptableInput
+ forwardNavigation: !hueItem.pressed
+ backNavigation: !hueItem.pressed
+
+ DialogHeader {
+ id: header
+
+ acceptText: forwardNavigation ?
+ (thisDialog.acceptText ? thisDialog.acceptText : defaultAcceptText) : ""
+ }
+
+ Component.onCompleted: hexText.text = initialColor.toString().substr(1)
+
+ // Otherwise width is changing with a delay, causing visible layout changes
+ onIsLandscapeChanged: width = isLandscape ? Screen.height : Screen.width
+
+ SilicaFlickable {
+ clip: true
+ interactive: !hueItem.pressed
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: header.bottom
+ bottom: parent.bottom
+ }
+
+ HarbourColorHueItem {
+ id: hueItem
+
+ x: Theme.horizontalPageMargin
+ width: parent.width - 2 * x
+ anchors {
+ top: parent.top
+ bottom: toolPanel.top
+ bottomMargin: Theme.paddingSmall
+ }
+ brightness: brightnessSlider.sliderValue
+ onTapped: hueSlider.value = h
+ }
+
+ Column {
+ id: toolPanel
+
+ width: parent.width
+ anchors.bottom: parent.bottom
+
+ Slider {
+ id: hueSlider
+
+ width: parent.width
+ leftMargin: Theme.horizontalPageMargin
+ rightMargin: Theme.horizontalPageMargin
+ minimumValue: 0
+ maximumValue: 1
+ value: 1
+ label: "Color"
+ opacity: (y + parent.y >= 0) ? 1 : 0
+ onSliderValueChanged: hexText.updateText()
+ }
+
+ Slider {
+ id: brightnessSlider
+
+ width: parent.width
+ leftMargin: Theme.horizontalPageMargin
+ rightMargin: Theme.horizontalPageMargin
+ label: "Brightness"
+ minimumValue: 0
+ maximumValue: 1
+ value: 1
+ opacity: (y + parent.y >= 0) ? 1 : 0
+ onSliderValueChanged: hexText.updateText()
+ }
+
+ Item {
+ x: Theme.horizontalPageMargin
+ width: parent.width - 2 * x
+ height: hexText.height
+ Row {
+ spacing: Theme.paddingSmall
+
+ Label {
+ id: hexLabel
+
+ y: hexText.textTopMargin
+ text: "#"
+ font.pixelSize: Theme.fontSizeLarge
+ }
+
+ Item {
+ readonly property int maxWidth: toolPanel.width - 2 * Theme.horizontalPageMargin - hexLabel.width - parent.spacing - Theme.paddingLarge - sample.width
+ width: Math.min(Math.max(textLabelTemplate.implicitWidth, Theme.itemSizeHuge), maxWidth)
+ height: hexText.height
+
+ Label {
+ id: textLabelTemplate
+
+ // Same text as hexText.label
+ text: hexNotationText
+ font.pixelSize: Theme.fontSizeSmall
+ opacity: 0
+ }
+
+ TextField {
+ id: hexText
+
+ property int ignoreTextUpdates // to avoid binding loops
+ property color tmpColor
+
+ font.pixelSize: Theme.fontSizeLarge
+ width: parent.width
+ textLeftMargin: 0
+ textRightMargin: 0
+ label: hexNotationText
+ validator: RegExpValidator { regExp: /^[0-9a-fA-F]{6}$/ }
+ inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
+ EnterKey.iconSource: "image://theme/icon-m-enter-close"
+ EnterKey.onClicked: hexText.focus = false
+
+ onTextChanged: {
+ if (!ignoreTextUpdates) {
+ // acceptableInput hasn't been updated yet
+ syncTimer.restart()
+ }
+ }
+
+ onActiveFocusChanged: {
+ if (!activeFocus && !acceptableInput) {
+ updateText()
+ }
+ }
+
+ function syncColor() {
+ if (acceptableInput) {
+ tmpColor = "#" + text
+ ignoreTextUpdates++
+ brightnessSlider.value = hueItem.getV(tmpColor)
+ hueSlider.value = hueItem.getH(tmpColor)
+ ignoreTextUpdates--
+ }
+ }
+
+ function updateText() {
+ if (!ignoreTextUpdates) {
+ ignoreTextUpdates++
+ var s = hueItem.getColor(hueSlider.sliderValue).toString()
+ text = (s.length > 0 && s.charAt(0) === '#') ? s.substr(1) : s
+ ignoreTextUpdates--
+ }
+ }
+
+ Timer {
+ id: syncTimer
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/qml/HarbourColorHueItem.qml
^
|
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Rectangle {
+ id: thisItem
+
+ color: "black"
+
+ property alias brightness: mouseArea.opacity
+ property alias pressed: mouseArea.pressed
+
+ readonly property color color0: "#ffffff" // 1.0
+ readonly property color color1: "#ff0000" // colorStop7
+ readonly property color color2: "#ff00ff" // colorStop6
+ readonly property color color3: "#0000ff" // colorStop5
+ readonly property color color4: "#00ffff" // colorStop4
+ readonly property color color5: "#00ff00" // colorStop3
+ readonly property color color6: "#ffff00" // colorStop2
+ readonly property color color7: "#ff0000" // colorStop1
+ readonly property color color8: "#ffffff" // 0.0
+
+ readonly property real colorStop1: 0.125
+ readonly property real colorStop2: 0.250
+ readonly property real colorStop3: 0.375
+ readonly property real colorStop4: 0.500
+ readonly property real colorStop5: 0.625
+ readonly property real colorStop6: 0.750
+ readonly property real colorStop7: 0.875
+ readonly property real hueLast: colorStop7
+ readonly property real hueRange: hueLast - colorStop1
+
+ signal tapped(var h)
+
+ function getColor(h) {
+ if (h < colorStop4) {
+ if (h > colorStop3) {
+ // colorStop3..colorStop4
+ return averageColor(color3, color4, (h - colorStop3)/(colorStop4 - colorStop3), brightness)
+ } else if (h > colorStop2) {
+ // colorStop2..colorStop3
+ return averageColor(color2, color3, (h - colorStop2)/(colorStop3 - colorStop2), brightness)
+ } else if (h > colorStop1) {
+ // colorStop1..colorStop2
+ return averageColor(color1, color2, (h - colorStop1)/(colorStop2 - colorStop1), brightness)
+ } else if (h > 0) {
+ // 0..colorStop1
+ return averageColor(color0, color1, h/colorStop1, brightness)
+ } else {
+ return adjustColor(color0, brightness)
+ }
+ } else {
+ if (h < colorStop5) {
+ // colorStop4..colorStop5
+ return averageColor(color4, color5, (h - colorStop4)/(colorStop5 - colorStop4), brightness)
+ } else if (h < colorStop6) {
+ // colorStop5..colorStop6
+ return averageColor(color5, color6, (h - colorStop5)/(colorStop6 - colorStop5), brightness)
+ } else if (h < colorStop7) {
+ // colorStop6..colorStop7
+ return averageColor(color6, color7, (h - colorStop6)/(colorStop7 - colorStop6), brightness)
+ } else if (h < 1) {
+ // colorStop7..1
+ return averageColor(color7, color8, (h - colorStop7)/(1 - colorStop7), brightness)
+ } else {
+ return adjustColor(color8, brightness)
+ }
+ }
+ }
+
+ function averageColor(c1,c2,h,v) {
+ return Qt.rgba((c1.r + (c2.r - c1.r) * h) * v,
+ (c1.g + (c2.g - c1.g) * h) * v,
+ (c1.b + (c2.b - c1.b) * h) * v, 1)
+ }
+
+ function adjustColor(c,v) {
+ return Qt.rgba(c.r * v, c.g * v, c.b * v, 1)
+ }
+
+ function getV(c) {
+ return Math.max(c.r, c.g, c.b)
+ }
+
+ function getH(c) {
+ var max = Math.max(c.r, c.g, c.b)
+ var min = Math.min(c.r, c.g, c.b)
+ var chroma = max - min
+ if (chroma === 0) {
+ return 0
+ } else {
+ if (max === c.r) {
+ return hueLast - (c.g - c.b)/chroma/6 * hueRange
+ } else if (max === c.g) {
+ return hueLast - (2 + (c.b - c.r)/chroma)/6 * hueRange
+ } else {
+ return hueLast - (4 + (c.r - c.g)/chroma)/6 * hueRange
+ }
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+
+ width: parent.height
+ height: parent.width
+ anchors.centerIn: parent
+ rotation: -90
+
+ ShaderEffectSource {
+ anchors.fill: parent
+ sourceItem: Rectangle {
+ width: mouseArea.width
+ height: mouseArea.height
+ radius: Theme.paddingSmall
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: color0 }
+ GradientStop { position: colorStop1; color: color1 }
+ GradientStop { position: colorStop2; color: color2 }
+ GradientStop { position: colorStop3; color: color3 }
+ GradientStop { position: colorStop4; color: color4 }
+ GradientStop { position: colorStop5; color: color5 }
+ GradientStop { position: colorStop6; color: color6 }
+ GradientStop { position: colorStop7; color: color7 }
+ GradientStop { position: 1.0; color: color8 }
+ }
+ }
+ }
+ // mouseY/height because we are rotated
+ onClicked: thisItem.tapped(mouseY/height)
+ onPositionChanged: thisItem.tapped(mouseY/height)
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/qml/HarbourColorPickerDialog.qml
^
|
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Dialog {
+ id: thisDialog
+
+ property color color
+ property alias colorModel: grid.model // HarbourColorEditorModel
+
+ // Localizable strings
+ property alias resetColorsMenuText: resetColorsMenuItem.text // "Reset colors"
+ property string acceptText: "Select color"
+ property string addColorAcceptText: "Add color"
+ property string addColorHueSliderText: "Color"
+ property string addColorBrightnessSliderText: "Brightness"
+ property string addColorHexNotationText: "Hex notation"
+
+ forwardNavigation: false
+
+ signal resetColors()
+
+ // Constants used by HarbourColorEditorModel
+ readonly property int itemTypeColor: 0
+ readonly property int itemTypeTrash: 1
+ readonly property int itemTypeAdd: 2
+
+ SilicaGridView {
+ id: grid
+
+ cellWidth: Math.floor(width/cellsPerRow)
+ cellHeight: cellWidth
+ anchors.fill: parent
+
+ VerticalScrollDecorator {}
+
+ PullDownMenu {
+ MenuItem {
+ id: resetColorsMenuItem
+
+ text: "Reset colors"
+ onClicked: thisDialog.resetColors()
+ }
+ }
+
+ property Item dragItem
+ property int pageHeaderHeight
+ readonly property int cellsPerRow: Math.floor(width / Theme.itemSizeHuge)
+
+ header: DialogHeader {
+ dialog: thisDialog
+ acceptText: thisDialog.acceptText
+ spacing: 0
+ Component.onCompleted: grid.pageHeaderHeight = height
+ onHeightChanged: grid.pageHeaderHeight = height
+ }
+
+ delegate: MouseArea {
+ id: colorDelegate
+
+ width: grid.cellWidth
+ height: grid.cellHeight
+
+ drag.target: dragging ? colorItem : null
+ drag.axis: Drag.XandYAxis
+
+ readonly property bool highlighted: (pressed && containsMouse)
+ readonly property bool dragging: grid.dragItem === colorDelegate
+ readonly property int index: model.index
+
+ Rectangle {
+ id: colorItem
+
+ width: grid.cellWidth
+ height: grid.cellHeight
+ color: model.color
+ scale: !colorDelegate.dragging ? 1 : isTrashed ? 0.8 : 1.1
+ opacity: isTrashed ? 0.8 : 1
+ layer.enabled: colorDelegate.highlighted || colorDelegate.dragging || scale > 1
+ layer.effect: HarbourPressEffect { source: colorItem }
+
+ readonly property bool isTrashed: model.itemType === itemTypeTrash
+ property real returnX
+ property real returnY
+ property bool snappingBack
+
+ Behavior on opacity { FadeAnimation { } }
+ Behavior on scale {
+ NumberAnimation {
+ easing.type: Easing.InQuad
+ duration: 150
+ }
+ }
+
+ Image {
+ anchors.centerIn: parent
+ source: opacity ? ("image://theme/graphic-close-app?" + deriveColor(model.color)) : ""
+ sourceSize: Qt.size(Theme.iconSizeLarge, Theme.iconSizeLarge)
+ opacity: (model.itemType === itemTypeTrash) ? 0.8 : 0
+ visible: opacity > 0
+ Behavior on opacity { FadeAnimation { } }
+
+ function deriveColor(color) {
+ var gray = 0.299 * color.r + 0.587 * color.g + 0.114 *color.b
+ var v = (gray > 0.5) ? 0 : 1
+ return Qt.rgba(v, v, v, color.a)
+ }
+ }
+
+ states: [
+ State {
+ name: "dragging"
+ when: colorDelegate.dragging
+ ParentChange {
+ target: colorItem
+ parent: grid
+ x: colorDelegate.mapToItem(grid, 0, 0).x
+ y: colorDelegate.mapToItem(grid, 0, 0).y
+ }
+ },
+ State {
+ name: "snappingBack"
+ when: !colorDelegate.dragging && colorItem.snappingBack
+ ParentChange {
+ target: colorItem
+ parent: grid
+ x: colorItem.returnX
+ y: colorItem.returnY
+ }
+ },
+ State {
+ name: "idle"
+ when: !colorDelegate.dragging && !colorItem.snappingBack
+ ParentChange {
+ target: colorItem
+ parent: colorDelegate
+ x: 0
+ y: 0
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ to: "snappingBack"
+ SequentialAnimation {
+ SmoothedAnimation {
+ properties: "x,y"
+ duration: 150
+ }
+ ScriptAction { script: colorItem.snappingBack = false }
+ }
+ },
+ Transition {
+ to: "idle"
+ ScriptAction { script: colorModel.dragPos = -1 }
+ }
+ ]
+
+ Connections {
+ target: colorDelegate.dragging ? colorItem : null
+ onXChanged: colorItem.updateDragPos()
+ onYChanged: colorItem.scrollAndUpdateDragPos()
+ }
+
+ Connections {
+ target: colorDelegate.dragging ? grid : null
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/src/HarbourAztecCodeGenerator.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -48,22 +48,25 @@
class HarbourAztecCodeGenerator::Task : public HarbourTask {
Q_OBJECT
public:
- Task(QThreadPool* aPool, QString aText);
+ Task(QThreadPool* aPool, QString aText, int aEcLevel);
void performTask() Q_DECL_OVERRIDE;
public:
QString iText;
QString iCode;
+ int iEcLevel;
};
-HarbourAztecCodeGenerator::Task::Task(QThreadPool* aPool, QString aText) :
+HarbourAztecCodeGenerator::Task::Task(QThreadPool* aPool, QString aText,
+ int aEcLevel) :
HarbourTask(aPool),
- iText(aText)
+ iText(aText),
+ iEcLevel(aEcLevel)
{
}
void HarbourAztecCodeGenerator::Task::performTask()
{
- QByteArray bytes(generate(iText));
+ QByteArray bytes(generate(iText, iEcLevel));
if (!bytes.isEmpty()) {
iCode = HarbourBase32::toBase32(bytes);
}
@@ -82,6 +85,10 @@
HarbourAztecCodeGenerator* parentObject() const;
void setText(QString aValue);
+ void setEcLevel(int aValue);
+ void regenerate();
+
+ static int realEcLevel(int aEcLevel);
public Q_SLOTS:
void onTaskDone();
@@ -89,6 +96,7 @@
public:
QThreadPool* iThreadPool;
Task* iTask;
+ int iEcLevel;
QString iText;
QString iCode;
};
@@ -96,7 +104,8 @@
HarbourAztecCodeGenerator::Private::Private(HarbourAztecCodeGenerator* aParent) :
QObject(aParent),
iThreadPool(new QThreadPool(this)),
- iTask(Q_NULLPTR)
+ iTask(Q_NULLPTR),
+ iEcLevel(ECLevelDefault)
{
// Serialize the tasks:
iThreadPool->setMaxThreadCount(1);
@@ -112,19 +121,45 @@
return qobject_cast<HarbourAztecCodeGenerator*>(parent());
}
+int HarbourAztecCodeGenerator::Private::realEcLevel(int aEcLevel)
+{
+ return (aEcLevel == ECLevelDefault) ? AZTEC_CORRECTION_DEFAULT :
+ (aEcLevel < ECLevelLowest) ? ECLevelLowest :
+ (aEcLevel > ECLevelHighest) ? ECLevelHighest :
+ aEcLevel;
+}
+
void HarbourAztecCodeGenerator::Private::setText(QString aText)
{
if (iText != aText) {
iText = aText;
- HarbourAztecCodeGenerator* obj = parentObject();
- const bool wasRunning = (iTask != Q_NULLPTR);
- if (iTask) iTask->release(this);
- iTask = new Task(iThreadPool, aText);
- iTask->submit(this, SLOT(onTaskDone()));
- Q_EMIT obj->textChanged();
- if (!wasRunning) {
- Q_EMIT obj->runningChanged();
+ regenerate();
+ Q_EMIT parentObject()->textChanged();
+ }
+}
+
+void HarbourAztecCodeGenerator::Private::setEcLevel(int aValue)
+{
+ const int level = (aValue == ECLevelDefault) ? ECLevelDefault : realEcLevel(aValue);
+ if (iEcLevel != level) {
+ const int prevRealLevel = realEcLevel(iEcLevel);
+ iEcLevel = level;
+ HDEBUG(level);
+ if (realEcLevel(level) != prevRealLevel) {
+ regenerate();
}
+ Q_EMIT parentObject()->ecLevelChanged();
+ }
+}
+
+void HarbourAztecCodeGenerator::Private::regenerate()
+{
+ const bool wasRunning = (iTask != Q_NULLPTR);
+ if (iTask) iTask->release(this);
+ iTask = new Task(iThreadPool, iText, iEcLevel);
+ iTask->submit(this, SLOT(onTaskDone()));
+ if (!wasRunning) {
+ Q_EMIT parentObject()->runningChanged();
}
}
@@ -169,6 +204,16 @@
iPrivate->setText(aValue);
}
+int HarbourAztecCodeGenerator::ecLevel() const
+{
+ return iPrivate->iEcLevel;
+}
+
+void HarbourAztecCodeGenerator::setEcLevel(int aValue)
+{
+ iPrivate->setEcLevel(aValue);
+}
+
QString HarbourAztecCodeGenerator::code() const
{
return iPrivate->iCode;
@@ -179,12 +224,12 @@
return iPrivate->iTask != Q_NULLPTR;
}
-QByteArray HarbourAztecCodeGenerator::generate(QString aText)
+QByteArray HarbourAztecCodeGenerator::generate(QString aText, int aEcLevel)
{
HDEBUG(aText);
QByteArray in(aText.toUtf8()), out;
AztecSymbol* aztec = aztec_encode_inv(in.constData(), in.size(),
- AZTEC_CORRECTION_DEFAULT);
+ Private::realEcLevel(aEcLevel));
if (aztec) {
const int bytesPerRow = (aztec->size + 7) / 8;
out.reserve(bytesPerRow * aztec->size);
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/src/HarbourBase45.cpp
^
|
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourBase45.h"
+
+#include "HarbourDebug.h"
+
+// ==========================================================================
+// HarbourBase45::Private
+// ==========================================================================
+
+class HarbourBase45::Private {
+public:
+ enum {
+ BASE = 45,
+ BASE2 = BASE * BASE,
+ REVERSE_MAP_SIZE = 91
+ };
+ static const char mapBase45[BASE];
+ static const int reverseMapBase45[REVERSE_MAP_SIZE];
+ static bool isValidChar(uint x);
+};
+
+const char HarbourBase45::Private::mapBase45[HarbourBase45::Private::BASE] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
+ 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+ 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
+ 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*',
+ '+', '-', '.', '/', ':'
+};
+
+const int HarbourBase45::Private::reverseMapBase45[HarbourBase45::Private::REVERSE_MAP_SIZE] = {
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ 36, -1, -1, -1, 37, 38, -1, -1,
+ -1, -1, 39, 40, -1, 41, 42, 43,
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 44, -1, -1, -1, -1, -1,
+ -1, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35
+};
+
+inline bool HarbourBase45::Private::isValidChar(uint x)
+{
+ return (x < Private::REVERSE_MAP_SIZE) && Private::reverseMapBase45[x] >= 0;
+}
+
+// ==========================================================================
+// HarbourBase45::Private
+// ==========================================================================
+
+bool HarbourBase45::isValidBase45(QString aBase45)
+{
+ const int len = aBase45.length();
+
+ if (!((len % 3) % 2)) {
+ const QChar* chars = aBase45.constData();
+ int i = 0;
+
+ while ((i + 2) < len) {
+ const uint c = chars[i++].unicode();
+ const uint d = chars[i++].unicode();
+ const uint e = chars[i++].unicode();
+
+ if (!Private::isValidChar(c) ||
+ !Private::isValidChar(d) ||
+ !Private::isValidChar(e) ||
+ (Private::reverseMapBase45[c] +
+ Private::reverseMapBase45[d] * Private::BASE +
+ Private::reverseMapBase45[e] * Private::BASE2) > 0xffff) {
+ return false;
+ }
+ }
+
+ if (i < len) {
+ const uint c = chars[i++].unicode();
+ const uint d = chars[i++].unicode();
+
+ if (!Private::isValidChar(c) ||
+ !Private::isValidChar(d) ||
+ (Private::reverseMapBase45[c] +
+ Private::reverseMapBase45[d] * Private::BASE) > 0xff) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+QByteArray HarbourBase45::fromBase45(QString aBase45)
+{
+ QByteArray out;
+ const int len = aBase45.length();
+ const int tail = (len % 3);
+
+ if (!(tail % 2)) {
+ const QChar* chars = aBase45.constData();
+ int i = 0;
+
+ out.reserve(len/3*2 + tail/2);
+ while ((i + 2) < len) {
+ const uint c = chars[i++].unicode();
+ const uint d = chars[i++].unicode();
+ const uint e = chars[i++].unicode();
+
+ if (!Private::isValidChar(c) ||
+ !Private::isValidChar(d) ||
+ !Private::isValidChar(e)) {
+ return QByteArray();
+ }
+ const uint n = Private::reverseMapBase45[c] +
+ Private::reverseMapBase45[d] * Private::BASE +
+ Private::reverseMapBase45[e] * Private::BASE2;
+ if (n > 0xffff) {
+ return QByteArray();
+ }
+ char ab[2];
+ ab[0] = (char)(n >> 8);
+ ab[1] = (char)n;
+ out.append(ab, sizeof(ab));
+ }
+
+ if (i < len) {
+ const uint c = chars[i++].unicode();
+ const uint d = chars[i++].unicode();
+
+ if (!Private::isValidChar(c) ||
+ !Private::isValidChar(d)) {
+ return QByteArray();
+ }
+ const uint a = Private::reverseMapBase45[c] +
+ Private::reverseMapBase45[d] * Private::BASE;
+ if (a > 0xff) {
+ return QByteArray();
+ }
+ out.append((char)a);
+ }
+ }
+ return out;
+}
+
+QString HarbourBase45::toBase45(QByteArray aBinary)
+{
+ const uchar* ptr = (uchar*)aBinary.constData();
+ const int n = aBinary.size();
+ int i;
+
+ QString str;
+ str.reserve(3 * (n / 2) + 2 * (n % 2));
+ for (i = 0; (i + 1) < n; i += 2) {
+ uint e = (uint)(ptr[i]) * 256 + ptr[i+1];
+ const uchar c = (uchar)(e % Private::BASE);
+ e = (e - c)/Private::BASE;
+ const uchar d = (uchar)(e % Private::BASE);
+ e = (e - d)/Private::BASE;
+ str.append(QChar::fromLatin1(Private::mapBase45[c]));
+ str.append(QChar::fromLatin1(Private::mapBase45[d]));
+ str.append(QChar::fromLatin1(Private::mapBase45[e]));
+ }
+ if (i < n) {
+ uchar d = ptr[i];
+ const uchar c = d % Private::BASE;
+ d = (d - c)/Private::BASE;
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/src/HarbourColorEditorModel.cpp
^
|
@@ -0,0 +1,298 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourColorEditorModel.h"
+#include "HarbourDebug.h"
+
+// ==========================================================================
+// HarbourColorEditorModel::Private
+// ==========================================================================
+
+class HarbourColorEditorModel::Private
+{
+public:
+ enum ModelRole {
+ ColorRole = Qt::UserRole,
+ ItemTypeRole
+ };
+
+ Private();
+
+ bool resetDragPos();
+ QStringList getColors() const;
+ QList<QColor> makeColors(const QStringList& aColors, bool* aChanged) const;
+ QVariant data(int aRow, ModelRole aRole) const;
+
+public:
+ int iDragPos;
+ int iDragStartPos;
+ QList<QColor> iColors;
+ const QColor iAddColor;
+};
+
+HarbourColorEditorModel::Private::Private() :
+ iDragPos(-1),
+ iDragStartPos(-1),
+ iAddColor(0, 0, 0, 0)
+{
+}
+
+bool HarbourColorEditorModel::Private::resetDragPos()
+{
+ if (iDragPos >= 0) {
+ iDragPos = -1;
+ iDragStartPos = -1;
+ return true;
+ } else {
+ return false;
+ }
+}
+
+QStringList HarbourColorEditorModel::Private::getColors() const
+{
+ const int n = iColors.count();
+ QStringList colors;
+ colors.reserve(n);
+ for (int i = 0; i < n; i++) {
+ colors.append(iColors.at(i).name());
+ }
+ return colors;
+}
+
+QList<QColor> HarbourColorEditorModel::Private::makeColors(const QStringList& aColors, bool* aChanged) const
+{
+ const int n = aColors.count();
+ *aChanged = iColors.count() != n;
+ QList<QColor> newColors;
+ newColors.reserve(n);
+ for (int i = 0; i < n; i++) {
+ const QColor c(aColors.at(i));
+ newColors.append(c);
+ if (!*aChanged && iColors.at(i) != c) {
+ *aChanged = true;
+ }
+ }
+ return newColors;
+}
+
+QVariant HarbourColorEditorModel::Private::data(int aRow, ModelRole aRole) const
+{
+ const int n = iColors.count();
+ if (aRow >= 0 && aRow <= n) {
+ switch (aRole) {
+ case ColorRole:
+ if (iDragPos >= 0) {
+ if (aRow == iDragPos) {
+ // This includes the item dragged outside
+ return iColors.at(iDragStartPos);
+ } else {
+ if (iDragPos == n && aRow == (n - 1)) {
+ // When item is dragged outside, it becomes
+ // the last one and shifts the "add" item.
+ return iAddColor;
+ } else if (aRow >= iDragStartPos && aRow < iDragPos) {
+ return iColors.at(aRow + 1);
+ } else if (aRow > iDragPos && aRow <= iDragStartPos) {
+ return iColors.at(aRow - 1);
+ }
+ }
+ }
+ return (aRow == n) ? iAddColor : iColors.at(aRow);
+ case ItemTypeRole:
+ if (iDragPos == n) {
+ // Item is dragged outside
+ return (aRow == n) ? TrashedItem :
+ (aRow == (n - 1)) ? AddItem : ColorItem;
+ } else {
+ return (aRow == n) ? AddItem : ColorItem;
+ }
+ }
+ }
+ return QVariant();
+}
+
+// ==========================================================================
+// HarbourColorEditorModel::Private
+// ==========================================================================
+
+HarbourColorEditorModel::HarbourColorEditorModel(QObject* aParent) :
+ QAbstractListModel(aParent),
+ iPrivate(new Private)
+{
+}
+
+QHash<int,QByteArray> HarbourColorEditorModel::roleNames() const
+{
+ QHash<int,QByteArray> roles;
+ roles.insert(Private::ColorRole, "color");
+ roles.insert(Private::ItemTypeRole, "itemType");
+ return roles;
+}
+
+int HarbourColorEditorModel::rowCount(const QModelIndex&) const
+{
+ return iPrivate->iColors.count() + 1;
+}
+
+QVariant HarbourColorEditorModel::data(const QModelIndex& aIndex, int aRole) const
+{
+ return iPrivate->data(aIndex.row(), (Private::ModelRole)aRole);
+}
+
+QStringList HarbourColorEditorModel::getColors() const
+{
+ return iPrivate->getColors();
+}
+
+void HarbourColorEditorModel::setColors(QStringList aColors)
+{
+ bool changed;
+ const QList<QColor> prevColors(iPrivate->iColors);
+ const QList<QColor> newColors(iPrivate->makeColors(aColors, &changed));
+ if (changed) {
+ const int prevCount = prevColors.count();
+ const int newCount = newColors.count();
+ const QVector<int> colorRole(1, Private::ColorRole);
+ if (newCount < prevCount) {
+ beginRemoveRows(QModelIndex(), newCount + 1, prevCount);
+ iPrivate->iColors = newColors;
+ endRemoveRows();
+ } else if (newCount > prevCount) {
+ beginInsertRows(QModelIndex(), prevCount + 1, newCount);
+ iPrivate->iColors = newColors;
+ endInsertRows();
+ } else {
+ iPrivate->iColors = newColors;
+ }
+ // Change the colors
+ int rangeStart = -1;
+ const int n = qMin(prevCount, newCount);
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/src/HarbourObject.cpp
^
|
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "HarbourObject.h"
+
+HarbourObject::HarbourObject(QObject* aParent) :
+ QObject(aParent)
+{
+}
+
+QQmlListProperty<QObject> HarbourObject::children()
+{
+ return QQmlListProperty<QObject>(this, iChidren);
+}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/src/HarbourPluginLoader.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2017-2020 Jolla Ltd.
- * Copyright (C) 2017-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2017-2021 Jolla Ltd.
+ * Copyright (C) 2017-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -78,6 +78,24 @@
// sym,ret,name,args
#define QMLTYPE_FUNCTIONS(f) \
+ f("_ZN12QQmlMetaType7qmlTypeERK7QStringii", \
+ QQmlType*, qmlType, (QString const&, int, int)) \
+ f("_ZNK8QQmlType23propertyValueSourceCastEv", \
+ int, propertyValueSourceCast, (QQmlType*)) \
+ f("_ZNK8QQmlType10createSizeEv", \
+ int, createSize, (QQmlType*)) \
+ f("_ZNK8QQmlType10metaObjectEv", \
+ const QMetaObject*, metaObject, (QQmlType*)) \
+ f("_ZNK8QQmlType16parserStatusCastEv", \
+ int, parserStatusCast, (QQmlType*)) \
+ f("_ZNK8QQmlType28propertyValueInterceptorCastEv", \
+ int, propertyValueInterceptorCast, (QQmlType*)) \
+ f("_ZNK8QQmlType6typeIdEv", \
+ int, typeId, (QQmlType*)) \
+ f("_ZNK8QQmlType14createFunctionEv", \
+ QQmlType::CreateFunc, createFunction, (QQmlType*)) \
+ f("_ZNK8QQmlType11qListTypeIdEv", \
+ int, qListTypeId, (QQmlType*)) \
f("_ZNK8QQmlType26attachedPropertiesFunctionEv", \
QQmlAttachedPropertiesFunc, AttachedPropertiesFunctionProc,(QQmlType*)) \
f("_ZNK8QQmlType22attachedPropertiesTypeEv", \
@@ -100,8 +118,8 @@
int parserStatusCast() const;
int propertyValueSourceCast() const;
int propertyValueInterceptorCast() const;
- QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const;
- const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const;
+ // attachedPropertiesFunction
+ // attachedPropertiesType
};
// PRIVATE QT API!
@@ -219,8 +237,10 @@
HarbourPluginLoader::Private::qmlType(
QString aName)
{
- QString fullName(iModule + '/' + aName);
- QQmlType* type = QQmlMetaType::qmlType(fullName, iMajor, iMinor);
+ const QString fullName(iModule + '/' + aName);
+ QQmlType* type = gLibQt5Qml.iSym.fn.qmlType ?
+ gLibQt5Qml.iSym.fn.qmlType(fullName, iMajor, iMinor) :
+ Q_NULLPTR;
if (!type) {
HWARN("Failed to load" << fullName);
}
@@ -259,7 +279,15 @@
int aMajor,
int aMinor)
{
- if (aType && iEngine) {
+ if (aType && iEngine &&
+ gLibQt5Qml.iSym.fn.typeId &&
+ gLibQt5Qml.iSym.fn.qListTypeId &&
+ gLibQt5Qml.iSym.fn.createSize &&
+ gLibQt5Qml.iSym.fn.createFunction &&
+ gLibQt5Qml.iSym.fn.metaObject &&
+ gLibQt5Qml.iSym.fn.parserStatusCast &&
+ gLibQt5Qml.iSym.fn.propertyValueSourceCast &&
+ gLibQt5Qml.iSym.fn.propertyValueInterceptorCast) {
// Get around the ABI break in Qt 5.6
QQmlAttachedPropertiesFunc attachedPropertiesFunction =
gLibQt5Qml.iSym.fn.AttachedPropertiesFunctionProc ?
@@ -275,21 +303,21 @@
NULL;
QQmlPrivate::RegisterType type = {
0, // int version;
- aType->typeId(), // int typeId;
- aType->qListTypeId(), // int listId;
- aType->createSize(), // int objectSize;
- aType->createFunction(), // void (*create)(void *);
+ gLibQt5Qml.iSym.fn.typeId(aType), // int typeId;
+ gLibQt5Qml.iSym.fn.qListTypeId(aType), // int listId;
+ gLibQt5Qml.iSym.fn.createSize(aType), // int objectSize;
+ gLibQt5Qml.iSym.fn.createFunction(aType), // void (*create)(void *);
QString(), // QString noCreationReason;
aModule, // const char *uri;
aMajor, // int versionMajor;
aMinor, // int versionMinor;
aQmlName, // const char *elementName;
- aType->metaObject(), // const QMetaObject *metaObject;
+ gLibQt5Qml.iSym.fn.metaObject(aType), // const QMetaObject *metaObject;
attachedPropertiesFunction,
attachedPropertiesMetaObject,
- aType->parserStatusCast(), // int parserStatusCast;
- aType->propertyValueSourceCast(), // int valueSourceCast;
- aType->propertyValueInterceptorCast(), // int valueInterceptorCast;
+ gLibQt5Qml.iSym.fn.parserStatusCast(aType), // int parserStatusCast;
+ gLibQt5Qml.iSym.fn.propertyValueSourceCast(aType), // int valueSourceCast;
+ gLibQt5Qml.iSym.fn.propertyValueInterceptorCast(aType), // int valueInterceptorCast;
Q_NULLPTR, // QObject *(*extensionObjectCreate)(QObject *);
Q_NULLPTR, // const QMetaObject *extensionMetaObject;
Q_NULLPTR, // QQmlCustomParser *customParser;
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/src/HarbourProcessState.cpp
^
|
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourProcessState.h"
+#include "HarbourDebug.h"
+
+#include <unistd.h>
+#include <grp.h>
+#include <sys/types.h>
+
+HarbourProcessState::HarbourProcessState(QObject* aParent) :
+ QObject(aParent)
+{
+}
+
+// Callback for qmlRegisterSingletonType<HarbourProcessState>
+QObject* HarbourProcessState::createSingleton(QQmlEngine*, QJSEngine*)
+{
+ return new HarbourProcessState;
+}
+
+bool HarbourProcessState::isJailedApp()
+{
+ static int processJailed = -1;
+
+ // Apps are not supposed to be started by the root systemd process.
+ // Firejail tells us that our parent pid is 1.
+ // We could additionally check that /proc contains only our and
+ // parent pids, if ppid check becomes not reliable enough.
+ if (processJailed < 0) {
+ bool simulate = false;
+ const char* var = "HARBOUR_JAIL_STATE";
+ processJailed = QString(qgetenv(var)).toInt(&simulate);
+ if (!simulate || processJailed < 0) {
+ if (getppid() == 1) {
+ HWARN("We are jailed!");
+ processJailed = 1;
+ } else{
+ HDEBUG("Cool, we are free!");
+ processJailed = 0;
+ }
+ } else {
+ HWARN(var << processJailed);
+ }
+ }
+ return processJailed > 0;
+}
+
+bool HarbourProcessState::isPrivileged()
+{
+ static gid_t privilegedGid = 0;
+
+ if (!privilegedGid) {
+ const struct group* gr = getgrnam("privileged");
+
+ if (gr) {
+ privilegedGid = gr->gr_gid;
+ HDEBUG("privileged =" << privilegedGid);
+ }
+ }
+ const gid_t egid = getegid();
+ if (egid == privilegedGid) {
+ HDEBUG("Yes, we are privileged :)");
+ return true;
+ } else {
+ HDEBUG("Oops, we are not privileged :(");
+ return false;
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/src/HarbourQrCodeGenerator.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -45,25 +45,31 @@
// HarbourQrCodeGenerator::Task
// ==========================================================================
-class HarbourQrCodeGenerator::Task : public HarbourTask {
+class HarbourQrCodeGenerator::Task : public HarbourTask
+{
Q_OBJECT
+
public:
- Task(QThreadPool* aPool, QString aText);
+ Task(QThreadPool* aPool, QString aText, ECLevel aEcLevel);
void performTask() Q_DECL_OVERRIDE;
+
public:
QString iText;
QString iCode;
+ ECLevel iEcLevel;
};
-HarbourQrCodeGenerator::Task::Task(QThreadPool* aPool, QString aText) :
+HarbourQrCodeGenerator::Task::Task(QThreadPool* aPool, QString aText,
+ ECLevel aEcLevel) :
HarbourTask(aPool),
- iText(aText)
+ iText(aText),
+ iEcLevel(aEcLevel)
{
}
void HarbourQrCodeGenerator::Task::performTask()
{
- QByteArray bytes(generate(iText));
+ QByteArray bytes(generate(iText, iEcLevel));
if (!bytes.isEmpty()) {
iCode = HarbourBase32::toBase32(bytes);
}
@@ -73,7 +79,8 @@
// HarbourQrCodeGenerator::Private
// ==========================================================================
-class HarbourQrCodeGenerator::Private : public QObject {
+class HarbourQrCodeGenerator::Private : public QObject
+{
Q_OBJECT
public:
@@ -82,6 +89,10 @@
HarbourQrCodeGenerator* parentObject() const;
void setText(QString aValue);
+ void setEcLevel(int aValue);
+ void regenerate();
+
+ static QRecLevel realEcLevel(ECLevel aEcLevel);
public Q_SLOTS:
void onTaskDone();
@@ -89,6 +100,7 @@
public:
QThreadPool* iThreadPool;
Task* iTask;
+ ECLevel iEcLevel;
QString iText;
QString iCode;
};
@@ -96,7 +108,8 @@
HarbourQrCodeGenerator::Private::Private(HarbourQrCodeGenerator* aParent) :
QObject(aParent),
iThreadPool(new QThreadPool(this)),
- iTask(Q_NULLPTR)
+ iTask(Q_NULLPTR),
+ iEcLevel(ECLevelDefault)
{
// Serialize the tasks:
iThreadPool->setMaxThreadCount(1);
@@ -104,6 +117,7 @@
HarbourQrCodeGenerator::Private::~Private()
{
+ if (iTask) iTask->release();
iThreadPool->waitForDone();
}
@@ -112,19 +126,52 @@
return qobject_cast<HarbourQrCodeGenerator*>(parent());
}
+QRecLevel HarbourQrCodeGenerator::Private::realEcLevel(ECLevel aEcLevel)
+{
+ switch (aEcLevel) {
+ case ECLevel_L: return QR_ECLEVEL_L;
+ case ECLevel_M: return QR_ECLEVEL_M;
+ case ECLevel_Q: return QR_ECLEVEL_Q;
+ case ECLevel_H: return QR_ECLEVEL_H;
+ case ECLevelDefault:
+ case ECLevelCount:
+ break;
+ }
+ return QR_ECLEVEL_M; // default
+}
+
void HarbourQrCodeGenerator::Private::setText(QString aText)
{
if (iText != aText) {
iText = aText;
- HarbourQrCodeGenerator* obj = parentObject();
- const bool wasRunning = (iTask != Q_NULLPTR);
- if (iTask) iTask->release(this);
- iTask = new Task(iThreadPool, aText);
- iTask->submit(this, SLOT(onTaskDone()));
- Q_EMIT obj->textChanged();
- if (!wasRunning) {
- Q_EMIT obj->runningChanged();
+ regenerate();
+ Q_EMIT parentObject()->textChanged();
+ }
+}
+
+void HarbourQrCodeGenerator::Private::setEcLevel(int aValue)
+{
+ const ECLevel level = (aValue < ECLevelDefault) ? ECLevelDefault :
+ (aValue > ECLevelHighest) ? ECLevelHighest : (ECLevel)aValue;
+ if (iEcLevel != level) {
+ const QRecLevel prevRealLevel = realEcLevel(iEcLevel);
+ iEcLevel = level;
+ if (realEcLevel(level) != prevRealLevel) {
+ regenerate();
}
+ Q_EMIT parentObject()->ecLevelChanged();
+ }
+}
+
+void HarbourQrCodeGenerator::Private::regenerate()
+{
+ HarbourQrCodeGenerator* obj = parentObject();
+ const bool wasRunning = (iTask != Q_NULLPTR);
+ if (iTask) iTask->release();
+ iTask = new Task(iThreadPool, iText, iEcLevel);
+ iTask->submit(this, SLOT(onTaskDone()));
+ if (!wasRunning) {
+ Q_EMIT obj->runningChanged();
}
}
@@ -156,7 +203,7 @@
// Callback for qmlRegisterSingletonType<HarbourQrCodeGenerator>
QObject* HarbourQrCodeGenerator::createSingleton(QQmlEngine* aEngine, QJSEngine*)
{
- return new HarbourQrCodeGenerator(aEngine);
+ return new HarbourQrCodeGenerator(); // Singleton doesn't need a parent
}
QString HarbourQrCodeGenerator::text() const
@@ -169,6 +216,16 @@
iPrivate->setText(aValue);
}
+HarbourQrCodeGenerator::ECLevel HarbourQrCodeGenerator::ecLevel() const
+{
+ return iPrivate->iEcLevel;
+}
+
+void HarbourQrCodeGenerator::setEcLevel(int aValue)
+{
+ iPrivate->setEcLevel(aValue);
+}
+
QString HarbourQrCodeGenerator::code() const
{
return iPrivate->iCode;
@@ -179,10 +236,11 @@
return iPrivate->iTask != Q_NULLPTR;
}
-QByteArray HarbourQrCodeGenerator::generate(QString aText)
+QByteArray HarbourQrCodeGenerator::generate(QString aText, ECLevel aEcLevel)
{
QByteArray in(aText.toUtf8()), out;
- QRcode* code = QRcode_encodeString(in.constData(), 0, QR_ECLEVEL_M, QR_MODE_8, true);
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/src/HarbourSystemInfo.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2020 Jolla Ltd.
- * Copyright (C) 2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2020-2021 Jolla Ltd.
+ * Copyright (C) 2020-2021 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -44,6 +44,12 @@
#include <QFile>
#include <QTextStream>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
// ==========================================================================
// HarbourSystemInfo::Private
// ==========================================================================
@@ -63,10 +69,13 @@
static int compareVersions(const QVector<uint> aVersion1, const QVector<uint> aVersion2);
static int compareVersions(const QVector<uint> aVersion1, const QString aVersion2);
+ QString getPackageVersion(QString aPackage);
+
public:
QString iName;
QString iVersion;
QVector<uint> iParsedVersion;
+ QMap<QString,QString> iPackageVersions;
};
const QString HarbourSystemInfo::Private::NAME("NAME");
@@ -159,6 +168,21 @@
return compareVersions(aVersion1, Private::parseVersion(aVersion2));
}
+QString HarbourSystemInfo::Private::getPackageVersion(QString aPackage)
+{
+ QString version;
+ if (!aPackage.isEmpty()) {
+ version = iPackageVersions.value(aPackage);
+ if (version.isEmpty()) {
+ version = HarbourSystemInfo::queryPackageVersion(aPackage);
+ if (!version.isEmpty()) {
+ iPackageVersions.insert(aPackage, version);
+ }
+ }
+ }
+ return version;
+}
+
// ==========================================================================
// HarbourSystemInfo
// ==========================================================================
@@ -192,6 +216,11 @@
return iPrivate->iVersion;
}
+QString HarbourSystemInfo::packageVersion(QString aPackage)
+{
+ return iPrivate->getPackageVersion(aPackage);
+}
+
int HarbourSystemInfo::osVersionCompare(QString aVersion)
{
return Private::compareVersions(iPrivate->iParsedVersion, aVersion);
@@ -203,3 +232,52 @@
const QString os(Private::parseOsRelease(keys).value(Private::VERSION_ID));
return Private::compareVersions(Private::parseVersion(os), aVersion);
}
+
+int HarbourSystemInfo::compareVersions(QString aVersion1, QString aVersion2)
+{
+ return Private::compareVersions(Private::parseVersion(aVersion1),
+ Private::parseVersion(aVersion2));
+}
+
+QString HarbourSystemInfo::queryPackageVersion(QString aPackage)
+{
+ QString version;
+ int fds[2];
+ if (pipe(fds) == 0) {
+ pid_t pid = fork();
+ if (!pid) {
+ const QByteArray package(aPackage.toLatin1());
+ const char* argv[6];
+ argv[0] = "rpm";
+ argv[1] = "-q";
+ argv[2] = "--qf";
+ argv[3] = "%{version}";
+ argv[4] = package.constData();
+ argv[5] = NULL;
+ while ((dup2(fds[1], STDOUT_FILENO) == -1) && (errno == EINTR));
+ execvp(argv[0], (char**)argv);
+ abort();
+ }
+ close(fds[1]);
+
+ // There shouldn't be much output
+ QByteArray out;
+ const int chunk = 16;
+ ssize_t n = 0;
+ do {
+ const int size = out.size();
+ out.resize(size + chunk);
+ while ((n = read(fds[0], out.data() + size, chunk)) == -1 && (errno == EINTR));
+ out.resize(size + qMax(n, (ssize_t)0));
+ } while (n > 0);
+
+ // Parse the version
+ if (out.size() > 0) {
+ version = QString::fromLatin1(out);
+ HDEBUG(qPrintable(aPackage) << qPrintable(version));
+ }
+ waitpid(pid, NULL, 0);
+ close(fds[0]);
+ }
+ return version;
+}
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/test/Makefile
^
|
@@ -0,0 +1,6 @@
+# -*- Mode: makefile-gmake -*-
+
+all:
+%:
+ @$(MAKE) -C TestHarbourBase32 $*
+ @$(MAKE) -C TestHarbourBase45 $*
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/test/Makefile.common
^
|
@@ -0,0 +1,200 @@
+# -*- Mode: makefile-gmake -*-
+
+.PHONY: clean all debug release coverage
+
+#
+# Real test makefile defines EXE (and possibly SRC) and includes this one.
+#
+
+ifndef EXE
+${error EXE not defined}
+endif
+
+SRC ?= $(EXE).cpp
+
+#
+# Required packages
+#
+
+PKGS += Qt5Core glib-2.0
+
+#
+# Default target
+#
+
+all: debug release
+
+#
+# Directories
+#
+
+SRC_DIR = .
+TOP_DIR = ../..
+HARBOUR_DIR = $(TOP_DIR)
+BUILD_DIR = build
+DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
+RELEASE_BUILD_DIR = $(BUILD_DIR)/release
+COVERAGE_BUILD_DIR = $(BUILD_DIR)/coverage
+
+#
+# Tools and flags
+#
+
+CC = $(CROSS_COMPILE)gcc
+LD = $(CC)
+MOC = qtchooser -run-tool=moc -qt=5
+WARNINGS = -Wall
+INCLUDES = -I$(BUILD_DIR) -I$(HARBOUR_DIR)/include
+BASE_FLAGS = -fPIC
+BASE_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS)
+BASE_CFLAGS = $(BASE_FLAGS) $(CFLAGS)
+FULL_CFLAGS = $(BASE_CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
+ $(shell pkg-config --cflags $(PKGS))
+FULL_LDFLAGS = $(BASE_LDFLAGS)
+LIBS = $(shell pkg-config --libs $(PKGS)) -lstdc++
+QUIET_MAKE = make --no-print-directory
+DEBUG_FLAGS = -g
+RELEASE_FLAGS =
+COVERAGE_FLAGS = -g
+
+DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
+RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
+COVERAGE_LDFLAGS = $(FULL_LDFLAGS) $(COVERAGE_FLAGS) --coverage
+
+DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG -DHARBOUR_DEBUG
+RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
+COVERAGE_CFLAGS = $(FULL_CFLAGS) $(COVERAGE_FLAGS) --coverage
+
+#
+# Files
+#
+
+DEBUG_OBJS = \
+ $(MOC_H:%.h=$(DEBUG_BUILD_DIR)/moc_h_%.o) \
+ $(MOC_CPP:%.cpp=$(DEBUG_BUILD_DIR)/moc_cpp_%.o) \
+ $(SRC:%.cpp=$(DEBUG_BUILD_DIR)/%.o) \
+ $(HARBOUR_SRC:%.cpp=$(DEBUG_BUILD_DIR)/harbour_%.o)
+RELEASE_OBJS = \
+ $(MOC_H:%.h=$(RELEASE_BUILD_DIR)/moc_h_%.o) \
+ $(MOC_CPP:%.cpp=$(RELEASE_BUILD_DIR)/moc_cpp_%.o) \
+ $(SRC:%.cpp=$(RELEASE_BUILD_DIR)/%.o) \
+ $(HARBOUR_SRC:%.cpp=$(RELEASE_BUILD_DIR)/harbour_%.o)
+COVERAGE_OBJS = \
+ $(MOC_H:%.h=$(COVERAGE_BUILD_DIR)/moc_h_%.o) \
+ $(MOC_CPP:%.cpp=$(COVERAGE_BUILD_DIR)/moc_cpp_%.o) \
+ $(SRC:%.cpp=$(COVERAGE_BUILD_DIR)/%.o) \
+ $(HARBOUR_SRC:%.cpp=$(COVERAGE_BUILD_DIR)/harbour_%.o)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d) $(COVERAGE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
+$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
+$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR)
+
+#
+# Rules
+#
+
+DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
+RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
+COVERAGE_EXE = $(COVERAGE_BUILD_DIR)/$(EXE)
+
+debug: $(DEBUG_EXE)
+
+release: $(RELEASE_EXE)
+
+coverage: $(COVERAGE_EXE)
+
+clean:
+ rm -f *~
+ rm -fr $(BUILD_DIR)
+
+test_banner:
+ @echo "===========" $(EXE) "=========== "
+
+test: test_banner debug
+ @$(DEBUG_EXE)
+
+valgrind: test_banner debug
+ @G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no $(DEBUG_EXE)
+
+$(BUILD_DIR):
+ mkdir -p $@
+
+$(DEBUG_BUILD_DIR):
+ mkdir -p $@
+
+$(RELEASE_BUILD_DIR):
+ mkdir -p $@
+
+$(COVERAGE_BUILD_DIR):
+ mkdir -p $@
+
+$(BUILD_DIR)/moc_%.cpp : $(APP_DIR)/%.h
+ $(MOC) $< -o $@
+
+$(BUILD_DIR)/%.moc : $(APP_DIR)/%.cpp
+ $(MOC) $< -o $@
+
+$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/moc_h_%.o : $(BUILD_DIR)/moc_%.cpp $(BUILD_DIR)
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/moc_h_%.o : $(BUILD_DIR)/moc_%.cpp $(BUILD_DIR)
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/moc_h_%.o : $(BUILD_DIR)/moc_%.cpp $(BUILD_DIR)
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_EXE): $(DEBUG_OBJS)
+ $(LD) $(DEBUG_LDFLAGS) $^ $(LIBS) -o $@
+
+$(RELEASE_EXE): $(RELEASE_OBJS)
+ $(LD) $(RELEASE_LDFLAGS) $^ $(LIBS) -o $@
+
+$(COVERAGE_EXE): $(COVERAGE_OBJS)
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/test/TestHarbourBase32/Makefile
^
|
@@ -0,0 +1,6 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = TestHarbourBase32
+HARBOUR_SRC = HarbourBase32.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/test/TestHarbourBase32/TestHarbourBase32.cpp
^
|
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourBase32.h"
+#include "HarbourDebug.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * isValidBase45
+ *==========================================================================*/
+
+static
+void
+test_isValidBase32(
+ void)
+{
+ g_assert(HarbourBase32::isValidBase32("AEBAGBAFAYDQQCIKBMGA2DQPCAIREEYUCULBOGI2DMOB2HQ7"));
+ g_assert(HarbourBase32::isValidBase32("aebagbaf aydqqcik bmga2dqp caireeyu culbogi2 dmob2hq7"));
+ g_assert(HarbourBase32::isValidBase32("ae"));
+ g_assert(!HarbourBase32::isValidBase32("aeb"));
+ g_assert(HarbourBase32::isValidBase32("aeba"));
+ g_assert(HarbourBase32::isValidBase32("aebag"));
+ g_assert(!HarbourBase32::isValidBase32("aebagb"));
+ g_assert(!HarbourBase32::isValidBase32("aebagb= x"));
+ g_assert(HarbourBase32::isValidBase32("aebagba"));
+ g_assert(HarbourBase32::isValidBase32("aebagbaf"));
+ g_assert(HarbourBase32::isValidBase32("aebagbafa"));
+ g_assert(HarbourBase32::isValidBase32("aebagbafay"));
+ g_assert(!HarbourBase32::isValidBase32(QString()));
+ g_assert(!HarbourBase32::isValidBase32(" "));
+ g_assert(!HarbourBase32::isValidBase32("01234567"));
+ g_assert(!HarbourBase32::isValidBase32("88888888"));
+ g_assert(!HarbourBase32::isValidBase32("{}"));
+ g_assert(!HarbourBase32::isValidBase32("[]"));
+}
+
+/*==========================================================================*
+ * fromBase32
+ *==========================================================================*/
+
+static
+void
+test_fromBase32(
+ void)
+{
+ static const char out[] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
+ 0x15, 0x16, 0x17, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
+ };
+ QString in1("AEBAGBAFAYDQQCIKBMGA2DQPCAIREEYUCULBOGI2DMOB2HQ7");
+ QString in2("aebagbaf aydqqcik bmga2dqp caireeyu culbogi2 dmob2hq7");
+ QByteArray out1(HarbourBase32::fromBase32(in1));
+ QByteArray out2(HarbourBase32::fromBase32(in2));
+ g_assert(out1 == out2);
+ g_assert(out1 == QByteArray(out, sizeof(out)));
+ g_assert(HarbourBase32::fromBase32("ae") == QByteArray(out, 1));
+ g_assert(HarbourBase32::fromBase32("aeb").isEmpty());
+ g_assert(HarbourBase32::fromBase32("aeba") == QByteArray(out, 2));
+ g_assert(HarbourBase32::fromBase32("aebag") == QByteArray(out, 3));
+ g_assert(HarbourBase32::fromBase32("aebagb").isEmpty());
+ g_assert(HarbourBase32::fromBase32("aebagb=x").isEmpty());
+ g_assert(HarbourBase32::fromBase32("aebagb= x").isEmpty());
+ g_assert(HarbourBase32::fromBase32("aebagba") == QByteArray(out, 4));
+ g_assert(HarbourBase32::fromBase32("aebagbaf") == QByteArray(out, 5));
+ g_assert(HarbourBase32::fromBase32("aebagbafa") == QByteArray(out, 5));
+ g_assert(HarbourBase32::fromBase32("aebagbafay") == QByteArray(out, 6));
+ g_assert(HarbourBase32::fromBase32(QString()).isEmpty());
+ g_assert(HarbourBase32::fromBase32(" ").isEmpty());
+ g_assert(HarbourBase32::fromBase32("01234567").isEmpty());
+ g_assert(HarbourBase32::fromBase32("88888888").isEmpty());
+ g_assert(HarbourBase32::fromBase32("{}").isEmpty());
+ g_assert(HarbourBase32::fromBase32("[]").isEmpty());
+}
+
+/*==========================================================================*
+ * base32pad
+ *==========================================================================*/
+
+static
+void
+test_base32pad(
+ void)
+{
+ static const char out[] = {
+ 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23
+ };
+ QString in1("DMOB2HQ7EA====="); // One pad character missing
+ QString in2("DMOB2HQ7EAQQ====="); // One extra pagging character
+ QString in3("DMOB2HQ7EAQSE== ="); // Space is ignored
+ QString in4("DMOB2HQ7EAQSEIY=");
+ g_assert(HarbourBase32::fromBase32(in1) == QByteArray(out, sizeof(out) - 3));
+ g_assert(HarbourBase32::fromBase32(in2) == QByteArray(out, sizeof(out) - 2));
+ g_assert(HarbourBase32::fromBase32(in3) == QByteArray(out, sizeof(out) - 1));
+ g_assert(HarbourBase32::fromBase32(in4) == QByteArray(out, sizeof(out)));
+ g_assert(HarbourBase32::fromBase32(QString("=================")).isEmpty());
+ g_assert(HarbourBase32::fromBase32(QString("=DMOB2HQ7EAQSEIY=")).isEmpty());
+ g_assert(HarbourBase32::fromBase32(QString("DMOB2HQ7EB=")).isEmpty());
+}
+
+/*==========================================================================*
+ * toBase32
+ *==========================================================================*/
+
+static
+void
+test_toBase32(
+ void)
+{
+ static const char in[] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
+ 0x15, 0x16, 0x17, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
+ };
+ QString out("aebagbafaydqqcikbmga2dqpcaireeyuculbogi2dmob2hq7");
+ g_assert(HarbourBase32::toBase32(QByteArray()).isEmpty());
+ g_assert(HarbourBase32::toBase32(QByteArray(in, sizeof(in))) == out);
+}
+
+/*==========================================================================*
+ * rfc4648
+ *==========================================================================*/
+
+static
+void
+test_rfc4648(
+ void)
+{
+ // Test vectors from RFC 4648
+ static const char* test[][2] = {
+ { "f", "MY======" },
+ { "fo", "MZXQ====" },
+ { "foo", "MZXW6===" },
+ { "foob", "MZXW6YQ=" },
+ { "fooba", "MZXW6YTB" },
+ { "foobar", "MZXW6YTBOI======" }
+ };
+
+ for (guint i = 0; i < G_N_ELEMENTS(test); i++) {
+ QByteArray data(test[i][0]);
+ QString base32(test[i][1]);
+ g_assert(HarbourBase32::isValidBase32(base32));
+ g_assert(HarbourBase32::fromBase32(base32) == data);
+ g_assert(HarbourBase32::toBase32(data, false) == base32);
+ }
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourBase32/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("isValidBase32"), test_isValidBase32);
+ g_test_add_func(TEST_("fromBase32"), test_fromBase32);
+ g_test_add_func(TEST_("base32pad"), test_base32pad);
+ g_test_add_func(TEST_("rfc4648"), test_rfc4648);
+ g_test_add_func(TEST_("toBase32"), test_toBase32);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/test/TestHarbourBase45/Makefile
^
|
@@ -0,0 +1,6 @@
+# -*- Mode: makefile-gmake -*-
+
+EXE = TestHarbourBase45
+HARBOUR_SRC = HarbourBase45.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/test/TestHarbourBase45/TestHarbourBase45.cpp
^
|
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourBase45.h"
+#include "HarbourDebug.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * isValidBase45
+ *==========================================================================*/
+
+static
+void
+test_isValidBase45(
+ void)
+{
+ g_assert(HarbourBase45::isValidBase45("")); // Empty is considered valid
+ g_assert(HarbourBase45::isValidBase45("BB8"));
+ g_assert(HarbourBase45::isValidBase45("%69 VD92EX0"));
+ g_assert(HarbourBase45::isValidBase45("UJCLQE7W581"));
+ g_assert(!HarbourBase45::isValidBase45("AA("));
+ g_assert(!HarbourBase45::isValidBase45("A(A"));
+ g_assert(!HarbourBase45::isValidBase45("(AA"));
+ g_assert(!HarbourBase45::isValidBase45("A("));
+ g_assert(!HarbourBase45::isValidBase45("A["));
+ g_assert(!HarbourBase45::isValidBase45("[A"));
+ g_assert(!HarbourBase45::isValidBase45("A"));
+ g_assert(!HarbourBase45::isValidBase45("ZZ"));
+ g_assert(!HarbourBase45::isValidBase45("ZZZ"));
+}
+
+/*==========================================================================*
+ * toBase45
+ *==========================================================================*/
+
+static
+void
+test_toBase45(
+ void)
+{
+ g_assert(HarbourBase45::toBase45(QByteArray()).isEmpty());
+ // Examples from draft-faltstrom-base45-07
+ g_assert(HarbourBase45::toBase45(QByteArray("AB")) == QString("BB8"));
+ g_assert(HarbourBase45::toBase45(QByteArray("Hello!!")) == QString("%69 VD92EX0"));
+ g_assert(HarbourBase45::toBase45(QByteArray("base-45")) == QString("UJCLQE7W581"));
+}
+
+/*==========================================================================*
+ * fromBase45
+ *==========================================================================*/
+
+static
+void
+test_fromBase45(
+ void)
+{
+ // Invalid
+ g_assert(HarbourBase45::fromBase45(QByteArray("AA[")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A[A")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("[AA")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("AA(")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A(A")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("(AA")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A(")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A[")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("[A")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("A")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("ZZ")).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("ZZZ")).isEmpty());
+ // Valid
+ g_assert(HarbourBase45::fromBase45(QByteArray()).isEmpty());
+ g_assert(HarbourBase45::fromBase45(QByteArray("BB8")) == QByteArray("AB"));
+ g_assert(HarbourBase45::fromBase45(QByteArray("%69 VD92EX0")) == QByteArray("Hello!!"));
+ g_assert(HarbourBase45::fromBase45(QByteArray("UJCLQE7W581")) == QByteArray("base-45"));
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourBase45/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("isValidBase45"), test_isValidBase45);
+ g_test_add_func(TEST_("fromBase45"), test_fromBase45);
+ g_test_add_func(TEST_("toBase45"), test_toBase45);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/test/coverage/.gitignore
^
|
@@ -0,0 +1,4 @@
+app.gcov
+full.gcov
+report
+*~
|
[-]
[+]
|
Added |
_service:tar_git:openrepos-books-1.0.44.tar.gz/harbour-lib/test/coverage/run
^
|
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# This script requires lcov, dirname
+#
+
+TESTS="\
+TestHarbourBase32 \
+TestHarbourBase45"
+
+function err() {
+ echo "*** ERROR!" $1
+ exit 1
+}
+
+# Check the required tools
+which lcov >> /dev/null || err "Please install lcov"
+which dirname >> /dev/null || err "Please install dirname"
+
+# LCOV 1.10 has branch coverage disabled per default
+# Previous versions didn't have the --rc option
+if [ ! -z "$(lcov --help | grep ' --rc ')" ] ; then
+ LCOV_OPT="--rc lcov_branch_coverage=1"
+ GENHTML_OPT="--branch-coverage"
+fi
+
+pushd `dirname $0` > /dev/null
+COV_DIR="$PWD"
+pushd .. > /dev/null
+TEST_DIR="$PWD"
+pushd .. > /dev/null
+TOP_DIR="$PWD"
+popd > /dev/null
+popd > /dev/null
+popd > /dev/null
+
+FULL_COV="$COV_DIR/full.gcov"
+APP_COV="$COV_DIR/app.gcov"
+
+make -C "$TEST_DIR" clean
+rm -f "$FULL_COV" "$APP_COV"
+TESTS_COV=
+
+for t in $TESTS ; do
+ pushd "$TEST_DIR/$t"
+ make -C "$TEST_DIR/$t" clean coverage || exit 1
+ build/coverage/$t || exit 1
+ TEST_COV="$TEST_DIR/$t/build/coverage/$t.cov"
+ lcov $LCOV_OPT -c -d build/coverage -o "$TEST_COV" || exit 1
+ TESTS_COV+="-a $TEST_COV "
+ popd
+done
+
+lcov $LCOV_OPT $TESTS_COV -o "$FULL_COV" || exit 1
+lcov $LCOV_OPT -e "$FULL_COV" "$TOP_DIR/src/*" -o "$APP_COV" || exit 1
+genhtml $GENHTML_OPT "$APP_COV" -t "HarbourLib" --output-directory "$COV_DIR/report" || exit 1
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/test/test-css/data/test1/out.css
^
|
@@ -5,7 +5,7 @@
margin-right: 0;
display: none;
font-weight: bold;
- font-size: 207%; /* 4 */
+ font-size: 172%; /* 3 */
}
.calibre {
margin-left: 5px;
@@ -23,7 +23,7 @@
margin-top: 1em;
margin-right: 0;
font-weight: bold;
- font-size: 207%; /* 4 */
+ font-size: 172%; /* 3 */
}
.calibre3 {
margin-left: 0;
@@ -31,7 +31,7 @@
margin-top: 1em;
margin-right: 0;
font-weight: bold;
- font-size: 207%; /* 4 */
+ font-size: 172%; /* 3 */
}
.calibre4 {
margin-left: 0;
@@ -71,7 +71,7 @@
margin-top: 1em;
margin-right: 0;
font-weight: bold;
- font-size: 144%; /* 2 */
+ font-size: 120%; /* 1 */
}
.hljs-comment {
color: #8e908c;
|
[-]
[+]
|
Changed |
_service:tar_git:openrepos-books-1.0.44.tar.gz/test/test-css/data/test2/out.css
^
|
@@ -19,7 +19,7 @@
page-break-before: avoid;
text-align: center;
font-weight: bold;
- font-size: 248%; /* 5 */
+ font-size: 207%; /* 4 */
}
.p {
margin-left: 0;
@@ -59,7 +59,7 @@
page-break-before: avoid;
text-align: center;
font-weight: bold;
- font-size: 207%; /* 4 */
+ font-size: 172%; /* 3 */
}
.title2 {
margin-left: 1.56em;
@@ -69,7 +69,7 @@
page-break-before: avoid;
text-align: left;
font-weight: bold;
- font-size: 172%; /* 3 */
+ font-size: 144%; /* 2 */
}
.empty-line {
margin-left: 0;
@@ -118,7 +118,7 @@
page-break-before: avoid;
text-align: left;
font-weight: bold;
- font-size: 144%; /* 2 */
+ font-size: 120%; /* 1 */
}
.cite {
margin-left: 1em;
|