mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
3dbbbca587
commit
43ac1dfd0d
|
@ -496,9 +496,12 @@ QString Settings::getAutoAcceptDir(const QString& id) const
|
|||
return autoAccept.value(id.left(TOX_ID_PUBLIC_KEY_LENGTH));
|
||||
}
|
||||
|
||||
void Settings::setAutoAcceptDir(const QString&id, const QString& dir)
|
||||
void Settings::setAutoAcceptDir(const QString& id, const QString& dir)
|
||||
{
|
||||
autoAccept[id.left(TOX_ID_PUBLIC_KEY_LENGTH)] = dir;
|
||||
if (dir.isEmpty())
|
||||
autoAccept.remove(id.left(TOX_ID_PUBLIC_KEY_LENGTH));
|
||||
else
|
||||
autoAccept[id.left(TOX_ID_PUBLIC_KEY_LENGTH)] = dir;
|
||||
}
|
||||
|
||||
void Settings::setWidgetData(const QString& uniqueName, const QByteArray& data)
|
||||
|
|
|
@ -25,12 +25,15 @@
|
|||
#include "maskablepixmapwidget.h"
|
||||
#include "croppinglabel.h"
|
||||
#include "src/misc/style.h"
|
||||
#include "src/misc/settings.h"
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
#include <QApplication>
|
||||
#include <QBitmap>
|
||||
#include <QFileDialog>
|
||||
#include <QDebug>
|
||||
|
||||
FriendWidget::FriendWidget(int FriendId, QString id)
|
||||
: friendId(FriendId)
|
||||
|
@ -44,6 +47,8 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||
{
|
||||
QPoint pos = event->globalPos();
|
||||
QString id = Core::getInstance()->getFriendAddress(friendId);
|
||||
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
||||
QMenu menu;
|
||||
QAction* copyId = menu.addAction(tr("Copy friend ID","Menu to copy the Tox ID of that friend"));
|
||||
QMenu* inviteMenu = menu.addMenu(tr("Invite in group","Menu to invite a friend in a groupchat"));
|
||||
|
@ -55,6 +60,10 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
}
|
||||
if (groupActions.isEmpty())
|
||||
inviteMenu->setEnabled(false);
|
||||
QAction* autoAccept = menu.addAction(tr("Auto accept files from this friend", "context menu entry"));
|
||||
QAction* disableAutoAccept = menu.addAction(tr("Diasble auto accepting files", "context menu entry"));
|
||||
if (dir.isEmpty())
|
||||
disableAutoAccept->setEnabled(false);
|
||||
menu.addSeparator();
|
||||
QAction* removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist"));
|
||||
|
||||
|
@ -74,6 +83,21 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
emit removeFriend(friendId);
|
||||
return;
|
||||
}
|
||||
else if (selectedItem == autoAccept)
|
||||
{
|
||||
if (dir.isEmpty())
|
||||
dir = QDir::homePath();
|
||||
dir = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"), dir);
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
qDebug() << "FriendWidget: setting auto accept dir for" << friendId << "to" << dir;
|
||||
Settings::getInstance().setAutoAcceptDir(id, dir);
|
||||
}
|
||||
}
|
||||
else if (selectedItem == disableAutoAccept)
|
||||
{
|
||||
Settings::getInstance().setAutoAcceptDir(id, "");
|
||||
}
|
||||
else if (groupActions.contains(selectedItem))
|
||||
{
|
||||
Group* group = groupActions[selectedItem];
|
||||
|
|
Loading…
Reference in New Issue
Block a user