void MailFieldsWidget::fillSenderIdentities() { QMenu* menu = new QMenu(this); ui->fromButton->setMenu(menu); QAction* first = nullptr; auto profile = bts::application::instance()->get_profile(); std::vector<bts::addressbook::wallet_identity> identities = profile->identities(); for(const auto& identity : identities) { std::string entry = identity.get_display_name(); auto ipk = identity.public_key; assert(ipk.valid()); QAction* action = menu->addAction(tr(entry.c_str())); action->setCheckable(true); Action2Identity.insert(TAction2IdentityIndex::value_type(action, identity)); if(first == nullptr) first = action; } connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onFromBtnTriggered(QAction*))); onFromBtnTriggered(first); menu->setActiveAction(first); }
void MailFieldsWidget::fillSenderIdentities() { QMenu* menu = new QMenu(this); ui->fromButton->setMenu(menu); QAction* first = nullptr; std::vector<bts::addressbook::wallet_identity> identities = bts::application::instance()->get_profile()->identities(); for(const auto& identity : identities) { std::string identity_label = identity.first_name + " " + identity.last_name; std::string entry(identity_label); if(identity_label.empty() == false) entry += '('; entry += identity.dac_id_string; if(identity_label.empty() == false) entry += ')'; QAction* action = menu->addAction(tr(entry.c_str())); action->setCheckable(true); Action2Identity.insert(TAction2IdentityIndex::value_type(action, identity)); if(first == nullptr) first = action; } connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onFromBtnTriggered(QAction*))); onFromBtnTriggered(first); menu->setActiveAction(first); }
void MailFieldsWidget::selectSenderIdentity(const TRecipientPublicKey& senderPK) { assert(senderPK.valid()); for(const auto& it : Action2Identity) { const IMailProcessor::TIdentity& id = it.second; assert(id.public_key.valid()); if(id.public_key == senderPK) { onFromBtnTriggered(it.first); return; } } assert(EditMode == false && "When editing an email only one of profile identities could be used" "as sender."); setChosenSender(senderPK); }