Commit e9d77bab authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Show the name that will be used

Maybe we'd like to make it easy to modify?

BUG: 390035
parent 761e3195
......@@ -13,6 +13,7 @@ Kirigami.OverlaySheet
readonly property alias rating: ratingInput.rating
readonly property alias summary: summaryInput.text
readonly property alias review: reviewInput.text
property QtObject backend: null
signal accepted()
......@@ -24,6 +25,10 @@ Kirigami.OverlaySheet
editable: true
}
Label {
visible: reviewDialog.backend.userName.length > 0
text: visible ? i18n("Submission name: %1", reviewDialog.backend.userName) : ""
}
Label { text: i18n("Summary:") }
TextField {
id: summaryInput
......
......@@ -34,7 +34,8 @@ Kirigami.OverlaySheet {
id: reviewDialog
application: page.resource
parent: overlay
onAccepted: page.reviewsBackend.submitReview(resource, summary, review, rating)
backend: page.reviewsBackend
onAccepted: backend.submitReview(resource, summary, review, rating)
}
function openReviewDialog() {
......
......@@ -33,7 +33,7 @@ class DISCOVERCOMMON_EXPORT AbstractReviewsBackend : public QObject
Q_OBJECT
Q_PROPERTY(bool isReviewable READ isReviewable CONSTANT)
Q_PROPERTY(bool hasCredentials READ hasCredentials NOTIFY loginStateChanged)
Q_PROPERTY(QString name READ userName NOTIFY loginStateChanged)
Q_PROPERTY(QString userName READ userName NOTIFY loginStateChanged)
public:
explicit AbstractReviewsBackend(QObject* parent = nullptr);
......
......@@ -29,6 +29,7 @@
#include <KIO/FileCopyJob>
#include <KUser>
#include <KLocalizedString>
#include <QCryptographicHash>
#include <QDir>
......@@ -244,6 +245,11 @@ void OdrsReviewsBackend::usefulnessSubmitted()
}
}
QString OdrsReviewsBackend::userName() const
{
return i18n("%1 (%2)", KUser().property(KUser::FullName).toString(), KUser().loginName());
}
void OdrsReviewsBackend::submitReview(AbstractResource *res, const QString &summary, const QString &description, const QString &rating)
{
QJsonObject map = {{QStringLiteral("app_id"), res->appstreamId()},
......
......@@ -37,7 +37,7 @@ Q_OBJECT
public:
explicit OdrsReviewsBackend(AbstractResourcesBackend *parent = nullptr);
QString userName() const override { return {}; }
QString userName() const override;
void login() override {}
void logout() override {}
void registerAndLogin() override {}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment