mirror of https://github.com/qTox/qTox.git
9 changed files with 462 additions and 11 deletions
@ -0,0 +1,109 @@ |
|||||||
|
#include "aboutuser.h" |
||||||
|
#include "ui_aboutuser.h" |
||||||
|
#include "src/persistence/settings.h" |
||||||
|
#include "src/persistence/historykeeper.h" |
||||||
|
|
||||||
|
#include <QDir> |
||||||
|
#include <QFileDialog> |
||||||
|
#include <QMessageBox> |
||||||
|
|
||||||
|
AboutUser::AboutUser(ToxId &toxId, QWidget *parent) : |
||||||
|
QDialog(parent), |
||||||
|
ui(new Ui::AboutUser) |
||||||
|
{ |
||||||
|
ui->setupUi(this); |
||||||
|
ui->label_4->hide(); |
||||||
|
ui->aliases->hide(); |
||||||
|
|
||||||
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked); |
||||||
|
connect(ui->autoaccept, &QCheckBox::clicked, this, &AboutUser::onAutoAcceptClicked); |
||||||
|
connect(ui->selectSaveDir, &QPushButton::clicked, this, &AboutUser::onSelectDirClicked); |
||||||
|
connect(ui->removeHistory, &QPushButton::clicked, this, &AboutUser::onRemoveHistoryClicked); |
||||||
|
|
||||||
|
this->toxId = toxId; |
||||||
|
QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId); |
||||||
|
ui->autoaccept->setChecked(!dir.isEmpty()); |
||||||
|
ui->selectSaveDir->setEnabled(ui->autoaccept->isChecked()); |
||||||
|
|
||||||
|
if(ui->autoaccept->isChecked()) |
||||||
|
ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId)); |
||||||
|
} |
||||||
|
|
||||||
|
void AboutUser::setFriend(Friend *f) |
||||||
|
{ |
||||||
|
this->setWindowTitle(f->getDisplayedName()); |
||||||
|
ui->userName->setText(f->getDisplayedName()); |
||||||
|
ui->publicKey->setText(QString(f->getToxId().toString())); |
||||||
|
ui->publicKey->setCursorPosition(0); //scroll textline to left
|
||||||
|
ui->note->setPlainText(Settings::getInstance().getContactNote(f->getToxId())); |
||||||
|
|
||||||
|
QPixmap avatar = Settings::getInstance().getSavedAvatar(f->getToxId().toString()); |
||||||
|
ui->statusMessage->setText(f->getStatusMessage()); |
||||||
|
if(!avatar.isNull()) { |
||||||
|
ui->avatar->setPixmap(avatar); |
||||||
|
} else { |
||||||
|
ui->avatar->setPixmap(QPixmap(":/img/contact_dark.svg")); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
void AboutUser::onAutoAcceptClicked() |
||||||
|
{ |
||||||
|
QString dir; |
||||||
|
if (!ui->autoaccept->isChecked()) |
||||||
|
{ |
||||||
|
dir = QDir::homePath(); |
||||||
|
ui->autoaccept->setChecked(false); |
||||||
|
Settings::getInstance().setAutoAcceptDir(this->toxId, ""); |
||||||
|
ui->selectSaveDir->setText(tr("Auto accept for this contact is disabled")); |
||||||
|
} |
||||||
|
else if (ui->autoaccept->isChecked()) |
||||||
|
{ |
||||||
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose an auto accept directory", |
||||||
|
"popup title"), dir); |
||||||
|
if(dir.isEmpty()) |
||||||
|
{ |
||||||
|
ui->autoaccept->setChecked(false); |
||||||
|
return; // user canellced
|
||||||
|
} |
||||||
|
Settings::getInstance().setAutoAcceptDir(this->toxId, dir); |
||||||
|
ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId)); |
||||||
|
} |
||||||
|
Settings::getInstance().saveGlobal(); |
||||||
|
ui->selectSaveDir->setEnabled(ui->autoaccept->isChecked()); |
||||||
|
} |
||||||
|
|
||||||
|
void AboutUser::onSelectDirClicked() |
||||||
|
{ |
||||||
|
QString dir; |
||||||
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose an auto accept directory", |
||||||
|
"popup title"), dir); |
||||||
|
ui->autoaccept->setChecked(true); |
||||||
|
Settings::getInstance().setAutoAcceptDir(this->toxId, dir); |
||||||
|
Settings::getInstance().saveGlobal(); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AboutUser::onAcceptedClicked When users clicks the bottom OK button, |
||||||
|
* save all settings |
||||||
|
*/ |
||||||
|
void AboutUser::onAcceptedClicked() |
||||||
|
{ |
||||||
|
Settings::getInstance().setContactNote(ui->publicKey->text(), ui->note->toPlainText()); |
||||||
|
Settings::getInstance().saveGlobal(); |
||||||
|
} |
||||||
|
|
||||||
|
void AboutUser::onRemoveHistoryClicked() |
||||||
|
{ |
||||||
|
HistoryKeeper::getInstance()->removeFriendHistory(toxId.publicKey); |
||||||
|
QMessageBox::StandardButton reply; |
||||||
|
reply = QMessageBox::information(this, |
||||||
|
tr("History removed"), |
||||||
|
tr("Chat history with %1 removed!").arg(ui->userName->text().toHtmlEscaped()), |
||||||
|
QMessageBox::Ok); |
||||||
|
} |
||||||
|
|
||||||
|
AboutUser::~AboutUser() |
||||||
|
{ |
||||||
|
delete ui; |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
#ifndef ABOUTUSER_H |
||||||
|
#define ABOUTUSER_H |
||||||
|
|
||||||
|
#include <QDialog> |
||||||
|
#include "src/friend.h" |
||||||
|
|
||||||
|
|
||||||
|
namespace Ui { |
||||||
|
class AboutUser; |
||||||
|
} |
||||||
|
|
||||||
|
class AboutUser : public QDialog |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
|
||||||
|
public: |
||||||
|
explicit AboutUser(ToxId &toxID, QWidget *parent = 0); |
||||||
|
~AboutUser(); |
||||||
|
void setFriend(Friend *f); |
||||||
|
|
||||||
|
private: |
||||||
|
Ui::AboutUser *ui; |
||||||
|
ToxId toxId; |
||||||
|
|
||||||
|
private slots: |
||||||
|
void onAcceptedClicked(); |
||||||
|
void onAutoAcceptClicked(); |
||||||
|
void onSelectDirClicked(); |
||||||
|
void onRemoveHistoryClicked(); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // ABOUTUSER_H
|
@ -0,0 +1,254 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<ui version="4.0"> |
||||||
|
<class>AboutUser</class> |
||||||
|
<widget class="QDialog" name="AboutUser"> |
||||||
|
<property name="geometry"> |
||||||
|
<rect> |
||||||
|
<x>0</x> |
||||||
|
<y>0</y> |
||||||
|
<width>465</width> |
||||||
|
<height>406</height> |
||||||
|
</rect> |
||||||
|
</property> |
||||||
|
<property name="windowTitle"> |
||||||
|
<string>Dialog</string> |
||||||
|
</property> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4"> |
||||||
|
<item> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout"> |
||||||
|
<item> |
||||||
|
<layout class="QGridLayout" name="gridLayout"> |
||||||
|
<item row="0" column="1"> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||||
|
<item> |
||||||
|
<widget class="QLabel" name="userName"> |
||||||
|
<property name="text"> |
||||||
|
<string>username</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="alignment"> |
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item alignment="Qt::AlignBottom"> |
||||||
|
<widget class="QLabel" name="statusMessage"> |
||||||
|
<property name="sizePolicy"> |
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> |
||||||
|
<horstretch>0</horstretch> |
||||||
|
<verstretch>0</verstretch> |
||||||
|
</sizepolicy> |
||||||
|
</property> |
||||||
|
<property name="autoFillBackground"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>status message</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="alignment"> |
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
<item row="0" column="0"> |
||||||
|
<widget class="QLabel" name="avatar"> |
||||||
|
<property name="sizePolicy"> |
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> |
||||||
|
<horstretch>0</horstretch> |
||||||
|
<verstretch>0</verstretch> |
||||||
|
</sizepolicy> |
||||||
|
</property> |
||||||
|
<property name="minimumSize"> |
||||||
|
<size> |
||||||
|
<width>75</width> |
||||||
|
<height>75</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
<property name="maximumSize"> |
||||||
|
<size> |
||||||
|
<width>75</width> |
||||||
|
<height>75</height> |
||||||
|
</size> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
<property name="pixmap"> |
||||||
|
<pixmap>../../../img/contact_dark.svg</pixmap> |
||||||
|
</property> |
||||||
|
<property name="scaledContents"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<layout class="QFormLayout" name="formLayout"> |
||||||
|
<property name="labelAlignment"> |
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> |
||||||
|
</property> |
||||||
|
<item row="0" column="0"> |
||||||
|
<widget class="QLabel" name="label_5"> |
||||||
|
<property name="layoutDirection"> |
||||||
|
<enum>Qt::LeftToRight</enum> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string>Public key:</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item row="0" column="1"> |
||||||
|
<widget class="QLineEdit" name="publicKey"> |
||||||
|
<property name="enabled"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
<property name="mouseTracking"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
<property name="acceptDrops"> |
||||||
|
<bool>false</bool> |
||||||
|
</property> |
||||||
|
<property name="inputMask"> |
||||||
|
<string notr="true"/> |
||||||
|
</property> |
||||||
|
<property name="text"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="cursorPosition"> |
||||||
|
<number>0</number> |
||||||
|
</property> |
||||||
|
<property name="readOnly"> |
||||||
|
<bool>true</bool> |
||||||
|
</property> |
||||||
|
<property name="cursorMoveStyle"> |
||||||
|
<enum>Qt::LogicalMoveStyle</enum> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item row="1" column="0"> |
||||||
|
<widget class="QLabel" name="label_4"> |
||||||
|
<property name="text"> |
||||||
|
<string>Used aliases:</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item row="1" column="1"> |
||||||
|
<widget class="QLabel" name="aliases"> |
||||||
|
<property name="text"> |
||||||
|
<string>HISTORY OF ALIASES</string> |
||||||
|
</property> |
||||||
|
<property name="textFormat"> |
||||||
|
<enum>Qt::PlainText</enum> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item row="3" column="0"> |
||||||
|
<widget class="QLabel" name="label"> |
||||||
|
<property name="text"> |
||||||
|
<string>Default directory to save files:</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item row="3" column="1"> |
||||||
|
<widget class="QPushButton" name="selectSaveDir"> |
||||||
|
<property name="text"> |
||||||
|
<string>Auto accept for this contact is disabled</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item row="2" column="0" colspan="2"> |
||||||
|
<widget class="QCheckBox" name="autoaccept"> |
||||||
|
<property name="text"> |
||||||
|
<string>Auto accept files</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QPushButton" name="removeHistory"> |
||||||
|
<property name="text"> |
||||||
|
<string>Remove history (operation can not be undone!)</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QGroupBox" name="groupBox"> |
||||||
|
<property name="title"> |
||||||
|
<string>Notes</string> |
||||||
|
</property> |
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3"> |
||||||
|
<item> |
||||||
|
<widget class="QPlainTextEdit" name="note"> |
||||||
|
<property name="plainText"> |
||||||
|
<string/> |
||||||
|
</property> |
||||||
|
<property name="placeholderText"> |
||||||
|
<string>You can save comment about this contact here.</string> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
<item> |
||||||
|
<widget class="QDialogButtonBox" name="buttonBox"> |
||||||
|
<property name="orientation"> |
||||||
|
<enum>Qt::Horizontal</enum> |
||||||
|
</property> |
||||||
|
<property name="standardButtons"> |
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||||
|
</property> |
||||||
|
</widget> |
||||||
|
</item> |
||||||
|
</layout> |
||||||
|
</widget> |
||||||
|
<resources/> |
||||||
|
<connections> |
||||||
|
<connection> |
||||||
|
<sender>buttonBox</sender> |
||||||
|
<signal>accepted()</signal> |
||||||
|
<receiver>AboutUser</receiver> |
||||||
|
<slot>accept()</slot> |
||||||
|
<hints> |
||||||
|
<hint type="sourcelabel"> |
||||||
|
<x>248</x> |
||||||
|
<y>254</y> |
||||||
|
</hint> |
||||||
|
<hint type="destinationlabel"> |
||||||
|
<x>157</x> |
||||||
|
<y>274</y> |
||||||
|
</hint> |
||||||
|
</hints> |
||||||
|
</connection> |
||||||
|
<connection> |
||||||
|
<sender>buttonBox</sender> |
||||||
|
<signal>rejected()</signal> |
||||||
|
<receiver>AboutUser</receiver> |
||||||
|
<slot>reject()</slot> |
||||||
|
<hints> |
||||||
|
<hint type="sourcelabel"> |
||||||
|
<x>316</x> |
||||||
|
<y>260</y> |
||||||
|
</hint> |
||||||
|
<hint type="destinationlabel"> |
||||||
|
<x>286</x> |
||||||
|
<y>274</y> |
||||||
|
</hint> |
||||||
|
</hints> |
||||||
|
</connection> |
||||||
|
</connections> |
||||||
|
</ui> |
Loading…
Reference in new issue