diff options
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/widgets/accessible/itemviews.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/accessible/itemviews_p.h | 4 | ||||
| -rw-r--r-- | src/widgets/accessible/qaccessiblewidgets.cpp | 46 | ||||
| -rw-r--r-- | src/widgets/accessible/rangecontrols.cpp | 26 | ||||
| -rw-r--r-- | src/widgets/accessible/rangecontrols_p.h | 5 | ||||
| -rw-r--r-- | src/widgets/dialogs/qcolordialog.cpp | 256 | ||||
| -rw-r--r-- | src/widgets/dialogs/qcolorwell_p.h | 142 | ||||
| -rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 1 | ||||
| -rw-r--r-- | src/widgets/dialogs/qfiledialog.ui | 10 | ||||
| -rw-r--r-- | src/widgets/dialogs/qfiledialog_p.h | 5 | ||||
| -rw-r--r-- | src/widgets/dialogs/qfontdialog.cpp | 2 | ||||
| -rw-r--r-- | src/widgets/kernel/qlayout.cpp | 11 | ||||
| -rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 21 | ||||
| -rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 13 | ||||
| -rw-r--r-- | src/widgets/widgets/qlineedit_p.cpp | 7 | ||||
| -rw-r--r-- | src/widgets/widgets/qtabbar.cpp | 2 |
17 files changed, 330 insertions, 226 deletions
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index ce30f50616b..c0be3debe49 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -681,6 +681,7 @@ qt_internal_extend_target(Widgets CONDITION MACOS AND (QT_FEATURE_menu OR QT_FEA qt_internal_extend_target(Widgets CONDITION QT_FEATURE_colordialog SOURCES dialogs/qcolordialog.cpp dialogs/qcolordialog.h + dialogs/qcolorwell_p.h ) qt_internal_extend_target(Widgets CONDITION QT_FEATURE_dialog diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index fc969e17380..265c523eae0 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -60,7 +60,7 @@ int QAccessibleTable::logicalIndex(const QModelIndex &index) const } QAccessibleTable::QAccessibleTable(QWidget *w) - : QAccessibleObject(w) + : QAccessibleWidgetV2(w) { Q_ASSERT(view()); @@ -677,7 +677,7 @@ void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t) return static_cast<QAccessibleSelectionInterface*>(this); if (t == QAccessible::TableInterface) return static_cast<QAccessibleTableInterface*>(this); - return nullptr; + return QAccessibleWidgetV2::interface_cast(t); } void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) diff --git a/src/widgets/accessible/itemviews_p.h b/src/widgets/accessible/itemviews_p.h index 9b30f36ced3..79f9a7f2f05 100644 --- a/src/widgets/accessible/itemviews_p.h +++ b/src/widgets/accessible/itemviews_p.h @@ -31,7 +31,9 @@ QT_BEGIN_NAMESPACE class QAccessibleTableCell; class QAccessibleTableHeaderCell; -class QAccessibleTable :public QAccessibleTableInterface, public QAccessibleSelectionInterface, public QAccessibleObject +class QAccessibleTable : public QAccessibleTableInterface, + public QAccessibleSelectionInterface, + public QAccessibleWidgetV2 { public: explicit QAccessibleTable(QWidget *w); diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 608a99b575d..cd28a61f427 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -958,54 +958,22 @@ QPoint QAccessibleTextWidget::scrollBarPosition() const QString QAccessibleTextWidget::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const { - Q_ASSERT(startOffset); - Q_ASSERT(endOffset); - - QTextCursor cursor = textCursor(); - cursor.setPosition(offset); - std::pair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - cursor.setPosition(boundaries.first - 1); - boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); - } - + return qt_accTextBeforeOffsetHelper(*this, textCursor(), offset, boundaryType, startOffset, + endOffset); +} QString QAccessibleTextWidget::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const { - Q_ASSERT(startOffset); - Q_ASSERT(endOffset); - - QTextCursor cursor = textCursor(); - cursor.setPosition(offset); - std::pair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - cursor.setPosition(boundaries.second); - boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); + return qt_accTextAfterOffsetHelper(*this, textCursor(), offset, boundaryType, startOffset, + endOffset); } QString QAccessibleTextWidget::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const { - Q_ASSERT(startOffset); - Q_ASSERT(endOffset); - - QTextCursor cursor = textCursor(); - cursor.setPosition(offset); - std::pair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); + return qt_accTextAtOffsetHelper(*this, textCursor(), offset, boundaryType, startOffset, + endOffset); } void QAccessibleTextWidget::setCursorPosition(int position) diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp index 741a1589851..1f7b20833dd 100644 --- a/src/widgets/accessible/rangecontrols.cpp +++ b/src/widgets/accessible/rangecontrols.cpp @@ -65,6 +65,16 @@ QAccessibleInterface *QAccessibleAbstractSpinBox::lineEditIface() const #endif } +QAccessible::State QAccessibleAbstractSpinBox::state() const +{ + QAccessible::State state = QAccessibleWidgetV2::state(); + if (abstractSpinBox()->isReadOnly()) + state.readOnly = true; + else + state.editable = true; + return state; +} + QString QAccessibleAbstractSpinBox::text(QAccessible::Text t) const { if (t == QAccessible::Value) @@ -338,6 +348,22 @@ void *QAccessibleAbstractSlider::interface_cast(QAccessible::InterfaceType t) return QAccessibleWidgetV2::interface_cast(t); } +QList<QAccessible::Attribute> QAccessibleAbstractSlider::attributeKeys() const +{ + QList<QAccessible::Attribute> keys = QAccessibleWidgetV2::attributeKeys(); + keys.append(QAccessible::Attribute::Orientation); + + return keys; +} + +QVariant QAccessibleAbstractSlider::attributeValue(QAccessible::Attribute key) const +{ + if (key == QAccessible::Attribute::Orientation) + return QVariant::fromValue(abstractSlider()->orientation()); + + return QAccessibleWidgetV2::attributeValue(key); +} + QVariant QAccessibleAbstractSlider::currentValue() const { return abstractSlider()->value(); diff --git a/src/widgets/accessible/rangecontrols_p.h b/src/widgets/accessible/rangecontrols_p.h index 23482556f42..5a023d2f00b 100644 --- a/src/widgets/accessible/rangecontrols_p.h +++ b/src/widgets/accessible/rangecontrols_p.h @@ -42,6 +42,7 @@ public: explicit QAccessibleAbstractSpinBox(QWidget *w); virtual ~QAccessibleAbstractSpinBox(); + QAccessible::State state() const override; QString text(QAccessible::Text t) const override; void *interface_cast(QAccessible::InterfaceType t) override; @@ -114,6 +115,10 @@ public: explicit QAccessibleAbstractSlider(QWidget *w, QAccessible::Role r = QAccessible::Slider); void *interface_cast(QAccessible::InterfaceType t) override; + // QAccessibleAttributesInterface + QList<QAccessible::Attribute> attributeKeys() const override; + QVariant attributeValue(QAccessible::Attribute key) const override; + // QAccessibleValueInterface QVariant currentValue() const override; void setCurrentValue(const QVariant &value) override; diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index b4ca17b9f64..f8125204045 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -39,6 +39,7 @@ #include "qwindow.h" #include "private/qdialog_p.h" +#include "private/qcolorwell_p.h" #include <qpa/qplatformintegration.h> #include <qpa/qplatformservices.h> @@ -56,16 +57,12 @@ namespace QtPrivate { class QColorLuminancePicker; class QColorPicker; class QColorShower; -class QWellArray; -class QColorWell; class QColorPickingEventFilter; } // namespace QtPrivate using QColorLuminancePicker = QtPrivate::QColorLuminancePicker; using QColorPicker = QtPrivate::QColorPicker; using QColorShower = QtPrivate::QColorShower; -using QWellArray = QtPrivate::QWellArray; -using QColorWell = QtPrivate::QColorWell; using QColorPickingEventFilter = QtPrivate::QColorPickingEventFilter; class QColorDialogPrivate : public QDialogPrivate @@ -162,96 +159,6 @@ private: //////////// QWellArray BEGIN -namespace QtPrivate { - -class QWellArray : public QWidget -{ - Q_OBJECT - Q_PROPERTY(int selectedColumn READ selectedColumn) - Q_PROPERTY(int selectedRow READ selectedRow) - -public: - QWellArray(int rows, int cols, QWidget* parent=nullptr); - ~QWellArray() {} - QString cellContent(int row, int col) const; - - int selectedColumn() const { return selCol; } - int selectedRow() const { return selRow; } - - virtual void setCurrent(int row, int col); - virtual void setSelected(int row, int col); - - QSize sizeHint() const override; - - inline int cellWidth() const - { return cellw; } - - inline int cellHeight() const - { return cellh; } - - inline int rowAt(int y) const - { return y / cellh; } - - inline int columnAt(int x) const - { if (isRightToLeft()) return ncols - (x / cellw) - 1; return x / cellw; } - - inline int rowY(int row) const - { return cellh * row; } - - inline int columnX(int column) const - { if (isRightToLeft()) return cellw * (ncols - column - 1); return cellw * column; } - - inline int numRows() const - { return nrows; } - - inline int numCols() const - {return ncols; } - - inline QRect cellRect() const - { return QRect(0, 0, cellw, cellh); } - - inline QSize gridSize() const - { return QSize(ncols * cellw, nrows * cellh); } - - QRect cellGeometry(int row, int column) - { - QRect r; - if (row >= 0 && row < nrows && column >= 0 && column < ncols) - r.setRect(columnX(column), rowY(row), cellw, cellh); - return r; - } - - inline void updateCell(int row, int column) { update(cellGeometry(row, column)); } - -signals: - void selected(int row, int col); - void currentChanged(int row, int col); - void colorChanged(int index, QRgb color); - -protected: - virtual void paintCell(QPainter *, int row, int col, const QRect&); - virtual void paintCellContents(QPainter *, int row, int col, const QRect&); - - void mousePressEvent(QMouseEvent*) override; - void mouseReleaseEvent(QMouseEvent*) override; - void keyPressEvent(QKeyEvent*) override; - void focusInEvent(QFocusEvent*) override; - void focusOutEvent(QFocusEvent*) override; - void paintEvent(QPaintEvent *) override; - -private: - Q_DISABLE_COPY(QWellArray) - - int nrows; - int ncols; - int cellw; - int cellh; - int curRow; - int curCol; - int selRow; - int selCol; -}; - void QWellArray::paintEvent(QPaintEvent *e) { QRect r = e->rect(); @@ -476,11 +383,12 @@ void QWellArray::keyPressEvent(QKeyEvent* e) e->ignore(); // we don't accept the event return; } - -} // namespace QtPrivate +} //////////// QWellArray END +namespace QtPrivate { + // Event filter to be installed on the dialog while in color-picking mode. class QColorPickingEventFilter : public QObject { public: @@ -511,7 +419,7 @@ private: QColorDialogPrivate *m_dp; }; -} // unnamed namespace +} // namespace QtPrivate /*! Returns the number of custom colors supported by QColorDialog. All @@ -571,35 +479,6 @@ static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v) c.getHsv(&h, &s, &v); } -namespace QtPrivate { - -class QColorWell : public QWellArray -{ -public: - QColorWell(QWidget *parent, int r, int c, const QRgb *vals) - :QWellArray(r, c, parent), values(vals), mousePressed(false), oldCurrent(-1, -1) - { setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); } - -protected: - void paintCellContents(QPainter *, int row, int col, const QRect&) override; - void mousePressEvent(QMouseEvent *e) override; - void mouseMoveEvent(QMouseEvent *e) override; - void mouseReleaseEvent(QMouseEvent *e) override; -#if QT_CONFIG(draganddrop) - void dragEnterEvent(QDragEnterEvent *e) override; - void dragLeaveEvent(QDragLeaveEvent *e) override; - void dragMoveEvent(QDragMoveEvent *e) override; - void dropEvent(QDropEvent *e) override; -#endif - -private: - const QRgb *values; - bool mousePressed; - QPoint pressPos; - QPoint oldCurrent; - -}; - void QColorWell::paintCellContents(QPainter *p, int row, int col, const QRect &r) { int i = row + col*numRows(); @@ -687,6 +566,8 @@ void QColorWell::mouseReleaseEvent(QMouseEvent *e) mousePressed = false; } +namespace QtPrivate { + class QColorPicker : public QFrame { Q_OBJECT @@ -704,18 +585,21 @@ signals: protected: QSize sizeHint() const override; void paintEvent(QPaintEvent*) override; + void keyPressEvent(QKeyEvent *event) override; void mouseMoveEvent(QMouseEvent *) override; void mousePressEvent(QMouseEvent *) override; void resizeEvent(QResizeEvent *) override; private: - int hue; - int sat; + QPoint m_pos; - QPoint colPt(); - int huePt(const QPoint &pt); - int satPt(const QPoint &pt); - void setCol(const QPoint &pt); + QPixmap createColorsPixmap(); + QPoint colPt(int hue, int sat); + int huePt(const QPoint &pt, const QSize &widgetSize); + int huePt(const QPoint &pt) { return huePt(pt, size()); } + int satPt(const QPoint &pt, const QSize &widgetSize); + int satPt(const QPoint &pt) { return satPt(pt, size()); } + void setCol(const QPoint &pt, bool notify = true); QPixmap pix; bool crossVisible; @@ -744,6 +628,7 @@ signals: protected: void paintEvent(QPaintEvent*) override; + void keyPressEvent(QKeyEvent *event) override; void mouseMoveEvent(QMouseEvent *) override; void mousePressEvent(QMouseEvent *) override; @@ -779,6 +664,7 @@ QColorLuminancePicker::QColorLuminancePicker(QWidget* parent) hue = 100; val = 100; sat = 100; pix = nullptr; // setAttribute(WA_NoErase, true); + setFocusPolicy(Qt::StrongFocus); } QColorLuminancePicker::~QColorLuminancePicker() @@ -786,6 +672,21 @@ QColorLuminancePicker::~QColorLuminancePicker() delete pix; } +void QColorLuminancePicker::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Down: + setVal(std::clamp(val - 1, 0, 255)); + break; + case Qt::Key_Up: + setVal(std::clamp(val + 1, 0, 255)); + break; + default: + QWidget::keyPressEvent(event); + break; + } +} + void QColorLuminancePicker::mouseMoveEvent(QMouseEvent *m) { if (m->buttons() == Qt::NoButton) { @@ -856,38 +757,53 @@ void QColorLuminancePicker::setCol(int h, int s , int v) repaint(); } -QPoint QColorPicker::colPt() +QPoint QColorPicker::colPt(int hue, int sat) { QRect r = contentsRect(); return QPoint((360 - hue) * (r.width() - 1) / 360, (255 - sat) * (r.height() - 1) / 255); } -int QColorPicker::huePt(const QPoint &pt) +int QColorPicker::huePt(const QPoint &pt, const QSize &widgetSize) { - QRect r = contentsRect(); - return 360 - pt.x() * 360 / (r.width() - 1); + QRect r = QRect(QPoint(0, 0), widgetSize) - contentsMargins(); + return std::clamp(360 - pt.x() * 360 / (r.width() - 1), 0, 359); } -int QColorPicker::satPt(const QPoint &pt) +int QColorPicker::satPt(const QPoint &pt, const QSize &widgetSize) { - QRect r = contentsRect(); - return 255 - pt.y() * 255 / (r.height() - 1); + QRect r = QRect(QPoint(0, 0), widgetSize) - contentsMargins(); + return std::clamp(255 - pt.y() * 255 / (r.height() - 1), 0, 255); } -void QColorPicker::setCol(const QPoint &pt) +void QColorPicker::setCol(const QPoint &pt, bool notify) { - setCol(huePt(pt), satPt(pt)); + if (pt == m_pos) + return; + + QRect r(m_pos, QSize(20, 20)); + m_pos.setX(std::clamp(pt.x(), 0, pix.width() - 1)); + m_pos.setY(std::clamp(pt.y(), 0, pix.height() - 1)); + r = r.united(QRect(m_pos, QSize(20, 20))); + r.translate(contentsRect().x() - 9, contentsRect().y() - 9); + // update(r); + repaint(r); + + if (notify) + emit newCol(huePt(m_pos), satPt(m_pos)); } QColorPicker::QColorPicker(QWidget* parent) : QFrame(parent) , crossVisible(true) { - hue = 0; sat = 0; - setCol(150, 255); - setAttribute(Qt::WA_NoSystemBackground); + setFocusPolicy(Qt::StrongFocus); setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) ); + adjustSize(); + + pix = createColorsPixmap(); + + setCol(150, 255); } QColorPicker::~QColorPicker() @@ -911,15 +827,31 @@ void QColorPicker::setCol(int h, int s) { int nhue = qMin(qMax(0,h), 359); int nsat = qMin(qMax(0,s), 255); - if (nhue == hue && nsat == sat) + if (nhue == huePt(m_pos) && nsat == satPt(m_pos)) return; - QRect r(colPt(), QSize(20,20)); - hue = nhue; sat = nsat; - r = r.united(QRect(colPt(), QSize(20,20))); - r.translate(contentsRect().x()-9, contentsRect().y()-9); - // update(r); - repaint(r); + setCol(colPt(nhue, nsat), false); +} + +void QColorPicker::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Down: + setCol(m_pos + QPoint(0, 1)); + break; + case Qt::Key_Left: + setCol(m_pos + QPoint(-1, 0)); + break; + case Qt::Key_Right: + setCol(m_pos + QPoint(1, 0)); + break; + case Qt::Key_Up: + setCol(m_pos + QPoint(0, -1)); + break; + default: + QFrame::keyPressEvent(event); + break; + } } void QColorPicker::mouseMoveEvent(QMouseEvent *m) @@ -930,14 +862,12 @@ void QColorPicker::mouseMoveEvent(QMouseEvent *m) return; } setCol(p); - emit newCol(hue, sat); } void QColorPicker::mousePressEvent(QMouseEvent *m) { QPoint p = m->position().toPoint() - contentsRect().topLeft(); setCol(p); - emit newCol(hue, sat); } void QColorPicker::paintEvent(QPaintEvent* ) @@ -949,7 +879,7 @@ void QColorPicker::paintEvent(QPaintEvent* ) p.drawPixmap(r.topLeft(), pix); if (crossVisible) { - QPoint pt = colPt() + r.topLeft(); + QPoint pt = m_pos + r.topLeft(); p.setPen(Qt::black); p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black); p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black); @@ -960,6 +890,21 @@ void QColorPicker::resizeEvent(QResizeEvent *ev) { QFrame::resizeEvent(ev); + pix = createColorsPixmap(); + + const QSize &oldSize = ev->oldSize(); + if (!oldSize.isValid()) + return; + + // calculate hue/saturation based on previous widget size + // and update position accordingly + const int hue = huePt(m_pos, oldSize); + const int sat = satPt(m_pos, oldSize); + setCol(hue, sat); +} + +QPixmap QColorPicker::createColorsPixmap() +{ int w = width() - frameWidth() * 2; int h = height() - frameWidth() * 2; QImage img(w, h, QImage::Format_RGB32); @@ -977,10 +922,9 @@ void QColorPicker::resizeEvent(QResizeEvent *ev) ++x; } } - pix = QPixmap::fromImage(img); + return QPixmap::fromImage(img); } - class QColSpinBox : public QSpinBox { public: diff --git a/src/widgets/dialogs/qcolorwell_p.h b/src/widgets/dialogs/qcolorwell_p.h new file mode 100644 index 00000000000..31d69fabb13 --- /dev/null +++ b/src/widgets/dialogs/qcolorwell_p.h @@ -0,0 +1,142 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QCOLORWELL_P_H +#define QCOLORWELL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qrect.h> +#include <QtWidgets/qwidget.h> + +QT_REQUIRE_CONFIG(colordialog); + +QT_BEGIN_NAMESPACE + +class QWellArray : public QWidget +{ + Q_OBJECT + Q_PROPERTY(int selectedColumn READ selectedColumn) + Q_PROPERTY(int selectedRow READ selectedRow) + +public: + QWellArray(int rows, int cols, QWidget *parent = nullptr); + ~QWellArray() { } + + int selectedColumn() const { return selCol; } + int selectedRow() const { return selRow; } + + virtual void setCurrent(int row, int col); + virtual void setSelected(int row, int col); + + QSize sizeHint() const override; + + inline int cellWidth() const { return cellw; } + + inline int cellHeight() const { return cellh; } + + inline int rowAt(int y) const { return y / cellh; } + + inline int columnAt(int x) const + { + if (isRightToLeft()) + return ncols - (x / cellw) - 1; + return x / cellw; + } + + inline int rowY(int row) const { return cellh * row; } + + inline int columnX(int column) const + { + if (isRightToLeft()) + return cellw * (ncols - column - 1); + return cellw * column; + } + + inline int numRows() const { return nrows; } + + inline int numCols() const { return ncols; } + + inline QRect cellRect() const { return QRect(0, 0, cellw, cellh); } + + inline QSize gridSize() const { return QSize(ncols * cellw, nrows * cellh); } + + QRect cellGeometry(int row, int column) + { + QRect r; + if (row >= 0 && row < nrows && column >= 0 && column < ncols) + r.setRect(columnX(column), rowY(row), cellw, cellh); + return r; + } + + inline void updateCell(int row, int column) { update(cellGeometry(row, column)); } + +signals: + void selected(int row, int col); + void currentChanged(int row, int col); + void colorChanged(int index, QRgb color); + +protected: + virtual void paintCell(QPainter *, int row, int col, const QRect &); + virtual void paintCellContents(QPainter *, int row, int col, const QRect &); + + void mousePressEvent(QMouseEvent *) override; + void mouseReleaseEvent(QMouseEvent *) override; + void keyPressEvent(QKeyEvent *) override; + void focusInEvent(QFocusEvent *) override; + void focusOutEvent(QFocusEvent *) override; + void paintEvent(QPaintEvent *) override; + +private: + Q_DISABLE_COPY(QWellArray) + + int nrows; + int ncols; + int cellw; + int cellh; + int curRow; + int curCol; + int selRow; + int selCol; +}; + +class QColorWell : public QWellArray +{ +public: + QColorWell(QWidget *parent, int r, int c, const QRgb *vals) + : QWellArray(r, c, parent), values(vals), mousePressed(false), oldCurrent(-1, -1) + { + setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); + } + +protected: + void paintCellContents(QPainter *, int row, int col, const QRect &) override; + void mousePressEvent(QMouseEvent *e) override; + void mouseMoveEvent(QMouseEvent *e) override; + void mouseReleaseEvent(QMouseEvent *e) override; +#if QT_CONFIG(draganddrop) + void dragEnterEvent(QDragEnterEvent *e) override; + void dragLeaveEvent(QDragLeaveEvent *e) override; + void dragMoveEvent(QDragMoveEvent *e) override; + void dropEvent(QDropEvent *e) override; +#endif + +private: + const QRgb *values; + bool mousePressed; + QPoint pressPos; + QPoint oldCurrent; +}; + +QT_END_NAMESPACE + +#endif // QCOLORWELL_P_H diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index d964c9667e6..1ed9dd06e3c 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -3008,7 +3008,6 @@ void QFileDialogPrivate::createWidgets() qFileDialogUi->lookInCombo->setDuplicatesEnabled(false); // filename - qFileDialogUi->fileNameEdit->setFileDialogPrivate(this); #ifndef QT_NO_SHORTCUT qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit); #endif diff --git a/src/widgets/dialogs/qfiledialog.ui b/src/widgets/dialogs/qfiledialog.ui index f275e20c633..97f39fa6194 100644 --- a/src/widgets/dialogs/qfiledialog.ui +++ b/src/widgets/dialogs/qfiledialog.ui @@ -20,7 +20,10 @@ <item row="0" column="0"> <widget class="QLabel" name="lookInLabel"> <property name="text"> - <string>Look in:</string> + <string>&Look in:</string> + </property> + <property name="buddy"> + <cstring>lookInCombo</cstring> </property> </widget> </item> @@ -284,7 +287,10 @@ </sizepolicy> </property> <property name="text"> - <string>Files of type:</string> + <string>Files of &type:</string> + </property> + <property name="buddy"> + <cstring>fileTypeCombo</cstring> </property> </widget> </item> diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index 15044cfd291..dd4a2505def 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -266,12 +266,9 @@ private: class QFileDialogLineEdit : public QLineEdit { public: - QFileDialogLineEdit(QWidget *parent = nullptr) : QLineEdit(parent), d_ptr(nullptr){} - void setFileDialogPrivate(QFileDialogPrivate *d_pointer) {d_ptr = d_pointer; } + QFileDialogLineEdit(QWidget *parent = nullptr) : QLineEdit(parent) {} void keyPressEvent(QKeyEvent *e) override; bool hideOnEsc; -private: - QFileDialogPrivate *d_ptr; }; class QFileDialogComboBox : public QComboBox diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 870b0c40faf..c4f8af1a639 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -172,7 +172,7 @@ void QFontDialogPrivate::init() sizeAccel = new QLabel(q); #ifndef QT_NO_SHORTCUT - sizeAccel->setBuddy(sizeEdit); + sizeAccel->setBuddy(sizeList); #endif sizeAccel->setIndent(2); diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 00f9766af29..5ba92714f6c 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -345,6 +345,17 @@ void QLayout::getContentsMargins(int *left, int *top, int *right, int *bottom) c } /*! + \property QLayout::contentsMargins + \since 4.6 + \brief the margins used around the layout + + By default, QLayout uses the values provided by the style. On + most platforms, the margin is 11 pixels in all directions. + + \sa setContentsMargins(), getContentsMargins() +*/ + +/*! \since 4.6 Returns the margins used around the layout. diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index c4b78539114..bb9f7ab27fc 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5,15 +5,12 @@ #include "qcommonstyle.h" #include "qcommonstyle_p.h" -#include <qfile.h> #if QT_CONFIG(itemviews) #include <qabstractitemview.h> #endif #include <qapplication.h> #include <private/qguiapplication_p.h> #include <qpa/qplatformtheme.h> -#include <qbitmap.h> -#include <qcache.h> #if QT_CONFIG(dockwidget) #include <qdockwidget.h> #endif @@ -61,7 +58,6 @@ #endif #include <private/qcommonstylepixmaps_p.h> #include <private/qmath_p.h> -#include <qdebug.h> #include <qtextformat.h> #if QT_CONFIG(wizard) #include <qwizard.h> @@ -69,11 +65,6 @@ #if QT_CONFIG(filedialog) #include <qsidebar_p.h> #endif -#include <qfileinfo.h> -#include <qdir.h> -#if QT_CONFIG(settings) -#include <qsettings.h> -#endif #include <qvariant.h> #include <qpixmapcache.h> #if QT_CONFIG(animation) @@ -6199,17 +6190,17 @@ QPixmap QCommonStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &p return QPixmap::fromImage(std::move(im)); } case QIcon::Selected: { - QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); QColor color = opt->palette.color(QPalette::Normal, QPalette::Highlight); color.setAlphaF(0.3f); - QPainter painter(&img); + QPixmap ret(pixmap); + QPainter painter(&ret); painter.setCompositionMode(QPainter::CompositionMode_SourceAtop); - painter.fillRect(0, 0, img.width(), img.height(), color); + painter.fillRect(0, 0, pixmap.width(), pixmap.height(), color); painter.end(); - return QPixmap::fromImage(std::move(img)); } + return ret; + } case QIcon::Active: - return pixmap; - default: + case QIcon::Normal: break; } return pixmap; diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 9b06822c218..b9143a59ee7 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -851,6 +851,12 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } #ifndef QT_NO_FRAME case PE_Frame: + if (w && w->inherits("QComboBoxPrivateContainer")){ + QStyleOption copy = *opt; + copy.state |= State_Raised; + proxy()->drawPrimitive(PE_PanelMenu, ©, p, w); + break; + } case PE_FrameMenu: if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { if (frame->lineWidth == 2 || pe == PE_Frame) { @@ -873,6 +879,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } } else { QPalette popupPal = opt->palette; + p->drawRect(opt->rect); popupPal.setColor(QPalette::Light, opt->palette.window().color()); popupPal.setColor(QPalette::Midlight, opt->palette.light().color()); qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken); @@ -899,6 +906,12 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->drawRect(opt->rect); } break; } + case PE_PanelMenu: + if (w && w->inherits("QComboBoxPrivateContainer")){ + const QBrush menuBackground = opt->palette.base().color(); + QColor borderColor = opt->palette.window().color(); + qDrawPlainRect(p, opt->rect, borderColor, 1, &menuBackground); + } case PE_FrameWindow: { QPalette popupPal = opt->palette; popupPal.setColor(QPalette::Light, opt->palette.window().color()); diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 55e6137dba9..ee80cca649c 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -353,17 +353,16 @@ QLineEditPrivate *QLineEditIconButton::lineEditPrivate() const void QLineEditIconButton::paintEvent(QPaintEvent *) { QPainter painter(this); - QIcon::Mode state = QIcon::Disabled; + QIcon::Mode mode = QIcon::Disabled; if (isEnabled()) - state = isDown() ? QIcon::Active : QIcon::Normal; + mode = isDown() ? QIcon::Active : QIcon::Normal; const QLineEditPrivate *lep = lineEditPrivate(); const int iconWidth = lep ? lep->sideWidgetParameters().iconSize : 16; const QSize iconSize(iconWidth, iconWidth); - const QPixmap iconPixmap = icon().pixmap(iconSize, devicePixelRatio(), state, QIcon::Off); QRect pixmapRect = QRect(QPoint(0, 0), iconSize); pixmapRect.moveCenter(rect().center()); painter.setOpacity(m_opacity); - painter.drawPixmap(pixmapRect, iconPixmap); + icon().paint(&painter, pixmapRect, Qt::AlignCenter, mode, QIcon::Off); } void QLineEditIconButton::actionEvent(QActionEvent *e) diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 0b562a47879..8e6f497d7f5 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -1003,7 +1003,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text) ++tab->lastTab; } - if (tabAt(d->mousePosition) == index) { + if (isVisible() && tabAt(d->mousePosition) == index) { d->hoverIndex = index; d->hoverRect = tabRect(index); } |
