void ContactView::onEdit() { setAddingNewContact(false); //editing doDataExchange (false); keyEdit(true); //and set focus on the first field ui->contact_pages->setCurrentIndex(info); ui->info_stack->setCurrentWidget(ui->info_edit); }
void ContactView::onCancel() { setModyfied(false); doDataExchange (false); keyEdit(false); if (isAddingNewContact()) { emit canceledNewContact(); } else //editing contact { } }
void ContactView::onSave() { try { if (doDataExchange (true)) { if (_current_record) { //_current_contact.bit_id_hash = _current_record->name_hash; if (!_current_contact.public_key.valid() ) { _current_contact.public_key = _current_record->active_key; FC_ASSERT(_current_contact.public_key.valid() ); } // TODO: lookup block id / timestamp that registered this ID // _current_contact.known_since.setMSecsSinceEpoch( ); } else if (!_current_record) /// note: user is entering manual public key { elog("!current record??\n"); /* if( _current_contact.known_since == QDateTime() ) { _current_contact.known_since = QDateTime::currentDateTime(); } */ std::string enteredPKey = ui->public_key->text().toStdString(); if (enteredPKey.empty() == false) { bool publicKeySemanticallyValid = false; assert(public_key_address::is_valid(enteredPKey, &publicKeySemanticallyValid)); assert(publicKeySemanticallyValid); public_key_address key_address(enteredPKey); _current_contact.public_key = key_address.key; } } _current_contact.privacy_setting = bts::addressbook::secret_contact; int idxNewContact = _address_book->storeContact(_current_contact); keyEdit(false); emit savedNewContact(idxNewContact); } } FC_RETHROW_EXCEPTIONS(warn, "onSave") }
ContactView::ContactView(QWidget* parent) : QWidget(parent), ui(new Ui::ContactView() ) { _address_book = nullptr; ui->setupUi(this); _addingNewContact = false; _editing = false; _modyfied = false; message_tools = new QToolBar( ui->toolbar_container ); QGridLayout* grid_layout = new QGridLayout(ui->toolbar_container); grid_layout->setContentsMargins(0, 0, 0, 0); grid_layout->setSpacing(0); ui->toolbar_container->setLayout(grid_layout); grid_layout->addWidget(message_tools, 0, 0); ui->email->setVisible (false); //unsupported ui->phone->setVisible (false); ui->phone_label->setVisible (false); ui->email_label->setVisible (false); ui->privacy_comboBox->setVisible (false); ui->privacy_level_label->setVisible (false);//unsupported //default contact view: info page ui->contact_pages->setCurrentIndex(info); send_mail = new QAction( QIcon( ":/images/128x128/contact_info_send_mail.png"), tr("Mail"), this); chat_contact = new QAction( QIcon( ":/images/chat.png"), tr("Chat"), this); edit_contact = new QAction( QIcon(":/images/128x128/contact_info_edit.png"), tr("Edit"), this); share_contact = new QAction(QIcon(":/images/read-icon.png"), tr("Share (need new icon)"), this); request_contact = new QAction( QIcon(":/images/128x128/contact_info_request_authorisation.png"), tr("Request authorisation"), this); save_contact = new QAction( QIcon(":/images/128x128/contact_info_save.png"), tr( "Save"), this ); cancel_edit_contact = new QAction( QIcon(":/images/128x128/contact_info_cancel_edit.png"), tr("Discard changes"), this); connect(ui->icon_view, &QToolButton::clicked, this, &ContactView::onIconSearch); message_tools->addAction(send_mail); message_tools->addAction(chat_contact); message_tools->addAction(share_contact); message_tools->addAction(request_contact); separatorToolBar = message_tools->addSeparator (); message_tools->addAction(edit_contact); message_tools->addAction(save_contact); message_tools->addAction(cancel_edit_contact); QLabel *label = new QLabel((tr(" Create new contact"))); label_createContact = message_tools->addWidget (label); QFont font; font.setBold(true); font.setPointSize (16); label->setFont (font); //ui->chat_conversation->setHtml( "<html><head></head><body>Hello World<br/></body></html>" ); connect(save_contact, &QAction::triggered, this, &ContactView::onSave); connect(cancel_edit_contact, &QAction::triggered, this, &ContactView::onCancel); connect(edit_contact, &QAction::triggered, this, &ContactView::onEdit); connect(send_mail, &QAction::triggered, this, &ContactView::onMail); connect(chat_contact, &QAction::triggered, this, &ContactView::onChat); connect(share_contact, &QAction::triggered, this, &ContactView::onShareContact); connect(request_contact, &QAction::triggered, this, &ContactView::onRequestContact); connect(ui->firstname, &QLineEdit::textChanged, this, &ContactView::firstNameChanged); connect(ui->lastname, &QLineEdit::textChanged, this, &ContactView::lastNameChanged); connect(ui->id_edit, &QLineEdit::textChanged, this, &ContactView::keyhoteeIdChanged); connect(ui->id_edit, &QLineEdit::textEdited, this, &ContactView::keyhoteeIdEdited); connect(ui->public_key, &QLineEdit::textEdited, this, &ContactView::publicKeyEdited); connect(ui->public_key, &QLineEdit::textChanged, this, &ContactView::publicKeyChanged); connect( ui->privacy_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(privacyLevelChanged(int))); connect(ui->email, &QLineEdit::textChanged, this, &ContactView::emailChanged); connect(ui->phone, &QLineEdit::textChanged, this, &ContactView::phoneChanged); connect(ui->notes, &QPlainTextEdit::textChanged, this, &ContactView::notesChanged); connect(ui->public_key_to_clipboard, &QToolButton::clicked, this, &ContactView::onPublicKeyToClipboard); connect(ui->sendButton, &QPushButton::clicked, this, &ContactView::onSend); connect(ui->contact_pages, &QTabWidget::currentChanged, this, &ContactView::currentTabChanged); connect(ui->mining_effort_slider, &QSlider::valueChanged, this, &ContactView::onSliderChanged); keyEdit(false); ui->chat_input->installEventFilter(this); setContact(Contact() ); }
void ContactView::addNewContact () { doDataExchange (false); keyEdit(true); }