Verified Commit cbce2175 authored by Linus Jahn's avatar Linus Jahn

QmlUtils: Add more getters for C++ constants

New getters are:
 * applicationDisplayName()
 * applicationSourceCodeUlr()
 * invitiationUrl(jid)
parent 2db4c8f6
Pipeline #12292 passed with stages
in 48 minutes and 22 seconds
......@@ -39,6 +39,9 @@
#define KAIDAN_RESOURCE_RANDOM_CHARS \
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
#define INVITATION_URL "https://i.kaidan.im/#"
#define APPLICATION_SOURCE_CODE_URL "https://invent.kde.org/kde/kaidan"
// XML namespaces
#define NS_SPOILERS "urn:xmpp:spoiler:0"
#define NS_CARBONS "urn:xmpp:carbons:2"
......
......@@ -32,6 +32,8 @@
#define QMLUTILS_H
#include <QObject>
#include <QUrl>
#include "Globals.h"
#include "Enums.h"
......@@ -80,11 +82,35 @@ public:
/**
* Returns a string of this build's Kaidan version
*/
Q_INVOKABLE static QString getVersionString()
Q_INVOKABLE static QString versionString()
{
return QStringLiteral(VERSION_STRING);
}
/**
* Returns the name of this application as it should be displayed to the user
*/
Q_INVOKABLE static QString applicationDisplayName()
{
return QStringLiteral(APPLICATION_DISPLAY_NAME);
}
/**
* Returns the URL where the source code of this application can be found
*/
Q_INVOKABLE static QUrl applicationSourceCodeUrl()
{
return {QStringLiteral(APPLICATION_SOURCE_CODE_URL)};
}
/**
* Returns an invitation URL to the given JID
*/
Q_INVOKABLE static QUrl invitationUrl(const QString &jid)
{
return {QStringLiteral(INVITATION_URL) + jid};
}
/**
* Returns a string without new lines, unneeded spaces, etc.
*
......
......@@ -65,7 +65,7 @@ Controls.Dialog {
spacing: Kirigami.gridUnit * 0.6
Kirigami.Heading {
text: "Kaidan " + Utils.getVersionString()
text: Utils.applicationDisplayName() + " " + Utils.versionString()
textFormat: Text.PlainText
wrapMode: Text.WordWrap
Layout.fillWidth: true
......@@ -99,7 +99,7 @@ Controls.Dialog {
Controls.ToolButton {
text: qsTr("View source code online")
onClicked: Qt.openUrlExternally("https://invent.kde.org/kde/kaidan")
onClicked: Qt.openUrlExternally(Utils.applicationSourceCodeUrl())
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
}
......
......@@ -34,7 +34,7 @@ import "settings"
Kirigami.GlobalDrawer {
id: globalDrawer
title: "Kaidan"
title: Utils.applicationDisplayName()
titleIcon: Utils.getResourcePath("images/kaidan.svg")
bannerImageSource: Utils.getResourcePath("images/banner.png")
......@@ -47,10 +47,8 @@ Kirigami.GlobalDrawer {
text: qsTr("Invite friends")
iconName: "mail-invitation"
onTriggered: {
Utils.copyToClipboard(
"https://i.kaidan.im/#" + kaidan.jid)
passiveNotification(
qsTr("Invitation link copied to clipboard"))
Utils.copyToClipboard(Utils.invitationUrl(kaidan.jid))
passiveNotification(qsTr("Invitation link copied to clipboard"))
}
},
Kirigami.Action {
......
Markdown is supported
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