From 53b90d085ec1a3b14b5fb412c8f050109f97d3f3 Mon Sep 17 00:00:00 2001 From: agilob Date: Sat, 20 Jun 2015 13:16:54 +0100 Subject: [PATCH] fix issues with global autoaccept --- src/widget/form/chatform.cpp | 8 +++- src/widget/form/settings/generalform.cpp | 14 +++---- src/widget/form/settings/generalsettings.ui | 42 ++++++++++++++------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 1f0b12a09..75965079c 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -225,13 +225,17 @@ void ChatForm::onFileRecvRequest(ToxFile file) ChatMessage::Ptr msg = ChatMessage::createFileTransferMessage(name, file, false, QDateTime::currentDateTime()); insertChatMessage(msg); - if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty() - || Settings::getInstance().getAutoSaveEnabled()) + if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty()) //per contact autosave { ChatLineContentProxy* proxy = static_cast(msg->getContent(1)); assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType); FileTransferWidget* tfWidget = static_cast(proxy->getWidget()); tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId())); + } else if (Settings::getInstance().getAutoSaveEnabled()) { //global autosave to global directory + ChatLineContentProxy* proxy = static_cast(msg->getContent(1)); + assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType); + FileTransferWidget* tfWidget = static_cast(proxy->getWidget()); + tfWidget->autoAcceptTransfer(Settings::getInstance().getGlobalAutoAcceptDir()); } } diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index 417eddba9..c5efc02bd 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -160,8 +160,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) : connect(bodyUI->notifySound, &QCheckBox::stateChanged, this, &GeneralForm::onSetNotifySound); connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify); connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange); - if (bodyUI->autoacceptFiles->isChecked()) - connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange())); + connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange())); //theme connect(bodyUI->useEmoticons, &QCheckBox::stateChanged, this, &GeneralForm::onUseEmoticonsChange); connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int))); @@ -291,19 +290,16 @@ void GeneralForm::onAutoAwayChanged() void GeneralForm::onAutoAcceptFileChange() { Settings::getInstance().setAutoSaveEnabled(bodyUI->autoacceptFiles->isChecked()); - - if (bodyUI->autoacceptFiles->isChecked() == true) - connect(bodyUI->autoSaveFilesDir, &QPushButton::clicked, this, &GeneralForm::onAutoSaveDirChange); - else - disconnect(bodyUI->autoSaveFilesDir, &QPushButton::clicked, this, &GeneralForm::onAutoSaveDirChange); } void GeneralForm::onAutoSaveDirChange() { QString previousDir = Settings::getInstance().getGlobalAutoAcceptDir(); QString directory = QFileDialog::getExistingDirectory(0, - tr("Choose an auto accept directory","popup title")); - if (directory.isEmpty()) + tr("Choose an auto accept directory", "popup title"), //opens in home directory + QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory) + ); + if (directory.isEmpty()) // cancel was pressed directory = previousDir; Settings::getInstance().setGlobalAutoAcceptDir(directory); diff --git a/src/widget/form/settings/generalsettings.ui b/src/widget/form/settings/generalsettings.ui index a03a08e77..c341c986b 100644 --- a/src/widget/form/settings/generalsettings.ui +++ b/src/widget/form/settings/generalsettings.ui @@ -39,8 +39,8 @@ 0 0 - 653 - 1150 + 639 + 1221 @@ -236,6 +236,13 @@ instead of system taskbar. + + + + + + + @@ -256,21 +263,11 @@ instead of system taskbar. - + 0 - - - - You can set this on a per-friend basis by right clicking them. - - - Autoaccept and save files: - - - - + @@ -283,6 +280,23 @@ instead of system taskbar. + + + + Default directory to save files + + + + + + + You can set this on a per-friend basis by right clicking them. + + + Autoaccept files + + +