summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp140
-rw-r--r--src/application.hpp7
-rw-r--r--src/plugins/rplugininterface.hpp2
-rw-r--r--src/rekonq.kcfg4
-rw-r--r--src/rekonqwindow.cpp3
-rw-r--r--src/rekonqwindow.ui6
-rw-r--r--src/settings/settings.cpp2
-rw-r--r--src/settings/settings.hpp8
-rw-r--r--src/settings/test/settings_mock.hpp11
-rw-r--r--src/settings/test/test_settings.cpp16
-rw-r--r--src/settings/test/test_settingsdialog.cpp7
-rw-r--r--src/taskmanager.cpp1
-rw-r--r--src/taskmanager.ui27
13 files changed, 99 insertions, 135 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 69279734..814bfab8 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -13,7 +13,11 @@
#include "plugins/pluginloader.h"
#include "plugins/rplugininterface.hpp"
#include "rekonqwindow.h"
+#include "settings/settings.hpp"
+#include <QDir>
#include <QPluginLoader>
+#include <QStandardPaths>
+#include <spdlog/spdlog.h>
// ---------------------------------------------------------------------------------------------------------------
// Ctor and Dtor
@@ -24,7 +28,18 @@ Application::Application(int &argc, char *argv[]) : SingleApplication(argc, argv
connect(this, &SingleApplication::receivedMessage, this, &Application::parseCommandLine);
// updating rekonq configuration
- // updateConfiguration();
+ const auto settingsPath =
+ QDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)).filePath("rekonqrc");
+ spdlog::info("Loading rekonq configuration: {}", qUtf8Printable(settingsPath));
+ m_settings = new Settings(settingsPath, this);
+
+ // load default plugins
+ for (const auto &location : QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation)) {
+ QDir dir(location + "/plugins");
+ spdlog::info("Loading rekonq plugins: {}", qUtf8Printable(dir.absolutePath()));
+
+ for (const auto &fileName : dir.entryList({"*.so"}, QDir::Files)) registerPlugin(dir.absoluteFilePath(fileName));
+ }
// setWindowIcon(KIcon("rekonq"));
@@ -37,6 +52,7 @@ Application::~Application()
// ok, we are closing well: don't recover on next load..
// ReKonfig::setRecoverOnCrash(0);
// saveConfiguration();
+ delete m_settings;
// Destroy all windows...
for (const auto &window : m_windows) delete window;
@@ -57,11 +73,15 @@ Application::~Application()
bool Application::registerPlugin(const QString &path)
{
auto *loader = new PluginLoader(path);
- if (!loader->load()) {
+ const auto is_loaded = loader->load();
+ spdlog::info("{:<60}{:>20}", qUtf8Printable(path), is_loaded ? "ok" : "failed");
+ if (!is_loaded) {
+ spdlog::warn(qUtf8Printable(loader->errorString()));
delete loader;
return false;
}
+ loader->interface()->init(m_settings);
m_plugins.append(loader);
return true;
}
@@ -484,122 +504,6 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
w->loadUrl(url, newType);
}
-
-void Application::updateConfiguration()
-{
- QWebSettings *defaultSettings = QWebSettings::globalSettings();
-
- // =========== Fonts ==============
- defaultSettings->setFontFamily(QWebSettings::StandardFont, ReKonfig::standardFontFamily());
- defaultSettings->setFontFamily(QWebSettings::FixedFont, ReKonfig::fixedFontFamily());
- defaultSettings->setFontFamily(QWebSettings::SerifFont, ReKonfig::serifFontFamily());
- defaultSettings->setFontFamily(QWebSettings::SansSerifFont, ReKonfig::sansSerifFontFamily());
- defaultSettings->setFontFamily(QWebSettings::CursiveFont, ReKonfig::cursiveFontFamily());
- defaultSettings->setFontFamily(QWebSettings::FantasyFont, ReKonfig::fantasyFontFamily());
-
- defaultSettings->setFontSize(QWebSettings::DefaultFontSize, ReKonfig::defaultFontSize());
- defaultSettings->setFontSize(QWebSettings::MinimumFontSize, ReKonfig::minFontSize());
-
- // encodings
- QString enc = ReKonfig::defaultEncoding();
- defaultSettings->setDefaultTextEncoding(enc);
-
- // ================ WebKit ============================
- defaultSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, ReKonfig::dnsPrefetch());
- defaultSettings->setAttribute(QWebSettings::PrintElementBackgrounds, ReKonfig::printElementBackgrounds());
- defaultSettings->setAttribute(QWebSettings::ZoomTextOnly, ReKonfig::zoomTextOnly());
-
- defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, ReKonfig::javascriptEnabled());
- defaultSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, ReKonfig::javascriptCanOpenWindows());
- defaultSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, ReKonfig::javascriptCanAccessClipboard());
-
- defaultSettings->setAttribute(QWebSettings::JavaEnabled, ReKonfig::javaEnabled());
-
- if (ReKonfig::pluginsEnabled() == 2)
- defaultSettings->setAttribute(QWebSettings::PluginsEnabled, false);
- else
- defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true);
-
- // Enabling WebKit "Page Cache" feature: http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
- defaultSettings->setMaximumPagesInCache(3);
-
- // ===== HTML 5 features WebKit support ======
- defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled,
-ReKonfig::offlineStorageDatabaseEnabled());
- defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled,
-ReKonfig::offlineWebApplicationCacheEnabled()); defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled,
-ReKonfig::localStorageEnabled()); if (ReKonfig::localStorageEnabled())
- {
- QString path = KStandardDirs::locateLocal("cache", QString("WebkitLocalStorage/rekonq"), true);
- path.remove("rekonq");
- QWebSettings::setOfflineStoragePath(path);
- QWebSettings::setOfflineStorageDefaultQuota(ReKonfig::offlineWebApplicationCacheQuota() * 1024);
- }
-
- // ================= WebGl ===================
- defaultSettings->setAttribute(QWebSettings::WebGLEnabled, ReKonfig::webGL());
- defaultSettings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, ReKonfig::webGL());
-
- // Applies user defined CSS to all open webpages.
- defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS());
-
- // ====== load Settings on main classes
- HistoryManager::self()->loadSettings();
-
- defaultSettings = 0;
-
- if (!rekonqWindow())
- return;
-
- // ============== Tabs ==================
- bool b = ReKonfig::closeTabSelectPrevious();
- Q_FOREACH(const QWeakPointer<RekonqWindow> &w, m_rekonqWindows)
- {
- if (b)
- w.data()->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
- else
- w.data()->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab);
- }
-
- // FIXME What about this?
-// ReKonfig::useFavicon()
-// ? rekonqWindow()->changeWindowIcon(rekonqWindow()->mainView()->currentIndex())
-// : rekonqWindow()->setWindowIcon(KIcon("rekonq"))
-// ;
-//
- // hovering unfocused tabs options
- switch (ReKonfig::hoveringTabOption())
- {
- case 0: // tab previews
- case 3: // nothing
- for (int i = 0; i < rekonqWindow()->tabBar()->count(); i++)
- {
- rekonqWindow()->tabBar()->setTabToolTip(i, QL1S(""));
- }
- break;
-
- case 1: // title previews
- for (int i = 0; i < rekonqWindow()->tabBar()->count(); i++)
- {
- rekonqWindow()->tabBar()->setTabToolTip(i, rekonqWindow()->tabWidget()->tabText(i).remove('&'));
- }
- break;
-
- case 2: // url previews
- for (int i = 0; i < rekonqWindow()->tabBar()->count(); i++)
- {
- rekonqWindow()->tabBar()->setTabToolTip(i,
-rekonqWindow()->tabWidget()->webWindow(i)->url().toMimeDataString());
- }
- break;
-
- default: // non extant case
- ASSERT_NOT_REACHED(unknown hoveringTabOption);
- break;
- }
-}
-
-
void Application::queryQuit()
{
if (m_webApps.count() > 0)
diff --git a/src/application.hpp b/src/application.hpp
index 9d98b5a0..cc38bda9 100644
--- a/src/application.hpp
+++ b/src/application.hpp
@@ -21,9 +21,7 @@
class RekonqView;
class RekonqWindow;
class PluginLoader;
-
-// class WebTab;
-// class WebPage;
+class RekonqSettings;
typedef QList<QPointer<PluginLoader>> RekonqPluginList;
typedef QList<QPointer<RekonqWindow>> RekonqWindowList;
@@ -46,6 +44,7 @@ public:
// int newInstance();
static Application *instance() { return (qobject_cast<Application *>(QCoreApplication::instance())); }
+ [[nodiscard]] auto *settings() const { return m_settings; }
// RekonqWindow *rekonqWindow(const QString &activityID = QString());
[[nodiscard]] auto windowList() const { return m_windows; }
@@ -122,6 +121,8 @@ private slots:
// void pageCreated(WebPage *);
private:
+ RekonqSettings *m_settings;
+
RekonqPluginList m_plugins;
RekonqWindowList m_windows;
RekonqViewList m_views;
diff --git a/src/plugins/rplugininterface.hpp b/src/plugins/rplugininterface.hpp
index e45f2422..0a12e3aa 100644
--- a/src/plugins/rplugininterface.hpp
+++ b/src/plugins/rplugininterface.hpp
@@ -9,6 +9,8 @@
#pragma once
+#include "rsettings.hpp"
+#include "rview.hpp"
#include <QtPlugin>
#include <rsettings.hpp>
#include <rview.hpp>
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index b51f0526..0de9cd44 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -26,8 +26,8 @@
<entry name="Default Search Engine" key="searchUrl" type="String">
<default>https://duckduckgo.com/?q=%1</default>
</entry>
- <entry name="Configuration Path" key="configPath" type="String">
- <default>TODO: change type to Path</default>
+ <entry name="Profile Path" key="profilePath" type="String">
+ <default code="true">TODO: change type to Path</default>
</entry>
<entry name="Load plugins from" key="pluginPath" type="String">
<default>TODO: change type to Path</default>
diff --git a/src/rekonqwindow.cpp b/src/rekonqwindow.cpp
index b1380154..c2355afb 100644
--- a/src/rekonqwindow.cpp
+++ b/src/rekonqwindow.cpp
@@ -11,6 +11,7 @@
#include "rekonqwindow.h"
#include "application.hpp"
+#include "settings/settingsdialog.h"
#include "taskmanager.h"
#include "ui_rekonqwindow.h"
#include <rview.hpp>
@@ -18,6 +19,8 @@
RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::RekonqWindow)
{
ui->setupUi(this);
+ connect(ui->actionSettings, &QAction::triggered, this,
+ [this]() { (new SettingsDialog(Application::instance()->settings(), this))->show(); });
connect(ui->actionTaskManager, &QAction::triggered, this, [this]() { (new TaskManager(this))->show(); });
}
diff --git a/src/rekonqwindow.ui b/src/rekonqwindow.ui
index 9df36cf2..ee76a408 100644
--- a/src/rekonqwindow.ui
+++ b/src/rekonqwindow.ui
@@ -50,6 +50,7 @@
</property>
<addaction name="actionTaskManager"/>
<addaction name="separator"/>
+ <addaction name="actionSettings"/>
<addaction name="actionCloseWindow"/>
</widget>
<addaction name="menurekonq"/>
@@ -68,6 +69,11 @@
<string>Close Window</string>
</property>
</action>
+ <action name="actionSettings">
+ <property name="text">
+ <string>Configure rekonq</string>
+ </property>
+ </action>
</widget>
<resources/>
<connections>
diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp
index 1ffa14cb..190bc977 100644
--- a/src/settings/settings.cpp
+++ b/src/settings/settings.cpp
@@ -26,3 +26,5 @@ void Settings::setValue(const QString &key, const QVariant &value)
}
QVariant Settings::value(const QString &key, const QVariant &defaultValue) const { return d->value(key, defaultValue); }
+
+QString Settings::filePath() const { return d->fileName(); }
diff --git a/src/settings/settings.hpp b/src/settings/settings.hpp
index c595e981..ec654f17 100644
--- a/src/settings/settings.hpp
+++ b/src/settings/settings.hpp
@@ -16,14 +16,16 @@ class Settings final : public RekonqSettings {
Q_OBJECT
public:
- explicit Settings(const QString &path, QObject *parent = nullptr);
- ~Settings() = default;
+ explicit Settings(const QString &settingsPath, QObject *parent = nullptr);
+ ~Settings() override = default;
void beginGroup(const QString &prefix) override;
void endGroup() override;
void setValue(const QString &key, const QVariant &value) override;
- QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const override;
+ [[nodiscard]] QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const override;
+
+ [[nodiscard]] QString filePath() const override;
private:
QSettings *d;
diff --git a/src/settings/test/settings_mock.hpp b/src/settings/test/settings_mock.hpp
index ec792ff5..bc3fbc2f 100644
--- a/src/settings/test/settings_mock.hpp
+++ b/src/settings/test/settings_mock.hpp
@@ -1,3 +1,10 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
#pragma once
#include <gmock/gmock.h>
@@ -8,11 +15,13 @@ class MockSettings : public RekonqSettings {
public:
explicit MockSettings() : RekonqSettings(nullptr) {}
- ~MockSettings() = default;
+ ~MockSettings() override = default;
MOCK_METHOD(void, beginGroup, (const QString &), (override));
MOCK_METHOD(void, endGroup, (), (override));
MOCK_METHOD(void, setValue, (const QString &, const QVariant &), (override));
MOCK_METHOD(QVariant, value, (const QString &, const QVariant &), (const, override));
+
+ MOCK_METHOD(QString, filePath, (), (const, override));
};
diff --git a/src/settings/test/test_settings.cpp b/src/settings/test/test_settings.cpp
index 72582bc7..2ca5ba1a 100644
--- a/src/settings/test/test_settings.cpp
+++ b/src/settings/test/test_settings.cpp
@@ -1,4 +1,13 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
#include <QApplication>
+#include <QDir>
+#include <QStandardPaths>
#include <gtest/gtest.h>
#include <iostream>
@@ -23,6 +32,13 @@ TEST(settings, getFont)
EXPECT_EQ(fixed.styleHint(), QFont::Monospace) << qUtf8Printable(fixed.toString());
}
+TEST(settings, settingsPath)
+{
+ const auto path = QDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)).filePath("rekonqrc");
+ EXPECT_FALSE(path.isEmpty());
+ EXPECT_TRUE(path.endsWith("rekonqrc"));
+}
+
TEST(settings, Settings)
{
Settings settings(settingsFile);
diff --git a/src/settings/test/test_settingsdialog.cpp b/src/settings/test/test_settingsdialog.cpp
index b70c6dda..a50cf307 100644
--- a/src/settings/test/test_settingsdialog.cpp
+++ b/src/settings/test/test_settingsdialog.cpp
@@ -1,3 +1,10 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
#include "../settingsdialog.h"
#include "settings_mock.hpp"
#include <QApplication>
diff --git a/src/taskmanager.cpp b/src/taskmanager.cpp
index b69b30b8..ef1f44fb 100644
--- a/src/taskmanager.cpp
+++ b/src/taskmanager.cpp
@@ -16,6 +16,7 @@
TaskManager::TaskManager(QWidget *parent) : QDialog(parent), ui(new Ui::TaskManager)
{
ui->setupUi(this);
+ ui->settings->setText(Application::instance()->settings()->filePath());
ui->pluginStateBox->setVisible(false);
auto *app = Application::instance();
diff --git a/src/taskmanager.ui b/src/taskmanager.ui
index 8242e43c..d709eb32 100644
--- a/src/taskmanager.ui
+++ b/src/taskmanager.ui
@@ -119,14 +119,25 @@
</widget>
</item>
<item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Close</set>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="settings">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>