Renaming contacts in roster, set 2 reconnects by default
This commit is contained in:
parent
415d56ba69
commit
475a12c28e
@ -1200,3 +1200,14 @@ void Core::Account::removeContactFromGroupRequest(const QString& jid, const QStr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Account::renameContactRequest(const QString& jid, const QString& newName)
|
||||
{
|
||||
std::map<QString, Contact*>::const_iterator itr = contacts.find(jid);
|
||||
if (itr == contacts.end()) {
|
||||
qDebug() << "An attempt to rename non existing contact" << jid << "of account" << name << ", skipping";
|
||||
} else {
|
||||
QXmppRosterManager& rm = client.rosterManager();
|
||||
rm.renameItem(jid, newName);
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
void addContactRequest(const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||
void addContactToGroupRequest(const QString& jid, const QString& groupName);
|
||||
void removeContactFromGroupRequest(const QString& jid, const QString& groupName);
|
||||
void renameContactRequest(const QString& jid, const QString& newName);
|
||||
|
||||
void setRoomJoined(const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& jid, bool joined);
|
||||
|
@ -101,8 +101,12 @@ void Core::Squawk::newAccountRequest(const QMap<QString, QVariant>& map)
|
||||
|
||||
void Core::Squawk::addAccount(const QString& login, const QString& server, const QString& password, const QString& name, const QString& resource)
|
||||
{
|
||||
QSettings settings;
|
||||
unsigned int reconnects = settings.value("reconnects", 2).toUInt();
|
||||
|
||||
Account* acc = new Account(login, server, password, name);
|
||||
acc->setResource(resource);
|
||||
acc->setReconnectTimes(reconnects);
|
||||
accounts.push_back(acc);
|
||||
amap.insert(std::make_pair(name, acc));
|
||||
|
||||
@ -518,3 +522,13 @@ void Core::Squawk::removeContactFromGroupRequest(const QString& account, const Q
|
||||
}
|
||||
itr->second->removeContactFromGroupRequest(jid, groupName);
|
||||
}
|
||||
|
||||
void Core::Squawk::renameContactRequest(const QString& account, const QString& jid, const QString& newName)
|
||||
{
|
||||
AccountsMap::const_iterator itr = amap.find(account);
|
||||
if (itr == amap.end()) {
|
||||
qDebug() << "An attempt to rename contact" << jid << "of existing account" << account << ", skipping";
|
||||
return;
|
||||
}
|
||||
itr->second->renameContactRequest(jid, newName);
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ public slots:
|
||||
void addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
||||
void removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
||||
void removeContactRequest(const QString& account, const QString& jid);
|
||||
void renameContactRequest(const QString& account, const QString& jid, const QString& newName);
|
||||
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||
void setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& account, const QString& jid, bool joined);
|
||||
|
1
main.cpp
1
main.cpp
@ -91,6 +91,7 @@ int main(int argc, char *argv[])
|
||||
QObject::connect(&w, SIGNAL(downloadFileRequest(const QString&, const QString&)), squawk, SLOT(downloadFileRequest(const QString&, const QString&)));
|
||||
QObject::connect(&w, &Squawk::addContactToGroupRequest, squawk, &Core::Squawk::addContactToGroupRequest);
|
||||
QObject::connect(&w, &Squawk::removeContactFromGroupRequest, squawk, &Core::Squawk::removeContactFromGroupRequest);
|
||||
QObject::connect(&w, &Squawk::renameContactRequest, squawk, &Core::Squawk::renameContactRequest);
|
||||
|
||||
QObject::connect(squawk, SIGNAL(newAccount(const QMap<QString, QVariant>&)), &w, SLOT(newAccount(const QMap<QString, QVariant>&)));
|
||||
QObject::connect(squawk, SIGNAL(addContact(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)),
|
||||
|
@ -578,10 +578,31 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
QMenu* groupsMenu = contextMenu->addMenu(Shared::icon("group"), "Groups");
|
||||
QString accName = cnt->getAccountName();
|
||||
QString cntJID = cnt->getJid();
|
||||
QString cntName = cnt->getName();
|
||||
|
||||
QAction* rename = contextMenu->addAction(Shared::icon("edit-rename"), "Rename");
|
||||
rename->setEnabled(active);
|
||||
connect(rename, &QAction::triggered, [this, cntName, accName, cntJID]() {
|
||||
QInputDialog* dialog = new QInputDialog(this);
|
||||
connect(dialog, &QDialog::accepted, [this, dialog, cntName, accName, cntJID]() {
|
||||
QString newName = dialog->textValue();
|
||||
if (newName != cntName) {
|
||||
emit renameContactRequest(accName, cntJID, newName);
|
||||
}
|
||||
dialog->deleteLater();
|
||||
});
|
||||
connect(dialog, &QDialog::rejected, dialog, &QObject::deleteLater);
|
||||
dialog->setInputMode(QInputDialog::TextInput);
|
||||
dialog->setLabelText("Input new name for " + cntJID + " \nor leave it empty for the contact \nto be displayed as " + cntJID);
|
||||
dialog->setWindowTitle("Renaming " + cntJID);
|
||||
dialog->setTextValue(cntName);
|
||||
dialog->exec();
|
||||
});
|
||||
|
||||
|
||||
QMenu* groupsMenu = contextMenu->addMenu(Shared::icon("group"), "Groups");
|
||||
std::deque<QString> groupList = rosterModel.groupList(accName);
|
||||
for (QString groupName : groupList) {
|
||||
QAction* gr = groupsMenu->addAction(groupName);
|
||||
|
@ -64,6 +64,7 @@ signals:
|
||||
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||
void addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
||||
void removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
||||
void renameContactRequest(const QString& account, const QString& jid, const QString& newName);
|
||||
void setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& account, const QString& jid, bool joined);
|
||||
void addRoomRequest(const QString& account, const QString& jid, const QString& nick, const QString& password, bool autoJoin);
|
||||
|
Loading…
Reference in New Issue
Block a user