新版布局

This commit is contained in:
xu
2026-10-16 09:06:03 +08:00
parent e5efdea06e
commit 1ec93e42cb
37 changed files with 1785 additions and 977 deletions
+13 -3
View File
@@ -79,13 +79,15 @@ bool ConfirmDialog::confirm(QWidget* parent, const QString& title, const QString
return dlg.exec() == QDialog::Accepted;
}
void ConfirmDialog::message(QWidget* parent, const QString& title, const QString& text)
void ConfirmDialog::message(QWidget* parent, const QString& title, const QString& text,
int width, int fontPx)
{
ConfirmDialog dlg(parent);
dlg.m_panel->setFixedSize(900, 600); // 正文行数少 → 面板收窄
dlg.m_cancel->hide(); // 只保留“确认”
dlg.m_title->setStyleSheet(QString("background:transparent;color:%1;font-size:50px;font-weight:700;").arg(C::TEXT));
dlg.m_body->setStyleSheet(QString("background:transparent;color:%1;font-size:50px;").arg(C::TEXT));
// 正文单独给字号:文案长的调用点可以调小它,让固定的字数在更窄的面板里排成预期行数
dlg.m_body->setStyleSheet(QString("background:transparent;color:%1;font-size:%2px;")
.arg(C::TEXT).arg(fontPx));
dlg.m_title->setWordWrap(true);
dlg.m_title->setContentsMargins(0, 20, 0, 0); // 标题文字距该行顶部 10px
dlg.m_body->setContentsMargins(0, 0, 0, 0);
@@ -97,6 +99,14 @@ void ConfirmDialog::message(QWidget* parent, const QString& title, const QString
}
dlg.setTitle(title);
dlg.setText(text);
// 面板宽度由调用点给定,高度按内容算:标题/正文都开了 wordWrap,宽度先定下来,
// layout 才能用 heightForWidth 量出准确高度(QLabel 的 sizeHint 对换行文本不准,
// 所以不能靠 adjustSize)。宽度以前是写死的常量、三个调用点共用,一处的长文案
// 会把别处的弹窗一起撑宽,故改成逐调用点传入。
const int kW = width;
dlg.m_panel->ensurePolished(); // 先让 QSS 的 50px 字号落到控件上,量出来的高度才对
dlg.m_panel->setFixedSize(kW, dlg.m_panel->heightForWidth(kW));
dlg.exec();
}