From 0527235dbbcd99df9c6c43e46022f3d1d5dcfceb Mon Sep 17 00:00:00 2001 From: EndrII Date: Thu, 13 Mar 2025 12:05:09 +0100 Subject: [PATCH 1/8] added icon overlay --- .../src/ViewSolutionsModule/ActivityPage.qml | 2 +- .../ViewSolutionsModule/ActivityProcessor.qml | 3 ++ .../src/ViewSolutionsModule/IconOverlay.qml | 29 +++++++++++++++++++ ViewSolutions/src/ViewSolutionsModule/qmldir | 1 + ViewSolutions/src/ViewSolutionsResources.qrc | 1 + 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 ViewSolutions/src/ViewSolutionsModule/IconOverlay.qml diff --git a/ViewSolutions/src/ViewSolutionsModule/ActivityPage.qml b/ViewSolutions/src/ViewSolutionsModule/ActivityPage.qml index b6f1c42..31035b7 100644 --- a/ViewSolutions/src/ViewSolutionsModule/ActivityPage.qml +++ b/ViewSolutions/src/ViewSolutionsModule/ActivityPage.qml @@ -18,7 +18,7 @@ Control { // shows close button on the ActivityProcessor header property bool closeButton: true // attach to this property link to ActivityProcessor (if is it not to abble atomaticaly) - property var activityProcessorLink: null + property var activityProcessorLink: (parent && parent.link)? parent.link: null // emit this signal when you finish work on this page. The ActivityProcessor will inoke pop method. signal finish(); diff --git a/ViewSolutions/src/ViewSolutionsModule/ActivityProcessor.qml b/ViewSolutions/src/ViewSolutionsModule/ActivityProcessor.qml index 00364c7..f4c22fe 100644 --- a/ViewSolutions/src/ViewSolutionsModule/ActivityProcessor.qml +++ b/ViewSolutions/src/ViewSolutionsModule/ActivityProcessor.qml @@ -50,6 +50,8 @@ Page { contentItem: StackView { id: stackView + property var link : root + Connections { target: (stackView.currentItem && stackView.currentItem.finish)? stackView.currentItem : null @@ -194,6 +196,7 @@ Page { && typeof(callback) === "function") { activity.activityCallBack = callback; } + return activity; } else if (component.status === Component.Error) { diff --git a/ViewSolutions/src/ViewSolutionsModule/IconOverlay.qml b/ViewSolutions/src/ViewSolutionsModule/IconOverlay.qml new file mode 100644 index 0000000..75f8a2c --- /dev/null +++ b/ViewSolutions/src/ViewSolutionsModule/IconOverlay.qml @@ -0,0 +1,29 @@ +//# +//# Copyright (C) 2025-2025 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +import QtQuick +import QtQuick.Controls +import QtQuick.Effects + +Control { + id: root + property alias source: image.source + property alias color: effect.colorizationColor + property alias colorization: effect.colorization + + contentItem: Image { + id: image + + MultiEffect { + id: effect + anchors.fill: image + colorization: 1 + + } + } +} diff --git a/ViewSolutions/src/ViewSolutionsModule/qmldir b/ViewSolutions/src/ViewSolutionsModule/qmldir index 80985fd..e492236 100644 --- a/ViewSolutions/src/ViewSolutionsModule/qmldir +++ b/ViewSolutions/src/ViewSolutionsModule/qmldir @@ -8,3 +8,4 @@ ViewPortPage 1.0 ViewPortPage.qml ViewPortGradientPage 1.0 ViewPortGradientPage.qml ViewPortStaticPage 1.0 ViewPortStaticPage.qml ViewPortStaticGradientPage 1.0 ViewPortStaticGradientPage.qml +IconOverlay 1.0 IconOverlay.qml diff --git a/ViewSolutions/src/ViewSolutionsResources.qrc b/ViewSolutions/src/ViewSolutionsResources.qrc index 2b80125..fdf06fc 100644 --- a/ViewSolutions/src/ViewSolutionsResources.qrc +++ b/ViewSolutions/src/ViewSolutionsResources.qrc @@ -11,6 +11,7 @@ ViewSolutionsModule/ActivityProcessorHeader.qml ViewSolutionsModule/ActivityProcessor.qml ViewSolutionsModule/ActivityPage.qml + ViewSolutionsModule/IconOverlay.qml From d0eb5b9c4deb93fc30fb49a1e1f51bf4ea60685e Mon Sep 17 00:00:00 2001 From: EndrII Date: Mon, 17 Mar 2025 13:15:36 +0100 Subject: [PATCH 2/8] update header --- ViewSolutions/src/ViewSolutionsModule/ActivityPage.qml | 4 ++++ ViewSolutions/src/ViewSolutionsModule/ActivityProcessor.qml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ViewSolutions/src/ViewSolutionsModule/ActivityPage.qml b/ViewSolutions/src/ViewSolutionsModule/ActivityPage.qml index 31035b7..846142d 100644 --- a/ViewSolutions/src/ViewSolutionsModule/ActivityPage.qml +++ b/ViewSolutions/src/ViewSolutionsModule/ActivityPage.qml @@ -15,6 +15,10 @@ Control { // shows the back button with text property bool buttonBack: true + // shows the header of the ActivityProcessor (if is it not to abble atomaticaly) + property bool headerVisible: true + + // shows close button on the ActivityProcessor header property bool closeButton: true // attach to this property link to ActivityProcessor (if is it not to abble atomaticaly) diff --git a/ViewSolutions/src/ViewSolutionsModule/ActivityProcessor.qml b/ViewSolutions/src/ViewSolutionsModule/ActivityProcessor.qml index f4c22fe..2b2793c 100644 --- a/ViewSolutions/src/ViewSolutionsModule/ActivityProcessor.qml +++ b/ViewSolutions/src/ViewSolutionsModule/ActivityProcessor.qml @@ -28,7 +28,7 @@ Page { header: ActivityProcessorHeader { id: headerView - visible: root.enableHeader + visible: root.enableHeader && stackView.currentItem && stackView.currentItem.headerVisible title: { if (root.enableHeader && stackView.currentItem && stackView.currentItem.title) { return stackView.currentItem.title From e549d7eab13591df94b1e05d85433388e2809f30 Mon Sep 17 00:00:00 2001 From: EndrII Date: Tue, 18 Mar 2025 12:37:31 +0100 Subject: [PATCH 3/8] simple fix of cards --- ViewSolutions/src/ViewSolutionsModule/ImageView.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ViewSolutions/src/ViewSolutionsModule/ImageView.qml b/ViewSolutions/src/ViewSolutionsModule/ImageView.qml index 5613063..d70a719 100644 --- a/ViewSolutions/src/ViewSolutionsModule/ImageView.qml +++ b/ViewSolutions/src/ViewSolutionsModule/ImageView.qml @@ -114,7 +114,7 @@ AbstractButton { Layout.fillWidth: true Layout.fillHeight: true - source: Image { + source: Image { id: sourceImg source: root.source @@ -151,6 +151,7 @@ AbstractButton { Layout.fillWidth: true color: root.textColor font: root.font + wrapMode: Text.WordWrap horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter From 7298396386871db583e7b58b201d137d919f3ded Mon Sep 17 00:00:00 2001 From: EndrII Date: Wed, 19 Mar 2025 13:19:35 +0100 Subject: [PATCH 4/8] draging delegate --- .../src/ViewSolutionsModule/DragDelegate.qml | 70 +++++++++++++++++++ ViewSolutions/src/ViewSolutionsModule/qmldir | 1 + ViewSolutions/src/ViewSolutionsResources.qrc | 1 + 3 files changed, 72 insertions(+) create mode 100644 ViewSolutions/src/ViewSolutionsModule/DragDelegate.qml diff --git a/ViewSolutions/src/ViewSolutionsModule/DragDelegate.qml b/ViewSolutions/src/ViewSolutionsModule/DragDelegate.qml new file mode 100644 index 0000000..062b14d --- /dev/null +++ b/ViewSolutions/src/ViewSolutionsModule/DragDelegate.qml @@ -0,0 +1,70 @@ +//# +//# Copyright (C) 2025-2025 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + + Control { + id: root + + /// The content this is content data of the draging + property alias dragingContent: data.contentItem + property var mimeData: null + + /// The draging area this is the area where the draging will be dropped + required property var dragingArea + + signal draged() + signal clicked(var mouse) + + contentItem: Control { + id: delegate + + Drag.active: activeDragArea.drag.active + Drag.hotSpot.x: activeDragArea.width / 2 + Drag.hotSpot.y: activeDragArea.height / 2 + Drag.source: activeDragArea + Drag.mimeData: root.mimeData + + states: [ + State { + when: delegate.Drag.active + ParentChange { + target: delegate + parent: dragingArea + } + } + ] + + MouseArea { + id: activeDragArea + anchors.fill: parent + drag.target: parent + + drag.onActiveChanged: { + if (drag.active) { + root.draged() + dragingArea.opacity *= 0.5 + } else { + dragingArea.opacity *= 2 + } + parent.Drag.drop(); + } + onClicked: root.clicked(mouse) + } + + implicitHeight: data.implicitHeight + implicitWidth: data.implicitWidth + Control { + id: data + anchors.fill: parent + + } + } +} diff --git a/ViewSolutions/src/ViewSolutionsModule/qmldir b/ViewSolutions/src/ViewSolutionsModule/qmldir index e492236..5c7a4c3 100644 --- a/ViewSolutions/src/ViewSolutionsModule/qmldir +++ b/ViewSolutions/src/ViewSolutionsModule/qmldir @@ -9,3 +9,4 @@ ViewPortGradientPage 1.0 ViewPortGradientPage.qml ViewPortStaticPage 1.0 ViewPortStaticPage.qml ViewPortStaticGradientPage 1.0 ViewPortStaticGradientPage.qml IconOverlay 1.0 IconOverlay.qml +DragDelegate 1.0 DragDelegate.qml diff --git a/ViewSolutions/src/ViewSolutionsResources.qrc b/ViewSolutions/src/ViewSolutionsResources.qrc index fdf06fc..07b78c2 100644 --- a/ViewSolutions/src/ViewSolutionsResources.qrc +++ b/ViewSolutions/src/ViewSolutionsResources.qrc @@ -12,6 +12,7 @@ ViewSolutionsModule/ActivityProcessor.qml ViewSolutionsModule/ActivityPage.qml ViewSolutionsModule/IconOverlay.qml + ViewSolutionsModule/DragDelegate.qml From 596147a6bff6d11b012fe7adec53841577c4857a Mon Sep 17 00:00:00 2001 From: EndrII Date: Mon, 24 Mar 2025 12:24:23 +0100 Subject: [PATCH 5/8] update viewsolutions --- .../src/ViewSolutionsModule/ImageView.qml | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/ViewSolutions/src/ViewSolutionsModule/ImageView.qml b/ViewSolutions/src/ViewSolutionsModule/ImageView.qml index d70a719..0764cf7 100644 --- a/ViewSolutions/src/ViewSolutionsModule/ImageView.qml +++ b/ViewSolutions/src/ViewSolutionsModule/ImageView.qml @@ -26,6 +26,7 @@ AbstractButton { property color backgroundColor: Material.background property color selectedColor: Material.accent property color hoverColor: Material.accent + property alias contentData: content.contentItem Connections { target: sourceImg @@ -50,7 +51,6 @@ AbstractButton { contentItem: Control { id: privateData property int rootMinSize: Math.min(root.height, root.width) - bottomPadding : 8 property real rx : 0 property real ry : 0 property real rz : 0 @@ -106,8 +106,7 @@ AbstractButton { } contentItem: ColumnLayout { - spacing: 8 - + spacing: 0 MultiEffect { id: imgEffect @@ -144,18 +143,24 @@ AbstractButton { } } - - Label { - text: root.text - visible: text.length + Control { + id: content Layout.fillWidth: true - color: root.textColor - font: root.font - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter + padding: 8 + + contentItem: Label { + text: root.text + visible: text.length + Layout.fillWidth: true + color: root.textColor + font: root.font + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } } + } transform: [ From 5589106a442847403ad053c4db2ad0550a7c528a Mon Sep 17 00:00:00 2001 From: EndrII Date: Wed, 16 Apr 2025 11:12:28 +0200 Subject: [PATCH 6/8] added avatar generator model --- ViewSolutions/src/avatargenerator.cpp | 73 +++++++++++++++++++++++++++ ViewSolutions/src/avatargenerator.h | 42 +++++++++++++++ ViewSolutions/src/qmlcolorpicker.cpp | 6 +-- ViewSolutions/src/viewsolutions.cpp | 2 - 4 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 ViewSolutions/src/avatargenerator.cpp create mode 100644 ViewSolutions/src/avatargenerator.h diff --git a/ViewSolutions/src/avatargenerator.cpp b/ViewSolutions/src/avatargenerator.cpp new file mode 100644 index 0000000..21c8680 --- /dev/null +++ b/ViewSolutions/src/avatargenerator.cpp @@ -0,0 +1,73 @@ +//# +//# Copyright (C) 2025-2025 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "avatargenerator.h" + +#include +#include + +namespace ViewSolutions { + +AvatarGenerator::AvatarGenerator() {} + +bool AvatarGenerator::generateDefaultAvatar(QImage &result, + const QString &nickName, + const QFont &font, + const QColor &color) const { + + const int size = std::max(std::max(result.width(), result.height()), 256); + + + QBrush solidBrush = QBrush(color); + if (!color.isValid()) { + auto mainColor = QColor(qHash(nickName + "red") % 250, + qHash(nickName + "green") % 250, + qHash(nickName + "blue") % 250); + + // radnom dark + auto secondColor = QColor(qHash(nickName + "red dark") % 50, + qHash(nickName + "green dark") % 50, + qHash(nickName + "blue dark") % 50); + + QLinearGradient g(0.0, 0.0, 0.0, size); + g.setColorAt(0, mainColor); + g.setColorAt(1, secondColor); + + solidBrush = QBrush(g); + } + + QImage image(size, size, QImage::Format_ARGB32); + image.fill(Qt::transparent); + + QPainter painter(&image); + painter.setRenderHint(QPainter::Antialiasing); + + + painter.setBrush(solidBrush); + painter.setPen(Qt::NoPen); + painter.drawEllipse(0, 0, size, size); + + QString firstLetter = nickName.left(1).toUpper(); + QFont currentFont = font; + currentFont.setPixelSize( size / 2); + painter.setPen(QColor(Qt::white)); + QFontMetrics metrics(currentFont); + painter.setFont(currentFont); + + int textWidth = metrics.horizontalAdvance(firstLetter); + int textHeight = metrics.height(); + int x = (size - textWidth) / 2; + int y = (size + textHeight / 2) / 1.9; + painter.drawText(x, y, firstLetter); + + result = image; + + return true; +} + +} diff --git a/ViewSolutions/src/avatargenerator.h b/ViewSolutions/src/avatargenerator.h new file mode 100644 index 0000000..6b39dda --- /dev/null +++ b/ViewSolutions/src/avatargenerator.h @@ -0,0 +1,42 @@ +//# +//# Copyright (C) 2025-2025 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + + +#ifndef AVATARGENERATOR_H +#define AVATARGENERATOR_H + +#include + +namespace ViewSolutions { + +/** + * @brief The AvatarGenerator class contains function for create default users avatars. + * + */ +class AvatarGenerator +{ +public: + AvatarGenerator(); + + /** + * @brief generateDefaultAvatar generates default avatar. + * This function generate Ellipse with 2 first letters of user name. + * Size of image depends of result image size, but if it smaller the 256 px will use 256 px. + * @param result - result image + * @param nickName - user name + * @param font - font for text + * @param color - color of text - if not sets by default will be used random color + */ + bool generateDefaultAvatar(QImage &result, const QString &nickName, + const QFont& font, const QColor& color = {}) const; + + +}; + +} +#endif // AVATARGENERATOR_H diff --git a/ViewSolutions/src/qmlcolorpicker.cpp b/ViewSolutions/src/qmlcolorpicker.cpp index 09b53a4..06bbe5b 100644 --- a/ViewSolutions/src/qmlcolorpicker.cpp +++ b/ViewSolutions/src/qmlcolorpicker.cpp @@ -47,15 +47,15 @@ QColor QMLColorPicker::pick(const QString &img) const { return responce; } - if (provider->imageType() & QQmlImageProviderBase::Texture) { + if (provider->imageType() == QQmlImageProviderBase::Texture) { return ColorPicker::pick(provider->requestTexture(url, nullptr, {})->image()); } - if (provider->imageType() & QQmlImageProviderBase::Pixmap) { + if (provider->imageType() == QQmlImageProviderBase::Pixmap) { return ColorPicker::pick(provider->requestPixmap(url, nullptr, {}).toImage()); } - if (provider->imageType() & QQmlImageProviderBase::Image) { + if (provider->imageType() == QQmlImageProviderBase::Image) { return ColorPicker::pick(provider->requestImage(url, nullptr, {})); } diff --git a/ViewSolutions/src/viewsolutions.cpp b/ViewSolutions/src/viewsolutions.cpp index 7c848dc..eb8da8c 100644 --- a/ViewSolutions/src/viewsolutions.cpp +++ b/ViewSolutions/src/viewsolutions.cpp @@ -43,8 +43,6 @@ QSharedPointer init(QQmlApplicationEngine *engine) { qRegisterMetaType("VariantListModel"); - - return storage; } } From c0a566861a3e579a62cc5455dd70604c8caf1fed Mon Sep 17 00:00:00 2001 From: EndrII Date: Thu, 17 Apr 2025 13:09:51 +0200 Subject: [PATCH 7/8] update image --- ViewSolutions/src/ViewSolutionsModule/ImageView.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ViewSolutions/src/ViewSolutionsModule/ImageView.qml b/ViewSolutions/src/ViewSolutionsModule/ImageView.qml index 0764cf7..b397d32 100644 --- a/ViewSolutions/src/ViewSolutionsModule/ImageView.qml +++ b/ViewSolutions/src/ViewSolutionsModule/ImageView.qml @@ -22,7 +22,7 @@ AbstractButton { property string toolTip: "" property color textColor: Material.foreground - + property alias textVisible: content.visible property color backgroundColor: Material.background property color selectedColor: Material.accent property color hoverColor: Material.accent @@ -134,10 +134,10 @@ AbstractButton { Rectangle { color: "Black" - anchors.bottom: parent.bottom height: 20 width: parent.width + visible: content.visible } } } From da2afe699eb6556a680764b9cf984d6bfbc9d2d1 Mon Sep 17 00:00:00 2001 From: EndrII Date: Thu, 24 Apr 2025 17:22:43 +0200 Subject: [PATCH 8/8] update image view --- ViewSolutions/src/ViewSolutionsModule/ImageView.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ViewSolutions/src/ViewSolutionsModule/ImageView.qml b/ViewSolutions/src/ViewSolutionsModule/ImageView.qml index b397d32..0302be1 100644 --- a/ViewSolutions/src/ViewSolutionsModule/ImageView.qml +++ b/ViewSolutions/src/ViewSolutionsModule/ImageView.qml @@ -33,7 +33,7 @@ AbstractButton { function onStatusChanged(status) { if (status === Image.Ready) { - root.backgroundColor = colorPicker.pick(source); + root.backgroundColor = colorPicker.pick(root.source); } } }