aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/macros/savedialog.cpp
blob: 24b4b5036866ae435626be199fa2976b0dec8d73 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (C) 2016 Nicolas Arnaud-Cormos
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#include "savedialog.h"

#include <utils/layoutbuilder.h>

#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QRegularExpressionValidator>

using namespace Utils;

namespace Macros::Internal {

SaveDialog::SaveDialog(QWidget *parent) :
    QDialog(parent)
{
    resize(219, 91);
    setWindowTitle(tr("Save Macro"));

    m_name = new QLineEdit;
    m_name->setValidator(new QRegularExpressionValidator(QRegularExpression(QLatin1String("\\w*")), this));

    m_description = new QLineEdit;

    auto buttonBox = new QDialogButtonBox;
    buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Save);

    using namespace Layouting;

    Form {
        tr("Name:"), m_name, br,
        tr("Description:"), m_description, br,
        buttonBox
    }.attachTo(this);

    connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
    connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
}

SaveDialog::~SaveDialog() = default;

QString SaveDialog::name() const
{
    return m_name->text();
}

QString SaveDialog::description() const
{
    return m_description->text();
}

} // Macros::Internal