[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://git.monich.net/git/harbour-meecalc.git</param>
<param name="branch">master</param>
- <param name="revision">324c0fc</param>
+ <param name="revision">dd5a9b5</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/.gitignore
^
|
@@ -1,2 +1,2 @@
build
-harbour-meecalc.pro.user
+harbour-meecalc.pro.user*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/LICENSE
^
|
@@ -0,0 +1,30 @@
+ Copyright (C) 2014-2018 Jolla Ltd.
+ Copyright (C) 2014-2023 Slava Monich <slava@monich.com>
+
+ You may use this file under the terms of 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.
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/LICENSE
^
|
@@ -1,7 +1,7 @@
-Copyright (C) 2015-2018 Jolla Ltd.
-Copyright (C) 2015-2018 Slava Monich <slava@monich.com>
+Copyright (C) 2015-2021 Jolla Ltd.
+Copyright (C) 2015-2023 Slava Monich <slava@monich.com>
-You may use this file under the terms of the BSD license as follows:
+You may use this file under the terms of BSD license as follows:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -13,9 +13,9 @@
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
- 3. Neither the name of 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.
+ 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
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/README
^
|
@@ -0,0 +1,14 @@
+Reusable components for Jolla harbour apps
+==========================================
+
+Some of them allow to access undocumented Sailfish OS features, some
+provide compatibility with older releases of Sailfish OS. This code
+has been tested against Sailfish OS 2.0 meaning that most of it is
+probably incompatible with older versions.
+
+The easiest way to use this code in your project is to add this repo
+as a git submodule to your project and add the files you need to your
+.pro file.
+
+This repository is always work in progress, don't expect any tags,
+formal releases or anything like that.
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/harbour-lib.pro
^
|
@@ -4,6 +4,10 @@
QT += dbus
QT-= gui
+# For HarbourSystemTime
+CONFIG += link_pkgconfig
+PKGCONFIG += libglibutil
+
VERSION = 1.0
greaterThan(QT_MAJOR_VERSION, 4) {
@@ -19,16 +23,33 @@
}
SOURCES += \
+ src/HarbourBase32.cpp \
+ src/HarbourBase45.cpp \
+ src/HarbourBattery.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/HarbourProtoBuf.cpp \
+ src/HarbourSelectionListModel.cpp \
src/HarbourSigChildHandler.cpp \
+ src/HarbourSingleImageProvider.cpp \
+ src/HarbourSystem.cpp \
+ src/HarbourSystemInfo.cpp \
src/HarbourSystemState.cpp \
+ src/HarbourSystemTime.cpp \
src/HarbourTask.cpp \
src/HarbourTemporaryFile.cpp \
src/HarbourTransferMethodInfo.cpp \
- src/HarbourTransferMethodsModel.cpp
+ src/HarbourTransferMethodsModel.cpp \
+ src/HarbourUtil.cpp
greaterThan(QT_MAJOR_VERSION, 4) {
SOURCES += \
@@ -39,22 +60,40 @@
INCLUDEPATH += include
PUBLIC_HEADERS += \
+ include/HarbourBase32.h \
+ include/HarbourBase45.h \
+ include/HarbourBattery.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/HarbourProtoBuf.h \
+ include/HarbourSelectionListModel.h \
include/HarbourSigChildHandler.h \
+ include/HarbourSingleImageProvider.h \
+ include/HarbourSystem.h \
+ include/HarbourSystemInfo.h \
include/HarbourSystemState.h \
+ include/HarbourSystemTime.h \
include/HarbourTask.h \
include/HarbourTemporaryFile.h \
include/HarbourTransferMethodInfo.h \
- include/HarbourTransferMethodsModel.h
+ include/HarbourTransferMethodsModel.h \
+ include/HarbourUtil.h
greaterThan(QT_MAJOR_VERSION, 4) {
PUBLIC_HEADERS += \
include/HarbourImageProvider.h \
include/HarbourPluginLoader.h \
include/HarbourTheme.h
+OTHER_FILES += qml/*.qml
}
HEADERS += \
@@ -63,6 +102,7 @@
OTHER_FILES += \
LICENSE \
+ README \
rpm/harbour-lib-devel.spec
headers.path = $$INSTALL_ROOT$$PREFIX/include/$$TARGET
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourAztecCodeGenerator.h
^
|
@@ -0,0 +1,89 @@
+/*
+ * 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:
+ *
+ * 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_AZTEC_CODE_GENERATOR_H
+#define HARBOUR_AZTEC_CODE_GENERATOR_H
+
+#include <QtQml>
+
+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, int aEcLevel = ECLevelDefault);
+
+ // Callback for qmlRegisterSingletonType<HarbourAztecCodeGenerator>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+Q_SIGNALS:
+ void textChanged();
+ void ecLevelChanged();
+ void codeChanged();
+ void runningChanged();
+
+private:
+ class Task;
+ class Private;
+ Private* iPrivate;
+};
+
+QML_DECLARE_TYPE(HarbourAztecCodeGenerator)
+
+#endif // HARBOUR_AZTEC_CODE_GENERATOR_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourBase32.h
^
|
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019-2022 Jolla Ltd.
+ * Copyright (C) 2019-2022 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_BASE32_H
+#define HARBOUR_BASE32_H
+
+#include <QString>
+#include <QByteArray>
+
+class HarbourBase32
+{
+ class Private;
+ HarbourBase32() Q_DECL_EQ_DELETE;
+
+public:
+ static bool isValidBase32(const QString);
+ static QString toBase32(const QByteArray, bool aLowerCase = true);
+ static QByteArray fromBase32(const QString);
+};
+
+#endif // HARBOUR_BASE32_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourBase45.h
^
|
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 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() Q_DECL_EQ_DELETE;
+
+public:
+ static bool isValidBase45(const QString);
+ static QString toBase45(const QByteArray);
+ static QByteArray fromBase45(const QString);
+};
+
+#endif // HARBOUR_BASE45_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourBattery.h
^
|
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 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_BATTERY_H
+#define HARBOUR_BATTERY_H
+
+#include <QObject>
+
+class QQmlEngine;
+class QJSEngine;
+
+// D-Bus calls used by this object require mce 1.86.0 (Sailfish OS 2.1)
+class HarbourBattery: public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(BatteryStatus batteryStatus READ batteryStatus NOTIFY batteryStatusChanged)
+ Q_PROPERTY(BatteryState batteryState READ batteryState NOTIFY batteryStateChanged)
+ Q_PROPERTY(int batteryLevel READ batteryLevel NOTIFY batteryLevelChanged)
+ Q_ENUMS(BatteryStatus)
+ Q_ENUMS(BatteryState)
+
+public:
+ enum BatteryStatus {
+ BatteryStatusUnknown,
+ BatteryStatusEmpty,
+ BatteryStatusLow,
+ BatteryStatusOk,
+ BatteryStatusFull
+ };
+
+ enum BatteryState {
+ BatteryStateUnknown,
+ BatteryStateCharging,
+ BatteryStateDischarging,
+ BatteryStateNotCharging,
+ BatteryStateFull
+ };
+
+ explicit HarbourBattery(QObject* aParent = Q_NULLPTR);
+ ~HarbourBattery();
+
+ // Callback for qmlRegisterSingletonType<HarbourBattery>
+ static QObject* createSingleton(QQmlEngine*, QJSEngine*);
+
+ BatteryStatus batteryStatus() const;
+ BatteryState batteryState() const;
+ int batteryLevel() const;
+
+Q_SIGNALS:
+ void batteryStatusChanged();
+ void batteryStateChanged();
+ void batteryLevelChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_BATTERY_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourClipboard.h
^
|
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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
+ * 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_CLIPBOARD_H
+#define HARBOUR_CLIPBOARD_H
+
+#include <QtQml>
+
+class HarbourClipboard : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(bool cacheText READ cacheText WRITE setCacheText NOTIFY cacheTextChanged)
+
+public:
+ HarbourClipboard(QObject* aParent = Q_NULLPTR);
+
+ QString text() const;
+ void setText(QString aValue);
+
+ bool cacheText() const;
+ void setCacheText(bool aValue);
+
+ // Callback for qmlRegisterSingletonType<HarbourClipboard>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+Q_SIGNALS:
+ void textChanged();
+ void cacheTextChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+QML_DECLARE_TYPE(HarbourClipboard)
+
+#endif // HARBOUR_CLIPBOARD_H
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/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
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourDebug.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2016 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2019 Jolla Ltd.
+ * Copyright (C) 2015-2019 Slava Monich <slava@monich.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 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.
+ * 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
@@ -74,4 +74,10 @@
# define HWARN(x) qWarning() << Q_FUNC_INFO << x
#endif
+// Usage: TODO("Remember to fix this")
+#ifndef TODO
+# define HARBOUR_PRAGMA(x) _Pragma(#x)
+# define TODO(x) HARBOUR_PRAGMA(message("TODO - " x))
+#endif
+
#endif // HARBOUR_DEBUG_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourDisplayBlanking.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2018 Jolla Ltd.
- * Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2019 Jolla Ltd.
+ * Copyright (C) 2015-2019 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 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.
+ * 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
@@ -38,17 +38,21 @@
#include <QString>
#include <QSharedPointer>
-class HarbourDisplayBlanking: public QObject
-{
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourDisplayBlanking: public QObject {
Q_OBJECT
Q_PROPERTY(bool paused READ paused NOTIFY pausedChanged)
Q_PROPERTY(bool pauseAllowed READ pauseAllowed NOTIFY pauseAllowedChanged)
Q_PROPERTY(bool pauseRequested READ pauseRequested WRITE setPauseRequested NOTIFY pauseRequestedChanged)
public:
- explicit HarbourDisplayBlanking(QObject* aParent = NULL);
+ explicit HarbourDisplayBlanking(QObject* aParent = Q_NULLPTR);
~HarbourDisplayBlanking();
+ // Callback for qmlRegisterSingletonType<HarbourDisplayBlanking>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
static QSharedPointer<HarbourDisplayBlanking> sharedInstance();
bool paused() const;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourJson.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2020 Jolla Ltd.
+ * Copyright (C) 2015-2020 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,27 +8,31 @@
* 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
* 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,
+ * 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_JSON_H
@@ -38,8 +42,8 @@
#include <QVariant>
namespace HarbourJson {
- bool save(QString aPath, const QVariantMap& aMap);
- bool load(QString aPath, QVariantMap& aRoot);
+ bool save(const QString& aPath, const QVariantMap& aMap);
+ bool load(const QString& aPath, QVariantMap& aRoot);
}
#endif // HARBOUR_JSON_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourMediaPlugin.h
^
|
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 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_MEDIA_PLUGIN_H
+#define HARBOUR_MEDIA_PLUGIN_H
+
+#include "HarbourPluginLoader.h"
+
+// Workaround for org.nemomobile.policy (or Sailfish.Media) not being
+// allowed in harbour apps
+
+class HarbourMediaPlugin : public HarbourPluginLoader
+{
+ static HarbourMediaPlugin* gInstance;
+ static const char MEDIAKEY_QML_TYPE[];
+
+public:
+ static void registerTypes(QQmlEngine* aEngine, const char* aModule,
+ int aMajor, int aMinor);
+
+private:
+ HarbourMediaPlugin(QQmlEngine* aEngine);
+ ~HarbourMediaPlugin();
+ void registerTypes(const char* aModule, int aMajor, int aMinor);
+};
+
+#endif // HARBOUR_MEDIA_PLUGIN_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/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:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourOrganizeListModel.h
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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_ORGANIZE_LIST_MODEL_H
+#define HARBOUR_ORGANIZE_LIST_MODEL_H
+
+#include <QtQml>
+#include <QSortFilterProxyModel>
+
+// This model helps to implement rearranging list items by dragging.
+// When drag starts, QML sets dragIndex property and then updates
+// dragPos when with the position of the dragged list item. When
+// drag is finished, QML sets dragIndex to -1 and the model calls
+// moveRow() on the underlying (source) model, to finish the move.
+
+class HarbourOrganizeListModel : public QSortFilterProxyModel {
+ Q_OBJECT
+ Q_PROPERTY(QObject* sourceModel READ sourceModel WRITE setSourceModelObject NOTIFY sourceModelObjectChanged)
+ Q_PROPERTY(int dragIndex READ dragIndex WRITE setDragIndex NOTIFY dragIndexChanged)
+ Q_PROPERTY(int dragPos READ dragPos WRITE setDragPos NOTIFY dragPosChanged)
+
+public:
+ HarbourOrganizeListModel(QObject* aParent = Q_NULLPTR);
+ ~HarbourOrganizeListModel();
+
+ void setSourceModelObject(QObject* aModel);
+
+ int dragIndex() const;
+ void setDragIndex(int aIndex);
+
+ int dragPos() const;
+ void setDragPos(int aPos);
+
+ // QAbstractProxyModel
+ QModelIndex mapToSource(const QModelIndex& aIndex) const Q_DECL_OVERRIDE;
+ QModelIndex mapFromSource(const QModelIndex& aIndex) const Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void sourceModelObjectChanged();
+ void dragIndexChanged();
+ void dragPosChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+QML_DECLARE_TYPE(HarbourOrganizeListModel)
+
+#endif // HARBOUR_ORGANIZE_LIST_MODEL_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourPluginLoader.h
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2017 Jolla Ltd.
- * Copyright (C) 2017 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 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
@@ -11,23 +11,24 @@
* 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 name of 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.
+ * 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.
+ * 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.
*/
#ifndef HARBOUR_PLUGIN_LOADER_H
@@ -79,6 +80,7 @@
const char* aModule, int aMajor, int aMinor);
private:
+ class LibQt5Qml;
class Private;
Private* iPrivate;
};
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourPolicyPlugin.h
^
|
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 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_POLICY_PLUGIN_H
+#define HARBOUR_POLICY_PLUGIN_H
+
+#include "HarbourPluginLoader.h"
+
+// Workaround for org.nemomobile.policy (or Nemo.Policy) not being
+// allowed in harbour apps
+
+class HarbourPolicyPlugin : public HarbourPluginLoader
+{
+ static HarbourPolicyPlugin* gInstance;
+ static const char RESOURCE_QML_TYPE[];
+ static const char PERMISSIONS_QML_TYPE[];
+
+public:
+ static void registerTypes(QQmlEngine* aEngine, const char* aModule,
+ int aMajor, int aMinor);
+
+private:
+ HarbourPolicyPlugin(QQmlEngine* aEngine);
+ ~HarbourPolicyPlugin();
+ void registerTypes(const char* aModule, int aMajor, int aMinor);
+};
+
+#endif // HARBOUR_POLICY_PLUGIN_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/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
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourProtoBuf.h
^
|
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 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_PROTOBUF_H
+#define HARBOUR_PROTOBUF_H
+
+#include <QByteArray>
+
+#include <gutil_types.h>
+
+// https://developers.google.com/protocol-buffers/docs/encoding
+
+class HarbourProtoBuf
+{
+ HarbourProtoBuf() Q_DECL_EQ_DELETE;
+
+public:
+ enum {
+ TYPE_SHIFT = 3,
+ TYPE_MASK = ((1 << TYPE_SHIFT)-1),
+ TYPE_VARINT = 0,
+ TYPE_DELIMITED = 2
+ };
+
+ static QByteArray* appendVarInt(QByteArray*, quint64);
+ static QByteArray* appendVarIntKeyValue(QByteArray*, quint64, quint64);
+ static QByteArray* appendDelimitedValue(QByteArray*, const QByteArray);
+ static QByteArray* appendDelimitedKeyValue(QByteArray*, quint64, const QByteArray);
+
+ static bool parseVarInt(GUtilRange*, quint64*);
+ static bool parseDelimitedValue(GUtilRange*, GUtilData*);
+};
+
+#endif // HARBOUR_PROTOBUF_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourQrCodeGenerator.h
^
|
@@ -0,0 +1,90 @@
+/*
+ * 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:
+ *
+ * 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_QRCODE_GENERATOR_H
+#define HARBOUR_QRCODE_GENERATOR_H
+
+#include <QtQml>
+
+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, ECLevel aEcLevel = ECLevelDefault);
+
+ // Callback for qmlRegisterSingletonType<HarbourQrCodeGenerator>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+Q_SIGNALS:
+ void textChanged();
+ void ecLevelChanged();
+ void codeChanged();
+ void runningChanged();
+
+private:
+ class Task;
+ class Private;
+ Private* iPrivate;
+};
+
+QML_DECLARE_TYPE(HarbourQrCodeGenerator)
+
+#endif // HARBOUR_QRCODE_GENERATOR_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourQrCodeImageProvider.h
^
|
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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_QRCODE_IMAGEPROVIDER_H
+#define HARBOUR_QRCODE_IMAGEPROVIDER_H
+
+#include <QImage>
+#include <QQuickImageProvider>
+
+class HarbourQrCodeImageProvider : public QQuickImageProvider {
+public:
+ HarbourQrCodeImageProvider() : QQuickImageProvider(Image) {}
+
+ static const QColor DEFAULT_COLOR; // Qt::black
+ static const QColor DEFAULT_BACKGROUND; // Qt::transparent
+
+ static QImage createImage(QByteArray aBits, QColor aColor = DEFAULT_COLOR,
+ QColor aBackground = DEFAULT_BACKGROUND);
+
+ QImage requestImage(const QString& aId, QSize* aSize,
+ const QSize& aRequested) Q_DECL_OVERRIDE;
+};
+
+#endif // HARBOUR_QRCODE_IMAGEPROVIDER_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourSelectionListModel.h
^
|
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019-2023 Slava Monich <slava@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_SELECTION_LIST_MODEL_H
+#define HARBOUR_SELECTION_LIST_MODEL_H
+
+#include <QtQml>
+#include <QIdentityProxyModel>
+
+class HarbourSelectionListModel : public QIdentityProxyModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject* sourceModel READ sourceModel WRITE setSourceModelObject NOTIFY sourceModelObjectChanged)
+ Q_PROPERTY(QList<int> nonSelectableRows READ nonSelectableRows WRITE setNonSelectableRows NOTIFY nonSelectableRowsChanged)
+ Q_PROPERTY(QList<int> selectedRows READ selectedRows NOTIFY selectedRowsChanged)
+ Q_PROPERTY(int selectableCount READ selectableCount NOTIFY selectableCountChanged)
+ Q_PROPERTY(int selectionCount READ selectionCount NOTIFY selectionCountChanged)
+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
+
+public:
+ HarbourSelectionListModel(QObject* aParent = Q_NULLPTR);
+
+ void setSourceModelObject(QObject*);
+
+ QList<int> nonSelectableRows() const;
+ void setNonSelectableRows(const QList<int>);
+
+ QList<int> selectedRows() const;
+ int selectableCount() const;
+ int selectionCount() const;
+
+ Q_INVOKABLE void selectAll();
+ Q_INVOKABLE void clearSelection();
+ Q_INVOKABLE void toggleRows(const QList<int>);
+
+ // QAbstractItemModel
+ Qt::ItemFlags flags(const QModelIndex&) const Q_DECL_OVERRIDE;
+ QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex&, int) const Q_DECL_OVERRIDE;
+ bool setData(const QModelIndex&, const QVariant&, int) Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void sourceModelObjectChanged();
+ void nonSelectableRowsChanged();
+ void selectedRowsChanged();
+ void selectableCountChanged();
+ void selectionCountChanged();
+ void countChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+QML_DECLARE_TYPE(HarbourSelectionListModel)
+
+#endif // HARBOUR_SELECTION_LIST_MODEL_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourSingleImageProvider.h
^
|
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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_SINGLE_IMAGE_PROVIDER_H
+#define HARBOUR_SINGLE_IMAGE_PROVIDER_H
+
+#include <QImage>
+#include <QObject>
+#include <QQmlParserStatus>
+
+class HarbourSingleImageProvider : public QObject, public QQmlParserStatus {
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QImage image READ image WRITE setImage NOTIFY imageChanged)
+ Q_PROPERTY(QString source READ source NOTIFY sourceChanged)
+
+public:
+ HarbourSingleImageProvider(QObject* aParent = Q_NULLPTR);
+
+ QImage image() const;
+ void setImage(QImage aImage);
+
+ QString source() const;
+
+ Q_INVOKABLE void clear();
+
+ // QQmlParserStatus
+ void classBegin() Q_DECL_OVERRIDE;
+ void componentComplete() Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void imageChanged();
+ void sourceChanged();
+
+private:
+ class Private;
+ class ImageProvider;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_SINGLE_IMAGE_PROVIDER_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourSystem.h
^
|
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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_SYSTEM_H
+#define HARBOUR_SYSTEM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void* HarbourDlopen(const char* aLibFile, int aFlags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // HARBOUR_SYSTEM_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourSystemInfo.h
^
|
@@ -0,0 +1,76 @@
+/*
+ * 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:
+ *
+ * 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_SYSTEM_INFO_H
+#define HARBOUR_SYSTEM_INFO_H
+
+#include <QObject>
+#include <QVector>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourSystemInfo: public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HarbourSystemInfo)
+ Q_PROPERTY(QString osName READ osName CONSTANT)
+ Q_PROPERTY(QString osVersion READ osVersion CONSTANT)
+
+public:
+ explicit HarbourSystemInfo(QObject* aParent = NULL);
+ ~HarbourSystemInfo();
+
+ // Callback for qmlRegisterSingletonType<HarbourSystemInfo>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ 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:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_SYSTEM_INFO_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourSystemState.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2016 Jolla Ltd.
- * Copyright (C) 2015-2017 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2019 Jolla Ltd.
+ * Copyright (C) 2015-2019 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 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.
+ * 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
@@ -38,6 +38,9 @@
#include <QString>
#include <QSharedPointer>
+class QQmlEngine;
+class QJSEngine;
+
class HarbourSystemState: public QObject
{
Q_OBJECT
@@ -60,9 +63,11 @@
static const QString MCE_TK_UNLOCKED;
public:
- explicit HarbourSystemState(QObject* aParent = NULL);
+ explicit HarbourSystemState(QObject* aParent = Q_NULLPTR);
~HarbourSystemState();
+ // Callback for qmlRegisterSingletonType<HarbourSystemState>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
static QSharedPointer<HarbourSystemState> sharedInstance();
QString displayStatus() const;
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourSystemTime.h
^
|
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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_SYSTEM_TIME_H
+#define HARBOUR_SYSTEM_TIME_H
+
+#include <QObject>
+#include <QSharedPointer>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourSystemTime: public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HarbourSystemTime)
+ Q_PROPERTY(QString notification READ emptyString NOTIFY notify)
+
+public:
+ explicit HarbourSystemTime(QObject* aParent = NULL);
+ ~HarbourSystemTime();
+
+ // Dummy getter for notification property which can be used to
+ // force re-evaluation of a JavaScript expression. As its name
+ // suggests, always returns empty string.
+ static QString emptyString();
+
+ // Callback for qmlRegisterSingletonType<HarbourSystemTime>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ // Shared instance for use by native code
+ static QSharedPointer<HarbourSystemTime> sharedInstance();
+
+Q_SIGNALS:
+ // Recipient must be ready to receive multiple notifications for
+ // a single time or timezone change.
+ void preNotify(); // For Date.timeZoneUpdated()
+ void notify(); // For everything else
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_SYSTEM_TIME_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourTask.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,24 +11,28 @@
* 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 name of 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.
+ * 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,
+ * 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_TASK_H
@@ -47,7 +51,7 @@
Q_OBJECT
protected:
- HarbourTask(QThreadPool* aPool, QThread* aTargetThread = NULL);
+ HarbourTask(QThreadPool* aPool, QThread* aTargetThread = Q_NULLPTR);
public:
virtual ~HarbourTask();
@@ -64,7 +68,7 @@
void released();
protected:
- virtual void run();
+ void run() Q_DECL_OVERRIDE;
virtual void performTask() = 0;
Q_SIGNALS:
@@ -74,6 +78,7 @@
private Q_SLOTS:
void onAboutToQuit();
void onRunFinished();
+ void onTargetDestroyed(QObject* aObject);
private:
class Private;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourTemporaryFile.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,27 +8,31 @@
* 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 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.
+ * 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,
+ * 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_TEMPORARY_FILE_H
@@ -44,17 +48,27 @@
Q_PROPERTY(QString fileTemplate READ fileTemplate WRITE setFileTemplate NOTIFY fileTemplateChanged)
Q_PROPERTY(QString content READ content WRITE setContent NOTIFY contentChanged)
Q_PROPERTY(QString fileName READ fileName NOTIFY fileNameChanged)
+ Q_PROPERTY(Location location READ location WRITE setLocation NOTIFY locationChanged)
Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
+ Q_ENUMS(Location)
public:
+ enum Location {
+ Tmp,
+ Downloads
+ };
+
explicit HarbourTemporaryFile(QObject* aParent = NULL);
~HarbourTemporaryFile();
QString content() const;
- void setContent(QString value);
+ void setContent(QString aValue);
QString fileTemplate() const;
- void setFileTemplate(QString value);
+ void setFileTemplate(QString aValue);
+
+ Location location() const;
+ void setLocation(Location aValue);
QString fileName() const;
QUrl url() const;
@@ -63,6 +77,7 @@
void fileTemplateChanged();
void contentChanged();
void fileNameChanged();
+ void locationChanged();
void urlChanged();
private:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourTheme.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -37,14 +37,23 @@
#include <QObject>
#include <QColor>
+class QQmlEngine;
+class QJSEngine;
+
class HarbourTheme : public QObject
{
Q_OBJECT
+ Q_ENUMS(ColorScheme)
Q_PROPERTY(ColorScheme colorScheme READ colorScheme NOTIFY colorSchemeChanged)
+ Q_PROPERTY(QColor invertedPrimaryColor READ invertedPrimaryColor NOTIFY primaryColorChanged)
Q_PROPERTY(QColor primaryColor READ primaryColor NOTIFY primaryColorChanged)
Q_PROPERTY(bool lightOnDark READ lightOnDark NOTIFY colorSchemeChanged)
Q_PROPERTY(bool darkOnLight READ darkOnLight NOTIFY colorSchemeChanged)
- Q_ENUMS(ColorScheme)
+
+ Q_PROPERTY(qreal opacityFaint READ opacityFaint CONSTANT)
+ Q_PROPERTY(qreal opacityLow READ opacityLow CONSTANT)
+ Q_PROPERTY(qreal opacityHigh READ opacityHigh CONSTANT)
+ Q_PROPERTY(qreal opacityOverlay READ opacityOverlay CONSTANT)
public:
class Private;
@@ -54,15 +63,27 @@
DarkOnLight
};
- explicit HarbourTheme(QObject* aParent = NULL);
+ explicit HarbourTheme(QObject* aParent = Q_NULLPTR);
~HarbourTheme();
+ // Callback for qmlRegisterSingletonType<HarbourTheme>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
+ QColor invertedPrimaryColor() const;
QColor primaryColor() const;
ColorScheme colorScheme() const;
bool lightOnDark() const;
bool darkOnLight() const;
+ qreal opacityFaint() const;
+ qreal opacityLow() const;
+ qreal opacityHigh() const;
+ qreal opacityOverlay() const;
+
+ Q_INVOKABLE static QColor invertedColor(const QColor& aColor);
+ Q_INVOKABLE static qreal colorDifference(const QColor& aColor1, const QColor& aColor2);
+
Q_SIGNALS:
void colorSchemeChanged();
void primaryColorChanged();
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourTransferMethodsModel.h
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2016-2018 Jolla Ltd.
- * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2020 Jolla Ltd.
+ * Copyright (C) 2016-2020 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
@@ -11,33 +11,36 @@
* 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 name of 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.
+ * 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.
+ * 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.
*/
#ifndef HARBOUR_TRANSFER_METHODS_MODEL_H
#define HARBOUR_TRANSFER_METHODS_MODEL_H
#include "HarbourTransferMethodInfo.h"
+
#include <QLocale>
-#include <QRegExp>
class QTranslator;
+class QQmlEngine;
+class QJSEngine;
class HarbourTransferMethodsModel: public QAbstractListModel
{
@@ -45,63 +48,43 @@
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
Q_PROPERTY(bool accountIconSupported READ accountIconSupported NOTIFY accountIconSupportedChanged)
- typedef QDBusPendingCallWatcher* (HarbourTransferMethodsModel::*RequestUpdate)();
-
-public:
- enum TransferMethodsRole {
- DisplayNameRole = Qt::UserRole + 1,
- UserNameRole,
- MethodIdRole,
- ShareUIPathRole,
- AccountIdRole,
- AccountIconRole
- };
+ Q_PROPERTY(bool showAccountsPending READ showAccountsPending NOTIFY showAccountsPendingChanged)
+ Q_PROPERTY(bool canShowAccounts READ canShowAccounts NOTIFY canShowAccountsChanged)
public:
- explicit HarbourTransferMethodsModel(QObject* aParent = NULL);
+ explicit HarbourTransferMethodsModel(QObject* aParent = Q_NULLPTR);
~HarbourTransferMethodsModel();
+ // Callback for qmlRegisterSingletonType<HarbourTransferMethodsModel>
+ static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
+
static bool loadTranslations(QTranslator* aTranslator, QLocale aLocale);
int count() const;
QString filter() const;
void setFilter(QString filter);
bool accountIconSupported() const;
+ bool showAccountsPending() const;
+ bool canShowAccounts() const;
- int rowCount(const QModelIndex& aParent) const;
- QVariant data(const QModelIndex& aIndex, int aRole) const;
-
-protected:
- QHash<int,QByteArray> roleNames() const;
+ Q_INVOKABLE void showAccounts();
-private:
- void filterModel();
- static QRegExp regExp(QString aRegExp);
- QDBusPendingCallWatcher* checkTransferMethods();
- QDBusPendingCallWatcher* requestTransferMethods();
- QDBusPendingCallWatcher* requestTransferMethods2();
- void setTransferMethods2(HarbourTransferMethodInfo2List aList);
-
-private Q_SLOTS:
- void onTransferMethodsCheckFinished(QDBusPendingCallWatcher* aWatch);
- void onTransferMethodsFinished(QDBusPendingCallWatcher* aWatch);
- void onTransferMethods2Finished(QDBusPendingCallWatcher* aWatch);
- void requestUpdate();
+ // 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 countChanged();
void filterChanged();
void accountIconSupportedChanged();
+ void showAccountsPendingChanged();
+ void canShowAccountsChanged();
private:
+ class Private;
class TransferEngine;
- TransferEngine* iTransferEngine;
- QString iFilter;
- QList<HarbourTransferMethodInfo2> iMethodList;
- QList<int> iFilteredList;
- bool iAccountIconSupported;
- RequestUpdate iRequestUpdate;
- QDBusPendingCallWatcher* iUpdateWatcher;
+ Private* iPrivate;
};
#endif // HARBOUR_TRANSFER_METHODS_MODEL_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourUtil.h
^
|
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 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_UTIL_H
+#define HARBOUR_UTIL_H
+
+#include <QByteArray>
+#include <QColor>
+#include <QObject>
+#include <QRgb>
+#include <QString>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourUtil :
+ public QObject
+{
+ Q_OBJECT
+ class Private;
+
+public:
+ explicit HarbourUtil(QObject* aParent = Q_NULLPTR);
+
+ // Callback for qmlRegisterSingletonType<HarbourUtil>
+ static QObject* createSingleton(QQmlEngine*, QJSEngine*);
+
+ // QML (and possibly native) utilities
+ Q_INVOKABLE static QColor invertedColor(const QColor&);
+
+ // Static utilities
+ static QRgb invertedRgb(QRgb);
+ static QByteArray toHexBytes(const void*, size_t);
+ static QString toHex(const void*, size_t);
+ static inline QString toHex(const QByteArray& aData)
+ { return toHex(aData.constData(), aData.size()); }
+};
+
+#endif // HARBOUR_UTIL_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourBadge.qml
^
|
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+Item {
+ id: badge
+
+ property real maxWidth: parent.width
+ property alias text: label.text
+ property alias backgroundColor: background.color
+ property alias textColor: label.color
+
+ readonly property real radius: height/2
+
+ width: Math.max(label.implicitWidth + radius, height)
+ height: Theme.itemSizeSmall/2
+ visible: opacity > 0
+ opacity: text.length ? 1 : 0
+
+ Behavior on opacity { FadeAnimation {} }
+
+ Rectangle {
+ id: background
+
+ anchors.fill: parent
+ color: Theme.rgba(Theme.primaryColor, 0.2)
+ radius: badge.radius
+ }
+
+ HarbourFitLabel {
+ id: label
+
+ font.bold: true
+ maxWidth: Math.max(badge.maxWidth - radius, 2 * radius)
+ maxHeight: Math.floor(parent.height - radius/2)
+ anchors.centerIn: background
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/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:harbour-meecalc-1.0.10.tar.bz2/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:harbour-meecalc-1.0.10.tar.bz2/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
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourFitLabel.qml
^
|
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+Label {
+ property int minFontSize: Theme.fontSizeTiny
+ property int maxFontSize: Theme.fontSizeMedium
+ property real maxWidth: width
+ property real maxHeight: height
+ property bool refitting
+
+ smooth: true
+ visible: opacity > 0
+ color: Theme.highlightColor
+ anchors.margins: Theme.paddingMedium
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+
+ Behavior on opacity { FadeAnimation {} }
+
+ Component.onCompleted: {
+ refitting = true
+ font.pixelSize = maxFontSize
+ refitTextRun()
+ refitting = false
+ }
+
+ onMaxWidthChanged: refitText()
+ onMaxHeightChanged: refitText()
+ onTextChanged: refitText()
+ onMaxFontSizeChanged: refitText()
+ onMinFontSizeChanged: refitText()
+
+ function refitText() {
+ if (!refitting) {
+ refitting = true
+ refitTextRun()
+ refitting = false
+ }
+ }
+
+ function refitTextRun() {
+ if (implicitHeight > 0 && implicitWidth > 0) {
+ if (font.pixelSize % 2) font.pixelSize++
+ while ((implicitWidth > maxWidth || implicitHeight > maxHeight || font.pixelSize > maxFontSize) && (font.pixelSize - 2) >= minFontSize) {
+ font.pixelSize -= 2
+ }
+ while (implicitWidth < maxWidth && implicitHeight < maxHeight && (font.pixelSize + 2) <= maxFontSize) {
+ font.pixelSize += 2
+ }
+ if (implicitWidth > maxWidth || implicitHeight > maxHeight) {
+ font.pixelSize -= 2
+ }
+ }
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourGrayscaleEffect.qml
^
|
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+ShaderEffect {
+ property variant source
+
+ vertexShader: "
+ uniform highp mat4 qt_Matrix;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 coord;
+ void main() {
+ coord = qt_MultiTexCoord0;
+ gl_Position = qt_Matrix * qt_Vertex;
+ }"
+ fragmentShader: "
+ varying highp vec2 coord;
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ void main() {
+ lowp vec4 tex = texture2D(source, coord);
+ gl_FragColor = vec4(vec3(dot(tex.rgb,
+ vec3(0.344, 0.5, 0.156))),
+ tex.a) * qt_Opacity;
+ }"
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourHighlightIcon.qml
^
|
@@ -0,0 +1,38 @@
+// This is basically a Qt example slightly adapted for Sailfish OS
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Image {
+ id: icon
+
+ property bool highlightEnabled: true
+ property color highlightColor: Theme.highlightColor
+
+ layer.enabled: highlightEnabled
+ layer.effect: ShaderEffect {
+ property variant src: icon
+ property color highlight: highlightColor
+
+ vertexShader: "
+ uniform highp mat4 qt_Matrix;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 coord;
+ void main() {
+ coord = qt_MultiTexCoord0;
+ gl_Position = qt_Matrix * qt_Vertex;
+ }"
+ fragmentShader: "
+ varying highp vec2 coord;
+ uniform sampler2D src;
+ uniform lowp vec4 highlight;
+ uniform lowp float qt_Opacity;
+ void main() {
+ lowp vec4 tex = texture2D(src, coord);
+ gl_FragColor = vec4(vec3(dot(tex.rgb,
+ vec3(0.344, 0.5, 0.156))),
+ tex.a) * qt_Opacity * highlight;
+ }"
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourHintIconButton.qml
^
|
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+MouseArea {
+ property alias icon: image
+ property bool down: pressed && containsMouse
+ property bool highlighted: down
+ property string hint
+
+ signal showHint(var text)
+ signal hideHint()
+
+ width: Theme.itemSizeSmall
+ height: Theme.itemSizeSmall
+
+ readonly property bool _showPress: highlighted || pressTimer.running
+
+ onPressedChanged: {
+ if (pressed) {
+ pressTimer.start()
+ }
+ }
+
+ onClicked: hideHint()
+
+ onReleased: hideHint()
+
+ onPressAndHold: if (hint !== "") showHint(hint)
+
+ onCanceled: {
+ pressTimer.stop()
+ hideHint()
+ }
+
+ Timer {
+ id: pressTimer
+
+ interval: 50
+ }
+
+ HarbourHighlightIcon {
+ id: image
+
+ highlightColor: _showPress ? Theme.highlightColor : Theme.primaryColor
+ sourceSize: Qt.size(Theme.iconSizeMedium, Theme.iconSizeMedium)
+ anchors.centerIn: parent
+ opacity: parent.enabled ? 1.0 : 0.4
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourHorizontalSwipeHint.qml
^
|
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2019-2020 Jolla Ltd.
+ * Copyright (C) 2019-2020 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+Item {
+ id: hint
+
+ anchors.fill: parent
+
+ property bool swipeRight
+ property bool bothWays
+ property bool hintEnabled
+ property alias text: label.text
+ property alias hintDelay: hintDelayTimer.interval
+ property alias loops: touchInteractionHint.loops
+ readonly property bool hintRunning: hintDelayTimer.running || touchInteractionHint.running || label.opacity > 0
+
+ signal hintShown()
+
+ function showHint() {
+ if (!touchInteractionHint.running) {
+ touchInteractionHint.direction = touchInteractionHint.defaultDirection
+ touchInteractionHint.start()
+ }
+ }
+
+ onHintEnabledChanged: {
+ if (hint.hintEnabled) {
+ hintDelayTimer.restart()
+ } else {
+ hintDelayTimer.stop()
+ }
+ }
+
+ Component.onCompleted: if (hint.hintEnabled) hintDelayTimer.start()
+
+ InteractionHintLabel {
+ id: label
+
+ anchors.bottom: parent.bottom
+ opacity: touchInteractionHint.running ? 1.0 : 0.0
+ Behavior on opacity { FadeAnimation { duration: 1000 } }
+ }
+
+ TouchInteractionHint {
+ id: touchInteractionHint
+
+ readonly property int defaultDirection: swipeRight ? TouchInteraction.Right : TouchInteraction.Left
+ readonly property int otherDirection: swipeRight ? TouchInteraction.Left : TouchInteraction.Right
+ anchors.verticalCenter: parent.verticalCenter
+ onRunningChanged: {
+ if (!running) {
+ if (bothWays && direction === defaultDirection) {
+ direction = otherDirection
+ start()
+ } else {
+ hint.hintShown()
+ }
+ }
+ }
+ }
+
+ Timer {
+ id: hintDelayTimer
+
+ interval: 1000
+ onTriggered: showHint()
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourIconTextButton.qml
^
|
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2018-2020 Jolla Ltd.
+ * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+MouseArea {
+ property alias icon: image
+ property bool down: pressed && containsMouse
+ property bool highlighted: down
+ property alias iconSource: image.source
+ property alias text: label.text
+
+ readonly property bool _showPress: highlighted || pressTimer.running
+
+ onPressedChanged: {
+ if (pressed) {
+ pressTimer.start()
+ }
+ }
+
+ onCanceled: pressTimer.stop()
+
+ width: Math.max(image.width, label.width)
+ height: image.height + label.height
+
+ HarbourHighlightIcon {
+ id: image
+
+ highlightColor: _showPress ? Theme.highlightColor : Theme.primaryColor
+ sourceSize: Qt.size(Theme.itemSizeSmall, Theme.itemSizeSmall)
+ opacity: parent.enabled ? 1.0 : 0.4
+ anchors {
+ top: parent.top
+ horizontalCenter: parent.horizontalCenter
+ }
+ }
+
+ Label {
+ id: label
+
+ height: text.length ? (implicitHeight + Theme.paddingMedium) : 0
+ opacity: parent.enabled ? 1.0 : 0.4
+ anchors {
+ top: image.bottom
+ horizontalCenter: parent.horizontalCenter
+ }
+ wrapMode: Text.Wrap
+ font.pixelSize: Theme.fontSizeExtraSmall
+ color: _showPress ? Theme.secondaryHighlightColor : Theme.secondaryColor
+ }
+
+ Timer {
+ id: pressTimer
+
+ interval: ('minimumPressHighlightTime' in Theme) ? Theme.minimumPressHighlightTime : 64
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourInvertEffect.qml
^
|
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+ShaderEffect {
+ property variant source
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main(void) {
+ highp vec4 pixelColor = texture2D(source, qt_TexCoord0);
+ gl_FragColor = vec4(vec3(1,1,1) - pixelColor.rgb, pixelColor.a) * qt_Opacity;
+ }"
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourPasswordInputField.qml
^
|
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+TextField {
+ id: field
+
+ property bool showEchoModeToggle: activeFocus
+ property int passwordEchoMode: TextInput.Password
+
+ property bool _usePasswordEchoMode: true
+ property int _buttonLeftMargin: Theme.paddingLarge
+
+ width: (parent ? parent.width : Screen.width) - 2*x
+ textRightMargin: textMargin
+ echoMode: _usePasswordEchoMode ? passwordEchoMode : TextInput.Normal
+ inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
+ placeholderText: label
+
+ //: Default label for password field
+ //% "Password"
+ label: qsTrId("components-la-password")
+
+ function requestFocus() {
+ focusOutBehavior = FocusBehavior.KeepFocus
+ forceActiveFocus()
+ keepFocusTimer.start()
+ }
+
+ Connections {
+ target: Qt.application
+ onActiveChanged: {
+ if (!Qt.application.active) {
+ _usePasswordEchoMode = true
+ if (!readOnly) text = "" // Reset whatever has been typed
+ }
+ }
+ }
+
+ Timer {
+ id: keepFocusTimer
+
+ interval: 500
+ onTriggered: field.focusOutBehavior = FocusBehavior.ClearItemFocus
+ }
+
+ states: State {
+ name: "showToggle"
+ when: field.showEchoModeToggle
+ PropertyChanges {
+ target: field
+ textRightMargin: field._buttonLeftMargin/2 + passwordVisibilityButton.width + field.textMargin
+ }
+ PropertyChanges {
+ target: passwordVisibilityButton
+ opacity: 1
+ enabled: true
+ }
+ }
+
+ transitions: Transition {
+ from: ""
+ to: "showToggle"
+ reversible: true
+ NumberAnimation {
+ property: "textRightMargin"
+ duration: 50
+ }
+ FadeAnimation {
+ target: passwordVisibilityButton
+ }
+ }
+
+ MouseArea {
+ id: passwordVisibilityButton
+
+ parent: field // ensure the field is visible, avoid auto-parenting to TextBase contentItem
+ x: field.width - width - field.textMargin
+ width: Math.max(textAbc.implicitWidth, textDots.implicitWidth) + field._buttonLeftMargin/2
+ height: field.height - Theme.paddingLarge
+ opacity: 0
+ enabled: false
+
+ onClicked: {
+ field._usePasswordEchoMode = !field._usePasswordEchoMode
+ }
+
+ Text {
+ id: textAbc
+
+ anchors {
+ top: parent.top
+ topMargin: field.textTopMargin
+ horizontalCenter: parent.horizontalCenter
+ }
+ visible: field.echoMode == TextInput.Password
+ font.pixelSize: Theme.fontSizeMedium
+ text: "abc"
+ textFormat: Text.PlainText
+ color: parent.pressed && parent.containsMouse ? Theme.highlightColor : Theme.primaryColor
+ }
+
+ Text {
+ id: textDots
+
+ anchors {
+ top: parent.top
+ topMargin: field.textTopMargin
+ horizontalCenter: parent.horizontalCenter
+ }
+ visible: field.echoMode == TextInput.Normal
+ font.pixelSize: Theme.fontSizeMedium
+ text: "\u2022\u2022\u2022"
+ textFormat: Text.PlainText
+ color: parent.pressed && parent.containsMouse ? Theme.highlightColor : Theme.primaryColor
+ }
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourPressEffect.qml
^
|
@@ -0,0 +1,18 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+ShaderEffect {
+ property variant source
+ property color color: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec4 color;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main(void) {
+ highp vec4 pixelColor = texture2D(source, qt_TexCoord0);
+ gl_FragColor = vec4(mix(pixelColor.rgb/max(pixelColor.a, 0.00390625),
+ color.rgb/max(color.a, 0.00390625), color.a) *
+ pixelColor.a, pixelColor.a) * qt_Opacity;
+ }"
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourShakeAnimation.qml
^
|
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 Jolla Ltd.
+ * Copyright (C) 2018 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+SequentialAnimation {
+ id: animation
+
+ property var target
+ property real amplitude: Theme.horizontalPageMargin * 4 / 5
+ property real x: 0
+
+ alwaysRunToEnd: true
+
+ NumberAnimation {
+ target: animation.target
+ property: "x"
+ to: animation.x + animation.amplitude
+ duration: 25
+ easing.type: Easing.InOutSine
+ }
+
+ NumberAnimation {
+ target: animation.target
+ property: "x"
+ from: animation.x + animation.amplitude
+ to: animation.x
+ duration: 500
+ easing.type: Easing.OutElastic
+ easing.amplitude: 2
+ easing.period: 0.2
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourShareMethodList.qml
^
|
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+SilicaListView {
+ id: view
+
+ property url source
+ property string subject
+ property string emailTo
+ property string type
+
+ width: parent.width
+ height: Theme.itemSizeSmall * model.count
+
+ property string addAccountText: "Add account"
+ readonly property bool accountIconSupported: model.accountIconSupported
+ property var content: []
+ // model: HarbourTransferMethodsModel
+
+ onTypeChanged: content.type = type
+
+ Component.onCompleted: content.type = type
+
+ delegate: BackgroundItem {
+ id: backgroundItem
+ width: view.width
+
+ Image {
+ id: icon
+
+ x: Theme.horizontalPageMargin
+ anchors.verticalCenter: parent.verticalCenter
+ source: accountIcon ? accountIcon :
+ view.accountIconSupported ? "image://theme/icon-m-share" : ""
+ visible: view.accountIconSupported
+ }
+
+ Label {
+ id: displayNameLabel
+
+ text: displayName
+ color: backgroundItem.highlighted ? Theme.highlightColor : Theme.primaryColor
+ truncationMode: TruncationMode.Fade
+ x: Theme.horizontalPageMargin
+ anchors {
+ left: icon.visible ? icon.right : parent.left
+ leftMargin: icon.visible ? Theme.paddingMedium : Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
+ width: Math.min(implicitWidth, parent.width - 2*Theme.horizontalPageMargin)
+ }
+
+ Label {
+ text: userName
+ font.pixelSize: Theme.fontSizeMedium
+ color: backgroundItem.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
+ truncationMode: TruncationMode.Fade
+ anchors {
+ left: displayNameLabel.right
+ leftMargin: Theme.paddingSmall
+ right: parent.right
+ rightMargin: Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
+ visible: text.length > 0
+ }
+
+ onClicked: {
+ pageStack.push(model.shareUIPath, {
+ source: view.source,
+ content: content,
+ methodId: model.methodId,
+ displayName: model.displayName,
+ accountId: model.accountId,
+ accountName: model.userName,
+ emailTo: view.emailTo,
+ emailSubject: view.subject
+ })
+ }
+ }
+
+ footer: BackgroundItem {
+ enabled: model.canShowAccounts && !model.showAccountsPending
+ opacity: enabled ? 1.0 : 0.4
+
+ Image {
+ id: addAccountIcon
+
+ x: Theme.horizontalPageMargin
+ anchors.verticalCenter: parent.verticalCenter
+ source: view.accountIconSupported ?
+ ("image://theme/icon-m-add" + (parent.highlighted ? "?" + Theme.highlightColor : "")) : ""
+ visible: view.accountIconSupported
+ }
+
+ Label {
+ text: addAccountText
+ x: Theme.horizontalPageMargin
+ anchors {
+ left: addAccountIcon.visible ? addAccountIcon.right : parent.left
+ leftMargin: addAccountIcon.visible ? Theme.paddingMedium : Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
+ color: highlighted ? Theme.highlightColor : Theme.primaryColor
+ }
+
+ onClicked: model.showAccounts()
+ }
+
+ VerticalScrollDecorator { }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourTextFlip.qml
^
|
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of 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
+
+Rotation {
+ id: rotation
+
+ property string text
+ property Item target
+ property real duration: 500
+ property bool enabled: true
+ property string property: "text"
+ readonly property bool running: animation.running
+
+ property var animation: SequentialAnimation {
+ alwaysRunToEnd: true
+
+ onRunningChanged: {
+ if (!running && target[property] != rotation.text) {
+ start()
+ }
+ }
+
+ NumberAnimation {
+ easing.type: Easing.InOutSine
+ target: rotation
+ property: "angle"
+ from: 0
+ to: 90
+ duration: rotation.duration/2
+ }
+ ScriptAction { script: target[property] = rotation.text; }
+ NumberAnimation {
+ easing.type: Easing.InOutSine
+ target: rotation
+ property: "angle"
+ to: 0
+ duration: rotation.duration/2
+ }
+ }
+
+ origin {
+ x: target.width / 2
+ y: target.height / 2
+ }
+
+ axis {
+ x: 1
+ y: 0
+ z: 0
+ }
+
+ function flipTo(value) {
+ if (!!target) {
+ animation.start()
+ text = value
+ }
+ }
+
+ function _updateTargetProperty() {
+ if (!!target) {
+ if (enabled) {
+ animation.start()
+ } else if (!animation.running) {
+ target[property] = text
+ }
+ }
+ }
+
+ onTextChanged: _updateTargetProperty()
+ onTargetChanged: _updateTargetProperty()
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourAztecCodeGenerator.cpp
^
|
@@ -0,0 +1,244 @@
+/*
+ * 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:
+ *
+ * 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 "HarbourAztecCodeGenerator.h"
+
+#include "HarbourBase32.h"
+#include "HarbourTask.h"
+#include "HarbourDebug.h"
+
+#include <QThreadPool>
+
+#include "aztec_encode.h" // Requires https://github.com/monich/libaztec
+
+// ==========================================================================
+// HarbourAztecCodeGenerator::Task
+// ==========================================================================
+
+class HarbourAztecCodeGenerator::Task : public HarbourTask {
+ Q_OBJECT
+public:
+ 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,
+ int aEcLevel) :
+ HarbourTask(aPool),
+ iText(aText),
+ iEcLevel(aEcLevel)
+{
+}
+
+void HarbourAztecCodeGenerator::Task::performTask()
+{
+ QByteArray bytes(generate(iText, iEcLevel));
+ if (!bytes.isEmpty()) {
+ iCode = HarbourBase32::toBase32(bytes);
+ }
+}
+
+// ==========================================================================
+// HarbourAztecCodeGenerator::Private
+// ==========================================================================
+
+class HarbourAztecCodeGenerator::Private : public QObject {
+ Q_OBJECT
+
+public:
+ Private(HarbourAztecCodeGenerator* aParent);
+ ~Private();
+
+ HarbourAztecCodeGenerator* parentObject() const;
+ void setText(QString aValue);
+ void setEcLevel(int aValue);
+ void regenerate();
+
+ static int realEcLevel(int aEcLevel);
+
+public Q_SLOTS:
+ void onTaskDone();
+
+public:
+ QThreadPool* iThreadPool;
+ Task* iTask;
+ int iEcLevel;
+ QString iText;
+ QString iCode;
+};
+
+HarbourAztecCodeGenerator::Private::Private(HarbourAztecCodeGenerator* aParent) :
+ QObject(aParent),
+ iThreadPool(new QThreadPool(this)),
+ iTask(Q_NULLPTR),
+ iEcLevel(ECLevelDefault)
+{
+ // Serialize the tasks:
+ iThreadPool->setMaxThreadCount(1);
+}
+
+HarbourAztecCodeGenerator::Private::~Private()
+{
+ iThreadPool->waitForDone();
+}
+
+inline HarbourAztecCodeGenerator* HarbourAztecCodeGenerator::Private::parentObject() const
+{
+ 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;
+ 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();
+ }
+}
+
+void HarbourAztecCodeGenerator::Private::onTaskDone()
+{
+ if (sender() == iTask) {
+ HarbourAztecCodeGenerator* obj = parentObject();
+ const bool changed = (iCode != iTask->iCode);
+ iCode = iTask->iCode;
+ iTask->release();
+ iTask = NULL;
+ if (changed) {
+ Q_EMIT obj->codeChanged();
+ }
+ Q_EMIT obj->runningChanged();
+ }
+}
+
+// ==========================================================================
+// HarbourAztecCodeGenerator
+// ==========================================================================
+
+HarbourAztecCodeGenerator::HarbourAztecCodeGenerator(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+}
+
+// Callback for qmlRegisterSingletonType<HarbourAztecCodeGenerator>
+QObject* HarbourAztecCodeGenerator::createSingleton(QQmlEngine*, QJSEngine*)
+{
+ return new HarbourAztecCodeGenerator();
+}
+
+QString HarbourAztecCodeGenerator::text() const
+{
+ return iPrivate->iText;
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourBase32.cpp
^
|
@@ -0,0 +1,267 @@
+/*
+ * Copyright (C) 2019-2022 Jolla Ltd.
+ * Copyright (C) 2019-2022 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"
+
+#define BASE32_BITS_PER_NIBBLE (5)
+#define BASE32_BYTES_PER_CHUNK (5)
+#define BASE32_NIBBLES_PER_CHUNK (8)
+#define BASE32_BITS_PER_CHUNK (BASE32_BITS_PER_NIBBLE*BASE32_NIBBLES_PER_CHUNK)
+#define BASE32_NIBBLE_MASK ((1 << BASE32_BITS_PER_NIBBLE) - 1)
+Q_STATIC_ASSERT(BASE32_BITS_PER_CHUNK == BASE32_BYTES_PER_CHUNK * 8);
+
+// ==========================================================================
+// HarbourBase32::Private
+// ==========================================================================
+
+class HarbourBase32::Private
+{
+public:
+ static char nibbleToBase32(int, char);
+ static int base32ToNibble(char);
+};
+
+inline
+char
+HarbourBase32::Private::nibbleToBase32(
+ int aNibble,
+ char aBaseChar)
+{
+ return (aNibble < 26) ? (aBaseChar + aNibble) : ('2' + (aNibble - 26));
+}
+
+inline
+int
+HarbourBase32::Private::base32ToNibble(
+ char aChar)
+{
+ if (aChar >= 'a' && aChar <= 'z') {
+ return aChar - 'a';
+ } else if (aChar >= 'A' && aChar <= 'Z') {
+ return aChar - 'A';
+ } else if (aChar >= '2' && aChar <= '7') {
+ return 26 + (aChar - '2');
+ } else {
+ return -1;
+ }
+}
+
+// ==========================================================================
+// HarbourBase32
+// ==========================================================================
+
+bool
+HarbourBase32::isValidBase32(
+ QString aBase32)
+{
+ const int n = aBase32.length();
+ const QChar* chars = aBase32.constData();
+
+ qint64 buf = 0;
+ int i, bits = 0;
+ bool empty = true;
+
+ for (i = 0; i < n; i++) {
+ const QChar c = chars[i];
+
+ if (!c.isSpace()) {
+ const char l = c.toLatin1();
+
+ empty = false;
+ if (l == '=') {
+ i++;
+ break;
+ } else {
+ const int nibble = Private::base32ToNibble(l);
+
+ if (nibble < 0) {
+ HDEBUG("Invalid BASE32 character" << c);
+ return false;
+ }
+ bits += BASE32_BITS_PER_NIBBLE;
+ buf <<= BASE32_BITS_PER_NIBBLE;
+ buf += nibble;
+ if (bits == BASE32_BITS_PER_CHUNK) {
+ bits = 0;
+ buf = 0;
+ }
+ }
+ }
+ }
+
+ // Handle padding per RFC 4648
+ if (bits) {
+ while (i < n) {
+ const QChar c = chars[i++];
+
+ if (!c.isSpace()) {
+ empty = false;
+ if (c != '=') {
+ HDEBUG("Invalid BASE32 string" << aBase32);
+ return false;
+ }
+ }
+ }
+ const int realbits = bits/8*8;
+ const int mask = (1 << (bits - realbits)) - 1;
+ if (buf & mask) {
+ return false;
+ }
+ }
+ return !empty;
+}
+
+QByteArray
+HarbourBase32::fromBase32(
+ const QString aBase32)
+{
+ QByteArray out;
+
+ const int n = aBase32.length();
+ const QChar* chars = aBase32.constData();
+
+ qint64 buf = 0;
+ int i, bits = 0;
+ char bytes[BASE32_BYTES_PER_CHUNK];
+
+ out.reserve((n * 5 + 7)/8);
+
+ for (i = 0; i < n; i++) {
+ const QChar c = chars[i];
+
+ if (!c.isSpace()) {
+ const char l = c.toLatin1();
+
+ if (l == '=') {
+ i++;
+ break;
+ } else {
+ const int nibble = Private::base32ToNibble(l);
+
+ if (nibble < 0) {
+ HDEBUG("Invalid BASE32 character" << c);
+ return QByteArray();
+ } else {
+ bits += BASE32_BITS_PER_NIBBLE;
+ buf <<= BASE32_BITS_PER_NIBBLE;
+ buf += nibble;
+ if (bits == BASE32_BITS_PER_CHUNK) {
+ bits = 0;
+ for (int k = BASE32_BYTES_PER_CHUNK; k > 0; k--) {
+ bytes[k - 1] = (char)buf;
+ buf >>= 8;
+ }
+ out.append(bytes, BASE32_BYTES_PER_CHUNK);
+ }
+ }
+ }
+ }
+ }
+
+ // Handle padding per RFC 4648
+ if (bits) {
+ while (i < n) {
+ const QChar c = chars[i++];
+
+ if (!c.isSpace() && c != '=') {
+ HDEBUG("Invalid BASE32 string" << aBase32);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourBase45.cpp
^
|
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 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);
+};
+
+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 aChar)
+{
+ return (aChar < Private::REVERSE_MAP_SIZE) &&
+ Private::reverseMapBase45[aChar] >= 0;
+}
+
+// ==========================================================================
+// HarbourBase45::Private
+// ==========================================================================
+
+bool
+HarbourBase45::isValidBase45(
+ const 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(
+ const 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(
+ const 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);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourBattery.cpp
^
|
@@ -0,0 +1,266 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 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 "HarbourBattery.h"
+#include "HarbourDebug.h"
+#include "HarbourMce.h"
+
+#include <QDBusPendingCallWatcher>
+#include <QDBusPendingReply>
+
+// ==========================================================================
+// HarbourBattery::Private
+// ==========================================================================
+
+class HarbourBattery::Private : public HarbourMce
+{
+ Q_OBJECT
+
+public:
+ static const QString MCE_BATTERY_STATUS_UNKNOWN;
+ static const QString MCE_BATTERY_STATUS_FULL;
+ static const QString MCE_BATTERY_STATUS_OK;
+ static const QString MCE_BATTERY_STATUS_LOW;
+ static const QString MCE_BATTERY_STATUS_EMPTY;
+
+ static const QString MCE_BATTERY_STATE_UNKNOWN;
+ static const QString MCE_BATTERY_STATE_DISCHARGING;
+ static const QString MCE_BATTERY_STATE_CHARGING;
+ static const QString MCE_BATTERY_STATE_NOT_CHARGING;
+ static const QString MCE_BATTERY_STATE_FULL;
+
+ Private(HarbourBattery*);
+
+ HarbourBattery* parentObject() const;
+
+public Q_SLOTS:
+ void updateBatteryStatus(const QString);
+ void updateBatteryState(const QString);
+ void updateBatteryLevel(int);
+ void onBatteryStatusQueryDone(QDBusPendingCallWatcher*);
+ void onBatteryStateQueryDone(QDBusPendingCallWatcher*);
+ void onBatteryLevelQueryDone(QDBusPendingCallWatcher*);
+
+public:
+ BatteryStatus iBatteryStatus;
+ BatteryState iBatteryState;
+ int iBatteryLevel;
+};
+
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_UNKNOWN("unknown");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_FULL("full");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_OK("ok");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_LOW("low");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_EMPTY("empty");
+
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_UNKNOWN("unknown");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_DISCHARGING("discharging");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_CHARGING("charging");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_NOT_CHARGING("not_charging");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_FULL("full");
+
+HarbourBattery::Private::Private(
+ HarbourBattery* aParent) :
+ HarbourMce(aParent),
+ iBatteryStatus(BatteryStatusUnknown),
+ iBatteryState(BatteryStateUnknown),
+ iBatteryLevel(0)
+{
+ setupProperty("get_battery_status", "battery_status_ind",
+ SLOT(onBatteryStatusQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(updateBatteryStatus(QString)));
+ setupProperty("get_battery_state", "battery_state_ind",
+ SLOT(onBatteryStateQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(updateBatteryState(QString)));
+ setupProperty("get_battery_level", "battery_level_ind",
+ SLOT(onBatteryLevelQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(updateBatteryLevel(int)));
+}
+
+inline
+HarbourBattery*
+HarbourBattery::Private::parentObject() const
+{
+ return qobject_cast<HarbourBattery*>(parent());
+}
+
+void
+HarbourBattery::Private::updateBatteryStatus(
+ const QString aStatus)
+{
+ BatteryStatus status = BatteryStatusUnknown;
+
+ if (aStatus == MCE_BATTERY_STATUS_OK) {
+ status = BatteryStatusOk;
+ } else if (aStatus == MCE_BATTERY_STATUS_FULL) {
+ status = BatteryStatusFull;
+ } else if (aStatus == MCE_BATTERY_STATUS_LOW) {
+ status = BatteryStatusLow;
+ } else if (aStatus == MCE_BATTERY_STATUS_EMPTY) {
+ status = BatteryStatusEmpty;
+ } else if (aStatus != MCE_BATTERY_STATUS_UNKNOWN) {
+ HWARN("Unexpected battery status" << aStatus);
+ return;
+ }
+
+ if (iBatteryStatus != status) {
+ iBatteryStatus = status;
+ HDEBUG(aStatus);
+ Q_EMIT parentObject()->batteryStatusChanged();
+ }
+}
+
+void
+HarbourBattery::Private::updateBatteryState(
+ const QString aState)
+{
+ BatteryState state = BatteryStateUnknown;
+
+ if (aState == MCE_BATTERY_STATE_CHARGING) {
+ state = BatteryStateCharging;
+ } else if (aState == MCE_BATTERY_STATE_DISCHARGING) {
+ state = BatteryStateDischarging;
+ } else if (aState == MCE_BATTERY_STATE_NOT_CHARGING) {
+ state = BatteryStateNotCharging;
+ } else if (aState == MCE_BATTERY_STATE_FULL) {
+ state = BatteryStateFull;
+ } else if (aState != MCE_BATTERY_STATE_UNKNOWN) {
+ HWARN("Unexpected battery state" << aState);
+ return;
+ }
+
+ if (iBatteryState != state) {
+ iBatteryState = state;
+ HDEBUG(aState);
+ Q_EMIT parentObject()->batteryStateChanged();
+ }
+}
+
+void
+HarbourBattery::Private::updateBatteryLevel(
+ int aLevel)
+{
+ if (iBatteryLevel != aLevel) {
+ iBatteryLevel = aLevel;
+ HDEBUG(aLevel);
+ Q_EMIT parentObject()->batteryLevelChanged();
+ }
+}
+
+void
+HarbourBattery::Private::onBatteryStatusQueryDone(
+ QDBusPendingCallWatcher* aWatcher)
+{
+ QDBusPendingReply<QString> reply(*aWatcher);
+
+ if (reply.isError()) {
+ HWARN(reply.error().message());
+ } else {
+ updateBatteryStatus(reply.value());
+ }
+ aWatcher->deleteLater();
+}
+
+void
+HarbourBattery::Private::onBatteryStateQueryDone(
+ QDBusPendingCallWatcher* aWatcher)
+{
+ QDBusPendingReply<QString> reply(*aWatcher);
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourClipboard.cpp
^
|
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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
+ * 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 "HarbourClipboard.h"
+#include "HarbourDebug.h"
+
+#include <QGuiApplication>
+#include <QClipboard>
+
+// ==========================================================================
+// HarbourClipboard::Private
+// ==========================================================================
+
+class HarbourClipboard::Private : public QObject {
+ Q_OBJECT
+
+public:
+ Private(HarbourClipboard* aParent);
+
+ HarbourClipboard* parentObject() const;
+ void setText(QString aValue);
+ void setCacheText(bool aValue);
+
+public Q_SLOTS:
+ void onClipboardChanged();
+
+public:
+ QClipboard* iClipboard;
+ QString iText;
+ bool iCacheText;
+};
+
+HarbourClipboard::Private::Private(HarbourClipboard* aParent) :
+ QObject(aParent),
+ iClipboard(qApp->clipboard()),
+ iText(iClipboard->text()),
+ iCacheText(true)
+{
+ connect(iClipboard, SIGNAL(dataChanged()), SLOT(onClipboardChanged()));
+}
+
+inline HarbourClipboard* HarbourClipboard::Private::parentObject() const
+{
+ return qobject_cast<HarbourClipboard*>(parent());
+}
+
+void HarbourClipboard::Private::onClipboardChanged()
+{
+ const QString clipboardText(iClipboard->text());
+ HDEBUG(clipboardText);
+ if (iText != clipboardText && (!iCacheText || !clipboardText.isEmpty())) {
+ iText = clipboardText;
+ Q_EMIT parentObject()->textChanged();
+ }
+}
+
+void HarbourClipboard::Private::setText(QString aValue)
+{
+ if (iText != aValue) {
+ iText = aValue;
+ HDEBUG(aValue);
+ Q_EMIT parentObject()->textChanged();
+ if (aValue.isEmpty()) {
+ iClipboard->clear();
+ } else {
+ iClipboard->setText(iText);
+ }
+ }
+}
+
+void HarbourClipboard::Private::setCacheText(bool aValue)
+{
+ if (iCacheText != aValue) {
+ iCacheText = aValue;
+ HDEBUG(aValue);
+ HarbourClipboard* obj = parentObject();
+ Q_EMIT obj->cacheTextChanged();
+ if (!iCacheText) {
+ const QString clipboardText(iClipboard->text());
+ if (iText != clipboardText) {
+ iText = clipboardText;
+ Q_EMIT obj->textChanged();
+ }
+ }
+ }
+}
+
+// ==========================================================================
+// HarbourClipboard::Private
+// ==========================================================================
+
+HarbourClipboard::HarbourClipboard(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+}
+
+// Callback for qmlRegisterSingletonType<HarbourClipboard>
+QObject* HarbourClipboard::createSingleton(QQmlEngine* aEngine, QJSEngine*)
+{
+ return new HarbourClipboard;
+}
+
+QString HarbourClipboard::text() const
+{
+ return iPrivate->iText;
+}
+
+void HarbourClipboard::setText(QString aValue)
+{
+ iPrivate->setText(aValue);
+}
+
+bool HarbourClipboard::cacheText() const
+{
+ return iPrivate->iCacheText;
+}
+
+void HarbourClipboard::setCacheText(bool aValue)
+{
+ iPrivate->setCacheText(aValue);
+}
+
+#include "HarbourClipboard.moc"
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/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);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourDisplayBlanking.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2018 Jolla Ltd.
- * Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2019 Jolla Ltd.
+ * Copyright (C) 2015-2019 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 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.
+ * 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
@@ -35,6 +35,8 @@
#include "HarbourDebug.h"
#include "HarbourMce.h"
+#include <QQmlEngine>
+
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDBusPendingCallWatcher>
@@ -45,11 +47,12 @@
// ==========================================================================
// HarbourDisplayBlanking::Private
// ==========================================================================
+
class HarbourDisplayBlanking::Private : public HarbourMce {
Q_OBJECT
public:
- static const int REPEAT_INERVAL_SEC = 50;
+ static const int REPEAT_INTERVAL_SEC = 50;
static const QString BLANK_ACTIVE;
static const QString BLANK_INACTIVE;
static QWeakPointer<HarbourDisplayBlanking> sSharedInstance;
@@ -91,7 +94,7 @@
iPauseAllowed(false),
iPauseRequested(false),
iPauseActive(false),
- iRepeatTimer(NULL)
+ iRepeatTimer(Q_NULLPTR)
{
HDEBUG("created");
setupProperty("get_display_blanking_pause", "display_blanking_pause_ind",
@@ -197,7 +200,7 @@
if (iPauseActive) {
if (!iRepeatTimer) {
iRepeatTimer = new QTimer(this);
- iRepeatTimer->setInterval(REPEAT_INERVAL_SEC * 1000);
+ iRepeatTimer->setInterval(REPEAT_INTERVAL_SEC * 1000);
iRepeatTimer->setSingleShot(false);
connect(iRepeatTimer, SIGNAL(timeout()),
SLOT(onRepeatBlankingRequest()));
@@ -247,6 +250,15 @@
HDEBUG("destroyed");
}
+// Callback for qmlRegisterSingletonType<HarbourDisplayBlanking>
+QObject*
+HarbourDisplayBlanking::createSingleton(
+ QQmlEngine*,
+ QJSEngine*)
+{
+ return new HarbourDisplayBlanking();
+}
+
QSharedPointer<HarbourDisplayBlanking>
HarbourDisplayBlanking::sharedInstance()
{
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourImageProvider.cpp
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2019 Jolla Ltd.
+ * Copyright (C) 2018-2019 Slava Monich <slava@monich.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
@@ -11,23 +11,24 @@
* 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.
+ * 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.
+ * 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.
+ * 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 "HarbourImageProvider.h"
@@ -82,11 +83,31 @@
HarbourImageProvider::TextureFactory::load() const
{
if (iImage.isNull() && !iPath.isEmpty()) {
- QImageReader imageReader(iPath);
- if (iRequestedSize.width() > 0 && iRequestedSize.height() > 0) {
+ if (iRequestedSize.isEmpty()) {
+ if (iImage.load(iPath) && !iImage.size().isEmpty()) {
+ QSize size(iImage.size());
+ if (iRequestedSize.width() > 0) {
+ size.setHeight(qRound(iRequestedSize.width()*
+ (qreal)size.height()/size.width()));
+ size.setWidth(iRequestedSize.width());
+ } else if (iRequestedSize.height() > 0) {
+ size.setWidth(qRound(iRequestedSize.height()*
+ (qreal)size.width()/size.height()));
+ size.setHeight(iRequestedSize.height());
+ }
+ if (iImage.size() != size) {
+ HDEBUG(iImage.size() << "=>" << size);
+ QImageReader imageReader(iPath);
+ imageReader.setScaledSize(size);
+ imageReader.read(&iImage);
+ }
+ }
+ } else {
+ QImageReader imageReader(iPath);
imageReader.setScaledSize(iRequestedSize);
+ imageReader.read(&iImage);
}
- if (imageReader.read(&iImage) && !iImage.isNull()) {
+ if (!iImage.isNull()) {
if (iHighlight.isEmpty()) {
// Colorize grayscale to match ambience
if (iImage.isGrayscale()) {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourJson.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015 Jolla Ltd.
- * Contact: Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2020 Jolla Ltd.
+ * Copyright (C) 2015-2020 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,27 +8,31 @@
* 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
* 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,
+ * 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 "HarbourJson.h"
@@ -46,35 +50,64 @@
# include <qjson/serializer.h>
#endif
-bool HarbourJson::save(QString aPath, const QVariantMap& aMap)
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+bool HarbourJson::save(const QString& aPath, const QVariantMap& aMap)
{
QFileInfo file(aPath);
QDir dir(file.dir());
if (dir.mkpath(dir.absolutePath())) {
- QFile f(file.absoluteFilePath());
+ const QString absPath(file.absoluteFilePath());
+ QFile f(absPath);
if (!aMap.isEmpty()) {
+ struct stat st;
+ const QByteArray pathBytes(absPath.toLocal8Bit());
+ const char* path = pathBytes.constData();
+ const bool haveFileAttr = (stat(path, &st) == 0);
+
if (f.open(QIODevice::WriteOnly)) {
+ bool ok;
#if QT_VERSION >= 0x050000
if (f.write(QJsonDocument::fromVariant(aMap).toJson()) >= 0) {
- return true;
+ ok = true;
+ } else {
+ HWARN("Error writing" << absPath << f.errorString());
}
#else
QJson::Serializer serializer;
QByteArray json = serializer.serialize(aMap);
if (!json.isNull()) {
- if (f.write(json ) >= 0) {
- return true;
+ if (f.write(json) >= 0) {
+ ok = true;
+ } else {
+ HWARN("Error writing" << absPath << f.errorString());
}
} else {
HWARN("Json serialization error");
}
#endif
- HWARN("Error writing" << aPath << f.errorString());
+ if (ok) {
+ if (haveFileAttr) {
+ // Try to restore ownership and mode
+ if (chown(path, st.st_uid, st.st_gid)) {
+ HWARN("Failed to chown" << path << ":" <<
+ strerror(errno));
+ }
+ if (chmod(path, st.st_mode & ~S_IFMT)) {
+ HWARN("Failed to chmod" << path << ":" <<
+ strerror(errno));
+ }
+ }
+ return true;
+ }
} else {
- HWARN("Error opening" << aPath << f.errorString());
+ HWARN("Error opening" << absPath << f.errorString());
}
} else if (!f.remove()) {
- HWARN("Error removing" << aPath << f.errorString());
+ HWARN("Error removing" << absPath << f.errorString());
}
} else {
HWARN("Failed to create" << dir.absolutePath());
@@ -82,7 +115,7 @@
return false;
}
-bool HarbourJson::load(QString aPath, QVariantMap& aRoot)
+bool HarbourJson::load(const QString& aPath, QVariantMap& aRoot)
{
QFile f(aPath);
if (f.exists()) {
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourMediaPlugin.cpp
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 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 "HarbourMediaPlugin.h"
+#include "HarbourDebug.h"
+
+// Workaround for org.nemomobile.policy (or Sailfish.Media) not being
+// allowed in harbour apps
+
+HarbourMediaPlugin* HarbourMediaPlugin::gInstance = Q_NULLPTR;
+
+const char HarbourMediaPlugin::MEDIAKEY_QML_TYPE[] = "MediaKey";
+
+HarbourMediaPlugin::HarbourMediaPlugin(
+ QQmlEngine* aEngine) :
+ HarbourPluginLoader(aEngine, "Sailfish.Media", 1, 0)
+{
+}
+
+HarbourMediaPlugin::~HarbourMediaPlugin()
+{
+ HASSERT(gInstance == this);
+ gInstance = Q_NULLPTR;
+}
+
+void
+HarbourMediaPlugin::registerTypes(
+ const char* aModule,
+ int aMajor,
+ int aMinor)
+{
+ reRegisterType(MEDIAKEY_QML_TYPE, aModule, aMajor, aMinor);
+}
+
+void
+HarbourMediaPlugin::registerTypes(
+ QQmlEngine* aEngine,
+ const char* aModule,
+ int aMajor,
+ int aMinor)
+{
+ if (!gInstance) {
+ gInstance = new HarbourMediaPlugin(aEngine);
+ }
+ gInstance->registerTypes(aModule, aMajor, aMinor);
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/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);
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourOrganizeListModel.cpp
^
|
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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 "HarbourOrganizeListModel.h"
+
+#include "HarbourDebug.h"
+
+// ==========================================================================
+// HarbourOrganizeListModel::Private
+// ==========================================================================
+
+class HarbourOrganizeListModel::Private {
+public:
+ Private();
+
+ int mapToSource(int aRow) const;
+ int mapFromSource(int aRow) const;
+
+public:
+ int iDragIndex;
+ int iDragPos;
+ const char* iRowsAboutToBeMovedSlot;
+ const char* iRowsMovedSlot;
+};
+
+HarbourOrganizeListModel::Private::Private() :
+ iDragIndex(-1),
+ iDragPos(-1),
+ iRowsAboutToBeMovedSlot(SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))),
+ iRowsMovedSlot(SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)))
+{
+}
+
+int HarbourOrganizeListModel::Private::mapToSource(int aRow) const
+{
+ if (iDragIndex < iDragPos) {
+ if (aRow < iDragIndex || aRow > iDragPos) {
+ return aRow;
+ } else if (aRow == iDragPos) {
+ return iDragIndex;
+ } else {
+ return aRow + 1;
+ }
+ } else if (iDragPos < iDragIndex) {
+ if (aRow < iDragPos || aRow > iDragIndex) {
+ return aRow;
+ } else if (aRow == iDragPos) {
+ return iDragIndex;
+ } else {
+ return aRow - 1;
+ }
+ }
+ return aRow;
+}
+
+int HarbourOrganizeListModel::Private::mapFromSource(int aRow) const
+{
+ if (iDragIndex < iDragPos) {
+ if (aRow < iDragIndex || aRow > iDragPos) {
+ return aRow;
+ } else if (aRow == iDragIndex) {
+ return iDragPos;
+ } else {
+ return aRow - 1;
+ }
+ } else if (iDragPos < iDragIndex) {
+ if (aRow < iDragPos || aRow > iDragIndex) {
+ return aRow;
+ } else if (aRow == iDragIndex) {
+ return iDragPos;
+ } else {
+ return aRow + 1;
+ }
+ }
+ return aRow;
+}
+
+// ==========================================================================
+// HarbourOrganizeListModel
+// ==========================================================================
+
+#define SUPER QSortFilterProxyModel
+
+HarbourOrganizeListModel::HarbourOrganizeListModel(QObject* aParent) :
+ SUPER(aParent),
+ iPrivate(new Private)
+{
+ connect(this, SIGNAL(sourceModelChanged()), SIGNAL(sourceModelObjectChanged()));
+}
+
+HarbourOrganizeListModel::~HarbourOrganizeListModel()
+{
+ delete iPrivate;
+}
+
+void HarbourOrganizeListModel::setSourceModelObject(QObject* aModel)
+{
+ setSourceModel(qobject_cast<QAbstractItemModel*>(aModel));
+}
+
+int HarbourOrganizeListModel::dragIndex() const
+{
+ return iPrivate->iDragIndex;
+}
+
+int HarbourOrganizeListModel::dragPos() const
+{
+ return iPrivate->iDragPos;
+}
+
+QModelIndex HarbourOrganizeListModel::mapToSource(const QModelIndex& aIndex) const
+{
+ QAbstractItemModel* source = sourceModel();
+ if (source) {
+ return source->index(iPrivate->mapToSource(aIndex.row()), aIndex.column());
+ }
+ return aIndex;
+}
+
+QModelIndex HarbourOrganizeListModel::mapFromSource(const QModelIndex& aIndex) const
+{
+ return index(iPrivate->mapFromSource(aIndex.row()), aIndex.column());
+}
+
+void HarbourOrganizeListModel::setDragIndex(int aIndex)
+{
+ HDEBUG(aIndex);
+ if (aIndex < 0) {
+ if (iPrivate->iDragIndex >= 0) {
+ // Drag is finished
+ if (iPrivate->iDragPos != iPrivate->iDragIndex) {
+ const int dragIndex = iPrivate->iDragIndex;
+ const int dragPos = iPrivate->iDragPos;
+ iPrivate->iDragPos = iPrivate->iDragIndex = -1;
+ QAbstractItemModel* source = sourceModel();
+ if (source) {
+ //
+ // Now, this is getting a bit hackish.
+ //
+ // We don't need QSortFilterProxyModel to react to
+ // rowsAboutToBeMoved and rowsMoved signals emitted
+ // by the source model when we invoke moveRow() because
+ // that would result in layoutChanged signal which
+ // would reset the view (its current position etc).
+ // That's totally unnecessary because all the rows
+ // are already in the right place as long as the view
+ // is concerned.
+ //
+ // It looks a bit fragile since these slots are
+ // internal and can change at any point of time.
+ // Well, in the worst case we would get the view
+ // reset.
+ //
+ QObject::disconnect(source,
+ SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, iPrivate->iRowsAboutToBeMovedSlot);
+ QObject::disconnect(source,
+ SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, iPrivate->iRowsMovedSlot);
+
+ // Actually move the row
+ source->moveRow(QModelIndex(), dragIndex, QModelIndex(), dragPos);
+
+ // And (hopefully) reconnect the handlers.
+ QObject::connect(source,
+ SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, iPrivate->iRowsAboutToBeMovedSlot);
+ QObject::connect(source,
+ SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourPluginLoader.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2017 Jolla Ltd.
- * Copyright (C) 2017 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:
*
@@ -11,26 +11,28 @@
* 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 name of 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.
+ * 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.
+ * 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.
*/
#include "HarbourPluginLoader.h"
+#include "HarbourSystem.h"
#include "HarbourDebug.h"
// These are included from qqmlengine.h
@@ -72,10 +74,28 @@
// _ZNK8QQmlType22attachedPropertiesTypeEP17QQmlEnginePrivate
//
-#define LIBQT5QML_SO "/usr/lib/libQt5Qml.so.5"
+#define LIBQT5QML_SO "libQt5Qml.so.5"
// 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", \
@@ -98,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!
@@ -124,13 +144,45 @@
Q_STATIC_ASSERT(sizeof(QmlTypeFunctions) == NUM_FUNCTIONS*sizeof(void*));
// ==========================================================================
+// HarbourPluginLoader::LibQt5Qml
+// ==========================================================================
+
+class HarbourPluginLoader::LibQt5Qml {
+public:
+
+ LibQt5Qml();
+
+public:
+ void* iHandle;
+ union {
+ QmlTypeFunctions fn;
+ void* ptr[NUM_FUNCTIONS];
+ } iSym;
+};
+
+HarbourPluginLoader::LibQt5Qml::LibQt5Qml() :
+ iHandle(HarbourDlopen(LIBQT5QML_SO, RTLD_LAZY))
+{
+ memset(&iSym, 0, sizeof(iSym));
+ if (iHandle) {
+ // Resolve unstable symbols
+ for (uint i = 0; i < NUM_FUNCTIONS; i++) {
+ iSym.ptr[i] = dlsym(iHandle, QmlTypeSymbols[i]);
+ HDEBUG(QmlTypeSymbols[i] << (iSym.ptr[i] ? "OK" : "missing"));
+ }
+ // No need to ever call dlclose(iHandle);
+ } else {
+ HWARN("Failed to load" << LIBQT5QML_SO);
+ }
+}
+
+// ==========================================================================
// HarbourPluginLoader::Private
// ==========================================================================
class HarbourPluginLoader::Private {
public:
Private(QQmlEngine* aEngine, QString aModule, int aMajor, int aMinor);
- ~Private();
QQmlType* qmlType(QString aName);
@@ -142,18 +194,18 @@
const char* aModule, int aMajor, int aMinor);
public:
+ static const LibQt5Qml gLibQt5Qml;
+
+public:
QQmlEngine* iEngine;
QString iModule;
int iMajor;
int iMinor;
bool iLoaded;
- void* iHandle;
- union {
- QmlTypeFunctions fn;
- void* ptr[NUM_FUNCTIONS];
- } iLibQt5Qml;
};
+const HarbourPluginLoader::LibQt5Qml HarbourPluginLoader::Private::gLibQt5Qml;
+
HarbourPluginLoader::Private::Private(
QQmlEngine* aEngine,
QString aModule,
@@ -163,37 +215,21 @@
iModule(aModule),
iMajor(aMajor),
iMinor(aMinor),
- iLoaded(false),
- iHandle(NULL)
+ iLoaded(false)
{
- memset(&iLibQt5Qml, 0, sizeof(iLibQt5Qml));
- // Load the actual import library
- QQmlComponent* component = new QQmlComponent(iEngine);
- component->setData(QString("import QtQuick 2.0\nimport %1 %2.%3\nQtObject {}").
- arg(iModule).arg(iMajor).arg(iMinor).toUtf8(), QUrl());
- if (component->status() == QQmlComponent::Ready) {
- delete component->create();
- // Resolve unstable symbols
- iHandle = dlopen(LIBQT5QML_SO, RTLD_LAZY);
- if (iHandle) {
- for (uint i = 0; i < NUM_FUNCTIONS; i++) {
- iLibQt5Qml.ptr[i] = dlsym(iHandle, QmlTypeSymbols[i]);
- HDEBUG(QmlTypeSymbols[i] << (iLibQt5Qml.ptr[i] ? "OK" : "missing"));
- }
+ HASSERT(gLibQt5Qml.iHandle);
+ if (gLibQt5Qml.iHandle) {
+ // Load the actual import library
+ QQmlComponent* component = new QQmlComponent(iEngine);
+ component->setData(QString("import QtQuick 2.0\nimport %1 %2.%3\nQtObject {}").
+ arg(iModule).arg(iMajor).arg(iMinor).toUtf8(), QUrl());
+ if (component->status() == QQmlComponent::Ready) {
+ delete component->create();
+ iLoaded = true;
} else {
- HWARN("Failed to load" << LIBQT5QML_SO);
+ HWARN(component->errors());
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourPolicyPlugin.cpp
^
|
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2017-2020 Jolla Ltd.
+ * Copyright (C) 2017-2020 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 "HarbourPolicyPlugin.h"
+#include "HarbourDebug.h"
+
+// Workaround for org.nemomobile.policy (or Nemo.Policy) not being
+// allowed in harbour apps
+
+HarbourPolicyPlugin* HarbourPolicyPlugin::gInstance = Q_NULLPTR;
+
+const char HarbourPolicyPlugin::RESOURCE_QML_TYPE[] = "Resource";
+const char HarbourPolicyPlugin::PERMISSIONS_QML_TYPE[] = "Permissions";
+
+HarbourPolicyPlugin::HarbourPolicyPlugin(
+ QQmlEngine* aEngine) :
+ HarbourPluginLoader(aEngine, "org.nemomobile.policy", 1, 0)
+{
+}
+
+HarbourPolicyPlugin::~HarbourPolicyPlugin()
+{
+ HASSERT(gInstance == this);
+ gInstance = Q_NULLPTR;
+}
+
+void
+HarbourPolicyPlugin::registerTypes(
+ const char* aModule,
+ int aMajor,
+ int aMinor)
+{
+ reRegisterType(RESOURCE_QML_TYPE, aModule, aMajor, aMinor);
+ reRegisterType(PERMISSIONS_QML_TYPE, aModule, aMajor, aMinor);
+}
+
+void
+HarbourPolicyPlugin::registerTypes(
+ QQmlEngine* aEngine,
+ const char* aModule,
+ int aMajor,
+ int aMinor)
+{
+ if (!gInstance) {
+ gInstance = new HarbourPolicyPlugin(aEngine);
+ }
+ gInstance->registerTypes(aModule, aMajor, aMinor);
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/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;
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourProtoBuf.cpp
^
|
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 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 "HarbourDebug.h"
+#include "HarbourProtoBuf.h"
+
+// https://developers.google.com/protocol-buffers/docs/encoding
+
+QByteArray*
+HarbourProtoBuf::appendVarInt(
+ QByteArray* aOutput,
+ quint64 aValue)
+{
+ if (aOutput) {
+ uchar out[10];
+ quint64 value = aValue;
+ int i = sizeof(out) - 1;
+
+ out[i] = value & 0x7f;
+ value >>= 7;
+ while (value) {
+ out[--i] = 0x80 | (uchar)value;
+ value >>= 7;
+ }
+
+ const int n = sizeof(out) - i;
+
+ aOutput->reserve(aOutput->size() + n);
+ aOutput->append((char*)(out + i), n);
+ }
+ return aOutput;
+}
+
+QByteArray*
+HarbourProtoBuf::appendVarIntKeyValue(
+ QByteArray* aOutput,
+ quint64 aKey,
+ quint64 aValue)
+{
+ HASSERT((aKey & TYPE_MASK) == TYPE_VARINT);
+ return appendVarInt(appendVarInt(aOutput, aKey), aValue);
+}
+
+QByteArray*
+HarbourProtoBuf::appendDelimitedValue(
+ QByteArray* aOutput,
+ const QByteArray aValue)
+{
+ if (aOutput) {
+ appendVarInt(aOutput, aValue.size())->append(aValue);
+ }
+ return aOutput;
+}
+
+QByteArray*
+HarbourProtoBuf::appendDelimitedKeyValue(
+ QByteArray* aOutput,
+ quint64 aKey,
+ const QByteArray aValue)
+{
+ HASSERT((aKey & TYPE_MASK) == TYPE_DELIMITED);
+ return appendDelimitedValue(appendVarInt(aOutput, aKey), aValue);
+}
+
+bool
+HarbourProtoBuf::parseVarInt(
+ GUtilRange* aPos,
+ quint64* aResult)
+{
+ if (aPos) {
+ quint64 value = 0;
+ const guint8* ptr = aPos->ptr;
+
+ for (int i = 0; i < 10 && ptr < aPos->end; i++, ptr++) {
+ value = (value << 7) | (*ptr & 0x7f);
+ if (!(*ptr & 0x80)) {
+ aPos->ptr = ptr + 1;
+ if (aResult) {
+ *aResult = value;
+ }
+ return true;
+ }
+ }
+
+ // Premature end of stream or too many bytes
+ if (aResult) {
+ *aResult = 0;
+ }
+ }
+ return false;
+}
+
+// A delimited value is stored as a size, encoded as a varint, followed
+// by the payload of type (message | string | bytes | packed)
+bool
+HarbourProtoBuf::parseDelimitedValue(
+ GUtilRange* aPos,
+ GUtilData* aPayload)
+{
+ if (aPos) {
+ GUtilRange pos = *aPos;
+ quint64 size;
+
+ if (parseVarInt(&pos, &size) && (pos.ptr + size) <= pos.end) {
+ if (aPayload) {
+ aPayload->bytes = pos.ptr;
+ aPayload->size = size;
+ }
+ aPos->ptr = pos.ptr + size;
+ return true;
+ }
+ }
+ return false;
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourQrCodeGenerator.cpp
^
|
@@ -0,0 +1,273 @@
+/*
+ * 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:
+ *
+ * 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 "HarbourQrCodeGenerator.h"
+
+#include "HarbourBase32.h"
+#include "HarbourTask.h"
+#include "HarbourDebug.h"
+
+#include <QThreadPool>
+
+#include "qrencode.h"
+
+// ==========================================================================
+// HarbourQrCodeGenerator::Task
+// ==========================================================================
+
+class HarbourQrCodeGenerator::Task : public HarbourTask
+{
+ Q_OBJECT
+
+public:
+ 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,
+ ECLevel aEcLevel) :
+ HarbourTask(aPool),
+ iText(aText),
+ iEcLevel(aEcLevel)
+{
+}
+
+void HarbourQrCodeGenerator::Task::performTask()
+{
+ QByteArray bytes(generate(iText, iEcLevel));
+ if (!bytes.isEmpty()) {
+ iCode = HarbourBase32::toBase32(bytes);
+ }
+}
+
+// ==========================================================================
+// HarbourQrCodeGenerator::Private
+// ==========================================================================
+
+class HarbourQrCodeGenerator::Private : public QObject
+{
+ Q_OBJECT
+
+public:
+ Private(HarbourQrCodeGenerator* aParent);
+ ~Private();
+
+ HarbourQrCodeGenerator* parentObject() const;
+ void setText(QString aValue);
+ void setEcLevel(int aValue);
+ void regenerate();
+
+ static QRecLevel realEcLevel(ECLevel aEcLevel);
+
+public Q_SLOTS:
+ void onTaskDone();
+
+public:
+ QThreadPool* iThreadPool;
+ Task* iTask;
+ ECLevel iEcLevel;
+ QString iText;
+ QString iCode;
+};
+
+HarbourQrCodeGenerator::Private::Private(HarbourQrCodeGenerator* aParent) :
+ QObject(aParent),
+ iThreadPool(new QThreadPool(this)),
+ iTask(Q_NULLPTR),
+ iEcLevel(ECLevelDefault)
+{
+ // Serialize the tasks:
+ iThreadPool->setMaxThreadCount(1);
+}
+
+HarbourQrCodeGenerator::Private::~Private()
+{
+ if (iTask) iTask->release();
+ iThreadPool->waitForDone();
+}
+
+inline HarbourQrCodeGenerator* HarbourQrCodeGenerator::Private::parentObject() const
+{
+ 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;
+ 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();
+ }
+}
+
+void HarbourQrCodeGenerator::Private::onTaskDone()
+{
+ if (sender() == iTask) {
+ HarbourQrCodeGenerator* obj = parentObject();
+ const bool qrCodeChanged = (iCode != iTask->iCode);
+ iCode = iTask->iCode;
+ iTask->release();
+ iTask = NULL;
+ if (qrCodeChanged) {
+ Q_EMIT obj->codeChanged();
+ }
+ Q_EMIT obj->runningChanged();
+ }
+}
+
+// ==========================================================================
+// HarbourQrCodeGenerator
+// ==========================================================================
+
+HarbourQrCodeGenerator::HarbourQrCodeGenerator(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourQrCodeImageProvider.cpp
^
|
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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 "HarbourQrCodeImageProvider.h"
+
+#include "HarbourBase32.h"
+#include "HarbourDebug.h"
+
+#include <QVector>
+#include <QColor>
+#include <QRgb>
+
+const QColor HarbourQrCodeImageProvider::DEFAULT_COLOR(Qt::black);
+const QColor HarbourQrCodeImageProvider::DEFAULT_BACKGROUND(Qt::transparent);
+
+QImage HarbourQrCodeImageProvider::createImage(QByteArray aBits, QColor aColor, QColor aBackground)
+{
+ if (aBits.size() > 0) {
+ // Bits are packed, rows are rounded at byte boundary
+ int rows, rowSize;
+ for (rows = 2; ((rowSize = (rows + 7)/8) * rows) < aBits.size(); rows++);
+ if ((rows * rowSize) == aBits.size()) {
+ HDEBUG(rows << "x" << rows);
+ QImage img(rows, rows, QImage::Format_Mono);
+ QVector<QRgb> colors;
+ QColor background(aBackground.isValid() ? aBackground : DEFAULT_BACKGROUND);
+ QColor color(aColor.isValid() ? aColor : DEFAULT_COLOR);
+ colors.append(background.rgba());
+ colors.append(color.rgba());
+ img.setColorTable(colors);
+ for (int y = 0; y < rows; y++) {
+ memcpy(img.scanLine(y), aBits.constData() + y * rowSize, rowSize);
+ }
+ return img;
+ }
+ }
+ return QImage();
+}
+
+QImage HarbourQrCodeImageProvider::requestImage(const QString& aId, QSize* aSize, const QSize&)
+{
+ // Default background and foreground
+ QColor background(DEFAULT_BACKGROUND), color(DEFAULT_COLOR);
+
+ // Parse parameters
+ QString base32;
+ const int sep = aId.indexOf('?');
+ if (sep < 0) {
+ base32 = aId;
+ } else {
+ base32 = aId.left(sep);
+ const QStringList params(aId.mid(sep + 1).split('&', QString::SkipEmptyParts));
+ const int n = params.count();
+ for (int i = 0; i < n; i++) {
+ const QString param(params.at(i));
+ const int eq = param.indexOf('=');
+ if (eq > 0) {
+ static const QString BACKGROUND("background");
+ static const QString COLOR("color");
+ const QString name(param.left(eq).trimmed());
+ const QString value(param.mid(eq + 1).trimmed());
+ if (name == COLOR) {
+ const QColor colorValue(value);
+ if (colorValue.isValid()) {
+ color = colorValue;
+ } else {
+ HDEBUG("Invalid" << qPrintable(name) << value);
+ }
+ } else if (name == BACKGROUND) {
+ const QColor colorValue(value);
+ if (colorValue.isValid()) {
+ background = colorValue;
+ } else {
+ HDEBUG("Invalid" << qPrintable(name) << value);
+ }
+ } else {
+ HDEBUG("Invalid parameter name" << name);
+ }
+ } else {
+ HDEBUG("Invalid parameter" << param);
+ }
+ }
+ }
+
+ // Decode BASE32
+ const QByteArray bits(HarbourBase32::fromBase32(base32.toLocal8Bit()));
+ HDEBUG(base32 << "=>" << bits.size() << "bytes");
+
+ // Convert to image
+ QImage img(createImage(bits, color, background));
+ if (!img.isNull() && aSize) {
+ *aSize = img.size();
+ }
+
+ return img;
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourSelectionListModel.cpp
^
|
@@ -0,0 +1,580 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019-2023 Slava Monich <slava@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 "HarbourSelectionListModel.h"
+
+#include "HarbourDebug.h"
+
+#define ROLE "selected"
+
+// ==========================================================================
+// HarbourSelectionListModel::Private
+// ==========================================================================
+
+// s(SignalName,signalName)
+#define QUEUED_SIGNALS(s) \
+ s(NonSelectableRows,nonSelectableRows) \
+ s(SelectedRows,selectedRows) \
+ s(SelectableCount,selectableCount) \
+ s(SelectionCount,selectionCount) \
+ s(Count,count)
+
+class HarbourSelectionListModel::Private : public QObject
+{
+ Q_OBJECT
+
+public:
+ typedef void (HarbourSelectionListModel::*SignalEmitter)();
+ typedef uint SignalMask;
+
+ enum Signal {
+#define SIGNAL_ENUM_(Name,name) Signal##Name##Changed,
+ QUEUED_SIGNALS(SIGNAL_ENUM_)
+#undef SIGNAL_ENUM_
+ SignalCount
+ };
+
+ Private(HarbourSelectionListModel*);
+
+ static int binaryFind(const QList<int>, int);
+
+ HarbourSelectionListModel* parentModel();
+ void queueSignal(Signal aSignal);
+ void emitQueuedSignals();
+ bool isSelectionRole(int) const;
+ bool isSelectedRow(int) const;
+ bool isSelectableRow(int) const;
+ int findSelectedRow(int) const;
+ void updateCounts();
+ void selectRow(int);
+ void unselectRow(int);
+ void toggleRows(const QList<int>);
+ void setNonSelectableRows(const QList<int>);
+ void selectedRowChanged(int);
+ void selectionChangedAt(int);
+ void clearSelection();
+ void selectAll();
+ void reset();
+
+public Q_SLOTS:
+ void onCountChanged();
+
+public:
+ SignalMask iQueuedSignals;
+ Signal iFirstQueuedSignal;
+ QList<int> iSelectedRows;
+ QList<int> iNonSelectableRows;
+ QList<int> iNormalizedNonSelectableRows;
+ QVector<int> iSelectedRole; // Passed to dataChanged as an argument
+ int iLastKnownSelectableCount;
+ int iLastKnownCount;
+};
+
+HarbourSelectionListModel::Private::Private(
+ HarbourSelectionListModel* aParent) :
+ QObject(aParent),
+ iLastKnownSelectableCount(0),
+ iLastKnownCount(0)
+{
+ connect(aParent, SIGNAL(modelReset()), SLOT(onCountChanged()));
+ connect(aParent, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(onCountChanged()));
+ connect(aParent, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(onCountChanged()));
+}
+
+int
+HarbourSelectionListModel::Private::binaryFind(
+ const QList<int> aList,
+ int aValue)
+{
+ // It turned out to be significantly easier to copy/paste this code
+ // than to fight with qBinaryFind and iterators which behave strangely
+ // with empty QList and when you convert them to index. Oh well...
+ int low = 0;
+ int high = aList.count() - 1;
+
+ while (low <= high) {
+ int mid = (low + high)/2;
+ const int val = aList.at(mid);
+ if (val < aValue) {
+ low = mid + 1;
+ } else if (val > aValue) {
+ high = mid - 1;
+ } else {
+ // Found
+ return mid;
+ }
+ }
+
+ // Not found, return -(INSERTION POINT+1)
+ return -(low + 1);
+}
+
+inline
+HarbourSelectionListModel*
+HarbourSelectionListModel::Private::parentModel()
+{
+ return qobject_cast<HarbourSelectionListModel*>(parent());
+}
+
+void
+HarbourSelectionListModel::Private::queueSignal(
+ Signal aSignal)
+{
+ if (aSignal >= 0 && aSignal < SignalCount) {
+ const SignalMask signalBit = (SignalMask(1) << aSignal);
+ if (iQueuedSignals) {
+ iQueuedSignals |= signalBit;
+ if (iFirstQueuedSignal > aSignal) {
+ iFirstQueuedSignal = aSignal;
+ }
+ } else {
+ iQueuedSignals = signalBit;
+ iFirstQueuedSignal = aSignal;
+ }
+ }
+}
+
+void
+HarbourSelectionListModel::Private::emitQueuedSignals()
+{
+ static const SignalEmitter emitSignal [] = {
+#define SIGNAL_EMITTER_(Name,name) &HarbourSelectionListModel::name##Changed,
+ QUEUED_SIGNALS(SIGNAL_EMITTER_)
+#undef SIGNAL_EMITTER_
+ };
+ if (iQueuedSignals) {
+ HarbourSelectionListModel* model = parentModel();
+ // Reset first queued signal before emitting the signals.
+ // Signal handlers may emit new signals.
+ uint i = iFirstQueuedSignal;
+ iFirstQueuedSignal = SignalCount;
+ for (; i < SignalCount && iQueuedSignals; i++) {
+ const SignalMask signalBit = (SignalMask(1) << i);
+ if (iQueuedSignals & signalBit) {
+ iQueuedSignals &= ~signalBit;
+ Q_EMIT (model->*(emitSignal[i]))();
+ }
+ }
+ }
+}
+
+inline
+bool
+HarbourSelectionListModel::Private::isSelectionRole(
+ int aRole) const
+{
+ return !iSelectedRole.isEmpty() && iSelectedRole.first() == aRole;
+}
+
+inline
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourSingleImageProvider.cpp
^
|
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2019 Jolla Ltd.
+ * Copyright (C) 2019 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 "HarbourSingleImageProvider.h"
+
+#include "HarbourDebug.h"
+
+#include <QQuickImageProvider>
+#include <QQmlEngine>
+#include <QQmlContext>
+
+// ==========================================================================
+// HarbourSingleImageProvider::ImageProvider
+// ==========================================================================
+
+class HarbourSingleImageProvider::ImageProvider : public QQuickImageProvider {
+public:
+ static const QString IMAGE_NAME;
+
+ ImageProvider(QImage aImage);
+
+ QImage requestImage(const QString& aId, QSize* aSize,
+ const QSize& aRequested) Q_DECL_OVERRIDE;
+
+private:
+ QImage iImage;
+};
+
+const QString HarbourSingleImageProvider::ImageProvider::IMAGE_NAME("image");
+
+HarbourSingleImageProvider::ImageProvider::ImageProvider(QImage aImage) :
+ QQuickImageProvider(Image),
+ iImage(aImage)
+{
+}
+
+QImage HarbourSingleImageProvider::ImageProvider::requestImage(const QString& aId,
+ QSize* aSize, const QSize& aRequested)
+{
+ HDEBUG(aId);
+ if (aSize) {
+ *aSize = iImage.size();
+ }
+ return iImage;
+}
+
+// ==========================================================================
+// HarbourSingleImageProvider::Private
+// ==========================================================================
+
+class HarbourSingleImageProvider::Private : public QObject {
+ Q_OBJECT
+
+public:
+ Private(HarbourSingleImageProvider* aParent);
+ ~Private();
+
+ bool setEngine(QQmlEngine* aEngine);
+ bool setImage(QImage aImage);
+ void registerProvider();
+
+public Q_SLOTS:
+ void onEngineDied();
+
+public:
+ QImage iImage;
+ QString iId;
+ QString iSourceUri;
+ QQmlEngine* iEngine;
+};
+
+HarbourSingleImageProvider::Private::Private(HarbourSingleImageProvider* aParent) :
+ QObject(aParent),
+ iEngine(Q_NULLPTR)
+{
+}
+
+HarbourSingleImageProvider::Private::~Private()
+{
+ if (!iId.isEmpty()) {
+ iEngine->removeImageProvider(iId);
+ }
+}
+
+void HarbourSingleImageProvider::Private::registerProvider()
+{
+ QQmlImageProviderBase* provider = new ImageProvider(iImage);
+ iId = QString().sprintf("HarbourSingleImageProvider%p", provider);
+ iSourceUri = QString("image://%1/%2").arg(iId, ImageProvider::IMAGE_NAME);
+ HDEBUG("registering provider" << iId);
+ iEngine->addImageProvider(iId, provider);
+}
+
+bool HarbourSingleImageProvider::Private::setEngine(QQmlEngine* aEngine)
+{
+ if (iEngine) {
+ if (!iId.isEmpty()) {
+ iEngine->removeImageProvider(iId);
+ iId = QString();
+ }
+ iEngine->disconnect(this);
+ }
+ iEngine = aEngine;
+ if (iEngine) {
+ connect(iEngine, SIGNAL(destroyed(QObject*)), SLOT(onEngineDied()));
+ if (!iImage.isNull()) {
+ registerProvider();
+ return true;
+ }
+ }
+ return false;
+}
+
+bool HarbourSingleImageProvider::Private::setImage(QImage aImage)
+{
+ HDEBUG(aImage);
+ if (!iId.isEmpty()) {
+ iEngine->removeImageProvider(iId);
+ }
+ iImage = aImage;
+ if (iEngine && !iImage.isNull()) {
+ registerProvider();
+ return true;
+ }
+ return false;
+}
+
+void HarbourSingleImageProvider::Private::onEngineDied()
+{
+ HDEBUG("engine died");
+ iEngine = Q_NULLPTR;
+ iId = QString();
+}
+
+// ==========================================================================
+// HarbourSingleImageProvider
+// ==========================================================================
+
+HarbourSingleImageProvider::HarbourSingleImageProvider(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+}
+
+void HarbourSingleImageProvider::classBegin()
+{
+}
+
+void HarbourSingleImageProvider::componentComplete()
+{
+ QQmlContext* context = QQmlEngine::contextForObject(this);
+ HDEBUG(context);
+ if (context) {
+ QQmlEngine* engine = context->engine();
+ HDEBUG(engine);
+ if (iPrivate->setEngine(engine)) {
+ Q_EMIT sourceChanged();
+ }
+ }
+}
+
+QImage HarbourSingleImageProvider::image() const
+{
+ return iPrivate->iImage;
+}
+
+void HarbourSingleImageProvider::setImage(QImage aImage)
+{
+ HDEBUG(aImage);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourSystem.cpp
^
|
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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 "HarbourSystem.h"
+#include "HarbourDebug.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#ifdef LIBDIR
+# define HARBOUR_LIBDIR LIBDIR
+#elif defined __aarch64__
+# define HARBOUR_LIBDIR "/usr/lib64"
+#else
+# define HARBOUR_LIBDIR "/usr/lib"
+#endif
+
+void* HarbourDlopen(const char* aLibFile, int aFlags)
+{
+ const char* libdir = HARBOUR_LIBDIR;
+ const size_t libdir_len = strlen(libdir);
+ const size_t libfile_len = strlen(aLibFile);
+ char* filename = (char*) malloc(libdir_len + libfile_len + 2);
+ void* handle;
+
+ memcpy(filename, libdir, libdir_len);
+ memcpy(filename + libdir_len + 1, aLibFile, libfile_len);
+ filename[libdir_len] = '/';
+ filename[libdir_len + 1 + libfile_len] = '\0';
+ handle = dlopen(filename, aFlags);
+ if (!handle) {
+ HWARN("Failed to load" << filename);
+ }
+ free(filename);
+ return handle;
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourSystemInfo.cpp
^
|
@@ -0,0 +1,283 @@
+/*
+ * 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:
+ *
+ * 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 "HarbourSystemInfo.h"
+#include "HarbourDebug.h"
+
+#include <QHash>
+#include <QVector>
+#include <QStringList>
+#include <QFile>
+#include <QTextStream>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+// ==========================================================================
+// HarbourSystemInfo::Private
+// ==========================================================================
+
+class HarbourSystemInfo::Private
+{
+public:
+ static const QString NAME;
+ static const QString VERSION_ID;
+
+public:
+ Private();
+
+ static QHash<QString,QString> parseFile(QString aFileName, const QStringList aKeys);
+ static QHash<QString,QString> parseOsRelease(const QStringList aKeys);
+ static QVector<uint> parseVersion(QString aVersion);
+ 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");
+const QString HarbourSystemInfo::Private::VERSION_ID("VERSION_ID");
+
+HarbourSystemInfo::Private::Private()
+{
+ QStringList keys;
+ keys.append(NAME);
+ keys.append(VERSION_ID);
+
+ QHash<QString,QString> values(parseOsRelease(keys));
+ iName = values.value(NAME);
+ iVersion = values.value(VERSION_ID);
+ iParsedVersion = parseVersion(iVersion);
+}
+
+inline QHash<QString,QString> HarbourSystemInfo::Private::parseOsRelease(const QStringList aKeys)
+{
+ return parseFile("/etc/os-release", aKeys);
+}
+
+QHash<QString,QString> HarbourSystemInfo::Private::parseFile(QString aPath, const QStringList aKeys)
+{
+ QFile file(aPath);
+ QHash<QString,QString> result;
+ if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ HDEBUG("Parsing" << qPrintable(aPath));
+ QTextStream in(&file);
+ while (!in.atEnd() && result.size() < aKeys.size()) {
+ const QString line = in.readLine();
+ const int sep = line.indexOf('=');
+ if (sep > 0 && (sep + 1) < line.length()) {
+ const QString key(line.left(sep));
+ if (aKeys.contains(key)) {
+ QString value(line.mid(sep + 1));
+ const int len = value.length();
+ if (len > 1 && value.at(0) == '"' && value.at(len - 1) == '"') {
+ value = value.mid(1, len - 2);
+ }
+ value = value.replace("\\\"", "\"");
+ HDEBUG(qPrintable(key) << "=" << qPrintable(value));
+ result.insert(key, value);
+ }
+ }
+ }
+ }
+ return result;
+}
+
+QVector<uint> HarbourSystemInfo::Private::parseVersion(QString aVersion)
+{
+ QVector<uint> parsed;
+ QStringList parts(aVersion.split('.', QString::SkipEmptyParts));
+ const int n = qMin(parts.count(),4);
+ for (int i = 0; i < n; i++) {
+ const QString part(parts.at(i));
+ bool ok = false;
+ int val = part.toUInt(&ok);
+ if (ok) {
+ parsed.append(val);
+ } else {
+ break;
+ }
+ }
+ return parsed;
+}
+
+int HarbourSystemInfo::Private::compareVersions(const QVector<uint> aVersion1,
+ const QVector<uint> aVersion2)
+{
+ const int n1 = aVersion1.size();
+ const int n2 = aVersion2.size();
+ const int n = qMin(n1, n2);
+ for (int i = 0; i < n; i++) {
+ const uint v1 = aVersion1.at(i);
+ const uint v2 = aVersion2.at(i);
+ if (v1 > v2) {
+ return 1;
+ } else if (v1 < v2) {
+ return -1;
+ }
+ }
+ return (n1 > n2) ? 1 : (n1 < n2) ? -1 : 0;
+}
+
+inline int HarbourSystemInfo::Private::compareVersions(const QVector<uint> aVersion1,
+ const QString aVersion2)
+{
+ 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
+// ==========================================================================
+
+HarbourSystemInfo::HarbourSystemInfo(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private)
+{
+ HDEBUG("created");
+}
+
+HarbourSystemInfo::~HarbourSystemInfo()
+{
+ HDEBUG("deleted");
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourSystemState.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015-2018 Jolla Ltd.
- * Copyright (C) 2015-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2015-2019 Jolla Ltd.
+ * Copyright (C) 2015-2019 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 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.
+ * 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
@@ -35,6 +35,8 @@
#include "HarbourDebug.h"
#include "HarbourMce.h"
+#include <QQmlEngine>
+
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDBusPendingCall>
@@ -190,6 +192,15 @@
HDEBUG("destroyed");
}
+// Callback for qmlRegisterSingletonType<HarbourSystemState>
+QObject*
+HarbourSystemState::createSingleton(
+ QQmlEngine*,
+ QJSEngine*)
+{
+ return new HarbourSystemState();
+}
+
QSharedPointer<HarbourSystemState>
HarbourSystemState::sharedInstance()
{
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourSystemTime.cpp
^
|
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2020 Jolla Ltd.
+ * Copyright (C) 2020 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
+ * 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 "HarbourSystemTime.h"
+#include "HarbourDebug.h"
+
+#include <QDBusConnection>
+
+#include <gutil_timenotify.h>
+
+// ==========================================================================
+// HarbourSystemTime::Private
+// ==========================================================================
+
+class HarbourSystemTime::Private : public QObject
+{
+ Q_OBJECT
+public:
+ Private(HarbourSystemTime* aSystemTime);
+ ~Private();
+
+ static void timeNotify(GUtilTimeNotify*, void*);
+
+public Q_SLOTS:
+ void onDBusNotify();
+ void notify();
+
+public:
+ GUtilTimeNotify* iNotify;
+ gulong iNotifyId;
+};
+
+HarbourSystemTime::Private::Private(HarbourSystemTime* aParent) :
+ QObject(aParent),
+ iNotify(gutil_time_notify_new()),
+ iNotifyId(gutil_time_notify_add_handler(iNotify, timeNotify, this))
+{
+ QDBusConnection::systemBus().connect("com.nokia.time", "/com/nokia/time",
+ "com.nokia.time", "settings_changed", this, SLOT(onDBusNotify()));
+}
+
+HarbourSystemTime::Private::~Private()
+{
+ gutil_time_notify_remove_handler(iNotify, iNotifyId);
+ gutil_time_notify_unref(iNotify);
+}
+
+void HarbourSystemTime::Private::timeNotify(GUtilTimeNotify*, void* aSelf)
+{
+ HDEBUG("System time changed");
+ QMetaObject::invokeMethod((QObject*)aSelf, "notify");
+}
+
+void HarbourSystemTime::Private::onDBusNotify()
+{
+ HDEBUG("timed settings changed");
+ notify();
+}
+
+void HarbourSystemTime::Private::notify()
+{
+ HarbourSystemTime* obj = qobject_cast<HarbourSystemTime*>(parent());
+ Q_EMIT obj->preNotify(); // For Date.timeZoneUpdated()
+ Q_EMIT obj->notify(); // For everything else
+}
+
+// ==========================================================================
+// HarbourSystemTime
+// ==========================================================================
+
+HarbourSystemTime::HarbourSystemTime(QObject* aParent) :
+ QObject(aParent),
+ iPrivate(new Private(this))
+{
+ HDEBUG("created");
+}
+
+HarbourSystemTime::~HarbourSystemTime()
+{
+ HDEBUG("deleted");
+ delete iPrivate;
+}
+
+// Callback for qmlRegisterSingletonType<HarbourSystemTime>
+QObject* HarbourSystemTime::createSingleton(QQmlEngine*, QJSEngine*)
+{
+ return new HarbourSystemTime();
+}
+
+// Getter for notification property which can be used to force
+// re-evaluation of a JavaScript expression. Always returns an
+// empty string.
+QString HarbourSystemTime::emptyString()
+{
+ return QString();
+}
+
+QSharedPointer<HarbourSystemTime> HarbourSystemTime::sharedInstance()
+{
+ static QWeakPointer<HarbourSystemTime> sSharedInstance;
+ QSharedPointer<HarbourSystemTime> instance = sSharedInstance;
+ if (instance.isNull()) {
+ // QObject::deleteLater protects against trouble in case if the
+ // recipient of the signal drops the last shared reference.
+ sSharedInstance = instance = QSharedPointer<HarbourSystemTime>
+ (new HarbourSystemTime, &QObject::deleteLater);
+ }
+ return instance;
+}
+
+#include "HarbourSystemTime.moc"
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourTask.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2019 Jolla Ltd.
+ * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -47,18 +47,22 @@
public:
QThreadPool* iPool;
- bool iAboutToQuit;
+ QObject* iTarget;
+ bool iStarted; // These two flags are set by the worker thread
+ bool iFinished;
+ bool iAboutToQuit; // All other flags are set by the main thread
bool iSubmitted;
- bool iStarted;
bool iReleased;
bool iDone;
};
HarbourTask::Private::Private(QThreadPool* aPool) :
iPool(aPool),
+ iTarget(NULL),
+ iStarted(false),
+ iFinished(false),
iAboutToQuit(false),
iSubmitted(false),
- iStarted(false),
iReleased(false),
iDone(false)
{
@@ -81,8 +85,12 @@
HarbourTask::~HarbourTask()
{
- HASSERT(iPrivate->iReleased);
- if (iPrivate->iSubmitted) wait();
+ // Target can be destroyed before done() signal is delivered to the
+ // main thread and the target has a chance to release the task. In
+ // that case onTargetDestroyed must be invoked before the task gets
+ // destroyed (which clears iPrivate->iTarget).
+ HASSERT(iPrivate->iReleased || !iPrivate->iTarget);
+ HASSERT(!iPrivate->iSubmitted || iPrivate->iFinished);
delete iPrivate;
}
@@ -108,18 +116,26 @@
void HarbourTask::submit(QObject* aTarget, const char* aSlot)
{
+ HASSERT(!iPrivate->iTarget);
+ iPrivate->iTarget = aTarget;
+ connect(aTarget, SIGNAL(destroyed(QObject*)), SLOT(onTargetDestroyed(QObject*)));
aTarget->connect(this, SIGNAL(done()), aSlot);
submit();
}
void HarbourTask::release(QObject* aHandler)
{
+ aHandler->disconnect(this);
disconnect(aHandler);
released();
}
void HarbourTask::release()
{
+ if (iPrivate->iTarget) {
+ iPrivate->iTarget->disconnect(this);
+ disconnect(iPrivate->iTarget);
+ }
released();
}
@@ -135,7 +151,10 @@
{
HASSERT(!iPrivate->iStarted);
iPrivate->iStarted = true;
- performTask();
+ if (!isCanceled()) {
+ performTask();
+ }
+ iPrivate->iFinished = true;
Q_EMIT runFinished();
}
@@ -156,3 +175,12 @@
HDEBUG("OK");
iPrivate->iAboutToQuit = true;
}
+
+void HarbourTask::onTargetDestroyed(QObject* aObject)
+{
+ HDEBUG(aObject);
+ HASSERT(iPrivate->iTarget == aObject);
+ if (iPrivate->iTarget == aObject) {
+ iPrivate->iTarget = NULL;
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourTemporaryFile.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2018-2021 Jolla Ltd.
+ * Copyright (C) 2018-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -8,27 +8,31 @@
* 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 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.
+ * 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,
+ * 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 "HarbourTemporaryFile.h"
@@ -37,6 +41,7 @@
#include <QDir>
#include <QTemporaryFile>
#include <QTextStream>
+#include <QStandardPaths>
// ==========================================================================
// HarbourTemporaryFile::Private
@@ -48,9 +53,11 @@
~Private();
void reopen(HarbourTemporaryFile* aObject);
+ QString directoryPath() const;
QString fileName() const;
public:
+ Location iLocation;
QTemporaryFile* iFile;
QString iFileTemplate;
QString iContent;
@@ -58,7 +65,8 @@
};
HarbourTemporaryFile::Private::Private() :
- iFile(NULL)
+ iLocation(Tmp),
+ iFile(NULL)
{
}
@@ -76,6 +84,21 @@
return iFile ? iFile->fileName() : QString();
}
+QString
+HarbourTemporaryFile::Private::directoryPath() const
+{
+ QStandardPaths::StandardLocation type = QStandardPaths::TempLocation;
+ switch (iLocation) {
+ case Downloads:
+ type = QStandardPaths::DownloadLocation;
+ break;
+ case Tmp:
+ // This is the default
+ break;
+ }
+ return QStandardPaths::writableLocation(type);
+}
+
void
HarbourTemporaryFile::Private::reopen(
HarbourTemporaryFile* aObject)
@@ -89,7 +112,7 @@
iUrl = QUrl();
}
if (!iContent.isEmpty() && !iFileTemplate.isEmpty()) {
- iFile = new QTemporaryFile(QDir::tempPath() +
+ iFile = new QTemporaryFile(directoryPath() +
QDir::separator() + iFileTemplate);
iFile->setAutoRemove(true);
if (iFile->open()) {
@@ -159,6 +182,22 @@
}
}
+HarbourTemporaryFile::Location
+HarbourTemporaryFile::location() const
+{
+ return iPrivate->iLocation;
+}
+
+void
+HarbourTemporaryFile::setLocation(Location aValue)
+{
+ if (iPrivate->iLocation != aValue) {
+ iPrivate->iLocation = aValue;
+ iPrivate->reopen(this);
+ Q_EMIT locationChanged();
+ }
+}
+
QString
HarbourTemporaryFile::fileName() const
{
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourTheme.cpp
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2018 Jolla Ltd.
- * Copyright (C) 2018 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.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
@@ -11,31 +11,36 @@
* 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.
+ * 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.
+ * 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.
+ * 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 "HarbourTheme.h"
#include "HarbourDebug.h"
+#include "HarbourSystem.h"
+#include "HarbourTheme.h"
+#include "HarbourUtil.h"
+
+#include <QQmlEngine>
#include <dlfcn.h>
-#define SILICA_SO "/usr/lib/libsailfishsilica.so.1"
+#define SILICA_SO "libsailfishsilica.so.1"
#define SILICA_FUNCTIONS(f) \
f("_ZN6Silica5Theme8instanceEv", /* Silica::Theme* Silica::Theme::instance() */ \
QObject*, instance,()) \
@@ -44,7 +49,15 @@
f("_ZNK6Silica5Theme11colorSchemeEv", /* Silica::ColorScheme Silica::Theme::colorScheme() const */ \
HarbourTheme::ColorScheme, colorScheme,(QObject*)) \
f("_ZNK6Silica5Theme12primaryColorEv", /* QColor Silica::Theme::primaryColor() const */ \
- QColor, primaryColor,(QObject*))
+ QColor, primaryColor,(QObject*)) \
+ f("_ZNK6Silica5Theme12opacityFaintEv", /* qreal Silica::Theme::opacityFaint() const */ \
+ qreal, opacityFaint,(QObject*)) \
+ f("_ZNK6Silica5Theme10opacityLowEv", /* qreal Silica::Theme::opacityLow() const */ \
+ qreal, opacityLow,(QObject*)) \
+ f("_ZNK6Silica5Theme11opacityHighEv", /* qreal Silica::Theme::opacityHigh() const */ \
+ qreal, opacityHigh,(QObject*)) \
+ f("_ZNK6Silica5Theme14opacityOverlayEv", /* qreal Silica::Theme::opacityOverlay() const */ \
+ qreal, opacityOverlay,(QObject*))
// ==========================================================================
// HarbourTheme::Private
@@ -63,6 +76,11 @@
SILICA_FUNCTIONS(SILICA_TYPEDEF)
} SilicaFunctions;
+ static const qreal DEFAULT_OPACITY_FAINT;
+ static const qreal DEFAULT_OPACITY_LOW;
+ static const qreal DEFAULT_OPACITY_HIGH;
+ static const qreal DEFAULT_OPACITY_OVERLAY;
+
static void* gHandle;
static SilicaFunctions gSilica;
@@ -70,11 +88,20 @@
static QObject* instance();
static ColorScheme colorScheme();
static QColor primaryColor();
+ static qreal opacityFaint();
+ static qreal opacityLow();
+ static qreal opacityHigh();
+ static qreal opacityOverlay();
};
void* HarbourTheme::Private::gHandle;
HarbourTheme::Private::SilicaFunctions HarbourTheme::Private::gSilica;
+const qreal HarbourTheme::Private::DEFAULT_OPACITY_FAINT = 0.2;
+const qreal HarbourTheme::Private::DEFAULT_OPACITY_LOW = 0.4;
+const qreal HarbourTheme::Private::DEFAULT_OPACITY_HIGH = 0.6;
+const qreal HarbourTheme::Private::DEFAULT_OPACITY_OVERLAY = 0.8;
+
static const char* SilicaSymbols[] = {
#define SILICA_SYMBOL(sym,ret,name,args) sym,
SILICA_FUNCTIONS(SILICA_SYMBOL)
@@ -86,7 +113,7 @@
QObject* HarbourTheme::Private::instance()
{
- return gSilica.instance ? gSilica.instance() : NULL;
+ return gSilica.instance ? gSilica.instance() : Q_NULLPTR;
}
HarbourTheme::ColorScheme HarbourTheme::Private::colorScheme()
@@ -108,6 +135,34 @@
return (silica && gSilica.primaryColor) ? gSilica.primaryColor(silica) : QColor();
}
+qreal HarbourTheme::Private::opacityFaint()
+{
+ QObject* silica = instance();
+ return (silica && gSilica.opacityFaint) ? gSilica.opacityFaint(silica) :
+ DEFAULT_OPACITY_FAINT;
+}
+
+qreal HarbourTheme::Private::opacityLow()
+{
+ QObject* silica = instance();
+ return (silica && gSilica.opacityLow) ? gSilica.opacityLow(silica) :
+ DEFAULT_OPACITY_LOW;
+}
+
+qreal HarbourTheme::Private::opacityHigh()
+{
+ QObject* silica = instance();
+ return (silica && gSilica.opacityHigh) ? gSilica.opacityHigh(silica) :
+ DEFAULT_OPACITY_HIGH;
+}
+
+qreal HarbourTheme::Private::opacityOverlay()
+{
+ QObject* silica = instance();
+ return (silica && gSilica.opacityOverlay) ? gSilica.opacityOverlay(silica) :
+ DEFAULT_OPACITY_OVERLAY;
+}
+
// ==========================================================================
// HarbourTheme
// ==========================================================================
@@ -115,7 +170,7 @@
HarbourTheme::HarbourTheme(QObject* aParent) : QObject(aParent)
{
if (!Private::gHandle) {
- Private::gHandle = dlopen(SILICA_SO, RTLD_LAZY);
+ Private::gHandle = HarbourDlopen(SILICA_SO, RTLD_LAZY);
if (Private::gHandle) {
void** ptr = (void**)&Private::gSilica;
for (uint i = 0; i < NUM_FUNCTIONS; i++) {
@@ -145,11 +200,35 @@
{
}
+// Callback for qmlRegisterSingletonType<HarbourTheme>
+QObject* HarbourTheme::createSingleton(QQmlEngine*, QJSEngine*)
+{
+ return new HarbourTheme();
+}
+
QColor HarbourTheme::primaryColor() const
{
return Private::primaryColor();
}
+QColor HarbourTheme::invertedPrimaryColor() const
+{
+ return HarbourUtil::invertedColor(Private::primaryColor());
+}
+
+QColor HarbourTheme::invertedColor(const QColor& aColor)
+{
+ return HarbourUtil::invertedColor(aColor);
+}
+
+qreal HarbourTheme::colorDifference(const QColor& aColor1, const QColor& aColor2)
+{
+ const qreal dr = aColor1.red() - aColor2.red();
+ const qreal dg = aColor1.green() - aColor2.green();
+ const qreal db = aColor1.blue() - aColor2.blue();
+ return dr * dr + dg * dg + db * db;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourTransferMethodsModel.cpp
^
|
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2016-2018 Jolla Ltd.
- * Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2016-2020 Jolla Ltd.
+ * Copyright (C) 2016-2020 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
@@ -11,29 +11,32 @@
* 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 name of 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.
+ * 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.
+ * 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.
*/
#include "HarbourTransferMethodsModel.h"
#include "HarbourDebug.h"
#include <QTranslator>
+#include <QQmlEngine>
+#include <QRegExp>
// ==========================================================================
// HarbourTransferMethodsModel::TransferEngine
@@ -43,75 +46,111 @@
{
Q_OBJECT
- static const char SERVICE[];
- static const char PATH[];
- static const char INTERFACE[];
-
public:
- TransferEngine(QObject* aParent) : QDBusAbstractInterface(SERVICE, PATH,
- INTERFACE, QDBusConnection::sessionBus(), aParent) {}
+ TransferEngine(QObject* aParent) :
+ QDBusAbstractInterface(QStringLiteral("org.nemo.transferengine"),
+ QStringLiteral("/org/nemo/transferengine"), "org.nemo.transferengine",
+ QDBusConnection::sessionBus(), aParent) {}
public: // METHODS
inline QDBusPendingCall transferMethods()
- { return asyncCall("transferMethods"); }
+ { return asyncCall(QStringLiteral("transferMethods")); }
inline QDBusPendingCall transferMethods2()
- { return asyncCall("transferMethods2"); }
+ { return asyncCall(QStringLiteral("transferMethods2")); }
Q_SIGNALS: // SIGNALS
void transferMethodListChanged();
};
-const char HarbourTransferMethodsModel::TransferEngine::SERVICE[] = "org.nemo.transferengine";
-const char HarbourTransferMethodsModel::TransferEngine::PATH[] = "/org/nemo/transferengine";
-const char HarbourTransferMethodsModel::TransferEngine::INTERFACE[] = "org.nemo.transferengine";
-
// ==========================================================================
-// HarbourTransferMethodsModel
+// HarbourTransferMethodsModel::Private
// ==========================================================================
-HarbourTransferMethodsModel::HarbourTransferMethodsModel(QObject* aParent):
- QAbstractListModel(aParent),
+class HarbourTransferMethodsModel::Private: public QObject
+{
+ Q_OBJECT
+ typedef QDBusPendingCallWatcher* (Private::*RequestUpdate)();
+
+public:
+ enum Role {
+ DisplayNameRole = Qt::UserRole + 1,
+ UserNameRole,
+ MethodIdRole,
+ ShareUIPathRole,
+ AccountIdRole,
+ AccountIconRole
+ };
+
+ Private(HarbourTransferMethodsModel* aModel);
+ ~Private();
+
+public:
+ HarbourTransferMethodsModel* parentModel();
+ static QRegExp regExp(QString aRegExp);
+ void filterModel();
+ QDBusPendingCallWatcher* checkTransferMethods();
+ QDBusPendingCallWatcher* requestTransferMethods();
+ QDBusPendingCallWatcher* requestTransferMethods2();
+ void setTransferMethods2(HarbourTransferMethodInfo2List aList);
+ bool showAccounts();
+
+private Q_SLOTS:
+ void onTransferMethodsCheckFinished(QDBusPendingCallWatcher* aWatch);
+ void onTransferMethodsFinished(QDBusPendingCallWatcher* aWatch);
+ void onTransferMethods2Finished(QDBusPendingCallWatcher* aWatch);
+ void onShowAccountsFinished(QDBusPendingCallWatcher* aWatch);
+ void requestUpdate();
+
+public:
+ QString iFilter;
+ QList<HarbourTransferMethodInfo2> iMethodList;
+ QList<int> iFilteredList;
+ bool iAccountIconSupported;
+ RequestUpdate iRequestUpdate;
+ QDBusPendingCallWatcher* iUpdateWatcher;
+ QDBusPendingCallWatcher* iShowAccountsWatcher;
+ bool iShowAccountsFailed;
+ TransferEngine* iTransferEngine;
+};
+
+HarbourTransferMethodsModel::Private::Private(HarbourTransferMethodsModel* aModel) :
+ QObject(aModel),
iAccountIconSupported(false),
- iRequestUpdate(&HarbourTransferMethodsModel::checkTransferMethods),
- iUpdateWatcher(NULL)
+ iRequestUpdate(&Private::checkTransferMethods),
+ iUpdateWatcher(Q_NULLPTR),
+ iShowAccountsWatcher(Q_NULLPTR),
+ iShowAccountsFailed(false),
+ iTransferEngine(new TransferEngine(this))
{
- iTransferEngine = new TransferEngine(this);
connect(iTransferEngine,
SIGNAL(transferMethodListChanged()),
SLOT(requestUpdate()));
requestUpdate();
}
-HarbourTransferMethodsModel::~HarbourTransferMethodsModel()
+HarbourTransferMethodsModel::Private::~Private()
{
delete iTransferEngine;
}
-bool HarbourTransferMethodsModel::loadTranslations(QTranslator* aTranslator, QLocale aLocale)
+inline HarbourTransferMethodsModel* HarbourTransferMethodsModel::Private::parentModel()
{
- if (aTranslator->load(aLocale, "sailfish_transferengine_plugins", "-",
- "/usr/share/translations")) {
- return true;
- } else {
- HWARN("Failed to load transferengine plugin translator for" << aLocale);
- return false;
- }
+ return qobject_cast<HarbourTransferMethodsModel*>(parent());
}
-void HarbourTransferMethodsModel::requestUpdate()
+void HarbourTransferMethodsModel::Private::requestUpdate()
{
if (iUpdateWatcher) {
- HDEBUG("dropping pending call");
+ HDEBUG("dropping pending method list query");
iUpdateWatcher->disconnect(this);
delete iUpdateWatcher;
- iUpdateWatcher = NULL;
}
iUpdateWatcher = (this->*iRequestUpdate)();
}
-void HarbourTransferMethodsModel::setTransferMethods2(HarbourTransferMethodInfo2List aList)
+void HarbourTransferMethodsModel::Private::setTransferMethods2(HarbourTransferMethodInfo2List aList)
{
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourUtil.cpp
^
|
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 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 "HarbourUtil.h"
+
+// ==========================================================================
+// HarbourUtil::Private
+// ==========================================================================
+
+class HarbourUtil::Private
+{
+public:
+ static const char hex[];
+};
+
+const char HarbourUtil::Private::hex[] = "0123456789abcdef";
+
+// ==========================================================================
+// HarbourUtil
+// ==========================================================================
+
+HarbourUtil::HarbourUtil(
+ QObject* aParent) :
+ QObject(aParent)
+{
+}
+
+// Callback for qmlRegisterSingletonType<HarbourUtil>
+QObject*
+HarbourUtil::createSingleton(
+ QQmlEngine*,
+ QJSEngine*)
+{
+ return new HarbourUtil();
+}
+
+QColor
+HarbourUtil::invertedColor(
+ const QColor& aColor)
+{
+ if (aColor.isValid()) {
+ const QRgb inv = invertedRgb(aColor.rgba());
+
+ return QColor(qRed(inv), qGreen(inv), qBlue(inv), qAlpha(inv));
+ } else {
+ return aColor;
+ }
+}
+
+QRgb
+HarbourUtil::invertedRgb(
+ QRgb aRgb)
+{
+ return ((~(aRgb & RGB_MASK)) & RGB_MASK) | (aRgb & (~RGB_MASK));
+}
+
+QString
+HarbourUtil::toHex(
+ const void* aData,
+ size_t aSize)
+{
+ QString hex;
+
+ if (aSize > 0) {
+ const uchar* bytes = (const uchar*)aData;
+
+ hex.reserve(2 * aSize);
+ for (size_t i = 0; i < aSize; i++) {
+ const uchar b = bytes[i];
+
+ hex.append(QChar(Private::hex[(b & 0xf0) >> 4]));
+ hex.append(QChar(Private::hex[b & 0x0f]));
+ }
+ }
+ return hex;
+}
+
+QByteArray
+HarbourUtil::toHexBytes(
+ const void* aData,
+ size_t aSize)
+{
+ return aSize ?
+ QByteArray::fromRawData((const char*) aData, (int) aSize).toHex() :
+ QByteArray();
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/libcrypto.c
^
|
@@ -0,0 +1,276 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021-2023 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
+ * 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 "gutil_log.h"
+
+#include <dlfcn.h>
+#include <stdint.h>
+
+#include <openssl/aes.h>
+#include <openssl/des.h>
+#include <openssl/md5.h>
+#include <openssl/rsa.h>
+#include <openssl/sha.h>
+
+/*
+ * What is this code?
+ *
+ * Sailfish OS comes in 3 flavors wrt openssl versions:
+ *
+ * 1. Sailfish OS up to 3.4 had openssl 1.0
+ * 2. Sailfish 4.0..4.2 had both openssl 1.0 and openssl 1.1 libraries
+ * 3. Sailfish 4.3 dropped openssl 1.0 libraries and only has openssl 1.1
+ *
+ * Which means that explicitly linking with any version of openssl
+ * makes your app incompatible with either Sailfish OS <= 3.4 or
+ * Sailfish OS >= 4.3 (nice symmetry).
+ *
+ * If you want to build an app which runs on both Sailfish OS <= 3.4
+ * and Sailfish OS >= 4.3 you have two options:
+ *
+ * 1. Link openssl statically
+ * 2. Load libcrypts.so dynamically with dlopen/dlsym
+ *
+ * This module allows you to implement the second strategy. It works
+ * because openssl 1.0 and 1.1 (luckily!) appear to be binary compatible.
+ * It doesn't load all libcrypto functions, only those referenced by my
+ * apps but the list can be easily expanded.
+ */
+
+#ifndef LIBDIR
+# ifdef __aarch64__
+# define LIBDIR "/usr/lib64"
+# else
+# define LIBDIR "/usr/lib"
+# endif
+#endif
+
+/*
+ * OpenSSL 1.0 headers define ERR_load_crypto_strings as a function:
+ *
+ * void ERR_load_crypto_strings(void);
+ *
+ * and OpenSSL 1.1 as a macro:
+ *
+ * #if OPENSSL_API_COMPAT < 0x10100000L
+ * # define ERR_load_crypto_strings() \
+ * OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
+ * # define ERR_free_strings() while(0) continue
+ * #endif
+ *
+ * We want to try loading both ERR_load_crypto_strings and
+ * OPENSSL_init_crypto, one of which will probably fail.
+ */
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+# undef ERR_load_crypto_strings
+#else
+# define OPENSSL_INIT_SETTINGS void
+#endif
+
+/* f(name,params,args) */
+#define LIBCRYPTO_FUNCTIONS1(f) \
+ f(AES_cbc_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key, unsigned char* ivec, const int enc), \
+ (in, out, length, key, ivec, enc)) \
+ f(AES_cfb128_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key,unsigned char* ivec, int* num, const int enc), \
+ (in, out, length, key, ivec, num, enc)) \
+ f(AES_ecb_encrypt, \
+ (const unsigned char* in, unsigned char* out, const AES_KEY* key, \
+ const int enc), \
+ (in, out, key, enc)) \
+ f(BN_clear_free, (BIGNUM *a), (a)) \
+ f(BN_free, (BIGNUM *a), (a)) \
+ f(DES_ede3_cbc_encrypt, \
+ (const unsigned char* input, unsigned char* output, long length, \
+ DES_key_schedule* ks1, DES_key_schedule* ks2, DES_key_schedule* ks3, \
+ DES_cblock* ivec, int enc), \
+ (input, output, length, ks1, ks2, ks3, ivec, enc)) \
+ f(/* libcrypto.so.10 */ ERR_load_crypto_strings, (void), ()) \
+ f(RSA_free, (RSA* r), (r)) \
+ f(/* libcrypto.so.1.1 */ RSA_get0_key, (const RSA* r, const BIGNUM** n, \
+ const BIGNUM** e, const BIGNUM** d), (r, n, e, d)) \
+ f(/* libcrypto.so.1.1 */ RSA_get0_factors, (const RSA* r, \
+ const BIGNUM** p, const BIGNUM** q), (r, p, q)) \
+ f(/* libcrypto.so.1.1 */ RSA_get0_crt_params, (const RSA* r, \
+ const BIGNUM** dmp1, const BIGNUM** dmq1, const BIGNUM** iqmp), \
+ (r, dmp1, dmq1, iqmp))
+
+/* f(ret,name,params,args,def) */
+#define LIBCRYPTO_FUNCTIONS2(f) \
+ f(int, AES_set_decrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(int, AES_set_encrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(BIGNUM*, BN_bin2bn, \
+ (const unsigned char* s, int len, BIGNUM* ret), (s, len, ret), NULL) \
+ f(int, BN_bn2bin, \
+ (const BIGNUM* a, unsigned char* to), (a, to), 0) \
+ f(BIGNUM*, BN_new, (void), (), NULL) \
+ f(int, BN_num_bits, (const BIGNUM *a), (a), 0) \
+ f(int, BN_set_word, (BIGNUM* a, BN_ULONG w), (a, w), 0) \
+ f(int, DES_check_key_parity, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_is_weak_key, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_set_key, \
+ (const_DES_cblock* key, DES_key_schedule* schedule), \
+ (key, schedule), -1) \
+ f(char*, ERR_error_string, (unsigned long e, char* buf), (e, buf), NULL) \
+ f(unsigned long, ERR_get_error, (void), (), 0) \
+ f(unsigned char*, MD5, \
+ (const unsigned char* d, size_t n, unsigned char* md), (d, n, md), NULL) \
+ f(int, MD5_Final, (unsigned char* md, MD5_CTX* c), (md, c), 0) \
+ f(int, MD5_Init, (MD5_CTX* c), (c), 0) \
+ f(int, MD5_Update, (MD5_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(int, /* libcrypto.so.1.1 */ OPENSSL_init_crypto, \
+ (uint64_t opts, const OPENSSL_INIT_SETTINGS* settings), \
+ (opts, settings), 0) \
+ f(int, RAND_bytes, (unsigned char* buf, int num), (buf, num), 0) \
+ f(int, RAND_poll, (void), (), 0) \
+ f(RSA*, RSAPrivateKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(RSA*, RSAPublicKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(int, RSA_generate_key_ex, \
+ (RSA* rsa, int bits, BIGNUM* e, BN_GENCB* cb), \
+ (rsa, bits, e, cb), 0) \
+ f(RSA*, RSA_new, (void), (), NULL) \
+ f(int, RSA_private_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_private_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_size, (const RSA* rsa), (rsa), 0) \
+ f(int, /* libcrypto.so.1.1 */ RSA_set0_key, (RSA* r, BIGNUM* n, \
+ BIGNUM* e, BIGNUM* d), (r, n, e, d), 0) \
+ f(int, /* libcrypto.so.1.1 */ RSA_set0_factors, (RSA* r, BIGNUM* p, \
+ BIGNUM* q), (r, p, q), 0) \
+ f(int, /* libcrypto.so.1.1 */ RSA_set0_crt_params, (RSA* r, \
+ BIGNUM* dmp1, BIGNUM* dmq1, BIGNUM* iqmp), (r, dmp1, dmq1, iqmp), 0) \
+ f(unsigned char*, SHA1, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA1_Final, (unsigned char* md, SHA_CTX* c), (md, c), 0) \
+ f(int, SHA1_Init, (SHA_CTX* c), (c), 0) \
+ f(int, SHA1_Update, (SHA_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(unsigned char*, SHA256, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA256_Final, (unsigned char* md, SHA256_CTX* c), (md, c), 0) \
+ f(int, SHA256_Init, (SHA256_CTX* c), (c), 0) \
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/Makefile
^
|
@@ -0,0 +1,8 @@
+# -*- Mode: makefile-gmake -*-
+
+all:
+%:
+ @$(MAKE) -C TestHarbourBase32 $*
+ @$(MAKE) -C TestHarbourBase45 $*
+ @$(MAKE) -C TestHarbourProtoBuf $*
+ @$(MAKE) -C TestHarbourUtil $*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/Makefile.common
^
|
@@ -0,0 +1,197 @@
+# -*- 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)
+HARBOUR_INCLUDE_DIR = $(HARBOUR_DIR)/include
+HARBOUR_SRC_DIR = $(HARBOUR_DIR)/src
+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_INCLUDE_DIR)
+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)
+GEN_FILES = \
+ $(MOC_H:%.h=$(BUILD_DIR)/moc_%.cpp) \
+ $(MOC_CPP:%.cpp=$(BUILD_DIR)/%.moc)
+
+#
+# Dependencies
+#
+
+DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d) $(COVERAGE_OBJS:%.o=%.d)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(GEN_FILES): | $(BUILD_DIR)
+$(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 : $(HARBOUR_INCLUDE_DIR)/%.h
+ $(MOC) $< -o $@
+
+$(BUILD_DIR)/%.moc : $(HARBOUR_SRC_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_SRC_DIR)/%.cpp $(BUILD_DIR)/%.moc
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_SRC_DIR)/%.cpp $(BUILD_DIR)/%.moc
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_SRC_DIR)/%.cpp $(BUILD_DIR)/%.moc
+ $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(DEBUG_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
+ $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(RELEASE_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
+ $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
+
+$(COVERAGE_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.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)
+ $(LD) $(COVERAGE_LDFLAGS) $^ $(LIBS) -o $@
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/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:harbour-meecalc-1.0.10.tar.bz2/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:harbour-meecalc-1.0.10.tar.bz2/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:harbour-meecalc-1.0.10.tar.bz2/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:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/TestHarbourProtoBuf/Makefile
^
|
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake -*-
+
+PKGS = libglibutil
+EXE = TestHarbourProtoBuf
+HARBOUR_SRC = HarbourProtoBuf.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/TestHarbourProtoBuf/TestHarbourProtoBuf.cpp
^
|
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 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 "HarbourProtoBuf.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * null
+ *==========================================================================*/
+
+static
+void
+test_null(
+ void)
+{
+ g_assert(!HarbourProtoBuf::appendVarInt(NULL, 0));
+ g_assert(!HarbourProtoBuf::appendVarIntKeyValue(NULL, 0, 0));
+ g_assert(!HarbourProtoBuf::appendDelimitedValue(NULL, QByteArray()));
+ g_assert(!HarbourProtoBuf::appendDelimitedKeyValue(NULL,
+ HarbourProtoBuf::TYPE_DELIMITED, QByteArray()));
+ g_assert(!HarbourProtoBuf::parseVarInt(NULL, NULL));
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(NULL, NULL));
+}
+
+/*==========================================================================*
+ * int
+ *==========================================================================*/
+
+static
+void
+test_int(
+ void)
+{
+ QByteArray buf;
+ GUtilRange range;
+ quint64 res;
+
+ static const guint8 enc0[] = { 0 };
+
+ g_assert(HarbourProtoBuf::appendVarInt(&buf, 0) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)enc0, sizeof(enc0)));
+
+ range.end = (range.ptr = enc0);
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, NULL));
+ range.end = (range.ptr = enc0);
+
+ res = 42;
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ range.end = (range.ptr = enc0) + sizeof(enc0);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, NULL));
+ g_assert(range.ptr == range.end);
+
+ res = 42;
+ range.end = (range.ptr = enc0) + sizeof(enc0);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ static const guint8 enc257[] = { 0x82, 0x01 };
+
+ buf.clear();
+ g_assert(HarbourProtoBuf::appendVarInt(&buf, 257) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)enc257, sizeof(enc257)));
+
+ res = 42;
+ range.end = (range.ptr = enc257) + 1;
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ res = 42;
+ range.end = (range.ptr = enc257) + sizeof(enc257);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert(range.ptr == range.end);
+ g_assert_cmpuint(res, == ,257);
+}
+
+/*==========================================================================*
+ * delimited
+ *==========================================================================*/
+
+static
+void
+test_delimited(
+ void)
+{
+ QByteArray buf;
+ GUtilRange range;
+ GUtilData payload;
+ static const guint8 value[] = { 0x01, 0x02 };
+ static const guint8 encodedValue[] = { 0x02, 0x01, 0x02 };
+
+ g_assert(HarbourProtoBuf::appendDelimitedValue(&buf,
+ QByteArray::fromRawData((char*)value, sizeof(value))) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)encodedValue,
+ sizeof(encodedValue)));
+
+ range.end = (range.ptr = encodedValue);
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+ g_assert(range.ptr == encodedValue);
+
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue) - 1;
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+ g_assert(range.ptr == encodedValue);
+
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue);
+ g_assert(HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+
+ memset(&payload, 0, sizeof(payload));
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue);
+ g_assert(HarbourProtoBuf::parseDelimitedValue(&range, &payload));
+ g_assert_cmpuint(payload.size, == ,sizeof(value));
+ g_assert(!memcmp(payload.bytes, value, sizeof(value)));
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourProtoBuf/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("null"), test_null);
+ g_test_add_func(TEST_("int"), test_int);
+ g_test_add_func(TEST_("delimited"), test_delimited);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/TestHarbourUtil/Makefile
^
|
@@ -0,0 +1,8 @@
+# -*- Mode: makefile-gmake -*-
+
+PKGS = Qt5Gui
+EXE = TestHarbourUtil
+MOC_H = HarbourUtil.h
+HARBOUR_SRC = HarbourUtil.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/TestHarbourUtil/TestHarbourUtil.cpp
^
|
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 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 "HarbourUtil.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * object
+ *==========================================================================*/
+
+static
+void
+test_object(
+ void)
+{
+ QObject* obj = HarbourUtil::createSingleton(Q_NULLPTR, Q_NULLPTR);
+
+ g_assert(qobject_cast<HarbourUtil*>(obj));
+ delete obj;
+}
+
+/*==========================================================================*
+ * invertColor
+ *==========================================================================*/
+
+static
+void
+test_invertColor(
+ void)
+{
+ g_assert_cmpuint(HarbourUtil::invertedRgb(0x12345678), == ,0x12cba987);
+ const QColor original(0xcb,0xa9,0x87,0x12);
+ const QColor inverted(0x34,0x56,0x78,0x12);
+ g_assert(HarbourUtil::invertedColor(original) == inverted);
+ g_assert(!HarbourUtil::invertedColor(QColor()).isValid());
+}
+
+/*==========================================================================*
+ * toHex
+ *==========================================================================*/
+
+static
+void
+test_toHex(
+ void)
+{
+ static const char data[] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14
+ };
+
+ // Lower case is assumed
+ const QByteArray hex("0102030405060708090a0b0c0d0e0f1011121314");
+
+ g_assert(HarbourUtil::toHex(QByteArray()).isEmpty());
+ g_assert(HarbourUtil::toHex(Q_NULLPTR, 0).isEmpty());
+ g_assert(HarbourUtil::toHexBytes(Q_NULLPTR, 0).isEmpty());
+ g_assert(HarbourUtil::toHex(data, sizeof(data)) == QString::fromLatin1(hex));
+ const QByteArray out(HarbourUtil::toHexBytes(data, sizeof(data)));
+ g_assert_cmpstr(out.constData(), == ,hex.constData());
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourUtil/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("object"), test_object);
+ g_test_add_func(TEST_("invertColor"), test_invertColor);
+ g_test_add_func(TEST_("toHex"), test_toHex);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/coverage/.gitignore
^
|
@@ -0,0 +1,4 @@
+app.gcov
+full.gcov
+report
+*~
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/coverage/run
^
|
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# This script requires lcov, dirname
+#
+
+TESTS="\
+TestHarbourBase32 \
+TestHarbourBase45 \
+TestHarbourProtoBuf \
+TestHarbourUtil"
+
+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:harbour-meecalc-1.0.10.tar.bz2/harbour-meecalc.desktop
^
|
@@ -5,3 +5,9 @@
Name=MeeCalc
Icon=harbour-meecalc
Exec=harbour-meecalc
+
+[X-HarbourBackup]
+BackupPathList = .local/share/harbour-meecalc/
+
+[X-Sailjail]
+Permissions=
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-meecalc.pro
^
|
@@ -3,22 +3,21 @@
TARGET = $${PREFIX}-$${NAME}
CONFIG += sailfishapp
QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-psabi
-QT += svg
LIBS += -ldl
CONFIG(debug, debug|release) {
DEFINES += HARBOUR_DEBUG=1
}
+TARGET_DATA_DIR = /usr/share/$${TARGET}
+
SOURCES += \
src/main.cpp \
src/CalcEngine.cpp \
src/CalcState.cpp
SOURCES += \
- harbour-lib/src/HarbourJson.cpp \
- harbour-lib/src/HarbourTheme.cpp \
- harbour-lib/src/HarbourImageProvider.cpp
+ harbour-lib/src/HarbourJson.cpp
HEADERS += \
src/CalcEngine.h \
@@ -26,25 +25,32 @@
HEADERS += \
harbour-lib/include/HarbourDebug.h \
- harbour-lib/include/HarbourJson.h \
- harbour-lib/include/HarbourImageProvider.h \
- harbour-lib/include/HarbourTheme.h
+ harbour-lib/include/HarbourJson.h
INCLUDEPATH += \
harbour-lib/include
+HARBOUR_QML_COMPONENTS = \
+ harbour-lib/qml/HarbourHighlightIcon.qml
+
OTHER_FILES += \
+ $${HARBOUR_QML_COMPONENTS} \
qml/*.qml \
qml/*.svg \
translations/*.ts \
icons/*.svg \
*.md \
*.desktop \
+ LICENSE \
rpm/harbour-meecalc.changes \
rpm/harbour-meecalc.spec
+harbour_qml_components.files = $${HARBOUR_QML_COMPONENTS}
+harbour_qml_components.path = $${TARGET_DATA_DIR}/qml/harbour
+INSTALLS += harbour_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}
|
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/icons/172x172/harbour-meecalc.png
^
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/icons/harbour-meecalc.svg
^
|
@@ -1,10 +1,5 @@
<?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:xlink="http://www.w3.org/1999/xlink"
@@ -18,172 +13,96 @@
viewBox="0 0 86 86"
enable-background="new 0 0 86 86"
xml:space="preserve"
- id="svg2"
- inkscape:version="0.48.2 r9819"
sodipodi:docname="harbour-meecalc.svg"
inkscape:export-filename="harbour-meecalc.png"
inkscape:export-xdpi="90"
- inkscape:export-ydpi="90"><metadata
- id="metadata27"><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 /></cc:Work></rdf:RDF></metadata><defs
- id="defs25"><linearGradient
- id="linearGradient3779"><stop
- style="stop-color:#bcbcbc;stop-opacity:1;"
- offset="0"
- id="stop3781" /><stop
- style="stop-color:#ffffff;stop-opacity:1;"
- offset="1"
- id="stop3783" /></linearGradient><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3779"
- id="linearGradient3785"
- x1="43.129311"
- y1="57.637562"
- x2="43.018715"
- y2="30.241274"
- gradientUnits="userSpaceOnUse" /><filter
- id="filter3829"
- inkscape:label="Drop shadow"
- width="1.5"
- height="1.5"
- x="-.25"
- y="-.25"><feGaussianBlur
- id="feGaussianBlur3831"
- in="SourceAlpha"
- stdDeviation="2"
- result="blur" /><feColorMatrix
- id="feColorMatrix3833"
- result="bluralpha"
- type="matrix"
- values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.5 0 " /><feOffset
- id="feOffset3835"
- in="bluralpha"
- dx="2"
- dy="2"
- result="offsetBlur" /><feMerge
- id="feMerge3837"><feMergeNode
- id="feMergeNode3839"
- in="offsetBlur" /><feMergeNode
- id="feMergeNode3841"
- in="SourceGraphic" /></feMerge></filter><linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient8305"
- id="linearGradient23103"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0,-21.095261,-21.095261,0,461.10156,174.82715)"
- spreadMethod="pad"
- x1="0"
- y1="0"
- x2="1"
- y2="0" /><linearGradient
- id="linearGradient8305"
- spreadMethod="pad"
- gradientTransform="matrix(0,-21.095261,-21.095261,0,461.10156,174.82715)"
- gradientUnits="userSpaceOnUse"
- y2="0"
- x2="1"
- y1="0"
- x1="0"><stop
- id="stop8307"
- offset="0"
- style="stop-opacity:1;stop-color:#f6f9ec" /><stop
- id="stop8309"
- offset="1"
- style="stop-opacity:1;stop-color:#d0c9c3" /></linearGradient><linearGradient
- y2="0"
- x2="1"
- y1="0"
- x1="0"
- spreadMethod="pad"
- gradientTransform="matrix(0,26.369076,-26.369076,0,43.000075,30.804812)"
- gradientUnits="userSpaceOnUse"
- id="linearGradient23420"
- xlink:href="#linearGradient8305"
- inkscape:collect="always" /><filter
- id="filter3017"
- inkscape:label="Drop shadow"
- width="1.5"
- height="1.5"
- x="-.25"
- y="-.25"><feGaussianBlur
- id="feGaussianBlur3019"
- in="SourceAlpha"
- stdDeviation="2"
- result="blur" /><feColorMatrix
- id="feColorMatrix3021"
- result="bluralpha"
- type="matrix"
- values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.5 0 " /><feOffset
- id="feOffset3023"
- in="bluralpha"
- dx="2"
- dy="2"
- result="offsetBlur" /><feMerge
- id="feMerge3025"><feMergeNode
- id="feMergeNode3027"
- in="offsetBlur" /><feMergeNode
- id="feMergeNode3029"
- in="SourceGraphic" /></feMerge></filter></defs><sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1337"
- inkscape:window-height="993"
- id="namedview23"
- showgrid="false"
- inkscape:snap-grids="true"
- inkscape:snap-to-guides="true"
- inkscape:zoom="8"
- inkscape:cx="27.349864"
- inkscape:cy="40.039715"
- inkscape:window-x="2229"
- inkscape:window-y="95"
- inkscape:window-maximized="0"
- inkscape:current-layer="svg2" />
-<g
- id="Layer_2"
- display="none">
-</g>
-<g
- id="Layer_1"
- transform="matrix(-1,0,0,1,86,0)">
- <linearGradient
- id="SVGID_1_"
- gradientUnits="userSpaceOnUse"
- x1="22.490395"
- y1="63.509602"
- x2="85.798447"
- y2="0.20155098">
- <stop
- offset="0"
- style="stop-color:#dc6a00;stop-opacity:1;"
- id="stop7" />
- <stop
- offset="1"
- style="stop-color:#f3cb00;stop-opacity:1;"
- id="stop9" />
- </linearGradient>
- <path
- d="M 84.277,0.3 H 43 C 19.417,0.3 0.3,19.418 0.3,43 v 41.277 c 0,0.786 0.637,1.423 1.423,1.423 H 43 C 66.583,85.7 85.7,66.582 85.7,43 V 1.723 C 85.7,0.937 85.063,0.3 84.277,0.3 z"
- id="path11"
- style="fill:url(#SVGID_1_)"
- inkscape:connector-curvature="0" />
- <g
- id="g13">
-
- </g>
-
-
-
-</g>
-<path
- id="path8311"
- style="fill:url(#linearGradient23420);stroke:none;filter:url(#filter3017)"
- d="m 21.344375,28.92375 c -1.19125,0 -2.16625,0.975 -2.16625,2.16875 l 0,0 0,5.41125 c 0,1.19 0.975,2.16625 2.16625,2.16625 l 0,0 43.3125,0 c 1.19125,0 2.165,-0.97625 2.165,-2.16625 l 0,0 0,-5.41125 c 0,-1.19375 -0.97375,-2.16875 -2.165,-2.16875 l 0,0 -43.3125,0 z m 0,18.4075 c -1.19125,0 -2.16625,0.975 -2.16625,2.16625 l 0,0 0,5.41375 c 0,1.19125 0.975,2.165 2.16625,2.165 l 0,0 43.3125,0 c 1.19125,0 2.165,-0.97375 2.165,-2.165 l 0,0 0,-5.41375 c 0,-1.19125 -0.97375,-2.16625 -2.165,-2.16625 l 0,0 -43.3125,0 z"
- inkscape:connector-curvature="0" /></svg>
+ inkscape:export-ydpi="90">
+ <defs>
+ <linearGradient
+ id="linearGradient8305"
+ spreadMethod="pad"
+ gradientTransform="matrix(0,-21.095261,-21.095261,0,461.10156,174.82715)"
+ gradientUnits="userSpaceOnUse"
+ y2="0"
+ x2="1"
+ y1="0"
+ x1="0">
+ <stop
+ offset="0"
+ style="stop-opacity:1;stop-color:#f6f9ec"/>
+ <stop
+ offset="1"
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/qml/Backspace.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2021 Jolla Ltd.
+ * Copyright (C) 2014-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of 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
@@ -34,10 +34,13 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
+import "harbour"
+
MouseArea {
id: button
- property string iconSourcePrefix
- property string iconSourceSuffix
+
+ property alias foregroundColor: image.highlightColor
+
signal repeat()
onPressedChanged: {
@@ -49,13 +52,14 @@
}
}
- Image {
+ HarbourHighlightIcon {
id: image
+
anchors.centerIn: parent
width: parent.width
sourceSize.width: parent.width
fillMode: Image.PreserveAspectFit
- source: iconSourcePrefix + Qt.resolvedUrl("meecalc-backspace.svg") + iconSourceSuffix
+ source: Qt.resolvedUrl("meecalc-backspace.svg")
smooth: true
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/qml/CalcCover.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2021 Jolla Ltd.
+ * Copyright (C) 2014-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of 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
@@ -37,10 +37,9 @@
CoverBackground {
Calculator {
engine: Engine
- buttonTextColor: Theme.primaryColor
- iconSourcePrefix: "image://" + ImageProvider + "/"
- iconSourceSuffix: "?" + Theme.primaryColor
+ foregroundColor: Theme.primaryColor
anchors.centerIn: parent
- height: parent.height*19/20
+ height: parent.height - 2 * Theme.paddingLarge
+ width: parent.width - 2 * Theme.paddingLarge
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/qml/CalcPage.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2021 Jolla Ltd.
+ * Copyright (C) 2014-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of 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
@@ -32,38 +32,51 @@
*/
import QtQuick 2.0
+import QtFeedback 5.0
import Sailfish.Silica 1.0
import org.nemomobile.notifications 1.0
Page {
- allowedOrientations: window.allowedOrientations
property alias engine: calculator.engine
- Rectangle {
- anchors.fill: parent
- color: "black"
+
+ ThemeEffect {
+ id: buzz
+
+ effect: ThemeEffect.Press
}
+
Notification {
id: notification
+
+ //: Shown when display text has been copied to clipboard
+ //% "Copied to clipboard"
+ previewBody: qsTrId("calculator-notification-text_copied")
+ Component.onCompleted: {
+ if ("icon" in notification) {
+ notification.icon = "icon-s-clipboard"
+ }
+ }
}
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ }
+
Calculator {
id: calculator
- anchors.centerIn: parent
- height: parent.height - 2*Theme.paddingLarge
+
+ x: Theme.paddingLarge
+ y: Theme.paddingLarge
+ width: parent.width - 2 * x
+ height: parent.height - 2 * y
onTextCopied: {
- notification.close()
- //: Shown when display text has been copied to clipboard
- //% "Copied to clipboard"
- notification.previewBody = qsTrId("calculator-notification-text_copied")
- if ("icon" in notification) {
- notification.icon = "icon-s-clipboard"
- }
notification.publish()
+ buzz.play()
}
onButtonPressed: {
notification.close()
+ buzz.play()
}
}
- function oops() {
- calculator.oops()
- }
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/qml/Calculator.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2021 Jolla Ltd.
+ * Copyright (C) 2014-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of 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
@@ -36,28 +36,21 @@
Item {
id: calculator
- implicitWidth: buttons.width
+
+ implicitWidth: 3 * buttonSize + 2 + Theme.paddingSmall
property var engine
- property color buttonTextColor: "white"
- property string iconSourcePrefix
- property string iconSourceSuffix
-
- readonly property int buttonSize: height/8
- readonly property int paddingSmall: Math.max(height/160,3)
- readonly property int paddingMedium: Math.max(height/80,2)
- readonly property int paddingLarge: Math.max(height/40,1)
- readonly property int gap: paddingLarge + paddingSmall
+ property color foregroundColor: "white"
+
+ readonly property int buttonSize: Math.floor(height/8)
+ readonly property int sizeTiny: Math.max(Math.floor(height/1024),1)
signal textCopied(var text)
signal buttonPressed()
Connections {
target: engine
- onOops: {
- console.log("oops")
- display.flash()
- }
+ onOops: display.flash()
}
Item {
@@ -66,7 +59,6 @@
bottom: buttons.top
left: parent.left
right: parent.right
- bottomMargin: paddingSmall
}
Display {
@@ -77,16 +69,16 @@
bottom: parent.bottom
left: parent.left
right: backspace.left
- rightMargin: paddingLarge
+ rightMargin: Theme.paddingLarge
}
onTextCopied: calculator.textCopied(text)
onPressed: calculator.buttonPressed()
}
+
Backspace {
id: backspace
width: buttonSize/2
- iconSourcePrefix: calculator.iconSourcePrefix
- iconSourceSuffix: calculator.iconSourceSuffix
+ foregroundColor: calculator.foregroundColor
anchors {
top: parent.top
bottom: parent.bottom
@@ -102,24 +94,39 @@
Column {
id: buttons
- spacing: paddingSmall
+
+ spacing: Theme.paddingSmall
+ width: parent.width
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
}
- Image {
- height: sourceSize.height
- width: parent.width - 2*paddingSmall
+ Rectangle {
+ width: parent.width
+ height: sizeTiny * 2
anchors.horizontalCenter: parent.horizontalCenter
- source: "meecalc-separator-background.svg"
- fillMode: Image.TileHorizontally
+ color: foregroundColor
+ opacity: 0.2
+
+ Rectangle {
+ y: sizeTiny
+ width: parent.width
+ height: sizeTiny
+ color: foregroundColor
+ opacity: 0.6
+ }
}
- Row {
- spacing: gap
+ Grid {
+ rows: 6
+ columns: 3
+ rowSpacing: Math.min((calculator.height - (rows + 1) * buttonSize) / (rows + 2))
+ columnSpacing: Math.min((calculator.width - columns * buttonSize) / (columns + 1))
+ x: columnSpacing
+
CalcButton {
- normalColor: buttonTextColor
+ normalColor: foregroundColor
width: buttonSize
text: "C"
onPressed: {
@@ -127,9 +134,9 @@
calculator.buttonPressed()
}
}
+
CalcButton {
- id: divideButton
- normalColor: buttonTextColor
+ normalColor: foregroundColor
width: buttonSize
text: OP_DIVIDE
onPressed: {
@@ -138,9 +145,9 @@
}
selected: engine.selectedOp === text
}
+
CalcButton {
- id: multiplyButton
- normalColor: buttonTextColor
+ normalColor: foregroundColor
width: buttonSize
text: OP_MULTIPLY
onPressed: {
@@ -149,12 +156,11 @@
}
selected: engine.selectedOp === text
}
- }
- Row {
- spacing: gap
- height: buttonSize + gap
+
+ // -------------------------------------
+
CalcButton {
- normalColor: buttonTextColor
+ normalColor: foregroundColor
width: buttonSize
text: "\u00b1"
onPressed: {
@@ -162,9 +168,9 @@
calculator.buttonPressed()
}
}
+
CalcButton {
- id: minusButton
- normalColor: buttonTextColor
+ normalColor: foregroundColor
width: buttonSize
text: OP_MINUS
onPressed: {
@@ -173,9 +179,9 @@
}
selected: engine.selectedOp === text
}
+
CalcButton {
- id: plusButton
- normalColor: buttonTextColor
+ normalColor: foregroundColor
width: buttonSize
text: OP_PLUS
onPressed: {
@@ -184,11 +190,11 @@
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/qml/Display.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2021 Jolla Ltd.
+ * Copyright (C) 2014-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of 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
@@ -34,7 +34,7 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
-Item {
+MouseArea {
id: display
property alias text: displayText.text
@@ -51,6 +51,7 @@
Rectangle {
id: background
+
anchors {
left: parent.left
right: parent.right
@@ -65,41 +66,22 @@
Text {
id: displayText
+
color: textColor
anchors.fill: parent
-
- smooth: true
- font.bold: true
-
- Component.onCompleted: refitText()
+ font {
+ bold: true
+ pixelSize: parent.height - 2 * Theme.paddingSmall
+ }
+ fontSizeMode: Text.Fit
+ minimumPixelSize: Theme.fontSizeTiny
horizontalAlignment: Text.AlignRight;
verticalAlignment: Text.AlignVCenter;
-
- onWidthChanged: refitText()
- onHeightChanged: refitText()
- onTextChanged: refitText()
-
- function refitText() {
- if (paintedHeight > 0 && paintedWidth > 0) {
- if (font.pixelSize % 2) font.pixelSize++
- while (paintedWidth > width || paintedHeight > height) {
- if ((font.pixelSize -= 2) <= minimumSize)
- break
- }
- while (paintedWidth < width && paintedHeight < height) {
- font.pixelSize += 2
- }
- font.pixelSize -= 2
- if (font.pixelSize >= maximumSize) {
- font.pixelSize = maximumSize
- return
- }
- }
- }
}
SequentialAnimation{
id: flashAnimation
+
ParallelAnimation {
ColorAnimation {
target: displayText
@@ -136,15 +118,10 @@
}
}
- MouseArea {
- anchors.fill: parent
- onPressed: display.pressed()
- onPressAndHold: {
- if (displayText.text != "0") {
- Clipboard.text = text
- display.textCopied(displayText.text)
- display.flash()
- }
- }
+ onPressed: display.pressed()
+ onPressAndHold: {
+ Clipboard.text = text
+ display.textCopied(displayText.text)
+ display.flash()
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/qml/main.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2021 Jolla Ltd.
+ * Copyright (C) 2014-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of 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
@@ -33,11 +33,16 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
-import harbour.meecalc 1.0
ApplicationWindow {
id: window
+
allowedOrientations: Orientation.Portrait
- initialPage: Component { CalcPage { engine: Engine } }
- cover: Qt.resolvedUrl("CalcCover.qml")
+ initialPage: Component {
+ CalcPage {
+ engine: Engine
+ allowedOrientations: window.allowedOrientations
+ }
+ }
+ cover: Component { CalcCover { } }
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/qml/meecalc-backspace.svg
^
|
@@ -1,75 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
<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"
width="45"
height="28"
- id="svg6664"
version="1.1"
inkscape:version="0.48.2 r9819"
sodipodi:docname="meecalc-backspace.svg">
- <defs
- id="defs6666" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="19.79899"
- inkscape:cx="21.957929"
- inkscape:cy="15.792381"
- inkscape:current-layer="layer3"
- showgrid="true"
- inkscape:grid-bbox="true"
- inkscape:document-units="px"
- fit-margin-top="0"
- fit-margin-left="0"
- fit-margin-right="0"
- fit-margin-bottom="0"
- inkscape:window-width="1430"
- inkscape:window-height="1016"
- inkscape:window-x="1995"
- inkscape:window-y="75"
- inkscape:window-maximized="0">
- <inkscape:grid
- type="xygrid"
- id="grid6683"
- empspacing="8"
- visible="true"
- enabled="true"
- snapvisiblegridlinesonly="true" />
- </sodipodi:namedview>
- <metadata
- id="metadata6669">
- <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
inkscape:groupmode="layer"
- id="layer3"
inkscape:label="Drawing"
style="display:inline"
transform="translate(-2.9374978,-10.062499)">
<path
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
- d="m 16.968748,10.062499 c -1.02107,0 -2.03125,1 -2.03125,1 l -11.0000002,11 c -1,1 -1,2 -1,2 0,0 0,1 1,2 l 11.0000002,11 c 0,0 1,1 2,1 l 30,0 c 1,0 1,-1 1,-1 l 0,-26 c 0,0 0,-1 -1,-1 l -29.96875,0 z m 18.875,5.1875 c 0.379794,0.03453 0.65625,0.3125 0.65625,0.3125 l 1.4375,1.4375 c 0,0 0.681853,0.693147 0,1.375 l -5.6875,5.6875 5.625,5.59375 c 0.757617,0.757615 0.0625,1.46875 0.0625,1.46875 l -1.375,1.375 c 0,0 -0.761643,0.738357 -1.46875,0.03125 l -5.65625,-5.65625 -5.6875,5.6875 c -0.681853,0.681857 -1.375,-0.03125 -1.375,-0.03125 l -1.4375,-1.4375 c 0,0 -0.707107,-0.667893 0,-1.375 l 5.65625,-5.65625 -5.625,-5.625 c -0.732357,-0.73236 -0.03125,-1.4375 -0.03125,-1.4375 l 1.40625,-1.40625 c 0,0 0.730393,-0.738357 1.4375,-0.03125 l 5.65625,5.65625 5.65625,-5.65625 c 0.265165,-0.265165 0.522124,-0.333216 0.75,-0.3125 z"
- id="path6686"
- inkscape:connector-curvature="0" />
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ d="m 16.968748,10.062499 c -1.02107,0 -2.03125,1 -2.03125,1 l -11.0000002,11 c -1,1 -1,2 -1,2 0,0 0,1 1,2 l 11.0000002,11 c 0,0 1,1 2,1 l 30,0 c 1,0 1,-1 1,-1 l 0,-26 c 0,0 0,-1 -1,-1 l -29.96875,0 z m 18.875,5.1875 c 0.379794,0.03453 0.65625,0.3125 0.65625,0.3125 l 1.4375,1.4375 c 0,0 0.681853,0.693147 0,1.375 l -5.6875,5.6875 5.625,5.59375 c 0.757617,0.757615 0.0625,1.46875 0.0625,1.46875 l -1.375,1.375 c 0,0 -0.761643,0.738357 -1.46875,0.03125 l -5.65625,-5.65625 -5.6875,5.6875 c -0.681853,0.681857 -1.375,-0.03125 -1.375,-0.03125 l -1.4375,-1.4375 c 0,0 -0.707107,-0.667893 0,-1.375 l 5.65625,-5.65625 -5.625,-5.625 c -0.732357,-0.73236 -0.03125,-1.4375 -0.03125,-1.4375 l 1.40625,-1.40625 c 0,0 0.730393,-0.738357 1.4375,-0.03125 l 5.65625,5.65625 5.65625,-5.65625 c 0.265165,-0.265165 0.522124,-0.333216 0.75,-0.3125 z"
+ inkscape:connector-curvature="0" />
</g>
</svg>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/qml/meecalc-button-background.svg
^
|
@@ -1,111 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
<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"
width="100"
height="100"
- id="svg2"
version="1.1"
- inkscape:version="0.48.2 r9819"
sodipodi:docname="meecalc-button-background.svg"
- inkscape:export-filename="D:\users\slava\projects\jolla\icons\meecalc-button-background.png"
+ inkscape:export-filename="meecalc-button-background.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
- <defs
- id="defs4">
- <linearGradient
- id="linearGradient6074">
- <stop
- style="stop-color:#ef9608;stop-opacity:1;"
- offset="0"
- id="stop6076" />
- <stop
- id="stop6084"
- offset="0.5"
- style="stop-color:#efa40c;stop-opacity:1;" />
- <stop
- id="stop6082"
- offset="1"
- style="stop-color:#efb210;stop-opacity:1;" />
- </linearGradient>
- <clipPath
- id="clipPath2999"
- clipPathUnits="userSpaceOnUse">
- <path
- id="path3001"
- d="M 0,80 80,80 80,0 0,0 0,80 z"
- inkscape:connector-curvature="0" />
- </clipPath>
- <linearGradient
- id="linearGradient5819"
- spreadMethod="pad"
- gradientTransform="matrix(0,-66.929413,-66.929413,0,461.10254,199.50684)"
- gradientUnits="userSpaceOnUse"
- y2="0"
- x2="1"
- y1="0"
- x1="0">
- <stop
- id="stop5821"
- offset="0"
- style="stop-opacity:1;stop-color:#ffffff" />
- <stop
- id="stop5823"
- offset="1"
- style="stop-opacity:1;stop-color:#ffffff" />
- </linearGradient>
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="3.959798"
- inkscape:cx="84.562273"
- inkscape:cy="31.572608"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- inkscape:window-width="1279"
- inkscape:window-height="990"
- inkscape:window-x="2398"
- inkscape:window-y="18"
- inkscape:window-maximized="0"
- fit-margin-top="0"
- fit-margin-left="0"
- fit-margin-right="0"
- fit-margin-bottom="0" />
- <metadata
- id="metadata7">
- <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>
+ <defs/>
<g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-952.3622)">
+ inkscape:groupmode="layer"
+ transform="translate(0,-952.3622)">
<path
- id="path5841"
- style="fill:#efa40c;fill-opacity:1;stroke:none"
- d="M 49.999261,952.3622 C 12.955645,952.3622 0,965.3195 0,1002.3622 c 0,37.0426 12.955645,50 49.999261,50 37.045095,0 50.000739,-12.9574 50.000739,-50 0,-37.0427 -12.955644,-50 -50.000739,-50"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="csssc" />
+ style="fill:#efa40c;fill-opacity:1;stroke:none"
+ d="M 50,952.3622 C 12.955645,952.3622 0,965.3195 0,1002.3622 c 0,37.0426 12.955645,50 50,50 37.045095,0 50,-12.9574 50,-50 0,-37 -12.955644,-50 -50,-50"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="csssc"/>
</g>
</svg>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/src/main.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2021 Jolla Ltd.
+ * Copyright (C) 2014-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of 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
@@ -34,9 +34,6 @@
#include "CalcEngine.h"
#include "CalcState.h"
-#include "HarbourImageProvider.h"
-#include "HarbourTheme.h"
-
#include <sailfishapp.h>
#include <QtGui>
@@ -49,8 +46,6 @@
{
QGuiApplication* app = SailfishApp::application(argc, argv);
- qmlRegisterType<CalcEngine>("harbour.meecalc", 1, 0, "CalcEngine");
-
QString statePath(QStandardPaths::writableLocation(
QStandardPaths::GenericDataLocation) +
QStringLiteral("/" MEECALC_APP "/") +
@@ -75,13 +70,8 @@
}
QQuickView* view = SailfishApp::createView();
- QQmlEngine* engine = view->engine();
- QString imageProvider("meecalc");
- engine->addImageProvider(imageProvider, new HarbourImageProvider);
-
QQmlContext* root = view->rootContext();
- root->setContextProperty("ImageProvider", imageProvider);
- root->setContextProperty("HarbourTheme", new HarbourTheme(app));
+
root->setContextProperty("OP_MULTIPLY", CalcEngine::OP_MULTIPLY);
root->setContextProperty("OP_DIVIDE", CalcEngine::OP_DIVIDE);
root->setContextProperty("OP_MINUS", CalcEngine::OP_MINUS);
|
[-]
[+]
|
Deleted |
_service:tar_git:harbour-meecalc-1.0.8.tar.bz2/qml/meecalc-separator-background.svg
^
|
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<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"
- width="1"
- height="2"
- id="svg2"
- version="1.1"
- inkscape:version="0.48.2 r9819"
- sodipodi:docname="New document 1">
- <defs
- id="defs4" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="179.2"
- inkscape:cx="-0.084821424"
- inkscape:cy="1.0327444"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- inkscape:window-width="1164"
- inkscape:window-height="1026"
- inkscape:window-x="2311"
- inkscape:window-y="17"
- inkscape:window-maximized="0">
- <inkscape:grid
- type="xygrid"
- id="grid2985"
- empspacing="1"
- visible="true"
- enabled="true"
- snapvisiblegridlinesonly="true"
- dotted="false" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <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
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(0,-1050.3622)">
- <rect
- style="fill:#ffffff;fill-opacity:0.15686275;fill-rule:nonzero;stroke:none"
- id="rect2987"
- width="1"
- height="2"
- x="0"
- y="1050.3622" />
- <rect
- style="fill:#ffffff;fill-opacity:0.15686275;fill-rule:nonzero;stroke:none"
- id="rect2989"
- width="1"
- height="1"
- x="0"
- y="1"
- transform="translate(0,1050.3622)" />
- </g>
-</svg>
|