mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
global autoaccept files
This commit is contained in:
parent
7372fe5314
commit
c702e18ccf
|
@ -209,7 +209,10 @@ bool isFileWritable(QString& path)
|
||||||
void FileTransferInstance::acceptRecvRequest()
|
void FileTransferInstance::acceptRecvRequest()
|
||||||
{
|
{
|
||||||
QString path = Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(friendId));
|
QString path = Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(friendId));
|
||||||
if (path.isEmpty()) path = Settings::getInstance().getGlobalAutoAcceptDir();
|
|
||||||
|
if (path.isEmpty())
|
||||||
|
path = Settings::getInstance().getGlobalAutoAcceptDir();
|
||||||
|
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
{
|
{
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
|
|
|
@ -114,8 +114,6 @@ void Settings::load()
|
||||||
proxyPort = s.value("proxyPort", 0).toInt();
|
proxyPort = s.value("proxyPort", 0).toInt();
|
||||||
currentProfile = s.value("currentProfile", "").toString();
|
currentProfile = s.value("currentProfile", "").toString();
|
||||||
autoAwayTime = s.value("autoAwayTime", 10).toInt();
|
autoAwayTime = s.value("autoAwayTime", 10).toInt();
|
||||||
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
|
|
||||||
autoSaveDir = s.value("autoSaveDir", QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)).toString();
|
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Widgets");
|
s.beginGroup("Widgets");
|
||||||
|
@ -156,7 +154,11 @@ void Settings::load()
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("AutoAccept");
|
s.beginGroup("AutoAccept");
|
||||||
globalAutoAcceptDir = s.value("globalAutoAcceptDir", "").toString();
|
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
|
||||||
|
globalAutoAcceptDir = s.value("globalAutoAcceptDir",
|
||||||
|
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
|
||||||
|
).toString();
|
||||||
|
|
||||||
for (auto& key : s.childKeys())
|
for (auto& key : s.childKeys())
|
||||||
autoAccept[key] = s.value(key).toString();
|
autoAccept[key] = s.value(key).toString();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
@ -241,8 +243,6 @@ void Settings::save(QString path)
|
||||||
s.setValue("proxyPort", proxyPort);
|
s.setValue("proxyPort", proxyPort);
|
||||||
s.setValue("currentProfile", currentProfile);
|
s.setValue("currentProfile", currentProfile);
|
||||||
s.setValue("autoAwayTime", autoAwayTime);
|
s.setValue("autoAwayTime", autoAwayTime);
|
||||||
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
|
||||||
s.setValue("autoSaveDir", autoSaveDir);
|
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Widgets");
|
s.beginGroup("Widgets");
|
||||||
|
@ -283,6 +283,7 @@ void Settings::save(QString path)
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("AutoAccept");
|
s.beginGroup("AutoAccept");
|
||||||
|
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
||||||
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
||||||
for (auto& id : autoAccept.keys())
|
for (auto& id : autoAccept.keys())
|
||||||
s.setValue(id, autoAccept.value(id));
|
s.setValue(id, autoAccept.value(id));
|
||||||
|
@ -475,17 +476,6 @@ void Settings::setTranslation(QString newValue)
|
||||||
translation = newValue;
|
translation = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Settings::getAutoSaveFilesDir() const
|
|
||||||
{
|
|
||||||
return autoSaveDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::setAutoSaveFilesDir(QString newValue)
|
|
||||||
{
|
|
||||||
autoSaveDir = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Settings::getForceTCP() const
|
bool Settings::getForceTCP() const
|
||||||
{
|
{
|
||||||
return forceTCP;
|
return forceTCP;
|
||||||
|
|
|
@ -70,9 +70,6 @@ public:
|
||||||
QString getTranslation() const;
|
QString getTranslation() const;
|
||||||
void setTranslation(QString newValue);
|
void setTranslation(QString newValue);
|
||||||
|
|
||||||
QString getAutoSaveFilesDir() const;
|
|
||||||
void setAutoSaveFilesDir(QString newValue);
|
|
||||||
|
|
||||||
void setAutoSaveEnabled(bool newValue);
|
void setAutoSaveEnabled(bool newValue);
|
||||||
bool getAutoSaveEnabled() const;
|
bool getAutoSaveEnabled() const;
|
||||||
|
|
||||||
|
@ -210,13 +207,11 @@ private:
|
||||||
|
|
||||||
bool enableIPv6;
|
bool enableIPv6;
|
||||||
QString translation;
|
QString translation;
|
||||||
QString autoSaveDir;
|
|
||||||
static bool makeToxPortable;
|
static bool makeToxPortable;
|
||||||
bool autostartInTray;
|
bool autostartInTray;
|
||||||
bool closeToTray;
|
bool closeToTray;
|
||||||
bool minimizeToTray;
|
bool minimizeToTray;
|
||||||
bool useEmoticons;
|
bool useEmoticons;
|
||||||
bool autoSaveEnabled;
|
|
||||||
|
|
||||||
bool forceTCP;
|
bool forceTCP;
|
||||||
|
|
||||||
|
@ -234,6 +229,7 @@ private:
|
||||||
|
|
||||||
QHash<QString, QByteArray> widgetSettings;
|
QHash<QString, QByteArray> widgetSettings;
|
||||||
QHash<QString, QString> autoAccept;
|
QHash<QString, QString> autoAccept;
|
||||||
|
bool autoSaveEnabled;
|
||||||
QString globalAutoAcceptDir;
|
QString globalAutoAcceptDir;
|
||||||
|
|
||||||
// GUI
|
// GUI
|
||||||
|
|
|
@ -202,7 +202,7 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
||||||
QTime::currentTime().toString("hh:mm"), false)));
|
QTime::currentTime().toString("hh:mm"), false)));
|
||||||
|
|
||||||
if (!Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(f->friendId)).isEmpty()
|
if (!Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(f->friendId)).isEmpty()
|
||||||
|| !Settings::getInstance().getGlobalAutoAcceptDir().isEmpty())
|
|| Settings::getInstance().getAutoSaveEnabled())
|
||||||
fileTrans->pressFromHtml("btnB");
|
fileTrans->pressFromHtml("btnB");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
||||||
bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
|
bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
|
||||||
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
|
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
|
||||||
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
|
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
|
||||||
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getAutoSaveFilesDir());
|
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir());
|
||||||
|
|
||||||
for (auto entry : SmileyPack::listSmileyPacks())
|
for (auto entry : SmileyPack::listSmileyPacks())
|
||||||
{
|
{
|
||||||
|
@ -172,8 +172,7 @@ void GeneralForm::onEmoticonSizeChanged()
|
||||||
|
|
||||||
void GeneralForm::onTimestampSelected(int index)
|
void GeneralForm::onTimestampSelected(int index)
|
||||||
{
|
{
|
||||||
Settings::getInstance().setTimestampFormat(
|
Settings::getInstance().setTimestampFormat(timeFormats[index]);
|
||||||
bodyUI->timestamp->currentText().split(" ").at(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralForm::onAutoAwayChanged()
|
void GeneralForm::onAutoAwayChanged()
|
||||||
|
@ -199,12 +198,12 @@ void GeneralForm::onAutoAcceptFileChange()
|
||||||
|
|
||||||
void GeneralForm::onAutoSaveDirChange()
|
void GeneralForm::onAutoSaveDirChange()
|
||||||
{
|
{
|
||||||
QString previousDir = Settings::getInstance().getAutoSaveFilesDir();
|
QString previousDir = Settings::getInstance().getGlobalAutoAcceptDir();
|
||||||
QString directory = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"));
|
QString directory = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"));
|
||||||
if(directory.isEmpty())
|
if(directory.isEmpty())
|
||||||
directory = previousDir;
|
directory = previousDir;
|
||||||
|
|
||||||
Settings::getInstance().setAutoSaveFilesDir(directory);
|
Settings::getInstance().setGlobalAutoAcceptDir(directory);
|
||||||
bodyUI->autoSaveFilesDir->setText(directory);
|
bodyUI->autoSaveFilesDir->setText(directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,28 +49,28 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
QPoint pos = event->globalPos();
|
QPoint pos = event->globalPos();
|
||||||
QString id = Core::getInstance()->getFriendAddress(friendId);
|
QString id = Core::getInstance()->getFriendAddress(friendId);
|
||||||
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
||||||
QString globalDir = Settings::getInstance().getGlobalAutoAcceptDir();
|
|
||||||
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"));
|
||||||
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"));
|
||||||
QMap<QAction*, Group*> groupActions;
|
QMap<QAction*, Group*> groupActions;
|
||||||
|
|
||||||
for (Group* group : GroupList::groupList)
|
for (Group* group : GroupList::groupList)
|
||||||
{
|
{
|
||||||
QAction* groupAction = inviteMenu->addAction(group->widget->getName());
|
QAction* groupAction = inviteMenu->addAction(group->widget->getName());
|
||||||
groupActions[groupAction] = group;
|
groupActions[groupAction] = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupActions.isEmpty())
|
if (groupActions.isEmpty())
|
||||||
inviteMenu->setEnabled(false);
|
inviteMenu->setEnabled(false);
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
QAction* autoAccept = menu.addAction(tr("Auto accept files from this friend", "context menu entry"));
|
QAction* autoAccept = menu.addAction(tr("Auto accept files from this friend", "context menu entry"));
|
||||||
QAction* disableAutoAccept = menu.addAction(tr("Manually accept files from this friend", "context menu entry"));
|
QAction* disableAutoAccept = menu.addAction(tr("Manually accept files from this friend", "context menu entry"));
|
||||||
QAction* globalAA = menu.addAction(tr("Auto accept files from all friends", "context menu entry"));
|
|
||||||
QAction* disableGlobalAA = menu.addAction(tr("Disable global auto accept", "context menu entry"));
|
|
||||||
if (dir.isEmpty())
|
if (dir.isEmpty())
|
||||||
disableAutoAccept->setEnabled(false);
|
disableAutoAccept->setEnabled(false);
|
||||||
if (globalDir.isEmpty())
|
|
||||||
disableGlobalAA->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"));
|
||||||
|
|
||||||
QAction* selectedItem = menu.exec(pos);
|
QAction* selectedItem = menu.exec(pos);
|
||||||
|
@ -100,25 +100,6 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
Settings::getInstance().setAutoAcceptDir(id, dir);
|
Settings::getInstance().setAutoAcceptDir(id, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (selectedItem == disableAutoAccept)
|
|
||||||
{
|
|
||||||
Settings::getInstance().setAutoAcceptDir(id, "");
|
|
||||||
}
|
|
||||||
else if (selectedItem == globalAA)
|
|
||||||
{
|
|
||||||
if (globalDir.isEmpty())
|
|
||||||
globalDir = QDir::homePath();
|
|
||||||
globalDir = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"), dir);
|
|
||||||
if (!globalDir.isEmpty())
|
|
||||||
{
|
|
||||||
qDebug() << "FriendWidget: setting global auto accept dir to" << globalDir;
|
|
||||||
Settings::getInstance().setGlobalAutoAcceptDir(globalDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (selectedItem == disableGlobalAA)
|
|
||||||
{
|
|
||||||
Settings::getInstance().setGlobalAutoAcceptDir("");
|
|
||||||
}
|
|
||||||
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