diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qabstractscrollarea.cpp | 58 | ||||
-rw-r--r-- | src/gui/widgets/qabstractscrollarea.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/qabstractscrollarea_p.h | 5 | ||||
-rw-r--r-- | src/gui/widgets/qdockarealayout.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/qdockwidget.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/qlinecontrol.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/qlinecontrol_p.h | 5 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit_p.cpp | 15 | ||||
-rw-r--r-- | src/gui/widgets/qlineedit_p.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/qmainwindowlayout.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 41 | ||||
-rw-r--r-- | src/gui/widgets/qmenubar.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/qtextedit.cpp | 24 | ||||
-rw-r--r-- | src/gui/widgets/qtextedit.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/qtextedit_p.h | 4 |
17 files changed, 100 insertions, 86 deletions
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index 391e095..c72c36c 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate() :hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded), viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0), - xoffset(0), yoffset(0), viewportFilter(0) + xoffset(0), yoffset(0), viewportFilter(0), panGesture(0) #ifdef Q_WS_WIN , singleFingerPanEnabled(false) #endif @@ -294,33 +294,18 @@ void QAbstractScrollAreaPrivate::init() q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layoutChildren(); + + panGesture = new QPanGesture(q); + QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered())); } -void QAbstractScrollAreaPrivate::setupGestures() +#ifdef Q_WS_WIN +void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on) { -#ifdef Q_OS_WIN - if (!viewport) - return; - QApplicationPrivate* getQApplicationPrivateInternal(); - QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal(); - bool needh = (hbarpolicy == Qt::ScrollBarAlwaysOn - || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum())); - - bool needv = (vbarpolicy == Qt::ScrollBarAlwaysOn - || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum())); - if (qAppPriv->SetGestureConfig && (needh || needv)) { - GESTURECONFIG gc[1]; - gc[0].dwID = GID_PAN; - gc[0].dwWant = GC_PAN; - gc[0].dwBlock = 0; - if (needv && singleFingerPanEnabled) - gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY; - if (needh && singleFingerPanEnabled) - gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY; - qAppPriv->SetGestureConfig(viewport->winId(), 0, 1, gc, sizeof(gc)); - } -#endif // Q_OS_WIN + singleFingerPanEnabled = on; + winSetupGestures(); } +#endif // Q_WS_WIN void QAbstractScrollAreaPrivate::layoutChildren() { @@ -1278,7 +1263,11 @@ void QAbstractScrollAreaPrivate::_q_vslide(int y) void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars() { layoutChildren(); - setupGestures(); +#ifdef Q_OS_WIN + // Need to re-subscribe to gestures as the content changes to make sure we + // enable/disable panning when needed. + winSetupGestures(); +#endif // Q_OS_WIN } QPoint QAbstractScrollAreaPrivate::contentsOffset() const @@ -1343,6 +1332,25 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport) Q_UNUSED(viewport); } +void QAbstractScrollAreaPrivate::_q_gestureTriggered() +{ + Q_Q(QAbstractScrollArea); + QPanGesture *g = qobject_cast<QPanGesture*>(q->sender()); + if (!g) + return; + QScrollBar *hBar = q->horizontalScrollBar(); + QScrollBar *vBar = q->verticalScrollBar(); + QSize delta = g->lastOffset(); + if (!delta.isNull()) { + if (QApplication::isRightToLeft()) + delta.rwidth() *= -1; + int newX = hBar->value() - delta.width(); + int newY = vBar->value() - delta.height(); + hbar->setValue(newX); + vbar->setValue(newY); + } +} + QT_END_NAMESPACE #include "moc_qabstractscrollarea.cpp" diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h index 3ec41d1..9178629 100644 --- a/src/gui/widgets/qabstractscrollarea.h +++ b/src/gui/widgets/qabstractscrollarea.h @@ -128,8 +128,10 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_hslide(int)) Q_PRIVATE_SLOT(d_func(), void _q_vslide(int)) Q_PRIVATE_SLOT(d_func(), void _q_showOrHideScrollBars()) + Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered()) friend class QStyleSheetStyle; + friend class QWidgetPrivate; }; #endif // QT_NO_SCROLLAREA diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h index f8ea843..a54ba1c 100644 --- a/src/gui/widgets/qabstractscrollarea_p.h +++ b/src/gui/widgets/qabstractscrollarea_p.h @@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_SCROLLAREA +class QPanGesture; class QScrollBar; class QAbstractScrollAreaScrollBarContainer; class Q_AUTOTEST_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate @@ -100,10 +101,12 @@ public: { return q_func()->viewportEvent(event); } QScopedPointer<QObject> viewportFilter; + virtual void _q_gestureTriggered(); + QPanGesture *panGesture; #ifdef Q_WS_WIN bool singleFingerPanEnabled; + void setSingleFingerPanEnabled(bool on = true); #endif - void setupGestures(); }; class QAbstractScrollAreaFilter : public QObject diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index ee29b55..cad6903 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -1545,7 +1545,7 @@ void QDockAreaLayoutInfo::apply(bool animate) QRect geo = w->geometry(); widgetAnimator.animate(w, r, animate); - if (!w->isHidden()) { + if (!w->isHidden() && w->window()->isVisible()) { QDockWidget *dw = qobject_cast<QDockWidget*>(w); if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) { dw->lower(); diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index 5810c81..e60f099 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -1390,7 +1390,7 @@ bool QDockWidget::event(QEvent *event) break; case QEvent::Show: d->toggleViewAction->setChecked(true); - emit visibilityChanged(true); + emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0); break; #endif case QEvent::ApplicationLayoutDirectionChange: diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 64832c8..f4a2348 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -257,6 +257,7 @@ void QLineControl::setSelection(int start, int length) m_cursor = m_selstart; } emit selectionChanged(); + emitCursorPositionChanged(); } void QLineControl::_q_clipboardChanged() @@ -1704,8 +1705,7 @@ void QLineControl::processKeyEvent(QKeyEvent* event) if (passwordEchoEditing()) updatePasswordEchoEditing(false); - // ### TODO this needs to be fixed. - // setEditFocus(false); + emit editFocusChange(false); } else if (!m_deleteAllTimer) { m_deleteAllTimer = startTimer(750); } diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 9cad857..ad4e4e4 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -343,6 +343,9 @@ Q_SIGNALS: void editingFinished(); void updateNeeded(const QRect &); +#ifdef QT_KEYPAD_NAVIGATION + void editFocusChange(bool); +#endif protected: virtual void timerEvent(QTimerEvent *event); @@ -638,7 +641,7 @@ inline void QLineControl::setCursorPosition(int pos) { if (pos < 0) pos = 0; - if (pos < m_text.length()) + if (pos <= m_text.length()) moveCursor(pos); } diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 8ab30fa..5b04616 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1693,12 +1693,10 @@ void QLineEdit::focusInEvent(QFocusEvent *e) d->clickCausedFocus = 1; } #ifdef QT_KEYPAD_NAVIGATION - if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)) + if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)){ #endif - { - int cft = QApplication::cursorFlashTime(); - d->control->setCursorBlinkPeriod(cft/2); - } + int cft = QApplication::cursorFlashTime(); + d->control->setCursorBlinkPeriod(cft/2); QStyleOptionFrameV2 opt; initStyleOption(&opt); if((!hasSelectedText() && d->control->preeditAreaText().isEmpty()) @@ -1709,7 +1707,8 @@ void QLineEdit::focusInEvent(QFocusEvent *e) qt_mac_secure_keyboard(true); #endif #ifdef QT_KEYPAD_NAVIGATION - d->control->setCancelText(d->control->text()); + d->control->setCancelText(d->control->text()); + } #endif #ifndef QT_NO_COMPLETER if (d->control->completer()) { diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index daac6a7..32ef6a4 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -273,6 +273,9 @@ private: #ifndef QT_NO_COMPLETER Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(QString)) #endif +#ifdef QT_KEYPAD_NAVIGATION + Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool)) +#endif }; #endif // QT_NO_LINEEDIT diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp index f0ec8ad..d907233 100644 --- a/src/gui/widgets/qlineedit_p.cpp +++ b/src/gui/widgets/qlineedit_p.cpp @@ -126,6 +126,14 @@ void QLineEditPrivate::_q_cursorPositionChanged(int from, int to) emit q->cursorPositionChanged(from, to); } +#ifdef QT_KEYPAD_NAVIGATION +void QLineEditPrivate::_q_editFocusChange(bool e) +{ + Q_Q(QLineEdit); + q->setEditFocus(e); +} +#endif + void QLineEditPrivate::init(const QString& txt) { Q_Q(QLineEdit); @@ -142,6 +150,10 @@ void QLineEditPrivate::init(const QString& txt) q, SIGNAL(returnPressed())); QObject::connect(control, SIGNAL(editingFinished()), q, SIGNAL(editingFinished())); +#ifdef QT_KEYPAD_NAVIGATION + QObject::connect(control, SIGNAL(editFocusChange(bool)), + q, SLOT(_q_editFocusChange(bool))); +#endif // for now, going completely overboard with updates. QObject::connect(control, SIGNAL(selectionChanged()), @@ -149,6 +161,9 @@ void QLineEditPrivate::init(const QString& txt) QObject::connect(control, SIGNAL(displayTextChanged(const QString &)), q, SLOT(update())); + + QObject::connect(control, SIGNAL(updateNeeded(const QRect &)), + q, SLOT(update())); control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter)); #ifndef QT_NO_CURSOR q->setCursor(Qt::IBeamCursor); diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h index b09c3f0..b21820c 100644 --- a/src/gui/widgets/qlineedit_p.h +++ b/src/gui/widgets/qlineedit_p.h @@ -126,6 +126,9 @@ public: void _q_deleteSelected(); void _q_textEdited(const QString &); void _q_cursorPositionChanged(int, int); +#ifdef QT_KEYPAD_NAVIGATION + void _q_editFocusChange(bool); +#endif #ifndef QT_NO_COMPLETER void _q_completionHighlighted(QString); diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 3936a67..55afa70 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1988,6 +1988,9 @@ void QMainWindowLayout::timerEvent(QTimerEvent *e) if (movingSeparatorOrigin == movingSeparatorPos) return; + //when moving the separator, we need to update the previous position + parentWidget()->update(layoutState.dockAreaLayout.separatorRegion()); + layoutState = savedState; layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin, movingSeparatorPos); diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 6465975..1ba6fdc 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -205,6 +205,8 @@ void QMenuPrivate::updateActionRects() const Q_Q(const QMenu); if (!itemsDirty) return; + + q->ensurePolished(); //let's reinitialize the buffer actionRects.resize(actions.count()); @@ -226,13 +228,17 @@ void QMenuPrivate::updateActionRects() const dh = popupGeometry(QApplication::desktop()->screenNumber(q)).height(), y = 0; QStyle *style = q->style(); - const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, 0, q), - vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, 0, q), - icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q); - const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); - - const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, 0, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); + QStyleOption opt; + opt.init(q); + const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q), + vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q), + icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q); + const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); + const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q); + + const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); + const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0; //for compatability now - will have to refactor this away.. tabWidth = 0; @@ -308,7 +314,7 @@ void QMenuPrivate::updateActionRects() const max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width())); //wrapping if (!scroll && - y+sz.height()+vmargin > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) { + y+sz.height()+vmargin > dh - (deskFw * 2)) { ncols++; y = vmargin; } @@ -323,7 +329,7 @@ void QMenuPrivate::updateActionRects() const //calculate position const int base_y = vmargin + fw + topmargin + (scroll ? scroll->scrollOffset : 0) + - (tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q) : 0); + tearoffHeight; int x = hmargin + fw + leftmargin; y = base_y; @@ -332,7 +338,7 @@ void QMenuPrivate::updateActionRects() const if (rect.isNull()) continue; if (!scroll && - y+rect.height() > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) { + y+rect.height() > dh - deskFw * 2) { x += max_column_width + hmargin; y = base_y; } @@ -1708,12 +1714,9 @@ QRect QMenu::actionGeometry(QAction *act) const QSize QMenu::sizeHint() const { Q_D(const QMenu); - ensurePolished(); d->updateActionRects(); QSize s; - QStyleOption opt(0); - opt.init(this); for (int i = 0; i < d->actionRects.count(); ++i) { const QRect &rect = d->actionRects.at(i); if (rect.isNull()) @@ -1726,15 +1729,11 @@ QSize QMenu::sizeHint() const // Note that the action rects calculated above already include // the top and left margins, so we only need to add margins for // the bottom and right. - if (const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this)) { - s.rwidth() += fw; - s.rheight() += fw; - } - - s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this); - s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this); - - s += QSize(d->rightmargin, d->bottommargin); + QStyleOption opt(0); + opt.init(this); + const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this); + s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this) + fw + d->rightmargin; + s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) + fw + d->bottommargin; return style()->sizeFromContents(QStyle::CT_Menu, &opt, s.expandedTo(QApplication::globalStrut()), this); diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index eaf03b3..a0a2f57 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -272,6 +272,9 @@ QRect QMenuBarPrivate::actionRect(QAction *act) const //makes sure the geometries are up-to-date const_cast<QMenuBarPrivate*>(this)->updateGeometries(); + if (index >= actionRects.count()) + return QRect(); // that can happen in case of native menubar + QRect ret = actionRects.at(index); return QStyle::visualRect(q->layoutDirection(), q->rect(), ret); } diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index e5c4d4f..57f43c6 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -119,7 +119,7 @@ QTextEditPrivate::QTextEditPrivate() showCursorOnInitialShow = true; inDrag = false; #ifdef Q_WS_WIN - singleFingerPanEnabled = true; + setSingleFingerPanEnabled(true); #endif } @@ -188,8 +188,6 @@ void QTextEditPrivate::init(const QString &html) #ifndef QT_NO_CURSOR viewport->setCursor(Qt::IBeamCursor); #endif - panGesture = new QPanGesture(q); - QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered())); } void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect) @@ -2631,26 +2629,6 @@ void QTextEdit::ensureCursorVisible() d->control->ensureCursorVisible(); } -void QTextEditPrivate::_q_gestureTriggered() -{ - Q_Q(QTextEdit); - QPanGesture *g = qobject_cast<QPanGesture*>(q->sender()); - if (!g) - return; - QScrollBar *hBar = q->horizontalScrollBar(); - QScrollBar *vBar = q->verticalScrollBar(); - QSize delta = g->lastOffset(); - if (!delta.isNull()) { - if (QApplication::isRightToLeft()) - delta.rwidth() *= -1; - int newX = hBar->value() - delta.width(); - int newY = vBar->value() - delta.height(); - hbar->setValue(newX); - vbar->setValue(newY); - } -} - - /*! \enum QTextEdit::KeyboardAction diff --git a/src/gui/widgets/qtextedit.h b/src/gui/widgets/qtextedit.h index 9e10e07..617822a 100644 --- a/src/gui/widgets/qtextedit.h +++ b/src/gui/widgets/qtextedit.h @@ -414,7 +414,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_currentCharFormatChanged(const QTextCharFormat &)) Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars()) Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &)) - Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered()) friend class QTextEditControl; friend class QTextDocument; friend class QTextControl; diff --git a/src/gui/widgets/qtextedit_p.h b/src/gui/widgets/qtextedit_p.h index cf87a86..85b6f7c 100644 --- a/src/gui/widgets/qtextedit_p.h +++ b/src/gui/widgets/qtextedit_p.h @@ -70,7 +70,6 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_TEXTEDIT class QMimeData; -class QPanGesture; class QTextEditPrivate : public QAbstractScrollAreaPrivate { Q_DECLARE_PUBLIC(QTextEdit) @@ -130,9 +129,6 @@ public: QString anchorToScrollToWhenVisible; - void _q_gestureTriggered(); - QPanGesture *panGesture; - #ifdef QT_KEYPAD_NAVIGATION QBasicTimer deleteAllTimer; #endif |