This commit is contained in:
Martin Rotter 2024-08-06 12:07:28 +02:00
parent 9952329e74
commit ab4861a64f
5 changed files with 36 additions and 7 deletions

View File

@ -51,6 +51,10 @@ SettingsBrowserMail::SettingsBrowserMail(Settings* settings, QWidget* parent)
connect(m_ui->m_txtExternalBrowserExecutable, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtExternalBrowserExecutable, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_txtExternalEmailArguments, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtExternalEmailArguments, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_txtExternalEmailExecutable, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtExternalEmailExecutable, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_txtUserAgent, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings);
connect(m_ui->m_txtUserAgent, &QLineEdit::textChanged, this, &SettingsBrowserMail::requireRestart);
connect(m_ui->m_cmbExternalBrowserPreset, connect(m_ui->m_cmbExternalBrowserPreset,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, this,
@ -178,6 +182,7 @@ void SettingsBrowserMail::loadSettings() {
->setChecked(settings()->value(GROUP(Network), SETTING(Network::IgnoreAllCookies)).toBool()); ->setChecked(settings()->value(GROUP(Network), SETTING(Network::IgnoreAllCookies)).toBool());
m_ui->m_checkOpenLinksInExternal m_ui->m_checkOpenLinksInExternal
->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::OpenLinksInExternalBrowserRightAway)).toBool()); ->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::OpenLinksInExternalBrowserRightAway)).toBool());
m_ui->m_txtUserAgent->setText(settings()->value(GROUP(Network), SETTING(Network::CustomUserAgent)).toString());
// Load settings of web browser GUI. // Load settings of web browser GUI.
m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1")); m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1"));
@ -222,6 +227,7 @@ void SettingsBrowserMail::saveSettings() {
settings()->setValue(GROUP(Network), Network::EnableHttp2, m_ui->m_cbEnableHttp2->isChecked()); settings()->setValue(GROUP(Network), Network::EnableHttp2, m_ui->m_cbEnableHttp2->isChecked());
settings()->setValue(GROUP(Network), Network::EnableApiServer, m_ui->m_cbEnableApiServer->isChecked()); settings()->setValue(GROUP(Network), Network::EnableApiServer, m_ui->m_cbEnableApiServer->isChecked());
settings()->setValue(GROUP(Network), Network::IgnoreAllCookies, m_ui->m_cbIgnoreAllCookies->isChecked()); settings()->setValue(GROUP(Network), Network::IgnoreAllCookies, m_ui->m_cbIgnoreAllCookies->isChecked());
settings()->setValue(GROUP(Network), Network::CustomUserAgent, m_ui->m_txtUserAgent->text());
qApp->web()->stopApiServer(); qApp->web()->stopApiServer();

View File

@ -42,6 +42,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1">
<widget class="QLineEdit" name="m_txtUserAgent"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Custom User-Agent</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="m_tabWebEngine"> <widget class="QWidget" name="m_tabWebEngine">
@ -83,7 +93,7 @@
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Orientation::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
@ -172,7 +182,7 @@
<item row="2" column="1"> <item row="2" column="1">
<widget class="QComboBox" name="m_cmbExternalBrowserPreset"> <widget class="QComboBox" name="m_cmbExternalBrowserPreset">
<property name="sizeAdjustPolicy"> <property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum> <enum>QComboBox::SizeAdjustPolicy::AdjustToContents</enum>
</property> </property>
<item> <item>
<property name="text"> <property name="text">
@ -197,7 +207,7 @@
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Orientation::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
@ -289,7 +299,7 @@
<item row="2" column="1"> <item row="2" column="1">
<widget class="QComboBox" name="m_cmbExternalEmailPreset"> <widget class="QComboBox" name="m_cmbExternalEmailPreset">
<property name="sizeAdjustPolicy"> <property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum> <enum>QComboBox::SizeAdjustPolicy::AdjustToContents</enum>
</property> </property>
<item> <item>
<property name="text"> <property name="text">
@ -372,7 +382,7 @@
<item row="3" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Orientation::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>

View File

@ -222,7 +222,13 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin
} }
#endif #endif
if (!custom_ua.isEmpty()) {
m_webFactory->setCustomUserAgent(custom_ua); m_webFactory->setCustomUserAgent(custom_ua);
}
else {
custom_ua = qApp->settings()->value(GROUP(Network), SETTING(Network::CustomUserAgent)).toString();
m_webFactory->setCustomUserAgent(custom_ua);
}
#if defined(NO_LITE) #if defined(NO_LITE)
m_webFactory->urlIinterceptor()->load(); m_webFactory->urlIinterceptor()->load();
@ -1358,7 +1364,8 @@ void Application::fillCmdArgumentsParser(QCommandLineParser& parser) {
QSL("style-name")); QSL("style-name"));
QCommandLineOption custom_ua({QSL(CLI_USERAGENT_SHORT), QSL(CLI_USERAGENT_LONG)}, QCommandLineOption custom_ua({QSL(CLI_USERAGENT_SHORT), QSL(CLI_USERAGENT_LONG)},
QSL("User custom User-Agent HTTP header for all network requests."), QSL("User custom User-Agent HTTP header for all network requests. This option "
"takes precedence over User-Agent set via application settings."),
QSL("user-agent")); QSL("user-agent"));
QCommandLineOption QCommandLineOption
adblock_port({QSL(CLI_ADBLOCKPORT_SHORT), QSL(CLI_ADBLOCKPORT_LONG)}, adblock_port({QSL(CLI_ADBLOCKPORT_SHORT), QSL(CLI_ADBLOCKPORT_LONG)},

View File

@ -65,6 +65,9 @@ VALUE(bool) Network::EnableApiServerDef = false;
DKEY Network::EnableHttp2 = "http2_enabled"; DKEY Network::EnableHttp2 = "http2_enabled";
DVALUE(bool) Network::EnableHttp2Def = false; DVALUE(bool) Network::EnableHttp2Def = false;
DKEY Network::CustomUserAgent = "user_agent";
DVALUE(QString) Network::CustomUserAgentDef = QString();
DKEY Network::IgnoreAllCookies = "ignore_all_cookies"; DKEY Network::IgnoreAllCookies = "ignore_all_cookies";
DVALUE(bool) Network::IgnoreAllCookiesDef = false; DVALUE(bool) Network::IgnoreAllCookiesDef = false;

View File

@ -413,6 +413,9 @@ namespace Network {
KEY EnableHttp2; KEY EnableHttp2;
VALUE(bool) EnableHttp2Def; VALUE(bool) EnableHttp2Def;
KEY CustomUserAgent;
VALUE(QString) CustomUserAgentDef;
KEY IgnoreAllCookies; KEY IgnoreAllCookies;
VALUE(bool) IgnoreAllCookiesDef; VALUE(bool) IgnoreAllCookiesDef;
} // namespace Network } // namespace Network