summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2010-02-12 14:55:11 (GMT)
committeraxis <qt-info@nokia.com>2010-02-12 14:55:11 (GMT)
commit0a3fef019630a7a49fdca28b3e507400bf4dec19 (patch)
tree50fbc7b6303787fa3ef9eac363aa6fe53397c5e7 /src/gui/kernel
parent12b5471062a52f6745f4309568b4c27c5e12d91f (diff)
parent01245bcabf97dfdfdd23a2ec075b8de3e78bdeb2 (diff)
downloadQt-0a3fef019630a7a49fdca28b3e507400bf4dec19.zip
Qt-0a3fef019630a7a49fdca28b3e507400bf4dec19.tar.gz
Qt-0a3fef019630a7a49fdca28b3e507400bf4dec19.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt
Conflicts: mkspecs/common/symbian/symbian.conf qmake/generators/makefile.cpp qmake/generators/symbian/symmake.cpp src/3rdparty/webkit/WebCore/WebCore.pro Conflict resolution was heavily based on manual application of commit 9cc4ae77a73bd28ff495f36f26dd87c78b76b976.
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri53
-rw-r--r--src/gui/kernel/qaction.cpp4
-rw-r--r--src/gui/kernel/qapplication.cpp4
-rw-r--r--src/gui/kernel/qapplication_mac.mm48
-rw-r--r--src/gui/kernel/qapplication_p.h2
-rw-r--r--src/gui/kernel/qapplication_s60.cpp31
-rw-r--r--src/gui/kernel/qapplication_win.cpp28
-rw-r--r--src/gui/kernel/qapplication_x11.cpp8
-rw-r--r--src/gui/kernel/qclipboard_mac.cpp12
-rw-r--r--src/gui/kernel/qclipboard_s60.cpp3
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac.mm6
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac_p.h1
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm3
-rw-r--r--src/gui/kernel/qcocoasharedwindowmethods_mac_p.h20
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm16
-rw-r--r--src/gui/kernel/qcocoawindow_mac_p.h3
-rw-r--r--src/gui/kernel/qdesktopwidget_s60.cpp18
-rw-r--r--src/gui/kernel/qdnd_x11.cpp2
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm2
-rw-r--r--src/gui/kernel/qkeymapper_x11.cpp14
-rw-r--r--src/gui/kernel/qmime_mac.cpp4
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp209
-rw-r--r--src/gui/kernel/qsoftkeymanager_common_p.h82
-rw-r--r--src/gui/kernel/qsoftkeymanager_p.h22
-rw-r--r--src/gui/kernel/qsoftkeymanager_s60.cpp404
-rw-r--r--src/gui/kernel/qsoftkeymanager_s60_p.h111
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm18
-rw-r--r--src/gui/kernel/qt_s60_p.h6
-rw-r--r--src/gui/kernel/qwidget.cpp33
-rw-r--r--src/gui/kernel/qwidget_mac.mm23
-rw-r--r--src/gui/kernel/qwidget_p.h5
-rw-r--r--src/gui/kernel/qwidget_s60.cpp114
-rw-r--r--src/gui/kernel/qwidget_x11.cpp77
33 files changed, 1044 insertions, 342 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index f2bd288..0993b86 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -7,7 +7,7 @@ PRECOMPILED_HEADER = kernel/qt_gui_pch.h
KERNEL_P= kernel
HEADERS += \
kernel/qaction.h \
- kernel/qaction_p.h \
+ kernel/qaction_p.h \
kernel/qactiongroup.h \
kernel/qapplication.h \
kernel/qapplication_p.h \
@@ -37,8 +37,8 @@ HEADERS += \
kernel/qstackedlayout.h \
kernel/qtooltip.h \
kernel/qwhatsthis.h \
- kernel/qwidget.h \
- kernel/qwidget_p.h \
+ kernel/qwidget.h \
+ kernel/qwidget_p.h \
kernel/qwidgetaction.h \
kernel/qwidgetaction_p.h \
kernel/qwindowdefs.h \
@@ -49,6 +49,7 @@ HEADERS += \
kernel/qgesturerecognizer.h \
kernel/qgesturemanager_p.h \
kernel/qsoftkeymanager_p.h \
+ kernel/qsoftkeymanager_common_p.h \
kernel/qguiplatformplugin_p.h
SOURCES += \
@@ -84,14 +85,14 @@ SOURCES += \
kernel/qgesturerecognizer.cpp \
kernel/qgesturemanager.cpp \
kernel/qsoftkeymanager.cpp \
- kernel/qdesktopwidget.cpp \
+ kernel/qdesktopwidget.cpp \
kernel/qguiplatformplugin.cpp
win32 {
DEFINES += QT_NO_DIRECTDRAW
- HEADERS += \
- kernel/qwinnativepangesturerecognizer_win_p.h
+ HEADERS += \
+ kernel/qwinnativepangesturerecognizer_win_p.h
SOURCES += \
kernel/qapplication_win.cpp \
@@ -103,30 +104,34 @@ win32 {
kernel/qsound_win.cpp \
kernel/qwidget_win.cpp \
kernel/qole_win.cpp \
- kernel/qkeymapper_win.cpp \
- kernel/qwinnativepangesturerecognizer_win.cpp
+ kernel/qkeymapper_win.cpp \
+ kernel/qwinnativepangesturerecognizer_win.cpp
- !contains(DEFINES, QT_NO_DIRECTDRAW):LIBS += ddraw.lib
+ !contains(DEFINES, QT_NO_DIRECTDRAW):LIBS += ddraw.lib
}
symbian {
- SOURCES += \
- kernel/qapplication_s60.cpp \
- kernel/qeventdispatcher_s60.cpp \
- kernel/qwidget_s60.cpp \
- kernel/qcursor_s60.cpp \
- kernel/qdesktopwidget_s60.cpp \
- kernel/qkeymapper_s60.cpp\
- kernel/qclipboard_s60.cpp\
- kernel/qdnd_s60.cpp \
- kernel/qsound_s60.cpp
+ SOURCES += \
+ kernel/qapplication_s60.cpp \
+ kernel/qeventdispatcher_s60.cpp \
+ kernel/qwidget_s60.cpp \
+ kernel/qcursor_s60.cpp \
+ kernel/qdesktopwidget_s60.cpp \
+ kernel/qkeymapper_s60.cpp\
+ kernel/qclipboard_s60.cpp\
+ kernel/qdnd_s60.cpp \
+ kernel/qsound_s60.cpp \
+ kernel/qsoftkeymanager_s60.cpp
- HEADERS += \
- kernel/qt_s60_p.h \
- kernel/qeventdispatcher_s60_p.h
- LIBS += -lbafl -lestor
+ HEADERS += \
+ kernel/qt_s60_p.h \
+ kernel/qeventdispatcher_s60_p.h \
+ kernel/qsoftkeymanager_s60_p.h
+
+ LIBS += -lbafl -lestor
- INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+ INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+ INCLUDEPATH += ../3rdparty/s60
}
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index 4b7d949..8ddd051 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -715,6 +715,10 @@ QActionGroup *QAction::actionGroup() const
it is displayed to the left of the menu text. There is no default
icon.
+ On Symbian the icons which are passed to softkeys, i.e. to actions with
+ softkey role, need to have pixmap alpha channel correctly set otherwise
+ drawing artifacts will appear when softkey is pressed down.
+
If a null icon (QIcon::isNull() is passed into this function,
the icon of the action is cleared.
*/
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 12fe797..4fe3900 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -121,8 +121,10 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
static void initResources()
{
-#ifdef Q_WS_WINCE
+#if defined(Q_WS_WINCE)
Q_INIT_RESOURCE(qstyle_wince);
+#elif defined(Q_OS_SYMBIAN)
+ Q_INIT_RESOURCE(qstyle_s60);
#else
Q_INIT_RESOURCE(qstyle);
#endif
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index 6aebef5..54a4901 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -227,8 +227,29 @@ void onApplicationChangedActivation( bool activated );
static void qt_mac_read_fontsmoothing_settings()
{
- NSInteger appleFontSmoothing = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleFontSmoothing"];
- qt_applefontsmoothing_enabled = (appleFontSmoothing > 0);
+ qt_applefontsmoothing_enabled = true;
+ int w = 10, h = 10;
+ QImage image(w, h, QImage::Format_RGB32);
+ image.fill(0xffffffff);
+ QPainter p(&image);
+ p.drawText(0, h, "X\\");
+ p.end();
+
+ const int *bits = (const int *) ((const QImage &) image).bits();
+ int bpl = image.bytesPerLine() / 4;
+ for (int y=0; y<w; ++y) {
+ for (int x=0; x<h; ++x) {
+ int r = qRed(bits[x]);
+ int g = qGreen(bits[x]);
+ int b = qBlue(bits[x]);
+ if (r != g || r != b) {
+ qt_applefontsmoothing_enabled = true;
+ return;
+ }
+ }
+ bits += bpl;
+ }
+ qt_applefontsmoothing_enabled = false;
}
Q_GUI_EXPORT bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret) {
@@ -772,11 +793,11 @@ static void qt_mac_update_intersected_gl_widgets(QWidget *widget)
qt_post_window_change_event(glWidget);
it->lastUpdateWidget = widget;
} else if (it->lastUpdateWidget == widget) {
- // Update the gl wigets that the widget intersected the last time around,
- // and that we are not intersecting now. This prevents paint errors when the
+ // Update the gl wigets that the widget intersected the last time around,
+ // and that we are not intersecting now. This prevents paint errors when the
// intersecting widget leaves a gl widget.
qt_post_window_change_event(glWidget);
- it->lastUpdateWidget = 0;
+ it->lastUpdateWidget = 0;
}
}
#else
@@ -808,8 +829,8 @@ Q_GUI_EXPORT void qt_event_request_window_change(QWidget *widget)
// Post a kEventQtRequestWindowChange event. This event is semi-public,
// don't remove this line!
qt_event_request_window_change();
-
- // Post update request on gl widgets unconditionally.
+
+ // Post update request on gl widgets unconditionally.
if (qt_widget_private(widget)->isGLWidget == true) {
qt_post_window_change_event(widget);
return;
@@ -1214,8 +1235,6 @@ void qt_init(QApplicationPrivate *priv, int)
if (QApplication::desktopSettingsAware())
QApplicationPrivate::qt_mac_apply_settings();
- qt_mac_read_fontsmoothing_settings();
-
// Cocoa application delegate
#ifdef QT_MAC_USE_COCOA
NSApplication *cocoaApp = [NSApplication sharedApplication];
@@ -1253,6 +1272,7 @@ void qt_init(QApplicationPrivate *priv, int)
}
priv->native_modal_dialog_active = false;
+ qt_mac_read_fontsmoothing_settings();
}
void qt_release_apple_event_handler()
@@ -1705,7 +1725,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
// kEventMouseWheelMoved events if we dont eat this 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'.
+ // we try to detect when this happend by checking the 'compatibilityEvent'.
SInt32 mdelt = 0;
GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0,
sizeof(mdelt), 0, &mdelt);
@@ -2123,6 +2143,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
}
if (wheel_deltaX || wheel_deltaY) {
+#ifndef QT_NO_WHEELEVENT
if (wheel_deltaX) {
QWheelEvent qwe(plocal, p, wheel_deltaX, buttons, modifiers, Qt::Horizontal);
QApplication::sendSpontaneousEvent(widget, &qwe);
@@ -2145,6 +2166,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
handled_event = false;
}
}
+#endif // QT_NO_WHEELEVENT
} else {
#ifdef QMAC_SPEAK_TO_ME
const int speak_keys = Qt::AltModifier | Qt::ShiftModifier;
@@ -2576,7 +2598,7 @@ void QApplicationPrivate::closePopup(QWidget *popup)
if (QApplicationPrivate::popupWidgets->isEmpty()) { // this was the last popup
delete QApplicationPrivate::popupWidgets;
QApplicationPrivate::popupWidgets = 0;
-
+
// Special case for Tool windows: since they are activated and deactived together
// with a normal window they never become the QApplicationPrivate::active_window.
QWidget *appFocusWidget = QApplication::focusWidget();
@@ -2697,6 +2719,7 @@ int QApplication::keyboardInputInterval()
return QApplicationPrivate::keyboard_input_time;
}
+#ifndef QT_NO_WHEELEVENT
void QApplication::setWheelScrollLines(int n)
{
QApplicationPrivate::wheel_scroll_lines = n;
@@ -2706,6 +2729,7 @@ int QApplication::wheelScrollLines()
{
return QApplicationPrivate::wheel_scroll_lines;
}
+#endif
void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
{
@@ -2868,9 +2892,11 @@ bool QApplicationPrivate::qt_mac_apply_settings()
QApplication::cursorFlashTime()).toInt();
QApplication::setCursorFlashTime(num);
+#ifndef QT_NO_WHEELEVENT
num = settings.value(QLatin1String("wheelScrollLines"),
QApplication::wheelScrollLines()).toInt();
QApplication::setWheelScrollLines(num);
+#endif
QString colorspec = settings.value(QLatin1String("colorSpec"),
QVariant(QLatin1String("default"))).toString();
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 9c001ab..b3ec732 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -427,7 +427,9 @@ public:
static int cursor_flash_time;
static int mouse_double_click_time;
static int keyboard_input_time;
+#ifndef QT_NO_WHEELEVENT
static int wheel_scroll_lines;
+#endif
static bool animate_ui;
static bool animate_menu;
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index d9cf45d..cc12a65 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -809,12 +809,15 @@ TCoeInputCapabilities QSymbianControl::InputCapabilities() const
void QSymbianControl::Draw(const TRect& controlRect) const
{
// Set flag to avoid calling DrawNow in window surface
- QWExtra *extra = qwidget->d_func()->extraData();
- if (extra && !extra->inExpose) {
- extra->inExpose = true;
+ QWidget *window = qwidget->window();
+ Q_ASSERT(window);
+ QTLWExtra *topExtra = window->d_func()->maybeTopData();
+ Q_ASSERT(topExtra);
+ if (!topExtra->inExpose) {
+ topExtra->inExpose = true;
QRect exposeRect = qt_TRect2QRect(controlRect);
qwidget->d_func()->syncBackingStore(exposeRect);
- extra->inExpose = false;
+ topExtra->inExpose = false;
}
QWindowSurface *surface = qwidget->windowSurface();
@@ -924,8 +927,8 @@ void QSymbianControl::PositionChanged()
cr.moveTopLeft(newPos);
qwidget->data->crect = cr;
QTLWExtra *top = qwidget->d_func()->maybeTopData();
- if (top)
- top->normalGeometry = cr;
+ if (top && (qwidget->windowState() & (~Qt::WindowActive)) == Qt::WindowNoState)
+ top->normalGeometry.moveTopLeft(newPos);
if (qwidget->isVisible()) {
QMoveEvent e(newPos, oldPos);
qt_sendSpontaneousEvent(qwidget, &e);
@@ -960,15 +963,14 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
qwidget->d_func()->setWindowIcon_sys(true);
qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle());
#ifdef Q_WS_S60
- // If widget is fullscreen, hide status pane and button container
- // otherwise show them.
+ // If widget is fullscreen/minimized, hide status pane and button container otherwise show them.
CEikStatusPane* statusPane = S60->statusPane();
CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer();
- bool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen;
- if (statusPane && (bool)statusPane->IsVisible() == isFullscreen)
- statusPane->MakeVisible(!isFullscreen);
- if (buttonGroup && (bool)buttonGroup->IsVisible() == isFullscreen)
- buttonGroup->MakeVisible(!isFullscreen);
+ TBool visible = !(qwidget->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized));
+ if (statusPane)
+ statusPane->MakeVisible(visible);
+ if (buttonGroup)
+ buttonGroup->MakeVisible(visible);
#endif
} else if (QApplication::activeWindow() == qwidget->window()) {
if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) {
@@ -1649,6 +1651,9 @@ int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent
if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) {
delete w->d_func()->topData()->backingStore;
w->d_func()->topData()->backingStore = 0;
+ // In order to ensure that any resources used by the window surface
+ // are immediately freed, we flush the WSERV command buffer.
+ S60->wsSession().Flush();
} else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible)
&& !w->d_func()->maybeBackingStore()) {
w->d_func()->topData()->backingStore = new QWidgetBackingStore(w);
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 3355272..0a4869b 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -928,7 +928,11 @@ const QString qt_reg_winclass(QWidget *w) // register window class
uint style;
bool icon;
QString cname;
- if (flags & Qt::MSWindowsOwnDC) {
+ if (qt_widget_private(w)->isGLWidget) {
+ cname = QLatin1String("QGLWidget");
+ style = CS_DBLCLKS;
+ icon = true;
+ } else if (flags & Qt::MSWindowsOwnDC) {
cname = QLatin1String("QWidgetOwnDC");
style = CS_DBLCLKS;
#ifndef Q_WS_WINCE
@@ -1021,7 +1025,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
}
wc.hCursor = 0;
#ifndef Q_WS_WINCE
- wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
+ wc.hbrBackground = qt_widget_private(w)->isGLWidget ? 0 : (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
#else
wc.hbrBackground = 0;
#endif
@@ -3616,13 +3620,19 @@ bool QETWidget::translatePaintEvent(const MSG &msg)
return true;
setAttribute(Qt::WA_PendingUpdate, false);
- const QRegion dirtyInBackingStore(qt_dirtyRegion(this));
- // Make sure the invalidated region contains the region we're about to repaint.
- // BeginPaint will set the clip to the invalidated region and it is impossible
- // to enlarge it afterwards (only shrink it). Using GetDCEx is not suffient
- // as it may return an invalid context (especially on Windows Vista).
- if (!dirtyInBackingStore.isEmpty())
- InvalidateRgn(internalWinId(), dirtyInBackingStore.handle(), false);
+
+ if (d_func()->isGLWidget) {
+ if (d_func()->usesDoubleBufferedGLContext)
+ InvalidateRect(internalWinId(), 0, false);
+ } else {
+ const QRegion dirtyInBackingStore(qt_dirtyRegion(this));
+ // Make sure the invalidated region contains the region we're about to repaint.
+ // BeginPaint will set the clip to the invalidated region and it is impossible
+ // to enlarge it afterwards (only shrink it). Using GetDCEx is not suffient
+ // as it may return an invalid context (especially on Windows Vista).
+ if (!dirtyInBackingStore.isEmpty())
+ InvalidateRgn(internalWinId(), dirtyInBackingStore.handle(), false);
+ }
PAINTSTRUCT ps;
d_func()->hd = BeginPaint(internalWinId(), &ps);
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 2a1f655..afd927b 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -944,10 +944,12 @@ bool QApplicationPrivate::x11_apply_settings()
QApplication::cursorFlashTime()).toInt();
QApplication::setCursorFlashTime(num);
+#ifndef QT_NO_WHEELEVENT
num =
settings.value(QLatin1String("wheelScrollLines"),
QApplication::wheelScrollLines()).toInt();
QApplication::setWheelScrollLines(num);
+#endif
QString colorspec = settings.value(QLatin1String("colorSpec"),
QVariant(QLatin1String("default"))).toString();
@@ -4401,8 +4403,10 @@ bool QETWidget::translateWheelEvent(int global_x, int global_y, int delta,
QWidget* popup = qApp->activePopupWidget();
if (popup && window() != popup)
popup->close();
+#ifndef QT_NO_WHEELEVENT
QWheelEvent e(pos, globalPos, delta, buttons, modifiers, orient);
if (QApplication::sendSpontaneousEvent(widget, &e))
+#endif
return true;
}
@@ -4413,8 +4417,10 @@ bool QETWidget::translateWheelEvent(int global_x, int global_y, int delta,
QWidget* popup = qApp->activePopupWidget();
if (popup && widget != popup)
popup->hide();
+#ifndef QT_NO_WHEELEVENT
QWheelEvent e(pos, globalPos, delta, buttons, modifiers, orient);
if (QApplication::sendSpontaneousEvent(widget, &e))
+#endif
return true;
}
return false;
@@ -5313,6 +5319,7 @@ int QApplication::keyboardInputInterval()
return QApplicationPrivate::keyboard_input_time;
}
+#ifndef QT_NO_WHEELEVENT
void QApplication::setWheelScrollLines(int n)
{
QApplicationPrivate::wheel_scroll_lines = n;
@@ -5322,6 +5329,7 @@ int QApplication::wheelScrollLines()
{
return QApplicationPrivate::wheel_scroll_lines;
}
+#endif
void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
{
diff --git a/src/gui/kernel/qclipboard_mac.cpp b/src/gui/kernel/qclipboard_mac.cpp
index f3a971d..49a6cc8 100644
--- a/src/gui/kernel/qclipboard_mac.cpp
+++ b/src/gui/kernel/qclipboard_mac.cpp
@@ -388,6 +388,18 @@ QMacPasteboard::setMimeData(QMimeData *mime_src)
clear_helper();
QStringList formats = mime_src->formats();
+#ifdef QT_MAC_USE_COCOA
+ // QMimeData sub classes reimplementing the formats() might not expose the
+ // temporary "application/x-qt-mime-type-name" mimetype. So check the existence
+ // of this mime type while doing drag and drop.
+ QString dummyMimeType(QLatin1String("application/x-qt-mime-type-name"));
+ if (!formats.contains(dummyMimeType)) {
+ QByteArray dummyType = mime_src->data(dummyMimeType);
+ if (!dummyType.isEmpty()) {
+ formats.append(dummyMimeType);
+ }
+ }
+#endif
for(int f = 0; f < formats.size(); ++f) {
QString mimeType = formats.at(f);
for (QList<QMacPasteboardMime *>::Iterator it = availableConverters.begin(); it != availableConverters.end(); ++it) {
diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/gui/kernel/qclipboard_s60.cpp
index 71c355b..f07e066 100644
--- a/src/gui/kernel/qclipboard_s60.cpp
+++ b/src/gui/kernel/qclipboard_s60.cpp
@@ -164,7 +164,8 @@ void readFromStreamLX(QMimeData* aData,RReadStream& aStream)
TCardinality mimeTypeSize;
aStream >> mimeTypeSize;
HBufC* mimeTypeBuf = HBufC::NewLC(aStream,mimeTypeSize);
- QString mimeType = QString::fromUtf16(mimeTypeBuf->Des().Ptr(),mimeTypeBuf->Length());
+ QString mimeType = QString(reinterpret_cast<const QChar *>(mimeTypeBuf->Des().Ptr()),
+ mimeTypeBuf->Length());
CleanupStack::PopAndDestroy(mimeTypeBuf);
// mime data
TCardinality dataSize;
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm
index 9f90cec..18b3772 100644
--- a/src/gui/kernel/qcocoamenuloader_mac.mm
+++ b/src/gui/kernel/qcocoamenuloader_mac.mm
@@ -110,6 +110,12 @@ QT_USE_NAMESPACE
}
}
+- (void)removeActionsFromAppMenu
+{
+ for (NSMenuItem *item in [appMenu itemArray])
+ [item setTag:nil];
+}
+
- (void)dealloc
{
[lastAppSpecificItem release];
diff --git a/src/gui/kernel/qcocoamenuloader_mac_p.h b/src/gui/kernel/qcocoamenuloader_mac_p.h
index 432a7a6..81c136e 100644
--- a/src/gui/kernel/qcocoamenuloader_mac_p.h
+++ b/src/gui/kernel/qcocoamenuloader_mac_p.h
@@ -70,6 +70,7 @@
}
- (void)ensureAppMenuInMenu:(NSMenu *)menu;
+- (void)removeActionsFromAppMenu;
- (NSMenu *)applicationMenu;
- (NSMenu *)menu;
- (NSMenuItem *)quitMenuItem;
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm
index e535aac..5e24c84 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/gui/kernel/qcocoapanel_mac.mm
@@ -46,6 +46,9 @@
#import <private/qcocoawindowdelegate_mac_p.h>
#import <private/qcocoaview_mac_p.h>
#import <private/qcocoawindowcustomthemeframe_mac_p.h>
+#include <private/qapplication_p.h>
+#include <private/qbackingstore_p.h>
+
#include <QtGui/QWidget>
diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
index 1a265d0..d2b74d7 100644
--- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
@@ -51,6 +51,9 @@
NSPanel, while QCocoaWindow needs to inherit NSWindow rather than NSPanel).
****************************************************************************/
+// WARNING: Don't include any header files from within this file. Put them
+// directly into qcocoawindow_mac_p.h and qcocoapanel_mac_p.h
+
QT_BEGIN_NAMESPACE
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
@@ -185,3 +188,20 @@ QT_END_NAMESPACE
return [super frameViewClassForStyleMask:styleMask];
}
+- (void)displayIfNeeded
+{
+
+ QWidget *qwidget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
+ if (qwidget == 0) {
+ [super displayIfNeeded];
+ return;
+ }
+
+ if (QApplicationPrivate::graphicsSystem() != 0) {
+ if (QWidgetBackingStore *bs = qt_widget_private(qwidget)->maybeBackingStore())
+ bs->sync(qwidget, qwidget->rect());
+ }
+ [super displayIfNeeded];
+}
+
+
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index f61d2fe..ad64a91 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -520,10 +520,11 @@ extern "C" {
- (void)drawRect:(NSRect)aRect
{
if (QApplicationPrivate::graphicsSystem() != 0) {
- if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore())
- bs->markDirty(qwidget->rect(), qwidget);
- qwidgetprivate->syncBackingStore(qwidget->rect());
- return;
+ if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore()) {
+ // Drawing is handled on the window level
+ // See qcocoasharedwindowmethods_mac_p.
+ return;
+ }
}
CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
qwidgetprivate->hd = cg;
@@ -644,6 +645,8 @@ extern "C" {
- (void)mouseEntered:(NSEvent *)event
{
+ if (qwidgetprivate->data.in_destructor)
+ return;
QEvent enterEvent(QEvent::Enter);
NSPoint windowPoint = [event locationInWindow];
NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint];
@@ -825,6 +828,7 @@ extern "C" {
deltaZ = qBound(-120, int([theEvent deltaZ] * 10000), 120);
}
+#ifndef QT_NO_WHEELEVENT
if (deltaX != 0) {
QWheelEvent qwe(qlocal, qglobal, deltaX, buttons, keyMods, Qt::Horizontal);
qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
@@ -865,6 +869,8 @@ extern "C" {
wheelOK = qwe2.isAccepted();
}
}
+#endif //QT_NO_WHEELEVENT
+
if (!wheelOK) {
return [super scrollWheel:theEvent];
}
@@ -1401,7 +1407,7 @@ Qt::DropAction QDragManager::drag(QDrag *o)
// setup the data
QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacPasteboardMime::MIME_DND);
- dragPrivate()->data->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray());
+ dragPrivate()->data->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
dragBoard.setMimeData(dragPrivate()->data);
// create the image
diff --git a/src/gui/kernel/qcocoawindow_mac_p.h b/src/gui/kernel/qcocoawindow_mac_p.h
index c0d8252..0474882 100644
--- a/src/gui/kernel/qcocoawindow_mac_p.h
+++ b/src/gui/kernel/qcocoawindow_mac_p.h
@@ -53,6 +53,9 @@
#ifdef QT_MAC_USE_COCOA
#include "qmacdefines_mac.h"
#import <Cocoa/Cocoa.h>
+#include <private/qapplication_p.h>
+#include <private/qbackingstore_p.h>
+
enum { QtMacCustomizeWindow = 1 << 21 }; // This will one day be run over by
diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp
index 77745ea..84e3c5d 100644
--- a/src/gui/kernel/qdesktopwidget_s60.cpp
+++ b/src/gui/kernel/qdesktopwidget_s60.cpp
@@ -88,24 +88,20 @@ QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
void QDesktopWidgetPrivate::init(QDesktopWidget *that)
{
- int screenCount=0;
+// int screenCount=0;
- if (HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount) == KErrNone)
- QDesktopWidgetPrivate::screenCount = screenCount;
- else
- QDesktopWidgetPrivate::screenCount = 0;
+ // ### TODO: Implement proper multi-display support
+ QDesktopWidgetPrivate::screenCount = 1;
+// if (HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount) == KErrNone)
+// QDesktopWidgetPrivate::screenCount = screenCount;
+// else
+// QDesktopWidgetPrivate::screenCount = 0;
rects = new QVector<QRect>();
workrects = new QVector<QRect>();
rects->resize(QDesktopWidgetPrivate::screenCount);
workrects->resize(QDesktopWidgetPrivate::screenCount);
-
- // ### TODO: Implement proper multi-display support
- rects->resize(1);
- rects->replace(0, that->rect());
- workrects->resize(1);
- workrects->replace(0, that->rect());
}
void QDesktopWidgetPrivate::cleanup()
diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp
index edab6a0..33968bd 100644
--- a/src/gui/kernel/qdnd_x11.cpp
+++ b/src/gui/kernel/qdnd_x11.cpp
@@ -617,7 +617,7 @@ QVariant QX11Data::xdndMimeConvertToFormat(Atom a, const QByteArray &data, const
// so it should be safe to check that the second char is 0
// to verify that it is utf16
if (data.size() > 1 && data.at(1) == 0)
- return QString::fromUtf16(reinterpret_cast<const ushort *>(data.constData()),
+ return QString::fromRawData((const QChar *)data.constData(),
data.size() / 2).split(QLatin1Char('\n')).first().toLatin1();
}
}
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index eda75db..c7c7caf 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -569,7 +569,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
// in cocoa. [NSApp run] should be called at least once for any cocoa app.
if (NSModalSession session = d->currentModalSession()) {
QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
- while (!d->interrupt && [NSApp runModalSession:session] == NSRunContinuesResponse)
+ while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
qt_mac_waitForMoreModalSessionEvents();
if (!d->interrupt && session == d->currentModalSessionCached) {
// INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event
diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp
index 70574e7..4e6c847 100644
--- a/src/gui/kernel/qkeymapper_x11.cpp
+++ b/src/gui/kernel/qkeymapper_x11.cpp
@@ -360,6 +360,13 @@ QList<int> QKeyMapperPrivate::possibleKeysXKB(QKeyEvent *event)
if (code && code < 0xfffe)
code = QChar(code).toUpper().unicode();
+
+ if (code == Qt::Key_Tab && (baseModifiers & Qt::ShiftModifier)) {
+ // map shift+tab to shift+backtab
+ code = Qt::Key_Backtab;
+ text = QString();
+ }
+
if (code == baseCode)
continue;
@@ -448,6 +455,13 @@ QList<int> QKeyMapperPrivate::possibleKeysCore(QKeyEvent *event)
if (code && code < 0xfffe)
code = QChar(code).toUpper().unicode();
+
+ if (code == Qt::Key_Tab && (baseModifiers & Qt::ShiftModifier)) {
+ // map shift+tab to shift+backtab
+ code = Qt::Key_Backtab;
+ text = QString();
+ }
+
if (code == baseCode)
continue;
diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp
index 0431f2f..071f80d 100644
--- a/src/gui/kernel/qmime_mac.cpp
+++ b/src/gui/kernel/qmime_mac.cpp
@@ -431,8 +431,8 @@ QVariant QMacPasteboardMimeUnicodeText::convertToMime(const QString &mimetype, Q
firstData.size(), CFStringGetSystemEncoding(), false));
ret = QString(str);
} else if (flavor == QLatin1String("public.utf16-plain-text")) {
- ret = QString::fromUtf16(reinterpret_cast<const ushort *>(firstData.constData()),
- firstData.size() / sizeof(ushort));
+ ret = QString(reinterpret_cast<const QChar *>(firstData.constData()),
+ firstData.size() / sizeof(QChar));
} else {
qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mimetype));
}
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index 354f90b..6d108b0 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -41,34 +41,18 @@
#include "qapplication.h"
#include "qevent.h"
-#ifdef Q_WS_S60
-#include "qstyle.h"
-#include "private/qt_s60_p.h"
-#endif
+#include "qbitmap.h"
#include "private/qsoftkeymanager_p.h"
#include "private/qobject_p.h"
-
-#ifndef QT_NO_SOFTKEYMANAGER
-QT_BEGIN_NAMESPACE
+#include "private/qsoftkeymanager_common_p.h"
#ifdef Q_WS_S60
-static const int s60CommandStart = 6000;
+#include "private/qsoftkeymanager_s60_p.h"
#endif
-class QSoftKeyManagerPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QSoftKeyManager)
-
-public:
- static void updateSoftKeys_sys(const QList<QAction*> &softKeys);
-
-private:
- QHash<QAction*, Qt::Key> keyedActions;
- static QSoftKeyManager *self;
- static QWidget *softKeySource;
-};
+#ifndef QT_NO_SOFTKEYMANAGER
+QT_BEGIN_NAMESPACE
-QWidget *QSoftKeyManagerPrivate::softKeySource = 0;
QSoftKeyManager *QSoftKeyManagerPrivate::self = 0;
const char *QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
@@ -105,7 +89,12 @@ QSoftKeyManager *QSoftKeyManager::instance()
return QSoftKeyManagerPrivate::self;
}
-QSoftKeyManager::QSoftKeyManager() : QObject(*(new QSoftKeyManagerPrivate), 0)
+QSoftKeyManager::QSoftKeyManager() :
+#ifdef Q_WS_S60
+ QObject(*(new QSoftKeyManagerPrivateS60), 0)
+#else
+ QObject(*(new QSoftKeyManagerPrivate), 0)
+#endif
{
}
@@ -115,10 +104,11 @@ QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *act
QAction *action = new QAction(QSoftKeyManager::tr(text), actionWidget);
QAction::SoftKeyRole softKeyRole = QAction::NoSoftKey;
switch (standardKey) {
+ case MenuSoftKey: // FALL-THROUGH
+ action->setProperty(MENU_ACTION_PROPERTY, QVariant(true)); // TODO: can be refactored away to use _q_action_menubar
case OkSoftKey:
case SelectSoftKey:
case DoneSoftKey:
- case MenuSoftKey:
softKeyRole = QAction::PositiveSoftKey;
break;
case CancelSoftKey:
@@ -147,7 +137,7 @@ QAction *QSoftKeyManager::createKeyedAction(StandardSoftKey standardKey, Qt::Key
#endif //QT_NO_ACTION
}
-void QSoftKeyManager::cleanupHash(QObject* obj)
+void QSoftKeyManager::cleanupHash(QObject *obj)
{
Q_D(QSoftKeyManager);
QAction *action = qobject_cast<QAction*>(obj);
@@ -175,137 +165,78 @@ void QSoftKeyManager::updateSoftKeys()
QApplication::postEvent(QSoftKeyManager::instance(), event);
}
-bool QSoftKeyManager::event(QEvent *e)
+bool QSoftKeyManager::appendSoftkeys(const QWidget &source, int level)
{
-#ifndef QT_NO_ACTION
- if (e->type() == QEvent::UpdateSoftKeys) {
- QList<QAction*> softKeys;
- QWidget *source = QApplication::focusWidget();
- do {
- if (source) {
- QList<QAction*> actions = source->actions();
- for (int i = 0; i < actions.count(); ++i) {
- if (actions.at(i)->softKeyRole() != QAction::NoSoftKey)
- softKeys.append(actions.at(i));
- }
-
- QWidget *parent = source->parentWidget();
- if (parent && softKeys.isEmpty() && !source->isWindow())
- source = parent;
- else
- break;
- } else {
- source = QApplication::activeWindow();
- }
- } while (source);
-
- QSoftKeyManagerPrivate::softKeySource = source;
- QSoftKeyManagerPrivate::updateSoftKeys_sys(softKeys);
- return true;
+ Q_D(QSoftKeyManager);
+ bool ret = false;
+ QList<QAction*> actions = source.actions();
+ for (int i = 0; i < actions.count(); ++i) {
+ if (actions.at(i)->softKeyRole() != QAction::NoSoftKey) {
+ d->requestedSoftKeyActions.insert(level, actions.at(i));
+ ret = true;
+ }
}
-#endif //QT_NO_ACTION
- return false;
+ return ret;
}
-#ifdef Q_WS_S60
-void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList<QAction*> &softkeys)
+QWidget *QSoftKeyManager::softkeySource(QWidget *previousSource, bool& recursiveMerging)
{
- // lets not update softkeys if s60 native dialog or menu is shown
- if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)
- || CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog())
- return;
-
- CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer();
- nativeContainer->DrawableWindow()->SetOrdinalPosition(0);
- nativeContainer->DrawableWindow()->SetPointerCapturePriority(1); //keep softkeys available in modal dialog
- nativeContainer->DrawableWindow()->SetFaded(EFalse, RWindowTreeNode::EFadeIncludeChildren);
-
- int position = -1;
- bool needsExitButton = true;
- QT_TRAP_THROWING(
- //Using -1 instead of EAknSoftkeyEmpty to avoid flickering.
- nativeContainer->SetCommandL(0, -1, KNullDesC);
- nativeContainer->SetCommandL(2, -1, KNullDesC);
- );
-
- for (int index = 0; index < softkeys.count(); index++) {
- const QAction* softKeyAction = softkeys.at(index);
- switch (softKeyAction->softKeyRole()) {
- // Positive Actions on the LSK
- case QAction::PositiveSoftKey:
- position = 0;
- break;
- case QAction::SelectSoftKey:
- position = 0;
- break;
- // Negative Actions on the RSK
- case QAction::NegativeSoftKey:
- needsExitButton = false;
- position = 2;
- break;
- default:
- break;
- }
-
- int command = (softKeyAction->objectName().contains(QLatin1String("_q_menuSoftKeyAction")))
- ? EAknSoftkeyOptions
- : s60CommandStart + index;
-
- // _q_menuSoftKeyAction action is set to "invisible" and all invisible actions are by default
- // disabled. However we never want to dim options softkey, even it is set to "invisible"
- bool dimmed = (command == EAknSoftkeyOptions) ? false : !softKeyAction->isEnabled();
-
- if (position != -1) {
- const int underlineShortCut = QApplication::style()->styleHint(QStyle::SH_UnderlineShortcut);
- QString iconText = softKeyAction->iconText();
- TPtrC text = qt_QString2TPtrC( underlineShortCut ? softKeyAction->text() : iconText);
- QT_TRAP_THROWING(
- nativeContainer->SetCommandL(position, command, text);
- nativeContainer->DimCommand(command, dimmed);
- );
- }
+ Q_D(QSoftKeyManager);
+ QWidget *source = NULL;
+ if (!previousSource) {
+ // Initial source is primarily focuswidget and secondarily activeWindow
+ source = QApplication::focusWidget();
+ if (!source)
+ source = QApplication::activeWindow();
+ } else {
+ // Softkey merging is based on four criterias
+ // 1. Implicit merging is used whenever focus widget does not specify any softkeys
+ bool implicitMerging = d->requestedSoftKeyActions.isEmpty();
+ // 2. Explicit merging with parent is used whenever WA_MergeSoftkeys widget attribute is set
+ bool explicitMerging = previousSource->testAttribute(Qt::WA_MergeSoftkeys);
+ // 3. Explicit merging with all parents
+ recursiveMerging |= previousSource->testAttribute(Qt::WA_MergeSoftkeysRecursively);
+ // 4. Implicit and explicit merging always stops at window boundary
+ bool merging = (implicitMerging || explicitMerging || recursiveMerging) && !previousSource->isWindow();
+
+ source = merging ? previousSource->parentWidget() : NULL;
}
-
- const Qt::WindowType sourceWindowType = QSoftKeyManagerPrivate::softKeySource
- ? QSoftKeyManagerPrivate::softKeySource->window()->windowType()
- : Qt::Widget;
-
- 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
+ return source;
}
-bool QSoftKeyManager::handleCommand(int command)
+bool QSoftKeyManager::handleUpdateSoftKeys()
{
- if (command >= s60CommandStart && QSoftKeyManagerPrivate::softKeySource) {
- int index = command - s60CommandStart;
- const QList<QAction*>& softKeys = QSoftKeyManagerPrivate::softKeySource->actions();
- for (int i = 0, j = 0; i < softKeys.count(); ++i) {
- QAction *action = softKeys.at(i);
- if (action->softKeyRole() != QAction::NoSoftKey) {
- if (j == index) {
- QWidget *parent = action->parentWidget();
- if (parent && parent->isEnabled()) {
- action->activate(QAction::Trigger);
- return true;
- }
- }
- j++;
- }
+ Q_D(QSoftKeyManager);
+ int level = 0;
+ d->requestedSoftKeyActions.clear();
+ bool recursiveMerging = false;
+ QWidget *source = softkeySource(NULL, recursiveMerging);
+ do {
+ if (source) {
+ bool added = appendSoftkeys(*source, level);
+ source = softkeySource(source, recursiveMerging);
+ level = added ? ++level : level;
}
- }
+ } while (source);
- return false;
+ d->updateSoftKeys_sys();
+ return true;
}
-#else
-
-void QSoftKeyManagerPrivate::updateSoftKeys_sys(const QList<QAction*> &)
+bool QSoftKeyManager::event(QEvent *e)
{
+#ifndef QT_NO_ACTION
+ if (e->type() == QEvent::UpdateSoftKeys)
+ return handleUpdateSoftKeys();
+#endif //QT_NO_ACTION
+ return false;
}
+#ifdef Q_WS_S60
+bool QSoftKeyManager::handleCommand(int command)
+{
+ return static_cast<QSoftKeyManagerPrivateS60*>(QSoftKeyManager::instance()->d_func())->handleCommand(command);
+}
#endif
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qsoftkeymanager_common_p.h b/src/gui/kernel/qsoftkeymanager_common_p.h
new file mode 100644
index 0000000..460d0dc
--- /dev/null
+++ b/src/gui/kernel/qsoftkeymanager_common_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSOFTKEYMANAGER_COMMON_P_H
+#define QSOFTKEYMANAGER_COMMON_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_HEADER
+
+#ifndef QT_NO_SOFTKEYMANAGER
+
+QT_BEGIN_NAMESPACE
+
+class QSoftKeyManagerPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QSoftKeyManager)
+
+public:
+ virtual void updateSoftKeys_sys() {};
+
+protected:
+ static QSoftKeyManager *self;
+ QHash<QAction*, Qt::Key> keyedActions;
+ QMultiHash<int, QAction*> requestedSoftKeyActions;
+
+};
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_SOFTKEYMANAGER
+
+QT_END_HEADER
+
+#endif // QSOFTKEYMANAGER_COMMON_P_H \ No newline at end of file
diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h
index c901a29..ce902fe 100644
--- a/src/gui/kernel/qsoftkeymanager_p.h
+++ b/src/gui/kernel/qsoftkeymanager_p.h
@@ -63,6 +63,8 @@ QT_BEGIN_NAMESPACE
class QSoftKeyManagerPrivate;
+const char MENU_ACTION_PROPERTY[] = "_q_menuaction";
+
class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject
{
Q_OBJECT
@@ -79,26 +81,30 @@ public:
};
static void updateSoftKeys();
- static QAction *createAction(StandardSoftKey standardKey, QWidget *actionWidget);
- static QAction *createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget);
-
#ifdef Q_WS_S60
static bool handleCommand(int);
#endif
-private:
- QSoftKeyManager();
- static QSoftKeyManager *instance();
- static const char *standardSoftKeyText(StandardSoftKey standardKey);
+ static QAction *createAction(StandardSoftKey standardKey, QWidget *actionWidget);
+ static QAction *createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget);
protected:
bool event(QEvent *e);
- Q_DISABLE_COPY(QSoftKeyManager)
+private:
+ QSoftKeyManager();
+ static QSoftKeyManager *instance();
+ static const char *standardSoftKeyText(StandardSoftKey standardKey);
+ bool appendSoftkeys(const QWidget &source, int level);
+ QWidget *softkeySource(QWidget *previousSource, bool& recursiveMerging);
+ bool handleUpdateSoftKeys();
private Q_SLOTS:
void cleanupHash(QObject* obj);
void sendKeyEvent();
+
+private:
+ Q_DISABLE_COPY(QSoftKeyManager)
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp
new file mode 100644
index 0000000..af84a8f
--- /dev/null
+++ b/src/gui/kernel/qsoftkeymanager_s60.cpp
@@ -0,0 +1,404 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qapplication.h"
+#include "qevent.h"
+#include "qbitmap.h"
+#include "qstyle.h"
+#include "qmenubar.h"
+#include "private/qt_s60_p.h"
+#include "private/qmenu_p.h"
+#include "private/qsoftkeymanager_p.h"
+#include "private/qsoftkeymanager_s60_p.h"
+#include "private/qobject_p.h"
+#include <eiksoftkeyimage.h>
+#include <eikcmbut.h>
+
+#ifndef QT_NO_SOFTKEYMANAGER
+QT_BEGIN_NAMESPACE
+
+const int S60_COMMAND_START = 6000;
+const int LSK_POSITION = 0;
+const int MSK_POSITION = 3;
+const int RSK_POSITION = 2;
+
+QSoftKeyManagerPrivateS60::QSoftKeyManagerPrivateS60()
+{
+ cachedCbaIconSize[0] = QSize(0,0);
+ cachedCbaIconSize[1] = QSize(0,0);
+ cachedCbaIconSize[2] = QSize(0,0);
+ cachedCbaIconSize[3] = QSize(0,0);
+ skipNextUpdate = false;
+}
+
+bool QSoftKeyManagerPrivateS60::skipCbaUpdate()
+{
+ // lets not update softkeys if
+ // 1. We don't have application panes, i.e. cba
+ // 2. S60 native dialog or menu is shown
+ if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) ||
+ CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || skipNextUpdate) {
+ skipNextUpdate = false;
+ return true;
+ }
+ return false;
+}
+
+void QSoftKeyManagerPrivateS60::ensureCbaVisibilityAndResponsiviness(CEikButtonGroupContainer &cba)
+{
+ RDrawableWindow *cbaWindow = cba.DrawableWindow();
+ Q_ASSERT_X(cbaWindow, Q_FUNC_INFO, "Native CBA does not have window!");
+ // Make sure CBA is visible, i.e. CBA window is on top
+ cbaWindow->SetOrdinalPosition(0);
+ // Qt shares same CBA instance between top-level widgets,
+ // make sure we are not faded by underlying window.
+ cbaWindow->SetFaded(EFalse, RWindowTreeNode::EFadeIncludeChildren);
+ // Modal dialogs capture pointer events, but shared cba instance
+ // shall stay responsive. Raise pointer capture priority to keep
+ // softkeys responsive in modal dialogs
+ cbaWindow->SetPointerCapturePriority(1);
+}
+
+void QSoftKeyManagerPrivateS60::clearSoftkeys(CEikButtonGroupContainer &cba)
+{
+ QT_TRAP_THROWING(
+ //Using -1 instead of EAknSoftkeyEmpty to avoid flickering.
+ cba.SetCommandL(0, -1, KNullDesC);
+ // TODO: Should we clear also middle SK?
+ cba.SetCommandL(2, -1, KNullDesC);
+ );
+ realSoftKeyActions.clear();
+}
+
+QString QSoftKeyManagerPrivateS60::softkeyText(QAction &softkeyAction)
+{
+ // In S60 softkeys and menu items do not support key accelerators (i.e.
+ // CTRL+X). Therefore, removing the accelerator characters from both softkey
+ // and menu item texts.
+ const int underlineShortCut = QApplication::style()->styleHint(QStyle::SH_UnderlineShortcut);
+ QString iconText = softkeyAction.iconText();
+ return underlineShortCut ? softkeyAction.text() : iconText;
+}
+
+QAction *QSoftKeyManagerPrivateS60::highestPrioritySoftkey(QAction::SoftKeyRole role)
+{
+ QAction *ret = NULL;
+ // Priority look up is two level
+ // 1. First widget with softkeys always has highest priority
+ for (int level = 0; !ret; level++) {
+ // 2. Highest priority action within widget
+ QList<QAction*> actions = requestedSoftKeyActions.values(level);
+ if (actions.isEmpty())
+ break;
+ qSort(actions.begin(), actions.end(), QSoftKeyManagerPrivateS60::actionPriorityMoreThan);
+ foreach (QAction *action, actions) {
+ if (action->softKeyRole() == role) {
+ ret = action;
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
+bool QSoftKeyManagerPrivateS60::actionPriorityMoreThan(const QAction *firstItem, const QAction *secondItem)
+{
+ return firstItem->priority() > secondItem->priority();
+}
+
+void QSoftKeyManagerPrivateS60::setNativeSoftkey(CEikButtonGroupContainer &cba,
+ TInt position, TInt command, const TDesC &text)
+{
+ // Calling SetCommandL causes CBA redraw
+ QT_TRAP_THROWING(cba.SetCommandL(position, command, text));
+}
+
+QPoint QSoftKeyManagerPrivateS60::softkeyIconPosition(int position, QSize sourceSize, QSize targetSize)
+{
+ QPoint iconPosition(0,0);
+ switch( AknLayoutUtils::CbaLocation() )
+ {
+ case AknLayoutUtils::EAknCbaLocationBottom:
+ // RSK must be moved to right, LSK in on correct position by default
+ if (position == RSK_POSITION)
+ iconPosition.setX(targetSize.width() - sourceSize.width());
+ break;
+ case AknLayoutUtils::EAknCbaLocationRight:
+ case AknLayoutUtils::EAknCbaLocationLeft:
+ // Already in correct position
+ default:
+ break;
+ }
+
+ // Align horizontally to center
+ iconPosition.setY((targetSize.height() - sourceSize.height()) >> 1);
+ return iconPosition;
+}
+
+QPixmap QSoftKeyManagerPrivateS60::prepareSoftkeyPixmap(QPixmap src, int position, QSize targetSize)
+{
+ QPixmap target(targetSize);
+ target.fill(Qt::transparent);
+ QPainter p;
+ p.begin(&target);
+ p.drawPixmap(softkeyIconPosition(position, src.size(), targetSize), src);
+ p.end();
+ return target;
+}
+
+bool QSoftKeyManagerPrivateS60::isOrientationLandscape()
+{
+ // Hard to believe that there is no public API in S60 to
+ // get current orientation. This workaround works with currently supported resolutions
+ return S60->screenHeightInPixels < S60->screenWidthInPixels;
+}
+
+QSize QSoftKeyManagerPrivateS60::cbaIconSize(CEikButtonGroupContainer *cba, int position)
+{
+
+ int index = position;
+ index += isOrientationLandscape() ? 0 : 1;
+ if(cachedCbaIconSize[index].isNull()) {
+ // Only way I figured out to get CBA icon size without RnD SDK, was
+ // to set some dummy icon to CBA first and then ask CBA button CCoeControl::Size()
+ // The returned value is cached to avoid unnecessary icon setting every time.
+ const bool left = (position == LSK_POSITION);
+ if(position == LSK_POSITION || position == RSK_POSITION) {
+ CEikImage* tmpImage = NULL;
+ QT_TRAP_THROWING(tmpImage = new (ELeave) CEikImage);
+ EikSoftkeyImage::SetImage(cba, *tmpImage, left); // Takes myimage ownership
+ int command = S60_COMMAND_START + position;
+ setNativeSoftkey(*cba, position, command, KNullDesC());
+ cachedCbaIconSize[index] = qt_TSize2QSize(cba->ControlOrNull(command)->Size());
+ EikSoftkeyImage::SetLabel(cba, left);
+
+ if(cachedCbaIconSize[index] == QSize(138,72)) {
+ // Hack for S60 5.0 (5800) landscape orientation, which return wrong icon size
+ cachedCbaIconSize[index] = QSize(60,60);
+ }
+ }
+ }
+
+ return cachedCbaIconSize[index];
+}
+
+bool QSoftKeyManagerPrivateS60::setSoftkeyImage(CEikButtonGroupContainer *cba,
+ QAction &action, int position)
+{
+ bool ret = false;
+
+ const bool left = (position == LSK_POSITION);
+ if(position == LSK_POSITION || position == RSK_POSITION) {
+ QIcon icon = action.icon();
+ if (!icon.isNull()) {
+ // Get size of CBA icon area based on button position and orientation
+ QSize requiredIconSize = cbaIconSize(cba, position);
+ // Get pixmap out of icon based on preferred size, the aspect ratio is kept
+ QPixmap pmWihtAspectRatio = icon.pixmap(requiredIconSize);
+ // Native softkeys require that pixmap size is exactly the same as requiredIconSize
+ // prepareSoftkeyPixmap creates a new pixmap with requiredIconSize and blits the 'pmWihtAspectRatio'
+ // to correct location of it
+ QPixmap softkeyPixmap = prepareSoftkeyPixmap(pmWihtAspectRatio, position, requiredIconSize);
+
+ QPixmap softkeyAlpha = softkeyPixmap.alphaChannel();
+ // Alpha channel in 5.1 and older devices need to be inverted
+ // TODO: Switch to use toSymbianCFbsBitmap with invert when available
+ if(QSysInfo::s60Version() <= QSysInfo::SV_S60_5_1) {
+ QImage alphaImage = softkeyAlpha.toImage();
+ alphaImage.invertPixels();
+ softkeyAlpha = QPixmap::fromImage(alphaImage);
+ }
+
+ CFbsBitmap* nBitmap = softkeyPixmap.toSymbianCFbsBitmap();
+ CFbsBitmap* nMask = softkeyAlpha.toSymbianCFbsBitmap();
+
+ CEikImage* myimage = new (ELeave) CEikImage;
+ myimage->SetPicture( nBitmap, nMask ); // nBitmap and nMask ownership transfered
+
+ EikSoftkeyImage::SetImage(cba, *myimage, left); // Takes myimage ownership
+ ret = true;
+ } else {
+ // Restore softkey to text based
+ EikSoftkeyImage::SetLabel(cba, left);
+ }
+ }
+ return ret;
+}
+
+bool QSoftKeyManagerPrivateS60::setSoftkey(CEikButtonGroupContainer &cba,
+ QAction::SoftKeyRole role, int position)
+{
+ QAction *action = highestPrioritySoftkey(role);
+ if (action) {
+ setSoftkeyImage(&cba, *action, position);
+ QString text = softkeyText(*action);
+ TPtrC nativeText = qt_QString2TPtrC(text);
+ int command = S60_COMMAND_START + position;
+ setNativeSoftkey(cba, position, command, nativeText);
+ cba.DimCommand(command, !action->isEnabled());
+ realSoftKeyActions.insert(command, action);
+ return true;
+ }
+ return false;
+}
+
+bool QSoftKeyManagerPrivateS60::setLeftSoftkey(CEikButtonGroupContainer &cba)
+{
+ return setSoftkey(cba, QAction::PositiveSoftKey, LSK_POSITION);
+}
+
+bool QSoftKeyManagerPrivateS60::setMiddleSoftkey(CEikButtonGroupContainer &cba)
+{
+ // Note: In order to get MSK working, application has to have EAknEnableMSK flag set
+ // Currently it is not possible very easily)
+ // For more information see: http://wiki.forum.nokia.com/index.php/Middle_softkey_usage
+ return setSoftkey(cba, QAction::SelectSoftKey, MSK_POSITION);
+}
+
+bool QSoftKeyManagerPrivateS60::setRightSoftkey(CEikButtonGroupContainer &cba)
+{
+ if (!setSoftkey(cba, QAction::NegativeSoftKey, RSK_POSITION)) {
+ Qt::WindowType windowType = Qt::Window;
+ QAction *action = requestedSoftKeyActions.value(0);
+ if (action) {
+ QWidget *actionParent = action->parentWidget();
+ Q_ASSERT_X(actionParent, Q_FUNC_INFO, "No parent set for softkey action!");
+
+ QWidget *actionWindow = actionParent->window();
+ Q_ASSERT_X(actionWindow, Q_FUNC_INFO, "Softkey action does not have window!");
+ windowType = actionWindow->windowType();
+ }
+
+ if (windowType != Qt::Dialog && windowType != Qt::Popup) {
+ QString text(QSoftKeyManager::tr("Exit"));
+ TPtrC nativeText = qt_QString2TPtrC(text);
+ EikSoftkeyImage::SetLabel(&cba, false);
+ setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText);
+ return true;
+ }
+ }
+ return false;
+}
+
+void QSoftKeyManagerPrivateS60::setSoftkeys(CEikButtonGroupContainer &cba)
+{
+ int requestedSoftkeyCount = requestedSoftKeyActions.count();
+ const int maxSoftkeyCount = 2; // TODO: differs based on orientation ans S60 versions (some have MSK)
+ if (requestedSoftkeyCount > maxSoftkeyCount) {
+ // We have more softkeys than available slots
+ // Put highest priority negative action to RSK and Options menu with rest of softkey actions to LSK
+ // TODO: Build menu
+ setLeftSoftkey(cba);
+ if(AknLayoutUtils::MSKEnabled())
+ setMiddleSoftkey(cba);
+ setRightSoftkey(cba);
+ } else {
+ // We have less softkeys than available slots
+ // Put softkeys to request slots based on role
+ setLeftSoftkey(cba);
+ if(AknLayoutUtils::MSKEnabled())
+ setMiddleSoftkey(cba);
+ setRightSoftkey(cba);
+ }
+}
+
+void QSoftKeyManagerPrivateS60::updateSoftKeys_sys()
+{
+ if (skipCbaUpdate())
+ return;
+
+ CEikButtonGroupContainer *nativeContainer = S60->buttonGroupContainer();
+ Q_ASSERT_X(nativeContainer, Q_FUNC_INFO, "Native CBA does not exist!");
+ ensureCbaVisibilityAndResponsiviness(*nativeContainer);
+ clearSoftkeys(*nativeContainer);
+ setSoftkeys(*nativeContainer);
+
+ nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation
+}
+
+bool QSoftKeyManagerPrivateS60::handleCommand(int command)
+{
+ QAction *action = realSoftKeyActions.value(command);
+ if (action) {
+ QVariant property = action->property(MENU_ACTION_PROPERTY);
+ if (property.isValid() && property.toBool()) {
+ QT_TRAP_THROWING(S60->menuBar()->TryDisplayMenuBarL());
+ } else if (action->menu()) {
+ // TODO: This is hack, in order to use exising QMenuBar implementation for Symbian
+ // menubar needs to have widget to which it is associated. Since we want to associate
+ // menubar to action (which is inherited from QObejct), we create and associate QWidget
+ // to action and pass that for QMenuBar. This associates the menubar to action, and we
+ // can have own menubar for each action.
+ QWidget *actionContainer = action->property("_q_action_widget").value<QWidget*>();
+ if(!actionContainer) {
+ actionContainer = new QWidget(action->parentWidget());
+ QMenuBar *menuBar = new QMenuBar(actionContainer);
+ foreach(QAction *menuAction, action->menu()->actions()) {
+ QMenu *menu = menuAction->menu();
+ if(menu)
+ menuBar->addMenu(action->menu());
+ else
+ menuBar->addAction(menuAction);
+ }
+ QVariant v;
+ v.setValue(actionContainer);
+ action->setProperty("_q_action_widget", v);
+ }
+ qt_symbian_next_menu_from_action(actionContainer);
+ QT_TRAP_THROWING(S60->menuBar()->TryDisplayMenuBarL());
+ // TODO: hack remove, it can happen that IsDisplayingMenuOrDialog return false
+ // in updateSoftKeys_sys, and we will override menu CBA with our own
+ skipNextUpdate = true;
+ } else {
+ Q_ASSERT(action->softKeyRole() != QAction::NoSoftKey);
+ QWidget *actionParent = action->parentWidget();
+ Q_ASSERT_X(actionParent, Q_FUNC_INFO, "No parent set for softkey action!");
+ if (actionParent->isEnabled()) {
+ action->activate(QAction::Trigger);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+QT_END_NAMESPACE
+#endif //QT_NO_SOFTKEYMANAGER
diff --git a/src/gui/kernel/qsoftkeymanager_s60_p.h b/src/gui/kernel/qsoftkeymanager_s60_p.h
new file mode 100644
index 0000000..f8bd6d9
--- /dev/null
+++ b/src/gui/kernel/qsoftkeymanager_s60_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSOFTKEYMANAGER_S60_P_H
+#define QSOFTKEYMANAGER_S60_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qobject_p.h"
+#include "private/qsoftkeymanager_common_p.h"
+
+QT_BEGIN_HEADER
+
+#ifndef QT_NO_SOFTKEYMANAGER
+
+QT_BEGIN_NAMESPACE
+
+class CEikButtonGroupContainer;
+class QAction;
+
+class QSoftKeyManagerPrivateS60 : public QSoftKeyManagerPrivate
+{
+ Q_DECLARE_PUBLIC(QSoftKeyManager)
+
+public:
+ QSoftKeyManagerPrivateS60();
+
+public:
+ void updateSoftKeys_sys();
+ bool handleCommand(int command);
+
+private:
+ bool skipCbaUpdate();
+ void ensureCbaVisibilityAndResponsiviness(CEikButtonGroupContainer &cba);
+ void clearSoftkeys(CEikButtonGroupContainer &cba);
+ QString softkeyText(QAction &softkeyAction);
+ QAction *highestPrioritySoftkey(QAction::SoftKeyRole role);
+ static bool actionPriorityMoreThan(const QAction* item1, const QAction* item2);
+ void setNativeSoftkey(CEikButtonGroupContainer &cba, TInt position, TInt command, const TDesC& text);
+ QPoint softkeyIconPosition(int position, QSize sourceSize, QSize targetSize);
+ QPixmap prepareSoftkeyPixmap(QPixmap src, int position, QSize targetSize);
+ bool isOrientationLandscape();
+ QSize cbaIconSize(CEikButtonGroupContainer *cba, int position);
+ bool setSoftkeyImage(CEikButtonGroupContainer *cba, QAction &action, int position);
+ bool setSoftkey(CEikButtonGroupContainer &cba, QAction::SoftKeyRole role, int position);
+ bool setLeftSoftkey(CEikButtonGroupContainer &cba);
+ bool setMiddleSoftkey(CEikButtonGroupContainer &cba);
+ bool setRightSoftkey(CEikButtonGroupContainer &cba);
+ void setSoftkeys(CEikButtonGroupContainer &cba);
+
+private:
+ QHash<int, QAction*> realSoftKeyActions;
+ QSize cachedCbaIconSize[4];
+ bool skipNextUpdate;
+};
+
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_SOFTKEYMANAGER
+
+QT_END_HEADER
+
+#endif // QSOFTKEYMANAGER_S60_P_H
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index e36ab9b..65c04e5 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -143,6 +143,9 @@ extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds)
{
+#ifdef QT_MAC_USE_COCOA
+ QMacCocoaAutoReleasePool pool;
+#endif
OSWindowRef wnd = static_cast<OSWindowRef>(window);
if (wnd) {
QWidget *widget;
@@ -1159,7 +1162,7 @@ CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
QDBeginCGContext(port, &context);
#else
- CGContextRef context = (CGContextRef)[[NSGraphicsContext graphicsContextWithWindow:qt_mac_window_for(widget)] graphicsPort];
+ CGContextRef context = reinterpret_cast<CGContextRef>([[qt_mac_window_for(widget) graphicsContext] graphicsPort]);
#endif
return context;
}
@@ -1278,4 +1281,17 @@ void qt_cocoaChangeOverrideCursor(const QCursor &cursor)
}
#endif
+QMacCocoaAutoReleasePool::QMacCocoaAutoReleasePool()
+{
+#ifndef QT_MAC_USE_COCOA
+ NSApplicationLoad();
+#endif
+ pool = (void*)[[NSAutoreleasePool alloc] init];
+}
+
+QMacCocoaAutoReleasePool::~QMacCocoaAutoReleasePool()
+{
+ [(NSAutoreleasePool*)pool release];
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index 1163055..735ca7a 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -128,6 +128,7 @@ public:
static inline RWindowGroup& windowGroup();
static inline CWsScreenDevice* screenDevice();
static inline CCoeAppUi* appUi();
+ static inline CEikMenuBar* menuBar();
#ifdef Q_WS_S60
static inline CEikStatusPane* statusPane();
static inline CCoeControl* statusPaneSubPane(TInt aPaneId);
@@ -270,6 +271,11 @@ inline CCoeAppUi* QS60Data::appUi()
return CCoeEnv::Static()-> AppUi();
}
+inline CEikMenuBar* QS60Data::menuBar()
+{
+ return CEikonEnv::Static()->AppUiFactory()->MenuBar();
+}
+
#ifdef Q_WS_S60
inline CEikStatusPane* QS60Data::statusPane()
{
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index ede87de..2a19d23 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -192,6 +192,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
, inDirtyList(0)
, isScrolled(0)
, isMoved(0)
+ , isGLWidget(0)
, usesDoubleBufferedGLContext(0)
#if defined(Q_WS_X11)
, picture(0)
@@ -200,7 +201,6 @@ QWidgetPrivate::QWidgetPrivate(int version)
, nativeGesturePanEnabled(0)
#elif defined(Q_WS_MAC)
, needWindowChange(0)
- , isGLWidget(0)
, window_event(0)
, qd_hd(0)
#endif
@@ -1439,6 +1439,18 @@ QWidget::~QWidget()
}
#endif
+#ifdef Q_OS_SYMBIAN
+ if (d->extra && d->extra->topextra && d->extra->topextra->backingStore) {
+ // Okay, we are about to destroy the top-level window that owns
+ // the backing store. Make sure we delete the backing store right away
+ // before the window handle is invalid. This is important because
+ // the backing store will delete its window surface, which may or may
+ // not have a reference to this widget that will be used later to
+ // notify the window it no longer has a surface.
+ delete d->extra->topextra->backingStore;
+ d->extra->topextra->backingStore = 0;
+ }
+#endif
if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
bs->removeDirtyWidget(this);
if (testAttribute(Qt::WA_StaticContents))
@@ -1660,7 +1672,13 @@ void QWidgetPrivate::syncBackingStore()
repaint_sys(dirty);
dirty = QRegion();
} else if (QWidgetBackingStore *bs = maybeBackingStore()) {
+#ifdef QT_MAC_USE_COCOA
+ Q_UNUSED(bs);
+ void qt_mac_set_needs_display(QWidget *, QRegion);
+ qt_mac_set_needs_display(q_func(), QRegion());
+#else
bs->sync();
+#endif
}
}
@@ -1668,8 +1686,15 @@ void QWidgetPrivate::syncBackingStore(const QRegion &region)
{
if (paintOnScreen())
repaint_sys(region);
- else if (QWidgetBackingStore *bs = maybeBackingStore())
+ else if (QWidgetBackingStore *bs = maybeBackingStore()) {
+#ifdef QT_MAC_USE_COCOA
+ Q_UNUSED(bs);
+ void qt_mac_set_needs_display(QWidget *, QRegion);
+ qt_mac_set_needs_display(q_func(), region);
+#else
bs->sync(q_func(), region);
+#endif
+ }
}
void QWidgetPrivate::setUpdatesEnabled_helper(bool enable)
@@ -3352,7 +3377,7 @@ QPoint QWidget::pos() const
\note Setting the size to \c{QSize(0, 0)} will cause the widget to not
appear on screen. This also applies to windows.
- \sa pos, geometry, minimumSize, maximumSize, resizeEvent()
+ \sa pos, geometry, minimumSize, maximumSize, resizeEvent(), adjustSize()
*/
/*!
@@ -6414,6 +6439,8 @@ void QWidget::setTabOrder(QWidget* first, QWidget *second)
first = fp;
}
+ if (fp == second)
+ return;
if (QWidget *sp = second->focusProxy())
second = sp;
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 3dbc843..9e7517f 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -404,7 +404,7 @@ inline static void qt_mac_set_fullscreen_mode(bool b)
return;
qt_mac_app_fullscreen = b;
if (b) {
- SetSystemUIMode(kUIModeAllSuppressed, 0);
+ SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
} else {
SetSystemUIMode(kUIModeNormal, 0);
}
@@ -565,6 +565,25 @@ inline static void qt_mac_set_window_group_to_popup(OSWindowRef window)
}
#endif
+#ifdef QT_MAC_USE_COCOA
+void qt_mac_set_needs_display(QWidget *widget, QRegion region)
+{
+ NSView *theNSView = qt_mac_nativeview_for(widget);
+ if (region.isEmpty()) {
+ [theNSView setNeedsDisplay:YES];
+ return;
+ }
+
+ QVector<QRect> rects = region.rects();
+ for (int i = 0; i<rects.count(); ++i) {
+ const QRect &rect = rects.at(i);
+ NSRect nsrect = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
+ [theNSView setNeedsDisplayInRect:nsrect];
+ }
+
+}
+#endif
+
inline static bool updateRedirectedToGraphicsProxyWidget(QWidget *widget, const QRect &rect)
{
if (!widget)
@@ -3510,6 +3529,8 @@ void QWidgetPrivate::hide_sys()
if (!QWidget::mouseGrabber()){
QWidget *enterWidget = QApplication::widgetAt(QCursor::pos());
+ if (enterWidget && enterWidget->data->in_destructor)
+ enterWidget = 0;
QApplicationPrivate::dispatchEnterLeave(enterWidget, qt_mouseover);
qt_mouseover = enterWidget;
}
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index b1eb3c3..b421d30 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -173,6 +173,8 @@ struct QTLWExtra {
#ifndef QT_NO_QWS_MANAGER
QWSManager *qwsManager;
#endif
+#elif defined(Q_OS_SYMBIAN)
+ uint inExpose : 1; // Prevents drawing recursion
#endif
};
@@ -229,7 +231,6 @@ struct QWExtra {
#endif
#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
uint activated : 1; // RWindowBase::Activated has been called
- uint inExpose : 1; // Prevents drawing recursion
/**
* Defines the behaviour of QSymbianControl::Draw.
@@ -682,6 +683,7 @@ public:
uint inDirtyList : 1;
uint isScrolled : 1;
uint isMoved : 1;
+ uint isGLWidget : 1;
uint usesDoubleBufferedGLContext : 1;
// *************************** Platform specific ************************************
@@ -713,7 +715,6 @@ public:
#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
// This is new stuff
uint needWindowChange : 1;
- uint isGLWidget : 1;
// Each wiget keeps a list of all its child and grandchild OpenGL widgets.
// This list is used to update the gl context whenever a parent and a granparent
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index 00f2213..ebd289c 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -878,6 +878,7 @@ void QWidgetPrivate::registerDropSite(bool /* on */)
void QWidgetPrivate::createTLSysExtra()
{
extra->topextra->backingStore = 0;
+ extra->topextra->inExpose = 0;
}
void QWidgetPrivate::deleteTLSysExtra()
@@ -891,7 +892,6 @@ void QWidgetPrivate::createSysExtra()
extra->activated = 0;
extra->nativePaintMode = QWExtra::Default;
extra->receiveNativePaintEvents = 0;
- extra->inExpose = 0;
}
void QWidgetPrivate::deleteSysExtra()
@@ -1046,96 +1046,48 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
return;
if (isWindow()) {
-#ifdef Q_WS_S60
- // Change window decoration visibility if switching to or from fullsccreen
- // In addition decoration visibility is changed when the initial has been
- // WindowNoState.
- // The window decoration visibility has to be changed before doing actual
- // window state change since in that order the availableGeometry will return
- // directly the right size and we will avoid unnecessarty redraws
- if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen) ||
- oldstate == Qt::WindowNoState) {
- CEikStatusPane* statusPane = S60->statusPane();
- CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer();
- if (newstate & Qt::WindowFullScreen) {
- if (statusPane)
- statusPane->MakeVisible(false);
- if (buttonGroup)
- buttonGroup->MakeVisible(false);
- } else {
- if (statusPane)
- statusPane->MakeVisible(true);
- if (buttonGroup)
- buttonGroup->MakeVisible(true);
- }
+ QSymbianControl *window = static_cast<QSymbianControl *>(effectiveWinId());
+ if (window && newstate & Qt::WindowMinimized) {
+ window->setFocusSafely(false);
+ window->MakeVisible(false);
+ } else if (window && oldstate & Qt::WindowMinimized) {
+ window->setFocusSafely(true);
+ window->MakeVisible(true);
}
+
+#ifdef Q_WS_S60
+ // Hide window decoration when switching to fullsccreen / minimized otherwise show decoration.
+ // The window decoration visibility has to be changed before doing actual window state
+ // change since in that order the availableGeometry will return directly the right size and
+ // we will avoid unnecessarty redraws
+ CEikStatusPane* statusPane = S60->statusPane();
+ CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer();
+ TBool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized));
+ if (statusPane)
+ statusPane->MakeVisible(visible);
+ if (buttonGroup)
+ buttonGroup->MakeVisible(visible);
#endif // Q_WS_S60
createWinId();
Q_ASSERT(testAttribute(Qt::WA_WState_Created));
- QTLWExtra *top = d->topData();
-
// Ensure the initial size is valid, since we store it as normalGeometry below.
if (!testAttribute(Qt::WA_Resized) && !isVisible())
adjustSize();
- if ((oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized)) {
- if ((newstate & Qt::WindowMaximized)) {
- const QRect normalGeometry = geometry();
+ QTLWExtra *top = d->topData();
+ const QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry;
- const QRect r = top->normalGeometry;
- setGeometry(qApp->desktop()->availableGeometry(this));
- top->normalGeometry = r;
+ if (newstate & Qt::WindowFullScreen)
+ setGeometry(qApp->desktop()->screenGeometry(this));
+ else if (newstate & Qt::WindowMaximized)
+ setGeometry(qApp->desktop()->availableGeometry(this));
+ else
+ setGeometry(normalGeometry);
- if (top->normalGeometry.width() < 0)
- top->normalGeometry = normalGeometry;
- } else {
- // restore original geometry
- setGeometry(top->normalGeometry);
- }
- }
- if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) {
- if (newstate & Qt::WindowFullScreen) {
- const QRect normalGeometry = geometry();
- const QRect r = top->normalGeometry;
- setGeometry(qApp->desktop()->screenGeometry(this));
-
- top->normalGeometry = r;
- if (top->normalGeometry.width() < 0)
- top->normalGeometry = normalGeometry;
- } else {
- if (newstate & Qt::WindowMaximized) {
- const QRect r = top->normalGeometry;
- setGeometry(qApp->desktop()->availableGeometry(this));
- top->normalGeometry = r;
- } else {
- setGeometry(top->normalGeometry);
- }
- }
- }
- if ((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) {
- if (newstate & Qt::WindowMinimized) {
- if (isVisible()) {
- QSymbianControl *id = static_cast<QSymbianControl *>(effectiveWinId());
- if (id->IsFocused()) // Avoid unnecessary calls to FocusChanged()
- id->setFocusSafely(false);
- id->MakeVisible(false);
- }
- } else {
- if (isVisible()) {
- QSymbianControl *id = static_cast<QSymbianControl *>(effectiveWinId());
- id->MakeVisible(true);
- if (!id->IsFocused()) // Avoid unnecessary calls to FocusChanged()
- id->setFocusSafely(true);
- }
- const QRect normalGeometry = geometry();
- const QRect r = top->normalGeometry;
- top->normalGeometry = r;
- if (top->normalGeometry.width() < 0)
- top->normalGeometry = normalGeometry;
- }
- }
+ //restore normal geometry
+ top->normalGeometry = normalGeometry;
}
data->window_state = newstate;
@@ -1195,6 +1147,10 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
if (destroyWindow) {
delete id;
+ // At this point the backing store should already be destroyed
+ // so we flush the command buffer to ensure that the freeing of
+ // those resources and deleting the window can happen "atomically"
+ S60->wsSession().Flush();
}
}
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 4684bc1..10fb009 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -346,11 +346,6 @@ Q_GUI_EXPORT void qt_x11_enforce_cursor(QWidget * w)
qt_x11_enforce_cursor(w, false);
}
-static Bool checkForConfigureAndExpose(Display *, XEvent *e, XPointer)
-{
- return e->type == ConfigureNotify || e->type == Expose;
-}
-
Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
{
if (!w || (!w->isWindow() && !w->internalWinId()))
@@ -363,38 +358,60 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
if (!w->testAttribute(Qt::WA_WState_Created))
return;
- if (!(w->windowFlags() & Qt::X11BypassWindowManagerHint)) {
- // if the window is not override-redirect, then the window manager
- // will reparent us to the frame decoration window.
- while (!XCheckTypedWindowEvent(X11->display, w->effectiveWinId(), ReparentNotify, &ev)) {
- if (t.elapsed() > maximumWaitTime)
- return;
- qApp->syncX(); // non-busy wait
- }
- }
+ WId winid = w->internalWinId();
- while (!XCheckTypedWindowEvent(X11->display, w->effectiveWinId(), MapNotify, &ev)) {
- if (t.elapsed() > maximumWaitTime)
- return;
- qApp->syncX(); // non-busy wait
- }
+ // first deliver events that are already in the local queue
+ QApplication::sendPostedEvents();
- qApp->x11ProcessEvent(&ev);
+ // the normal sequence is:
+ // ... ConfigureNotify ... ReparentNotify ... MapNotify ... Expose
+ // with X11BypassWindowManagerHint:
+ // ConfigureNotify ... MapNotify ... Expose
- // ok, seems like the window manager successfully reparented us, we'll wait
- // for the first paint event to arrive, while handling ConfigureNotify in
- // the arrival order
- while(1)
- {
- if (XCheckIfEvent(X11->display, &ev, checkForConfigureAndExpose, 0)) {
+ enum State {
+ Initial, Reparented, Mapped
+ } state = Initial;
+
+ do {
+ if (XEventsQueued(X11->display, QueuedAlready)) {
+ XNextEvent(X11->display, &ev);
qApp->x11ProcessEvent(&ev);
- if (ev.type == Expose)
- return;
+
+ if (w->windowFlags() & Qt::X11BypassWindowManagerHint) {
+ switch (state) {
+ case Initial:
+ case Reparented:
+ if (ev.type == MapNotify && ev.xany.window == winid)
+ state = Mapped;
+ break;
+ case Mapped:
+ if (ev.type == Expose && ev.xany.window == winid)
+ return;
+ break;
+ }
+ } else {
+ switch (state) {
+ case Initial:
+ if (ev.type == ReparentNotify && ev.xany.window == winid)
+ state = Reparented;
+ break;
+ case Reparented:
+ if (ev.type == MapNotify && ev.xany.window == winid)
+ state = Mapped;
+ break;
+ case Mapped:
+ if (ev.type == Expose && ev.xany.window == winid)
+ return;
+ break;
+ }
+ }
+ } else {
+ if (!XEventsQueued(X11->display, QueuedAfterFlush))
+ qApp->syncX(); // non-busy wait
}
if (t.elapsed() > maximumWaitTime)
return;
- qApp->syncX(); // non-busy wait
- }
+ } while(1);
}
void qt_change_net_wm_state(const QWidget* w, bool set, Atom one, Atom two = 0)