aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-06-07 12:34:16 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-06-07 12:34:16 +0200
commitaaca93be3d8f153dce3ae98d4d4787463f3210cf (patch)
treefb2eeabd937e056bd5006f3aca1f19b9776a31c3
parentCheck URL validity before searching (diff)
downloadsmolbote-aaca93be3d8f153dce3ae98d4d4787463f3210cf.tar.xz
Don't copy profiles into profile manager plugin
-rw-r--r--plugins/ProfileEditor/CMakeLists.txt3
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.cpp8
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.h6
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.cpp20
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.h4
-rw-r--r--plugins/interfaces.h10
-rw-r--r--src/browser.cpp4
7 files changed, 29 insertions, 26 deletions
diff --git a/plugins/ProfileEditor/CMakeLists.txt b/plugins/ProfileEditor/CMakeLists.txt
index 2fa3ba8..0308fde 100644
--- a/plugins/ProfileEditor/CMakeLists.txt
+++ b/plugins/ProfileEditor/CMakeLists.txt
@@ -17,7 +17,8 @@ add_library(ProfileEditorPlugin SHARED
)
target_include_directories(ProfileEditorPlugin
- PRIVATE ..)
+ PRIVATE ..
+ PRIVATE ../../src/webengine)
target_link_libraries(ProfileEditorPlugin
PRIVATE Qt5::Widgets
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
index 13f974f..1c4d100 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
@@ -1,9 +1,9 @@
#include "profilemanagerdialog.h"
#include "profileview.h"
#include "ui_profilemanagerdialog.h"
-#include <QWebEngineProfile>
+#include <webprofile.h>
-ProfileManagerDialog::ProfileManagerDialog(QHash<QString, QWebEngineProfile *> &profiles, QWidget *parent)
+ProfileManagerDialog::ProfileManagerDialog(QHash<QString, WebProfile *> *profiles, QWidget *parent)
: QDialog(parent)
, ui(new Ui::ProfileManagerDialog)
, profiles(profiles)
@@ -13,7 +13,7 @@ ProfileManagerDialog::ProfileManagerDialog(QHash<QString, QWebEngineProfile *> &
connect(ui->listWidget, &QListWidget::itemPressed, this, &ProfileManagerDialog::showProfile);
showProfile(nullptr);
- for(auto i = profiles.constBegin(); i != profiles.constEnd(); ++i) {
+ for(auto i = profiles->constBegin(); i != profiles->constEnd(); ++i) {
ui->listWidget->addItem(i.key());
}
}
@@ -38,6 +38,6 @@ void ProfileManagerDialog::showProfile(QListWidgetItem *item)
}
ui->groupBox->setVisible(true);
- auto *v = new ProfileView(profiles.value(item->text()), this);
+ auto *v = new ProfileView(profiles->value(item->text()), this);
ui->groupBox->layout()->addWidget(v);
}
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.h b/plugins/ProfileEditor/forms/profilemanagerdialog.h
index 9ce177d..ba315ce 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.h
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.h
@@ -9,14 +9,14 @@ namespace Ui
class ProfileManagerDialog;
}
-class QWebEngineProfile;
+class WebProfile;
class QListWidgetItem;
class ProfileManagerDialog : public QDialog
{
Q_OBJECT
public:
- explicit ProfileManagerDialog(QHash<QString, QWebEngineProfile *> &profiles, QWidget *parent = 0);
+ explicit ProfileManagerDialog(QHash<QString, WebProfile *> *profiles, QWidget *parent = 0);
~ProfileManagerDialog();
private slots:
@@ -24,7 +24,7 @@ private slots:
private:
Ui::ProfileManagerDialog *ui;
- const QHash<QString, QWebEngineProfile *> profiles;
+ const QHash<QString, WebProfile *> *profiles;
};
#endif // PROFILEMANAGERDIALOG_H
diff --git a/plugins/ProfileEditor/profileeditorplugin.cpp b/plugins/ProfileEditor/profileeditorplugin.cpp
index d0341b9..2e7b261 100644
--- a/plugins/ProfileEditor/profileeditorplugin.cpp
+++ b/plugins/ProfileEditor/profileeditorplugin.cpp
@@ -10,26 +10,30 @@
#include "forms/profilemanagerdialog.h"
#include "forms/profileview.h"
#include <QHash>
+#include <webprofile.h>
QHash<QString, std::function<int()>> ProfileEditorPlugin::commands()
{
QHash<QString, std::function<int()>> hash;
- hash.insert("profileEditor:about", []() -> int {
- qDebug("ProfileEditor for smolbote");
- return 0;
- });
- hash.insert("profileEditor:edit", [this]() -> int {
+ hash.insert("edit-profiles-ui", [this]() -> int {
auto *dialog = createWidget(nullptr);
return dialog->exec();
});
+
+ hash.insert("list-profiles", [this]() -> int {
+ for(auto i = profiles->constBegin(); i != profiles->constEnd(); ++i) {
+ qDebug(" - %s", qUtf8Printable(i.key()));
+ }
+ return 0;
+ });
return hash;
}
-void ProfileEditorPlugin::addProfile(const QString &name, QWebEngineProfile *profile)
+void ProfileEditorPlugin::setProfiles(QHash<QString, WebProfile *> *profiles)
{
- Q_CHECK_PTR(profile);
- profiles.insert(name, profile);
+ Q_CHECK_PTR(profiles);
+ this->profiles = profiles;
}
QDialog *ProfileEditorPlugin::createWidget(QWidget *parent)
diff --git a/plugins/ProfileEditor/profileeditorplugin.h b/plugins/ProfileEditor/profileeditorplugin.h
index 7ae0a57..db82cfb 100644
--- a/plugins/ProfileEditor/profileeditorplugin.h
+++ b/plugins/ProfileEditor/profileeditorplugin.h
@@ -25,11 +25,11 @@ public:
QHash<QString, std::function<int()>> commands() override;
// ProfileInterface
- void addProfile(const QString &name, QWebEngineProfile *profile) override;
+ void setProfiles(QHash<QString, WebProfile *> *profiles) override;
QDialog *createWidget(QWidget *parent) override;
private:
- QHash<QString, QWebEngineProfile *> profiles;
+ QHash<QString, WebProfile *> *profiles;
};
#endif //PROFILEEDITOR_PLUGIN_H
diff --git a/plugins/interfaces.h b/plugins/interfaces.h
index d6bff54..8b5b78c 100644
--- a/plugins/interfaces.h
+++ b/plugins/interfaces.h
@@ -6,8 +6,8 @@
* SPDX-License-Identifier: MIT
*/
-#ifndef INTERFACES_H
-#define INTERFACES_H
+#ifndef SMOLBOTE_PLUGIN_INTERFACES_H
+#define SMOLBOTE_PLUGIN_INTERFACES_H
#include <QtPlugin>
#include <memory>
@@ -16,7 +16,7 @@
class QString;
class QAction;
class QDialog;
-class QWebEngineProfile;
+class WebProfile;
struct Plugin
{
@@ -34,7 +34,7 @@ class ProfileInterface
{
public:
virtual ~ProfileInterface() = default;
- virtual void addProfile(const QString &name, QWebEngineProfile *profile) = 0;
+ virtual void setProfiles(QHash<QString, WebProfile *> *profiles) = 0;
virtual QDialog *createWidget(QWidget *parent = nullptr) = 0;
};
@@ -44,4 +44,4 @@ Q_DECLARE_INTERFACE(PluginInterface, PluginInterfaceIid)
#define ProfileInterfaceIid "net.iserlohn-fortress.smolbote.ProfileInterface"
Q_DECLARE_INTERFACE(ProfileInterface, ProfileInterfaceIid)
-#endif //INTERFACES_H
+#endif // SMOLBOTE_PLUGIN_INTERFACES_H
diff --git a/src/browser.cpp b/src/browser.cpp
index 2985dd3..11feac0 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -123,9 +123,7 @@ void Browser::setup(const QString &defaultProfile)
auto *profileEditor = qobject_cast<ProfileInterface *>(p.instance.get());
Q_ASSERT_X(profileEditor != nullptr, "Browser::setup", "profile interface cast failed");
- for(auto i = m_profiles.constBegin(); i != m_profiles.constEnd(); ++i) {
- profileEditor->addProfile(i.key(), qobject_cast<QWebEngineProfile*>(i.value()));
- }
+ profileEditor->setProfiles(&m_profiles);
}
auto *plugin = qobject_cast<PluginInterface *>(p.instance.get());