1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix issues with global autoaccept

This commit is contained in:
agilob 2015-06-20 13:16:54 +01:00
parent cc0c929ab9
commit 53b90d085e
3 changed files with 39 additions and 25 deletions

View File

@ -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<ChatLineContentProxy*>(msg->getContent(1));
assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType);
FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget());
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId()));
} else if (Settings::getInstance().getAutoSaveEnabled()) { //global autosave to global directory
ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1));
assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType);
FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget());
tfWidget->autoAcceptTransfer(Settings::getInstance().getGlobalAutoAcceptDir());
}
}

View File

@ -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);

View File

@ -39,8 +39,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>653</width>
<height>1150</height>
<width>639</width>
<height>1221</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,1">
@ -236,6 +236,13 @@ instead of system taskbar.</string>
</item>
<item>
<layout class="QVBoxLayout" name="startupLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbAutorun">
<property name="toolTip">
@ -256,21 +263,11 @@ instead of system taskbar.</string>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="autoacceptLayout">
<layout class="QFormLayout" name="formLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="autoacceptFiles">
<property name="toolTip">
<string comment="autoaccept cb tooltip">You can set this on a per-friend basis by right clicking them.</string>
</property>
<property name="text">
<string>Autoaccept and save files:</string>
</property>
</widget>
</item>
<item>
<item row="2" column="1">
<widget class="QPushButton" name="autoSaveFilesDir">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -283,6 +280,23 @@ instead of system taskbar.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Default directory to save files</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="autoacceptFiles">
<property name="toolTip">
<string comment="autoaccept cb tooltip">You can set this on a per-friend basis by right clicking them.</string>
</property>
<property name="text">
<string>Autoaccept files</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>