Add feature.abstractbutton

Change-Id: Ie93c6d0a8256bc466d3419408b753d5f3738aa6b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Stephan Binner 2017-03-08 20:11:43 +01:00
parent f06f1adb6c
commit d08deb0b4a
16 changed files with 76 additions and 19 deletions

View File

@ -41,7 +41,6 @@
#include <qaccessible.h> #include <qaccessible.h>
#include <qapplication.h> #include <qapplication.h>
#include <qabstractbutton.h>
#include <qevent.h> #include <qevent.h>
#include <qheaderview.h> #include <qheaderview.h>
#include <qtabbar.h> #include <qtabbar.h>

View File

@ -103,11 +103,13 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
} else if (classname == QLatin1String("QToolButton")) { } else if (classname == QLatin1String("QToolButton")) {
iface = new QAccessibleToolButton(widget); iface = new QAccessibleToolButton(widget);
#endif // QT_NO_TOOLBUTTON #endif // QT_NO_TOOLBUTTON
#if QT_CONFIG(abstractbutton)
} else if (classname == QLatin1String("QCheckBox") } else if (classname == QLatin1String("QCheckBox")
|| classname == QLatin1String("QRadioButton") || classname == QLatin1String("QRadioButton")
|| classname == QLatin1String("QPushButton") || classname == QLatin1String("QPushButton")
|| classname == QLatin1String("QAbstractButton")) { || classname == QLatin1String("QAbstractButton")) {
iface = new QAccessibleButton(widget); iface = new QAccessibleButton(widget);
#endif
} else if (classname == QLatin1String("QDialog")) { } else if (classname == QLatin1String("QDialog")) {
iface = new QAccessibleWidget(widget, QAccessible::Dialog); iface = new QAccessibleWidget(widget, QAccessible::Dialog);
} else if (classname == QLatin1String("QMessageBox")) { } else if (classname == QLatin1String("QMessageBox")) {

View File

@ -64,7 +64,6 @@
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QDockWidget> #include <QDockWidget>
#include <QMainWindow> #include <QMainWindow>
#include <QAbstractButton>
#include <private/qdockwidget_p.h> #include <private/qdockwidget_p.h>
#include <QFocusFrame> #include <QFocusFrame>

View File

@ -39,7 +39,9 @@
#include "simplewidgets_p.h" #include "simplewidgets_p.h"
#if QT_CONFIG(abstractbutton)
#include <qabstractbutton.h> #include <qabstractbutton.h>
#endif
#if QT_CONFIG(checkbox) #if QT_CONFIG(checkbox)
#include <qcheckbox.h> #include <qcheckbox.h>
#endif #endif
@ -80,6 +82,7 @@ extern QList<QWidget*> childWidgets(const QWidget *widget);
QString qt_accStripAmp(const QString &text); QString qt_accStripAmp(const QString &text);
QString qt_accHotKey(const QString &text); QString qt_accHotKey(const QString &text);
#if QT_CONFIG(abstractbutton)
/*! /*!
\class QAccessibleButton \class QAccessibleButton
\brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets. \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets.
@ -267,7 +270,7 @@ QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) c
} }
return QStringList(); return QStringList();
} }
#endif // QT_CONFIG(abstractbutton)
#ifndef QT_NO_TOOLBUTTON #ifndef QT_NO_TOOLBUTTON
/*! /*!

View File

@ -65,6 +65,7 @@ class QToolButton;
class QGroupBox; class QGroupBox;
class QProgressBar; class QProgressBar;
#if QT_CONFIG(abstractbutton)
class QAccessibleButton : public QAccessibleWidget class QAccessibleButton : public QAccessibleWidget
{ {
Q_DECLARE_TR_FUNCTIONS(QAccessibleButton) Q_DECLARE_TR_FUNCTIONS(QAccessibleButton)
@ -83,6 +84,7 @@ public:
protected: protected:
QAbstractButton *button() const; QAbstractButton *button() const;
}; };
#endif
#ifndef QT_NO_TOOLBUTTON #ifndef QT_NO_TOOLBUTTON
class QAccessibleToolButton : public QAccessibleButton class QAccessibleToolButton : public QAccessibleButton

View File

@ -117,6 +117,12 @@
"condition": "features.tableview", "condition": "features.tableview",
"output": [ "publicFeature", "feature" ] "output": [ "publicFeature", "feature" ]
}, },
"abstractbutton": {
"label": "QAbstractButton",
"purpose": "Abstract base class of button widgets, providing functionality common to buttons.",
"section": "Widgets",
"output": [ "publicFeature" ]
},
"commandlinkbutton": { "commandlinkbutton": {
"label": "QCommandLinkButton", "label": "QCommandLinkButton",
"purpose": "Provides a Vista style command link button.", "purpose": "Provides a Vista style command link button.",
@ -193,6 +199,7 @@
"label": "QRadioButton", "label": "QRadioButton",
"purpose": "Provides a radio button with a text label.", "purpose": "Provides a radio button with a text label.",
"section": "Widgets", "section": "Widgets",
"condition": "features.abstractbutton",
"output": [ "publicFeature" ] "output": [ "publicFeature" ]
}, },
"spinbox": { "spinbox": {
@ -234,20 +241,21 @@
"label": "QCheckBox(", "label": "QCheckBox(",
"purpose": "Provides a checkbox with a text label.", "purpose": "Provides a checkbox with a text label.",
"section": "Widgets", "section": "Widgets",
"condition": "features.abstractbutton",
"output": [ "publicFeature" ] "output": [ "publicFeature" ]
}, },
"pushbutton": { "pushbutton": {
"label": "QPushButton", "label": "QPushButton",
"purpose": "Provides a command button.", "purpose": "Provides a command button.",
"section": "Widgets", "section": "Widgets",
"condition": "features.action", "condition": "features.abstractbutton && features.action",
"output": [ "publicFeature" ] "output": [ "publicFeature" ]
}, },
"toolbutton": { "toolbutton": {
"label": "QToolButton", "label": "QToolButton",
"purpose": "Provides quick-access buttons to commands and options.", "purpose": "Provides quick-access buttons to commands and options.",
"section": "Widgets", "section": "Widgets",
"condition": "features.action", "condition": "features.abstractbutton && features.action",
"output": [ "publicFeature", "feature" ] "output": [ "publicFeature", "feature" ]
}, },
"toolbar": { "toolbar": {
@ -274,7 +282,7 @@
"label": "QButtonGroup", "label": "QButtonGroup",
"purpose": "Supports organizing groups of button widgets.", "purpose": "Supports organizing groups of button widgets.",
"section": "Widgets", "section": "Widgets",
"condition": "features.groupbox", "condition": "features.abstractbutton && features.groupbox",
"output": [ "publicFeature", "feature" ] "output": [ "publicFeature", "feature" ]
}, },
"mainwindow": { "mainwindow": {

View File

@ -49,7 +49,9 @@
#include <qevent.h> #include <qevent.h>
#include <qbitarray.h> #include <qbitarray.h>
#include <qscrollbar.h> #include <qscrollbar.h>
#if QT_CONFIG(abstractbutton)
#include <qabstractbutton.h> #include <qabstractbutton.h>
#endif
#include <private/qtableview_p.h> #include <private/qtableview_p.h>
#include <private/qheaderview_p.h> #include <private/qheaderview_p.h>
#include <private/qscrollbar_p.h> #include <private/qscrollbar_p.h>
@ -578,6 +580,7 @@ bool QSpanCollection::checkConsistency() const
} }
#endif #endif
#if QT_CONFIG(abstractbutton)
class QTableCornerButton : public QAbstractButton class QTableCornerButton : public QAbstractButton
{ {
Q_OBJECT Q_OBJECT
@ -600,6 +603,7 @@ public:
style()->drawControl(QStyle::CE_Header, &opt, &painter, this); style()->drawControl(QStyle::CE_Header, &opt, &painter, this);
} }
}; };
#endif
void QTableViewPrivate::init() void QTableViewPrivate::init()
{ {
@ -619,9 +623,11 @@ void QTableViewPrivate::init()
tabKeyNavigation = true; tabKeyNavigation = true;
#if QT_CONFIG(abstractbutton)
cornerWidget = new QTableCornerButton(q); cornerWidget = new QTableCornerButton(q);
cornerWidget->setFocusPolicy(Qt::NoFocus); cornerWidget->setFocusPolicy(Qt::NoFocus);
QObject::connect(cornerWidget, SIGNAL(clicked()), q, SLOT(selectAll())); QObject::connect(cornerWidget, SIGNAL(clicked()), q, SLOT(selectAll()));
#endif
} }
/*! /*!
@ -2121,6 +2127,7 @@ void QTableView::updateGeometries()
if (d->horizontalHeader->isHidden()) if (d->horizontalHeader->isHidden())
QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries"); QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries");
#if QT_CONFIG(abstractbutton)
// update cornerWidget // update cornerWidget
if (d->horizontalHeader->isHidden() || d->verticalHeader->isHidden()) { if (d->horizontalHeader->isHidden() || d->verticalHeader->isHidden()) {
d->cornerWidget->setHidden(true); d->cornerWidget->setHidden(true);
@ -2128,6 +2135,7 @@ void QTableView::updateGeometries()
d->cornerWidget->setHidden(false); d->cornerWidget->setHidden(false);
d->cornerWidget->setGeometry(verticalLeft, horizontalTop, width, height); d->cornerWidget->setGeometry(verticalLeft, horizontalTop, width, height);
} }
#endif
// update scroll bars // update scroll bars
@ -2642,6 +2650,7 @@ bool QTableView::wordWrap() const
return d->wrapItemText; return d->wrapItemText;
} }
#if QT_CONFIG(abstractbutton)
/*! /*!
\property QTableView::cornerButtonEnabled \property QTableView::cornerButtonEnabled
\brief whether the button in the top-left corner is enabled \brief whether the button in the top-left corner is enabled
@ -2664,6 +2673,7 @@ bool QTableView::isCornerButtonEnabled() const
Q_D(const QTableView); Q_D(const QTableView);
return d->cornerWidget->isEnabled(); return d->cornerWidget->isEnabled();
} }
#endif
/*! /*!
\internal \internal

View File

@ -58,7 +58,9 @@ class Q_WIDGETS_EXPORT QTableView : public QAbstractItemView
Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle) Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle)
Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled) Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap) Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
#if QT_CONFIG(abstractbutton)
Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled) Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled)
#endif
public: public:
explicit QTableView(QWidget *parent = Q_NULLPTR); explicit QTableView(QWidget *parent = Q_NULLPTR);
@ -103,8 +105,10 @@ public:
void setWordWrap(bool on); void setWordWrap(bool on);
bool wordWrap() const; bool wordWrap() const;
#if QT_CONFIG(abstractbutton)
void setCornerButtonEnabled(bool enable); void setCornerButtonEnabled(bool enable);
bool isCornerButtonEnabled() const; bool isCornerButtonEnabled() const;
#endif
QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE; QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE;
void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE; void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE;

View File

@ -192,7 +192,9 @@ public:
QVector<int> rowsToUpdate; QVector<int> rowsToUpdate;
QHeaderView *horizontalHeader; QHeaderView *horizontalHeader;
QHeaderView *verticalHeader; QHeaderView *verticalHeader;
#if QT_CONFIG(abstractbutton)
QWidget *cornerWidget; QWidget *cornerWidget;
#endif
bool sortingEnabled; bool sortingEnabled;
bool geometryRecursionBlock; bool geometryRecursionBlock;
QPoint visualCursor; // (Row,column) cell coordinates to track through span navigation. QPoint visualCursor; // (Row,column) cell coordinates to track through span navigation.

View File

@ -45,7 +45,8 @@
#include <qcombobox.h> #include <qcombobox.h>
#if QT_CONFIG(pushbutton) #if QT_CONFIG(pushbutton)
#include <qpushbutton.h> #include <qpushbutton.h>
#else #endif
#if QT_CONFIG(abstractbutton)
#include <qabstractbutton.h> #include <qabstractbutton.h>
#endif #endif
#include <qpainter.h> #include <qpainter.h>
@ -3284,7 +3285,10 @@ void QFusionStyle::polish(QApplication *app)
void QFusionStyle::polish(QWidget *widget) void QFusionStyle::polish(QWidget *widget)
{ {
QCommonStyle::polish(widget); QCommonStyle::polish(widget);
if (qobject_cast<QAbstractButton*>(widget) if (false
#if QT_CONFIG(abstractbutton)
|| qobject_cast<QAbstractButton*>(widget)
#endif
#if QT_CONFIG(combobox) #if QT_CONFIG(combobox)
|| qobject_cast<QComboBox *>(widget) || qobject_cast<QComboBox *>(widget)
#endif #endif
@ -3325,7 +3329,10 @@ void QFusionStyle::polish(QPalette &pal)
void QFusionStyle::unpolish(QWidget *widget) void QFusionStyle::unpolish(QWidget *widget)
{ {
QCommonStyle::unpolish(widget); QCommonStyle::unpolish(widget);
if (qobject_cast<QAbstractButton*>(widget) if (false
#if QT_CONFIG(abstractbutton)
|| qobject_cast<QAbstractButton*>(widget)
#endif
#if QT_CONFIG(combobox) #if QT_CONFIG(combobox)
|| qobject_cast<QComboBox *>(widget) || qobject_cast<QComboBox *>(widget)
#endif #endif

View File

@ -4268,6 +4268,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
case PE_PanelButtonTool: case PE_PanelButtonTool:
case PE_PanelButtonCommand: case PE_PanelButtonCommand:
#if QT_CONFIG(abstractbutton)
if (qobject_cast<const QAbstractButton *>(w) && rule.hasBackground() && rule.hasNativeBorder()) { if (qobject_cast<const QAbstractButton *>(w) && rule.hasBackground() && rule.hasNativeBorder()) {
//the window style will draw the borders //the window style will draw the borders
ParentStyle::drawPrimitive(pe, opt, p, w); ParentStyle::drawPrimitive(pe, opt, p, w);
@ -4276,6 +4277,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
} }
return; return;
} }
#endif
if (!rule.hasNativeBorder()) { if (!rule.hasNativeBorder()) {
rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin)); rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin));
return; return;

View File

@ -1139,7 +1139,10 @@ void QWindowsXPStyle::polish(QWidget *widget)
if (!QWindowsXPStylePrivate::useXP()) if (!QWindowsXPStylePrivate::useXP())
return; return;
if (qobject_cast<QAbstractButton*>(widget) if (false
#if QT_CONFIG(abstractbutton)
|| qobject_cast<QAbstractButton*>(widget)
#endif
|| qobject_cast<QToolButton*>(widget) || qobject_cast<QToolButton*>(widget)
|| qobject_cast<QTabBar*>(widget) || qobject_cast<QTabBar*>(widget)
#ifndef QT_NO_COMBOBOX #ifndef QT_NO_COMBOBOX
@ -1211,7 +1214,10 @@ void QWindowsXPStyle::unpolish(QWidget *widget)
// already in the map might be old (other style). // already in the map might be old (other style).
d->cleanupHandleMap(); d->cleanupHandleMap();
} }
if (qobject_cast<QAbstractButton*>(widget) if (false
#if QT_CONFIG(abstractbutton)
|| qobject_cast<QAbstractButton*>(widget)
#endif
|| qobject_cast<QToolButton*>(widget) || qobject_cast<QToolButton*>(widget)
|| qobject_cast<QTabBar*>(widget) || qobject_cast<QTabBar*>(widget)
#ifndef QT_NO_COMBOBOX #ifndef QT_NO_COMBOBOX

View File

@ -45,6 +45,8 @@
#include <QtGui/qkeysequence.h> #include <QtGui/qkeysequence.h>
#include <QtWidgets/qwidget.h> #include <QtWidgets/qwidget.h>
QT_REQUIRE_CONFIG(abstractbutton);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -41,7 +41,9 @@
#include "qevent.h" #include "qevent.h"
#include "qdrawutil.h" #include "qdrawutil.h"
#include "qapplication.h" #include "qapplication.h"
#if QT_CONFIG(abstractbutton)
#include "qabstractbutton.h" #include "qabstractbutton.h"
#endif
#include "qstyle.h" #include "qstyle.h"
#include "qstyleoption.h" #include "qstyleoption.h"
#include <limits.h> #include <limits.h>
@ -972,12 +974,14 @@ bool QLabel::event(QEvent *e)
QShortcutEvent *se = static_cast<QShortcutEvent *>(e); QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
if (se->shortcutId() == d->shortcutId) { if (se->shortcutId() == d->shortcutId) {
QWidget * w = d->buddy; QWidget * w = d->buddy;
QAbstractButton *button = qobject_cast<QAbstractButton *>(w);
if (w->focusPolicy() != Qt::NoFocus) if (w->focusPolicy() != Qt::NoFocus)
w->setFocus(Qt::ShortcutFocusReason); w->setFocus(Qt::ShortcutFocusReason);
#if QT_CONFIG(abstractbutton)
QAbstractButton *button = qobject_cast<QAbstractButton *>(w);
if (button && !se->isAmbiguous()) if (button && !se->isAmbiguous())
button->animateClick(); button->animateClick();
else else
#endif
window()->setAttribute(Qt::WA_KeyboardFocusChange); window()->setAttribute(Qt::WA_KeyboardFocusChange);
return true; return true;
} }

View File

@ -41,13 +41,14 @@
#define QTOOLBUTTON_H #define QTOOLBUTTON_H
#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qtwidgetsglobal.h>
#if QT_CONFIG(toolbutton)
#include <QtWidgets/qabstractbutton.h> #include <QtWidgets/qabstractbutton.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#ifndef QT_NO_TOOLBUTTON
class QToolButtonPrivate; class QToolButtonPrivate;
class QMenu; class QMenu;
class QStyleOptionToolButton; class QStyleOptionToolButton;
@ -134,8 +135,8 @@ private:
}; };
#endif // QT_NO_TOOLBUTTON
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QT_CONFIG(toolbutton)
#endif // QTOOLBUTTON_H #endif // QTOOLBUTTON_H

View File

@ -3,8 +3,6 @@
HEADERS += \ HEADERS += \
widgets/qbuttongroup.h \ widgets/qbuttongroup.h \
widgets/qbuttongroup_p.h \ widgets/qbuttongroup_p.h \
widgets/qabstractbutton.h \
widgets/qabstractbutton_p.h \
widgets/qabstractspinbox.h \ widgets/qabstractspinbox.h \
widgets/qabstractspinbox_p.h \ widgets/qabstractspinbox_p.h \
widgets/qcalendarwidget.h \ widgets/qcalendarwidget.h \
@ -76,7 +74,6 @@ HEADERS += \
SOURCES += \ SOURCES += \
widgets/qbuttongroup.cpp \ widgets/qbuttongroup.cpp \
widgets/qabstractbutton.cpp \
widgets/qabstractspinbox.cpp \ widgets/qabstractspinbox.cpp \
widgets/qcalendarwidget.cpp \ widgets/qcalendarwidget.cpp \
widgets/qcombobox.cpp \ widgets/qcombobox.cpp \
@ -128,6 +125,15 @@ SOURCES += \
widgets/qtoolbararealayout.cpp \ widgets/qtoolbararealayout.cpp \
widgets/qplaintextedit.cpp widgets/qplaintextedit.cpp
qtConfig(abstractbutton) {
HEADERS += \
widgets/qabstractbutton.h \
widgets/qabstractbutton_p.h
SOURCES += \
widgets/qabstractbutton.cpp
}
qtConfig(abstractslider) { qtConfig(abstractslider) {
HEADERS += \ HEADERS += \
widgets/qabstractslider.h \ widgets/qabstractslider.h \