diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-10-09 12:05:28 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-10-09 12:05:28 +0200 |
commit | 3639d5789259561c531a3481d7061a0cb492c644 (patch) | |
tree | c9c7ff04022b62cf5be4d4ea31bf28d966ccefda /plugins/ProfileEditor/profileeditorplugin.cpp | |
parent | Create .profile file when adding a new profile (diff) | |
download | smolbote-3639d5789259561c531a3481d7061a0cb492c644.tar.xz |
Unlink plugins from lib/ libraries
Diffstat (limited to 'plugins/ProfileEditor/profileeditorplugin.cpp')
-rw-r--r-- | plugins/ProfileEditor/profileeditorplugin.cpp | 36 |
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; |