aboutsummaryrefslogtreecommitdiff
path: root/plugins/ProfileEditor/profileeditorplugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ProfileEditor/profileeditorplugin.cpp')
-rw-r--r--plugins/ProfileEditor/profileeditorplugin.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/plugins/ProfileEditor/profileeditorplugin.cpp b/plugins/ProfileEditor/profileeditorplugin.cpp
index 1eb7b28..d480392 100644
--- a/plugins/ProfileEditor/profileeditorplugin.cpp
+++ b/plugins/ProfileEditor/profileeditorplugin.cpp
@@ -8,9 +8,7 @@
#include "profileeditorplugin.h"
#include "forms/profilemanagerdialog.h"
-#include "forms/profileview.h"
-#include <QVector>
-#include <webprofile.h>
+#include "forms/newprofiledialog.h"
QHash<QString, std::function<int()>> ProfileEditorPlugin::commands()
{
@@ -23,20 +21,34 @@ QHash<QString, std::function<int()>> ProfileEditorPlugin::commands()
return hash;
}
-QDialog *ProfileEditorPlugin::createWidget(QWidget *parent)
+QDialog *ProfileEditorPlugin::createWidget(QWidget *parent) const
{
- Q_CHECK_PTR(browser);
- auto *widget = new ProfileManagerDialog(browser->getProfileManager(), parent);
+ auto *app = browser();
+ Q_CHECK_PTR(app);
+ auto *widget = new ProfileManagerDialog(parent);
widget->setAttribute(Qt::WA_DeleteOnClose, true);
- connect(widget, &ProfileManagerDialog::createProfile, this, [=](const QString &id) {
- auto newProfile = browser->loadProfile(id);
- widget->addProfile(newProfile.second);
+ for(const auto &pair : app->profileList()) {
+ widget->addProfile(pair.first, pair.second);
+ }
+
+ connect(widget->ui->new_pushButton, &QPushButton::clicked, widget, [=]() {
+ auto *newProfileDlg = new NewProfileDialog(widget);
+ if(newProfileDlg->exec() == QDialog::Accepted) {
+ const auto pair = app->loadProfile(newProfileDlg->getId(), newProfileDlg->getOtr());
+ widget->addProfile(pair.first, pair.second);
+ }
+ delete newProfileDlg;
});
- connect(widget, &ProfileManagerDialog::removeProfile, this, [this](const WebProfile *profile) {
- const QString id = browser->getProfileManager()->id(profile);
- browser->getProfileManager()->deleteProfile(id);
+ connect(widget->ui->delete_pushButton, &QPushButton::clicked, widget, [=]() {
+ auto *item = widget->ui->listWidget->currentItem();
+ if(item != nullptr) {
+ // there is a selected widget
+ const QString id = item->text();
+ widget->showProfile(nullptr);
+ app->removeProfile(id);
+ }
});
return widget;