1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | #include "gridpanel_p.h" |
5 | #include "ui_gridpanel.h" |
6 | #include "grid_p.h" |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace qdesigner_internal { |
11 | |
12 | GridPanel::GridPanel(QWidget *parentWidget) : |
13 | QWidget(parentWidget) |
14 | { |
15 | m_ui = new Ui::GridPanel; |
16 | m_ui->setupUi(this); |
17 | |
18 | connect(m_ui->m_resetButton, &QAbstractButton::clicked, this, &GridPanel::reset); |
19 | } |
20 | |
21 | GridPanel::~GridPanel() |
22 | { |
23 | delete m_ui; |
24 | } |
25 | |
26 | void GridPanel::setGrid(const Grid &g) |
27 | { |
28 | m_ui->m_deltaXSpinBox->setValue(g.deltaX()); |
29 | m_ui->m_deltaYSpinBox->setValue(g.deltaY()); |
30 | m_ui->m_visibleCheckBox->setCheckState(g.visible() ? Qt::Checked : Qt::Unchecked); |
31 | m_ui->m_snapXCheckBox->setCheckState(g.snapX() ? Qt::Checked : Qt::Unchecked); |
32 | m_ui->m_snapYCheckBox->setCheckState(g.snapY() ? Qt::Checked : Qt::Unchecked); |
33 | } |
34 | |
35 | void GridPanel::setTitle(const QString &title) |
36 | { |
37 | m_ui->m_gridGroupBox->setTitle(title); |
38 | } |
39 | |
40 | Grid GridPanel::grid() const |
41 | { |
42 | Grid rc; |
43 | rc.setDeltaX(m_ui->m_deltaXSpinBox->value()); |
44 | rc.setDeltaY(m_ui->m_deltaYSpinBox->value()); |
45 | rc.setSnapX(m_ui->m_snapXCheckBox->checkState() == Qt::Checked); |
46 | rc.setSnapY(m_ui->m_snapYCheckBox->checkState() == Qt::Checked); |
47 | rc.setVisible(m_ui->m_visibleCheckBox->checkState() == Qt::Checked); |
48 | return rc; |
49 | } |
50 | |
51 | void GridPanel::reset() |
52 | { |
53 | setGrid(Grid()); |
54 | } |
55 | |
56 | void GridPanel::setCheckable (bool c) |
57 | { |
58 | m_ui->m_gridGroupBox->setCheckable(c); |
59 | } |
60 | |
61 | bool GridPanel::isCheckable () const |
62 | { |
63 | return m_ui->m_gridGroupBox->isCheckable (); |
64 | } |
65 | |
66 | bool GridPanel::isChecked () const |
67 | { |
68 | return m_ui->m_gridGroupBox->isChecked (); |
69 | } |
70 | |
71 | void GridPanel::setChecked(bool c) |
72 | { |
73 | m_ui->m_gridGroupBox->setChecked(c); |
74 | } |
75 | |
76 | void GridPanel::setResetButtonVisible(bool v) |
77 | { |
78 | m_ui->m_resetButton->setVisible(v); |
79 | } |
80 | |
81 | } |
82 | |
83 | QT_END_NAMESPACE |
84 |