mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr790'
This commit is contained in:
commit
83de276fe1
|
@ -18,6 +18,8 @@
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "misc/settings.h"
|
#include "misc/settings.h"
|
||||||
#include "misc/style.h"
|
#include "misc/style.h"
|
||||||
|
#include "src/friendlist.h"
|
||||||
|
#include "src/friend.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -208,7 +210,7 @@ bool isFileWritable(QString& path)
|
||||||
|
|
||||||
void FileTransferInstance::acceptRecvRequest()
|
void FileTransferInstance::acceptRecvRequest()
|
||||||
{
|
{
|
||||||
QString path = Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(friendId));
|
QString path = Settings::getInstance().getAutoAcceptDir(FriendList::findFriend(friendId)->getToxID());
|
||||||
|
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
path = Settings::getInstance().getGlobalAutoAcceptDir();
|
path = Settings::getInstance().getGlobalAutoAcceptDir();
|
||||||
|
|
|
@ -98,13 +98,14 @@ void Settings::load()
|
||||||
|
|
||||||
friendLst.clear();
|
friendLst.clear();
|
||||||
s.beginGroup("Friends");
|
s.beginGroup("Friends");
|
||||||
int size = s.beginReadArray("fullAddresses");
|
int size = s.beginReadArray("Friend");
|
||||||
for (int i = 0; i < size; i ++)
|
for (int i = 0; i < size; i ++)
|
||||||
{
|
{
|
||||||
s.setArrayIndex(i);
|
s.setArrayIndex(i);
|
||||||
friendProp fp;
|
friendProp fp;
|
||||||
fp.addr = s.value("addr").toString();
|
fp.addr = s.value("addr").toString();
|
||||||
fp.alias = s.value("alias").toString();
|
fp.alias = s.value("alias").toString();
|
||||||
|
fp.autoAcceptDir = s.value("autoAcceptDir").toString();
|
||||||
friendLst[ToxID::fromString(fp.addr).publicKey] = fp;
|
friendLst[ToxID::fromString(fp.addr).publicKey] = fp;
|
||||||
}
|
}
|
||||||
s.endArray();
|
s.endArray();
|
||||||
|
@ -126,6 +127,10 @@ void Settings::load()
|
||||||
checkUpdates = s.value("checkUpdates", false).toBool();
|
checkUpdates = s.value("checkUpdates", false).toBool();
|
||||||
showInFront = s.value("showInFront", false).toBool();
|
showInFront = s.value("showInFront", false).toBool();
|
||||||
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
|
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
|
||||||
|
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
|
||||||
|
globalAutoAcceptDir = s.value("globalAutoAcceptDir",
|
||||||
|
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
|
||||||
|
).toString();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Advanced");
|
s.beginGroup("Advanced");
|
||||||
|
@ -178,16 +183,6 @@ void Settings::load()
|
||||||
encryptTox = s.value("encryptTox", false).toBool();
|
encryptTox = s.value("encryptTox", false).toBool();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("AutoAccept");
|
|
||||||
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
|
|
||||||
globalAutoAcceptDir = s.value("globalAutoAcceptDir",
|
|
||||||
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
|
|
||||||
).toString();
|
|
||||||
|
|
||||||
for (auto& key : s.childKeys())
|
|
||||||
autoAccept[key] = s.value(key).toString();
|
|
||||||
s.endGroup();
|
|
||||||
|
|
||||||
s.beginGroup("Audio");
|
s.beginGroup("Audio");
|
||||||
inDev = s.value("inDev", "").toString();
|
inDev = s.value("inDev", "").toString();
|
||||||
outDev = s.value("outDev", "").toString();
|
outDev = s.value("outDev", "").toString();
|
||||||
|
@ -244,13 +239,14 @@ void Settings::save(QString path)
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Friends");
|
s.beginGroup("Friends");
|
||||||
s.beginWriteArray("fullAddresses", friendLst.size());
|
s.beginWriteArray("Friend", friendLst.size());
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (auto &frnd : friendLst)
|
for (auto &frnd : friendLst)
|
||||||
{
|
{
|
||||||
s.setArrayIndex(index);
|
s.setArrayIndex(index);
|
||||||
s.setValue("addr", frnd.addr);
|
s.setValue("addr", frnd.addr);
|
||||||
s.setValue("alias", frnd.alias);
|
s.setValue("alias", frnd.alias);
|
||||||
|
s.setValue("autoAcceptDir", frnd.autoAcceptDir);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
s.endArray();
|
s.endArray();
|
||||||
|
@ -272,6 +268,8 @@ void Settings::save(QString path)
|
||||||
s.setValue("checkUpdates", checkUpdates);
|
s.setValue("checkUpdates", checkUpdates);
|
||||||
s.setValue("showInFront", showInFront);
|
s.setValue("showInFront", showInFront);
|
||||||
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
||||||
|
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
||||||
|
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Advanced");
|
s.beginGroup("Advanced");
|
||||||
|
@ -316,13 +314,6 @@ void Settings::save(QString path)
|
||||||
s.setValue("encryptTox", encryptTox);
|
s.setValue("encryptTox", encryptTox);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("AutoAccept");
|
|
||||||
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
|
||||||
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
|
||||||
for (auto& id : autoAccept.keys())
|
|
||||||
s.setValue(id, autoAccept.value(id));
|
|
||||||
s.endGroup();
|
|
||||||
|
|
||||||
s.beginGroup("Audio");
|
s.beginGroup("Audio");
|
||||||
s.setValue("inDev", inDev);
|
s.setValue("inDev", inDev);
|
||||||
s.setValue("outDev", outDev);
|
s.setValue("outDev", outDev);
|
||||||
|
@ -634,17 +625,31 @@ void Settings::setAutoAwayTime(int newValue)
|
||||||
autoAwayTime = newValue;
|
autoAwayTime = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getAutoAcceptDir(const QString& id) const
|
QString Settings::getAutoAcceptDir(const ToxID& id) const
|
||||||
{
|
{
|
||||||
return autoAccept.value(id.left(TOX_ID_PUBLIC_KEY_LENGTH));
|
QString key = id.publicKey;
|
||||||
|
|
||||||
|
auto it = friendLst.find(key);
|
||||||
|
if (it != friendLst.end())
|
||||||
|
{
|
||||||
|
return it->autoAcceptDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setAutoAcceptDir(const QString& id, const QString& dir)
|
void Settings::setAutoAcceptDir(const ToxID &id, const QString& dir)
|
||||||
{
|
{
|
||||||
if (dir.isEmpty())
|
QString key = id.publicKey;
|
||||||
autoAccept.remove(id.left(TOX_ID_PUBLIC_KEY_LENGTH));
|
|
||||||
else
|
auto it = friendLst.find(key);
|
||||||
autoAccept[id.left(TOX_ID_PUBLIC_KEY_LENGTH)] = dir;
|
if (it != friendLst.end())
|
||||||
|
{
|
||||||
|
it->autoAcceptDir = dir;
|
||||||
|
} else {
|
||||||
|
updateFriendAdress(id.toString());
|
||||||
|
setAutoAcceptDir(id, dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getGlobalAutoAcceptDir() const
|
QString Settings::getGlobalAutoAcceptDir() const
|
||||||
|
@ -865,6 +870,7 @@ void Settings::updateFriendAdress(const QString &newAddr)
|
||||||
friendProp fp;
|
friendProp fp;
|
||||||
fp.addr = newAddr;
|
fp.addr = newAddr;
|
||||||
fp.alias = "";
|
fp.alias = "";
|
||||||
|
fp.autoAcceptDir = "";
|
||||||
friendLst[newAddr] = fp;
|
friendLst[newAddr] = fp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -892,6 +898,7 @@ void Settings::setFriendAlias(const ToxID &id, const QString &alias)
|
||||||
friendProp fp;
|
friendProp fp;
|
||||||
fp.addr = key;
|
fp.addr = key;
|
||||||
fp.alias = alias;
|
fp.alias = alias;
|
||||||
|
fp.autoAcceptDir = "";
|
||||||
friendLst[key] = fp;
|
friendLst[key] = fp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,8 +164,8 @@ public:
|
||||||
int getEmojiFontPointSize() const;
|
int getEmojiFontPointSize() const;
|
||||||
void setEmojiFontPointSize(int value);
|
void setEmojiFontPointSize(int value);
|
||||||
|
|
||||||
QString getAutoAcceptDir(const QString& id) const;
|
QString getAutoAcceptDir(const ToxID& id) const;
|
||||||
void setAutoAcceptDir(const QString&id, const QString& dir);
|
void setAutoAcceptDir(const ToxID&id, const QString& dir);
|
||||||
|
|
||||||
QString getGlobalAutoAcceptDir() const;
|
QString getGlobalAutoAcceptDir() const;
|
||||||
void setGlobalAutoAcceptDir(const QString& dir);
|
void setGlobalAutoAcceptDir(const QString& dir);
|
||||||
|
@ -295,6 +295,7 @@ private:
|
||||||
{
|
{
|
||||||
QString alias;
|
QString alias;
|
||||||
QString addr;
|
QString addr;
|
||||||
|
QString autoAcceptDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
QHash<QString, friendProp> friendLst;
|
QHash<QString, friendProp> friendLst;
|
||||||
|
|
|
@ -217,7 +217,7 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
||||||
chatWidget->insertMessage(ChatActionPtr(new FileTransferAction(fileTrans, getElidedName(name),
|
chatWidget->insertMessage(ChatActionPtr(new FileTransferAction(fileTrans, getElidedName(name),
|
||||||
QTime::currentTime().toString("hh:mm"), false)));
|
QTime::currentTime().toString("hh:mm"), false)));
|
||||||
|
|
||||||
if (!Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(f->getFriendID())).isEmpty()
|
if (!Settings::getInstance().getAutoAcceptDir(f->getToxID()).isEmpty()
|
||||||
|| Settings::getInstance().getAutoSaveEnabled())
|
|| Settings::getInstance().getAutoSaveEnabled())
|
||||||
fileTrans->pressFromHtml("btnB");
|
fileTrans->pressFromHtml("btnB");
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ 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);
|
ToxID id = FriendList::findFriend(friendId)->getToxID();
|
||||||
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
QMenu* inviteMenu = menu.addMenu(tr("Invite to group","Menu to invite a friend to a groupchat"));
|
QMenu* inviteMenu = menu.addMenu(tr("Invite to group","Menu to invite a friend to a groupchat"));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user