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()); ChatMessage::Ptr msg = ChatMessage::createFileTransferMessage(name, file, false, QDateTime::currentDateTime());
insertChatMessage(msg); insertChatMessage(msg);
if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty() if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty()) //per contact autosave
|| Settings::getInstance().getAutoSaveEnabled())
{ {
ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1)); ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1));
assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType); assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType);
FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget()); FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget());
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId())); 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->notifySound, &QCheckBox::stateChanged, this, &GeneralForm::onSetNotifySound);
connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify); connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify);
connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange); 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 //theme
connect(bodyUI->useEmoticons, &QCheckBox::stateChanged, this, &GeneralForm::onUseEmoticonsChange); connect(bodyUI->useEmoticons, &QCheckBox::stateChanged, this, &GeneralForm::onUseEmoticonsChange);
connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int))); connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int)));
@ -291,19 +290,16 @@ void GeneralForm::onAutoAwayChanged()
void GeneralForm::onAutoAcceptFileChange() void GeneralForm::onAutoAcceptFileChange()
{ {
Settings::getInstance().setAutoSaveEnabled(bodyUI->autoacceptFiles->isChecked()); 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() void GeneralForm::onAutoSaveDirChange()
{ {
QString previousDir = Settings::getInstance().getGlobalAutoAcceptDir(); QString previousDir = Settings::getInstance().getGlobalAutoAcceptDir();
QString directory = QFileDialog::getExistingDirectory(0, QString directory = QFileDialog::getExistingDirectory(0,
tr("Choose an auto accept directory","popup title")); tr("Choose an auto accept directory", "popup title"), //opens in home directory
if (directory.isEmpty()) QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
);
if (directory.isEmpty()) // cancel was pressed
directory = previousDir; directory = previousDir;
Settings::getInstance().setGlobalAutoAcceptDir(directory); Settings::getInstance().setGlobalAutoAcceptDir(directory);

View File

@ -39,8 +39,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>653</width> <width>639</width>
<height>1150</height> <height>1221</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,1"> <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,1">
@ -236,6 +236,13 @@ instead of system taskbar.</string>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="startupLayout"> <layout class="QVBoxLayout" name="startupLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string/>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="cbAutorun"> <widget class="QCheckBox" name="cbAutorun">
<property name="toolTip"> <property name="toolTip">
@ -256,21 +263,11 @@ instead of system taskbar.</string>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="autoacceptLayout"> <layout class="QFormLayout" name="formLayout_2">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item row="2" column="1">
<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>
<widget class="QPushButton" name="autoSaveFilesDir"> <widget class="QPushButton" name="autoSaveFilesDir">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -283,6 +280,23 @@ instead of system taskbar.</string>
</property> </property>
</widget> </widget>
</item> </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> </layout>
</item> </item>
</layout> </layout>