mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
3dbbbca587
commit
43ac1dfd0d
|
@ -498,6 +498,9 @@ QString Settings::getAutoAcceptDir(const QString& id) const
|
||||||
|
|
||||||
void Settings::setAutoAcceptDir(const QString& id, const QString& dir)
|
void Settings::setAutoAcceptDir(const QString& id, const QString& dir)
|
||||||
{
|
{
|
||||||
|
if (dir.isEmpty())
|
||||||
|
autoAccept.remove(id.left(TOX_ID_PUBLIC_KEY_LENGTH));
|
||||||
|
else
|
||||||
autoAccept[id.left(TOX_ID_PUBLIC_KEY_LENGTH)] = dir;
|
autoAccept[id.left(TOX_ID_PUBLIC_KEY_LENGTH)] = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,15 @@
|
||||||
#include "maskablepixmapwidget.h"
|
#include "maskablepixmapwidget.h"
|
||||||
#include "croppinglabel.h"
|
#include "croppinglabel.h"
|
||||||
#include "src/misc/style.h"
|
#include "src/misc/style.h"
|
||||||
|
#include "src/misc/settings.h"
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
FriendWidget::FriendWidget(int FriendId, QString id)
|
FriendWidget::FriendWidget(int FriendId, QString id)
|
||||||
: friendId(FriendId)
|
: friendId(FriendId)
|
||||||
|
@ -44,6 +47,8 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
||||||
void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
{
|
{
|
||||||
QPoint pos = event->globalPos();
|
QPoint pos = event->globalPos();
|
||||||
|
QString id = Core::getInstance()->getFriendAddress(friendId);
|
||||||
|
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
QAction* copyId = menu.addAction(tr("Copy friend ID","Menu to copy the Tox ID of that friend"));
|
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"));
|
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())
|
if (groupActions.isEmpty())
|
||||||
inviteMenu->setEnabled(false);
|
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();
|
menu.addSeparator();
|
||||||
QAction* removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist"));
|
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);
|
emit removeFriend(friendId);
|
||||||
return;
|
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))
|
else if (groupActions.contains(selectedItem))
|
||||||
{
|
{
|
||||||
Group* group = groupActions[selectedItem];
|
Group* group = groupActions[selectedItem];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user