Browse Source

Expose Mark-of-the-Web setting in Options

master
Chocobo1 1 year ago
parent
commit
6cfbc02d8f
  1. 2
      src/base/bittorrent/torrentimpl.cpp
  2. 7
      src/base/net/downloadhandlerimpl.cpp
  3. 13
      src/base/preferences.cpp
  4. 2
      src/base/preferences.h
  5. 17
      src/gui/advancedsettings.cpp
  6. 6
      src/gui/advancedsettings.h
  7. 5
      src/webui/api/appcontroller.cpp
  8. 2
      src/webui/webapplication.h
  9. 10
      src/webui/www/private/views/preferences.html

2
src/base/bittorrent/torrentimpl.cpp

@ -2245,7 +2245,7 @@ void TorrentImpl::handleFileCompletedAlert(const lt::file_completed_alert *p)
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN) #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
// only apply Mark-of-the-Web to new download files // only apply Mark-of-the-Web to new download files
if (isDownloading()) if (Preferences::instance()->isMarkOfTheWebEnabled() && isDownloading())
{ {
const Path fullpath = actualStorageLocation() / actualPath; const Path fullpath = actualStorageLocation() / actualPath;
Utils::OS::applyMarkOfTheWeb(fullpath); Utils::OS::applyMarkOfTheWeb(fullpath);

7
src/base/net/downloadhandlerimpl.cpp

@ -43,6 +43,7 @@
#endif #endif
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN) #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
#include "base/preferences.h"
#include "base/utils/os.h" #include "base/utils/os.h"
#endif // Q_OS_MACOS || Q_OS_WIN #endif // Q_OS_MACOS || Q_OS_WIN
@ -155,7 +156,8 @@ void Net::DownloadHandlerImpl::processFinishedDownload()
m_result.filePath = result.value(); m_result.filePath = result.value();
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN) #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
Utils::OS::applyMarkOfTheWeb(m_result.filePath, m_result.url); if (Preferences::instance()->isMarkOfTheWebEnabled())
Utils::OS::applyMarkOfTheWeb(m_result.filePath, m_result.url);
#endif // Q_OS_MACOS || Q_OS_WIN #endif // Q_OS_MACOS || Q_OS_WIN
} }
else else
@ -171,7 +173,8 @@ void Net::DownloadHandlerImpl::processFinishedDownload()
m_result.filePath = destinationPath; m_result.filePath = destinationPath;
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN) #if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
Utils::OS::applyMarkOfTheWeb(m_result.filePath, m_result.url); if (Preferences::instance()->isMarkOfTheWebEnabled())
Utils::OS::applyMarkOfTheWeb(m_result.filePath, m_result.url);
#endif // Q_OS_MACOS || Q_OS_WIN #endif // Q_OS_MACOS || Q_OS_WIN
} }
else else

13
src/base/preferences.cpp

