1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 10:16:34 +01:00

UserAgentDialog: Use QUrl::host on user URL input

The system internally works with QUrl::host to compare the visited and
stored addresses to set UserAgent.

BUG: 497223

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2024-12-11 00:18:09 +01:00
parent 90078e4038
commit f4b371e8f0
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
2 changed files with 31 additions and 2 deletions

View File

@ -220,6 +220,34 @@ void ProfileManager::updateProfile(const QString &current, const QString &profil
if (prof < Updater::Version(QStringLiteral("3.1.99"))) {
return;
}
if (prof < Updater::Version(QStringLiteral("25.03.80"))) {
QSettings settings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini"), QSettings::IniFormat);
settings.beginGroup(QSL("User-Agent-Settings"));
QStringList domainList = settings.value(QSL("DomainList"), QStringList()).toStringList();
QStringList userAgentsList = settings.value(QSL("UserAgentsList"), QStringList()).toStringList();
if (domainList.count() == userAgentsList.count()) {
QStringList modifiedDomainList;
QStringList modifiedUserAgentsList;
for (int i = 0; i < domainList.count(); ++i) {
QString host = QUrl(domainList.at(i)).host();
if (!host.isEmpty()) {
modifiedDomainList.append(host);
modifiedUserAgentsList.append(userAgentsList.at(i));
}
}
settings.setValue(QSL("DomainList"), modifiedDomainList);
settings.setValue(QSL("UserAgentsList"), modifiedUserAgentsList);
settings.endGroup();
settings.sync();
qInfo() << "ProfileManager: Updated UserAgent per domain settings";
}
}
}
void ProfileManager::copyDataToProfile()

View File

@ -26,6 +26,7 @@
#include <QFormLayout>
#include <QLineEdit>
#include <QLabel>
#include <QUrl>
UserAgentDialog::UserAgentDialog(QWidget* parent)
: QDialog(parent)
@ -97,7 +98,7 @@ void UserAgentDialog::addSite()
QString userAgent;
if (showEditDialog(tr("Add new site"), &site, &userAgent)) {
auto* siteItem = new QTableWidgetItem(site);
auto* siteItem = new QTableWidgetItem(QUrl(site).host());
auto* userAgentItem = new QTableWidgetItem(userAgent);
int row = ui->table->rowCount();
@ -135,7 +136,7 @@ void UserAgentDialog::editSite()
QString userAgent = userAgentItem->text();
if (showEditDialog(tr("Edit site"), &site, &userAgent)) {
siteItem->setText(site);
siteItem->setText(QUrl(site).host());
userAgentItem->setText(userAgent);
}
}