aboutsummaryrefslogtreecommitdiff
path: root/plugins/ConfigurationEditor/configurationeditorplugin.cpp
blob: 93b1c695daf2605e0eb985b1adc0d73caf481194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "configurationeditorplugin.h"
#include <QHash>
#include <QDialog>
#include "forms/configurationdialog.h"
#include <configuration.h>

CommandHash_t ConfigurationEditorPlugin::commands()
{
    QHash<QString, std::function<int()>> hash;

    hash.insert("configure", [this]() -> int {
                    auto *dlg = createWidget(nullptr);
                    return dlg->exec();
                });

    return hash;
}

QDialog *ConfigurationEditorPlugin::createWidget(QWidget *parent)
{
    auto *dlg = new ConfigurationDialog(m_config, parent);
    dlg->setAttribute(Qt::WA_DeleteOnClose, true);
    return dlg;
}

void ConfigurationEditorPlugin::setConfiguration(Configuration *cfg)
{
    Q_CHECK_PTR(cfg);
    m_config = cfg;
}