diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-29 03:54:47 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-29 03:54:47 (GMT) |
commit | bfbded95056d43a65b2c9ef1fa90bfd40adc6472 (patch) | |
tree | c20ababb5a2e124e9c7ac796ace1d52380470bd3 /src/gui | |
parent | e8bc4cebe9963a8a4534a5febbd606a6e4d6a332 (diff) | |
parent | f425c08d4f2e7f061a0ee8e4a1eee2b17fa64962 (diff) | |
download | Qt-bfbded95056d43a65b2c9ef1fa90bfd40adc6472.zip Qt-bfbded95056d43a65b2c9ef1fa90bfd40adc6472.tar.gz Qt-bfbded95056d43a65b2c9ef1fa90bfd40adc6472.tar.bz2 |
Merge branch '4.6' of ../qt into kinetic-declarativeui
Conflicts:
src/script/api/qscriptengine.cpp
src/script/api/qscriptprogram.cpp
src/script/api/qscriptprogram.h
src/script/api/qscriptprogram_p.h
tests/auto/qscriptengine/tst_qscriptengine.cpp
tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
tools/qdoc3/test/qt-inc.qdocconf
Diffstat (limited to 'src/gui')
26 files changed, 159 insertions, 125 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index e22486b..f8c627d 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1228,7 +1228,8 @@ void QGraphicsItemCache::purge() } /*! - Constructs a QGraphicsItem, passing \a item to QGraphicsItem's constructor. It does not modify \fn QObject::parent(). + Constructs a QGraphicsItem with the given \a parent item. + It does not modify the parent object returned by QObject::parent(). If \a parent is 0, you can add the item to a scene by calling QGraphicsScene::addItem(). The item will then become a top-level item. @@ -7293,6 +7294,21 @@ static void qt_graphicsItem_highlightSelected( The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms. It maps many of QGraphicsItem's basic setters and getters to properties and adds notification signals for many of them. + + \section1 Parents and Children + + Each graphics object can be constructed with a parent item. This ensures that the + item will be destroyed when its parent item is destroyed. Although QGraphicsObject + inherits from both QObject and QGraphicsItem, you should use the functions provided + by QGraphicsItem, \e not QObject, to manage the relationships between parent and + child items. + + The relationships between items can be explored using the parentItem() and childItems() + functions. In the hierarchy of items in a scene, the parentObject() and parentWidget() + functions are the equivalent of the QWidget::parent() and QWidget::parentWidget() + functions for QWidget subclasses. + + \sa QGraphicsWidget */ /*! @@ -7328,7 +7344,10 @@ void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureContext co /*! \property QGraphicsObject::parent - \brief the parent of the item. It is independent from \fn QObject::parent. + \brief the parent of the item + + \note The item's parent is set independently of the parent object returned + by QObject::parent(). \sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject() */ diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp index 7ff7c9b..5684f0e 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.cpp +++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp @@ -59,7 +59,7 @@ You can add widgets, layouts, stretches (addStretch(), insertStretch() or setStretchFactor()), and spacings (setItemSpacing()) to a linear - layout. The layout takes ownership of the items. In some cases when the layout + layout. The layout takes ownership of the items. In some cases when the layout item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation of QGraphicsLayoutItem::setOwnedByLayout() how to handle @@ -208,7 +208,7 @@ QGraphicsLinearLayout::~QGraphicsLinearLayout() for (int i = count() - 1; i >= 0; --i) { QGraphicsLayoutItem *item = itemAt(i); // The following lines can be removed, but this removes the item - // from the layout more efficiently than the implementation of + // from the layout more efficiently than the implementation of // ~QGraphicsLayoutItem. removeAt(i); if (item) { @@ -542,18 +542,18 @@ void QGraphicsLinearLayout::invalidate() QGraphicsLayout::invalidate(); } -#ifdef QT_DEBUG void QGraphicsLinearLayout::dump(int indent) const { +#ifdef QT_DEBUG if (qt_graphicsLayoutDebug()) { Q_D(const QGraphicsLinearLayout); qDebug("%*s%s layout", indent, "", d->orientation == Qt::Horizontal ? "Horizontal" : "Vertical"); d->engine.dump(indent + 1); } -} #endif +} QT_END_NAMESPACE - + #endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicslinearlayout.h b/src/gui/graphicsview/qgraphicslinearlayout.h index 742392e..15fe81a 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.h +++ b/src/gui/graphicsview/qgraphicslinearlayout.h @@ -97,9 +97,7 @@ public: Q5SizePolicy::ControlTypes controlTypes(LayoutSide side) const; #endif -#ifdef QT_DEBUG void dump(int indent = 0) const; -#endif protected: #if 0 diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index 93dc196..e2a3f08 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -69,6 +69,9 @@ objects are applied to a QGraphicsItem, all of the transformations are computed in true 3D space, with the projection back to 2D only occurring after the last QGraphicsTransform is applied. + The exception to this is QGraphicsRotation, which projects back to + 2D after each rotation to preserve the perspective effect around + the X and Y axes. If you want to create your own configurable transformation, you can create a subclass of QGraphicsTransform (or any or the existing subclasses), and diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index a3b7516..45ff5f4 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -860,6 +860,9 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) { + if (len == 0 || buf == 0) + return false; + return data->fromData(buf, len, format, flags); } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 7c38d4b..85b055e 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -940,12 +940,8 @@ void QApplicationPrivate::initialize() graphics_system = QGraphicsSystemFactory::create(graphics_system_name); #endif #ifndef QT_NO_WHEELEVENT -#ifdef Q_OS_MAC - QApplicationPrivate::wheel_scroll_lines = 1; -#else QApplicationPrivate::wheel_scroll_lines = 3; #endif -#endif initializeMultitouch(); } diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 771cddc..84e0d50 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -1697,15 +1697,14 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event // (actually two events; one for horizontal and one for vertical). // As a results of this, and to make sure we dont't receive duplicate events, // we try to detect when this happend by checking the 'compatibilityEvent'. - const int scrollFactor = 4 * 8; SInt32 mdelt = 0; GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0, sizeof(mdelt), 0, &mdelt); - wheel_deltaX = mdelt * scrollFactor; + wheel_deltaX = mdelt; mdelt = 0; GetEventParameter(event, kEventParamMouseWheelSmoothVerticalDelta, typeSInt32, 0, sizeof(mdelt), 0, &mdelt); - wheel_deltaY = mdelt * scrollFactor; + wheel_deltaY = mdelt; GetEventParameter(event, kEventParamEventRef, typeEventRef, 0, sizeof(compatibilityEvent), 0, &compatibilityEvent); } else if (ekind == kEventMouseWheelMoved) { @@ -1718,31 +1717,11 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, 0, sizeof(axis), 0, &axis); - // The 'new' event has acceleration applied by the OS, while the old (on - // Carbon only), has not. So we introduce acceleration here to be consistent. - // The acceleration is trying to respect both pixel based and line scrolling, - // which turns out to be rather difficult. - int linesToScroll = mdelt > 0 ? 1 : -1; - static QTime t; - int elapsed = t.elapsed(); - t.restart(); - if (elapsed < 20) - linesToScroll *= 120; - else if (elapsed < 30) - linesToScroll *= 60; - else if (elapsed < 50) - linesToScroll *= 30; - else if (elapsed < 100) - linesToScroll *= 6; - else if (elapsed < 200) - linesToScroll *= 3; - else if (elapsed < 300) - linesToScroll *= 2; - + // Remove acceleration, and use either -120 or 120 as delta: if (axis == kEventMouseWheelAxisX) - wheel_deltaX = linesToScroll * 120; + wheel_deltaX = qBound(-120, int(mdelt * 10000), 120); else - wheel_deltaY = linesToScroll * 120; + wheel_deltaY = qBound(-120, int(mdelt * 10000), 120); } } @@ -2695,11 +2674,7 @@ int QApplication::keyboardInputInterval() void QApplication::setWheelScrollLines(int n) { - Q_UNUSED(n); - // On Mac, acceleration is handled by the OS. Multiplying wheel scroll - // deltas with n will not be as cross platform as one might think! So - // we choose to go native in this case (and let wheel_scroll_lines == 1). - // QApplicationPrivate::wheel_scroll_lines = n; + QApplicationPrivate::wheel_scroll_lines = n; } int QApplication::wheelScrollLines() diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 689429e..30bf99a 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1030,6 +1030,14 @@ QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int void qt_init(QApplicationPrivate * /* priv */, int) { if (!CCoeEnv::Static()) { + // The S60 framework creates a new trap handler which will render any existing traps + // invalid as long as it is active. This means that all code in main() that occurs after + // the QApplication construction needs to be surrounded by a new trap, despite having + // an outer one already. To avoid this, we save the original trap handler here, and set + // it back after the S60 framework is constructed. Then we restore it right before the S60 + // framework destruction. + TTrapHandler *origTrapHandler = User::TrapHandler(); + // The S60 framework has not been initalized. We need to do it. TApaApplicationFactory factory(S60->s60ApplicationFactory ? S60->s60ApplicationFactory : newS60Application); @@ -1041,6 +1049,8 @@ void qt_init(QApplicationPrivate * /* priv */, int) QT_TRAP_THROWING(coe->ConstructAppFromCommandLineL(factory,*commandLine)); delete commandLine; + S60->s60InstalledTrapHandler = User::SetTrapHandler(origTrapHandler); + S60->qtOwnsS60Environment = true; } else { S60->qtOwnsS60Environment = false; @@ -1195,6 +1205,9 @@ void qt_cleanup() S60->wsSession().SetPointerCursorMode(EPointerCursorNone); if (S60->qtOwnsS60Environment) { + // Restore the S60 framework trap handler. See qt_init(). + User::SetTrapHandler(S60->s60InstalledTrapHandler); + CEikonEnv* coe = CEikonEnv::Static(); coe->PrepareToExit(); // The CEikonEnv itself is destroyed in here. diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index d49c150..ecc6bc9 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -795,23 +795,23 @@ extern "C" { const EventRef carbonEvent = (EventRef)[theEvent eventRef]; const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0; - if (carbonEventKind == kEventMouseScroll) { + const bool scrollEvent = carbonEventKind == kEventMouseScroll; + + if (scrollEvent) { // The mouse device containts pixel scroll wheel support (Mighty Mouse, Trackpad). // Since deviceDelta is delivered as pixels rather than degrees, we need to // convert from pixels to degrees in a sensible manner. // It looks like four degrees per pixel behaves most native. // Qt expects the unit for delta to be 1/8 of a degree: - const int scrollFactor = 4 * 8; - deltaX = (int)[theEvent deviceDeltaX] * scrollFactor; - deltaY = (int)[theEvent deviceDeltaY] * scrollFactor; - deltaZ = (int)[theEvent deviceDeltaZ] * scrollFactor; - } else { // carbonEventKind == kEventMouseWheelMoved - // Mouse wheel deltas seem to tick in at increments of 0.1. - // Qt widgets expect the delta to be a multiple of 120. - const int scrollFactor = 10 * 120; - deltaX = [theEvent deltaX] * scrollFactor; - deltaY = [theEvent deltaY] * scrollFactor; - deltaZ = [theEvent deltaZ] * scrollFactor; + deltaX = [theEvent deviceDeltaX]; + deltaY = [theEvent deviceDeltaY]; + deltaZ = [theEvent deviceDeltaZ]; + } else { + // carbonEventKind == kEventMouseWheelMoved + // Remove acceleration, and use either -120 or 120 as delta: + deltaX = qBound(-120, int([theEvent deltaX] * 10000), 120); + deltaY = qBound(-120, int([theEvent deltaY] * 10000), 120); + deltaZ = qBound(-120, int([theEvent deltaZ] * 10000), 120); } if (deltaX != 0) { diff --git a/src/gui/kernel/qdesktopwidget.cpp b/src/gui/kernel/qdesktopwidget.cpp index b1e1008..c6d5000 100644 --- a/src/gui/kernel/qdesktopwidget.cpp +++ b/src/gui/kernel/qdesktopwidget.cpp @@ -40,12 +40,11 @@ ****************************************************************************/ #include "qglobal.h" - -QT_BEGIN_NAMESPACE - #include "qdesktopwidget.h" #include "qwidget_p.h" +QT_BEGIN_NAMESPACE + const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const { QRect rect = QWidgetPrivate::screenGeometry(widget); diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index ecdd661..a161876 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -142,12 +142,6 @@ QGesture::~QGesture() \brief whether the gesture has a hot-spot */ -/*! - \property QGesture::targetObject - \brief the target object which will receive the gesture event if the hotSpot is - not set -*/ - Qt::GestureType QGesture::gestureType() const { return d_func()->gestureType; diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 6116a5e..75c321e 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -189,7 +189,8 @@ bool QSoftKeyManager::event(QEvent *e) } while (source); QSoftKeyManagerPrivate::softKeySource = source; - QSoftKeyManagerPrivate::updateSoftKeys_sys(softKeys); + if (source) + QSoftKeyManagerPrivate::updateSoftKeys_sys(softKeys); return true; } return false; @@ -237,7 +238,8 @@ void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList<QAction*> &softkeys) } } - if (needsExitButton) + Qt::WindowType sourceWindowType = QSoftKeyManagerPrivate::softKeySource->window()->windowType(); + if (needsExitButton && sourceWindowType != Qt::Dialog && sourceWindowType != Qt::Popup) QT_TRAP_THROWING(nativeContainer->SetCommandL(2, EAknSoftkeyExit, qt_QString2TPtrC(QSoftKeyManager::tr("Exit")))); nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index a136379..dec2311 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -140,7 +140,6 @@ void QPanGestureRecognizer::reset(QGesture *state) QGestureRecognizer::reset(state); } -/*! \internal */ /* bool QPanGestureRecognizer::event(QEvent *event) { diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index e25bc81..789d89e 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -124,6 +124,8 @@ public: static inline CAknTitlePane* titlePane(); static inline CAknContextPane* contextPane(); static inline CEikButtonGroupContainer* buttonGroupContainer(); + + TTrapHandler *s60InstalledTrapHandler; #endif }; diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index d08f8a9..95c0bed 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3390,12 +3390,19 @@ void QWidgetPrivate::hide_sys() w = q->parentWidget()->window(); if(!w || (!w->isVisible() && !w->isMinimized())) { #ifndef QT_MAC_USE_COCOA - for(WindowPtr wp = GetFrontWindowOfClass(kDocumentWindowClass, true); - wp; wp = GetNextWindowOfClass(wp, kDocumentWindowClass, true)) { + for (WindowPtr wp = GetFrontWindowOfClass(kMovableModalWindowClass, true); + wp; wp = GetNextWindowOfClass(wp, kMovableModalWindowClass, true)) { if((w = qt_mac_find_window(wp))) break; } if (!w){ + for (WindowPtr wp = GetFrontWindowOfClass(kDocumentWindowClass, true); + wp; wp = GetNextWindowOfClass(wp, kDocumentWindowClass, true)) { + if((w = qt_mac_find_window(wp))) + break; + } + } + if (!w){ for(WindowPtr wp = GetFrontWindowOfClass(kSimpleWindowClass, true); wp; wp = GetNextWindowOfClass(wp, kSimpleWindowClass, true)) { if((w = qt_mac_find_window(wp))) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index abf5ba5..cb615fe 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -564,8 +564,13 @@ void QWidgetPrivate::lower_sys() Q_Q(QWidget); Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - if (q->internalWinId()) - q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); + if (q->internalWinId()) { + // If toplevel widget, lower app to background + if (q->isWindow()) + S60->wsSession().SetWindowGroupOrdinalPosition(S60->windowGroup().Identifier(), -1); + else + q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); + } if (!q->isWindow()) invalidateBuffer(q->rect()); diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index 6ec5796..32fde62 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -98,6 +98,7 @@ Ptr_gtk_check_menu_item_new QGtk::gtk_check_menu_item_new = 0; Ptr_gtk_menu_bar_new QGtk::gtk_menu_bar_new = 0; Ptr_gtk_menu_new QGtk::gtk_menu_new = 0; Ptr_gtk_button_new QGtk::gtk_button_new = 0; +Ptr_gtk_tool_button_new QGtk::gtk_tool_button_new = 0; Ptr_gtk_hbutton_box_new QGtk::gtk_hbutton_box_new = 0; Ptr_gtk_check_button_new QGtk::gtk_check_button_new = 0; Ptr_gtk_radio_button_new QGtk::gtk_radio_button_new = 0; @@ -266,6 +267,7 @@ static void resolveGtk() QGtk::gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)libgtk.resolve("gtk_separator_tool_item_new"); QGtk::gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)libgtk.resolve("gtk_toolbar_insert"); QGtk::gtk_button_new = (Ptr_gtk_button_new)libgtk.resolve("gtk_button_new"); + QGtk::gtk_tool_button_new = (Ptr_gtk_tool_button_new)libgtk.resolve("gtk_tool_button_new"); QGtk::gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)libgtk.resolve("gtk_hbutton_box_new"); QGtk::gtk_check_button_new = (Ptr_gtk_check_button_new)libgtk.resolve("gtk_check_button_new"); QGtk::gtk_radio_button_new = (Ptr_gtk_radio_button_new)libgtk.resolve("gtk_radio_button_new"); @@ -717,6 +719,7 @@ void QGtk::initGtkWidgets() GtkWidget *gtkButton = QGtk::gtk_button_new(); add_widget(gtkButton); g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), NULL); + add_widget(QGtk::gtk_tool_button_new(NULL, NULL)); add_widget(QGtk::gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE)); add_widget(QGtk::gtk_hbutton_box_new()); add_widget(QGtk::gtk_check_button_new()); diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h index 313d948..2cf21ce 100644 --- a/src/gui/styles/gtksymbols_p.h +++ b/src/gui/styles/gtksymbols_p.h @@ -96,6 +96,7 @@ typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void); typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void); typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int); typedef GtkWidget* (*Ptr_gtk_button_new)(void); +typedef GtkWidget* (*Ptr_gtk_tool_button_new)(GtkWidget *, const gchar *); typedef GtkWidget* (*Ptr_gtk_hbutton_box_new)(void); typedef GtkWidget* (*Ptr_gtk_check_button_new)(void); typedef GtkWidget* (*Ptr_gtk_radio_button_new)(GSList *); @@ -261,6 +262,7 @@ public: static Ptr_gtk_menu_new gtk_menu_new; static Ptr_gtk_expander_new gtk_expander_new; static Ptr_gtk_button_new gtk_button_new; + static Ptr_gtk_tool_button_new gtk_tool_button_new; static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new; static Ptr_gtk_check_button_new gtk_check_button_new; static Ptr_gtk_radio_button_new gtk_radio_button_new; diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 414580e..d315c98 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -1035,15 +1035,24 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, } break; - case PE_PanelButtonCommand: { + case PE_PanelButtonCommand: + case PE_PanelButtonTool: { bool isDefault = false; + bool isTool = (element == PE_PanelButtonTool); if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton*>(option)) isDefault = btn->features & QStyleOptionButton::DefaultButton; + // don't draw a frame for tool buttons that have the autoRaise flag and are not enabled or on + if (isTool && !(option->state & State_Enabled || option->state & State_On) && (option->state & State_AutoRaise)) + break; + // don't draw a frame for dock widget buttons, unless we are hovering + if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver)) + break; + GtkStateType state = gtkPainter.gtkState(option); if (option->state & State_On || option->state & State_Sunken) state = GTK_STATE_ACTIVE; - GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = QGtk::gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton")); gint focusWidth, focusPad; gboolean interiorFocus = false; QGtk::gtk_widget_style_get (gtkButton, @@ -1555,7 +1564,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QStyleOptionToolButton label = *toolbutton; label.state = bflags; - GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkToolButton.GtkButton")); QPalette pal = toolbutton->palette; if (option->state & State_Enabled && option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) { @@ -1931,13 +1940,26 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if (!QGtk::gtk_check_version(2, 10, 0)) QGtk::gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL); - if (trough_side_details && horizontal) { //### Vertical sliders look broken with this for some reason + if (!trough_side_details) { + gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state, + GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); + } else { + QRect upperGroove = grooveRect; QRect lowerGroove = grooveRect; - lowerGroove.setRight(handle.center().x()); + + if (horizontal) { + upperGroove.setLeft(handle.center().x()); + lowerGroove.setRight(handle.center().x()); + } else { + upperGroove.setBottom(handle.center().y()); + lowerGroove.setTop(handle.center().y()); + } + + gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state, + GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state, GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); } - } if (option->subControls & SC_SliderTickmarks) { @@ -3116,7 +3138,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, case CT_ToolButton: if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { - GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkToolButton.GtkButton")); newSize = size + QSize(2 * gtkButton->style->xthickness, 1 + 2 * gtkButton->style->ythickness); if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) { QSize minSize(0, 25); diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 4c6bc46..8d59d14 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1377,7 +1377,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) yEnd = -1; } - highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, xBeginning); + highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd); } QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); } diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index eef1573..ec238a9 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -2417,13 +2417,13 @@ int QStyle::layoutSpacingImplementation(QSizePolicy::ControlType /* control1 */, return -1; } -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) QT_BEGIN_INCLUDE_NAMESPACE #include <QDebug> QT_END_INCLUDE_NAMESPACE QDebug operator<<(QDebug debug, QStyle::State state) { +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) debug << "QStyle::State("; QStringList states; @@ -2455,9 +2455,9 @@ QDebug operator<<(QDebug debug, QStyle::State state) qSort(states); debug << states.join(QLatin1String(" | ")); debug << ')'; +#endif return debug; } -#endif /*! \since 4.6 diff --git a/src/gui/styles/qstyle.h b/src/gui/styles/qstyle.h index 1f8d5c8..0014954 100644 --- a/src/gui/styles/qstyle.h +++ b/src/gui/styles/qstyle.h @@ -878,9 +878,7 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::State) Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::SubControls) -#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DEBUG) Q_GUI_EXPORT QDebug operator<<(QDebug debug, QStyle::State state); -#endif QT_END_NAMESPACE diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index 10a6b5b..061afcc 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -45,9 +45,7 @@ # include "private/qt_mac_p.h" # include "qmacstyle_mac.h" #endif -#ifndef QT_NO_DEBUG #include <qdebug.h> -#endif #include <QtCore/qmath.h> QT_BEGIN_NAMESPACE @@ -1254,7 +1252,7 @@ QStyleOptionViewItemV4::QStyleOptionViewItemV4(int version) \brief the features of the group box frame The frame is flat by default. - + \sa QStyleOptionFrameV2::FrameFeature */ @@ -5298,9 +5296,9 @@ QStyleHintReturnVariant::QStyleHintReturnVariant() : QStyleHintReturn(Version, T Returns a T or 0 depending on the type of \a hint. */ -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) { +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) switch (optionType) { case QStyleOption::SO_Default: debug << "SO_Default"; break; @@ -5361,19 +5359,21 @@ QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) case QStyleOption::SO_GraphicsItem: debug << "SO_GraphicsItem"; break; } +#endif return debug; } QDebug operator<<(QDebug debug, const QStyleOption &option) { +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) debug << "QStyleOption("; debug << QStyleOption::OptionType(option.type); debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight"); debug << ',' << option.state; debug << ',' << option.rect; debug << ')'; +#endif return debug; } -#endif QT_END_NAMESPACE diff --git a/src/gui/styles/qstyleoption.h b/src/gui/styles/qstyleoption.h index 2860664..bf8b479 100644 --- a/src/gui/styles/qstyleoption.h +++ b/src/gui/styles/qstyleoption.h @@ -938,10 +938,8 @@ T qstyleoption_cast(QStyleHintReturn *hint) return 0; } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DEBUG) Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType); Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option); -#endif QT_END_NAMESPACE diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp index 588a48e..fec9fab 100644 --- a/src/gui/widgets/qabstractslider.cpp +++ b/src/gui/widgets/qabstractslider.cpp @@ -693,29 +693,27 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) if (e->orientation() != d->orientation && !rect().contains(e->pos())) return; - qreal currentOffset = qreal(e->delta()) / 120; - d->offset_accumulated += currentOffset; - if (int(d->offset_accumulated) == 0) { - // QAbstractSlider works on integer values. So if the accumulated - // offset is less than +/- 1, we need to wait until we get more - // wheel events (this means that the wheel resolution is higher than - // 15 degrees, e.g. when using mac mighty mouse/trackpad): - return; - } + int stepsToScroll = 0; + qreal offset = qreal(e->delta()) / 120; - int stepsToScroll; if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) { - stepsToScroll = currentOffset > 0 ? d->pageStep : -d->pageStep; + // Scroll one page regardless of delta: + stepsToScroll = qBound(-d->pageStep, int(offset * d->pageStep), d->pageStep); + d->offset_accumulated = 0; } else { - // Calculate the number of steps to scroll (per 15 degrees of rotate): -#ifdef Q_OS_MAC - // On mac, since mouse wheel scrolling is accelerated and - // fine tuned by the OS, we skip applying acceleration: - stepsToScroll = int(d->offset_accumulated); -#else - stepsToScroll = int(d->offset_accumulated) * QApplication::wheelScrollLines() * d->singleStep; -#endif - stepsToScroll = qBound(-d->pageStep, stepsToScroll, d->pageStep); + // Calculate how many lines to scroll. Depending on what delta is (and + // offset), we might end up with a fraction (e.g. scroll 1.3 lines). We can + // only scroll whole lines, so we keep the reminder until next event. + qreal stepsToScrollF = offset * QApplication::wheelScrollLines() * d->singleStep; + // Check if wheel changed direction since last event: + if (d->offset_accumulated != 0 && (offset / d->offset_accumulated) < 0) + d->offset_accumulated = 0; + + d->offset_accumulated += stepsToScrollF; + stepsToScroll = qBound(-d->pageStep, int(d->offset_accumulated), d->pageStep); + d->offset_accumulated -= int(d->offset_accumulated); + if (stepsToScroll == 0) + return; } if (d->invertedControls) @@ -725,12 +723,10 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) d->position = d->overflowSafeAdd(stepsToScroll); // value will be updated by triggerAction() triggerAction(SliderMove); - if (prevValue == d->value) { + if (prevValue == d->value) d->offset_accumulated = 0; - } else { - d->offset_accumulated -= int(d->offset_accumulated); + else e->accept(); - } } #endif #ifdef QT_KEYPAD_NAVIGATION diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 05e1e74..ae56d36 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -402,13 +402,6 @@ QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView layout->setSpacing(0); layout->setMargin(0); -#ifdef QT_SOFTKEYS_ENABLED - selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, this); - cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Escape, this); - addAction(selectAction); - addAction(cancelAction); -#endif - // set item view setItemView(itemView); @@ -572,6 +565,13 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView) this, SLOT(setCurrentIndex(QModelIndex))); connect(view, SIGNAL(destroyed()), this, SLOT(viewDestroyed())); + +#ifdef QT_SOFTKEYS_ENABLED + selectAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::SelectSoftKey, Qt::Key_Select, itemView); + cancelAction = QSoftKeyManager::createKeyedAction(QSoftKeyManager::CancelSoftKey, Qt::Key_Escape, itemView); + addAction(selectAction); + addAction(cancelAction); +#endif } /*! @@ -2452,15 +2452,15 @@ void QComboBox::showPopup() #if defined(Q_WS_WIN) && !defined(QT_NO_EFFECTS) bool scrollDown = (listRect.topLeft() == below); - if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo) + if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo) && !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 +// 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); |