diff options
Diffstat (limited to 'src/widgets')
30 files changed, 310 insertions, 120 deletions
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index ecb84d8b50..796d13487b 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -81,13 +81,22 @@ QAccessibleTable::QAccessibleTable(QWidget *w) { Q_ASSERT(view()); +#ifndef QT_NO_TABLEVIEW if (qobject_cast<const QTableView*>(view())) { m_role = QAccessible::Table; - } else if (qobject_cast<const QTreeView*>(view())) { + } else +#endif +#ifndef QT_NO_TREEVIEW + if (qobject_cast<const QTreeView*>(view())) { m_role = QAccessible::Tree; - } else if (qobject_cast<const QListView*>(view())) { + } else +#endif +#ifndef QT_NO_LISTVIEW + if (qobject_cast<const QListView*>(view())) { m_role = QAccessible::List; - } else { + } else +#endif + { // is this our best guess? m_role = QAccessible::Table; } @@ -664,6 +673,8 @@ void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) } } +#ifndef QT_NO_TREEVIEW + // TREE VIEW QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const @@ -714,7 +725,6 @@ int QAccessibleTree::childCount() const return (treeView->d_func()->viewItems.count() + hHeader)* view()->model()->columnCount(); } - QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const { if (logicalIndex < 0 || !view()->model() || !view()->model()->columnCount()) @@ -836,6 +846,8 @@ bool QAccessibleTree::selectRow(int row) return true; } +#endif // QT_NO_TREEVIEW + // TABLE CELL QAccessibleTableCell::QAccessibleTableCell(QAbstractItemView *view_, const QModelIndex &index_, QAccessible::Role role_) @@ -912,12 +924,14 @@ int QAccessibleTableCell::columnIndex() const int QAccessibleTableCell::rowIndex() const { +#ifndef QT_NO_TREEVIEW if (role() == QAccessible::TreeItem) { const QTreeView *treeView = qobject_cast<const QTreeView*>(view); Q_ASSERT(treeView); int row = treeView->d_func()->viewIndex(m_index); return row; } +#endif return m_index.row(); } @@ -1046,6 +1060,7 @@ QAccessible::State QAccessibleTableCell::state() const if (view->selectionMode() == QAbstractItemView::ExtendedSelection) st.extSelectable = true; } +#ifndef QT_NO_TREEVIEW if (m_role == QAccessible::TreeItem) { const QTreeView *treeView = qobject_cast<const QTreeView*>(view); if (treeView->model()->hasChildren(m_index)) @@ -1053,6 +1068,7 @@ QAccessible::State QAccessibleTableCell::state() const if (treeView->isExpanded(m_index)) st.expanded = true; } +#endif return st; } diff --git a/src/widgets/accessible/itemviews_p.h b/src/widgets/accessible/itemviews_p.h index ed421d3146..5b73444c67 100644 --- a/src/widgets/accessible/itemviews_p.h +++ b/src/widgets/accessible/itemviews_p.h @@ -145,6 +145,7 @@ private: QAccessible::Role m_role; }; +#ifndef QT_NO_TREEVIEW class QAccessibleTree :public QAccessibleTable { public: @@ -172,6 +173,7 @@ private: inline int logicalIndex(const QModelIndex &index) const; }; +#endif class QAccessibleTableCell: public QAccessibleInterface, public QAccessibleTableCellInterface, public QAccessibleActionInterface { @@ -221,7 +223,9 @@ private: void unselectCell(); friend class QAccessibleTable; +#ifndef QT_NO_TREEVIEW friend class QAccessibleTree; +#endif }; @@ -255,7 +259,9 @@ private: Qt::Orientation orientation; friend class QAccessibleTable; +#ifndef QT_NO_TREEVIEW friend class QAccessibleTree; +#endif }; // This is the corner button on the top left of a table. diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 5096c1ff37..840a990799 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -142,9 +142,11 @@ QString qt_accStripAmp(const QString &text) QString qt_accHotKey(const QString &text) { +#ifndef QT_NO_SHORTCUT int ampIndex = qt_accAmpIndex(text); if (ampIndex != -1) return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + text.at(ampIndex + 1); +#endif return QString(); } diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 3bfef49965..dfc8c84836 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -139,9 +139,11 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QMenu")) { iface = new QAccessibleMenu(widget); #endif -#ifndef QT_NO_ITEMVIEWS +#ifndef QT_NO_TREEVIEW } else if (classname == QLatin1String("QTreeView")) { iface = new QAccessibleTree(widget); +#endif // QT_NO_TREEVIEW +#ifndef QT_NO_ITEMVIEWS } else if (classname == QLatin1String("QTableView") || classname == QLatin1String("QListView")) { iface = new QAccessibleTable(widget); // ### This should be cleaned up. We return the parent for the scrollarea to hide it. diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 3e01d40de3..bd9f0c6e01 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -404,8 +404,10 @@ QAccessible::Role QAccessibleDisplay::role() const } else if (qobject_cast<QProgressBar*>(object())) { return QAccessible::ProgressBar; #endif +#ifndef QT_NO_STATUSBAR } else if (qobject_cast<QStatusBar*>(object())) { return QAccessible::StatusBar; +#endif } return QAccessibleWidget::role(); } @@ -428,8 +430,10 @@ QString QAccessibleDisplay::text(QAccessible::Text t) const str = doc.toPlainText(); } #endif +#ifndef QT_NO_SHORTCUT if (label->buddy()) str = qt_accStripAmp(str); +#endif #ifndef QT_NO_LCDNUMBER } else if (qobject_cast<QLCDNumber*>(object())) { QLCDNumber *l = qobject_cast<QLCDNumber*>(object()); @@ -438,8 +442,10 @@ QString QAccessibleDisplay::text(QAccessible::Text t) const else str = QString::number(l->intValue()); #endif +#ifndef QT_NO_STATUSBAR } else if (qobject_cast<QStatusBar*>(object())) { return qobject_cast<QStatusBar*>(object())->currentMessage(); +#endif } } break; diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index d4764c019e..1116685fc7 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -2172,7 +2172,8 @@ QColor QColorDialog::getColor(const QColor &initial, QWidget *parent, const QStr QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent) { - QColor color(getColor(QColor(initial), parent, QString(), ShowAlphaChannel)); + const QColor color = getColor(QColor::fromRgba(initial), parent, QString(), + ShowAlphaChannel); QRgb result = color.isValid() ? color.rgba() : initial; if (ok) *ok = color.isValid(); diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 8dfcf2c6d6..e8883df527 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -95,7 +95,7 @@ QPlatformDialogHelper *QDialogPrivate::platformHelper() const { // Delayed creation of the platform, ensuring that // that qobject_cast<> on the dialog works in the plugin. - if (!m_platformHelperCreated) { + if (!m_platformHelperCreated && canBeNativeDialog()) { m_platformHelperCreated = true; QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this); QDialog *dialog = ncThis->q_func(); @@ -634,12 +634,14 @@ void QDialog::contextMenuEvent(QContextMenuEvent *e) /*! \reimp */ void QDialog::keyPressEvent(QKeyEvent *e) { +#ifndef QT_NO_SHORTCUT // Calls reject() if Escape is pressed. Simulates a button // click for the default button if Enter is pressed. Move focus // for the arrow keys. Ignore the rest. if (e->matches(QKeySequence::Cancel)) { reject(); } else +#endif if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) { switch (e->key()) { case Qt::Key_Enter: diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index b4ca853c5d..7b60e9cb56 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -2414,8 +2414,7 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent, native file dialog and not a QFileDialog. However, the native Windows file dialog does not support displaying files in the directory chooser. You need to pass \l{QFileDialog::}{DontUseNativeDialog} to display files using a - QFileDialog. On Windows CE, if the device has no native file dialog, a - QFileDialog will be used. + QFileDialog. On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, @@ -2792,7 +2791,7 @@ void QFileDialogPrivate::init(const QUrl &directory, const QString &nameFilter, } q->setAcceptMode(QFileDialog::AcceptOpen); - nativeDialogInUse = (canBeNativeDialog() && platformFileDialogHelper() != 0); + nativeDialogInUse = platformFileDialogHelper() != 0; if (!nativeDialogInUse) createWidgets(); q->setFileMode(QFileDialog::AnyFile); diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 1c4166c567..5118383fe5 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -818,10 +818,8 @@ void QFontDialog::setCurrentFont(const QFont &font) d->strikeout->setChecked(font.strikeOut()); d->underline->setChecked(font.underline()); d->updateFamilies(); - if (d->canBeNativeDialog()) { - if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) - helper->setCurrentFont(font); - } + if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) + helper->setCurrentFont(font); } /*! @@ -834,10 +832,8 @@ void QFontDialog::setCurrentFont(const QFont &font) QFont QFontDialog::currentFont() const { Q_D(const QFontDialog); - if (d->canBeNativeDialog()) { - if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) - return helper->currentFont(); - } + if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) + return helper->currentFont(); return d->sampleEdit->font(); } diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index d86cddab61..713ccb6556 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -198,7 +198,9 @@ void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIn QIcon newIcon = qvariant_cast<QIcon>(dirIndex.data(Qt::DecorationRole)); if (!dirIndex.isValid()) { - newIcon = fileSystemModel->iconProvider()->icon(QFileIconProvider::Folder); + const QFileIconProvider *provider = fileSystemModel->iconProvider(); + if (provider) + newIcon = provider->icon(QFileIconProvider::Folder); newName = QFileInfo(url.toLocalFile()).fileName(); if (!invalidUrls.contains(url)) invalidUrls.append(url); diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index ebe1e93fe8..0b9e6e7216 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -544,6 +544,7 @@ QGraphicsProxyWidget::~QGraphicsProxyWidget() { Q_D(QGraphicsProxyWidget); if (d->widget) { + d->widget->removeEventFilter(this); QObject::disconnect(d->widget, SIGNAL(destroyed()), this, SLOT(_q_removeWidgetSlot())); delete d->widget; } diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h index a9d73459c0..47cba93fce 100644 --- a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h +++ b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h @@ -114,8 +114,8 @@ private: int m_numSortedElements; }; -#endif // QT_NO_GRAPHICSVIEW - QT_END_NAMESPACE +#endif // QT_NO_GRAPHICSVIEW + #endif // QGRAPHICSSCENELINEARINDEX_H diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index 5e3b74f7b7..8cd2a957be 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -464,11 +464,13 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev if (editorHandlesKeyEvent(editor, keyEvent)) return false; +#ifndef QT_NO_SHORTCUT if (keyEvent->matches(QKeySequence::Cancel)) { // don't commit data emit q->closeEditor(editor, QAbstractItemDelegate::RevertModelCache); return true; } +#endif switch (keyEvent->key()) { case Qt::Key_Tab: @@ -519,11 +521,13 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev emit q->closeEditor(editor, QAbstractItemDelegate::NoHint); } +#ifndef QT_NO_SHORTCUT } else if (event->type() == QEvent::ShortcutOverride) { if (static_cast<QKeyEvent*>(event)->matches(QKeySequence::Cancel)) { event->accept(); return true; } +#endif } return false; } diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 42b35ac644..a4e24b80b1 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -2473,10 +2473,12 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) break; #endif default: { +#ifndef QT_NO_SHORTCUT if (event == QKeySequence::SelectAll && selectionMode() != NoSelection) { selectAll(); break; } +#endif #ifdef Q_OS_OSX if (event->key() == Qt::Key_O && event->modifiers() & Qt::ControlModifier && currentIndex().isValid()) { emit activated(currentIndex()); diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index e5bf606901..72aae647e0 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -1304,8 +1304,10 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action) d << " toolTip=" << action->toolTip(); if (action->isCheckable()) d << " checked=" << action->isChecked(); +#ifndef QT_NO_SHORTCUT if (!action->shortcut().isEmpty()) d << " shortcut=" << action->shortcut(); +#endif d << " menuRole="; QtDebugUtils::formatQEnum(d, action->menuRole()); d << " visible=" << action->isVisible(); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index afc1be7458..9b8677e6a8 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1010,8 +1010,8 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis the WA_InputMethodEnabled attribute set, and is typically used to launch a virtual keyboard on devices which have very few or no keys. - \b{ The property only has an effect on platforms which use software input - panels, such as Windows CE.} + \b{ The property only has an effect on platforms that use software input + panels.} The default is platform dependent. */ @@ -3869,12 +3869,7 @@ void QApplicationPrivate::openPopup(QWidget *popup) /*! Sets the kind of focus navigation Qt should use to \a mode. - This feature is available in Qt for Embedded Linux, and Windows CE - only. - - \note On Windows CE this feature is disabled by default for touch device - mkspecs. To enable keypad navigation, build Qt with - QT_KEYPAD_NAVIGATION defined. + This feature is available in Qt for Embedded Linux only. \since 4.6 @@ -3888,11 +3883,7 @@ void QApplication::setNavigationMode(Qt::NavigationMode mode) /*! Returns what kind of focus navigation Qt is using. - This feature is available in Qt for Embedded Linux, and Windows CE only. - - \note On Windows CE this feature is disabled by default for touch device - mkspecs. To enable keypad navigation, build Qt with - QT_KEYPAD_NAVIGATION defined. + This feature is available in Qt for Embedded Linux only. \since 4.6 diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index 7bd9e74924..6eec5ff7e8 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -141,7 +141,7 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window) { bool visible = w->isVisible(); -#ifdef Q_OS_MAC +#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR) if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w)) visible = true; #endif @@ -204,7 +204,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window) { bool visible = w->isVisible(); -#ifdef Q_OS_MAC +#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR) if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w)) visible = true; #endif @@ -272,7 +272,7 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge QWidget *w = widgets.at(i); #ifndef QT_NO_MENU if (QMenu *menu = qobject_cast<QMenu *>(w)) { -#ifdef Q_OS_MAC +#ifdef Q_OS_DARWIN // On Mac, menu item shortcuts are processed before reaching any window. // That means that if a menu action shortcut has not been already processed // (and reaches this point), then the menu item itself has been disabled. diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index d0971443ba..bfadd69db5 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1432,6 +1432,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO win->setProperty("_q_showWithoutActivating", QVariant(true)); if (q->testAttribute(Qt::WA_MacAlwaysShowToolWindow)) win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true))); + setNetWmWindowTypes(true); // do nothing if none of WA_X11NetWmWindowType* is set win->setFlags(data.window_flags); fixPosIncludesFrame(); if (q->testAttribute(Qt::WA_Moved) @@ -1477,6 +1478,9 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO data.window_flags = win->flags(); + if (!topData()->role.isNull()) + QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1()); + QBackingStore *store = q->backingStore(); if (!store) { @@ -6353,13 +6357,11 @@ QString QWidget::windowRole() const */ void QWidget::setWindowRole(const QString &role) { -#if defined(Q_DEAD_CODE_FROM_QT4_X11) Q_D(QWidget); + d->createTLExtra(); d->topData()->role = role; - d->setWindowRole(); -#else - Q_UNUSED(role) -#endif + if (windowHandle()) + QXcbWindowFunctions::setWmWindowRole(windowHandle(), role.toLatin1()); } /*! @@ -9441,10 +9443,13 @@ void QWidget::tabletEvent(QTabletEvent *event) void QWidget::keyPressEvent(QKeyEvent *event) { +#ifndef QT_NO_SHORTCUT if ((windowType() == Qt::Popup) && event->matches(QKeySequence::Cancel)) { event->accept(); close(); - } else { + } else +#endif + { event->ignore(); } } @@ -10361,14 +10366,13 @@ void QWidgetPrivate::setWindowFlags(Qt::WindowFlags flags) // the old type was a window and/or the new type is a window QPoint oldPos = q->pos(); bool visible = q->isVisible(); + const bool windowFlagChanged = (q->data->window_flags ^ flags) & Qt::Window; q->setParent(q->parentWidget(), flags); // if both types are windows or neither of them are, we restore // the old position - if (!((q->data->window_flags ^ flags) & Qt::Window) - && (visible || q->testAttribute(Qt::WA_Moved))) { + if (!windowFlagChanged && (visible || q->testAttribute(Qt::WA_Moved))) q->move(oldPos); - } // for backward-compatibility we change Qt::WA_QuitOnClose attribute value only when the window was recreated. adjustQuitOnCloseAttribute(); } else { @@ -11249,7 +11253,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) break; } -#ifdef Q_DEAD_CODE_FROM_QT4_X11 case Qt::WA_X11NetWmWindowTypeDesktop: case Qt::WA_X11NetWmWindowTypeDock: case Qt::WA_X11NetWmWindowTypeToolBar: @@ -11263,10 +11266,8 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) case Qt::WA_X11NetWmWindowTypeNotification: case Qt::WA_X11NetWmWindowTypeCombo: case Qt::WA_X11NetWmWindowTypeDND: - if (testAttribute(Qt::WA_WState_Created)) - d->setNetWmWindowTypes(); + d->setNetWmWindowTypes(); break; -#endif case Qt::WA_StaticContents: if (QWidgetBackingStore *bs = d->maybeBackingStore()) { @@ -11322,9 +11323,7 @@ bool QWidget::testAttribute_helper(Qt::WidgetAttribute attribute) const This feature is available on Embedded Linux, \macos, Windows, and X11 platforms that support the Composite extension. - This feature is not available on Windows CE. - - Note that under X11 you need to have a composite manager running, + \note On X11 you need to have a composite manager running, and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be supported by the window manager you are using. @@ -12937,6 +12936,47 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new widget->setParent(static_cast<QWidget*>(newParent)); } +void QWidgetPrivate::setNetWmWindowTypes(bool skipIfMissing) +{ + Q_Q(QWidget); + + if (!q->windowHandle()) + return; + + int wmWindowType = 0; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop)) + wmWindowType |= QXcbWindowFunctions::Desktop; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock)) + wmWindowType |= QXcbWindowFunctions::Dock; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar)) + wmWindowType |= QXcbWindowFunctions::Toolbar; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu)) + wmWindowType |= QXcbWindowFunctions::Menu; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility)) + wmWindowType |= QXcbWindowFunctions::Utility; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash)) + wmWindowType |= QXcbWindowFunctions::Splash; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog)) + wmWindowType |= QXcbWindowFunctions::Dialog; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu)) + wmWindowType |= QXcbWindowFunctions::DropDownMenu; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu)) + wmWindowType |= QXcbWindowFunctions::PopupMenu; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip)) + wmWindowType |= QXcbWindowFunctions::Tooltip; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification)) + wmWindowType |= QXcbWindowFunctions::Notification; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo)) + wmWindowType |= QXcbWindowFunctions::Combo; + if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND)) + wmWindowType |= QXcbWindowFunctions::Dnd; + + if (wmWindowType == 0 && skipIfMissing) + return; + + QXcbWindowFunctions::setWmWindowType(q->windowHandle(), static_cast<QXcbWindowFunctions::WmWindowType>(wmWindowType)); +} + #ifndef QT_NO_DEBUG_STREAM static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget) diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index f2884e7b17..0a810df102 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -765,7 +765,6 @@ public: void setWindowRole(); void sendStartupMessage(const char *message) const; - void setNetWmWindowTypes(); void x11UpdateIsOpaque(); bool isBackgroundInherited() const; void updateX11AcceptFocus(); @@ -862,6 +861,8 @@ public: static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool); void registerTouchWindow(bool enable = true); #endif + void setNetWmWindowTypes(bool skipIfMissing = false); + bool stealKeyboardGrab(bool grab); bool stealMouseGrab(bool grab); }; diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index d7f4b1f989..bb25a3a986 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -97,11 +97,14 @@ public: } QWidget *p = q->parentWidget(); while (p) { - if ( + if (false #ifndef QT_NO_MDIAREA - qobject_cast<QMdiSubWindow *>(p) != 0 || + || qobject_cast<QMdiSubWindow *>(p) != 0 #endif - qobject_cast<QAbstractScrollArea *>(p) != 0) { +#ifndef QT_NO_SCROLLAREA + || qobject_cast<QAbstractScrollArea *>(p) != 0 +#endif + ) { q->winId(); usesNativeWidgets = true; break; diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 47a6156662..6aa5845a2c 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -190,12 +190,14 @@ typedef HIRect * (*PtrHIShapeGetBounds)(HIShapeRef, HIRect *); static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0; static int closeButtonSize = 12; +#ifndef QT_NO_TABBAR static bool isVerticalTabs(const QTabBar::Shape shape) { return (shape == QTabBar::RoundedEast || shape == QTabBar::TriangularEast || shape == QTabBar::RoundedWest || shape == QTabBar::TriangularWest); } +#endif static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY) { @@ -247,6 +249,7 @@ void drawTabCloseButton(QPainter *p, bool hover, bool active, bool selected) p->drawLine(min, max, max, min); } +#ifndef QT_NO_TABBAR QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect) { if (isVerticalTabs(shape)) { @@ -430,6 +433,7 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBase *tbb, const QWidget * p->setPen(borderBottom); p->drawLine(tabRect.x(), height - 1, width, height - 1); } +#endif static int getControlSize(const QStyleOption *option, const QWidget *widget) { @@ -445,13 +449,16 @@ static int getControlSize(const QStyleOption *option, const QWidget *widget) } +#ifndef QT_NO_TREEVIEW static inline bool isTreeView(const QWidget *widget) { return (widget && widget->parentWidget() && (qobject_cast<const QTreeView *>(widget->parentWidget()) )); } +#endif +#ifndef QT_NO_TABBAR static inline ThemeTabDirection getTabDirection(QTabBar::Shape shape) { ThemeTabDirection ttd; @@ -476,6 +483,7 @@ static inline ThemeTabDirection getTabDirection(QTabBar::Shape shape) } return ttd; } +#endif static QString qt_mac_removeMnemonics(const QString &original) { @@ -742,8 +750,10 @@ inline bool qt_mac_is_metal(const QWidget *w) if (w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) { // If not created will fall through to the opaque check and be fine anyway. return qt_macWindowIsTextured(w); } +#ifndef QT_NO_ACCESSIBILITY if (w->d_func()->isOpaque) break; +#endif } return false; } @@ -778,22 +788,34 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg ct = QStyle::CT_RadioButton; else if (qobject_cast<const QCheckBox *>(widg)) ct = QStyle::CT_CheckBox; +#ifndef QT_NO_COMBOBOX else if (qobject_cast<const QComboBox *>(widg)) ct = QStyle::CT_ComboBox; +#endif +#ifndef QT_NO_TOOLBUTTON else if (qobject_cast<const QToolButton *>(widg)) ct = QStyle::CT_ToolButton; +#endif else if (qobject_cast<const QSlider *>(widg)) ct = QStyle::CT_Slider; +#ifndef QT_NO_PROGRESSBAR else if (qobject_cast<const QProgressBar *>(widg)) ct = QStyle::CT_ProgressBar; +#endif +#ifndef QT_NO_LINEEDIT else if (qobject_cast<const QLineEdit *>(widg)) ct = QStyle::CT_LineEdit; +#endif else if (qobject_cast<const QHeaderView *>(widg)) ct = QStyle::CT_HeaderSection; +#ifndef QT_NO_MENUBAR else if (qobject_cast<const QMenuBar *>(widg)) ct = QStyle::CT_MenuBar; +#endif +#ifndef QT_NO_SIZEGRIP else if (qobject_cast<const QSizeGrip *>(widg)) ct = QStyle::CT_SizeGrip; +#endif else return ret; } @@ -903,6 +925,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg if (sz == QAquaSizeSmall) { int width = 0, height = 0; if (szHint == QSize(-1, -1)) { //just 'guess'.. +#ifndef QT_NO_TOOLBUTTON const QToolButton *bt = qobject_cast<const QToolButton *>(widg); // If this conversion fails then the widget was not what it claimed to be. if(bt) { @@ -923,7 +946,9 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg width = qMax(height, text_height); } } - } else { + } else +#endif + { // Let's return the size hint... width = szHint.width(); height = szHint.height(); @@ -987,6 +1012,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg ret.setWidth(w); break; } +#ifndef QT_NO_PROGRESSBAR case QStyle::CT_ProgressBar: { int finalValue = -1; Qt::Orientation orient = Qt::Horizontal; @@ -1005,6 +1031,8 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg ret.setWidth(finalValue); break; } +#endif +#ifndef QT_NO_COMBOBOX case QStyle::CT_LineEdit: if (!widg || !qobject_cast<QComboBox *>(widg->parentWidget())) { //should I take into account the font dimentions of the lineedit? -Sam @@ -1014,9 +1042,12 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg ret = QSize(-1, 19); } break; +#endif case QStyle::CT_HeaderSection: +#ifndef QT_NO_TREEVIEW if (isTreeView(widg)) ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricListHeaderHeight)); +#endif break; case QStyle::CT_MenuBar: if (sz == QAquaSizeLarge) { @@ -1424,6 +1455,7 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem // an extra check here before using the mini and small buttons. int h = combo->rect.size().height(); if (combo->editable){ +#ifndef QT_NO_DATETIMEEDIT if (qobject_cast<const QDateTimeEdit *>(widget)) { // Except when, you know, we get a QDateTimeEdit with calendarPopup // enabled. And then things get weird, basically because it's a @@ -1440,7 +1472,9 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem bdi->kind = kThemeComboBoxSmall; else bdi->kind = kThemeComboBox; - } else { + } else +#endif + { if (h < 21) bdi->kind = kThemeComboBoxMini; else if (h < 26) @@ -2308,7 +2342,12 @@ void QMacStyle::polish(QWidget* w) w->setAttribute(Qt::WA_SetPalette, false); } - if (qobject_cast<QMenu*>(w) || qobject_cast<QComboBoxPrivateContainer *>(w)) { +#ifndef QT_NO_MENU + if (qobject_cast<QMenu*>(w) +#ifndef QT_NO_COMBOBOX + || qobject_cast<QComboBoxPrivateContainer *>(w) +#endif + ) { w->setWindowOpacity(0.985); if (!w->testAttribute(Qt::WA_SetPalette)) { QPixmap px(64, 64); @@ -2328,7 +2367,9 @@ void QMacStyle::polish(QWidget* w) w->setAttribute(Qt::WA_SetPalette, false); } } +#endif +#ifndef QT_NO_TABBAR if (QTabBar *tb = qobject_cast<QTabBar*>(w)) { if (tb->documentMode()) { w->setAttribute(Qt::WA_Hover); @@ -2338,6 +2379,7 @@ void QMacStyle::polish(QWidget* w) w->setPalette(p); } } +#endif QCommonStyle::polish(w); @@ -2356,19 +2398,26 @@ void QMacStyle::polish(QWidget* w) void QMacStyle::unpolish(QWidget* w) { - if ((qobject_cast<QMenu*>(w) || qt_mac_is_metal(w)) && !w->testAttribute(Qt::WA_SetPalette)) { + if (( +#ifndef QT_NO_MENU + qobject_cast<QMenu*>(w) || +#endif + qt_mac_is_metal(w) + ) && !w->testAttribute(Qt::WA_SetPalette)) { QPalette pal = qApp->palette(w); w->setPalette(pal); w->setAttribute(Qt::WA_SetPalette, false); w->setWindowOpacity(1.0); } +#ifndef QT_NO_COMBOBOX if (QComboBox *combo = qobject_cast<QComboBox *>(w)) { if (!combo->isEditable()) { if (QWidget *widget = combo->findChild<QComboBoxPrivateContainer *>()) widget->setWindowOpacity(1.0); } } +#endif if (QRubberBand *rubber = qobject_cast<QRubberBand*>(w)) { rubber->setWindowOpacity(1.0); @@ -2878,9 +2927,12 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w ret = QEvent::MouseButtonRelease; break; case SH_TabBar_SelectMouseType: +#ifndef QT_NO_TABBAR if (const QStyleOptionTabBarBase *opt2 = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) { ret = opt2->documentMode ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - } else { + } else +#endif + { ret = QEvent::MouseButtonRelease; } break; @@ -2900,18 +2952,22 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w ret = Qt::AlignRight; break; case SH_TabBar_Alignment: { +#ifndef QT_NO_TABWIDGET if (const QTabWidget *tab = qobject_cast<const QTabWidget*>(w)) { if (tab->documentMode()) { ret = Qt::AlignLeft; break; } } +#endif +#ifndef QT_NO_TABBAR if (const QTabBar *tab = qobject_cast<const QTabBar*>(w)) { if (tab->documentMode()) { ret = Qt::AlignLeft; break; } } +#endif ret = Qt::AlignCenter; } break; case SH_UnderlineShortcut: @@ -3041,9 +3097,11 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_FocusFrame_AboveWidget: ret = true; break; +#ifndef QT_NO_WIZARD case SH_WizardStyle: ret = QWizard::MacStyle; break; +#endif case SH_ItemView_ArrowKeysNavigateIntoChildren: ret = false; break; @@ -3061,9 +3119,11 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w opt->rect.width(), opt->rect.height() - 8); HIThemeMenuDrawInfo mdi; mdi.version = 0; +#ifndef QT_NO_MENU if (w && qobject_cast<QMenu *>(w->parentWidget())) mdi.menuType = kThemeMenuTypeHierarchical; else +#endif mdi.menuType = kThemeMenuTypePopUp; QCFType<HIShapeRef> shape; HIThemeGetMenuBackgroundShape(&menuRect, &mdi, &shape); @@ -3075,9 +3135,11 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_ItemView_PaintAlternatingRowColorsForEmptyArea: ret = true; break; +#ifndef QT_NO_TABBAR case SH_TabBar_CloseButtonPosition: ret = QTabBar::LeftSide; break; +#endif case SH_DockWidget_ButtonsHaveFrame: ret = false; break; @@ -3246,6 +3308,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai p->drawPath(path); p->restore(); break; } +#ifndef QT_NO_TABBAR case PE_FrameTabBarBase: if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) { @@ -3281,6 +3344,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai p->restore(); } break; +#endif case PE_PanelTipLabel: p->fillRect(opt->rect, opt->palette.brush(QPalette::ToolTipBase)); break; @@ -3292,9 +3356,11 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai HIThemeGroupBoxDrawInfo gdi; gdi.version = qt_mac_hitheme_version; gdi.state = tds; +#ifndef QT_NO_GROUPBOX if (w && qobject_cast<QGroupBox *>(w->parentWidget())) gdi.kind = kHIThemeGroupBoxKindSecondary; else +#endif gdi.kind = kHIThemeGroupBoxKindPrimary; HIRect hirect = qt_hirectForQRect(opt->rect); HIThemeDrawGroupBox(&hirect, &gdi, cg, kHIThemeOrientationNormal); @@ -3528,6 +3594,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai // Draw the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit). // Focus frame is drawn outside the rectangle passed in the option-rect. if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { +#ifndef QT_NO_LINEEDIT if ((opt->state & State_HasFocus) && !qobject_cast<const QLineEdit*>(w)) { int vmargin = pixelMetric(QStyle::PM_FocusFrameVMargin); int hmargin = pixelMetric(QStyle::PM_FocusFrameHMargin); @@ -3535,9 +3602,11 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai focusFrame.rect = panel->rect.adjusted(-hmargin, -vmargin, hmargin, vmargin); drawControl(CE_FocusFrame, &focusFrame, p, w); } +#endif } break; +#ifndef QT_NO_TABWIDGET case PE_FrameTabWidget: if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { @@ -3552,6 +3621,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai HIThemeDrawTabPane(&hirect, &tpdi, cg, kHIThemeOrientationNormal); } break; +#endif case PE_PanelScrollAreaCorner: { const QBrush brush(opt->palette.brush(QPalette::Base)); p->fillRect(opt->rect, brush); @@ -3695,9 +3765,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter HIRect bounds = qt_hirectForQRect(ir); bool noVerticalHeader = true; +#ifndef QT_NO_TABLEVIEW if (w) if (const QTableView *table = qobject_cast<const QTableView *>(w->parentWidget())) noVerticalHeader = !table->verticalHeader()->isVisible(); +#endif bool drawTopBorder = header->orientation == Qt::Horizontal; bool drawLeftBorder = header->orientation == Qt::Vertical @@ -4131,6 +4203,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QCommonStyle::drawControl(CE_ComboBoxLabel, &comboCopy, p, w); } break; +#ifndef QT_NO_TABBAR case CE_TabBarTabShape: if (const QStyleOptionTab *tabOpt = qstyleoption_cast<const QStyleOptionTab *>(opt)) { @@ -4337,6 +4410,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } } break; +#endif +#ifndef QT_NO_DOCKWIDGET case CE_DockWidgetTitle: if (const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(w)) { bool floating = dockWidget->isFloating(); @@ -4412,6 +4487,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } } break; +#endif case CE_FocusFrame: { const int hMargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, w); const int vMargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin, opt, w); @@ -4536,9 +4612,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // Always be normal or disabled to follow the Mac style. int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize); QSize iconSize(smallIconSize, smallIconSize); +#ifndef QT_NO_COMBOBOX if (const QComboBox *comboBox = qobject_cast<const QComboBox *>(w)) { iconSize = comboBox->iconSize(); } +#endif QPixmap pixmap = mi->icon.pixmap(window, iconSize, mode); int pixw = pixmap.width() / pixmap.devicePixelRatio(); int pixh = pixmap.height() / pixmap.devicePixelRatio(); @@ -4822,6 +4900,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } } break; +#ifndef QT_NO_TOOLBAR case CE_ToolBar: { const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt); @@ -4830,6 +4909,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // the title bar. The following code fills the toolBar area with transparent pixels // to make that gradient visible. if (w) { +#ifndef QT_NO_MAINWINDOW if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(w->window())) { if (toolBar && toolBar->toolBarArea == Qt::TopToolBarArea && mainWindow->unifiedTitleAndToolBarOnMac()) { @@ -4858,6 +4938,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter break; } } +#endif } // draw background gradient @@ -4888,6 +4969,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } break; +#endif default: QCommonStyle::drawControl(ce, opt, p, w); break; @@ -4979,6 +5061,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, int(outRect.size.height)); break; } +#ifndef QT_NO_TABWIDGET case SE_TabWidgetLeftCorner: if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { @@ -5040,11 +5123,14 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, } } break; +#endif case SE_LineEditContents: rect = QCommonStyle::subElementRect(sr, opt, widget); +#ifndef QT_NO_COMBOBOX if (widget && qobject_cast<const QComboBox*>(widget->parentWidget())) rect.adjust(-1, -2, 0, 0); else +#endif rect.adjust(-1, -1, 0, +1); break; case SE_CheckBoxLayoutItem: @@ -5058,12 +5144,15 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, } break; case SE_ComboBoxLayoutItem: +#ifndef QT_NO_TOOLBAR if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) { // Do nothing, because QToolbar needs the entire widget rect. // Otherwise it will be clipped. Equivalent to // widget->setAttribute(Qt::WA_LayoutUsesWidgetRect), but without // all the hassle. - } else { + } else +#endif + { rect = opt->rect; if (controlSize == QAquaSizeLarge) { rect.adjust(+3, +2, -3, -4); @@ -5181,6 +5270,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, } rect.setBottom(rect.bottom() - 1); break; +#ifndef QT_NO_TABWIDGET case SE_TabWidgetLayoutItem: if (const QStyleOptionTabWidgetFrame *tabWidgetOpt = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { @@ -5194,6 +5284,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, rect.setTop(rect.top() + SIZE(6 /* AHIG */, 3 /* guess */, 2 /* AHIG */)); } break; +#endif #ifndef QT_NO_DOCKWIDGET case SE_DockWidgetCloseButton: case SE_DockWidgetFloatButton: @@ -5700,6 +5791,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } } break; +#ifndef QT_NO_SPINBOX case CC_SpinBox: if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { QStyleOptionSpinBox newSB = *sb; @@ -5770,6 +5862,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } } break; +#endif case CC_ComboBox: if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)){ HIThemeButtonDrawInfo bdi; @@ -6075,10 +6168,12 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex #endif } break; +#ifndef QT_NO_DIAL case CC_Dial: if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt)) QStyleHelper::drawDial(dial, p); break; +#endif default: QCommonStyle::drawComplexControl(cc, opt, p, widget); break; @@ -6456,6 +6551,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op } } break; +#ifndef QT_NO_SPINBOX case CC_SpinBox: if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { QAquaWidgetSize aquaSize = d->aquaSizeConstrain(spin, widget); @@ -6549,6 +6645,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op } } break; +#endif case CC_ToolButton: ret = QCommonStyle::subControlRect(cc, opt, sc, widget); if (sc == SC_ToolButtonMenu @@ -6574,7 +6671,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, bool useAquaGuideline = true; switch (ct) { - +#ifndef QT_NO_SPINBOX case CT_SpinBox: if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { // Add button + frame widths @@ -6583,6 +6680,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz += QSize(buttonWidth + 2*fw, 2*fw - 3); } break; +#endif case QStyle::CT_TabWidget: // the size between the pane and the "contentsRect" (+4,+4) // (the "contentsRect" is on the inside of the pane) @@ -6618,7 +6716,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, * overlap is how much the pane should overlap the tab bar */ // then add the size between the stackwidget and the "contentsRect" - +#ifndef QT_NO_TABWIDGET if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { QSize extra(0,0); @@ -6632,8 +6730,9 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } sz+= extra; } - +#endif break; +#ifndef QT_NO_TABBAR case QStyle::CT_TabBarTab: if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { const QAquaWidgetSize AquaSize = d->aquaSizeConstrain(opt, widget); @@ -6701,6 +6800,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } } break; +#endif case QStyle::CT_PushButton: // By default, we fit the contents inside a normal rounded push button. // Do this by add enough space around the contents so that rounded @@ -6714,7 +6814,9 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, case QStyle::CT_MenuItem: if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { int maxpmw = mi->maxIconWidth; +#ifndef QT_NO_COMBOBOX const QComboBox *comboBox = qobject_cast<const QComboBox *>(widget); +#endif int w = sz.width(), h = sz.height(); if (mi->menuItemType == QStyleOptionMenuItem::Separator) { @@ -6725,11 +6827,14 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } else { h = mi->fontMetrics.height() + 2; if (!mi->icon.isNull()) { +#ifndef QT_NO_COMBOBOX if (comboBox) { const QSize &iconSize = comboBox->iconSize(); h = qMax(h, iconSize.height() + 4); maxpmw = qMax(maxpmw, iconSize.width()); - } else { + } else +#endif + { int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4); } @@ -6743,6 +6848,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, w += maxpmw + 6; // add space for a check. All items have place for a check too. w += 20; +#ifndef QT_NO_COMBOBOX if (comboBox && comboBox->isVisible()) { QStyleOptionComboBox cmb; cmb.initFrom(comboBox); @@ -6752,7 +6858,9 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, w = qMax(w, subControlRect(QStyle::CC_ComboBox, &cmb, QStyle::SC_ComboBoxEditField, comboBox).width()); - } else { + } else +#endif + { w += 12; } sz = QSize(w, h); diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index f073f1cccb..583385ee8a 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -391,9 +391,11 @@ void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rec QColor backgroundColor(const QPalette &pal, const QWidget* widget) { +#ifndef QT_NO_SCROLLBAR if (qobject_cast<const QScrollBar *>(widget) && widget->parent() && qobject_cast<const QAbstractScrollArea *>(widget->parent()->parent())) return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base); +#endif return pal.color(QPalette::Base); } diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index c5904a5a96..690524b64b 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -210,7 +210,7 @@ enum PseudoElement { struct PseudoElementInfo { QStyle::SubControl subControl; - const char *name; + const char name[19]; }; static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = { @@ -595,7 +595,7 @@ public: Q_DECLARE_TYPEINFO(QRenderRule, Q_MOVABLE_TYPE); /////////////////////////////////////////////////////////////////////////////////////////// -static const char *const knownStyleHints[] = { +static const char knownStyleHints[][45] = { "activate-on-singleclick", "alignment", "arrow-keys-navigate-into-children", @@ -1002,15 +1002,17 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject } } - if (const QWidget *widget = qobject_cast<const QWidget *>(object)) { - QStyleSheetStyle *style = const_cast<QStyleSheetStyle *>(globalStyleSheetStyle); - if (!style) - style = qobject_cast<QStyleSheetStyle *>(widget->style()); - if (style) - fixupBorder(style->nativeFrameWidth(widget)); + if (hasBorder()) { + if (const QWidget *widget = qobject_cast<const QWidget *>(object)) { + QStyleSheetStyle *style = const_cast<QStyleSheetStyle *>(globalStyleSheetStyle); + if (!style) + style = qobject_cast<QStyleSheetStyle *>(widget->style()); + if (style) + fixupBorder(style->nativeFrameWidth(widget)); + } + if (border()->hasBorderImage()) + defaultBackground = QBrush(); } - if (hasBorder() && border()->hasBorderImage()) - defaultBackground = QBrush(); } QRect QRenderRule::borderRect(const QRect& r) const diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index c2cce5770f..bf5aad0187 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1175,9 +1175,9 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption case CE_MenuItem: if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { // windows always has a check column, regardless whether we have an icon or not - const qreal devicePixelRatio = QWindowsXPStylePrivate::devicePixelRatio(widget); - int checkcol = qRound(qreal(25) / devicePixelRatio); - const int gutterWidth = qRound(qreal(3) / devicePixelRatio); + const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget); + int checkcol = qRound(qreal(25) * factor); + const int gutterWidth = qRound(qreal(3) * factor); { XPThemeData theme(widget, 0, QWindowsXPStylePrivate::MenuTheme, MENU_POPUPCHECKBACKGROUND, MBI_HOT); @@ -2158,8 +2158,9 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt const bool isToolTitle = false; const int height = tb->rect.height(); const int width = tb->rect.width(); - int buttonWidth = GetSystemMetrics(SM_CXSIZE) / QWindowsStylePrivate::devicePixelRatio(widget) - - int(QStyleHelper::dpiScaled(4)); + const int buttonWidth = + qRound(qreal(GetSystemMetrics(SM_CXSIZE)) * QWindowsStylePrivate::nativeMetricScaleFactor(widget) + - QStyleHelper::dpiScaled(4)); const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget); const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0; diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index f3a8544d96..9d764d2a41 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -1923,7 +1923,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op themeNumber = QWindowsXPStylePrivate::StatusTheme; partId = SP_GRIPPER; XPThemeData theme(0, p, themeNumber, partId, 0); - QSize size = (theme.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); + QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); size.rheight()--; if (const QStyleOptionSizeGrip *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(option)) { switch (sg->corner) { @@ -1994,7 +1994,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op QWindowsXPStylePrivate::ToolBarTheme, TP_SPLITBUTTONDROPDOWN); if (theme.isValid()) { - const QSize size = (theme.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); + const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); mbiw = size.width(); mbih = size.height(); } @@ -2457,10 +2457,11 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme) { const bool horizontal = flags & QStyle::State_Horizontal; - const QMargins contentsMargin = (theme->margins(theme->rect, TMT_SIZINGMARGINS) - / QWindowsStylePrivate::devicePixelRatio(widget)).toMargins(); + const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(widget); + const QMargins contentsMargin = + (theme->margins(theme->rect, TMT_SIZINGMARGINS) * factor).toMargins(); theme->partId = horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT; - const QSize size = (theme->size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); + const QSize size = (theme->size() * factor).toSize(); const int hSpace = theme->rect.width() - size.width(); const int vSpace = theme->rect.height() - size.height(); @@ -3618,12 +3619,13 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt { XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL); if (buttontheme.isValid()) { - const qreal devicePixelRatio = QWindowsXPStylePrivate::devicePixelRatio(widget); - const QMarginsF borderSize = buttontheme.margins() / devicePixelRatio; + const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget); + const QMarginsF borderSize = buttontheme.margins() * factor; if (!borderSize.isNull()) { - const qreal margin = qreal(2) / devicePixelRatio; + const qreal margin = qreal(2) * factor; sz.rwidth() += qRound(borderSize.left() + borderSize.right() - margin); - sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin + devicePixelRatio - 1); + sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin + + qreal(1) / factor - 1); } const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1); sz += QSize(qMax(pixelMetric(QStyle::PM_ScrollBarExtent, option, widget) @@ -3897,7 +3899,7 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon, XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme, WP_RESTOREBUTTON, RBS_NORMAL); if (theme.isValid()) { - const QSize size = (themeSize.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); + const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); QPixmap pm(size); pm.fill(Qt::transparent); QPainter p(&pm); diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index d04ee24861..c0bd8bce5a 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -1100,6 +1100,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e) break; } default: +#ifndef QT_NO_SHORTCUT if (e->matches(QKeySequence::Cancel) && d->down) { setDown(false); repaint(); //flush paint event before invoking potentially expensive operation @@ -1107,6 +1108,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e) d->emitReleased(); return; } +#endif e->ignore(); } } diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 5778d16456..494e30c7c7 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1089,6 +1089,8 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event) } d->edit->event(event); + if (!d->edit->text().isEmpty()) + d->cleared = false; if (!isVisible()) d->ignoreUpdateEdit = true; } diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index b02651767c..ecd85c2ca7 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -202,10 +202,13 @@ bool QAlphaWidget::eventFilter(QObject *o, QEvent *e) render(); break; case QEvent::KeyPress: { +#ifndef QT_NO_SHORTCUT QKeyEvent *ke = (QKeyEvent*)e; if (ke->matches(QKeySequence::Cancel)) { showWidget = false; - } else { + } else +#endif + { duration = 0; } render(); diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 5cea9a9ea2..ed67446261 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1435,12 +1435,6 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) \warning To make QMenu visible on the screen, exec() or popup() should be used instead of show(). - \section1 QMenu on Qt for Windows CE - - If a menu is integrated into the native menubar on Windows Mobile we - do not support the signals: aboutToHide (), aboutToShow () and hovered (). - It is not possible to display an icon in a native menu on Windows Mobile. - \section1 QMenu on \macos with Qt Build Against Cocoa QMenu can be inserted only once in a menu/menubar. Subsequent insertions will @@ -2731,7 +2725,10 @@ QMenu::event(QEvent *e) if (kev->key() == Qt::Key_Up || kev->key() == Qt::Key_Down || kev->key() == Qt::Key_Left || kev->key() == Qt::Key_Right || kev->key() == Qt::Key_Enter || kev->key() == Qt::Key_Return - || kev->matches(QKeySequence::Cancel)) { +#ifndef QT_NO_SHORTCUT + || kev->matches(QKeySequence::Cancel) +#endif + ) { e->accept(); return true; } @@ -3059,7 +3056,11 @@ void QMenu::keyPressEvent(QKeyEvent *e) key_consumed = false; } - if (!key_consumed && (e->matches(QKeySequence::Cancel) + if (!key_consumed && ( + false +#ifndef QT_NO_SHORTCUT + || e->matches(QKeySequence::Cancel) +#endif #ifdef QT_KEYPAD_NAVIGATION || e->key() == Qt::Key_Back #endif @@ -3275,7 +3276,9 @@ static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *i item->setIcon(QIcon()); } item->setVisible(action->isVisible()); +#ifndef QT_NO_SHORTCUT item->setShortcut(action->shortcut()); +#endif item->setCheckable(action->isCheckable()); item->setChecked(action->isChecked()); item->setHasExclusiveGroup(action->actionGroup() && action->actionGroup()->isExclusive()); diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 45b7b3091a..99fddee53d 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -662,18 +662,6 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti the application's bundle. See \l{Qt for macOS - Deployment} for more information. - \section1 QMenuBar on Windows CE - - QMenuBar on Windows CE is a wrapper for using the system-wide menu bar, - similar to the Mac. This feature is activated for Windows Mobile - and integrates QMenuBar with the native soft keys. The left soft - key can be controlled with QMenuBar::setDefaultAction() and the - right soft key can be used to access the menu bar. - - The hovered() signal is not supported for the native menu - integration. Also, it is not possible to display an icon in a - native menu on Windows Mobile. - \section1 Examples The \l{mainwindows/menus}{Menus} example shows how to use QMenuBar @@ -1113,11 +1101,13 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) key_consumed = false; } +#ifndef QT_NO_SHORTCUT if (!key_consumed && e->matches(QKeySequence::Cancel)) { d->setCurrentAction(0); d->setKeyboardMode(false); key_consumed = true; } +#endif if(!key_consumed && (!e->modifiers() || @@ -1425,6 +1415,7 @@ bool QMenuBar::event(QEvent *e) case QEvent::Show: d->_q_updateLayout(); break; +#ifndef QT_NO_SHORTCUT case QEvent::ShortcutOverride: { QKeyEvent *kev = static_cast<QKeyEvent*>(e); //we only filter out escape if there is a current action @@ -1434,8 +1425,7 @@ bool QMenuBar::event(QEvent *e) } } break; - - +#endif #ifndef QT_NO_WHATSTHIS case QEvent::QueryWhatsThis: e->setAccepted(d->whatsThis.size()); @@ -1793,10 +1783,9 @@ QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const \brief Whether or not a menubar will be used as a native menubar on platforms that support it \since 4.6 - This property specifies whether or not the menubar should be used as a native menubar on platforms - that support it. The currently supported platforms are \macos and Windows CE. On these platforms - if this property is \c true, the menubar is used in the native menubar and is not in the window of - its parent, if false the menubar remains in the window. On other platforms the value of this + This property specifies whether or not the menubar should be used as a native menubar on \macos. + If this property is \c true, the menubar is used in the native menubar and is not in the window of + its parent, if \c false the menubar remains in the window. On other platforms the value of this attribute has no effect. The default is to follow whether the Qt::AA_DontUseNativeMenuBar attribute |