void ContactView::contactEditable(bool enable) { _editing = enable; ui->firstname->setEnabled(enable); ui->lastname->setEnabled(enable); ui->khid_pubkey->setEditable(enable); setEnabledSaveContact (); if (isAddingNewContact ()) { send_mail->setVisible(false); chat_contact->setVisible(false); edit_contact->setVisible(false); share_contact->setVisible(false); request_contact->setVisible(false); separatorToolBar->setVisible(false); label_createContact->setVisible(true); } else { send_mail->setVisible(true); chat_contact->setVisible(true); edit_contact->setVisible(true); share_contact->setVisible(true); request_contact->setVisible(true); separatorToolBar->setVisible(true); label_createContact->setVisible(false); } ui->privacy_comboBox->setEnabled(enable); ui->email->setEnabled(enable); ui->phone->setEnabled(enable); ui->notes->setEnabled(enable); ui->icon_view->setEnabled(enable); ui->keyhotee_founder->setVisible(!enable && _current_contact.isKeyhoteeFounder()); bool is_owner = _current_contact.isOwn(); ui->keyhoteeID_status->setVisible(!enable && is_owner); ui->authorization_status->setVisible(!enable && !is_owner); ui->mining_effort_slider->setDisabled(!enable && is_owner); cancel_edit_contact->setEnabled(enable); send_mail->setEnabled(!enable); chat_contact->setEnabled(!enable); edit_contact->setEnabled(!enable); share_contact->setEnabled(!enable); request_contact->setEnabled(!enable && !is_owner); ui->contact_pages->setTabEnabled(chat, !enable); if (enable) { ui->firstname->setFocus(); setModified(false); } checkSendMailButton(); }
ContactView::ContactView(QWidget* parent) : QWidget(parent), ui(new Ui::ContactView() ), _validForm(false) { _address_book = nullptr; ui->setupUi(this); _addingNewContact = false; _editing = false; _modified = 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); /// add identity observer IdentityObservable::getInstance().addObserver( ui->widget_Identity ); 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/128x128/contact_share.png"), tr("Share contact"), 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->khid_pubkey->setMode(KeyhoteeIDPubKeyWidget::ModeWidget::ShowContact); 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->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->sendButton, &QPushButton::clicked, this, &ContactView::onSend); connect(ui->chat_input, &QPlainTextEdit::textChanged, this, &ContactView::onTextChanged); connect(ui->contact_pages, &QTabWidget::currentChanged, this, &ContactView::currentTabChanged); connect(ui->mining_effort_slider, &QSlider::valueChanged, this, &ContactView::onMiningEffortSliderChanged); connect(ui->khid_pubkey, &KeyhoteeIDPubKeyWidget::currentState, this, &ContactView::onStateWidget); contactEditable(false); ui->chat_input->installEventFilter(this); checkSendMailButton(); setContact(Contact() ); }
ContactView::ContactView(QWidget* parent) : QWidget(parent), ui(new Ui::ContactView() ), _validForm(false) { _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->chat_input, &QPlainTextEdit::textChanged, this, &ContactView::onTextChanged); 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); checkSendMailButton(); setContact(Contact() ); }
void ContactView::keyEdit(bool enable) { _editing = enable; ui->firstname->setEnabled(enable); ui->lastname->setEnabled(enable); setEnabledSaveContact (); if (isAddingNewContact ()) { //keyhoteeIds don't function when mining is not possible ui->id_edit->setEnabled(enable && gMiningIsPossible); ui->public_key->setReadOnly(!enable); send_mail->setVisible(false); chat_contact->setVisible(false); edit_contact->setVisible(false); share_contact->setVisible(false); request_contact->setVisible(false); separatorToolBar->setVisible(false); label_createContact->setVisible(true); } else { /// note: you cannot change the id of a contact once it has been /// set... you must create a new contact anytime their public key /// changes. ui->id_edit->setEnabled(false); ui->public_key->setReadOnly (true); send_mail->setVisible(true); chat_contact->setVisible(true); edit_contact->setVisible(true); share_contact->setVisible(true); request_contact->setVisible(true); separatorToolBar->setVisible(true); label_createContact->setVisible(false); } ui->privacy_comboBox->setEnabled(enable); ui->email->setEnabled(enable); ui->phone->setEnabled(enable); ui->notes->setEnabled(enable); ui->icon_view->setEnabled(enable); ui->id_status->setVisible(enable); ui->keyhotee_founder->setVisible(!enable && _current_contact.isKeyhoteeFounder()); bool is_owner = _current_contact.isOwn(); ui->keyhoteeID_status->setVisible(!enable && is_owner); ui->mining_effort_slider->setDisabled(!enable && is_owner); cancel_edit_contact->setEnabled(enable); send_mail->setEnabled(!enable); chat_contact->setEnabled(!enable); edit_contact->setEnabled(!enable); share_contact->setEnabled(false); request_contact->setEnabled(false); ui->contact_pages->setTabEnabled(chat, !enable); if (enable) { ui->firstname->setFocus(); setModyfied(false); } checkSendMailButton(); }