summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp18
-rw-r--r--src/gui/widgets/qabstractscrollarea.h3
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h4
-rw-r--r--src/gui/widgets/qabstractslider.cpp2
-rw-r--r--src/gui/widgets/qcocoatoolbardelegate_mac.mm6
-rw-r--r--src/gui/widgets/qcombobox.cpp12
-rw-r--r--src/gui/widgets/qcommandlinkbutton.cpp4
-rw-r--r--src/gui/widgets/qdatetimeedit.cpp1
-rw-r--r--src/gui/widgets/qdatetimeedit_p.h1
-rw-r--r--src/gui/widgets/qlinecontrol_p.h8
-rw-r--r--src/gui/widgets/qlineedit.cpp8
-rw-r--r--src/gui/widgets/qlineedit.h1
-rw-r--r--src/gui/widgets/qlineedit_p.cpp8
-rw-r--r--src/gui/widgets/qlineedit_p.h3
-rw-r--r--src/gui/widgets/qmainwindowlayout.cpp2
-rw-r--r--src/gui/widgets/qmenu.cpp10
-rw-r--r--src/gui/widgets/qmenu_mac.mm32
-rw-r--r--src/gui/widgets/qmenubar.cpp10
-rw-r--r--src/gui/widgets/qplaintextedit.cpp17
-rw-r--r--src/gui/widgets/qplaintextedit.h4
-rw-r--r--src/gui/widgets/qplaintextedit_p.h6
-rw-r--r--src/gui/widgets/qtabbar.cpp16
-rw-r--r--src/gui/widgets/qtoolbar.cpp10
-rw-r--r--src/gui/widgets/qtoolbarextension.cpp6
-rw-r--r--src/gui/widgets/qtoolbarlayout.cpp4
-rw-r--r--src/gui/widgets/qtoolbarlayout_p.h4
-rw-r--r--src/gui/widgets/qwidgetanimator.cpp2
27 files changed, 126 insertions, 76 deletions
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 533a56b..d1adfee 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -51,7 +51,10 @@
#include "qdebug.h"
#include "qboxlayout.h"
#include "qpainter.h"
+
+#ifdef Q_WS_WIN
#include "qstandardgestures.h"
+#endif
#include "qabstractscrollarea_p.h"
#include <qwidget.h>
@@ -159,9 +162,9 @@ 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), panGesture(0)
+ xoffset(0), yoffset(0), viewportFilter(0)
#ifdef Q_WS_WIN
- , singleFingerPanEnabled(false)
+ , panGesture(0), singleFingerPanEnabled(false)
#endif
{
}
@@ -295,8 +298,10 @@ void QAbstractScrollAreaPrivate::init()
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layoutChildren();
- panGesture = new QPanGesture(q);
+#ifdef Q_WS_WIN
+ panGesture = new QPanGesture(viewport);
QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
+#endif // Q_WS_WIN
}
#ifdef Q_WS_WIN
@@ -547,6 +552,9 @@ void QAbstractScrollArea::setViewport(QWidget *widget)
if (isVisible())
d->viewport->show();
QMetaObject::invokeMethod(this, "setupViewport", Q_ARG(QWidget *, widget));
+#ifdef Q_WS_WIN
+ d->panGesture->setGestureTarget(widget);
+#endif
delete oldViewport;
}
}
@@ -1339,6 +1347,7 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport)
Q_UNUSED(viewport);
}
+#ifdef Q_WS_WIN
void QAbstractScrollAreaPrivate::_q_gestureTriggered()
{
Q_Q(QAbstractScrollArea);
@@ -1347,7 +1356,7 @@ void QAbstractScrollAreaPrivate::_q_gestureTriggered()
return;
QScrollBar *hBar = q->horizontalScrollBar();
QScrollBar *vBar = q->verticalScrollBar();
- QSize delta = g->lastOffset();
+ QSizeF delta = g->lastOffset();
if (!delta.isNull()) {
if (QApplication::isRightToLeft())
delta.rwidth() *= -1;
@@ -1357,6 +1366,7 @@ void QAbstractScrollAreaPrivate::_q_gestureTriggered()
vbar->setValue(newY);
}
}
+#endif
QT_END_NAMESPACE
diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h
index 0a3e9c5..0625458 100644
--- a/src/gui/widgets/qabstractscrollarea.h
+++ b/src/gui/widgets/qabstractscrollarea.h
@@ -128,7 +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())
+
+#ifdef Q_WS_WIN
Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered())
+#endif
friend class QStyleSheetStyle;
friend class QWidgetPrivate;
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index 211b7a7..4362ce9 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -101,9 +101,9 @@ public:
{ return q_func()->viewportEvent(event); }
QScopedPointer<QObject> viewportFilter;
- virtual void _q_gestureTriggered();
- QPanGesture *panGesture;
#ifdef Q_WS_WIN
+ QPanGesture *panGesture;
+ virtual void _q_gestureTriggered();
bool singleFingerPanEnabled;
void setSingleFingerPanEnabled(bool on = true);
#endif
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp
index 58edfde..52538e0 100644
--- a/src/gui/widgets/qabstractslider.cpp
+++ b/src/gui/widgets/qabstractslider.cpp
@@ -687,9 +687,7 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
Q_D(QAbstractSlider);
e->ignore();
if (e->orientation() != d->orientation && !rect().contains(e->pos()))
- {
return;
- }
static qreal offset = 0;
static QAbstractSlider *offset_owner = 0;
if (offset_owner != this){
diff --git a/src/gui/widgets/qcocoatoolbardelegate_mac.mm b/src/gui/widgets/qcocoatoolbardelegate_mac.mm
index 3b58a4e..2ef0ead 100644
--- a/src/gui/widgets/qcocoatoolbardelegate_mac.mm
+++ b/src/gui/widgets/qcocoatoolbardelegate_mac.mm
@@ -100,7 +100,8 @@ QT_FORWARD_DECLARE_CLASS(QCFString);
{
Q_UNUSED(flag);
Q_UNUSED(nstoolbar);
- QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(qt_mac_NSStringToQString(itemIdentifier));
+ QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(
+ QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(itemIdentifier));
NSToolbarItem *item = nil;
if (tb) {
item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
@@ -112,7 +113,8 @@ QT_FORWARD_DECLARE_CLASS(QCFString);
- (void)toolbarWillAddItem:(NSNotification *)notification
{
NSToolbarItem *item = [[notification userInfo] valueForKey:@"item"];
- QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(qt_mac_NSStringToQString([item itemIdentifier]));
+ QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(
+ QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)([item itemIdentifier]));
if (!tb)
return; // I can't really do anything about this.
[item retain];
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index bf0d52b..b1e9c79 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -2449,7 +2449,16 @@ void QComboBox::showPopup()
&& !style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) && !window()->testAttribute(Qt::WA_DontShowOnScreen))
qScrollEffect(container, scrollDown ? QEffects::DownScroll : QEffects::UpScroll, 150);
#endif
+
+// Don't disable updates on Mac OS X. Windows are displayed immediately on this platform,
+// which means that the window will be visible before the call to container->show() returns.
+// If updates are disabled at this point we'll miss our chance at painting the popup
+// menu before it's shown, causing flicker since the window then displays the standard gray
+// background.
+#ifndef Q_WS_MAC
container->setUpdatesEnabled(false);
+#endif
+
container->raise();
container->show();
container->updateScrollers();
@@ -2460,7 +2469,10 @@ void QComboBox::showPopup()
? QAbstractItemView::PositionAtCenter
: QAbstractItemView::EnsureVisible);
+#ifndef Q_WS_MAC
container->setUpdatesEnabled(updatesEnabled);
+#endif
+
container->update();
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled())
diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp
index 206221f..fd69f55 100644
--- a/src/gui/widgets/qcommandlinkbutton.cpp
+++ b/src/gui/widgets/qcommandlinkbutton.cpp
@@ -205,7 +205,9 @@ void QCommandLinkButtonPrivate::init()
q->setSizePolicy(policy);
q->setIconSize(QSize(20, 20));
- q->setIcon(q->style()->standardIcon(QStyle::SP_CommandLink));
+ QStyleOptionButton opt;
+ q->initStyleOption(&opt);
+ q->setIcon(q->style()->standardIcon(QStyle::SP_CommandLink, &opt));
}
// Calculates the height of the description text based on widget width
diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp
index 5a9c7e1..d1ebdf4 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/gui/widgets/qdatetimeedit.cpp
@@ -1643,7 +1643,6 @@ QDateTimeEditPrivate::QDateTimeEditPrivate()
cachedDay = -1;
currentSectionIndex = FirstSectionIndex;
- layoutDirection = QApplication::layoutDirection();
first.type = FirstSection;
last.type = LastSection;
none.type = NoSection;
diff --git a/src/gui/widgets/qdatetimeedit_p.h b/src/gui/widgets/qdatetimeedit_p.h
index 7b29e51..33c09c0 100644
--- a/src/gui/widgets/qdatetimeedit_p.h
+++ b/src/gui/widgets/qdatetimeedit_p.h
@@ -132,7 +132,6 @@ public:
mutable bool cacheGuard;
QString defaultDateFormat, defaultTimeFormat, defaultDateTimeFormat, unreversedFormat;
- Qt::LayoutDirection layoutDirection;
mutable QVariant conflictGuard;
bool hasHadFocus, formatExplicitlySet, calendarPopup;
QStyle::StateFlag arrowState;
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index 721d990..0db6279 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -78,10 +78,10 @@ class Q_GUI_EXPORT QLineControl : public QObject
public:
QLineControl(const QString &txt = QString())
- : m_cursor(0), m_preeditCursor(0), m_layoutDirection(Qt::LeftToRight),
+ : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LeftToRight),
m_hideCursor(false), m_separator(0), m_readOnly(0),
m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0),
- m_validInput(1), m_blinkPeriod(0), m_blinkTimer(0), m_deleteAllTimer(0),
+ m_validInput(1), m_blinkStatus(0), m_blinkPeriod(0), m_blinkTimer(0), m_deleteAllTimer(0),
m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1),
m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0),
m_selstart(0), m_selend(0), m_passwordEchoEditing(false)
@@ -262,10 +262,10 @@ private:
uint m_textDirty : 1;
uint m_selDirty : 1;
uint m_validInput : 1;
+ uint m_blinkStatus : 1;
int m_blinkPeriod; // 0 for non-blinking cursor
int m_blinkTimer;
int m_deleteAllTimer;
- int m_blinkStatus;
int m_ascent;
int m_maxLength;
int m_lastCursorPos;
@@ -349,7 +349,7 @@ Q_SIGNALS:
protected:
virtual void timerEvent(QTimerEvent *event);
-private slots:
+private Q_SLOTS:
void _q_clipboardChanged();
void _q_deleteSelected();
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 6b73e21..059aaf1 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1395,8 +1395,7 @@ bool QLineEdit::event(QEvent * e)
if (e->type() == QEvent::EnterEditFocus) {
end(false);
d->setCursorVisible(true);
- int cft = QApplication::cursorFlashTime();
- d->control->setCursorBlinkPeriod(cft/2);
+ d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
} else if (e->type() == QEvent::LeaveEditFocus) {
d->setCursorVisible(false);
d->control->setCursorBlinkPeriod(0);
@@ -1691,8 +1690,7 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
#ifdef QT_KEYPAD_NAVIGATION
if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)){
#endif
- int cft = QApplication::cursorFlashTime();
- d->control->setCursorBlinkPeriod(cft/2);
+ d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
QStyleOptionFrameV2 opt;
initStyleOption(&opt);
if((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
@@ -2004,7 +2002,7 @@ QMenu *QLineEdit::createStandardContextMenu()
action = popup->addAction(QLineEdit::tr("Delete"));
action->setEnabled(!d->control->isReadOnly() && !d->control->text().isEmpty() && d->control->hasSelectedText());
- connect(action, SIGNAL(triggered()), SLOT(_q_deleteSelected()));
+ connect(action, SIGNAL(triggered()), d->control, SLOT(_q_deleteSelected()));
popup->addSeparator();
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
index 03d4376..cd37ad0 100644
--- a/src/gui/widgets/qlineedit.h
+++ b/src/gui/widgets/qlineedit.h
@@ -267,7 +267,6 @@ private:
Q_DISABLE_COPY(QLineEdit)
Q_DECLARE_PRIVATE(QLineEdit)
Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate())
- Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected())
Q_PRIVATE_SLOT(d_func(), void _q_textEdited(const QString &))
Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged(int, int))
#ifndef QT_NO_COMPLETER
diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp
index cec34da..4218630 100644
--- a/src/gui/widgets/qlineedit_p.cpp
+++ b/src/gui/widgets/qlineedit_p.cpp
@@ -93,10 +93,6 @@ void QLineEditPrivate::_q_completionHighlighted(QString newText)
#endif // QT_NO_COMPLETER
-void QLineEditPrivate::_q_clipboardChanged()
-{
-}
-
void QLineEditPrivate::_q_handleWindowActivate()
{
Q_Q(QLineEdit);
@@ -104,10 +100,6 @@ void QLineEditPrivate::_q_handleWindowActivate()
control->deselect();
}
-void QLineEditPrivate::_q_deleteSelected()
-{
-}
-
void QLineEditPrivate::_q_textEdited(const QString &text)
{
Q_Q(QLineEdit);
diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h
index 3ab10fc..260bc19 100644
--- a/src/gui/widgets/qlineedit_p.h
+++ b/src/gui/widgets/qlineedit_p.h
@@ -84,6 +84,7 @@ public:
~QLineEditPrivate()
{
+ delete control;
}
QLineControl *control;
@@ -121,9 +122,7 @@ public:
QRect adjustedContentsRect() const;
- void _q_clipboardChanged();
void _q_handleWindowActivate();
- void _q_deleteSelected();
void _q_textEdited(const QString &);
void _q_cursorPositionChanged(int, int);
#ifdef QT_KEYPAD_NAVIGATION
diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp
index 529a225..0ea9b56 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/gui/widgets/qmainwindowlayout.cpp
@@ -1463,7 +1463,7 @@ void QMainWindowLayout::setGeometry(const QRect &_r)
QSize(r.width(), statusbar->heightForWidth(r.width()))
.expandedTo(statusbar->minimumSize()));
sbr.moveBottom(r.bottom());
- QRect vr = QStyle::visualRect(QApplication::layoutDirection(), _r, sbr);
+ QRect vr = QStyle::visualRect(parentWidget()->layoutDirection(), _r, sbr);
statusbar->setGeometry(vr);
r.setBottom(sbr.top() - 1);
}
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 69ccae5..4734d22 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -368,7 +368,9 @@ QRect QMenuPrivate::actionRect(QAction *act) const
return actionRects.at(index);
}
+#if defined(Q_WS_MAC)
static const qreal MenuFadeTimeInSec = 0.150;
+#endif
void QMenuPrivate::hideUpToMenuBar()
{
@@ -1832,7 +1834,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if (adjustToDesktop) {
//handle popup falling "off screen"
- if (QApplication::layoutDirection() == Qt::RightToLeft) {
+ if (isRightToLeft()) {
if(snapToMouse) //position flowing left from the mouse
pos.setX(mouse.x()-size.width());
@@ -1870,9 +1872,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
setGeometry(QRect(pos, size));
#ifndef QT_NO_EFFECTS
- int hGuess = QApplication::layoutDirection() == Qt::RightToLeft ? QEffects::LeftScroll : QEffects::RightScroll;
+ int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
int vGuess = QEffects::DownScroll;
- if (QApplication::layoutDirection() == Qt::RightToLeft) {
+ if (isRightToLeft()) {
if ((snapToMouse && (pos.x() + size.width()/2 > mouse.x())) ||
(qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 > d->causedPopup.widget->x()))
hGuess = QEffects::RightScroll;
@@ -2779,6 +2781,8 @@ void QMenu::leaveEvent(QEvent *)
d->sloppyAction = 0;
if (!d->sloppyRegion.isEmpty())
d->sloppyRegion = QRegion();
+ if (!d->activeMenu && d->currentAction)
+ setActiveAction(0);
}
/*!
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index 8089473..8e28abe 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -607,6 +607,13 @@ static inline void syncNSMenuItemVisiblity(NSMenuItem *menuItem, bool actionVisi
[menuItem setHidden:!actionVisibility];
}
+static inline void syncNSMenuItemEnabled(NSMenuItem *menuItem, bool enabled)
+{
+ [menuItem setEnabled:NO];
+ [menuItem setEnabled:YES];
+ [menuItem setEnabled:enabled];
+}
+
static inline void syncMenuBarItemsVisiblity(const QMenuBarPrivate::QMacMenuBarPrivate *mac_menubar)
{
const QList<QMacMenuAction *> &menubarActions = mac_menubar->actionItems;
@@ -659,12 +666,12 @@ void qt_mac_set_modal_state_helper_recursive(OSMenuRef menu, OSMenuRef merge, bo
// The item should follow what the QAction has.
if ([item tag]) {
QAction *action = reinterpret_cast<QAction *>([item tag]);
- [item setEnabled:action->isEnabled()];
+ syncNSMenuItemEnabled(item, action->isEnabled());
} else {
- [item setEnabled:YES];
+ syncNSMenuItemEnabled(item, YES);
}
} else {
- [item setEnabled:NO];
+ syncNSMenuItemEnabled(item, NO);
}
}
}
@@ -728,6 +735,9 @@ bool qt_mac_menubar_is_open()
void qt_mac_clear_menubar()
{
+ if (QApplication::testAttribute(Qt::AA_MacPluginApplication))
+ return;
+
#ifndef QT_MAC_USE_COCOA
MenuRef clear_menu = 0;
if (CreateNewMenu(0, 0, &clear_menu) == noErr) {
@@ -1361,7 +1371,7 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action)
if (!action->action->icon().isNull()
&& action->action->isIconVisibleInMenu()) {
data.iconType = kMenuIconRefType;
- data.iconHandle = (Handle)qt_mac_create_iconref(action->action->icon().pixmap(22, QIcon::Normal));
+ data.iconHandle = (Handle)qt_mac_create_iconref(action->action->icon().pixmap(16, QIcon::Normal));
} else {
data.iconType = kMenuNoIcon;
}
@@ -1400,7 +1410,7 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action)
// Cocoa icon
NSImage *nsimage = 0;
if (!action->action->icon().isNull() && action->action->isIconVisibleInMenu()) {
- nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(action->action->icon().pixmap(22, QIcon::Normal)));
+ nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(action->action->icon().pixmap(16, QIcon::Normal)));
}
[item setImage:nsimage];
[nsimage release];
@@ -1754,14 +1764,16 @@ void
QMenuBarPrivate::macCreateMenuBar(QWidget *parent)
{
Q_Q(QMenuBar);
- static int checkEnv = -1;
+ static int dontUseNativeMenuBar = -1;
// We call the isNativeMenuBar function here
- // becasue that will make sure that local overrides
+ // because that will make sure that local overrides
// are dealt with correctly.
bool qt_mac_no_native_menubar = !q->isNativeMenuBar();
- if (qt_mac_no_native_menubar == false && checkEnv < 0) {
- checkEnv = !qgetenv("QT_MAC_NO_NATIVE_MENUBAR").isEmpty();
- QApplication::instance()->setAttribute(Qt::AA_DontUseNativeMenuBar, checkEnv);
+ if (qt_mac_no_native_menubar == false && dontUseNativeMenuBar < 0) {
+ bool isPlugin = QApplication::testAttribute(Qt::AA_MacPluginApplication);
+ bool environmentSaysNo = !qgetenv("QT_MAC_NO_NATIVE_MENUBAR").isEmpty();
+ dontUseNativeMenuBar = isPlugin || environmentSaysNo;
+ QApplication::instance()->setAttribute(Qt::AA_DontUseNativeMenuBar, dontUseNativeMenuBar);
qt_mac_no_native_menubar = !q->isNativeMenuBar();
}
if (!qt_mac_no_native_menubar) {
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index 82b3769..6633f2a 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -132,7 +132,7 @@ QRect QMenuBarPrivate::menuRect(bool extVisible) const
result.adjust(hmargin, 0, -hmargin, 0);
if (extVisible) {
- if (q->layoutDirection() == Qt::RightToLeft)
+ if (q->isRightToLeft())
result.setLeft(result.left() + extension->sizeHint().width());
else
result.setWidth(result.width() - extension->sizeHint().width());
@@ -140,7 +140,7 @@ QRect QMenuBarPrivate::menuRect(bool extVisible) const
if (leftWidget && leftWidget->isVisible()) {
QSize sz = leftWidget->sizeHint();
- if (q->layoutDirection() == Qt::RightToLeft)
+ if (q->isRightToLeft())
result.setRight(result.right() - sz.width());
else
result.setLeft(result.left() + sz.width());
@@ -148,7 +148,7 @@ QRect QMenuBarPrivate::menuRect(bool extVisible) const
if (rightWidget && rightWidget->isVisible()) {
QSize sz = rightWidget->sizeHint();
- if (q->layoutDirection() == Qt::RightToLeft)
+ if (q->isRightToLeft())
result.setLeft(result.left() + sz.width());
else
result.setRight(result.right() - sz.width());
@@ -245,7 +245,7 @@ void QMenuBarPrivate::updateGeometries()
pop->addActions(hiddenActions);
int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q);
- int x = q->layoutDirection() == Qt::RightToLeft
+ int x = q->isRightToLeft()
? menuRect.left() - extension->sizeHint().width() + 1
: menuRect.right();
extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2);
@@ -1695,6 +1695,7 @@ QSize QMenuBar::sizeHint() const
ensurePolished();
QSize ret(0, 0);
+ const_cast<QMenuBarPrivate*>(d)->updateGeometries();
const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);
const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
@@ -1750,6 +1751,7 @@ int QMenuBar::heightForWidth(int) const
const bool as_gui_menubar = true;
#endif
+ const_cast<QMenuBarPrivate*>(d)->updateGeometries();
int height = 0;
const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 20de404..6ac521b 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -66,7 +66,9 @@
#include <qtexttable.h>
#include <qvariant.h>
+#ifdef Q_WS_WIN
#include <qstandardgestures.h>
+#endif
#include <qinputcontext.h>
@@ -377,7 +379,7 @@ void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block)
tl->beginLayout();
qreal availableWidth = d->width;
if (availableWidth <= 0) {
- availableWidth = INT_MAX; // similar to text edit with pageSize.width == 0
+ availableWidth = qreal(INT_MAX); // similar to text edit with pageSize.width == 0
}
availableWidth -= 2*margin + extraMargin;
while (1) {
@@ -573,7 +575,8 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const {
if (!block.isValid())
return QRectF();
QRectF r = documentLayout->blockBoundingRect(currentBlock);
- while (currentBlockNumber < blockNumber && offset.y() <= 2* textEdit->viewport()->height()) {
+ int maxVerticalOffset = r.height();
+ while (currentBlockNumber < blockNumber && offset.y() - maxVerticalOffset <= 2* textEdit->viewport()->height()) {
offset.ry() += r.height();
currentBlock = currentBlock.next();
++currentBlockNumber;
@@ -583,7 +586,7 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const {
}
r = documentLayout->blockBoundingRect(currentBlock);
}
- while (currentBlockNumber > blockNumber && offset.y() >= -textEdit->viewport()->height()) {
+ while (currentBlockNumber > blockNumber && offset.y() + maxVerticalOffset >= -textEdit->viewport()->height()) {
currentBlock = currentBlock.previous();
--currentBlockNumber;
while (!currentBlock.isVisible()) {
@@ -791,8 +794,10 @@ void QPlainTextEditPrivate::init(const QString &txt)
viewport->setCursor(Qt::IBeamCursor);
#endif
originalOffsetY = 0;
+#ifdef Q_WS_WIN
panGesture = new QPanGesture(q);
QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
+#endif
}
void QPlainTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
@@ -2917,6 +2922,8 @@ QAbstractTextDocumentLayout::PaintContext QPlainTextEdit::getPaintContext() cons
(\a available is true) or unavailable (\a available is false).
*/
+#ifdef Q_WS_WIN
+
void QPlainTextEditPrivate::_q_gestureTriggered()
{
Q_Q(QPlainTextEdit);
@@ -2927,7 +2934,7 @@ void QPlainTextEditPrivate::_q_gestureTriggered()
QScrollBar *vBar = q->verticalScrollBar();
if (g->state() == Qt::GestureStarted)
originalOffsetY = vBar->value();
- QSize totalOffset = g->totalOffset();
+ QSizeF totalOffset = g->totalOffset();
if (!totalOffset.isNull()) {
if (QApplication::isRightToLeft())
totalOffset.rwidth() *= -1;
@@ -2941,6 +2948,8 @@ void QPlainTextEditPrivate::_q_gestureTriggered()
}
}
+#endif
+
QT_END_NAMESPACE
#include "moc_qplaintextedit.cpp"
diff --git a/src/gui/widgets/qplaintextedit.h b/src/gui/widgets/qplaintextedit.h
index c9652ae..5ec3ed8 100644
--- a/src/gui/widgets/qplaintextedit.h
+++ b/src/gui/widgets/qplaintextedit.h
@@ -269,7 +269,11 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
Q_PRIVATE_SLOT(d_func(), void _q_verticalScrollbarActionTriggered(int))
Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged())
+
+#ifdef Q_WS_WIN
Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered())
+#endif
+
friend class QPlainTextEditControl;
};
diff --git a/src/gui/widgets/qplaintextedit_p.h b/src/gui/widgets/qplaintextedit_p.h
index 608f3cf..e93302c 100644
--- a/src/gui/widgets/qplaintextedit_p.h
+++ b/src/gui/widgets/qplaintextedit_p.h
@@ -176,12 +176,14 @@ public:
#endif
void _q_cursorPositionChanged();
-
void _q_modificationChanged(bool);
- void _q_gestureTriggered();
int originalOffsetY;
+
+#ifdef Q_WS_WIN
+ void _q_gestureTriggered();
QPanGesture *panGesture;
+#endif
};
QT_END_NAMESPACE
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 5166390..531c429 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -1293,6 +1293,7 @@ QSize QTabBarPrivate::minimumTabSizeHint(int index)
*/
QSize QTabBar::tabSizeHint(int index) const
{
+ //Note: this must match with the computations in QCommonStylePrivate::tabLayout
Q_D(const QTabBar);
if (const QTabBarPrivate::Tab *tab = d->at(index)) {
QStyleOptionTabV3 opt;
@@ -1309,18 +1310,18 @@ QSize QTabBar::tabSizeHint(int index) const
int widgetWidth = 0;
int widgetHeight = 0;
int padding = 0;
- if (opt.leftButtonSize.isValid()) {
- padding += 6 + 2;
+ if (!opt.leftButtonSize.isEmpty()) {
+ padding += 4;
widgetWidth += opt.leftButtonSize.width();
widgetHeight += opt.leftButtonSize.height();
}
- if (opt.rightButtonSize.isValid()) {
- padding += 6 + 2;
+ if (!opt.rightButtonSize.isEmpty()) {
+ padding += 4;
widgetWidth += opt.rightButtonSize.width();
widgetHeight += opt.rightButtonSize.height();
}
- if (opt.iconSize.isValid())
- padding += 2;
+ if (!opt.icon.isNull())
+ padding += 4;
QSize csz;
if (verticalTabs(d->shape)) {
@@ -1836,7 +1837,8 @@ void QTabBarPrivate::moveTabFinished(int index)
}
#endif //QT_NO_ANIMATION
if (allAnimationsFinished && cleanup) {
- movingTab->setVisible(false); // We might not get a mouse release
+ if(movingTab)
+ movingTab->setVisible(false); // We might not get a mouse release
for (int i = 0; i < tabList.count(); ++i) {
tabList[i].dragOffset = 0;
}
diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp
index ef0847b..89e6d7a 100644
--- a/src/gui/widgets/qtoolbar.cpp
+++ b/src/gui/widgets/qtoolbar.cpp
@@ -205,7 +205,7 @@ void QToolBarPrivate::initDrag(const QPoint &pos)
state->moving = false;
state->widgetItem = 0;
- if (q->layoutDirection() == Qt::RightToLeft)
+ if (q->isRightToLeft())
state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y());
}
@@ -359,7 +359,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)
QPoint pos = event->globalPos();
// if we are right-to-left, we move so as to keep the right edge the same distance
// from the mouse
- if (q->layoutDirection() == Qt::LeftToRight)
+ if (q->isLeftToRight())
pos -= state->pressPos;
else
pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y());
@@ -369,14 +369,14 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)
} else if (state->moving) {
const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL
- const QPoint globalPressPos = q->mapToGlobal(q->layoutDirection() == Qt::RightToLeft ? rtl : state->pressPos);
+ const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos);
int pos = 0;
QPoint delta = event->globalPos() - globalPressPos;
if (orientation == Qt::Vertical) {
pos = q->y() + delta.y();
} else {
- if (q->layoutDirection() == Qt::RightToLeft) {
+ if (q->isRightToLeft()) {
pos = win->width() - q->width() - q->x() - delta.x();
} else {
pos = q->x() + delta.x();
@@ -391,7 +391,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)
void QToolBarPrivate::unplug(const QRect &_r)
{
Q_Q(QToolBar);
-
+ layout->setExpanded(false, false);
QRect r = _r;
r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));
setWindowState(true, true, r);
diff --git a/src/gui/widgets/qtoolbarextension.cpp b/src/gui/widgets/qtoolbarextension.cpp
index 1f1186c..6a70326 100644
--- a/src/gui/widgets/qtoolbarextension.cpp
+++ b/src/gui/widgets/qtoolbarextension.cpp
@@ -61,10 +61,12 @@ QToolBarExtension::QToolBarExtension(QWidget *parent)
void QToolBarExtension::setOrientation(Qt::Orientation o)
{
+ QStyleOption opt;
+ opt.init(this);
if (o == Qt::Horizontal) {
- setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton));
+ setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, &opt));
} else {
- setIcon(style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton));
+ setIcon(style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton, &opt));
}
}
diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp
index d3c5b4b..1f2ca60 100644
--- a/src/gui/widgets/qtoolbarlayout.cpp
+++ b/src/gui/widgets/qtoolbarlayout.cpp
@@ -642,7 +642,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const
return result;
}
-void QToolBarLayout::setExpanded(bool exp)
+void QToolBarLayout::setExpanded(bool exp, bool animated)
{
if (exp == expanded)
return;
@@ -665,7 +665,7 @@ void QToolBarLayout::setExpanded(bool exp)
layoutActions(rect.size());
}
}
- layout->layoutState.toolBarAreaLayout.apply(true);
+ layout->layoutState.toolBarAreaLayout.apply(animated);
}
}
diff --git a/src/gui/widgets/qtoolbarlayout_p.h b/src/gui/widgets/qtoolbarlayout_p.h
index fe81d2f..bb40e215 100644
--- a/src/gui/widgets/qtoolbarlayout_p.h
+++ b/src/gui/widgets/qtoolbarlayout_p.h
@@ -111,8 +111,8 @@ public:
void updateMarginAndSpacing();
bool hasExpandFlag() const;
-public slots:
- void setExpanded(bool b);
+public Q_SLOTS:
+ void setExpanded(bool b, bool animated = true);
private:
QList<QToolBarItem*> items;
diff --git a/src/gui/widgets/qwidgetanimator.cpp b/src/gui/widgets/qwidgetanimator.cpp
index beb6be2..972e07b 100644
--- a/src/gui/widgets/qwidgetanimator.cpp
+++ b/src/gui/widgets/qwidgetanimator.cpp
@@ -93,7 +93,7 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo
if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry)
return;
- QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry");
+ QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget);
anim->setDuration(animate ? 200 : 0);
anim->setEasingCurve(QEasingCurve::InOutQuad);
anim->setEndValue(final_geometry);