78 lines
2.4 KiB
C++
78 lines
2.4 KiB
C++
#include "props/BackgroundPropertySection.h"
|
|
|
|
#include <QCheckBox>
|
|
#include <QFormLayout>
|
|
#include <QLabel>
|
|
#include <QVBoxLayout>
|
|
|
|
namespace gui {
|
|
|
|
BackgroundPropertySection::BackgroundPropertySection(QWidget* parent)
|
|
: PropertySectionWidget(parent) {
|
|
auto* lay = new QVBoxLayout(this);
|
|
lay->setContentsMargins(0, 0, 0, 0);
|
|
lay->setSpacing(6);
|
|
|
|
auto* form = new QFormLayout();
|
|
form->setContentsMargins(0, 0, 0, 0);
|
|
form->setSpacing(6);
|
|
|
|
m_sizeLabel = new QLabel(QStringLiteral("-"), this);
|
|
m_sizeLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
|
form->addRow(QStringLiteral("背景尺寸"), m_sizeLabel);
|
|
|
|
m_showBackground = new QCheckBox(QStringLiteral("显示背景"), this);
|
|
m_showBackground->setToolTip(QStringLiteral("是否绘制背景图"));
|
|
form->addRow(QString(), m_showBackground);
|
|
|
|
m_depthOverlay = new QCheckBox(QStringLiteral("叠加深度"), this);
|
|
m_depthOverlay->setToolTip(QStringLiteral("在背景上叠加深度伪彩图"));
|
|
form->addRow(QString(), m_depthOverlay);
|
|
|
|
lay->addLayout(form);
|
|
lay->addStretch(1);
|
|
|
|
connect(m_showBackground, &QCheckBox::toggled, this, &BackgroundPropertySection::backgroundVisibleToggled);
|
|
connect(m_depthOverlay, &QCheckBox::toggled, this, &BackgroundPropertySection::depthOverlayToggled);
|
|
}
|
|
|
|
void BackgroundPropertySection::setBackgroundSizeText(const QString& text) {
|
|
if (m_sizeLabel) {
|
|
m_sizeLabel->setText(text);
|
|
}
|
|
}
|
|
|
|
void BackgroundPropertySection::syncBackgroundVisible(bool visible, bool controlsEnabled) {
|
|
if (!m_showBackground) {
|
|
return;
|
|
}
|
|
m_showBackground->blockSignals(true);
|
|
m_showBackground->setChecked(visible);
|
|
m_showBackground->setEnabled(controlsEnabled);
|
|
m_showBackground->blockSignals(false);
|
|
}
|
|
|
|
void BackgroundPropertySection::syncDepthOverlayChecked(bool on) {
|
|
if (!m_depthOverlay) {
|
|
return;
|
|
}
|
|
m_depthOverlay->blockSignals(true);
|
|
m_depthOverlay->setChecked(on);
|
|
m_depthOverlay->blockSignals(false);
|
|
}
|
|
|
|
void BackgroundPropertySection::setDepthOverlayCheckEnabled(bool on) {
|
|
if (m_depthOverlay) {
|
|
m_depthOverlay->setEnabled(on);
|
|
}
|
|
}
|
|
|
|
void BackgroundPropertySection::setProjectClosedAppearance() {
|
|
setBackgroundSizeText(QStringLiteral("-"));
|
|
syncBackgroundVisible(true, false);
|
|
syncDepthOverlayChecked(false);
|
|
setDepthOverlayCheckEnabled(false);
|
|
}
|
|
|
|
} // namespace gui
|