mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #5373
Mick Sayson (2): refactor(files): clang-format generated whitespace changes feat(files): Add maximum size to autoaccept downloads
This commit is contained in:
commit
2ecfbf7f28
|
@ -183,6 +183,8 @@ void Settings::loadGlobal()
|
|||
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(),
|
||||
QStandardPaths::LocateDirectory))
|
||||
.toString();
|
||||
autoAcceptMaxSize =
|
||||
static_cast<size_t>(s.value("autoAcceptMaxSize", 20 << 20 /*20 MB*/).toLongLong());
|
||||
stylePreference = static_cast<StyleType>(s.value("stylePreference", 1).toInt());
|
||||
}
|
||||
s.endGroup();
|
||||
|
@ -272,9 +274,9 @@ void Settings::loadGlobal()
|
|||
enableTestSound = s.value("enableTestSound", true).toBool();
|
||||
audioBitrate = s.value("audioBitrate", 64).toInt();
|
||||
enableBackend2 = false;
|
||||
#ifdef USE_FILTERAUDIO
|
||||
#ifdef USE_FILTERAUDIO
|
||||
enableBackend2 = s.value("enableBackend2", false).toBool();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
s.endGroup();
|
||||
|
||||
|
@ -499,6 +501,7 @@ void Settings::saveGlobal()
|
|||
s.setValue("busySound", busySound);
|
||||
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
||||
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
||||
s.setValue("autoAcceptMaxSize", static_cast<qlonglong>(autoAcceptMaxSize));
|
||||
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
||||
s.setValue("stylePreference", static_cast<int>(stylePreference));
|
||||
}
|
||||
|
@ -1509,6 +1512,22 @@ void Settings::setGlobalAutoAcceptDir(const QString& newValue)
|
|||
}
|
||||
}
|
||||
|
||||
size_t Settings::getMaxAutoAcceptSize() const
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
return autoAcceptMaxSize;
|
||||
}
|
||||
|
||||
void Settings::setMaxAutoAcceptSize(size_t size)
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
|
||||
if (size != autoAcceptMaxSize) {
|
||||
autoAcceptMaxSize = size;
|
||||
emit autoAcceptMaxSizeChanged(autoAcceptMaxSize);
|
||||
}
|
||||
}
|
||||
|
||||
const QFont& Settings::getChatMessageFont() const
|
||||
{
|
||||
QMutexLocker locker(&bigLock);
|
||||
|
|
|
@ -43,8 +43,11 @@ namespace Db {
|
|||
enum class syncType;
|
||||
}
|
||||
|
||||
class Settings : public QObject, public ICoreSettings, public IFriendSettings,
|
||||
public IAudioSettings, public IVideoSettings
|
||||
class Settings : public QObject,
|
||||
public ICoreSettings,
|
||||
public IFriendSettings,
|
||||
public IAudioSettings,
|
||||
public IVideoSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -91,8 +94,8 @@ class Settings : public QObject, public ICoreSettings, public IFriendSettings,
|
|||
Q_PROPERTY(QString dateFormat READ getDateFormat WRITE setDateFormat NOTIFY dateFormatChanged FINAL)
|
||||
Q_PROPERTY(bool statusChangeNotificationEnabled READ getStatusChangeNotificationEnabled WRITE
|
||||
setStatusChangeNotificationEnabled NOTIFY statusChangeNotificationEnabledChanged FINAL)
|
||||
Q_PROPERTY(bool spellCheckingEnabled READ getSpellCheckingEnabled WRITE
|
||||
setSpellCheckingEnabled NOTIFY spellCheckingEnabledChanged FINAL)
|
||||
Q_PROPERTY(bool spellCheckingEnabled READ getSpellCheckingEnabled WRITE setSpellCheckingEnabled
|
||||
NOTIFY spellCheckingEnabledChanged FINAL)
|
||||
|
||||
// Privacy
|
||||
Q_PROPERTY(bool typingNotification READ getTypingNotification WRITE setTypingNotification NOTIFY
|
||||
|
@ -105,8 +108,8 @@ class Settings : public QObject, public ICoreSettings, public IFriendSettings,
|
|||
audioInDevEnabledChanged FINAL)
|
||||
Q_PROPERTY(qreal audioInGainDecibel READ getAudioInGainDecibel WRITE setAudioInGainDecibel
|
||||
NOTIFY audioInGainDecibelChanged FINAL)
|
||||
Q_PROPERTY(qreal audioThreshold READ getAudioThreshold WRITE setAudioThreshold
|
||||
NOTIFY audioThresholdChanged FINAL)
|
||||
Q_PROPERTY(qreal audioThreshold READ getAudioThreshold WRITE setAudioThreshold NOTIFY
|
||||
audioThresholdChanged FINAL)
|
||||
Q_PROPERTY(QString outDev READ getOutDev WRITE setOutDev NOTIFY outDevChanged FINAL)
|
||||
Q_PROPERTY(bool audioOutDevEnabled READ getAudioOutDevEnabled WRITE setAudioOutDevEnabled NOTIFY
|
||||
audioOutDevEnabledChanged FINAL)
|
||||
|
@ -183,6 +186,7 @@ signals:
|
|||
void enableLoggingChanged(bool enabled);
|
||||
void autoAwayTimeChanged(int minutes);
|
||||
void globalAutoAcceptDirChanged(const QString& path);
|
||||
void autoAcceptMaxSizeChanged(size_t size);
|
||||
void checkUpdatesChanged(bool enabled);
|
||||
void widgetDataChanged(const QString& key);
|
||||
|
||||
|
@ -352,8 +356,14 @@ public:
|
|||
void setAudioThreshold(qreal percent) override;
|
||||
|
||||
int getOutVolume() const override;
|
||||
int getOutVolumeMin() const override { return 0; }
|
||||
int getOutVolumeMax() const override { return 100; }
|
||||
int getOutVolumeMin() const override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int getOutVolumeMax() const override
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
void setOutVolume(int volume) override;
|
||||
|
||||
int getAudioBitrate() const override;
|
||||
|
@ -429,6 +439,9 @@ public:
|
|||
QString getGlobalAutoAcceptDir() const;
|
||||
void setGlobalAutoAcceptDir(const QString& dir);
|
||||
|
||||
size_t getMaxAutoAcceptSize() const;
|
||||
void setMaxAutoAcceptSize(size_t size);
|
||||
|
||||
bool getAutoGroupInvite(const ToxPk& id) const override;
|
||||
void setAutoGroupInvite(const ToxPk& id, bool accept) override;
|
||||
|
||||
|
@ -491,8 +504,8 @@ public:
|
|||
void saveFriendSettings(const ToxPk& id) override;
|
||||
void removeFriendSettings(const ToxPk& id) override;
|
||||
|
||||
SIGNAL_IMPL(Settings, autoAcceptCallChanged,
|
||||
const ToxPk& id, IFriendSettings::AutoAcceptCallFlags accept)
|
||||
SIGNAL_IMPL(Settings, autoAcceptCallChanged, const ToxPk& id,
|
||||
IFriendSettings::AutoAcceptCallFlags accept)
|
||||
SIGNAL_IMPL(Settings, autoGroupInviteChanged, const ToxPk& id, bool accept)
|
||||
SIGNAL_IMPL(Settings, autoAcceptDirChanged, const ToxPk& id, const QString& dir)
|
||||
SIGNAL_IMPL(Settings, contactNoteChanged, const ToxPk& id, const QString& note)
|
||||
|
@ -508,10 +521,10 @@ public:
|
|||
|
||||
bool getDontGroupWindows() const;
|
||||
void setDontGroupWindows(bool value);
|
||||
|
||||
|
||||
bool getGroupchatPosition() const;
|
||||
void setGroupchatPosition(bool value);
|
||||
|
||||
|
||||
bool getShowIdenticons() const;
|
||||
void setShowIdenticons(bool value);
|
||||
|
||||
|
@ -618,6 +631,7 @@ private:
|
|||
QHash<QString, QString> autoAccept;
|
||||
bool autoSaveEnabled;
|
||||
QString globalAutoAcceptDir;
|
||||
size_t autoAcceptMaxSize;
|
||||
|
||||
QList<Request> friendRequests;
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ void ChatForm::onSendTriggered()
|
|||
}
|
||||
void ChatForm::onFileNameChanged(const ToxPk& friendPk)
|
||||
{
|
||||
if(friendPk != f->getPublicKey()) {
|
||||
if (friendPk != f->getPublicKey()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -266,8 +266,8 @@ void ChatForm::onTextEditChanged()
|
|||
|
||||
void ChatForm::onAttachClicked()
|
||||
{
|
||||
QStringList paths =
|
||||
QFileDialog::getOpenFileNames(Q_NULLPTR, tr("Send a file"), QDir::homePath(), nullptr, nullptr);
|
||||
QStringList paths = QFileDialog::getOpenFileNames(Q_NULLPTR, tr("Send a file"),
|
||||
QDir::homePath(), nullptr, nullptr);
|
||||
|
||||
if (paths.isEmpty()) {
|
||||
return;
|
||||
|
@ -339,12 +339,16 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
|||
|
||||
const Settings& settings = Settings::getInstance();
|
||||
QString autoAcceptDir = settings.getAutoAcceptDir(f->getPublicKey());
|
||||
// there is auto-accept for that contact
|
||||
if (!autoAcceptDir.isEmpty()) {
|
||||
|
||||
if (autoAcceptDir.isEmpty() && settings.getAutoSaveEnabled()) {
|
||||
autoAcceptDir = settings.getGlobalAutoAcceptDir();
|
||||
}
|
||||
|
||||
auto maxAutoAcceptSize = settings.getMaxAutoAcceptSize();
|
||||
bool autoAcceptSizeCheckPassed = maxAutoAcceptSize == 0 || maxAutoAcceptSize >= file.filesize;
|
||||
|
||||
if (!autoAcceptDir.isEmpty() && autoAcceptSizeCheckPassed) {
|
||||
tfWidget->autoAcceptTransfer(autoAcceptDir);
|
||||
// global autosave to global directory
|
||||
} else if (settings.getAutoSaveEnabled()) {
|
||||
tfWidget->autoAcceptTransfer(settings.getGlobalAutoAcceptDir());
|
||||
}
|
||||
|
||||
Widget::getInstance()->updateFriendActivity(f);
|
||||
|
@ -509,8 +513,8 @@ void ChatForm::searchInBegin(const QString& phrase, const ParameterSearch& param
|
|||
if (isFirst || isAfter) {
|
||||
if (isFirst || (isAfter && parameter.date < getFirstDate())) {
|
||||
const QString pk = f->getPublicKey().toString();
|
||||
if ((isFirst || parameter.date >= history->getStartDateChatHistory(pk).date()) &&
|
||||
loadHistory(phrase, parameter)) {
|
||||
if ((isFirst || parameter.date >= history->getStartDateChatHistory(pk).date())
|
||||
&& loadHistory(phrase, parameter)) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -520,7 +524,8 @@ void ChatForm::searchInBegin(const QString& phrase, const ParameterSearch& param
|
|||
} else {
|
||||
if (parameter.period == PeriodSearch::BeforeDate && parameter.date < getFirstDate()) {
|
||||
const QString pk = f->getPublicKey().toString();
|
||||
if (parameter.date >= history->getStartDateChatHistory(pk).date() && loadHistory(phrase, parameter)) {
|
||||
if (parameter.date >= history->getStartDateChatHistory(pk).date()
|
||||
&& loadHistory(phrase, parameter)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +560,8 @@ void ChatForm::onSearchUp(const QString& phrase, const ParameterSearch& paramete
|
|||
|
||||
if (!isSearch) {
|
||||
const QString pk = f->getPublicKey().toString();
|
||||
const QDateTime newBaseDate = history->getDateWhereFindPhrase(pk, earliestMessage, phrase, parameter);
|
||||
const QDateTime newBaseDate =
|
||||
history->getDateWhereFindPhrase(pk, earliestMessage, phrase, parameter);
|
||||
|
||||
if (!newBaseDate.isValid()) {
|
||||
emit messageNotFoundShow(SearchDirection::Up);
|
||||
|
@ -648,7 +654,7 @@ void ChatForm::onReceiptReceived(quint32 friendId, int receipt)
|
|||
}
|
||||
}
|
||||
|
||||
void ChatForm::onAvatarChanged(const ToxPk &friendPk, const QPixmap& pic)
|
||||
void ChatForm::onAvatarChanged(const ToxPk& friendPk, const QPixmap& pic)
|
||||
{
|
||||
if (friendPk != f->getPublicKey()) {
|
||||
return;
|
||||
|
@ -1058,7 +1064,7 @@ void ChatForm::SendMessageStr(QString msg)
|
|||
}
|
||||
|
||||
ChatMessage::Ptr ma = createSelfMessage(part, timestamp, isAction, false);
|
||||
|
||||
|
||||
if (history && Settings::getInstance().getEnableLogging()) {
|
||||
auto* offMsgEngine = getOfflineMsgEngine();
|
||||
QString selfPk = Core::getInstance()->getSelfId().toString();
|
||||
|
@ -1083,7 +1089,8 @@ void ChatForm::SendMessageStr(QString msg)
|
|||
bool ChatForm::loadHistory(const QString& phrase, const ParameterSearch& parameter)
|
||||
{
|
||||
const QString pk = f->getPublicKey().toString();
|
||||
const QDateTime newBaseDate = history->getDateWhereFindPhrase(pk, earliestMessage, phrase, parameter);
|
||||
const QDateTime newBaseDate =
|
||||
history->getDateWhereFindPhrase(pk, earliestMessage, phrase, parameter);
|
||||
|
||||
if (newBaseDate.isValid() && getFirstDate().isValid() && newBaseDate.date() < getFirstDate()) {
|
||||
searchAfterLoadHistory = true;
|
||||
|
@ -1133,7 +1140,8 @@ void ChatForm::onExportChat()
|
|||
ToxPk authorPk(ToxId(it.sender).getPublicKey());
|
||||
QString author = getMsgAuthorDispName(authorPk, it.dispName);
|
||||
|
||||
buffer = buffer % QString{datestamp % '\t' % timestamp % '\t' % author % '\t' % it.message % '\n'};
|
||||
buffer = buffer
|
||||
% QString{datestamp % '\t' % timestamp % '\t' % author % '\t' % it.message % '\n'};
|
||||
}
|
||||
file.write(buffer.toUtf8());
|
||||
file.close();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "ui_generalsettings.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <cmath>
|
||||
|
||||
#include "src/core/core.h"
|
||||
#include "src/core/coreav.h"
|
||||
|
@ -148,11 +149,12 @@ GeneralForm::GeneralForm(SettingsWidget* myParent)
|
|||
|
||||
bodyUI->autoAwaySpinBox->setValue(s.getAutoAwayTime());
|
||||
bodyUI->autoSaveFilesDir->setText(s.getGlobalAutoAcceptDir());
|
||||
bodyUI->maxAutoAcceptSizeMB->setValue(static_cast<double>(s.getMaxAutoAcceptSize()) / 1024 / 1024);
|
||||
bodyUI->autoacceptFiles->setChecked(s.getAutoSaveEnabled());
|
||||
|
||||
|
||||
#ifndef QTOX_PLATFORM_EXT
|
||||
bodyUI->autoAwayLabel->setEnabled(
|
||||
false); // these don't seem to change the appearance of the widgets,
|
||||
bodyUI->autoAwayLabel->setEnabled(false); // these don't seem to change the appearance of the widgets,
|
||||
bodyUI->autoAwaySpinBox->setEnabled(false); // though they are unusable
|
||||
#endif
|
||||
|
||||
|
@ -245,6 +247,14 @@ void GeneralForm::on_autoSaveFilesDir_clicked()
|
|||
bodyUI->autoSaveFilesDir->setText(directory);
|
||||
}
|
||||
|
||||
void GeneralForm::on_maxAutoAcceptSizeMB_editingFinished()
|
||||
{
|
||||
auto newMaxSizeMB = bodyUI->maxAutoAcceptSizeMB->value();
|
||||
auto newMaxSizeB = std::lround(newMaxSizeMB * 1024 * 1024);
|
||||
|
||||
Settings::getInstance().setMaxAutoAcceptSize(newMaxSizeB);
|
||||
}
|
||||
|
||||
void GeneralForm::on_checkUpdates_stateChanged()
|
||||
{
|
||||
Settings::getInstance().setCheckUpdates(bodyUI->checkUpdates->isChecked());
|
||||
|
|
|
@ -53,6 +53,7 @@ private slots:
|
|||
void on_cbFauxOfflineMessaging_stateChanged();
|
||||
|
||||
void on_autoacceptFiles_stateChanged();
|
||||
void on_maxAutoAcceptSizeMB_editingFinished();
|
||||
void on_autoSaveFilesDir_clicked();
|
||||
void on_checkUpdates_stateChanged();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1312</width>
|
||||
<height>580</height>
|
||||
<height>511</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -39,8 +39,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1276</width>
|
||||
<height>587</height>
|
||||
<width>1298</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0">
|
||||
|
@ -278,6 +278,13 @@ instead of closing itself.</string>
|
|||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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="2" column="1">
|
||||
<widget class="QPushButton" name="autoSaveFilesDir">
|
||||
<property name="sizePolicy">
|
||||
|
@ -291,13 +298,6 @@ instead of closing itself.</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="sizePolicy">
|
||||
|
@ -314,6 +314,20 @@ instead of closing itself.</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="maxAutoAcceptSizeLabel">
|
||||
<property name="text">
|
||||
<string>Max autoaccept file size (0 to disable):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="maxAutoAcceptSizeMB">
|
||||
<property name="suffix">
|
||||
<string> MB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in New Issue
Block a user