aboutsummaryrefslogtreecommitdiff
path: root/plugins/ProfileEditor/profileeditorplugin.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-06-01 17:27:58 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-06-01 17:27:58 +0200
commit329e8de84fc8e0a2e4a04fbaf85ab0e1632c6084 (patch)
tree864df8426b543d6817d6e364be4889bc6e20d640 /plugins/ProfileEditor/profileeditorplugin.cpp
parentMiddle mouse button closes tab (diff)
downloadsmolbote-329e8de84fc8e0a2e4a04fbaf85ab0e1632c6084.tar.xz
Only add profiles to profile manager at init
Diffstat (limited to 'plugins/ProfileEditor/profileeditorplugin.cpp')
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/plugins/ProfileEditor/profileeditorplugin.cpp b/plugins/ProfileEditor/profileeditorplugin.cpp
index 041dbe7..d0341b9 100644
--- a/plugins/ProfileEditor/profileeditorplugin.cpp
+++ b/plugins/ProfileEditor/profileeditorplugin.cpp
@@ -7,26 +7,34 @@
*/
#include "profileeditorplugin.h"
-#include "forms/profileview.h"
#include "forms/profilemanagerdialog.h"
+#include "forms/profileview.h"
#include <QHash>
-QHash<QString, std::function<int ()> > ProfileEditorPlugin::commands()
+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 {
+ auto *dialog = createWidget(nullptr);
+ return dialog->exec();
+ });
return hash;
}
-QDialog *ProfileEditorPlugin::createWidget(QHash<QString, QWebEngineProfile *> profiles, QWidget *parent)
+void ProfileEditorPlugin::addProfile(const QString &name, QWebEngineProfile *profile)
+{
+ Q_CHECK_PTR(profile);
+ profiles.insert(name, profile);
+}
+
+QDialog *ProfileEditorPlugin::createWidget(QWidget *parent)
{
- auto *widget = new ProfileManagerDialog(parent);
- for(const QString &name : profiles.keys()) {
- widget->addProfile(name, profiles.value(name));
- }
+ auto *widget = new ProfileManagerDialog(profiles, parent);
widget->setAttribute(Qt::WA_DeleteOnClose, true);
return widget;
}