// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL // The crop of a picked picture into the avatar or banner that fits its frame. // QML draws the selection - it knows how to show the picture and drag the // rectangle, and has no way to write a file - so the actual read-crop-scale-save // lives here, behind a pair of invokables. #pragma once #include #include #include class ImageCrop : public QObject { Q_OBJECT public: explicit ImageCrop(QObject *parent = nullptr); // An absolute path under this app's writable data directory for whatever // the QML ends up saving, created if the directory does not exist yet. Q_INVOKABLE QString writableImagePath(const QString &fileName) const; // Copies srcRect out of sourcePath (a rectangle in that file's own pixels), // scales it to targetWidth/targetHeight and writes the result to outPath. // A zero target keeps the source size. Success is told by the return value, // so QML does not need a touchstone file to check for. Q_INVOKABLE bool cropToFile(const QString &sourcePath, const QRectF &srcRect, int targetWidth, int targetHeight, const QString &outPath) const; };