22 #include "ui_aboutfriendform.h"
26 #include <QFileDialog>
27 #include <QMessageBox>
32 , about{std::move(_about)}
40 connect(ui->autoacceptcall, SIGNAL(activated(
int)),
this, SLOT(onAutoAcceptCallClicked(
void)));
44 about->connectTo_autoAcceptDirChanged(
this, [=](
const QString& dir){ onAutoAcceptDirChanged(dir); });
46 const QString dir = about->getAutoAcceptDir();
47 ui->autoacceptfile->setChecked(!dir.isEmpty());
49 ui->removeHistory->setEnabled(about->isHistoryExistence());
51 const int index =
static_cast<int>(about->getAutoAcceptCall());
52 ui->autoacceptcall->setCurrentIndex(index);
54 ui->selectSaveDir->setEnabled(ui->autoacceptfile->isChecked());
55 ui->autogroupinvite->setChecked(about->getAutoGroupInvite());
57 if (ui->autoacceptfile->isChecked()) {
58 ui->selectSaveDir->setText(about->getAutoAcceptDir());
61 const QString name = about->getName();
63 ui->userName->setText(name);
64 ui->publicKey->setText(about->getPublicKey().toString());
65 ui->publicKey->setCursorPosition(0);
66 ui->note->setPlainText(about->getNote());
67 ui->statusMessage->setText(about->getStatusMessage());
68 ui->avatar->setPixmap(about->getAvatar());
75 static QString getAutoAcceptDir(
const QString& dir)
78 const QString title = AboutFriendForm::tr(
"Choose an auto-accept directory");
79 return QFileDialog::getExistingDirectory(Q_NULLPTR, title, dir);
84 const QString dir = [&]{
85 if (!
ui->autoacceptfile->isChecked()) {
89 return getAutoAcceptDir(
about->getAutoAcceptDir());
92 about->setAutoAcceptDir(dir);
102 const bool enabled = !path.isNull();
103 ui->autoacceptfile->setChecked(enabled);
104 ui->selectSaveDir->setEnabled(enabled);
105 ui->selectSaveDir->setText(enabled ? path : tr(
"Auto-accept for this contact is disabled"));
111 const int index =
ui->autoacceptcall->currentIndex();
112 const IFriendSettings::AutoAcceptCallFlags flag{index};
113 about->setAutoAcceptCall(flag);
121 about->setAutoGroupInvite(
ui->autogroupinvite->isChecked());
126 const QString dir = getAutoAcceptDir(
about->getAutoAcceptDir());
127 about->setAutoAcceptDir(dir);
135 about->setNote(
ui->note->toPlainText());
141 tr(
"Are you sure to remove %1 chat history?").arg(
about->getName()),
147 const bool result =
about->clearHistory();
151 tr(
"Failed to remove chat history with %1!").arg(
about->getName()).toHtmlEscaped());
157 ui->removeHistory->setEnabled(
false);