/*! \reimp */ QSize QLabel::minimumSizeHint() const { Q_D(const QLabel); if (d->valid_hints) { if (d->sizePolicy == sizePolicy()) return d->msh; } ensurePolished(); d->valid_hints = true; d->sh = d->sizeForWidth(-1); // wrap ? golden ratio : min doc size QSize msh(-1, -1); if (!d->isTextLabel) { msh = d->sh; } else { msh.rheight() = d->sizeForWidth(QWIDGETSIZE_MAX).height(); // height for one line msh.rwidth() = d->sizeForWidth(0).width(); // wrap ? size of biggest word : min doc size if (d->sh.height() < msh.height()) msh.rheight() = d->sh.height(); } d->msh = msh; d->sizePolicy = sizePolicy(); return msh; }
QmitkStringPropertyOnDemandEdit::QmitkStringPropertyOnDemandEdit(mitk::StringProperty *property, QWidget *parent) : QFrame(parent), PropertyEditor(property), m_StringProperty(property) { setFrameStyle(QFrame::NoFrame); setLineWidth(0); // create HBoxLayout with two buttons m_layout = new QHBoxLayout(this); m_layout->setMargin(0); m_label = new QLabel(this); m_layout->addWidget(m_label); m_toolbutton = new QClickableLabel2(this); m_toolbutton->setText("..."); m_layout->addWidget(m_toolbutton); m_layout->addStretch(10); connect(m_toolbutton, SIGNAL(clicked()), this, SLOT(onToolButtonClicked())); ensurePolished(); adjustSize(); PropertyChanged(); }
QSize minimumSizeHint() const { if(cachedMinimumSizeHint.isEmpty()) { ensurePolished(); const QFontMetrics fm(fontMetrics()); int h = lineEdit()->minimumSizeHint().height(); int w = fm.width(DrivercoinUnits::format(DrivercoinUnits::DVR, DrivercoinUnits::maxMoney(), false, DrivercoinUnits::separatorAlways)); w += 2; // cursor blinking space QStyleOptionSpinBox opt; initStyleOption(&opt); QSize hint(w, h); QSize extra(35, 6); opt.rect.setSize(hint + extra); extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxEditField, this).size(); // get closer to final result by repeating the calculation opt.rect.setSize(hint + extra); extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxEditField, this).size(); hint += extra; hint.setHeight(h); opt.rect = rect(); cachedMinimumSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this) .expandedTo(QApplication::globalStrut()); } return cachedMinimumSizeHint; }
QSize CloseButton::sizeHint() const { ensurePolished(); int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this); int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, this); return QSize(width, height); }
DCursorTracker::DCursorTracker(const QString& txt, QWidget* const parent, Qt::Alignment align) : QLabel(txt, parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), d(new Private) { setForegroundRole(QPalette::ToolTipText); setBackgroundRole(QPalette::ToolTipBase); setPalette(QToolTip::palette()); ensurePolished(); const int fwidth = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this); setContentsMargins(fwidth, fwidth, fwidth, fwidth); setFrameStyle(QFrame::NoFrame); setAlignment(Qt::AlignLeft | Qt::AlignTop); setIndent(1); setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0); d->alignment = align; d->parent = parent; d->parent->setMouseTracking(true); d->parent->installEventFilter(this); d->autoHideTimer = new QTimer(this); d->autoHideTimer->setSingleShot(true); connect(d->autoHideTimer, SIGNAL(timeout()), this, SLOT(slotAutoHide())); }
QSize K3b::MsfEdit::sizeHint() const { if (d->cachedSizeHint.isEmpty()) { ensurePolished(); const QFontMetrics fm(fontMetrics()); int h = lineEdit()->sizeHint().height(); int w = fm.width( lineEdit()->inputMask() ); w += 2; // cursor blinking space QStyleOptionSpinBox opt; initStyleOption(&opt); QSize hint(w, h); QSize extra(35, 6); opt.rect.setSize(hint + extra); extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxEditField, this).size(); // get closer to final result by repeating the calculation opt.rect.setSize(hint + extra); extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxEditField, this).size(); hint += extra; opt.rect = rect(); d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this) .expandedTo(QApplication::globalStrut()); } return d->cachedSizeHint; }
QSize TabButton::sizeHint() const { ensurePolished(); int h = normalHeight(); int w = normalWidth(); return QSize(w, h); }
QSize Q3TitleBar::sizeHint() const { ensurePolished(); QStyleOptionTitleBar opt = d_func()->getStyleOption(); QRect menur = style()->subControlRect(QStyle::CC_TitleBar, &opt, QStyle::SC_TitleBarSysMenu, this); return QSize(menur.width(), style()->pixelMetric(QStyle::PM_TitleBarHeight, &opt, this)); }
QSize Editor::sizeHint() const { ensurePolished(); const QFontMetrics metrics = fontMetrics(); const int width = metrics.width('x') * 10; const int height = metrics.lineSpacing() + 6; return QSize(width, height); }
/*! \reimp */ QSize Q3ProgressBar::sizeHint() const { ensurePolished(); QFontMetrics fm = fontMetrics(); QStyleOptionProgressBar opt = getStyleOption(this); int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this); return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, QSize(cw * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8), this); }
// --------- FancyLineEdit FancyLineEdit::FancyLineEdit(QWidget *parent) : QLineEdit(parent), d(new FancyLineEditPrivate(this)) { ensurePolished(); updateMargins(); connect(this, SIGNAL(textChanged(QString)), this, SLOT(checkButtons(QString))); connect(d->m_iconbutton[Left], SIGNAL(clicked()), this, SLOT(iconClicked())); connect(d->m_iconbutton[Right], SIGNAL(clicked()), this, SLOT(iconClicked())); }
QSize EvButton::sizeHint() const { ensurePolished(); QSize s = fontMetrics().size(Qt::TextSingleLine, text()); s *= 1.1; s.rheight() += 4; s.rwidth() += s.height(); return s.expandedTo(QApplication::globalStrut()); }
QSize QWellArray::sizeHint() const { int w = (cellw+margin+1)*nrows; int h = (cellh+margin+1)*ncols; int wh = std::max(w, h); ensurePolished(); return gridSize().boundedTo(QSize(wh, wh)); }
QSize TabCloseButton::sizeHint() const { // make sure the widget is polished ensurePolished(); // read the metrics from the style const int w = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this); const int h = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, this); return QSize(w, h); }
// --------- FancyLineEdit FancyLineEdit::FancyLineEdit(QWidget *parent) : CompletingLineEdit(parent), d(new FancyLineEditPrivate(this)) { ensurePolished(); updateMargins(); connect(d->m_iconbutton[Left], &QAbstractButton::clicked, this, &FancyLineEdit::iconClicked); connect(d->m_iconbutton[Right], &QAbstractButton::clicked, this, &FancyLineEdit::iconClicked); connect(this, &QLineEdit::textChanged, this, &FancyLineEdit::onTextChanged); }
QSize CloseButton::sizeHint() const { if (icon().isNull()) { ensurePolished(); int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this); int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, this); return QSize(width, height); } return icon().actualSize(iconSize()); }
TextTip::TextTip(QWidget *parent) : QTipLabel(parent) { setForegroundRole(QPalette::ToolTipText); setBackgroundRole(QPalette::ToolTipBase); ensurePolished(); setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this)); setFrameStyle(QFrame::NoFrame); setAlignment(Qt::AlignLeft); setIndent(1); setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0); }
/*! \reimp */ QSize QProgressBar::sizeHint() const { ensurePolished(); QFontMetrics fm = fontMetrics(); QStyleOptionProgressBarV2 opt; initStyleOption(&opt); int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this); QSize size = QSize(qMax(9, cw) * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8); if (opt.orientation == Qt::Vertical) size.transpose(); return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, this); }
QList<int> QSplitter::sizes() const { Q_D(const QSplitter); ensurePolished(); QList<int> list; for (int i = 0; i < d->list.size(); ++i) { QSplitterLayoutStruct *s = d->list.at(i); list.append(d->pick(s->rect.size())); } return list; }
QSize QDockWidgetTitleButton::sizeHint() const { ensurePolished(); int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin); if (!icon().isNull()) { int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize); const QPixmap pm = icon().pixmap(iconSize); size += qMax(pm.width(), pm.height()); } return QSize(size, size); }
QSize QDockWidgetTitleButton::sizeHint() const { ensurePolished(); int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this); if (!icon().isNull()) { int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); QSize sz = icon().actualSize(QSize(iconSize, iconSize)); size += qMax(sz.width(), sz.height()); } return QSize(size, size); }
QSize QStatusButton::sizeHint()const { ensurePolished(); QSize s=fontMetrics().size(Qt::TextSingleLine,m_text); s.rwidth()+=19+5+2; s.rheight()+=2+2; if(!m_label->text().isNull()) { s.rwidth()+=m_label->width(); } return s.expandedTo(QApplication::globalStrut()); }
QSize QVistaBackButton::sizeHint() const { ensurePolished(); int width = 32, height = 32; /* HANDLE theme = pOpenThemeData(0, L"Navigation"); SIZE size; if (pGetThemePartSize(theme, 0, WIZ_NAV_BACKBUTTON, WIZ_NAV_BB_NORMAL, 0, TS_TRUE, &size) == S_OK) { width = size.cx; height = size.cy; } */ return QSize(width, height); }
QSize SqueezedComboBox::sizeHint() const { ensurePolished(); QFontMetrics fm = fontMetrics(); int maxW = count() ? 18 : 7 * fm.width(QChar('x')) + 18; int maxH = qMax(fm.lineSpacing(), 14) + 2; QStyleOptionComboBox options; options.initFrom(this); return style()->sizeFromContents(QStyle::CT_ComboBox, &options, QSize(maxW, maxH), this).expandedTo(QApplication::globalStrut()); }
void PsiTipLabel::initUi() { margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, this); setFrameStyle(QFrame::NoFrame); doc = new QTextDocument(this); QTextOption opt = doc->defaultTextOption(); opt.setWrapMode(QTextOption::WordWrap); doc->setDefaultTextOption(opt); doc->setUndoRedoEnabled(false); doc->setDefaultFont(font()); ensurePolished(); setText(theText_); }
void TrackingSlider::setEnabledStylesheet() { QFile file; if(orientation() == Qt::Vertical) { file.setFileName(":/qss/TrackingSliderVerticalEnabled.qss"); } else { file.setFileName(":/qss/TrackingSliderHorizontalEnabled.qss"); } file.open(QFile::ReadOnly); setStyleSheet(file.readAll()); ensurePolished(); }
/*! \reimp */ QSize QToolButton::sizeHint() const { Q_D(const QToolButton); if (d->sizeHint.isValid()) return d->sizeHint; ensurePolished(); int w = 0, h = 0; QStyleOptionToolButton opt; initStyleOption(&opt); QFontMetrics fm = fontMetrics(); if (opt.toolButtonStyle != Qt::ToolButtonTextOnly) { QSize icon = opt.iconSize; w = icon.width(); h = icon.height(); #ifdef Q_WS_MAC extern CGFloat qt_mac_get_scalefactor(); w /= qt_mac_get_scalefactor(); h /= qt_mac_get_scalefactor(); #endif } if (opt.toolButtonStyle != Qt::ToolButtonIconOnly) { QSize textSize = fm.size(Qt::TextShowMnemonic, text()); textSize.setWidth(textSize.width() + fm.width(QLatin1Char(' '))*2); if (opt.toolButtonStyle == Qt::ToolButtonTextUnderIcon) { h += 4 + textSize.height(); if (textSize.width() > w) w = textSize.width(); } else if (opt.toolButtonStyle == Qt::ToolButtonTextBesideIcon) { w += 4 + textSize.width(); if (textSize.height() > h) h = textSize.height(); } else { // TextOnly w = textSize.width(); h = textSize.height(); } } opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height if (d->popupMode == MenuButtonPopup) w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); d->sizeHint = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), this). expandedTo(QApplication::globalStrut()); return d->sizeHint; }
int MovableTableWidget::sizeHintForColumn(int column) const { ensurePolished(); QStyleOptionViewItem option = viewOptions(); int hint = 0; QModelIndex index; for (int row = 0; row <= rowCount(); ++row) { index = indexFromItem(item(row, column)); hint = qMax(hint, itemDelegate(index)->sizeHint(option, index).width()); } return showGrid() ? hint + 1 : hint; }
/*! \reimp */ QSize QRadioButton::sizeHint() const { Q_D(const QRadioButton); if (d->sizeHint.isValid()) return d->sizeHint; ensurePolished(); QStyleOptionButton opt; initStyleOption(&opt); QSize sz = style()->itemTextRect(fontMetrics(), QRect(), Qt::TextShowMnemonic, false, text()).size(); if (!opt.icon.isNull()) sz = QSize(sz.width() + opt.iconSize.width() + 4, qMax(sz.height(), opt.iconSize.height())); d->sizeHint = (style()->sizeFromContents(QStyle::CT_RadioButton, &opt, sz, this). expandedTo(QApplication::globalStrut())); return d->sizeHint; }
QSize KoDockWidgetTitleBarButton::sizeHint() const { ensurePolished(); const int margin = style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this); if (icon().isNull()) return QSize(margin, margin); int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); if (iconSize != m_iconSize) { const_cast<KoDockWidgetTitleBarButton*>(this)->m_iconSize = iconSize; const QPixmap pm = icon().pixmap(iconSize); const_cast<KoDockWidgetTitleBarButton*>(this)->m_styleSize = QSize(pm.width() + margin, pm.height() + margin); } return m_styleSize; }