Verified Commit 0f979b4e authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

BrowserManager: Get rid of settings wrapping

parent 16761bda
......@@ -127,7 +127,7 @@ WebEngineView {
Controls.MenuItem {
enabled: contextMenu.request != null && contextMenu.request.selectedText
text: contextMenu.request && contextMenu.request.selectedText ? i18n("Search online for '%1'", contextMenu.request.selectedText) : i18n("Search online")
onTriggered: Qt.openUrlExternally(UrlUtils.urlFromUserInput(BrowserManager.searchBaseUrl + contextMenu.request.selectedText));
onTriggered: Qt.openUrlExternally(UrlUtils.urlFromUserInput(Settings.searchBaseUrl + contextMenu.request.selectedText));
}
Controls.MenuItem {
enabled: contextMenu.request !== null && contextMenu.request.linkUrl !== ""
......
......@@ -47,22 +47,6 @@ private Q_SLOTS:
delete m_browserManager;
}
void homepage()
{
const QString newHomepage = QStringLiteral("https://kde.org");
m_browserManager->setHomepage(newHomepage);
QCOMPARE(m_browserManager->homepage(), newHomepage);
}
void searchEngine()
{
const QString newSearchEngineUrl = QStringLiteral("https://search.angelfish.kde?q=");
m_browserManager->setSearchBaseUrl(newSearchEngineUrl);
QCOMPARE(m_browserManager->searchBaseUrl(), newSearchEngineUrl);
}
void urlFromUserInput()
{
const QString incompleteUrl = QStringLiteral("kde.org");
......
......@@ -5,8 +5,8 @@
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="angelfishrc" />
<include>"settingshelper.h"</include>
<group name="General">
<!-- Search Engine -->
<group name="SettingsPage">
<!-- The custom search engine that can be added to the list of engines -->
<entry key="searchCustomUrl" type="string"></entry>
</group>
<group name="Browser">
......
......@@ -78,29 +78,6 @@ void BrowserManager::updateIcon(const QString &url, const QString &iconSource)
m_dbmanager->updateIcon(url, iconSource);
}
void BrowserManager::setHomepage(const QString &homepage)
{
if (this->homepage() == homepage)
return;
AngelfishSettings::self()->setHomepage(homepage);
emit homepageChanged();
}
QString BrowserManager::homepage()
{
return AngelfishSettings::self()->homepage();
}
void BrowserManager::setSearchBaseUrl(const QString &searchBaseUrl)
{
if (this->searchBaseUrl() == searchBaseUrl)
return;
AngelfishSettings::self()->setSearchBaseUrl(searchBaseUrl);
emit searchBaseUrlChanged();
}
QString BrowserManager::initialUrl() const
{
return m_initialUrl;
......@@ -111,11 +88,6 @@ void BrowserManager::setInitialUrl(const QString &initialUrl)
m_initialUrl = initialUrl;
}
QString BrowserManager::searchBaseUrl()
{
return AngelfishSettings::self()->searchBaseUrl();
}
BrowserManager *BrowserManager::instance()
{
if (!s_instance)
......
......@@ -38,9 +38,6 @@ class BrowserManager : public QObject
{
Q_OBJECT
Q_PROPERTY(QString homepage READ homepage WRITE setHomepage NOTIFY homepageChanged)
Q_PROPERTY(QString searchBaseUrl READ searchBaseUrl WRITE setSearchBaseUrl NOTIFY searchBaseUrlChanged)
Q_PROPERTY(QString initialUrl READ initialUrl WRITE setInitialUrl NOTIFY initialUrlChanged)
public:
......@@ -48,19 +45,12 @@ public:
static BrowserManager *instance();
QString homepage();
QString searchBaseUrl();
QSettings *settings() const;
QString initialUrl() const;
void setInitialUrl(const QString &initialUrl);
signals:
void updated();
void homepageChanged();
void searchBaseUrlChanged();
void initialUrlChanged();
void databaseTableChanged(QString table);
......@@ -76,9 +66,6 @@ public slots:
void updateLastVisited(const QString &url);
void updateIcon(const QString &url, const QString &iconSource);
void setHomepage(const QString &homepage);
void setSearchBaseUrl(const QString &searchBaseUrl);
private:
// BrowserManager should only be createdd by calling the instance() function
BrowserManager(QObject *parent = nullptr);
......
......@@ -100,7 +100,7 @@ Controls.Drawer {
if (text.match(RegexWebUrl.re_weburl)) {
currentWebView.url = UrlUtils.urlFromUserInput(text);
} else {
currentWebView.url = UrlUtils.urlFromUserInput(BrowserManager.searchBaseUrl + text);
currentWebView.url = UrlUtils.urlFromUserInput(Settings.searchBaseUrl + text);
}
overlay.close();
}
......
......@@ -41,7 +41,7 @@ Kirigami.ScrollablePage {
color: Kirigami.Theme.backgroundColor
}
property string baseUrl: BrowserManager.searchBaseUrl
property string baseUrl: Settings.searchBaseUrl
ColumnLayout {
id: list
......@@ -157,7 +157,7 @@ Kirigami.ScrollablePage {
onBaseUrlChanged: {
var t = UrlUtils.urlFromUserInput(baseUrl);
BrowserManager.searchBaseUrl = t;
Settings.searchBaseUrl = t;
}
Component.onCompleted: {
......
......@@ -131,7 +131,7 @@ WebEngineView {
Controls.MenuItem {
enabled: contextMenu.request != null && contextMenu.request.selectedText
text: contextMenu.request && contextMenu.request.selectedText ? i18n("Search online for '%1'", contextMenu.request.selectedText) : i18n("Search online")
onTriggered: tabsModel.newTab(UrlUtils.urlFromUserInput(BrowserManager.searchBaseUrl + contextMenu.request.selectedText));
onTriggered: tabsModel.newTab(UrlUtils.urlFromUserInput(Settings.searchBaseUrl + contextMenu.request.selectedText));
}
Controls.MenuItem {
enabled: contextMenu.request !== null && contextMenu.request.linkUrl !== ""
......
......@@ -27,6 +27,7 @@
#include <QUrl>
#include "browsermanager.h"
#include "angelfishsettings.h"
TabsModel::TabsModel(QObject *parent)
: QAbstractListModel(parent)
......@@ -98,7 +99,7 @@ void TabsModel::loadInitialTabs()
if (!m_privateMode) {
if (BrowserManager::instance()->initialUrl().isEmpty()) {
if (m_tabs.first().url() == QStringLiteral("about:blank"))
setUrl(0, BrowserManager::instance()->homepage());
setUrl(0, AngelfishSettings::self()->homepage());
} else {
if (m_tabs.first().url() == QStringLiteral("about:blank"))
setUrl(0, BrowserManager::instance()->initialUrl());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment