Files
hfut-bishe/client/gui/props/BackgroundPropertySection.cpp
T
2026-05-14 13:30:06 +08:00

78 lines
2.3 KiB
C++

#include "props/BackgroundPropertySection.h"
#include "widgets/PropertyPanelControls.h"
#include <QFormLayout>
#include <QLabel>
#include <QVBoxLayout>
namespace gui {
BackgroundPropertySection::BackgroundPropertySection(QWidget* parent)
: PropertySectionWidget(parent) {
auto* lay = new QVBoxLayout(this);
polishPropertyVBoxLayout(lay);
auto* form = new QFormLayout();
polishPropertyFormLayout(form);
m_sizeLabel = new QLabel(QStringLiteral("-"), this);
m_sizeLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
m_sizeLabel->setWordWrap(true);
form->addRow(QStringLiteral("背景尺寸"), m_sizeLabel);
m_showBackground = new PropertyPanelCheckBox(QStringLiteral("显示背景"), this);
m_showBackground->setToolTip({});
form->addRow(QString(), m_showBackground);
m_depthOverlay = new PropertyPanelCheckBox(QStringLiteral("叠加深度"), this);
m_depthOverlay->setToolTip({});
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