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()
|
||||
{
|
||||
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())
|
||||
{
|
||||
QDir dir(path);
|
||||
|
|
|
@ -114,8 +114,6 @@ void Settings::load()
|
|||
proxyPort = s.value("proxyPort", 0).toInt();
|
||||
currentProfile = s.value("currentProfile", "").toString();
|
||||
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.beginGroup("Widgets");
|
||||
|
@ -156,7 +154,11 @@ void Settings::load()
|
|||
s.endGroup();
|
||||
|
||||
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())
|
||||
autoAccept[key] = s.value(key).toString();
|
||||
s.endGroup();
|
||||
|
@ -241,8 +243,6 @@ void Settings::save(QString path)
|
|||
s.setValue("proxyPort", proxyPort);
|
||||
s.setValue("currentProfile", currentProfile);
|
||||
s.setValue("autoAwayTime", autoAwayTime);
|
||||
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
||||
s.setValue("autoSaveDir", autoSaveDir);
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("Widgets");
|
||||
|
@ -283,6 +283,7 @@ void Settings::save(QString path)
|
|||
s.endGroup();
|
||||
|
||||
s.beginGroup("AutoAccept");
|
||||
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
||||
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
||||
for (auto& id : autoAccept.keys())
|
||||
s.setValue(id, autoAccept.value(id));
|
||||
|
@ -475,17 +476,6 @@ void Settings::setTranslation(QString newValue)
|
|||
translation = newValue;
|
||||
}
|
||||
|
||||
|
||||
QString Settings::getAutoSaveFilesDir() const
|
||||
{
|
||||
return autoSaveDir;
|
||||
}
|
||||
|
||||
void Settings::setAutoSaveFilesDir(QString newValue)
|
||||
{
|
||||
autoSaveDir = newValue;
|
||||
}
|
||||
|
||||
bool Settings::getForceTCP() const
|
||||
{
|
||||
return forceTCP;
|
||||
|
|
|
@ -70,9 +70,6 @@ public:
|
|||
QString getTranslation() const;
|
||||
void setTranslation(QString newValue);
|
||||
|
||||
QString getAutoSaveFilesDir() const;
|
||||
void setAutoSaveFilesDir(QString newValue);
|
||||
|
||||
void setAutoSaveEnabled(bool newValue);
|
||||
bool getAutoSaveEnabled() const;
|
||||
|
||||
|
@ -210,13 +207,11 @@ private:
|
|||
|
||||
bool enableIPv6;
|
||||
QString translation;
|
||||
QString autoSaveDir;
|
||||
static bool makeToxPortable;
|
||||
bool autostartInTray;
|
||||
bool closeToTray;
|
||||
bool minimizeToTray;
|
||||
bool useEmoticons;
|
||||
bool autoSaveEnabled;
|
||||
|
||||
bool forceTCP;
|
||||
|
||||
|
@ -234,6 +229,7 @@ private:
|
|||
|
||||
QHash<QString, QByteArray> widgetSettings;
|
||||
QHash<QString, QString> autoAccept;
|
||||
bool autoSaveEnabled;
|
||||
QString globalAutoAcceptDir;
|
||||
|
||||
// GUI
|
||||
|
|
|
@ -202,7 +202,7 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
|||
QTime::currentTime().toString("hh:mm"), false)));
|
||||
|
||||
if (!Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(f->friendId)).isEmpty()
|
||||
|| !Settings::getInstance().getGlobalAutoAcceptDir().isEmpty())
|
||||
|| Settings::getInstance().getAutoSaveEnabled())
|
||||
fileTrans->pressFromHtml("btnB");
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
|||
bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
|
||||
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
|
||||
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
|
||||
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getAutoSaveFilesDir());
|
||||
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir());
|
||||
|
||||
for (auto entry : SmileyPack::listSmileyPacks())
|
||||
{
|
||||
|
@ -172,8 +172,7 @@ void GeneralForm::onEmoticonSizeChanged()
|
|||
|
||||
void GeneralForm::onTimestampSelected(int index)
|
||||
{
|
||||
Settings::getInstance().setTimestampFormat(
|
||||
bodyUI->timestamp->currentText().split(" ").at(0));
|
||||
Settings::getInstance().setTimestampFormat(timeFormats[index]);
|
||||
}
|
||||
|
||||
void GeneralForm::onAutoAwayChanged()
|
||||
|
@ -199,12 +198,12 @@ void GeneralForm::onAutoAcceptFileChange()
|
|||
|
||||
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"));
|
||||
if(directory.isEmpty())
|
||||
directory = previousDir;
|
||||
|
||||
Settings::getInstance().setAutoSaveFilesDir(directory);
|
||||
Settings::getInstance().setGlobalAutoAcceptDir(directory);
|
||||
bodyUI->autoSaveFilesDir->setText(directory);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,28 +49,28 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
QPoint pos = event->globalPos();
|
||||
QString id = Core::getInstance()->getFriendAddress(friendId);
|
||||
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
||||
QString globalDir = Settings::getInstance().getGlobalAutoAcceptDir();
|
||||
QMenu menu;
|
||||
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"));
|
||||
QMap<QAction*, Group*> groupActions;
|
||||
|
||||
for (Group* group : GroupList::groupList)
|
||||
{
|
||||
QAction* groupAction = inviteMenu->addAction(group->widget->getName());
|
||||
groupActions[groupAction] = group;
|
||||
}
|
||||
|
||||
if (groupActions.isEmpty())
|
||||
inviteMenu->setEnabled(false);
|
||||
|
||||
menu.addSeparator();
|
||||
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* 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())
|
||||
disableAutoAccept->setEnabled(false);
|
||||
if (globalDir.isEmpty())
|
||||
disableGlobalAA->setEnabled(false);
|
||||
menu.addSeparator();
|
||||
|
||||
QAction* removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist"));
|
||||
|
||||
QAction* selectedItem = menu.exec(pos);
|
||||
|
@ -100,25 +100,6 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
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))
|
||||
{
|
||||
Group* group = groupActions[selectedItem];
|
||||
|
|
Loading…
Reference in New Issue
Block a user