From 170eb931ffa7935e9fcffe00257c52f44b4e0147 Mon Sep 17 00:00:00 2001 From: agilob Date: Mon, 9 Nov 2015 20:53:24 +0000 Subject: [PATCH 01/17] Add status message setter and getter --- src/friend.cpp | 6 ++++++ src/friend.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/friend.cpp b/src/friend.cpp index 86ba69ab8..8899c4ed7 100644 --- a/src/friend.cpp +++ b/src/friend.cpp @@ -92,10 +92,16 @@ void Friend::setAlias(QString name) void Friend::setStatusMessage(QString message) { + statusMessage = message; widget->setStatusMsg(message); chatForm->setStatusMessage(message); } +QString Friend::getStatusMessage() +{ + return statusMessage; +} + QString Friend::getDisplayedName() const { if (userAlias.size() == 0) diff --git a/src/friend.h b/src/friend.h index 667531235..3d609fde0 100644 --- a/src/friend.h +++ b/src/friend.h @@ -46,6 +46,7 @@ public: bool hasAlias() const; void setStatusMessage(QString message); + QString getStatusMessage(); void setEventFlag(int f); int getEventFlag() const; @@ -64,7 +65,7 @@ signals: void displayedNameChanged(FriendWidget* widget, Status s, int hasNewEvents); private: - QString userAlias, userName; + QString userAlias, userName, statusMessage; ToxId userID; uint32_t friendId; int hasNewEvents; From 95b5a75d0e932efc4df55d0d42df825b4526e9a3 Mon Sep 17 00:00:00 2001 From: agilob Date: Mon, 9 Nov 2015 20:54:28 +0000 Subject: [PATCH 02/17] Add settings for notes per user --- src/persistence/settings.cpp | 34 ++++++++++++++++++++++++++++++++++ src/persistence/settings.h | 6 +++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/persistence/settings.cpp b/src/persistence/settings.cpp index 1d626ca47..f7997e7eb 100644 --- a/src/persistence/settings.cpp +++ b/src/persistence/settings.cpp @@ -304,6 +304,7 @@ void Settings::loadPersonnal(Profile* profile) friendProp fp; fp.addr = ps.value("addr").toString(); fp.alias = ps.value("alias").toString(); + fp.note = ps.value("note").toString(); fp.autoAcceptDir = ps.value("autoAcceptDir").toString(); fp.circleID = ps.value("circle", -1).toInt(); @@ -478,6 +479,7 @@ void Settings::savePersonal(QString profileName, QString password) ps.setArrayIndex(index); ps.setValue("addr", frnd.addr); ps.setValue("alias", frnd.alias); + ps.setValue("note", frnd.note); ps.setValue("autoAcceptDir", frnd.autoAcceptDir); ps.setValue("circle", frnd.circleID); @@ -913,6 +915,34 @@ void Settings::setAutoAcceptDir(const ToxId &id, const QString& dir) } } +QString Settings::getContactNote(const ToxId &id) const +{ + QMutexLocker locker{&bigLock}; + + auto it = friendLst.find(id.publicKey); + if (it != friendLst.end()) + return it->note; + + return QString(); +} + +void Settings::setContactNote(const ToxId &id, const QString& note) +{ + QMutexLocker locker{&bigLock}; + + auto it = friendLst.find(id.publicKey); + if (it != friendLst.end()) + { + qDebug() << note; + it->note = note; + } + else + { + updateFriendAdress(id.toString()); + setContactNote(id, note); + } +} + QString Settings::getGlobalAutoAcceptDir() const { QMutexLocker locker{&bigLock}; @@ -1252,6 +1282,7 @@ void Settings::updateFriendAdress(const QString &newAddr) friendProp fp; fp.addr = newAddr; fp.alias = ""; + fp.note = ""; fp.autoAcceptDir = ""; friendLst[newAddr] = fp; } @@ -1282,6 +1313,7 @@ void Settings::setFriendAlias(const ToxId &id, const QString &alias) friendProp fp; fp.addr = key; fp.alias = alias; + fp.note = ""; fp.autoAcceptDir = ""; friendLst[key] = fp; } @@ -1310,6 +1342,7 @@ void Settings::setFriendCircleID(const ToxId &id, int circleID) friendProp fp; fp.addr = key; fp.alias = ""; + fp.note = ""; fp.autoAcceptDir = ""; fp.circleID = circleID; friendLst[key] = fp; @@ -1339,6 +1372,7 @@ void Settings::setFriendActivity(const ToxId &id, const QDate &activity) friendProp fp; fp.addr = key; fp.alias = ""; + fp.note = ""; fp.autoAcceptDir = ""; fp.circleID = -1; fp.activity = activity; diff --git a/src/persistence/settings.h b/src/persistence/settings.h index 73455d9e9..116beaaa8 100644 --- a/src/persistence/settings.h +++ b/src/persistence/settings.h @@ -187,8 +187,11 @@ public: int getEmojiFontPointSize() const; void setEmojiFontPointSize(int value); + QString getContactNote(const ToxId& id) const; + void setContactNote(const ToxId& id, const QString& note); + QString getAutoAcceptDir(const ToxId& id) const; - void setAutoAcceptDir(const ToxId&id, const QString& dir); + void setAutoAcceptDir(const ToxId& id, const QString& dir); QString getGlobalAutoAcceptDir() const; void setGlobalAutoAcceptDir(const QString& dir); @@ -394,6 +397,7 @@ private: QString alias; QString addr; QString autoAcceptDir; + QString note; int circleID = -1; QDate activity = QDate(); }; From b9a168dffe0a491dcc08157c2848b86a79881925 Mon Sep 17 00:00:00 2001 From: agilob Date: Mon, 9 Nov 2015 20:55:11 +0000 Subject: [PATCH 03/17] Add action for about window in context menu --- src/widget/friendwidget.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp index 8d798546c..0b1ecc4ef 100644 --- a/src/widget/friendwidget.cpp +++ b/src/widget/friendwidget.cpp @@ -31,6 +31,7 @@ #include "src/widget/style.h" #include "src/persistence/settings.h" #include "src/widget/widget.h" +#include "src/widget/about/aboutuser.h" #include #include #include @@ -48,8 +49,8 @@ FriendWidget::FriendWidget(int FriendId, QString id) , isDefaultAvatar{true} , historyLoaded{false} { - avatar->setPixmap(QPixmap(":img/contact.svg"), Qt::transparent); - statusPic.setPixmap(QPixmap(":img/status/dot_offline.svg")); + avatar->setPixmap(QPixmap(":/img/contact.svg"), Qt::transparent); + statusPic.setPixmap(QPixmap(":/img/status/dot_offline.svg")); statusPic.setMargin(3); nameLabel->setText(id); nameLabel->setTextFormat(Qt::PlainText); @@ -150,6 +151,9 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) if (contentDialog == nullptr || !contentDialog->hasFriendWidget(friendId, this)) removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist")); + menu.addSeparator(); + QAction* aboutWindow = menu.addAction(tr("Show details")); + QAction* selectedItem = menu.exec(pos); removeEventFilter(this); @@ -197,6 +201,14 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) Settings::getInstance().setAutoAcceptDir(id, dir); } } + else if (selectedItem == aboutWindow) { + AboutUser *aboutUser = new AboutUser(this); + aboutUser->setFriend(FriendList::findFriend(friendId)); + aboutUser->setToxId(id); + aboutUser->setAvatar(avatar->getPixmap()); + aboutUser->setStatusMessage(FriendList::findFriend(friendId)->getStatusMessage()); + aboutUser->show(); + } else if (selectedItem == newCircleAction) { if (circleWidget != nullptr) @@ -368,9 +380,9 @@ void FriendWidget::onAvatarRemoved(int FriendId) isDefaultAvatar = true; if (isActive()) - avatar->setPixmap(QPixmap(":img/contact_dark.svg"), Qt::transparent); + avatar->setPixmap(QPixmap(":/img/contact_dark.svg"), Qt::transparent); else - avatar->setPixmap(QPixmap(":img/contact.svg"), Qt::transparent); + avatar->setPixmap(QPixmap(":/img/contact.svg"), Qt::transparent); } void FriendWidget::mousePressEvent(QMouseEvent *ev) From 5ec68403849c602cb5b4192d04feb97ff8635bc2 Mon Sep 17 00:00:00 2001 From: agilob Date: Mon, 9 Nov 2015 20:55:31 +0000 Subject: [PATCH 04/17] Add aboutwindow in qtox.pro --- qtox.pro | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qtox.pro b/qtox.pro index 8d961d8c8..c6527d662 100644 --- a/qtox.pro +++ b/qtox.pro @@ -35,7 +35,8 @@ FORMS += \ src/widget/form/settings/avsettings.ui \ src/widget/form/settings/generalsettings.ui \ src/widget/form/settings/privacysettings.ui \ - src/widget/form/removefrienddialog.ui + src/widget/form/removefrienddialog.ui \ + src/widget/about/aboutuser.ui CONFIG += c++11 @@ -502,7 +503,8 @@ SOURCES += \ src/widget/tool/micfeedbackwidget.cpp \ src/widget/tool/removefrienddialog.cpp \ src/video/groupnetcamview.cpp \ - src/core/toxcall.cpp + src/core/toxcall.cpp \ + src/widget/about/aboutuser.cpp HEADERS += \ src/audio/audio.h \ @@ -555,4 +557,5 @@ HEADERS += \ src/video/genericnetcamview.h \ src/video/groupnetcamview.h \ src/core/indexedlist.h \ - src/core/toxcall.h + src/core/toxcall.h \ + src/widget/about/aboutuser.h From 08212ad7810bbc7eba752929ec121e2e66bb9b23 Mon Sep 17 00:00:00 2001 From: agilob Date: Mon, 9 Nov 2015 20:56:22 +0000 Subject: [PATCH 05/17] Add about window classes --- src/widget/about/aboutuser.cpp | 45 +++++++ src/widget/about/aboutuser.h | 32 +++++ src/widget/about/aboutuser.ui | 214 +++++++++++++++++++++++++++++++++ 3 files changed, 291 insertions(+) create mode 100644 src/widget/about/aboutuser.cpp create mode 100644 src/widget/about/aboutuser.h create mode 100644 src/widget/about/aboutuser.ui diff --git a/src/widget/about/aboutuser.cpp b/src/widget/about/aboutuser.cpp new file mode 100644 index 000000000..7699913f2 --- /dev/null +++ b/src/widget/about/aboutuser.cpp @@ -0,0 +1,45 @@ +#include "aboutuser.h" +#include "ui_aboutuser.h" +#include "src/persistence/settings.h" + +AboutUser::AboutUser(QWidget *parent) : + QDialog(parent), + ui(new Ui::AboutUser) +{ + ui->setupUi(this); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked); +} + +void AboutUser::setFriend(Friend *f) +{ + this->setWindowTitle(f->getDisplayedName()); + ui->userName->setText(f->getDisplayedName()); + ui->publicKey->setText(QString(f->getToxId().toString())); + ui->note->setPlainText(Settings::getInstance().getContactNote(f->getToxId())); +} + +void AboutUser::setAvatar(QPixmap pixmap) +{ + ui->avatar->setPixmap(pixmap); +} + +void AboutUser::setStatusMessage(QString statusMessage) +{ + ui->statusMessage->setText(statusMessage); +} + +void AboutUser::setToxId(ToxId &id) +{ + this->toxId = id; +} + +void AboutUser::onAcceptedClicked() +{ + Settings::getInstance().setContactNote(ui->publicKey->text(), ui->note->toPlainText()); + Settings::getInstance().saveGlobal(); +} + +AboutUser::~AboutUser() +{ + delete ui; +} diff --git a/src/widget/about/aboutuser.h b/src/widget/about/aboutuser.h new file mode 100644 index 000000000..150d95b38 --- /dev/null +++ b/src/widget/about/aboutuser.h @@ -0,0 +1,32 @@ +#ifndef ABOUTUSER_H +#define ABOUTUSER_H + +#include +#include "src/friend.h" + + +namespace Ui { +class AboutUser; +} + +class AboutUser : public QDialog +{ + Q_OBJECT + +public: + explicit AboutUser(QWidget *parent = 0); + ~AboutUser(); + void setFriend(Friend *f); + void setToxId(ToxId &id); + void setAvatar(QPixmap pixmap); + void setStatusMessage(QString statusMessage); + +private: + Ui::AboutUser *ui; + ToxId toxId; + +private slots: + void onAcceptedClicked(); +}; + +#endif // ABOUTUSER_H diff --git a/src/widget/about/aboutuser.ui b/src/widget/about/aboutuser.ui new file mode 100644 index 000000000..68126d1de --- /dev/null +++ b/src/widget/about/aboutuser.ui @@ -0,0 +1,214 @@ + + + AboutUser + + + + 0 + 0 + 465 + 394 + + + + Dialog + + + + + + + + + + + + username + + + Qt::PlainText + + + + + + + + 0 + 0 + + + + status message + + + Qt::PlainText + + + + + + + + + + 0 + 0 + + + + + 50 + 50 + + + + AVATAR + + + Qt::PlainText + + + true + + + + + + + + + + + + + Qt::LeftToRight + + + Public key + + + + + + + true + + + false + + + false + + + true + + + Qt::LogicalMoveStyle + + + + + + + Used aliases + + + + + + + HISTORY OF ALIASES + + + Qt::PlainText + + + + + + + Auto accept files + + + + + + + Remove history + + + + + + + Files save directory + + + + + + + + + Notes + + + + + + PLAIN TEXT EDIT + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + AboutUser + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AboutUser + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From ad5301eef756eeb34503e096ec1028910395b9fd Mon Sep 17 00:00:00 2001 From: agilob Date: Thu, 12 Nov 2015 20:33:57 +0000 Subject: [PATCH 06/17] Improve layout in aboutUser window --- src/widget/about/aboutuser.ui | 44 +++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/widget/about/aboutuser.ui b/src/widget/about/aboutuser.ui index 68126d1de..484617d54 100644 --- a/src/widget/about/aboutuser.ui +++ b/src/widget/about/aboutuser.ui @@ -79,13 +79,16 @@ + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Qt::LeftToRight - Public key + Public key: @@ -111,7 +114,7 @@ - Used aliases + Used aliases: @@ -125,29 +128,36 @@ - + + + + SELECT DIR + + + + + + + Default directory to save files: + + + + Auto accept files - - - - Remove history - - - - - - - Files save directory - - - + + + + Remove history (operation can not be undone!) + + + From a148e4dc5eec0e0630121e50fd132ca94b2a8ab0 Mon Sep 17 00:00:00 2001 From: agilob Date: Thu, 12 Nov 2015 21:13:37 +0000 Subject: [PATCH 07/17] Improve avatar quality in aboutUser window --- src/widget/about/aboutuser.cpp | 17 +++++++---------- src/widget/about/aboutuser.h | 2 -- src/widget/about/aboutuser.ui | 34 +++++++++++++++++++++++++++++----- src/widget/friendwidget.cpp | 2 -- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/widget/about/aboutuser.cpp b/src/widget/about/aboutuser.cpp index 7699913f2..d22cb12c5 100644 --- a/src/widget/about/aboutuser.cpp +++ b/src/widget/about/aboutuser.cpp @@ -16,16 +16,13 @@ void AboutUser::setFriend(Friend *f) ui->userName->setText(f->getDisplayedName()); ui->publicKey->setText(QString(f->getToxId().toString())); ui->note->setPlainText(Settings::getInstance().getContactNote(f->getToxId())); -} - -void AboutUser::setAvatar(QPixmap pixmap) -{ - ui->avatar->setPixmap(pixmap); -} - -void AboutUser::setStatusMessage(QString statusMessage) -{ - ui->statusMessage->setText(statusMessage); + 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::setToxId(ToxId &id) diff --git a/src/widget/about/aboutuser.h b/src/widget/about/aboutuser.h index 150d95b38..81e0f99eb 100644 --- a/src/widget/about/aboutuser.h +++ b/src/widget/about/aboutuser.h @@ -18,8 +18,6 @@ public: ~AboutUser(); void setFriend(Friend *f); void setToxId(ToxId &id); - void setAvatar(QPixmap pixmap); - void setStatusMessage(QString statusMessage); private: Ui::AboutUser *ui; diff --git a/src/widget/about/aboutuser.ui b/src/widget/about/aboutuser.ui index 484617d54..c38da602e 100644 --- a/src/widget/about/aboutuser.ui +++ b/src/widget/about/aboutuser.ui @@ -38,8 +38,11 @@ 0 + + false + - status message + Qt::PlainText @@ -58,16 +61,25 @@ - 50 - 50 + 40 + 40 + + + + + 40 + 40 - AVATAR + Qt::PlainText + + ../../../img/contact_dark.svg + true @@ -103,6 +115,15 @@ false + + + + + + + + 0 + true @@ -167,7 +188,10 @@ - PLAIN TEXT EDIT + + + + You can save comment about this contact here. diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp index 0b1ecc4ef..a2b3a1bfe 100644 --- a/src/widget/friendwidget.cpp +++ b/src/widget/friendwidget.cpp @@ -205,8 +205,6 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) AboutUser *aboutUser = new AboutUser(this); aboutUser->setFriend(FriendList::findFriend(friendId)); aboutUser->setToxId(id); - aboutUser->setAvatar(avatar->getPixmap()); - aboutUser->setStatusMessage(FriendList::findFriend(friendId)->getStatusMessage()); aboutUser->show(); } else if (selectedItem == newCircleAction) From b85e12b0fc55dbcb349ab1443e7612a615a7a39e Mon Sep 17 00:00:00 2001 From: agilob Date: Thu, 12 Nov 2015 21:30:54 +0000 Subject: [PATCH 08/17] Make autoaccept per user work from aboutUser window --- src/widget/about/aboutuser.cpp | 28 +++++++++++++++++++++++++++- src/widget/about/aboutuser.h | 1 + src/widget/about/aboutuser.ui | 2 +- src/widget/friendwidget.cpp | 3 +-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/widget/about/aboutuser.cpp b/src/widget/about/aboutuser.cpp index d22cb12c5..0a532df82 100644 --- a/src/widget/about/aboutuser.cpp +++ b/src/widget/about/aboutuser.cpp @@ -2,12 +2,16 @@ #include "ui_aboutuser.h" #include "src/persistence/settings.h" +#include +#include + AboutUser::AboutUser(QWidget *parent) : QDialog(parent), ui(new Ui::AboutUser) { ui->setupUi(this); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked); + connect(ui->autoaccept, &QCheckBox::clicked, this, &AboutUser::onAutoAcceptClicked); } void AboutUser::setFriend(Friend *f) @@ -21,13 +25,16 @@ void AboutUser::setFriend(Friend *f) if(!avatar.isNull()) { ui->avatar->setPixmap(avatar); } else { - ui->avatar->setPixmap(QPixmap("://img/contact_dark.svg")); + ui->avatar->setPixmap(QPixmap(":/img/contact_dark.svg")); } + } void AboutUser::setToxId(ToxId &id) { this->toxId = id; + QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId); + ui->autoaccept->setChecked(!dir.isEmpty()); } void AboutUser::onAcceptedClicked() @@ -36,6 +43,25 @@ void AboutUser::onAcceptedClicked() Settings::getInstance().saveGlobal(); } +void AboutUser::onAutoAcceptClicked() +{ + QString dir; + if (!ui->autoaccept->isChecked()) + { + dir = QDir::homePath(); + ui->autoaccept->setChecked(false); + Settings::getInstance().setAutoAcceptDir(this->toxId, ""); + } + else if (ui->autoaccept->isChecked()) + { + 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(); +} + AboutUser::~AboutUser() { delete ui; diff --git a/src/widget/about/aboutuser.h b/src/widget/about/aboutuser.h index 81e0f99eb..c27e7c469 100644 --- a/src/widget/about/aboutuser.h +++ b/src/widget/about/aboutuser.h @@ -25,6 +25,7 @@ private: private slots: void onAcceptedClicked(); + void onAutoAcceptClicked(); }; #endif // ABOUTUSER_H diff --git a/src/widget/about/aboutuser.ui b/src/widget/about/aboutuser.ui index c38da602e..3ebaec494 100644 --- a/src/widget/about/aboutuser.ui +++ b/src/widget/about/aboutuser.ui @@ -42,7 +42,7 @@ false - + status message Qt::PlainText diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp index a2b3a1bfe..807ad3d78 100644 --- a/src/widget/friendwidget.cpp +++ b/src/widget/friendwidget.cpp @@ -192,8 +192,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) autoAccept->setChecked(false); Settings::getInstance().setAutoAcceptDir(id, ""); } - - if (autoAccept->isChecked()) + else if (autoAccept->isChecked()) { dir = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"), dir); autoAccept->setChecked(true); From 8d1197903c51a043d61f3490360d275dcec34508 Mon Sep 17 00:00:00 2001 From: agilob Date: Thu, 12 Nov 2015 21:46:43 +0000 Subject: [PATCH 09/17] Make dir chooser work in aboutUser, code cleanup --- src/widget/about/aboutuser.cpp | 45 +++++++++++++++++++++++----------- src/widget/about/aboutuser.h | 4 +-- src/widget/about/aboutuser.ui | 18 +++++++------- src/widget/friendwidget.cpp | 3 +-- 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/widget/about/aboutuser.cpp b/src/widget/about/aboutuser.cpp index 0a532df82..0da896920 100644 --- a/src/widget/about/aboutuser.cpp +++ b/src/widget/about/aboutuser.cpp @@ -5,13 +5,19 @@ #include #include -AboutUser::AboutUser(QWidget *parent) : +AboutUser::AboutUser(ToxId &toxId, QWidget *parent) : QDialog(parent), ui(new Ui::AboutUser) { ui->setupUi(this); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked); connect(ui->autoaccept, &QCheckBox::clicked, this, &AboutUser::onAutoAcceptClicked); + connect(ui->selectSaveDir, &QPushButton::clicked, this, &AboutUser::onSelectDirClicked); + + this->toxId = toxId; + QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId); + ui->autoaccept->setChecked(!dir.isEmpty()); + ui->selectSaveDir->setEnabled(ui->autoaccept->isChecked()); } void AboutUser::setFriend(Friend *f) @@ -20,6 +26,7 @@ void AboutUser::setFriend(Friend *f) ui->userName->setText(f->getDisplayedName()); ui->publicKey->setText(QString(f->getToxId().toString())); ui->note->setPlainText(Settings::getInstance().getContactNote(f->getToxId())); + QPixmap avatar = Settings::getInstance().getSavedAvatar(f->getToxId().toString()); ui->statusMessage->setText(f->getStatusMessage()); if(!avatar.isNull()) { @@ -30,19 +37,6 @@ void AboutUser::setFriend(Friend *f) } -void AboutUser::setToxId(ToxId &id) -{ - this->toxId = id; - QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId); - ui->autoaccept->setChecked(!dir.isEmpty()); -} - -void AboutUser::onAcceptedClicked() -{ - Settings::getInstance().setContactNote(ui->publicKey->text(), ui->note->toPlainText()); - Settings::getInstance().saveGlobal(); -} - void AboutUser::onAutoAcceptClicked() { QString dir; @@ -51,6 +45,7 @@ void AboutUser::onAutoAcceptClicked() dir = QDir::homePath(); ui->autoaccept->setChecked(false); Settings::getInstance().setAutoAcceptDir(this->toxId, ""); + ui->selectSaveDir->setText("Auto accept for this contact is disabled"); } else if (ui->autoaccept->isChecked()) { @@ -58,8 +53,30 @@ void AboutUser::onAutoAcceptClicked() "popup title"), dir); ui->autoaccept->setChecked(true); 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(); } AboutUser::~AboutUser() diff --git a/src/widget/about/aboutuser.h b/src/widget/about/aboutuser.h index c27e7c469..d54ee3cd3 100644 --- a/src/widget/about/aboutuser.h +++ b/src/widget/about/aboutuser.h @@ -14,10 +14,9 @@ class AboutUser : public QDialog Q_OBJECT public: - explicit AboutUser(QWidget *parent = 0); + explicit AboutUser(ToxId &toxID, QWidget *parent = 0); ~AboutUser(); void setFriend(Friend *f); - void setToxId(ToxId &id); private: Ui::AboutUser *ui; @@ -26,6 +25,7 @@ private: private slots: void onAcceptedClicked(); void onAutoAcceptClicked(); + void onSelectDirClicked(); }; #endif // ABOUTUSER_H diff --git a/src/widget/about/aboutuser.ui b/src/widget/about/aboutuser.ui index 3ebaec494..9cc34c2ee 100644 --- a/src/widget/about/aboutuser.ui +++ b/src/widget/about/aboutuser.ui @@ -149,27 +149,27 @@ - - - - SELECT DIR - - - - + Default directory to save files: - + Auto accept files + + + + Auto accept for this contact is disabled + + + diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp index 807ad3d78..582831db9 100644 --- a/src/widget/friendwidget.cpp +++ b/src/widget/friendwidget.cpp @@ -201,9 +201,8 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) } } else if (selectedItem == aboutWindow) { - AboutUser *aboutUser = new AboutUser(this); + AboutUser *aboutUser = new AboutUser(id, this); aboutUser->setFriend(FriendList::findFriend(friendId)); - aboutUser->setToxId(id); aboutUser->show(); } else if (selectedItem == newCircleAction) From d3548f7a80f2d9f5d4bb9168de490180980f83dd Mon Sep 17 00:00:00 2001 From: agilob Date: Thu, 12 Nov 2015 21:49:27 +0000 Subject: [PATCH 10/17] Resize avatar in aboutUser to 75x75 --- src/widget/about/aboutuser.ui | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/widget/about/aboutuser.ui b/src/widget/about/aboutuser.ui index 9cc34c2ee..e47ecbac3 100644 --- a/src/widget/about/aboutuser.ui +++ b/src/widget/about/aboutuser.ui @@ -28,6 +28,9 @@ Qt::PlainText + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + @@ -47,6 +50,9 @@ Qt::PlainText + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + @@ -61,14 +67,14 @@ - 40 - 40 + 75 + 75 - 40 - 40 + 75 + 75 From 6d440e9c8cc354e318e7568e5447228d7a74a847 Mon Sep 17 00:00:00 2001 From: agilob Date: Thu, 12 Nov 2015 21:51:43 +0000 Subject: [PATCH 11/17] Minor UI fix --- src/widget/about/aboutuser.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widget/about/aboutuser.cpp b/src/widget/about/aboutuser.cpp index 0da896920..79e22e89d 100644 --- a/src/widget/about/aboutuser.cpp +++ b/src/widget/about/aboutuser.cpp @@ -18,6 +18,9 @@ AboutUser::AboutUser(ToxId &toxId, QWidget *parent) : 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) @@ -53,7 +56,7 @@ void AboutUser::onAutoAcceptClicked() "popup title"), dir); ui->autoaccept->setChecked(true); Settings::getInstance().setAutoAcceptDir(this->toxId, dir); - ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId)); + ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId)); } Settings::getInstance().saveGlobal(); ui->selectSaveDir->setEnabled(ui->autoaccept->isChecked()); From 09405f24934dd5e432812849974ddf0d4e18259f Mon Sep 17 00:00:00 2001 From: agilob Date: Thu, 12 Nov 2015 21:52:54 +0000 Subject: [PATCH 12/17] Scroll public key to left after creation in aboutUser --- src/widget/about/aboutuser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widget/about/aboutuser.cpp b/src/widget/about/aboutuser.cpp index 79e22e89d..fe89c0e5a 100644 --- a/src/widget/about/aboutuser.cpp +++ b/src/widget/about/aboutuser.cpp @@ -28,6 +28,7 @@ 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()); From 53f119b8e43b99dd0fef503df257dc20bd468b9b Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 14 Nov 2015 19:08:55 +0000 Subject: [PATCH 13/17] Fix button status after cancelling dir picker --- src/widget/about/aboutuser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/widget/about/aboutuser.cpp b/src/widget/about/aboutuser.cpp index fe89c0e5a..e6bfe8a76 100644 --- a/src/widget/about/aboutuser.cpp +++ b/src/widget/about/aboutuser.cpp @@ -49,13 +49,17 @@ void AboutUser::onAutoAcceptClicked() dir = QDir::homePath(); ui->autoaccept->setChecked(false); Settings::getInstance().setAutoAcceptDir(this->toxId, ""); - ui->selectSaveDir->setText("Auto accept for this contact is disabled"); + 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); - ui->autoaccept->setChecked(true); + if(dir.isEmpty()) + { + ui->autoaccept->setChecked(false); + return; // user canellced + } Settings::getInstance().setAutoAcceptDir(this->toxId, dir); ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId)); } From 734faa8a1f49bb77bc8e5c5d2a29b31afc42c1d5 Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 14 Nov 2015 19:10:41 +0000 Subject: [PATCH 14/17] Fix status message spacing in aboutUser --- src/widget/about/aboutuser.ui | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/widget/about/aboutuser.ui b/src/widget/about/aboutuser.ui index e47ecbac3..5fcafb074 100644 --- a/src/widget/about/aboutuser.ui +++ b/src/widget/about/aboutuser.ui @@ -7,7 +7,7 @@ 0 0 465 - 394 + 406 @@ -33,7 +33,7 @@ - + @@ -162,13 +162,6 @@ - - - - Auto accept files - - - @@ -176,6 +169,13 @@ + + + + Auto accept files + + + From e6504f2d46ae9c4f8a358e5269c4c52ae2255b1d Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 5 Dec 2015 12:14:31 +0000 Subject: [PATCH 15/17] Support removing history with user in about window --- src/widget/about/aboutuser.cpp | 13 +++++++++++++ src/widget/about/aboutuser.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/widget/about/aboutuser.cpp b/src/widget/about/aboutuser.cpp index e6bfe8a76..2bf554fa5 100644 --- a/src/widget/about/aboutuser.cpp +++ b/src/widget/about/aboutuser.cpp @@ -1,9 +1,11 @@ #include "aboutuser.h" #include "ui_aboutuser.h" #include "src/persistence/settings.h" +#include "src/persistence/historykeeper.h" #include #include +#include AboutUser::AboutUser(ToxId &toxId, QWidget *parent) : QDialog(parent), @@ -13,6 +15,7 @@ AboutUser::AboutUser(ToxId &toxId, QWidget *parent) : 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); @@ -87,6 +90,16 @@ void AboutUser::onAcceptedClicked() 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; diff --git a/src/widget/about/aboutuser.h b/src/widget/about/aboutuser.h index d54ee3cd3..b206b0395 100644 --- a/src/widget/about/aboutuser.h +++ b/src/widget/about/aboutuser.h @@ -26,6 +26,7 @@ private slots: void onAcceptedClicked(); void onAutoAcceptClicked(); void onSelectDirClicked(); + void onRemoveHistoryClicked(); }; #endif // ABOUTUSER_H From 56ae9e657f584f186d0cce2cde514a8c2c43f57a Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 5 Dec 2015 12:19:05 +0000 Subject: [PATCH 16/17] Hide label and list of aliases in aboutuser --- src/widget/about/aboutuser.cpp | 3 +++ src/widget/about/aboutuser.ui | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widget/about/aboutuser.cpp b/src/widget/about/aboutuser.cpp index 2bf554fa5..93eb66cbc 100644 --- a/src/widget/about/aboutuser.cpp +++ b/src/widget/about/aboutuser.cpp @@ -12,6 +12,9 @@ AboutUser::AboutUser(ToxId &toxId, QWidget *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); diff --git a/src/widget/about/aboutuser.ui b/src/widget/about/aboutuser.ui index 5fcafb074..d098ac193 100644 --- a/src/widget/about/aboutuser.ui +++ b/src/widget/about/aboutuser.ui @@ -146,7 +146,7 @@ - + HISTORY OF ALIASES From 84814e28e3e0e499507f28da54b29f3c1b5918cf Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 5 Dec 2015 14:18:43 +0000 Subject: [PATCH 17/17] Set widget as parent for AboutUser window to fix style inheriting --- src/widget/friendwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp index 582831db9..59cf07522 100644 --- a/src/widget/friendwidget.cpp +++ b/src/widget/friendwidget.cpp @@ -201,7 +201,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) } } else if (selectedItem == aboutWindow) { - AboutUser *aboutUser = new AboutUser(id, this); + AboutUser *aboutUser = new AboutUser(id, Widget::getInstance()); aboutUser->setFriend(FriendList::findFriend(friendId)); aboutUser->show(); }