Add feature.label and feature.formlayout

Change-Id: Ic8dc0aee7f3fc0d8218ba709352b1378078c6070
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Stephan Binner 2017-03-02 13:39:22 +01:00
parent 46bf3d71e5
commit dc2512f308
18 changed files with 125 additions and 24 deletions

View File

@ -46,7 +46,6 @@
#include <QtWidgets/qaction.h>
#include <QtWidgets/qboxlayout.h>
#include <QtWidgets/qcombobox.h>
#include <QtWidgets/qlabel.h>
#include <QtWidgets/qlineedit.h>
#include <QtPrintSupport/qpagesetupdialog.h>
#include <QtPrintSupport/qprinter.h>
@ -56,11 +55,13 @@
#include <QtWidgets/qfiledialog.h>
#include <QtWidgets/qmainwindow.h>
#include <QtWidgets/qtoolbar.h>
#include <QtWidgets/qformlayout.h>
#include <QtCore/QCoreApplication>
#ifndef QT_NO_PRINTPREVIEWDIALOG
#include <QtWidgets/qformlayout.h>
#include <QtWidgets/qlabel.h>
static void initResources()
{
static bool resourcesInitialized = false;

View File

@ -44,7 +44,9 @@
#include "qaction.h"
#include "qapplication.h"
#include "qgroupbox.h"
#if QT_CONFIG(label)
#include "qlabel.h"
#endif
#include "qtooltip.h"
#include "qwhatsthis.h"
#include "qwidget.h"
@ -81,7 +83,7 @@ static QString buddyString(const QWidget *widget)
QWidget *parent = widget->parentWidget();
if (!parent)
return QString();
#ifndef QT_NO_SHORTCUT
#if QT_CONFIG(shortcut) && QT_CONFIG(label)
for (QObject *o : parent->children()) {
QLabel *label = qobject_cast<QLabel*>(o);
if (label && label->buddy() == widget)
@ -309,7 +311,7 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel
if (match & QAccessible::Label) {
const QAccessible::Relation rel = QAccessible::Label;
if (QWidget *parent = widget()->parentWidget()) {
#ifndef QT_NO_SHORTCUT
#if QT_CONFIG(shortcut) && QT_CONFIG(label)
// first check for all siblings that are labels to us
// ideally we would go through all objects and check, but that
// will be too expensive

View File

@ -49,7 +49,9 @@
#endif
#include <qtoolbutton.h>
#include <qmenu.h>
#if QT_CONFIG(label)
#include <qlabel.h>
#endif
#include <qgroupbox.h>
#include <qlcdnumber.h>
#include <qlineedit.h>
@ -395,6 +397,7 @@ QAccessibleDisplay::QAccessibleDisplay(QWidget *w, QAccessible::Role role)
QAccessible::Role QAccessibleDisplay::role() const
{
#if QT_CONFIG(label)
QLabel *l = qobject_cast<QLabel*>(object());
if (l) {
if (l->pixmap())
@ -416,6 +419,7 @@ QAccessible::Role QAccessibleDisplay::role() const
return QAccessible::StatusBar;
#endif
}
#endif
return QAccessibleWidget::role();
}
@ -426,7 +430,9 @@ QString QAccessibleDisplay::text(QAccessible::Text t) const
case QAccessible::Name:
str = widget()->accessibleName();
if (str.isEmpty()) {
if (qobject_cast<QLabel*>(object())) {
if (false) {
#if QT_CONFIG(label)
} else if (qobject_cast<QLabel*>(object())) {
QLabel *label = qobject_cast<QLabel*>(object());
str = label->text();
#ifndef QT_NO_TEXTHTMLPARSER
@ -441,6 +447,7 @@ QString QAccessibleDisplay::text(QAccessible::Text t) const
if (label->buddy())
str = qt_accStripAmp(str);
#endif
#endif // QT_CONFIG(label)
#ifndef QT_NO_LCDNUMBER
} else if (qobject_cast<QLCDNumber*>(object())) {
QLCDNumber *l = qobject_cast<QLCDNumber*>(object());
@ -475,7 +482,7 @@ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >
QAccessibleDisplay::relations(QAccessible::Relation match /* = QAccessible::AllRelations */) const
{
QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels = QAccessibleWidget::relations(match);
#ifndef QT_NO_SHORTCUT
#if QT_CONFIG(shortcut) && QT_CONFIG(label)
if (match & QAccessible::Labelled) {
if (QLabel *label = qobject_cast<QLabel*>(object())) {
const QAccessible::Relation rel = QAccessible::Labelled;
@ -507,26 +514,34 @@ QString QAccessibleDisplay::imageDescription() const
/*! \internal */
QSize QAccessibleDisplay::imageSize() const
{
#if QT_CONFIG(label)
QLabel *label = qobject_cast<QLabel *>(widget());
if (!label)
#endif
return QSize();
#if QT_CONFIG(label)
const QPixmap *pixmap = label->pixmap();
if (!pixmap)
return QSize();
return pixmap->size();
#endif
}
/*! \internal */
QPoint QAccessibleDisplay::imagePosition() const
{
#if QT_CONFIG(label)
QLabel *label = qobject_cast<QLabel *>(widget());
if (!label)
#endif
return QPoint();
#if QT_CONFIG(label)
const QPixmap *pixmap = label->pixmap();
if (!pixmap)
return QPoint();
return QPoint(label->mapToGlobal(label->pos()));
#endif
}
#ifndef QT_NO_GROUPBOX

View File

@ -156,6 +156,19 @@
"condition": "features.rubberband",
"output": [ "publicFeature", "feature" ]
},
"label": {
"label": "QLabel",
"purpose": "Provides a text or image display.",
"section": "Widgets",
"output": [ "publicFeature" ]
},
"formlayout": {
"label": "QFormLayout",
"purpose": "Manages forms of input widgets and their associated labels.",
"section": "Widgets",
"condition": "features.label",
"output": [ "publicFeature" ]
},
"lcdnumber": {
"label": "QLCDNumber",
"purpose": "Provides LCD-like digits.",
@ -374,6 +387,7 @@
"label": "QToolTip",
"purpose": "Supports presentation of tooltips.",
"section": "Widgets",
"condition": "features.label",
"output": [ "publicFeature", "feature" ]
},
"statustip": {
@ -399,7 +413,7 @@
"label": "QCalendarWidget",
"purpose": "Provides a monthly based calendar widget allowing the user to select a date.",
"section": "Widgets",
"condition": "features.tableview && features.menu && features.textdate && features.spinbox && features.toolbutton",
"condition": "features.tableview && features.menu && features.textdate && features.spinbox && features.toolbutton && features.label",
"output": [ "publicFeature", "feature" ]
},
"keysequenceedit": {
@ -413,13 +427,14 @@
"label": "QMessageBox",
"purpose": "Provides message boxes displaying informative messages and simple questions.",
"section": "Dialogs",
"condition" : "features.label",
"output": [ "publicFeature", "feature" ]
},
"colordialog": {
"label": "QColorDialog",
"purpose": "Provides a dialog widget for specifying colors.",
"section": "Dialogs",
"condition": "features.spinbox",
"condition": "features.spinbox && features.label",
"output": [ "publicFeature", "feature" ]
},
"filedialog": {
@ -430,6 +445,7 @@
"features.buttongroup",
"features.combobox",
"features.dirmodel",
"features.label",
"features.proxymodel",
"features.splitter",
"features.stackedwidget",
@ -442,35 +458,35 @@
"label": "QFontDialog",
"purpose": "Provides a dialog widget for selecting fonts.",
"section": "Dialogs",
"condition": "features.stringlistmodel && features.combobox && features.validator && features.groupbox",
"condition": "features.stringlistmodel && features.combobox && features.validator && features.groupbox && features.label",
"output": [ "publicFeature", "feature" ]
},
"progressdialog": {
"label": "QProgressDialog",
"purpose": "Provides feedback on the progress of a slow operation.",
"section": "Dialogs",
"condition": "features.progressbar",
"condition": "features.progressbar && features.label",
"output": [ "publicFeature", "feature" ]
},
"inputdialog": {
"label": "QInputDialog",
"purpose": "Provides a simple convenience dialog to get a single value from the user.",
"section": "Dialogs",
"condition": "features.combobox && features.spinbox && features.stackedwidget && features.textedit",
"condition": "features.combobox && features.spinbox && features.stackedwidget && features.textedit && features.label",
"output": [ "publicFeature", "feature" ]
},
"errormessage": {
"label": "QErrorMessage",
"purpose": "Provides an error message display dialog.",
"section": "Dialogs",
"condition": "features.textedit",
"condition": "features.textedit && features.label",
"output": [ "publicFeature", "feature" ]
},
"wizard": {
"label": "QWizard",
"purpose": "Provides a framework for multi-page click-through dialogs.",
"section": "Dialogs",
"condition": "features.properties",
"condition": "features.properties && features.label",
"output": [ "publicFeature", "feature" ]
},
"dirmodel": {

View File

@ -2479,7 +2479,10 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
if (d->shouldAutoScroll(e->pos()))
d->startAutoScroll();
if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance()
|| !d->sectionIndicator->isHidden()) {
#if QT_CONFIG(label)
|| !d->sectionIndicator->isHidden()
#endif
) {
int visual = visualIndexAt(pos);
if (visual == -1)
return;
@ -2548,7 +2551,11 @@ void QHeaderView::mouseReleaseEvent(QMouseEvent *e)
int pos = d->orientation == Qt::Horizontal ? e->x() : e->y();
switch (d->state) {
case QHeaderViewPrivate::MoveSection:
if (!d->sectionIndicator->isHidden()) { // moving
if (true
#if QT_CONFIG(label)
&& !d->sectionIndicator->isHidden()
#endif
) { // moving
int from = visualIndex(d->section);
Q_ASSERT(from != -1);
int to = visualIndex(d->target);
@ -3138,9 +3145,11 @@ int QHeaderViewPrivate::sectionHandleAt(int position)
void QHeaderViewPrivate::setupSectionIndicator(int section, int position)
{
Q_Q(QHeaderView);
#if QT_CONFIG(label)
if (!sectionIndicator) {
sectionIndicator = new QLabel(viewport);
}
#endif
int w, h;
int p = q->sectionViewportPosition(section);
@ -3151,7 +3160,9 @@ void QHeaderViewPrivate::setupSectionIndicator(int section, int position)
w = viewport->width();
h = q->sectionSize(section);
}
#if QT_CONFIG(label)
sectionIndicator->resize(w, h);
#endif
QPixmap pm(w, h);
pm.fill(QColor(0, 0, 0, 45));
@ -3162,12 +3173,15 @@ void QHeaderViewPrivate::setupSectionIndicator(int section, int position)
q->paintSection(&painter, rect, section);
painter.end();
#if QT_CONFIG(label)
sectionIndicator->setPixmap(pm);
#endif
sectionIndicatorOffset = position - qMax(p, 0);
}
void QHeaderViewPrivate::updateSectionIndicator(int section, int position)
{
#if QT_CONFIG(label)
if (!sectionIndicator)
return;
@ -3182,6 +3196,7 @@ void QHeaderViewPrivate::updateSectionIndicator(int section, int position)
sectionIndicator->move(0, position - sectionIndicatorOffset);
sectionIndicator->show();
#endif
}
/*!

View File

@ -58,7 +58,9 @@
#include "QtCore/qbitarray.h"
#include "QtWidgets/qapplication.h"
#if QT_CONFIG(label)
#include "QtWidgets/qlabel.h"
#endif
QT_BEGIN_NAMESPACE
@ -99,7 +101,9 @@ public:
lastSectionSize(0),
lastSectionLogicalIdx(-1), // Only trust when we stretch last section
sectionIndicatorOffset(0),
#if QT_CONFIG(label)
sectionIndicator(0),
#endif
globalResizeMode(QHeaderView::Interactive),
sectionStartposRecalc(true),
resizeContentsPrecision(1000)
@ -296,7 +300,9 @@ public:
int lastSectionLogicalIdx; // Only trust if we stretch LastSection
int sectionIndicatorOffset;
Qt::Alignment defaultAlignment;
#if QT_CONFIG(label)
QLabel *sectionIndicator;
#endif
QHeaderView::ResizeMode globalResizeMode;
QList<QPersistentModelIndex> persistentHiddenSections;
mutable bool sectionStartposRecalc;

View File

@ -45,7 +45,9 @@
#include <qcombobox.h>
#include <qdatetimeedit.h>
#if QT_CONFIG(label)
#include <qlabel.h>
#endif
#include <qlineedit.h>
#include <qspinbox.h>
#include <limits.h>
@ -261,8 +263,10 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
ed->setFrame(false);
return ed; }
#endif
#if QT_CONFIG(label)
case QVariant::Pixmap:
return new QLabel(parent);
#endif
#ifndef QT_NO_SPINBOX
case QVariant::Double: {
QDoubleSpinBox *sb = new QDoubleSpinBox(parent);

View File

@ -15,7 +15,6 @@ HEADERS += \
kernel/qwidgetbackingstore_p.h \
kernel/qboxlayout.h \
kernel/qdesktopwidget.h \
kernel/qformlayout.h \
kernel/qgridlayout.h \
kernel/qlayout.h \
kernel/qlayout_p.h \
@ -45,7 +44,6 @@ SOURCES += \
kernel/qapplication.cpp \
kernel/qwidgetbackingstore.cpp \
kernel/qboxlayout.cpp \
kernel/qformlayout.cpp \
kernel/qgridlayout.cpp \
kernel/qlayout.cpp \
kernel/qlayoutengine.cpp \
@ -84,3 +82,8 @@ qtConfig(opengl) {
HEADERS += kernel/qopenglwidget.h
SOURCES += kernel/qopenglwidget.cpp
}
qtConfig(formlayout) {
HEADERS += kernel/qformlayout.h
SOURCES += kernel/qformlayout.cpp
}

View File

@ -43,6 +43,8 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/QLayout>
QT_REQUIRE_CONFIG(formlayout);
QT_BEGIN_NAMESPACE

View File

@ -49,7 +49,9 @@
#include "qvariant.h"
#include "qwidget_p.h"
#include "qlayout_p.h"
#if QT_CONFIG(formlayout)
#include "qformlayout.h"
#endif
QT_BEGIN_NAMESPACE
@ -320,8 +322,10 @@ int QLayout::spacing() const
return boxlayout->spacing();
} else if (const QGridLayout* gridlayout = qobject_cast<const QGridLayout*>(this)) {
return gridlayout->spacing();
#if QT_CONFIG(formlayout)
} else if (const QFormLayout* formlayout = qobject_cast<const QFormLayout*>(this)) {
return formlayout->spacing();
#endif
} else {
Q_D(const QLayout);
if (d->insideSpacing >=0) {
@ -347,8 +351,10 @@ void QLayout::setSpacing(int spacing)
boxlayout->setSpacing(spacing);
} else if (QGridLayout* gridlayout = qobject_cast<QGridLayout*>(this)) {
gridlayout->setSpacing(spacing);
#if QT_CONFIG(formlayout)
} else if (QFormLayout* formlayout = qobject_cast<QFormLayout*>(this)) {
formlayout->setSpacing(spacing);
#endif
} else {
Q_D(QLayout);
d->insideSpacing = spacing;

View File

@ -43,18 +43,19 @@
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qevent.h>
#include <qlabel.h>
#include <qpointer.h>
#include <qstyle.h>
#include <qstyleoption.h>
#include <qstylepainter.h>
#include <qtimer.h>
#include <qtooltip.h>
#include <private/qeffects_p.h>
#include <qtextdocument.h>
#include <qdebug.h>
#include <private/qstylesheetstyle_p.h>
#ifndef QT_NO_TOOLTIP
#include <qlabel.h>
#include <qtooltip.h>
#if 0 // Used to be included in Qt4 for Q_WS_MAC
# include <private/qcore_mac_p.h>

View File

@ -49,7 +49,11 @@
#include <qdockwidget.h>
#include <qdrawutil.h>
#include <qdialogbuttonbox.h>
#if QT_CONFIG(formlayout)
#include <qformlayout.h>
#else
#include <qlayout.h>
#endif
#include <qgroupbox.h>
#include <qmath.h>
#include <qmenu.h>
@ -5162,12 +5166,14 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
ret = QWizard::ClassicStyle;
break;
#endif
#if QT_CONFIG(formlayout)
case SH_FormLayoutWrapPolicy:
ret = QFormLayout::DontWrapRows;
break;
case SH_FormLayoutFieldGrowthPolicy:
ret = QFormLayout::AllNonFixedFieldsGrow;
break;
#endif
case SH_FormLayoutFormAlignment:
ret = Qt::AlignLeft | Qt::AlignTop;
break;

View File

@ -75,7 +75,9 @@
#include <qdialog.h>
#include <private/qwidget_p.h>
#include <QAbstractSpinBox>
#if QT_CONFIG(label)
#include <QLabel>
#endif
#include "qdrawutil.h"
#include <limits.h>
@ -1414,11 +1416,13 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q
static inline QObject *parentObject(const QObject *obj)
{
#if QT_CONFIG(tooltip)
if (qobject_cast<const QLabel *>(obj) && qstrcmp(obj->metaObject()->className(), "QTipLabel") == 0) {
QObject *p = qvariant_cast<QObject *>(obj->property("_q_stylesheet_parent"));
if (p)
return p;
}
#endif
return obj->parent();
}

View File

@ -46,7 +46,10 @@
#include "qlist.h"
#include "qevent.h"
#include "qpoint.h"
#if QT_CONFIG(label)
#include "qlabel.h"
#include "private/qlabel_p.h"
#endif
#include "qpushbutton.h"
#include "qpainterpath.h"
#include "qpainter.h"
@ -55,7 +58,6 @@
#include "qapplication.h"
#include "qdesktopwidget.h"
#include "qbitmap.h"
#include "private/qlabel_p.h"
QT_BEGIN_NAMESPACE
@ -481,6 +483,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(ti, SIGNAL(destroyed()), this, SLOT(close()));
#if QT_CONFIG(label)
QLabel *titleLabel = new QLabel;
titleLabel->installEventFilter(this);
titleLabel->setText(title);
@ -488,6 +491,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
f.setBold(true);
titleLabel->setFont(f);
titleLabel->setTextFormat(Qt::PlainText); // to maintain compat with windows
#endif
const int iconSize = 18;
const int closeButtonSize = 15;
@ -499,6 +503,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
closeButton->setFixedSize(closeButtonSize, closeButtonSize);
QObject::connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
#if QT_CONFIG(label)
QLabel *msgLabel = new QLabel;
msgLabel->installEventFilter(this);
msgLabel->setText(message);
@ -521,8 +526,10 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
// to emulate the weird standard windows behavior.
msgLabel->setFixedSize(limit, msgLabel->heightForWidth(limit));
}
#endif
QGridLayout *layout = new QGridLayout;
#if QT_CONFIG(label)
if (!icon.isNull()) {
QLabel *iconLabel = new QLabel;
iconLabel->setPixmap(icon.pixmap(iconSize, iconSize));
@ -533,9 +540,12 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
} else {
layout->addWidget(titleLabel, 0, 0, 1, 2);
}
#endif
layout->addWidget(closeButton, 0, 2);
#if QT_CONFIG(label)
layout->addWidget(msgLabel, 1, 0, 1, 3);
#endif
layout->setSizeConstraint(QLayout::SetFixedSize);
layout->setMargin(3);
setLayout(layout);

View File

@ -37,7 +37,10 @@
**
****************************************************************************/
#include "qtwidgetsglobal.h"
#if QT_CONFIG(label)
#include "qlabel.h"
#endif
#include "qpainter.h"
#include "qpixmap.h"
#include "qbitmap.h"

View File

@ -57,7 +57,6 @@
#include "QtWidgets/qspinbox.h"
#include "QtWidgets/qtoolbutton.h"
#include "QtWidgets/qmenu.h"
#include "QtWidgets/qlabel.h"
#include "QtWidgets/qdatetimeedit.h"
#include "private/qabstractspinbox_p.h"
#include "private/qdatetimeparser_p.h"

View File

@ -43,6 +43,8 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
QT_REQUIRE_CONFIG(label);
QT_BEGIN_NAMESPACE

View File

@ -26,8 +26,6 @@ HEADERS += \
widgets/qgroupbox.h \
widgets/qkeysequenceedit.h \
widgets/qkeysequenceedit_p.h \
widgets/qlabel.h \
widgets/qlabel_p.h \
widgets/qlcdnumber.h \
widgets/qlineedit.h \
widgets/qlineedit_p.h \
@ -100,7 +98,6 @@ SOURCES += \
widgets/qframe.cpp \
widgets/qgroupbox.cpp \
widgets/qkeysequenceedit.cpp \
widgets/qlabel.cpp \
widgets/qlcdnumber.cpp \
widgets/qlineedit_p.cpp \
widgets/qlineedit.cpp \
@ -149,6 +146,15 @@ qtConfig(commandlinkbutton) {
widgets/qcommandlinkbutton.cpp
}
qtConfig(label) {
HEADERS += \
widgets/qlabel.h \
widgets/qlabel_p.h
SOURCES += \
widgets/qlabel.cpp
}
qtConfig(radiobutton) {
HEADERS += \
widgets/qradiobutton.h