29 #include <QApplication> 34 #include <QStyleOptionButton> 67 inline static const QString label(
bool on)
78 opt.text = label(
false);
81 opt.text = label(
true);
93 return QSize(extent, extent);
133 init(title, text, details);
139 init(title, text, details, icon);
152 init(title, text, details, icon, buttons, defaultButtton);
159 m_textLabel->setText(text);
167 const bool haveDeets = !details.
isEmpty();
169 m_textEdit->setPlainText(details);
171 m_textEdit->setHtml(details);
173 m_textEdit->setText(details);
181 if (!m_promptLabel) {
182 m_promptLabel =
new QLabel(
this);
187 return m_promptLabel.
data();
195 m_promptLabel->setParent(
nullptr);
196 m_promptLabel->deleteLater();
197 m_promptLabel.
clear();
210 m_iconLabel->setPixmap(pixmap);
211 static_cast<QHBoxLayout*>(
layout()->itemAt(0))->setSpacing(pixmap.
isNull() ? 0 : 12);
233 static_cast<QHBoxLayout*>(
layout()->itemAt(0))->setAlignment(m_iconLabel,
Qt::AlignLeft | valign);
240 QFont newFont(m_textEdit->font());
246 newFont.setFamily(
"Helvetica");
250 newFont.setPointSize(13);
252 #elif defined Q_OS_WIN 253 newFont.setPointSize(10);
255 m_textEdit->setFont(newFont);
270 if (m_textLabel->wordWrap() == wrap)
272 m_textLabel->setWordWrap(wrap);
278 return m_textEdit && m_textEdit->isVisibleTo(
this);
285 m_textEdit->setVisible(on);
289 m_textEdit->setSizePolicy(sp);
291 m_detailsBtn->setChecked(on);
308 return !m_detailsBtn.
isNull();
318 m_detailsBtn =
new DetailButton(
this);
325 m_btnBox->removeButton(m_detailsBtn);
326 m_detailsBtn->deleteLater();
327 m_detailsBtn.
clear();
329 m_updatesSuspended =
true;
332 if (toggleDetailPosition)
334 m_updatesSuspended =
false;
343 int newIdx = on ? 2 : 1;
344 if (on && m_promptLabel)
346 if (l->
indexOf(m_textEdit) == newIdx)
357 m_textLabel =
new QLabel(
this);
361 m_textLabel->setOpenExternalLinks(
true);
364 m_iconLabel =
new QLabel(
this);
367 m_textEdit =
new TextEdit(
this);
368 m_textEdit->setReadOnly(
true);
374 sp.setVerticalStretch(1);
375 m_textEdit->setSizePolicy(sp);
408 m_detailsBtn->setDefault(
true);
416 m_updatesSuspended =
false;
423 return l->totalMinimumSize().width();
431 if (m_updatesSuspended)
434 const int maxWidth = screenSz.
width() <= 1024 ? screenSz.
width() : qMin(
int(screenSz.
width() * 0.66f), 1000);
435 const int maxHeight = qMin(
int(screenSz.
height() * 0.66f), 750);
438 if (
width > maxWidth && m_textLabel && !m_textLabel->wordWrap()) {
439 m_textLabel->setWordWrap(
true);
442 if (
width > maxWidth && m_promptLabel) {
443 m_promptLabel->setWordWrap(
true);
448 width = qMax(m_textEdit->sizeHint().width(),
width);
QSize boundedTo(const QSize &otherSize) const const
QTextEdit(QWidget *parent)
QScreen * screenAt(const QPoint &point)
bool isEmpty() const const
QString toHtml() const const
virtual int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const const=0
SH_MessageBox_TextInteractionFlags
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) const const
virtual int indexOf(QWidget *widget) const const
void removePostedEvents(QObject *receiver, int eventType)
QTextOption::WrapMode wordWrapMode() const const
bool isNull() const const
bool isEmpty() const const
QString tr(const char *s, const char *c, int n)
void setText(const QString &)
virtual QSize sizeHint() const const override
typedef TextInteractionFlags
void setVerticalPolicy(QSizePolicy::Policy policy)
void setHorizontalPolicy(QSizePolicy::Policy policy)
virtual QIcon standardIcon(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const const=0
bool isNull() const const
QSize expandedTo(const QSize &otherSize) const const
bool isNull() const const
void setFamily(const QString &family)
virtual QSize sizeHint() const const override
virtual int count() const const=0
virtual void showEvent(QShowEvent *event) override
void setText(const QString &text)
void setSizeGripEnabled(bool)
QSize size(int flags, const QString &text, int tabStops, int *tabArray) const const
QScreen * screen() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
virtual bool hasHeightForWidth() const const
virtual QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const const=0
void setWordWrap(bool on)
void setSpacing(int spacing)
void addLayout(QLayout *layout, int stretch)