[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/harbour-qrclip.git</param>
<param name="branch">master</param>
- <param name="revision">dc580c1</param>
+ <param name="revision">7c9fcb2</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/.gitignore
^
|
@@ -1,2 +1,2 @@
build
-harbour-qrclip.pro.user
+harbour-qrclip.pro.user*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/LICENSE
^
|
@@ -1,5 +1,5 @@
Copyright (C) 2019-2021 Jolla Ltd.
-Copyright (C) 2019-2021 Slava Monich <slava@monich.com>
+Copyright (C) 2019-2023 Slava Monich <slava@monich.com>
You may use this file under the terms of the BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/LICENSE
^
|
@@ -1,5 +1,5 @@
Copyright (C) 2015-2021 Jolla Ltd.
-Copyright (C) 2015-2021 Slava Monich <slava@monich.com>
+Copyright (C) 2015-2023 Slava Monich <slava@monich.com>
You may use this file under the terms of BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/harbour-lib.pro
^
|
@@ -25,7 +25,9 @@
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 \
@@ -35,6 +37,7 @@
src/HarbourOrganizeListModel.cpp \
src/HarbourPolicyPlugin.cpp \
src/HarbourProcessState.cpp \
+ src/HarbourProtoBuf.cpp \
src/HarbourSelectionListModel.cpp \
src/HarbourSigChildHandler.cpp \
src/HarbourSingleImageProvider.cpp \
@@ -45,7 +48,8 @@
src/HarbourTask.cpp \
src/HarbourTemporaryFile.cpp \
src/HarbourTransferMethodInfo.cpp \
- src/HarbourTransferMethodsModel.cpp
+ src/HarbourTransferMethodsModel.cpp \
+ src/HarbourUtil.cpp
greaterThan(QT_MAJOR_VERSION, 4) {
SOURCES += \
@@ -58,7 +62,9 @@
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 \
@@ -68,6 +74,7 @@
include/HarbourOrganizeListModel.h \
include/HarbourPolicyPlugin.h \
include/HarbourProcessState.h \
+ include/HarbourProtoBuf.h \
include/HarbourSelectionListModel.h \
include/HarbourSigChildHandler.h \
include/HarbourSingleImageProvider.h \
@@ -78,7 +85,8 @@
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 += \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/include/HarbourAztecCodeGenerator.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -39,25 +39,42 @@
class HarbourAztecCodeGenerator : public QObject {
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(int ecLevel READ ecLevel WRITE setEcLevel NOTIFY ecLevelChanged)
Q_PROPERTY(QString code READ code NOTIFY codeChanged)
Q_PROPERTY(bool running READ running NOTIFY runningChanged)
+ Q_ENUMS(ECLevel)
public:
+ enum ECLevel {
+ ECLevelDefault = -1,
+ ECLevelLowest = 5,
+ ECLevelLow = 10,
+ ECLevelMedium = 23,
+ ECLevelHigh = 36,
+ ECLevelVeryHigh = 50,
+ ECLevelHighest = 95,
+ ECLevelCount
+ };
+
HarbourAztecCodeGenerator(QObject* aParent = Q_NULLPTR);
QString text() const;
void setText(QString aValue);
+ int ecLevel() const;
+ void setEcLevel(int aValue);
+
QString code() const;
bool running() const;
- static QByteArray generate(QString aText);
+ static QByteArray generate(QString aText, int aEcLevel = ECLevelDefault);
// Callback for qmlRegisterSingletonType<HarbourAztecCodeGenerator>
static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
Q_SIGNALS:
void textChanged();
+ void ecLevelChanged();
void codeChanged();
void runningChanged();
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/include/HarbourBase32.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019-2021 Jolla Ltd.
- * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
+ * 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:
*
@@ -37,13 +37,15 @@
#include <QString>
#include <QByteArray>
-class HarbourBase32 {
+class HarbourBase32
+{
class Private;
- HarbourBase32();
+ HarbourBase32() Q_DECL_EQ_DELETE;
+
public:
- static QByteArray fromBase32(QString aBase32);
- static QString toBase32(QByteArray aBinary, bool aLowerCase = true);
- static bool isValidBase32(QString aBase32);
+ static bool isValidBase32(const QString);
+ static QString toBase32(const QByteArray, bool aLowerCase = true);
+ static QByteArray fromBase32(const QString);
};
#endif // HARBOUR_BASE32_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/include/HarbourBase45.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * 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:
*
@@ -37,13 +37,15 @@
#include <QString>
#include <QByteArray>
-class HarbourBase45 {
+class HarbourBase45
+{
class Private;
- HarbourBase45();
+ HarbourBase45() Q_DECL_EQ_DELETE;
+
public:
- static bool isValidBase45(QString aBase45);
- static QByteArray fromBase45(QString aBase45);
- static QString toBase45(QByteArray aBinary);
+ static bool isValidBase45(const QString);
+ static QString toBase45(const QByteArray);
+ static QByteArray fromBase45(const QString);
};
#endif // HARBOUR_BASE45_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/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-qrclip-1.0.11.tar.gz/harbour-lib/include/HarbourColorEditorModel.h
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_COLOR_EDITOR_MODEL_H
+#define HARBOUR_COLOR_EDITOR_MODEL_H
+
+#include <QList>
+#include <QColor>
+#include <QAbstractListModel>
+
+class HarbourColorEditorModel : public QAbstractListModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList colors READ getColors WRITE setColors NOTIFY colorsChanged)
+ Q_PROPERTY(int dragPos READ getDragPos WRITE setDragPos NOTIFY dragPosChanged)
+ Q_ENUMS(ItemType)
+
+public:
+ enum ItemType {
+ ColorItem,
+ TrashedItem,
+ AddItem
+ };
+
+ HarbourColorEditorModel(QObject* aParent = Q_NULLPTR);
+
+ QStringList getColors() const;
+ void setColors(QStringList aColors);
+
+ int getDragPos() const;
+ void setDragPos(int pos);
+
+ Q_INVOKABLE void addColor(QColor aColor);
+ Q_INVOKABLE int indexOf(QColor aColor) const;
+
+ // QAbstractListModel
+ QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE;
+ int rowCount(const QModelIndex& aParent) const Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex& aIndex, int aRole) const Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void colorsChanged();
+ void dragPosChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_COLOR_EDITOR_MODEL_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/include/HarbourProcessState.h
^
|
@@ -44,6 +44,7 @@
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);
@@ -52,6 +53,7 @@
static QObject* createSingleton(QQmlEngine* aEngine, QJSEngine* aScript);
static bool isJailedApp();
+ static bool isPrivileged();
};
#endif // HARBOUR_PROCESS_STATE_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/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
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/include/HarbourSelectionListModel.h
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -37,33 +37,44 @@
#include <QtQml>
#include <QIdentityProxyModel>
-class HarbourSelectionListModel : public 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 selectionCount READ selectionCount 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* aModel);
+ 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& aIndex) const Q_DECL_OVERRIDE;
+ Qt::ItemFlags flags(const QModelIndex&) const Q_DECL_OVERRIDE;
QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE;
- QVariant data(const QModelIndex& aIndex, int aRole) const Q_DECL_OVERRIDE;
- bool setData(const QModelIndex& aIndex, const QVariant& aValue, int aRole) 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:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/include/HarbourTheme.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 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:
*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/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
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/qml/HarbourBadge.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 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:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -39,6 +39,9 @@
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)
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/qml/HarbourColorEditorDialog.qml
^
|
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Dialog {
+ id: thisDialog
+
+ readonly property color selectedColor: sampleItem.color
+ property color initialColor: Theme.highlightColor
+ property string acceptText: "Add color"
+ property alias hueSliderText: hueSlider.label // "Color"
+ property alias brightnessSliderText: brightnessSlider.label // "Brightness"
+ property string hexNotationText: "Hex notation"
+
+ canAccept: hexText.acceptableInput
+ forwardNavigation: !hueItem.pressed
+ backNavigation: !hueItem.pressed
+
+ DialogHeader {
+ id: header
+
+ acceptText: forwardNavigation ?
+ (thisDialog.acceptText ? thisDialog.acceptText : defaultAcceptText) : ""
+ }
+
+ Component.onCompleted: hexText.text = initialColor.toString().substr(1)
+
+ // Otherwise width is changing with a delay, causing visible layout changes
+ onIsLandscapeChanged: width = isLandscape ? Screen.height : Screen.width
+
+ SilicaFlickable {
+ clip: true
+ interactive: !hueItem.pressed
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: header.bottom
+ bottom: parent.bottom
+ }
+
+ HarbourColorHueItem {
+ id: hueItem
+
+ x: Theme.horizontalPageMargin
+ width: parent.width - 2 * x
+ anchors {
+ top: parent.top
+ bottom: toolPanel.top
+ bottomMargin: Theme.paddingSmall
+ }
+ brightness: brightnessSlider.sliderValue
+ onTapped: hueSlider.value = h
+ }
+
+ Column {
+ id: toolPanel
+
+ width: parent.width
+ anchors.bottom: parent.bottom
+
+ Slider {
+ id: hueSlider
+
+ width: parent.width
+ leftMargin: Theme.horizontalPageMargin
+ rightMargin: Theme.horizontalPageMargin
+ minimumValue: 0
+ maximumValue: 1
+ value: 1
+ label: "Color"
+ opacity: (y + parent.y >= 0) ? 1 : 0
+ onSliderValueChanged: hexText.updateText()
+ }
+
+ Slider {
+ id: brightnessSlider
+
+ width: parent.width
+ leftMargin: Theme.horizontalPageMargin
+ rightMargin: Theme.horizontalPageMargin
+ label: "Brightness"
+ minimumValue: 0
+ maximumValue: 1
+ value: 1
+ opacity: (y + parent.y >= 0) ? 1 : 0
+ onSliderValueChanged: hexText.updateText()
+ }
+
+ Item {
+ x: Theme.horizontalPageMargin
+ width: parent.width - 2 * x
+ height: hexText.height
+ Row {
+ spacing: Theme.paddingSmall
+
+ Label {
+ id: hexLabel
+
+ y: hexText.textTopMargin
+ text: "#"
+ font.pixelSize: Theme.fontSizeLarge
+ }
+
+ Item {
+ readonly property int maxWidth: toolPanel.width - 2 * Theme.horizontalPageMargin - hexLabel.width - parent.spacing - Theme.paddingLarge - sample.width
+ width: Math.min(Math.max(textLabelTemplate.implicitWidth, Theme.itemSizeHuge), maxWidth)
+ height: hexText.height
+
+ Label {
+ id: textLabelTemplate
+
+ // Same text as hexText.label
+ text: hexNotationText
+ font.pixelSize: Theme.fontSizeSmall
+ opacity: 0
+ }
+
+ TextField {
+ id: hexText
+
+ property int ignoreTextUpdates // to avoid binding loops
+ property color tmpColor
+
+ font.pixelSize: Theme.fontSizeLarge
+ width: parent.width
+ textLeftMargin: 0
+ textRightMargin: 0
+ label: hexNotationText
+ validator: RegExpValidator { regExp: /^[0-9a-fA-F]{6}$/ }
+ inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
+ EnterKey.iconSource: "image://theme/icon-m-enter-close"
+ EnterKey.onClicked: hexText.focus = false
+
+ onTextChanged: {
+ if (!ignoreTextUpdates) {
+ // acceptableInput hasn't been updated yet
+ syncTimer.restart()
+ }
+ }
+
+ onActiveFocusChanged: {
+ if (!activeFocus && !acceptableInput) {
+ updateText()
+ }
+ }
+
+ function syncColor() {
+ if (acceptableInput) {
+ tmpColor = "#" + text
+ ignoreTextUpdates++
+ brightnessSlider.value = hueItem.getV(tmpColor)
+ hueSlider.value = hueItem.getH(tmpColor)
+ ignoreTextUpdates--
+ }
+ }
+
+ function updateText() {
+ if (!ignoreTextUpdates) {
+ ignoreTextUpdates++
+ var s = hueItem.getColor(hueSlider.sliderValue).toString()
+ text = (s.length > 0 && s.charAt(0) === '#') ? s.substr(1) : s
+ ignoreTextUpdates--
+ }
+ }
+
+ Timer {
+ id: syncTimer
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/qml/HarbourColorHueItem.qml
^
|
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Rectangle {
+ id: thisItem
+
+ color: "black"
+
+ property alias brightness: mouseArea.opacity
+ property alias pressed: mouseArea.pressed
+
+ readonly property color color0: "#ffffff" // 1.0
+ readonly property color color1: "#ff0000" // colorStop7
+ readonly property color color2: "#ff00ff" // colorStop6
+ readonly property color color3: "#0000ff" // colorStop5
+ readonly property color color4: "#00ffff" // colorStop4
+ readonly property color color5: "#00ff00" // colorStop3
+ readonly property color color6: "#ffff00" // colorStop2
+ readonly property color color7: "#ff0000" // colorStop1
+ readonly property color color8: "#ffffff" // 0.0
+
+ readonly property real colorStop1: 0.125
+ readonly property real colorStop2: 0.250
+ readonly property real colorStop3: 0.375
+ readonly property real colorStop4: 0.500
+ readonly property real colorStop5: 0.625
+ readonly property real colorStop6: 0.750
+ readonly property real colorStop7: 0.875
+ readonly property real hueLast: colorStop7
+ readonly property real hueRange: hueLast - colorStop1
+
+ signal tapped(var h)
+
+ function getColor(h) {
+ if (h < colorStop4) {
+ if (h > colorStop3) {
+ // colorStop3..colorStop4
+ return averageColor(color3, color4, (h - colorStop3)/(colorStop4 - colorStop3), brightness)
+ } else if (h > colorStop2) {
+ // colorStop2..colorStop3
+ return averageColor(color2, color3, (h - colorStop2)/(colorStop3 - colorStop2), brightness)
+ } else if (h > colorStop1) {
+ // colorStop1..colorStop2
+ return averageColor(color1, color2, (h - colorStop1)/(colorStop2 - colorStop1), brightness)
+ } else if (h > 0) {
+ // 0..colorStop1
+ return averageColor(color0, color1, h/colorStop1, brightness)
+ } else {
+ return adjustColor(color0, brightness)
+ }
+ } else {
+ if (h < colorStop5) {
+ // colorStop4..colorStop5
+ return averageColor(color4, color5, (h - colorStop4)/(colorStop5 - colorStop4), brightness)
+ } else if (h < colorStop6) {
+ // colorStop5..colorStop6
+ return averageColor(color5, color6, (h - colorStop5)/(colorStop6 - colorStop5), brightness)
+ } else if (h < colorStop7) {
+ // colorStop6..colorStop7
+ return averageColor(color6, color7, (h - colorStop6)/(colorStop7 - colorStop6), brightness)
+ } else if (h < 1) {
+ // colorStop7..1
+ return averageColor(color7, color8, (h - colorStop7)/(1 - colorStop7), brightness)
+ } else {
+ return adjustColor(color8, brightness)
+ }
+ }
+ }
+
+ function averageColor(c1,c2,h,v) {
+ return Qt.rgba((c1.r + (c2.r - c1.r) * h) * v,
+ (c1.g + (c2.g - c1.g) * h) * v,
+ (c1.b + (c2.b - c1.b) * h) * v, 1)
+ }
+
+ function adjustColor(c,v) {
+ return Qt.rgba(c.r * v, c.g * v, c.b * v, 1)
+ }
+
+ function getV(c) {
+ return Math.max(c.r, c.g, c.b)
+ }
+
+ function getH(c) {
+ var max = Math.max(c.r, c.g, c.b)
+ var min = Math.min(c.r, c.g, c.b)
+ var chroma = max - min
+ if (chroma === 0) {
+ return 0
+ } else {
+ if (max === c.r) {
+ return hueLast - (c.g - c.b)/chroma/6 * hueRange
+ } else if (max === c.g) {
+ return hueLast - (2 + (c.b - c.r)/chroma)/6 * hueRange
+ } else {
+ return hueLast - (4 + (c.r - c.g)/chroma)/6 * hueRange
+ }
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+
+ width: parent.height
+ height: parent.width
+ anchors.centerIn: parent
+ rotation: -90
+
+ ShaderEffectSource {
+ anchors.fill: parent
+ sourceItem: Rectangle {
+ width: mouseArea.width
+ height: mouseArea.height
+ radius: Theme.paddingSmall
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: color0 }
+ GradientStop { position: colorStop1; color: color1 }
+ GradientStop { position: colorStop2; color: color2 }
+ GradientStop { position: colorStop3; color: color3 }
+ GradientStop { position: colorStop4; color: color4 }
+ GradientStop { position: colorStop5; color: color5 }
+ GradientStop { position: colorStop6; color: color6 }
+ GradientStop { position: colorStop7; color: color7 }
+ GradientStop { position: 1.0; color: color8 }
+ }
+ }
+ }
+ // mouseY/height because we are rotated
+ onClicked: thisItem.tapped(mouseY/height)
+ onPositionChanged: thisItem.tapped(mouseY/height)
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/qml/HarbourColorPickerDialog.qml
^
|
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Dialog {
+ id: thisDialog
+
+ property color color
+ property alias colorModel: grid.model // HarbourColorEditorModel
+
+ // Localizable strings
+ property alias resetColorsMenuText: resetColorsMenuItem.text // "Reset colors"
+ property string acceptText: "Select color"
+ property string addColorAcceptText: "Add color"
+ property string addColorHueSliderText: "Color"
+ property string addColorBrightnessSliderText: "Brightness"
+ property string addColorHexNotationText: "Hex notation"
+
+ forwardNavigation: false
+
+ signal resetColors()
+
+ // Constants used by HarbourColorEditorModel
+ readonly property int itemTypeColor: 0
+ readonly property int itemTypeTrash: 1
+ readonly property int itemTypeAdd: 2
+
+ SilicaGridView {
+ id: grid
+
+ cellWidth: Math.floor(width/cellsPerRow)
+ cellHeight: cellWidth
+ anchors.fill: parent
+
+ VerticalScrollDecorator {}
+
+ PullDownMenu {
+ MenuItem {
+ id: resetColorsMenuItem
+
+ text: "Reset colors"
+ onClicked: thisDialog.resetColors()
+ }
+ }
+
+ property Item dragItem
+ property int pageHeaderHeight
+ readonly property int cellsPerRow: Math.floor(width / Theme.itemSizeHuge)
+
+ header: DialogHeader {
+ dialog: thisDialog
+ acceptText: thisDialog.acceptText
+ spacing: 0
+ Component.onCompleted: grid.pageHeaderHeight = height
+ onHeightChanged: grid.pageHeaderHeight = height
+ }
+
+ delegate: MouseArea {
+ id: colorDelegate
+
+ width: grid.cellWidth
+ height: grid.cellHeight
+
+ drag.target: dragging ? colorItem : null
+ drag.axis: Drag.XandYAxis
+
+ readonly property bool highlighted: (pressed && containsMouse)
+ readonly property bool dragging: grid.dragItem === colorDelegate
+ readonly property int index: model.index
+
+ Rectangle {
+ id: colorItem
+
+ width: grid.cellWidth
+ height: grid.cellHeight
+ color: model.color
+ scale: !colorDelegate.dragging ? 1 : isTrashed ? 0.8 : 1.1
+ opacity: isTrashed ? 0.8 : 1
+ layer.enabled: colorDelegate.highlighted || colorDelegate.dragging || scale > 1
+ layer.effect: HarbourPressEffect { source: colorItem }
+
+ readonly property bool isTrashed: model.itemType === itemTypeTrash
+ property real returnX
+ property real returnY
+ property bool snappingBack
+
+ Behavior on opacity { FadeAnimation { } }
+ Behavior on scale {
+ NumberAnimation {
+ easing.type: Easing.InQuad
+ duration: 150
+ }
+ }
+
+ Image {
+ anchors.centerIn: parent
+ source: opacity ? ("image://theme/graphic-close-app?" + deriveColor(model.color)) : ""
+ sourceSize: Qt.size(Theme.iconSizeLarge, Theme.iconSizeLarge)
+ opacity: (model.itemType === itemTypeTrash) ? 0.8 : 0
+ visible: opacity > 0
+ Behavior on opacity { FadeAnimation { } }
+
+ function deriveColor(color) {
+ var gray = 0.299 * color.r + 0.587 * color.g + 0.114 *color.b
+ var v = (gray > 0.5) ? 0 : 1
+ return Qt.rgba(v, v, v, color.a)
+ }
+ }
+
+ states: [
+ State {
+ name: "dragging"
+ when: colorDelegate.dragging
+ ParentChange {
+ target: colorItem
+ parent: grid
+ x: colorDelegate.mapToItem(grid, 0, 0).x
+ y: colorDelegate.mapToItem(grid, 0, 0).y
+ }
+ },
+ State {
+ name: "snappingBack"
+ when: !colorDelegate.dragging && colorItem.snappingBack
+ ParentChange {
+ target: colorItem
+ parent: grid
+ x: colorItem.returnX
+ y: colorItem.returnY
+ }
+ },
+ State {
+ name: "idle"
+ when: !colorDelegate.dragging && !colorItem.snappingBack
+ ParentChange {
+ target: colorItem
+ parent: colorDelegate
+ x: 0
+ y: 0
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ to: "snappingBack"
+ SequentialAnimation {
+ SmoothedAnimation {
+ properties: "x,y"
+ duration: 150
+ }
+ ScriptAction { script: colorItem.snappingBack = false }
+ }
+ },
+ Transition {
+ to: "idle"
+ ScriptAction { script: colorModel.dragPos = -1 }
+ }
+ ]
+
+ Connections {
+ target: colorDelegate.dragging ? colorItem : null
+ onXChanged: colorItem.updateDragPos()
+ onYChanged: colorItem.scrollAndUpdateDragPos()
+ }
+
+ Connections {
+ target: colorDelegate.dragging ? grid : null
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/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;
+ }"
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/src/HarbourAztecCodeGenerator.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2021 Jolla Ltd.
+ * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -48,22 +48,25 @@
class HarbourAztecCodeGenerator::Task : public HarbourTask {
Q_OBJECT
public:
- Task(QThreadPool* aPool, QString aText);
+ Task(QThreadPool* aPool, QString aText, int aEcLevel);
void performTask() Q_DECL_OVERRIDE;
public:
QString iText;
QString iCode;
+ int iEcLevel;
};
-HarbourAztecCodeGenerator::Task::Task(QThreadPool* aPool, QString aText) :
+HarbourAztecCodeGenerator::Task::Task(QThreadPool* aPool, QString aText,
+ int aEcLevel) :
HarbourTask(aPool),
- iText(aText)
+ iText(aText),
+ iEcLevel(aEcLevel)
{
}
void HarbourAztecCodeGenerator::Task::performTask()
{
- QByteArray bytes(generate(iText));
+ QByteArray bytes(generate(iText, iEcLevel));
if (!bytes.isEmpty()) {
iCode = HarbourBase32::toBase32(bytes);
}
@@ -82,6 +85,10 @@
HarbourAztecCodeGenerator* parentObject() const;
void setText(QString aValue);
+ void setEcLevel(int aValue);
+ void regenerate();
+
+ static int realEcLevel(int aEcLevel);
public Q_SLOTS:
void onTaskDone();
@@ -89,6 +96,7 @@
public:
QThreadPool* iThreadPool;
Task* iTask;
+ int iEcLevel;
QString iText;
QString iCode;
};
@@ -96,7 +104,8 @@
HarbourAztecCodeGenerator::Private::Private(HarbourAztecCodeGenerator* aParent) :
QObject(aParent),
iThreadPool(new QThreadPool(this)),
- iTask(Q_NULLPTR)
+ iTask(Q_NULLPTR),
+ iEcLevel(ECLevelDefault)
{
// Serialize the tasks:
iThreadPool->setMaxThreadCount(1);
@@ -112,19 +121,45 @@
return qobject_cast<HarbourAztecCodeGenerator*>(parent());
}
+int HarbourAztecCodeGenerator::Private::realEcLevel(int aEcLevel)
+{
+ return (aEcLevel == ECLevelDefault) ? AZTEC_CORRECTION_DEFAULT :
+ (aEcLevel < ECLevelLowest) ? ECLevelLowest :
+ (aEcLevel > ECLevelHighest) ? ECLevelHighest :
+ aEcLevel;
+}
+
void HarbourAztecCodeGenerator::Private::setText(QString aText)
{
if (iText != aText) {
iText = aText;
- HarbourAztecCodeGenerator* obj = parentObject();
- const bool wasRunning = (iTask != Q_NULLPTR);
- if (iTask) iTask->release(this);
- iTask = new Task(iThreadPool, aText);
- iTask->submit(this, SLOT(onTaskDone()));
- Q_EMIT obj->textChanged();
- if (!wasRunning) {
- Q_EMIT obj->runningChanged();
+ regenerate();
+ Q_EMIT parentObject()->textChanged();
+ }
+}
+
+void HarbourAztecCodeGenerator::Private::setEcLevel(int aValue)
+{
+ const int level = (aValue == ECLevelDefault) ? ECLevelDefault : realEcLevel(aValue);
+ if (iEcLevel != level) {
+ const int prevRealLevel = realEcLevel(iEcLevel);
+ iEcLevel = level;
+ HDEBUG(level);
+ if (realEcLevel(level) != prevRealLevel) {
+ regenerate();
}
+ Q_EMIT parentObject()->ecLevelChanged();
+ }
+}
+
+void HarbourAztecCodeGenerator::Private::regenerate()
+{
+ const bool wasRunning = (iTask != Q_NULLPTR);
+ if (iTask) iTask->release(this);
+ iTask = new Task(iThreadPool, iText, iEcLevel);
+ iTask->submit(this, SLOT(onTaskDone()));
+ if (!wasRunning) {
+ Q_EMIT parentObject()->runningChanged();
}
}
@@ -169,6 +204,16 @@
iPrivate->setText(aValue);
}
+int HarbourAztecCodeGenerator::ecLevel() const
+{
+ return iPrivate->iEcLevel;
+}
+
+void HarbourAztecCodeGenerator::setEcLevel(int aValue)
+{
+ iPrivate->setEcLevel(aValue);
+}
+
QString HarbourAztecCodeGenerator::code() const
{
return iPrivate->iCode;
@@ -179,12 +224,12 @@
return iPrivate->iTask != Q_NULLPTR;
}
-QByteArray HarbourAztecCodeGenerator::generate(QString aText)
+QByteArray HarbourAztecCodeGenerator::generate(QString aText, int aEcLevel)
{
HDEBUG(aText);
QByteArray in(aText.toUtf8()), out;
AztecSymbol* aztec = aztec_encode_inv(in.constData(), in.size(),
- AZTEC_CORRECTION_DEFAULT);
+ Private::realEcLevel(aEcLevel));
if (aztec) {
const int bytesPerRow = (aztec->size + 7) / 8;
out.reserve(bytesPerRow * aztec->size);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/src/HarbourBase32.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * 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:
*
@@ -46,25 +46,33 @@
// HarbourBase32::Private
// ==========================================================================
-class HarbourBase32::Private {
+class HarbourBase32::Private
+{
public:
- static char nibbleToBase32(int nibble, char a);
- static int base32ToNibble(char a);
+ static char nibbleToBase32(int, char);
+ static int base32ToNibble(char);
};
-inline char HarbourBase32::Private::nibbleToBase32(int nibble, char a)
+inline
+char
+HarbourBase32::Private::nibbleToBase32(
+ int aNibble,
+ char aBaseChar)
{
- return (nibble < 26) ? (a + nibble) : ('2' + (nibble - 26));
+ return (aNibble < 26) ? (aBaseChar + aNibble) : ('2' + (aNibble - 26));
}
-inline int HarbourBase32::Private::base32ToNibble(char c)
+inline
+int
+HarbourBase32::Private::base32ToNibble(
+ char aChar)
{
- if (c >= 'a' && c <= 'z') {
- return c - 'a';
- } else if (c >= 'A' && c <= 'Z') {
- return c - 'A';
- } else if (c >= '2' && c <= '7') {
- return 26 + (c - '2');
+ 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;
}
@@ -74,7 +82,9 @@
// HarbourBase32
// ==========================================================================
-bool HarbourBase32::isValidBase32(QString aBase32)
+bool
+HarbourBase32::isValidBase32(
+ QString aBase32)
{
const int n = aBase32.length();
const QChar* chars = aBase32.constData();
@@ -133,7 +143,9 @@
return !empty;
}
-QByteArray HarbourBase32::fromBase32(QString aBase32)
+QByteArray
+HarbourBase32::fromBase32(
+ const QString aBase32)
{
QByteArray out;
@@ -205,7 +217,10 @@
return out;
}
-QString HarbourBase32::toBase32(QByteArray aBinary, bool aLowerCase)
+QString
+HarbourBase32::toBase32(
+ const QByteArray aBinary,
+ bool aLowerCase)
{
QString str;
const int n = aBinary.size();
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/src/HarbourBase45.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * 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:
*
@@ -39,7 +39,8 @@
// HarbourBase45::Private
// ==========================================================================
-class HarbourBase45::Private {
+class HarbourBase45::Private
+{
public:
enum {
BASE = 45,
@@ -48,7 +49,7 @@
};
static const char mapBase45[BASE];
static const int reverseMapBase45[REVERSE_MAP_SIZE];
- static bool isValidChar(uint x);
+ static bool isValidChar(uint);
};
const char HarbourBase45::Private::mapBase45[HarbourBase45::Private::BASE] = {
@@ -75,16 +76,22 @@
33, 34, 35
};
-inline bool HarbourBase45::Private::isValidChar(uint x)
+inline
+bool
+HarbourBase45::Private::isValidChar(
+ uint aChar)
{
- return (x < Private::REVERSE_MAP_SIZE) && Private::reverseMapBase45[x] >= 0;
+ return (aChar < Private::REVERSE_MAP_SIZE) &&
+ Private::reverseMapBase45[aChar] >= 0;
}
// ==========================================================================
// HarbourBase45::Private
// ==========================================================================
-bool HarbourBase45::isValidBase45(QString aBase45)
+bool
+HarbourBase45::isValidBase45(
+ const QString aBase45)
{
const int len = aBase45.length();
@@ -123,7 +130,9 @@
return false;
}
-QByteArray HarbourBase45::fromBase45(QString aBase45)
+QByteArray
+HarbourBase45::fromBase45(
+ const QString aBase45)
{
QByteArray out;
const int len = aBase45.length();
@@ -175,7 +184,9 @@
return out;
}
-QString HarbourBase45::toBase45(QByteArray aBinary)
+QString
+HarbourBase45::toBase45(
+ const QByteArray aBinary)
{
const uchar* ptr = (uchar*)aBinary.constData();
const int n = aBinary.size();
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/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-qrclip-1.0.11.tar.gz/harbour-lib/src/HarbourColorEditorModel.cpp
^
|
@@ -0,0 +1,298 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourColorEditorModel.h"
+#include "HarbourDebug.h"
+
+// ==========================================================================
+// HarbourColorEditorModel::Private
+// ==========================================================================
+
+class HarbourColorEditorModel::Private
+{
+public:
+ enum ModelRole {
+ ColorRole = Qt::UserRole,
+ ItemTypeRole
+ };
+
+ Private();
+
+ bool resetDragPos();
+ QStringList getColors() const;
+ QList<QColor> makeColors(const QStringList& aColors, bool* aChanged) const;
+ QVariant data(int aRow, ModelRole aRole) const;
+
+public:
+ int iDragPos;
+ int iDragStartPos;
+ QList<QColor> iColors;
+ const QColor iAddColor;
+};
+
+HarbourColorEditorModel::Private::Private() :
+ iDragPos(-1),
+ iDragStartPos(-1),
+ iAddColor(0, 0, 0, 0)
+{
+}
+
+bool HarbourColorEditorModel::Private::resetDragPos()
+{
+ if (iDragPos >= 0) {
+ iDragPos = -1;
+ iDragStartPos = -1;
+ return true;
+ } else {
+ return false;
+ }
+}
+
+QStringList HarbourColorEditorModel::Private::getColors() const
+{
+ const int n = iColors.count();
+ QStringList colors;
+ colors.reserve(n);
+ for (int i = 0; i < n; i++) {
+ colors.append(iColors.at(i).name());
+ }
+ return colors;
+}
+
+QList<QColor> HarbourColorEditorModel::Private::makeColors(const QStringList& aColors, bool* aChanged) const
+{
+ const int n = aColors.count();
+ *aChanged = iColors.count() != n;
+ QList<QColor> newColors;
+ newColors.reserve(n);
+ for (int i = 0; i < n; i++) {
+ const QColor c(aColors.at(i));
+ newColors.append(c);
+ if (!*aChanged && iColors.at(i) != c) {
+ *aChanged = true;
+ }
+ }
+ return newColors;
+}
+
+QVariant HarbourColorEditorModel::Private::data(int aRow, ModelRole aRole) const
+{
+ const int n = iColors.count();
+ if (aRow >= 0 && aRow <= n) {
+ switch (aRole) {
+ case ColorRole:
+ if (iDragPos >= 0) {
+ if (aRow == iDragPos) {
+ // This includes the item dragged outside
+ return iColors.at(iDragStartPos);
+ } else {
+ if (iDragPos == n && aRow == (n - 1)) {
+ // When item is dragged outside, it becomes
+ // the last one and shifts the "add" item.
+ return iAddColor;
+ } else if (aRow >= iDragStartPos && aRow < iDragPos) {
+ return iColors.at(aRow + 1);
+ } else if (aRow > iDragPos && aRow <= iDragStartPos) {
+ return iColors.at(aRow - 1);
+ }
+ }
+ }
+ return (aRow == n) ? iAddColor : iColors.at(aRow);
+ case ItemTypeRole:
+ if (iDragPos == n) {
+ // Item is dragged outside
+ return (aRow == n) ? TrashedItem :
+ (aRow == (n - 1)) ? AddItem : ColorItem;
+ } else {
+ return (aRow == n) ? AddItem : ColorItem;
+ }
+ }
+ }
+ return QVariant();
+}
+
+// ==========================================================================
+// HarbourColorEditorModel::Private
+// ==========================================================================
+
+HarbourColorEditorModel::HarbourColorEditorModel(QObject* aParent) :
+ QAbstractListModel(aParent),
+ iPrivate(new Private)
+{
+}
+
+QHash<int,QByteArray> HarbourColorEditorModel::roleNames() const
+{
+ QHash<int,QByteArray> roles;
+ roles.insert(Private::ColorRole, "color");
+ roles.insert(Private::ItemTypeRole, "itemType");
+ return roles;
+}
+
+int HarbourColorEditorModel::rowCount(const QModelIndex&) const
+{
+ return iPrivate->iColors.count() + 1;
+}
+
+QVariant HarbourColorEditorModel::data(const QModelIndex& aIndex, int aRole) const
+{
+ return iPrivate->data(aIndex.row(), (Private::ModelRole)aRole);
+}
+
+QStringList HarbourColorEditorModel::getColors() const
+{
+ return iPrivate->getColors();
+}
+
+void HarbourColorEditorModel::setColors(QStringList aColors)
+{
+ bool changed;
+ const QList<QColor> prevColors(iPrivate->iColors);
+ const QList<QColor> newColors(iPrivate->makeColors(aColors, &changed));
+ if (changed) {
+ const int prevCount = prevColors.count();
+ const int newCount = newColors.count();
+ const QVector<int> colorRole(1, Private::ColorRole);
+ if (newCount < prevCount) {
+ beginRemoveRows(QModelIndex(), newCount + 1, prevCount);
+ iPrivate->iColors = newColors;
+ endRemoveRows();
+ } else if (newCount > prevCount) {
+ beginInsertRows(QModelIndex(), prevCount + 1, newCount);
+ iPrivate->iColors = newColors;
+ endInsertRows();
+ } else {
+ iPrivate->iColors = newColors;
+ }
+ // Change the colors
+ int rangeStart = -1;
+ const int n = qMin(prevCount, newCount);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/src/HarbourPluginLoader.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2017-2020 Jolla Ltd.
- * Copyright (C) 2017-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2017-2021 Jolla Ltd.
+ * Copyright (C) 2017-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -78,6 +78,24 @@
// sym,ret,name,args
#define QMLTYPE_FUNCTIONS(f) \
+ f("_ZN12QQmlMetaType7qmlTypeERK7QStringii", \
+ QQmlType*, qmlType, (QString const&, int, int)) \
+ f("_ZNK8QQmlType23propertyValueSourceCastEv", \
+ int, propertyValueSourceCast, (QQmlType*)) \
+ f("_ZNK8QQmlType10createSizeEv", \
+ int, createSize, (QQmlType*)) \
+ f("_ZNK8QQmlType10metaObjectEv", \
+ const QMetaObject*, metaObject, (QQmlType*)) \
+ f("_ZNK8QQmlType16parserStatusCastEv", \
+ int, parserStatusCast, (QQmlType*)) \
+ f("_ZNK8QQmlType28propertyValueInterceptorCastEv", \
+ int, propertyValueInterceptorCast, (QQmlType*)) \
+ f("_ZNK8QQmlType6typeIdEv", \
+ int, typeId, (QQmlType*)) \
+ f("_ZNK8QQmlType14createFunctionEv", \
+ QQmlType::CreateFunc, createFunction, (QQmlType*)) \
+ f("_ZNK8QQmlType11qListTypeIdEv", \
+ int, qListTypeId, (QQmlType*)) \
f("_ZNK8QQmlType26attachedPropertiesFunctionEv", \
QQmlAttachedPropertiesFunc, AttachedPropertiesFunctionProc,(QQmlType*)) \
f("_ZNK8QQmlType22attachedPropertiesTypeEv", \
@@ -100,8 +118,8 @@
int parserStatusCast() const;
int propertyValueSourceCast() const;
int propertyValueInterceptorCast() const;
- QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const;
- const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const;
+ // attachedPropertiesFunction
+ // attachedPropertiesType
};
// PRIVATE QT API!
@@ -219,8 +237,10 @@
HarbourPluginLoader::Private::qmlType(
QString aName)
{
- QString fullName(iModule + '/' + aName);
- QQmlType* type = QQmlMetaType::qmlType(fullName, iMajor, iMinor);
+ const QString fullName(iModule + '/' + aName);
+ QQmlType* type = gLibQt5Qml.iSym.fn.qmlType ?
+ gLibQt5Qml.iSym.fn.qmlType(fullName, iMajor, iMinor) :
+ Q_NULLPTR;
if (!type) {
HWARN("Failed to load" << fullName);
}
@@ -259,7 +279,15 @@
int aMajor,
int aMinor)
{
- if (aType && iEngine) {
+ if (aType && iEngine &&
+ gLibQt5Qml.iSym.fn.typeId &&
+ gLibQt5Qml.iSym.fn.qListTypeId &&
+ gLibQt5Qml.iSym.fn.createSize &&
+ gLibQt5Qml.iSym.fn.createFunction &&
+ gLibQt5Qml.iSym.fn.metaObject &&
+ gLibQt5Qml.iSym.fn.parserStatusCast &&
+ gLibQt5Qml.iSym.fn.propertyValueSourceCast &&
+ gLibQt5Qml.iSym.fn.propertyValueInterceptorCast) {
// Get around the ABI break in Qt 5.6
QQmlAttachedPropertiesFunc attachedPropertiesFunction =
gLibQt5Qml.iSym.fn.AttachedPropertiesFunctionProc ?
@@ -275,21 +303,21 @@
NULL;
QQmlPrivate::RegisterType type = {
0, // int version;
- aType->typeId(), // int typeId;
- aType->qListTypeId(), // int listId;
- aType->createSize(), // int objectSize;
- aType->createFunction(), // void (*create)(void *);
+ gLibQt5Qml.iSym.fn.typeId(aType), // int typeId;
+ gLibQt5Qml.iSym.fn.qListTypeId(aType), // int listId;
+ gLibQt5Qml.iSym.fn.createSize(aType), // int objectSize;
+ gLibQt5Qml.iSym.fn.createFunction(aType), // void (*create)(void *);
QString(), // QString noCreationReason;
aModule, // const char *uri;
aMajor, // int versionMajor;
aMinor, // int versionMinor;
aQmlName, // const char *elementName;
- aType->metaObject(), // const QMetaObject *metaObject;
+ gLibQt5Qml.iSym.fn.metaObject(aType), // const QMetaObject *metaObject;
attachedPropertiesFunction,
attachedPropertiesMetaObject,
- aType->parserStatusCast(), // int parserStatusCast;
- aType->propertyValueSourceCast(), // int valueSourceCast;
- aType->propertyValueInterceptorCast(), // int valueInterceptorCast;
+ gLibQt5Qml.iSym.fn.parserStatusCast(aType), // int parserStatusCast;
+ gLibQt5Qml.iSym.fn.propertyValueSourceCast(aType), // int valueSourceCast;
+ gLibQt5Qml.iSym.fn.propertyValueInterceptorCast(aType), // int valueInterceptorCast;
Q_NULLPTR, // QObject *(*extensionObjectCreate)(QObject *);
Q_NULLPTR, // const QMetaObject *extensionMetaObject;
Q_NULLPTR, // QQmlCustomParser *customParser;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/src/HarbourProcessState.cpp
^
|
@@ -35,6 +35,8 @@
#include "HarbourDebug.h"
#include <unistd.h>
+#include <grp.h>
+#include <sys/types.h>
HarbourProcessState::HarbourProcessState(QObject* aParent) :
QObject(aParent)
@@ -56,13 +58,42 @@
// We could additionally check that /proc contains only our and
// parent pids, if ppid check becomes not reliable enough.
if (processJailed < 0) {
- if (getppid() == 1) {
- HWARN("We are jailed!");
- processJailed = 1;
- } else{
- HDEBUG("Cool, we are free!");
- 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-qrclip-1.0.11.tar.gz/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;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/src/HarbourSelectionListModel.cpp
^
|
@@ -1,6 +1,6 @@
-/*
+/*
* Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -41,20 +41,47 @@
// HarbourSelectionListModel::Private
// ==========================================================================
-class HarbourSelectionListModel::Private : public QObject {
+// 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:
- Private(HarbourSelectionListModel* aParent);
+ 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();
- static int binaryFind(const QList<int> aList, int aValue);
- bool isSelectionRole(int aRole) const;
- bool isSelectedRow(int aRow) const;
- int findSelectedRow(int aRow) const;
- void selectRow(int aRow);
- void unselectRow(int aRow);
- void selectionChangedAt(int aRow);
+ 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();
@@ -63,13 +90,20 @@
void onCountChanged();
public:
+ SignalMask iQueuedSignals;
+ Signal iFirstQueuedSignal;
QList<int> iSelectedRows;
- QVector<int> iSelectedRole;
+ QList<int> iNonSelectableRows;
+ QList<int> iNormalizedNonSelectableRows;
+ QVector<int> iSelectedRole; // Passed to dataChanged as an argument
+ int iLastKnownSelectableCount;
int iLastKnownCount;
};
-HarbourSelectionListModel::Private::Private(HarbourSelectionListModel* aParent) :
+HarbourSelectionListModel::Private::Private(
+ HarbourSelectionListModel* aParent) :
QObject(aParent),
+ iLastKnownSelectableCount(0),
iLastKnownCount(0)
{
connect(aParent, SIGNAL(modelReset()), SLOT(onCountChanged()));
@@ -77,22 +111,10 @@
connect(aParent, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(onCountChanged()));
}
-inline HarbourSelectionListModel* HarbourSelectionListModel::Private::parentModel()
-{
- return qobject_cast<HarbourSelectionListModel*>(parent());
-}
-
-inline bool HarbourSelectionListModel::Private::isSelectionRole(int aRole) const
-{
- return !iSelectedRole.isEmpty() && iSelectedRole.first() == aRole;
-}
-
-inline bool HarbourSelectionListModel::Private::isSelectedRow(int aRow) const
-{
- return findSelectedRow(aRow) >= 0;
-}
-
-int HarbourSelectionListModel::Private::binaryFind(const QList<int> aList, int aValue)
+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
@@ -117,34 +139,131 @@
return -(low + 1);
}
-int HarbourSelectionListModel::Private::findSelectedRow(int aRow) const
+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
+bool
+HarbourSelectionListModel::Private::isSelectedRow(
+ int aRow) const
+{
+ return findSelectedRow(aRow) >= 0;
+}
+
+inline
+bool
+HarbourSelectionListModel::Private::isSelectableRow(
+ int aRow) const
+{
+ return binaryFind(iNonSelectableRows, aRow) < 0;
+}
+
+int
+HarbourSelectionListModel::Private::findSelectedRow(
+ int aRow) const
{
return binaryFind(iSelectedRows, aRow);
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/src/HarbourSystemInfo.cpp
^
|
@@ -44,6 +44,7 @@
#include <QFile>
#include <QTextStream>
+#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
@@ -255,7 +256,7 @@
argv[5] = NULL;
while ((dup2(fds[1], STDOUT_FILENO) == -1) && (errno == EINTR));
execvp(argv[0], (char**)argv);
- exit(1);
+ abort();
}
close(fds[1]);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/src/HarbourTheme.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 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:
*
@@ -31,9 +31,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "HarbourTheme.h"
-#include "HarbourSystem.h"
#include "HarbourDebug.h"
+#include "HarbourSystem.h"
+#include "HarbourTheme.h"
+#include "HarbourUtil.h"
#include <QQmlEngine>
@@ -212,17 +213,12 @@
QColor HarbourTheme::invertedPrimaryColor() const
{
- return invertedColor(Private::primaryColor());
+ return HarbourUtil::invertedColor(Private::primaryColor());
}
QColor HarbourTheme::invertedColor(const QColor& aColor)
{
- if (aColor.isValid()) {
- const QRgb rgba = aColor.rgba();
- return QColor(((~(rgba & RGB_MASK)) & RGB_MASK) | (rgba & (~RGB_MASK)));
- } else {
- return aColor;
- }
+ return HarbourUtil::invertedColor(aColor);
}
qreal HarbourTheme::colorDifference(const QColor& aColor1, const QColor& aColor2)
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/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-qrclip-1.0.11.tar.gz/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) \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/test/Makefile
^
|
@@ -4,3 +4,5 @@
%:
@$(MAKE) -C TestHarbourBase32 $*
@$(MAKE) -C TestHarbourBase45 $*
+ @$(MAKE) -C TestHarbourProtoBuf $*
+ @$(MAKE) -C TestHarbourUtil $*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/test/Makefile.common
^
|
@@ -31,6 +31,8 @@
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
@@ -44,7 +46,7 @@
LD = $(CC)
MOC = qtchooser -run-tool=moc -qt=5
WARNINGS = -Wall
-INCLUDES = -I$(BUILD_DIR) -I$(HARBOUR_DIR)/include
+INCLUDES = -I$(BUILD_DIR) -I$(HARBOUR_INCLUDE_DIR)
BASE_FLAGS = -fPIC
BASE_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS)
BASE_CFLAGS = $(BASE_FLAGS) $(CFLAGS)
@@ -84,6 +86,9 @@
$(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
@@ -96,6 +101,7 @@
endif
endif
+$(GEN_FILES): | $(BUILD_DIR)
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR)
@@ -139,10 +145,10 @@
$(COVERAGE_BUILD_DIR):
mkdir -p $@
-$(BUILD_DIR)/moc_%.cpp : $(APP_DIR)/%.h
+$(BUILD_DIR)/moc_%.cpp : $(HARBOUR_INCLUDE_DIR)/%.h
$(MOC) $< -o $@
-$(BUILD_DIR)/%.moc : $(APP_DIR)/%.cpp
+$(BUILD_DIR)/%.moc : $(HARBOUR_SRC_DIR)/%.cpp
$(MOC) $< -o $@
$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
@@ -163,31 +169,22 @@
$(COVERAGE_BUILD_DIR)/moc_h_%.o : $(BUILD_DIR)/moc_%.cpp $(BUILD_DIR)
$(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(DEBUG_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+$(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_DIR)/%.cpp $(BUILD_DIR)/%.moc
+$(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_DIR)/%.cpp $(BUILD_DIR)/%.moc
+$(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)/app_%.o : $(APP_DIR)/%.cpp
+$(DEBUG_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(RELEASE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+$(RELEASE_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(COVERAGE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
- $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(COVERAGE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
+$(COVERAGE_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
$(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
$(DEBUG_EXE): $(DEBUG_OBJS)
|
[-]
[+]
|
Added |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/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-qrclip-1.0.11.tar.gz/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-qrclip-1.0.11.tar.gz/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-qrclip-1.0.11.tar.gz/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:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-lib/test/coverage/run
^
|
@@ -5,7 +5,9 @@
TESTS="\
TestHarbourBase32 \
-TestHarbourBase45"
+TestHarbourBase45 \
+TestHarbourProtoBuf \
+TestHarbourUtil"
function err() {
echo "*** ERROR!" $1
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/harbour-qrclip.desktop
^
|
@@ -4,3 +4,6 @@
X-Nemo-Application-Type=silica-qt5
Icon=harbour-qrclip
Exec=harbour-qrclip
+
+[X-Sailjail]
+Permissions=UserDirs
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-qrclip-1.0.11.tar.gz/qml/MainPage.qml
^
|
@@ -137,7 +137,8 @@
Label {
id: textLabel
- width: parent.width
+ x: isPortrait ? 2 * Theme.horizontalPageMargin : 0
+ width: parent.width - (isPortrait ? 4 : 1) * Theme.horizontalPageMargin
horizontalAlignment: Text.AlignLeft
wrapMode: Text.Wrap
text: haveQrCode ? QrCodeModel.text : ""
@@ -189,9 +190,9 @@
changes: [
PropertyChanges {
target: textItem
- x: 2 * Theme.horizontalPageMargin
+ x: 0
y: page.height - spaceForText
- width: page.width - 2 * x
+ width: page.width
height: maxSpaceForText
}
]
|