From aaca93be3d8f153dce3ae98d4d4787463f3210cf Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 7 Jun 2018 12:34:16 +0200 Subject: Don't copy profiles into profile manager plugin --- plugins/ProfileEditor/CMakeLists.txt | 3 ++- plugins/ProfileEditor/forms/profilemanagerdialog.cpp | 8 ++++---- plugins/ProfileEditor/forms/profilemanagerdialog.h | 6 +++--- plugins/ProfileEditor/profileeditorplugin.cpp | 20 ++++++++++++-------- plugins/ProfileEditor/profileeditorplugin.h | 4 ++-- plugins/interfaces.h | 10 +++++----- 6 files changed, 28 insertions(+), 23 deletions(-) (limited to 'plugins') 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 +#include -ProfileManagerDialog::ProfileManagerDialog(QHash &profiles, QWidget *parent) +ProfileManagerDialog::ProfileManagerDialog(QHash *profiles, QWidget *parent) : QDialog(parent) , ui(new Ui::ProfileManagerDialog) , profiles(profiles) @@ -13,7 +13,7 @@ ProfileManagerDialog::ProfileManagerDialog(QHash & 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 &profiles, QWidget *parent = 0); + explicit ProfileManagerDialog(QHash *profiles, QWidget *parent = 0); ~ProfileManagerDialog(); private slots: @@ -24,7 +24,7 @@ private slots: private: Ui::ProfileManagerDialog *ui; - const QHash profiles; + const QHash *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 +#include QHash> ProfileEditorPlugin::commands() { QHash> 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 *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> commands() override; // ProfileInterface - void addProfile(const QString &name, QWebEngineProfile *profile) override; + void setProfiles(QHash *profiles) override; QDialog *createWidget(QWidget *parent) override; private: - QHash profiles; + QHash *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 #include @@ -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 *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 -- cgit v1.2.1