@ -1319,6 +1319,19 @@ void Preferences::setTrackerPortForwardingEnabled(const bool enabled)
setValue(u"Preferences/Advanced/trackerPortForwarding"_s, enabled); setValue(u"Preferences/Advanced/trackerPortForwarding"_s, enabled);
} }
bool Preferences::isMarkOfTheWebEnabled() const
{
return value(u"Preferences/Advanced/markOfTheWeb"_s, true);
}
void Preferences::setMarkOfTheWebEnabled(const bool enabled)
{
if (enabled == isMarkOfTheWebEnabled())
return;
setValue(u"Preferences/Advanced/markOfTheWeb"_s, enabled);
}
Path Preferences::getPythonExecutablePath() const Path Preferences::getPythonExecutablePath() const
{ {
return value(u"Preferences/Search/pythonExecutablePath"_s, Path()); return value(u"Preferences/Search/pythonExecutablePath"_s, Path());

2
src/base/preferences.h

@ -291,6 +291,8 @@ public:
void setTrackerPort(int port); void setTrackerPort(int port);
bool isTrackerPortForwardingEnabled() const; bool isTrackerPortForwardingEnabled() const;
void setTrackerPortForwardingEnabled(bool enabled); void setTrackerPortForwardingEnabled(bool enabled);
bool isMarkOfTheWebEnabled() const;
void setMarkOfTheWebEnabled(bool enabled);
Path getPythonExecutablePath() const; Path getPythonExecutablePath() const;
void setPythonExecutablePath(const Path &path); void setPythonExecutablePath(const Path &path);
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) #if defined(Q_OS_WIN) || defined(Q_OS_MACOS)

17
src/gui/advancedsettings.cpp

@ -100,6 +100,9 @@ namespace
TRACKER_STATUS, TRACKER_STATUS,
TRACKER_PORT, TRACKER_PORT,
TRACKER_PORT_FORWARDING, TRACKER_PORT_FORWARDING,
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
ENABLE_MARK_OF_THE_WEB,
#endif // Q_OS_MACOS || Q_OS_WIN
PYTHON_EXECUTABLE_PATH, PYTHON_EXECUTABLE_PATH,
// libtorrent section // libtorrent section
@ -319,6 +322,10 @@ void AdvancedSettings::saveAdvancedSettings() const
pref->setTrackerPort(m_spinBoxTrackerPort.value()); pref->setTrackerPort(m_spinBoxTrackerPort.value());
pref->setTrackerPortForwardingEnabled(m_checkBoxTrackerPortForwarding.isChecked()); pref->setTrackerPortForwardingEnabled(m_checkBoxTrackerPortForwarding.isChecked());
session->setTrackerEnabled(m_checkBoxTrackerStatus.isChecked()); session->setTrackerEnabled(m_checkBoxTrackerStatus.isChecked());
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
// Mark-of-the-Web
pref->setMarkOfTheWebEnabled(m_checkBoxMarkOfTheWeb.isChecked());
#endif // Q_OS_MACOS || Q_OS_WIN
// Python executable path // Python executable path
pref->setPythonExecutablePath(Path(m_pythonExecutablePath.text().trimmed())); pref->setPythonExecutablePath(Path(m_pythonExecutablePath.text().trimmed()));
// Choking algorithm // Choking algorithm
@ -815,6 +822,16 @@ void AdvancedSettings::loadAdvancedSettings()
// Tracker port forwarding // Tracker port forwarding
m_checkBoxTrackerPortForwarding.setChecked(pref->isTrackerPortForwardingEnabled()); m_checkBoxTrackerPortForwarding.setChecked(pref->isTrackerPortForwardingEnabled());
addRow(TRACKER_PORT_FORWARDING, tr("Enable port forwarding for embedded tracker"), &m_checkBoxTrackerPortForwarding); addRow(TRACKER_PORT_FORWARDING, tr("Enable port forwarding for embedded tracker"), &m_checkBoxTrackerPortForwarding);
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
// Mark-of-the-Web
#ifdef Q_OS_MACOS
const QString motwLabel = tr("Enable quarantine for downloaded files");
#elif defined(Q_OS_WIN)
const QString motwLabel = tr("Enable Mark-of-the-Web (MOTW) for downloaded files");
#endif
m_checkBoxMarkOfTheWeb.setChecked(pref->isMarkOfTheWebEnabled());
addRow(ENABLE_MARK_OF_THE_WEB, motwLabel, &m_checkBoxMarkOfTheWeb);
#endif // Q_OS_MACOS || Q_OS_WIN
// Python executable path // Python executable path
m_pythonExecutablePath.setPlaceholderText(tr("(Auto detect if empty)")); m_pythonExecutablePath.setPlaceholderText(tr("(Auto detect if empty)"));
m_pythonExecutablePath.setText(pref->getPythonExecutablePath().toString()); m_pythonExecutablePath.setText(pref->getPythonExecutablePath().toString());

6
src/gui/advancedsettings.h

@ -101,7 +101,7 @@ private:
#endif #endif
// OS dependent settings // OS dependent settings
#if defined(Q_OS_WIN) #ifdef Q_OS_WIN
QComboBox m_comboBoxOSMemoryPriority; QComboBox m_comboBoxOSMemoryPriority;
#endif #endif
@ -109,6 +109,10 @@ private:
QCheckBox m_checkBoxIconsInMenusEnabled; QCheckBox m_checkBoxIconsInMenusEnabled;
#endif #endif
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
QCheckBox m_checkBoxMarkOfTheWeb;
#endif // Q_OS_MACOS || Q_OS_WIN
#ifdef QBT_USES_DBUS #ifdef QBT_USES_DBUS
QSpinBox m_spinBoxNotificationTimeout; QSpinBox m_spinBoxNotificationTimeout;
#endif #endif

5
src/webui/api/appcontroller.cpp

@ -414,6 +414,8 @@ void AppController::preferencesAction()
data[u"enable_embedded_tracker"_s] = session->isTrackerEnabled(); data[u"enable_embedded_tracker"_s] = session->isTrackerEnabled();
data[u"embedded_tracker_port"_s] = pref->getTrackerPort(); data[u"embedded_tracker_port"_s] = pref->getTrackerPort();
data[u"embedded_tracker_port_forwarding"_s] = pref->isTrackerPortForwardingEnabled(); data[u"embedded_tracker_port_forwarding"_s] = pref->isTrackerPortForwardingEnabled();
// Mark-of-the-Web
data[u"mark_of_the_web"_s] = pref->isMarkOfTheWebEnabled();
// Python executable path // Python executable path
data[u"python_executable_path"_s] = pref->getPythonExecutablePath().toString(); data[u"python_executable_path"_s] = pref->getPythonExecutablePath().toString();
// Choking algorithm // Choking algorithm
@ -1020,6 +1022,9 @@ void AppController::setPreferencesAction()
pref->setTrackerPortForwardingEnabled(it.value().toBool()); pref->setTrackerPortForwardingEnabled(it.value().toBool());
if (hasKey(u"enable_embedded_tracker"_s)) if (hasKey(u"enable_embedded_tracker"_s))
session->setTrackerEnabled(it.value().toBool()); session->setTrackerEnabled(it.value().toBool());
// Mark-of-the-Web
if (hasKey(u"mark_of_the_web"_s))
pref->setMarkOfTheWebEnabled(it.value().toBool());
// Python executable path // Python executable path
if (hasKey(u"python_executable_path"_s)) if (hasKey(u"python_executable_path"_s))
pref->setPythonExecutablePath(Path(it.value().toString())); pref->setPythonExecutablePath(Path(it.value().toString()));

2
src/webui/webapplication.h

@ -52,7 +52,7 @@
#include "base/utils/version.h" #include "base/utils/version.h"
#include "api/isessionmanager.h" #include "api/isessionmanager.h"
inline const Utils::Version<3, 2> API_VERSION {2, 10, 0}; inline const Utils::Version<3, 2> API_VERSION {2, 10, 1};
class APIController; class APIController;
class AuthController; class AuthController;

10
src/webui/www/private/views/preferences.html

@ -1077,6 +1077,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
<input type="checkbox" id="embeddedTrackerPortForwarding" /> <input type="checkbox" id="embeddedTrackerPortForwarding" />
</td> </td>
</tr> </tr>
<tr>
<td>
<label for="markOfTheWeb">QBT_TR(Enable Mark-of-the-Web (MOTW) for downloaded files (require macOS or Windows):)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="checkbox" id="markOfTheWeb" />
</td>
</tr>
<tr> <tr>
<td> <td>
<label for="pythonExecutablePath">QBT_TR(Python executable path (may require restart):)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="pythonExecutablePath">QBT_TR(Python executable path (may require restart):)QBT_TR[CONTEXT=OptionsDialog]</label>
@ -2320,6 +2328,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
$('enableEmbeddedTracker').setProperty('checked', pref.enable_embedded_tracker); $('enableEmbeddedTracker').setProperty('checked', pref.enable_embedded_tracker);
$('embeddedTrackerPort').setProperty('value', pref.embedded_tracker_port); $('embeddedTrackerPort').setProperty('value', pref.embedded_tracker_port);
$('embeddedTrackerPortForwarding').setProperty('checked', pref.embedded_tracker_port_forwarding); $('embeddedTrackerPortForwarding').setProperty('checked', pref.embedded_tracker_port_forwarding);
$('markOfTheWeb').setProperty('checked', pref.mark_of_the_web);
$('pythonExecutablePath').setProperty('value', pref.python_executable_path); $('pythonExecutablePath').setProperty('value', pref.python_executable_path);
$('uploadSlotsBehavior').setProperty('value', pref.upload_slots_behavior); $('uploadSlotsBehavior').setProperty('value', pref.upload_slots_behavior);
$('uploadChokingAlgorithm').setProperty('value', pref.upload_choking_algorithm); $('uploadChokingAlgorithm').setProperty('value', pref.upload_choking_algorithm);
@ -2764,6 +2773,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
settings.set('enable_embedded_tracker', $('enableEmbeddedTracker').getProperty('checked')); settings.set('enable_embedded_tracker', $('enableEmbeddedTracker').getProperty('checked'));
settings.set('embedded_tracker_port', $('embeddedTrackerPort').getProperty('value')); settings.set('embedded_tracker_port', $('embeddedTrackerPort').getProperty('value'));
settings.set('embedded_tracker_port_forwarding', $('embeddedTrackerPortForwarding').getProperty('checked')); settings.set('embedded_tracker_port_forwarding', $('embeddedTrackerPortForwarding').getProperty('checked'));
settings.set('mark_of_the_web', $('markOfTheWeb').getProperty('checked'));
settings.set('python_executable_path', $('pythonExecutablePath').getProperty('value')); settings.set('python_executable_path', $('pythonExecutablePath').getProperty('value'));
settings.set('upload_slots_behavior', $('uploadSlotsBehavior').getProperty('value')); settings.set('upload_slots_behavior', $('uploadSlotsBehavior').getProperty('value'));
settings.set('upload_choking_algorithm', $('uploadChokingAlgorithm').getProperty('value')); settings.set('upload_choking_algorithm', $('uploadChokingAlgorithm').getProperty('value'));

Loading…
Cancel
Save