Commit a9630722 authored by Linus Jahn's avatar Linus Jahn 🔌 Committed by Jonah Brüchert
Browse files

AddContactSheet: Add optional message for subscription request

parent 2bd1acee
......@@ -187,7 +187,7 @@ signals:
/**
* Emit to add a new contact to the roster.
*/
void addContactRequested(QString jid, QString name);
void addContactRequested(QString jid, QString name, QString msg);
/**
* Emit to remove a contact from the roster.
......
......@@ -194,10 +194,10 @@ void Kaidan::sendMessage(QString jid, QString message)
}
}
void Kaidan::addContact(QString jid, QString nick)
void Kaidan::addContact(QString jid, QString nick, QString msg)
{
if (client->isConnected()) {
emit client->addContactRequested(jid, nick);
emit client->addContactRequested(jid, nick, msg);
} else {
emit passiveNotificationRequested(tr("Could not add contact, as a result of not being connected."));
qWarning() << "[main] Could not add contact, as a result of not being connected.";
......
......@@ -125,7 +125,7 @@ public:
* @param nick A simple nick name for the new contact, which should be
* used to display in the roster.
*/
Q_INVOKABLE void addContact(QString jid, QString nick);
Q_INVOKABLE void addContact(QString jid, QString nick, QString msg);
/**
* Remove a contact from your roster
......
......@@ -50,11 +50,13 @@ RosterManager::~RosterManager()
delete rosterUpdater;
}
void RosterManager::addContact(const QString jid, const QString nick)
void RosterManager::addContact(const QString jid, const QString nick,
const QString msg)
{
// don't set any groups
gloox::StringList groups;
rosterManager->subscribe(jid.toStdString(), nick.toStdString(), groups);
rosterManager->subscribe(jid.toStdString(), nick.toStdString(),
groups, msg.toStdString());
}
void RosterManager::removeContact(const QString jid)
......
......@@ -54,7 +54,7 @@ public:
~RosterManager();
public slots:
void addContact(const QString jid, const QString name);
void addContact(const QString jid, const QString name, const QString msg);
void removeContact(const QString jid);
private:
......
......@@ -28,25 +28,27 @@
* along with Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import QtQuick 2.7
import QtQuick.Controls 2.0 as Controls
import QtQuick.Layouts 1.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami
Kirigami.OverlaySheet {
ColumnLayout {
Layout.fillWidth: true
Kirigami.Heading {
text: qsTr("Add new contact") + " "
text: qsTr("Add new contact")
Layout.fillWidth: true
}
Controls.Label {
text: qsTr("Nickname:")
}
Controls.TextField {
id: nickField
selectByMouse: true
text: qsTr("This will also send a request to access the " +
"presence of the contact.")
textFormat: Text.PlainText
wrapMode: Text.WordWrap
Layout.fillWidth: true
bottomPadding: 10
}
Controls.Label {
......@@ -55,37 +57,63 @@ Kirigami.OverlaySheet {
Controls.TextField {
id: jidField
placeholderText: qsTr("user@example.org")
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhPreferLowercase
selectByMouse: true
Layout.fillWidth: true
}
Controls.Label {
text: qsTr("Nickname:")
}
Controls.TextField {
id: nickField
selectByMouse: true
Layout.fillWidth: true
}
Controls.Label {
text: qsTr("Optional message:")
textFormat: Text.PlainText
Layout.fillWidth: true
}
Controls.TextArea {
id: msgField
Layout.fillWidth: true
Layout.minimumHeight: Kirigami.Units.gridUnit * 4
placeholderText: qsTr("Tell your chat partner who you are.")
wrapMode: Controls.TextArea.Wrap
selectByMouse: true
}
RowLayout {
Layout.topMargin: 10
Controls.Button {
text: qsTr("Cancel")
onClicked: {
clearInput();
close();
clearInput()
close()
}
Layout.fillWidth: true
}
Controls.Button {
id: addButton
text: qsTr("Add")
enabled: jidField.length > 0
enabled: jidField.length >= 3 && jidField.contains("@")
onClicked: {
kaidan.addContact(jidField.text, nickField.text);
clearInput();
close();
kaidan.addContact(jidField.text, nickField.text, msgField.text)
clearInput()
close()
}
Layout.fillWidth: true
}
}
}
function clearInput() {
jidField.text = "";
nickField.text = "";
msgField.text = "";
}
}
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