diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-04-23 09:02:14 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-04-23 09:02:14 (GMT) |
commit | 429f29a305559313f92866ac19cf224ad1497b33 (patch) | |
tree | 8f8cc1dd5f6485d3282eec52c83a9fbeb71dd29e /src/gui/kernel | |
parent | 33afa6c1fbe230dec4eea435f9ad5d4141c128a8 (diff) | |
parent | be3916b7e4e8007394cbed40484ef6b696e90f2b (diff) | |
download | Qt-429f29a305559313f92866ac19cf224ad1497b33.zip Qt-429f29a305559313f92866ac19cf224ad1497b33.tar.gz Qt-429f29a305559313f92866ac19cf224ad1497b33.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into windows-7-multitouch
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/kernel.pri | 2 | ||||
-rw-r--r-- | src/gui/kernel/qaction.cpp | 47 | ||||
-rw-r--r-- | src/gui/kernel/qaction_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_x11.cpp | 24 | ||||
-rw-r--r-- | src/gui/kernel/qshortcut.cpp | 20 | ||||
-rw-r--r-- | src/gui/kernel/qshortcutmap.cpp | 11 | ||||
-rw-r--r-- | src/gui/kernel/qt_mac.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qt_x11_p.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_mac.mm | 93 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_p.h | 1 |
12 files changed, 129 insertions, 90 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index cb2b014..a1b982a 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -193,7 +193,7 @@ embedded { MENU_NIB.path = Resources MENU_NIB.version = Versions QMAKE_BUNDLE_DATA += MENU_NIB - RESOURCES += mac/maccursors.qrc + RESOURCES += mac/macresources.qrc LIBS += -framework AppKit } diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index c6addc1..921be22 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -136,25 +136,27 @@ void QActionPrivate::redoGrab(QShortcutMap &map) void QActionPrivate::redoGrabAlternate(QShortcutMap &map) { Q_Q(QAction); - foreach (int id, alternateShortcutIds) - if (id) + for (int i = 0; i < alternateShortcutIds.size(); ++i) + if (int id = alternateShortcutIds.at(i)) map.removeShortcut(id, q); alternateShortcutIds.clear(); if (alternateShortcuts.isEmpty()) return; - foreach (const QKeySequence& alternate, alternateShortcuts) { + for (int i = 0; i < alternateShortcuts.size(); ++i) { + const QKeySequence &alternate = alternateShortcuts.at(i); if (!alternate.isEmpty()) alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext)); else alternateShortcutIds.append(0); } + if (!enabled) { - foreach (int id, alternateShortcutIds) - map.setShortcutEnabled(false, id, q); + for (int i = 0; i < alternateShortcutIds.size(); ++i) + map.setShortcutEnabled(false, alternateShortcutIds.at(i), q); } if (!autorepeat) { - foreach (int id, alternateShortcutIds) - map.setShortcutAutoRepeat(false, id, q); + for (int i = 0; i < alternateShortcutIds.size(); ++i) + map.setShortcutAutoRepeat(false, alternateShortcutIds.at(i), q); } } @@ -163,10 +165,26 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) Q_Q(QAction); if (shortcutId) map.setShortcutEnabled(enable, shortcutId, q); - foreach (int id, alternateShortcutIds) - if (id) + for (int i = 0; i < alternateShortcutIds.size(); ++i) + if (int id = alternateShortcutIds.at(i)) map.setShortcutEnabled(enable, id, q); } + +void QActionPrivate::removeAll(QShortcutMap &map) +{ + Q_Q(QAction); + if (shortcutId) { + map.removeShortcut(shortcutId, q); + shortcutId = 0; + } + + for (int i = 0; i < alternateShortcutIds.size(); ++i) + if (int id = alternateShortcutIds.at(i)) + map.removeShortcut(id, q); + + alternateShortcutIds.clear(); +} + #endif // QT_NO_SHORTCUT @@ -615,8 +633,8 @@ QAction::~QAction() #ifndef QT_NO_SHORTCUT if (d->shortcutId && qApp) { qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); - foreach (int id, d->alternateShortcutIds) - qApp->d_func()->shortcutMap.removeShortcut(id, this); + for (int i = 0; i < d->alternateShortcutIds.size(); ++i) + qApp->d_func()->shortcutMap.removeShortcut(d->alternateShortcutIds.at(i), this); } #endif } @@ -1049,7 +1067,12 @@ void QAction::setVisible(bool b) d->visible = b; d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ; #ifndef QT_NO_SHORTCUT - d->setShortcutEnabled(d->enabled, qApp->d_func()->shortcutMap); + if (b) { + d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrabAlternate(qApp->d_func()->shortcutMap); + } else { + d->removeAll(qApp->d_func()->shortcutMap); + } #endif d->sendDataChanged(); } diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h index 0617ef5..a5b3731 100644 --- a/src/gui/kernel/qaction_p.h +++ b/src/gui/kernel/qaction_p.h @@ -111,6 +111,7 @@ public: void redoGrab(QShortcutMap &map); void redoGrabAlternate(QShortcutMap &map); void setShortcutEnabled(bool enable, QShortcutMap &map); + void removeAll(QShortcutMap &map); static QShortcutMap *globalMap; #endif // QT_NO_SHORTCUT diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 52d6a70..6755ffd 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -833,12 +833,13 @@ QApplication::QApplication(Display *dpy, int &argc, char **argv, #endif // Q_WS_X11 +extern void qInitDrawhelperAsm(); /*! + \fn void QApplicationPrivate::initialize() + Initializes the QApplication object, called from the constructors. */ -extern void qInitDrawhelperAsm(); - void QApplicationPrivate::initialize() { QWidgetPrivate::mapper = new QWidgetMapper; @@ -2101,8 +2102,8 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) if (that) QApplication::sendEvent(that->style(), &in); } + emit qApp->focusChanged(prev, focus_widget); } - emit qApp->focusChanged(prev, focus_widget); } } diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index b1270bc..4814f1a 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -294,6 +294,10 @@ static const char * x11_atomnames = { // XEMBED "_XEMBED\0" "_XEMBED_INFO\0" + + "Wacom Stylus\0" + "Wacom Cursor\0" + "Wacom Eraser\0" }; Q_GUI_EXPORT QX11Data *qt_x11Data = 0; @@ -1579,6 +1583,7 @@ static PtrWacomConfigOpenDevice ptrWacomConfigOpenDevice = 0; static PtrWacomConfigGetRawParam ptrWacomConfigGetRawParam = 0; static PtrWacomConfigCloseDevice ptrWacomConfigCloseDevice = 0; static PtrWacomConfigTerm ptrWacomConfigTerm = 0; +Q_GLOBAL_STATIC(QByteArray, wacomDeviceName) #endif #endif @@ -2350,13 +2355,6 @@ void qt_init(QApplicationPrivate *priv, int, XAxisInfoPtr a; XDevice *dev = 0; -#if !defined(Q_OS_IRIX) - // XFree86 divides a stylus and eraser into 2 devices, so we must do for both... - const QString XFREENAMESTYLUS = QLatin1String("stylus"); - const QString XFREENAMEPEN = QLatin1String("pen"); - const QString XFREENAMEERASER = QLatin1String("eraser"); -#endif - if (X11->ptrXListInputDevices) { devices = X11->ptrXListInputDevices(X11->display, &ndev); if (!devices) @@ -2371,18 +2369,19 @@ void qt_init(QApplicationPrivate *priv, int, gotStylus = false; gotEraser = false; - QString devName = QString::fromLocal8Bit(devs->name).toLower(); #if defined(Q_OS_IRIX) + QString devName = QString::fromLocal8Bit(devs->name).toLower(); if (devName == QLatin1String(WACOM_NAME)) { deviceType = QTabletEvent::Stylus; gotStylus = true; } #else - if (devName.startsWith(XFREENAMEPEN) - || devName.startsWith(XFREENAMESTYLUS)) { + if (devs->type == ATOM(XWacomStylus)) { deviceType = QTabletEvent::Stylus; + if (wacomDeviceName()->isEmpty()) + wacomDeviceName()->append(devs->name); gotStylus = true; - } else if (devName.startsWith(XFREENAMEERASER)) { + } else if (devs->type == ATOM(XWacomEraser)) { deviceType = QTabletEvent::XFreeEraser; gotEraser = true; } @@ -4515,8 +4514,7 @@ void fetchWacomToolId(int &deviceType, qint64 &serialId) WACOMCONFIG *config = ptrWacomConfigInit(X11->display, 0); if (config == 0) return; - const char *name = "stylus"; // TODO get this from the X config instead (users may have called it differently) - WACOMDEVICE *device = ptrWacomConfigOpenDevice (config, name); + WACOMDEVICE *device = ptrWacomConfigOpenDevice (config, wacomDeviceName()->constData()); if (device == 0) return; unsigned keys[1]; diff --git a/src/gui/kernel/qshortcut.cpp b/src/gui/kernel/qshortcut.cpp index 50b6e59..f3c93c6 100644 --- a/src/gui/kernel/qshortcut.cpp +++ b/src/gui/kernel/qshortcut.cpp @@ -385,19 +385,21 @@ bool QShortcut::event(QEvent *e) { Q_D(QShortcut); bool handled = false; - if (d->sc_enabled && e->type() == QEvent::Shortcut) { + if (e->type() == QEvent::Shortcut) { QShortcutEvent *se = static_cast<QShortcutEvent *>(e); if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){ + if (d->sc_enabled) { #ifndef QT_NO_WHATSTHIS - if (QWhatsThis::inWhatsThisMode()) { - QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis); - handled = true; - } else + if (QWhatsThis::inWhatsThisMode()) { + QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis); + handled = true; + } else #endif - if (se->isAmbiguous()) - emit activatedAmbiguously(); - else - emit activated(); + if (se->isAmbiguous()) + emit activatedAmbiguously(); + else + emit activated(); + } handled = true; } } diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index ed9654b..415d71e 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -359,8 +359,6 @@ bool QShortcutMap::tryShortcutEvent(QObject *o, QKeyEvent *e) else e->ignore(); - int identicalMatches = d->identicals.count(); - switch(result) { case QKeySequence::NoMatch: return stateWasAccepted; @@ -370,9 +368,8 @@ bool QShortcutMap::tryShortcutEvent(QObject *o, QKeyEvent *e) default: break; } - // If nextState is QKeySequence::ExactMatch && identicals.count == 0 - // we've only found disabled shortcuts - return identicalMatches > 0 || result == QKeySequence::PartialMatch; + + return true; } /*! \internal @@ -494,9 +491,7 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e) // We don't need partials, if we have identicals if (d->identicals.size()) break; - // We only care about enabled partials, so we don't consume - // key events when all partials are disabled! - partialFound |= (*it).enabled; + partialFound = true; } } ++it; diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp index b1247e8..44e10a8 100644 --- a/src/gui/kernel/qt_mac.cpp +++ b/src/gui/kernel/qt_mac.cpp @@ -131,7 +131,7 @@ QColor qcolorForTheme(ThemeBrush brush) QColor qcolorForThemeTextColor(ThemeTextColor themeColor) { -#ifdef QT_OS_MAC32 +#ifdef Q_OS_MAC32 RGBColor c; GetThemeTextColor(themeColor, 32, true, &c); QColor color = QColor(c.red / 265, c.green / 256, c.blue / 256); diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index 563b7e9..b9ace9d 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -652,6 +652,10 @@ struct QX11Data _XEMBED, _XEMBED_INFO, + XWacomStylus, + XWacomCursor, + XWacomEraser, + NPredefinedAtoms, _QT_SETTINGS_TIMESTAMP = NPredefinedAtoms, diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 3e25ffc..9f5f18d 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2234,9 +2234,10 @@ WId QWidget::effectiveWinId() const The style sheet contains a textual description of customizations to the widget's style, as described in the \l{Qt Style Sheets} document. - \note Qt style sheets are currently not supported for QMacStyle - (the default style on Mac OS X). We plan to address this in some future - release. + Since Qt 4.5, Qt style sheets fully supports Mac OS X. + + \warning Qt style sheets are currently not supported for custom QStyle + subclasses. We plan to address this in some future release. \sa setStyle(), QApplication::styleSheet, {Qt Style Sheets} */ diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index ec05f12..0f74c32 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3995,6 +3995,33 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect) } } +void QWidgetPrivate::applyMaxAndMinSizeConstraints(int &w, int &h) +{ + if (QWExtra *extra = extraData()) { + w = qMin(w, extra->maxw); + h = qMin(h, extra->maxh); + w = qMax(w, extra->minw); + h = qMax(h, extra->minh); + + // Deal with size increment + if (QTLWExtra *top = topData()) { + if(top->incw) { + w = w/top->incw; + w *= top->incw; + } + if(top->inch) { + h = h/top->inch; + h *= top->inch; + } + } + } + + if (isRealWindow()) { + w = qMax(0, w); + h = qMax(0, h); + } +} + void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) { Q_Q(QWidget); @@ -4005,7 +4032,9 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) QMacCocoaAutoReleasePool pool; bool realWindow = isRealWindow(); + if (realWindow && !(w == 0 && h == 0) && !q->testAttribute(Qt::WA_DontShowOnScreen)) { + applyMaxAndMinSizeConstraints(w, h); topData()->isSetGeometry = 1; topData()->isMove = isMove; #ifndef QT_MAC_USE_COCOA @@ -4031,10 +4060,26 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM { Q_Q(QWidget); bool realWindow = isRealWindow(); - if(QWExtra *extra = extraData()) { // any size restrictions? - if(realWindow) { + + QPoint oldp = q->pos(); + QSize olds = q->size(); + const bool isResize = (olds != QSize(w, h)); + + if (!realWindow && !isResize && QPoint(x, y) == oldp) + return; + + if (isResize) + data.window_state = data.window_state & ~Qt::WindowMaximized; + + const bool visible = q->isVisible(); + data.crect = QRect(x, y, w, h); + + if (realWindow) { + if (QWExtra *extra = extraData()) { + applyMaxAndMinSizeConstraints(w, h); qt_mac_update_sizer(q); - if(q->windowFlags() & Qt::WindowMaximizeButtonHint) { + + if (q->windowFlags() & Qt::WindowMaximizeButtonHint) { #ifndef QT_MAC_USE_COCOA OSWindowRef window = qt_mac_window_for(q); if(extra->maxw && extra->maxh && extra->maxw == extra->minw @@ -4045,43 +4090,8 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM } #endif } - } - - w = qMin(w,extra->maxw); - h = qMin(h,extra->maxh); - w = qMax(w,extra->minw); - h = qMax(h,extra->minh); - - // Deal with size increment - if(QTLWExtra *top = topData()) { - if(top->incw) { - w = w/top->incw; - w *= top->incw; - } - if(top->inch) { - h = h/top->inch; - h *= top->inch; - } - } - } - if (realWindow) { - w = qMax(0, w); - h = qMax(0, h); - } - - QPoint oldp = q->pos(); - QSize olds = q->size(); - const bool isResize = (olds != QSize(w, h)); - if(!realWindow && !isResize && QPoint(x, y) == oldp) - return; - if(isResize && q->isMaximized()) - data.window_state = data.window_state & ~Qt::WindowMaximized; - const bool visible = q->isVisible(); - data.crect = QRect(x, y, w, h); - - if(realWindow) { - if(QWExtra *extra = extraData()) { //set constraints + // Update max and min constraints: const float max_f(20000); #ifndef QT_MAC_USE_COCOA #define SF(x) ((x > max_f) ? max_f : x) @@ -4612,8 +4622,11 @@ void QWidgetPrivate::setModal_sys() if (windowParent && q->windowModality() == Qt::WindowModal){ // Window should be window-modal, which implies a sheet. - if (!alreadySheet) + if (!alreadySheet) { + // NB: the following call will call setModal_sys recursivly: recreateMacWindow(); + windowRef = qt_mac_window_for(q); + } if ([windowRef isKindOfClass:[NSPanel class]]){ // If the primary window of the sheet parent is a child of a modal dialog, // the sheet parent should not be modally shaddowed. diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 9e93f66..423e833 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -257,6 +257,7 @@ public: void macUpdateIsOpaque(); void setEnabled_helper_sys(bool enable); bool isRealWindow() const; + void applyMaxAndMinSizeConstraints(int &w, int &h); #endif void raise_sys(); |