aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ProfileEditor/CMakeLists.txt6
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.cpp45
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.h31
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.ui89
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.cpp8
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.h2
-rw-r--r--plugins/interfaces.h2
7 files changed, 178 insertions, 5 deletions
diff --git a/plugins/ProfileEditor/CMakeLists.txt b/plugins/ProfileEditor/CMakeLists.txt
index ad4c457..2fa3ba8 100644
--- a/plugins/ProfileEditor/CMakeLists.txt
+++ b/plugins/ProfileEditor/CMakeLists.txt
@@ -10,7 +10,11 @@ add_library(ProfileEditorPlugin SHARED
profileeditorplugin.h
forms/profileview.cpp
forms/profileview.h
- forms/profileview.ui)
+ forms/profileview.ui
+ forms/profilemanagerdialog.cpp
+ forms/profilemanagerdialog.h
+ forms/profilemanagerdialog.ui
+)
target_include_directories(ProfileEditorPlugin
PRIVATE ..)
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
new file mode 100644
index 0000000..c5fec2b
--- /dev/null
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
@@ -0,0 +1,45 @@
+#include "profilemanagerdialog.h"
+#include "ui_profilemanagerdialog.h"
+#include <QWebEngineProfile>
+#include <QLabel>
+#include "profileview.h"
+
+ProfileManagerDialog::ProfileManagerDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::ProfileManagerDialog)
+{
+ ui->setupUi(this);
+
+ connect(ui->listWidget, &QListWidget::itemPressed, this, &ProfileManagerDialog::showProfile);
+ showProfile(nullptr);
+}
+
+ProfileManagerDialog::~ProfileManagerDialog()
+{
+ delete ui;
+}
+
+void ProfileManagerDialog::addProfile(const QString &name, QWebEngineProfile *profile)
+{
+ profiles.insert(name, profile);
+ ui->listWidget->addItem(name);
+}
+
+void ProfileManagerDialog::showProfile(QListWidgetItem *item)
+{
+ // clear out groupbox layout
+ QLayoutItem *i;
+ while((i = ui->groupBox->layout()->takeAt(0)) != nullptr) {
+ delete i->widget();
+ delete i;
+ }
+
+ if(item == nullptr) {
+ ui->groupBox->setVisible(false);
+ return;
+ }
+ ui->groupBox->setVisible(true);
+
+ 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
new file mode 100644
index 0000000..ed79824
--- /dev/null
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.h
@@ -0,0 +1,31 @@
+#ifndef PROFILEMANAGERDIALOG_H
+#define PROFILEMANAGERDIALOG_H
+
+#include <QDialog>
+#include <QHash>
+
+namespace Ui {
+class ProfileManagerDialog;
+}
+
+class QWebEngineProfile;
+class QListWidgetItem;
+class ProfileManagerDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit ProfileManagerDialog(QWidget *parent = 0);
+ ~ProfileManagerDialog();
+
+ void addProfile(const QString &name, QWebEngineProfile *profile);
+
+private slots:
+ void showProfile(QListWidgetItem *item);
+
+private:
+ Ui::ProfileManagerDialog *ui;
+ QHash<QString, QWebEngineProfile *> profiles;
+};
+
+#endif // PROFILEMANAGERDIALOG_H
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.ui b/plugins/ProfileEditor/forms/profilemanagerdialog.ui
new file mode 100644
index 0000000..ae3829a
--- /dev/null
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.ui
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProfileManagerDialog</class>
+ <widget class="QDialog" name="ProfileManagerDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Profile Manager</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QListWidget" name="listWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2"/>
+ </widget>
+ </item>
+ </layout>
+ </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>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ProfileManagerDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ProfileManagerDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/plugins/ProfileEditor/profileeditorplugin.cpp b/plugins/ProfileEditor/profileeditorplugin.cpp
index b5e772f..041dbe7 100644
--- a/plugins/ProfileEditor/profileeditorplugin.cpp
+++ b/plugins/ProfileEditor/profileeditorplugin.cpp
@@ -8,6 +8,7 @@
#include "profileeditorplugin.h"
#include "forms/profileview.h"
+#include "forms/profilemanagerdialog.h"
#include <QHash>
QHash<QString, std::function<int ()> > ProfileEditorPlugin::commands()
@@ -20,9 +21,12 @@ QHash<QString, std::function<int ()> > ProfileEditorPlugin::commands()
return hash;
}
-QDialog *ProfileEditorPlugin::createWidget(QWebEngineProfile *profile, QWidget *parent)
+QDialog *ProfileEditorPlugin::createWidget(QHash<QString, QWebEngineProfile *> profiles, QWidget *parent)
{
- auto *widget = new ProfileView(profile, parent);
+ auto *widget = new ProfileManagerDialog(parent);
+ for(const QString &name : profiles.keys()) {
+ widget->addProfile(name, profiles.value(name));
+ }
widget->setAttribute(Qt::WA_DeleteOnClose, true);
return widget;
}
diff --git a/plugins/ProfileEditor/profileeditorplugin.h b/plugins/ProfileEditor/profileeditorplugin.h
index 4f88e1b..e026bbe 100644
--- a/plugins/ProfileEditor/profileeditorplugin.h
+++ b/plugins/ProfileEditor/profileeditorplugin.h
@@ -24,7 +24,7 @@ public:
QHash<QString, std::function<int()>> commands() override;
// ProfileInterface
- QDialog *createWidget(QWebEngineProfile *profile, QWidget *parent) override;
+ QDialog *createWidget(QHash<QString, QWebEngineProfile *> profiles, QWidget *parent) override;
};
#endif //PROFILEEDITOR_PLUGIN_H
diff --git a/plugins/interfaces.h b/plugins/interfaces.h
index 196da0b..4e361ab 100644
--- a/plugins/interfaces.h
+++ b/plugins/interfaces.h
@@ -34,7 +34,7 @@ class ProfileInterface
{
public:
virtual ~ProfileInterface() = default;
- virtual QDialog *createWidget(QWebEngineProfile *profile, QWidget *parent) = 0;
+ virtual QDialog *createWidget(QHash<QString, QWebEngineProfile *> profiles, QWidget *parent) = 0;
};
#define PluginInterfaceIid "net.iserlohn-fortress.smolbote.PluginInterface"