summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-10 14:16:17 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-10 14:16:17 (GMT)
commit727ec8c564a3947784bfe371b39615f965d530ec (patch)
treed4360972a21f8d24214b7a0c5ec7277391479192 /src/gui
parentef9e7168a8ed3e8149204cf6c604a38db35245c0 (diff)
parent01a045084ad45da37e6b79938354c82419c0a83e (diff)
downloadQt-727ec8c564a3947784bfe371b39615f965d530ec.zip
Qt-727ec8c564a3947784bfe371b39615f965d530ec.tar.gz
Qt-727ec8c564a3947784bfe371b39615f965d530ec.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dialogs/qdialog.cpp6
-rw-r--r--src/gui/dialogs/qfiledialog_mac.mm27
-rw-r--r--src/gui/dialogs/qfontdialog.cpp20
-rw-r--r--src/gui/dialogs/qfontdialog_mac.mm395
-rw-r--r--src/gui/dialogs/qfontdialog_p.h12
-rw-r--r--src/gui/dialogs/qmessagebox.cpp2
-rw-r--r--src/gui/dialogs/qprintpreviewdialog.cpp13
-rw-r--r--src/gui/egl/qegl.cpp7
-rw-r--r--src/gui/egl/qegl_p.h17
-rw-r--r--src/gui/egl/qegl_wince.cpp3
-rw-r--r--src/gui/egl/qegl_x11.cpp20
-rw-r--r--src/gui/egl/qeglproperties.cpp5
-rw-r--r--src/gui/embedded/directfb.pri2
-rw-r--r--src/gui/embedded/qscreen_qws.cpp2
-rw-r--r--src/gui/embedded/qwsmanager_qws.cpp6
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp131
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h8
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h3
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp58
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp6
-rw-r--r--src/gui/image/qicon.cpp4
-rw-r--r--src/gui/image/qiconloader.cpp32
-rw-r--r--src/gui/image/qiconloader_p.h2
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks.cpp10
-rw-r--r--src/gui/image/qpixmap.cpp25
-rw-r--r--src/gui/image/qpixmap_x11_p.h2
-rw-r--r--src/gui/image/qpixmapfilter.cpp5
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp15
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp9
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp8
-rw-r--r--src/gui/itemviews/qstyleditemdelegate.cpp7
-rw-r--r--src/gui/itemviews/qtableview.cpp14
-rw-r--r--src/gui/itemviews/qtreeview.cpp6
-rw-r--r--src/gui/kernel/qapplication.cpp24
-rw-r--r--src/gui/kernel/qapplication_mac.mm3
-rw-r--r--src/gui/kernel/qapplication_p.h3
-rw-r--r--src/gui/kernel/qapplication_s60.cpp42
-rw-r--r--src/gui/kernel/qapplication_win.cpp37
-rw-r--r--src/gui/kernel/qapplication_x11.cpp18
-rw-r--r--src/gui/kernel/qclipboard.cpp6
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac.mm13
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac.mm20
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac_p.h4
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm30
-rw-r--r--src/gui/kernel/qgesturemanager.cpp4
-rw-r--r--src/gui/kernel/qguifunctions_wince.cpp9
-rw-r--r--src/gui/kernel/qkeymapper_x11.cpp8
-rw-r--r--src/gui/kernel/qmime_win.cpp12
-rw-r--r--src/gui/kernel/qsoftkeymanager_s60.cpp32
-rw-r--r--src/gui/kernel/qsoftkeymanager_s60_p.h2
-rw-r--r--src/gui/kernel/qsound_mac.mm1
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm47
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac_p.h2
-rw-r--r--src/gui/kernel/qt_x11_p.h3
-rw-r--r--src/gui/kernel/qwidget.cpp128
-rw-r--r--src/gui/kernel/qwidget_mac.mm74
-rw-r--r--src/gui/kernel/qwidget_p.h1
-rw-r--r--src/gui/kernel/qwidget_s60.cpp41
-rw-r--r--src/gui/kernel/qwidget_win.cpp2
-rw-r--r--src/gui/kernel/qwinnativepangesturerecognizer_win_p.h32
-rw-r--r--src/gui/painting/qbackingstore.cpp11
-rw-r--r--src/gui/painting/qcolor.cpp15
-rw-r--r--src/gui/painting/qcolormap.qdoc10
-rw-r--r--src/gui/painting/qdrawhelper.cpp5
-rw-r--r--src/gui/painting/qdrawutil.cpp4
-rw-r--r--src/gui/painting/qgraphicssystem_raster.cpp13
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp2
-rw-r--r--src/gui/painting/qpaintengineex.cpp4
-rw-r--r--src/gui/painting/qpaintengineex_p.h3
-rw-r--r--src/gui/painting/qpainter.cpp53
-rw-r--r--src/gui/painting/qpainter.h12
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp2
-rw-r--r--src/gui/painting/qwindowsurface_qws.cpp17
-rw-r--r--src/gui/painting/qwindowsurface_qws_p.h2
-rw-r--r--src/gui/styles/qgtkpainter.cpp2
-rw-r--r--src/gui/styles/qgtkstyle.cpp203
-rw-r--r--src/gui/styles/qgtkstyle_p.cpp122
-rw-r--r--src/gui/styles/qgtkstyle_p.h86
-rw-r--r--src/gui/styles/qs60style.cpp48
-rw-r--r--src/gui/styles/qstylehelper.cpp65
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp15
-rw-r--r--src/gui/styles/qwindowsmobilestyle.cpp37
-rw-r--r--src/gui/text/qfontengine_ft.cpp70
-rw-r--r--src/gui/text/qfontengine_ft_p.h16
-rw-r--r--src/gui/text/qstatictext.cpp6
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp95
-rw-r--r--src/gui/text/qtextengine.cpp6
-rw-r--r--src/gui/text/qtextengine_p.h1
-rw-r--r--src/gui/text/qtextlayout.cpp2
-rw-r--r--src/gui/util/qsystemtrayicon_mac.mm4
-rw-r--r--src/gui/widgets/qabstractspinbox.cpp5
-rw-r--r--src/gui/widgets/qlabel_p.h2
-rw-r--r--src/gui/widgets/qlinecontrol.cpp6
-rw-r--r--src/gui/widgets/qlinecontrol_p.h2
-rw-r--r--src/gui/widgets/qlineedit.cpp17
-rw-r--r--src/gui/widgets/qlineedit.h6
-rw-r--r--src/gui/widgets/qmainwindow.cpp4
-rw-r--r--src/gui/widgets/qmainwindowlayout_mac.mm2
-rw-r--r--src/gui/widgets/qmenu.cpp9
-rw-r--r--src/gui/widgets/qmenu_mac.mm32
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp8
-rw-r--r--src/gui/widgets/qscrollbar.cpp1
103 files changed, 1604 insertions, 905 deletions
diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp
index fb0dba4..2d75913 100644
--- a/src/gui/dialogs/qdialog.cpp
+++ b/src/gui/dialogs/qdialog.cpp
@@ -808,11 +808,11 @@ void QDialog::setVisible(bool visible)
void QDialog::showEvent(QShowEvent *event)
{
if (!event->spontaneous() && !testAttribute(Qt::WA_Moved)) {
- Qt::WindowStates state = windowState();
+ Qt::WindowStates state = windowState();
adjustPosition(parentWidget());
setAttribute(Qt::WA_Moved, false); // not really an explicit position
- if (state != windowState())
- setWindowState(state);
+ if (state != windowState())
+ setWindowState(state);
}
}
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm
index 67daced..14a5f15 100644
--- a/src/gui/dialogs/qfiledialog_mac.mm
+++ b/src/gui/dialogs/qfiledialog_mac.mm
@@ -295,10 +295,14 @@ QT_USE_NAMESPACE
if (!mQDirFilterEntryList->contains(info.fileName()))
return NO;
- // Always accept directories regardless of their names:
+ // Always accept directories regardless of their names (unless it is a bundle):
BOOL isDir;
- if ([[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDir] && isDir)
- return YES;
+ if ([[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDir] && isDir) {
+ if ([mSavePanel treatsFilePackagesAsDirectories] == NO) {
+ if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename] == NO)
+ return YES;
+ }
+ }
// No filter means accept everything
if (mSelectedNameFilter->isEmpty())
@@ -725,6 +729,7 @@ Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void
NavFileOrFolderInfo *theInfo = static_cast<NavFileOrFolderInfo *>(info);
QString file;
+ QString path;
const QtMacFilterName &fn
= fileDialogPrivate->filterInfo.filters.at(fileDialogPrivate->filterInfo.currentSelection);
if (theItem->descriptorType == typeFSRef) {
@@ -732,10 +737,12 @@ Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void
AEGetDescData(theItem, &ref, sizeof(ref));
UInt8 str_buffer[1024];
FSRefMakePath(&ref, str_buffer, 1024);
- file = QString::fromUtf8(reinterpret_cast<const char *>(str_buffer));
- int slsh = file.lastIndexOf(QLatin1Char('/'));
+ path = QString::fromUtf8(reinterpret_cast<const char *>(str_buffer));
+ int slsh = path.lastIndexOf(QLatin1Char('/'));
if (slsh != -1)
- file = file.right(file.length() - slsh - 1);
+ file = path.right(path.length() - slsh - 1);
+ else
+ file = path;
}
QStringList reg = fn.regexp.split(QLatin1String(";"));
for (QStringList::const_iterator it = reg.constBegin(); it != reg.constEnd(); ++it) {
@@ -747,7 +754,13 @@ Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void
if (rg.exactMatch(file))
return true;
}
- return (theInfo->isFolder && !file.endsWith(QLatin1String(".app")));
+
+ if (theInfo->isFolder) {
+ if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:qt_mac_QStringToNSString(path)])
+ return false;
+ return true;
+ }
+ return false;
}
void QFileDialogPrivate::qt_mac_filedialog_event_proc(const NavEventCallbackMessage msg,
diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp
index b987611..b159fa7 100644
--- a/src/gui/dialogs/qfontdialog.cpp
+++ b/src/gui/dialogs/qfontdialog.cpp
@@ -174,6 +174,11 @@ void QFontDialogPrivate::init()
{
Q_Q(QFontDialog);
+#ifdef Q_WS_MAC
+ nativeDialogInUse = false;
+ delegate = 0;
+#endif
+
q->setSizeGripEnabled(true);
q->setWindowTitle(QFontDialog::tr("Select Font"));
@@ -329,10 +334,6 @@ void QFontDialogPrivate::init()
familyList->setFocus();
retranslateStrings();
-
-#ifdef Q_WS_MAC
- delegate = 0;
-#endif
}
/*!
@@ -345,8 +346,7 @@ QFontDialog::~QFontDialog()
#ifdef Q_WS_MAC
Q_D(QFontDialog);
if (d->delegate) {
- QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
- QFontDialogPrivate::sharedFontPanelAvailable = true;
+ d->closeCocoaFontPanel();
return;
}
#endif
@@ -428,14 +428,6 @@ QFont QFontDialog::getFont(bool *ok, QWidget *parent)
QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent,
const QString &title, QFontDialog::FontDialogOptions options)
{
-#ifdef Q_WS_MAC
- if (!(options & QFontDialog::DontUseNativeDialog)
- && QFontDialogPrivate::sharedFontPanelAvailable) {
- return QFontDialogPrivate::execCocoaFontPanel(ok, initial, parent,
- title.isEmpty() ? QFontDialog::tr("Select Font") : title, options);
- }
-#endif
-
QFontDialog dlg(parent);
dlg.setOptions(options);
dlg.setCurrentFont(initial);
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm
index 67d32b8..919790b 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/gui/dialogs/qfontdialog_mac.mm
@@ -58,6 +58,14 @@
typedef float CGFloat; // Should only not be defined on 32-bit platforms
#endif
+QT_BEGIN_NAMESPACE
+
+extern void macStartInterceptNSPanelCtor();
+extern void macStopInterceptNSPanelCtor();
+extern NSButton *macCreateButton(const char *text, NSView *superview);
+extern bool qt_mac_is_macsheet(const QWidget *w); // qwidget_mac.mm
+
+QT_END_NAMESPACE
QT_USE_NAMESPACE
// should a priori be kept in sync with qcolordialog_mac.mm
@@ -95,7 +103,8 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin
BOOL mPanelHackedWithButtons;
CGFloat mDialogExtraWidth;
CGFloat mDialogExtraHeight;
- NSModalSession mModalSession;
+ int mReturnCode;
+ BOOL mAppModal;
}
- (id)initWithFontPanel:(NSFontPanel *)panel
stolenContentView:(NSView *)stolenContentView
@@ -104,9 +113,11 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin
priv:(QFontDialogPrivate *)priv
extraWidth:(CGFloat)extraWidth
extraHeight:(CGFloat)extraHeight;
+- (void)showModelessPanel;
+- (void)showWindowModalSheet:(QWidget *)docWidget;
+- (void)runApplicationModalPanel;
- (void)changeFont:(id)sender;
- (void)changeAttributes:(id)sender;
-- (void)setModalSession:(NSModalSession)session;
- (BOOL)windowShouldClose:(id)window;
- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
- (void)relayout;
@@ -163,7 +174,8 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
mPanelHackedWithButtons = (okButton != 0);
mDialogExtraWidth = extraWidth;
mDialogExtraHeight = extraHeight;
- mModalSession = 0;
+ mReturnCode = -1;
+ mAppModal = false;
if (mPanelHackedWithButtons) {
[self relayout];
@@ -174,6 +186,20 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
[cancelButton setAction:@selector(onCancelClicked)];
[cancelButton setTarget:self];
}
+
+#ifdef QT_MAC_USE_COCOA
+ // Stack the native dialog in front of its parent, if any:
+ QFontDialog *q = mPriv->fontDialog();
+ if (!qt_mac_is_macsheet(q)) {
+ if (QWidget *parent = q->parentWidget()) {
+ if (parent->isWindow()) {
+ [qt_mac_window_for(parent)
+ addChildWindow:[mStolenContentView window] ordered:NSWindowAbove];
+ }
+ }
+ }
+#endif
+
mQtFont = new QFont();
return self;
}
@@ -184,6 +210,50 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
[super dealloc];
}
+- (void)showModelessPanel
+{
+ mAppModal = false;
+ NSWindow *ourPanel = [mStolenContentView window];
+ [ourPanel makeKeyAndOrderFront:self];
+}
+
+- (void)runApplicationModalPanel
+{
+ QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
+ mAppModal = true;
+ NSWindow *ourPanel = [mStolenContentView window];
+ [NSApp runModalForWindow:ourPanel];
+ QAbstractEventDispatcher::instance()->interrupt();
+
+ if (mReturnCode == NSOKButton)
+ mPriv->fontDialog()->accept();
+ else
+ mPriv->fontDialog()->reject();
+}
+
+- (void)showWindowModalSheet:(QWidget *)docWidget
+{
+#ifdef QT_MAC_USE_COCOA
+ NSWindow *window = qt_mac_window_for(docWidget);
+#else
+ WindowRef hiwindowRef = qt_mac_window_for(docWidget);
+ NSWindow *window = [[NSWindow alloc] initWithWindowRef:hiwindowRef];
+ CFRetain(hiwindowRef);
+#endif
+
+ mAppModal = false;
+ NSWindow *ourPanel = [mStolenContentView window];
+ [NSApp beginSheet:ourPanel
+ modalForWindow:window
+ modalDelegate:0
+ didEndSelector:0
+ contextInfo:0 ];
+
+#ifndef QT_MAC_USE_COCOA
+ CFRelease(hiwindowRef);
+#endif
+}
+
- (void)changeFont:(id)sender
{
NSFont *dummyFont = [NSFont userFontOfSize:12.0];
@@ -216,12 +286,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
mPriv->updateSampleFont(*mQtFont);
}
-- (void)setModalSession:(NSModalSession)session
-{
- Q_ASSERT(!mModalSession);
- mModalSession = session;
-}
-
- (BOOL)windowShouldClose:(id)window
{
Q_UNUSED(window);
@@ -282,9 +346,8 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
NSSize cancelSizeHint = [mCancelButton frame].size;
const CGFloat ButtonWidth = qMin(qMax(ButtonMinWidth,
- qMax(okSizeHint.width, cancelSizeHint.width)),
- CGFloat((frameSize.width - 2.0 * ButtonSideMargin
- - ButtonSpacing) * 0.5));
+ qMax(okSizeHint.width, cancelSizeHint.width)),
+ CGFloat((frameSize.width - 2.0 * ButtonSideMargin - ButtonSpacing) * 0.5));
const CGFloat ButtonHeight = qMax(ButtonMinHeight,
qMax(okSizeHint.height, cancelSizeHint.height));
@@ -317,14 +380,12 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
NSFontManager *fontManager = [NSFontManager sharedFontManager];
[self setQtFont:qfontForCocoaFont([fontManager convertFont:[fontManager selectedFont]],
*mQtFont)];
- [[mStolenContentView window] close];
[self finishOffWithCode:NSOKButton];
}
- (void)onCancelClicked
{
Q_ASSERT(mPanelHackedWithButtons);
- [[mStolenContentView window] close];
[self finishOffWithCode:NSCancelButton];
}
@@ -368,20 +429,26 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
- (void)finishOffWithCode:(NSInteger)code
{
- if (mPriv) {
- if (mModalSession) {
- [NSApp endModalSession:mModalSession];
- mModalSession = 0;
+#ifdef QT_MAC_USE_COCOA
+ QFontDialog *q = mPriv->fontDialog();
+ if (QWidget *parent = q->parentWidget()) {
+ if (parent->isWindow()) {
+ [qt_mac_window_for(parent) removeChildWindow:[mStolenContentView window]];
}
- // Hack alert!
- // Since this code path was never intended to be followed when starting from exec
- // we need to force the dialog to communicate the new font, otherwise the signal
- // won't get emitted.
- if(code == NSOKButton)
- mPriv->sampleEdit->setFont([self qtFont]);
- mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
- } else {
+ }
+#endif
+
+ if(code == NSOKButton)
+ mPriv->sampleEdit->setFont([self qtFont]);
+
+ if (mAppModal) {
+ mReturnCode = code;
[NSApp stopModalWithCode:code];
+ } else {
+ if (code == NSOKButton)
+ mPriv->fontDialog()->accept();
+ else
+ mPriv->fontDialog()->reject();
}
}
@@ -408,206 +475,16 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
QT_BEGIN_NAMESPACE
-extern void macStartInterceptNSPanelCtor();
-extern void macStopInterceptNSPanelCtor();
-extern NSButton *macCreateButton(const char *text, NSView *superview);
-
-void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial,
- QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options,
- QFontDialogPrivate *priv)
-{
- Q_UNUSED(parent); // we would use the parent if only NSFontPanel could be a sheet
- QMacCocoaAutoReleasePool pool;
-
- /*
- The standard Cocoa font panel has no OK or Cancel button and
- is created as a utility window. For strange reasons (which seem
- to stem from the fact that the font panel is based on a NIB
- file), the approach we use for the color panel doesn't work for
- the font panel (and, inversely, the approach we use here doesn't
- quite work for color panel, and crashed last time I tried). So
- instead, we take the following steps:
-
- 1. Constructs a plain NSPanel that looks the way we want it
- to look. Specifically, if the NoButtons option is off, we
- construct a panel without the NSUtilityWindowMask flag
- and with buttons (OK and Cancel).
-
- 2. Steal the content view from the shared NSFontPanel and
- put it inside our new NSPanel's content view, together
- with the OK and Cancel buttons.
-
- 3. Lay out the original content view and the buttons when
- the font panel is shown and whenever it is resized.
-
- 4. Clean up after ourselves.
-
- PS. Some customization is also done in QCocoaApplication
- validModesForFontPanel:.
- */
-
- Qt::WindowModality modality = Qt::ApplicationModal;
- if (priv)
- modality = priv->fontDialog()->windowModality();
-
- bool needButtons = !(options & QFontDialog::NoButtons);
- // don't need our own panel if the title bar isn't visible anyway (in a sheet)
- bool needOwnPanel = (needButtons && modality != Qt::WindowModal);
-
- bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists];
- NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel];
- [sharedFontPanel setHidesOnDeactivate:false];
-
- // hack to ensure that QCocoaApplication's validModesForFontPanel:
- // implementation is honored
- if (!sharedFontPanelExisted && needOwnPanel) {
- [sharedFontPanel makeKeyAndOrderFront:sharedFontPanel];
- [sharedFontPanel close];
- }
-
- NSPanel *ourPanel = 0;
- NSView *stolenContentView = 0;
- NSButton *okButton = 0;
- NSButton *cancelButton = 0;
-
- CGFloat dialogExtraWidth = 0.0;
- CGFloat dialogExtraHeight = 0.0;
-
- if (!needOwnPanel) {
- // we can reuse the NSFontPanel unchanged
- ourPanel = sharedFontPanel;
- } else {
- // compute dialogExtra{Width,Height}
- dialogExtraWidth = 2.0 * DialogSideMargin;
- dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight
- + ButtonBottomMargin;
-
- // compute initial contents rectangle
- NSRect contentRect = [sharedFontPanel contentRectForFrameRect:[sharedFontPanel frame]];
- contentRect.size.width += dialogExtraWidth;
- contentRect.size.height += dialogExtraHeight;
-
- // create the new panel
- ourPanel = [[NSPanel alloc] initWithContentRect:contentRect
- styleMask:StyleMask
- backing:NSBackingStoreBuffered
- defer:YES];
- [ourPanel setReleasedWhenClosed:YES];
- }
-
- stolenContentView = [sharedFontPanel contentView];
-
- if (needButtons) {
- // steal the font panel's contents view
- [stolenContentView retain];
- [sharedFontPanel setContentView:0];
-
- // create a new content view and add the stolen one as a subview
- NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
- NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
- [ourContentView addSubview:stolenContentView];
-
- // create OK and Cancel buttons and add these as subviews
- okButton = macCreateButton("&OK", ourContentView);
- cancelButton = macCreateButton("Cancel", ourContentView);
-
- [ourPanel setContentView:ourContentView];
- [ourPanel setDefaultButtonCell:[okButton cell]];
- }
-
- // create a delegate and set it
- QCocoaFontPanelDelegate *delegate =
- [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel
- stolenContentView:stolenContentView
- okButton:okButton
- cancelButton:cancelButton
- priv:priv
- extraWidth:dialogExtraWidth
- extraHeight:dialogExtraHeight];
- [ourPanel setDelegate:delegate];
- [[NSFontManager sharedFontManager] setDelegate:delegate];
-#ifdef QT_MAC_USE_COCOA
- [[NSFontManager sharedFontManager] setTarget:delegate];
-#endif
- setFont(delegate, initial);
-
- // hack to get correct initial layout
- NSRect frameRect = [ourPanel frame];
- frameRect.size.width += 1.0;
- [ourPanel setFrame:frameRect display:NO];
- frameRect.size.width -= 1.0;
- frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size];
- [ourPanel setFrame:frameRect display:NO];
- [ourPanel center];
-
- [ourPanel setTitle:(NSString*)(CFStringRef)QCFString(title)];
-
- if (priv) {
- switch (modality) {
- case Qt::WindowModal:
- if (parent) {
-#ifndef QT_MAC_USE_COCOA
- WindowRef hiwindowRef = qt_mac_window_for(parent);
- NSWindow *window =
- [[NSWindow alloc] initWithWindowRef:hiwindowRef];
- // Cocoa docs say I should retain the Carbon ref.
- CFRetain(hiwindowRef);
-#else
- NSWindow *window = qt_mac_window_for(parent);
-#endif
- [NSApp beginSheet:ourPanel
- modalForWindow:window
- modalDelegate:0
- didEndSelector:0
- contextInfo:0];
-#ifndef QT_MAC_USE_COCOA
- [window release];
-#endif
- break;
- }
- // fallthrough
- case Qt::ApplicationModal:
- [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]];
- break;
- default:
- [ourPanel makeKeyAndOrderFront:ourPanel];
- }
- }
- return delegate;
-}
-
-void QFontDialogPrivate::closeCocoaFontPanel(void *delegate)
+void QFontDialogPrivate::closeCocoaFontPanel()
{
QMacCocoaAutoReleasePool pool;
QCocoaFontPanelDelegate *theDelegate = static_cast<QCocoaFontPanelDelegate *>(delegate);
NSWindow *ourPanel = [theDelegate actualPanel];
[ourPanel close];
[theDelegate cleanUpAfterMyself];
- [theDelegate autorelease];
-}
-
-QFont QFontDialogPrivate::execCocoaFontPanel(bool *ok, const QFont &initial,
- QWidget *parent, const QString &title, QFontDialog::FontDialogOptions options)
-{
- QMacCocoaAutoReleasePool pool;
- QCocoaFontPanelDelegate *delegate =
- static_cast<QCocoaFontPanelDelegate *>(
- openCocoaFontPanel(initial, parent, title, options));
- NSWindow *ourPanel = [delegate actualPanel];
- [ourPanel retain];
- int rval = [NSApp runModalForWindow:ourPanel];
- QFont font([delegate qtFont]);
- [ourPanel release];
- [delegate cleanUpAfterMyself];
- [delegate release];
- bool isOk = ((options & QFontDialog::NoButtons) || rval == NSOKButton);
- if (ok)
- *ok = isOk;
- if (isOk) {
- return font;
- } else {
- return initial;
- }
+ [theDelegate release];
+ this->delegate = 0;
+ sharedFontPanelAvailable = true;
}
void QFontDialogPrivate::setFont(void *delegate, const QFont &font)
@@ -645,10 +522,13 @@ void QFontDialogPrivate::setFont(void *delegate, const QFont &font)
[static_cast<QCocoaFontPanelDelegate *>(delegate) setQtFont:font];
}
-void *QFontDialogPrivate::_q_constructNativePanel()
+void QFontDialogPrivate::createNSFontPanelDelegate()
{
- QMacCocoaAutoReleasePool pool;
+ if (delegate)
+ return;
+ sharedFontPanelAvailable = false;
+ QMacCocoaAutoReleasePool pool;
bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists];
NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel];
[sharedFontPanel setHidesOnDeactivate:false];
@@ -670,8 +550,7 @@ void *QFontDialogPrivate::_q_constructNativePanel()
// compute dialogExtra{Width,Height}
dialogExtraWidth = 2.0 * DialogSideMargin;
- dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight
- + ButtonBottomMargin;
+ dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight + ButtonBottomMargin;
// compute initial contents rectangle
NSRect contentRect = [sharedFontPanel contentRectForFrameRect:[sharedFontPanel frame]];
@@ -684,7 +563,6 @@ void *QFontDialogPrivate::_q_constructNativePanel()
backing:NSBackingStoreBuffered
defer:YES];
[ourPanel setReleasedWhenClosed:YES];
-
stolenContentView = [sharedFontPanel contentView];
// steal the font panel's contents view
@@ -704,21 +582,23 @@ void *QFontDialogPrivate::_q_constructNativePanel()
[ourPanel setContentView:ourContentView];
[ourPanel setDefaultButtonCell:[okButton cell]];
}
- // create a delegate and set it
- QCocoaFontPanelDelegate *delegate =
- [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel
+
+ // create the delegate and set it
+ QCocoaFontPanelDelegate *del = [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel
stolenContentView:stolenContentView
okButton:okButton
cancelButton:cancelButton
priv:this
extraWidth:dialogExtraWidth
extraHeight:dialogExtraHeight];
- [ourPanel setDelegate:delegate];
- [[NSFontManager sharedFontManager] setDelegate:delegate];
+ delegate = del;
+ [ourPanel setDelegate:del];
+
+ [[NSFontManager sharedFontManager] setDelegate:del];
#ifdef QT_MAC_USE_COCOA
- [[NSFontManager sharedFontManager] setTarget:delegate];
+ [[NSFontManager sharedFontManager] setTarget:del];
#endif
- setFont(delegate, QApplication::font());
+ setFont(del, q_func()->currentFont());
{
// hack to get correct initial layout
@@ -726,15 +606,12 @@ void *QFontDialogPrivate::_q_constructNativePanel()
frameRect.size.width += 1.0;
[ourPanel setFrame:frameRect display:NO];
frameRect.size.width -= 1.0;
- frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size];
+ frameRect.size = [del windowWillResize:ourPanel toSize:frameRect.size];
[ourPanel setFrame:frameRect display:NO];
[ourPanel center];
}
NSString *title = @"Select font";
[ourPanel setTitle:title];
-
- [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]];
- return delegate;
}
void QFontDialogPrivate::mac_nativeDialogModalHelp()
@@ -759,29 +636,47 @@ void QFontDialogPrivate::mac_nativeDialogModalHelp()
// and "adding" the buttons.
void QFontDialogPrivate::_q_macRunNativeAppModalPanel()
{
- QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
+ createNSFontPanelDelegate();
+ QCocoaFontPanelDelegate *del = static_cast<QCocoaFontPanelDelegate *>(delegate);
+ [del runApplicationModalPanel];
+}
+
+bool QFontDialogPrivate::showCocoaFontPanel()
+{
+ if (!sharedFontPanelAvailable)
+ return false;
+
Q_Q(QFontDialog);
- QCocoaFontPanelDelegate *delegate = (QCocoaFontPanelDelegate *)_q_constructNativePanel();
- NSWindow *ourPanel = [delegate actualPanel];
- [ourPanel retain];
- int rval = [NSApp runModalForWindow:ourPanel];
- QAbstractEventDispatcher::instance()->interrupt();
- [ourPanel release];
- [delegate cleanUpAfterMyself];
- [delegate release];
- bool isOk = (rval == NSOKButton);
- if(isOk)
- rescode = QDialog::Accepted;
+ QMacCocoaAutoReleasePool pool;
+ createNSFontPanelDelegate();
+ QCocoaFontPanelDelegate *del = static_cast<QCocoaFontPanelDelegate *>(delegate);
+ if (qt_mac_is_macsheet(q))
+ [del showWindowModalSheet:q->parentWidget()];
else
- rescode = QDialog::Rejected;
+ [del showModelessPanel];
+ return true;
}
+bool QFontDialogPrivate::hideCocoaFontPanel()
+{
+ if (!delegate){
+ // Nothing to do. We return false to leave the question
+ // open regarding whether or not to go native:
+ return false;
+ } else {
+ closeCocoaFontPanel();
+ // Even when we hide it, we are still using a
+ // native dialog, so return true:
+ return true;
+ }
+}
bool QFontDialogPrivate::setVisible_sys(bool visible)
{
Q_Q(QFontDialog);
if (!visible == q->isHidden())
return false;
- return visible;
+
+ return visible ? showCocoaFontPanel() : hideCocoaFontPanel();
}
QT_END_NAMESPACE
diff --git a/src/gui/dialogs/qfontdialog_p.h b/src/gui/dialogs/qfontdialog_p.h
index 7654a80..8676be3 100644
--- a/src/gui/dialogs/qfontdialog_p.h
+++ b/src/gui/dialogs/qfontdialog_p.h
@@ -139,25 +139,21 @@ public:
QByteArray memberToDisconnectOnClose;
#ifdef Q_WS_MAC
- static void *openCocoaFontPanel(const QFont &initial,
- QWidget *parent, const QString &title,
- QFontDialog::FontDialogOptions options,
- QFontDialogPrivate *priv = 0);
- static void closeCocoaFontPanel(void *delegate);
- static QFont execCocoaFontPanel(bool *ok, const QFont &initial, QWidget *parent,
- const QString &title, QFontDialog::FontDialogOptions options);
static void setFont(void *delegate, const QFont &font);
inline void done(int result) { q_func()->done(result); }
inline QFontDialog *fontDialog() { return q_func(); }
void *delegate;
+ void closeCocoaFontPanel();
bool nativeDialogInUse;
bool canBeNativeDialog();
bool setVisible_sys(bool visible);
- void *_q_constructNativePanel();
+ void createNSFontPanelDelegate();
void _q_macRunNativeAppModalPanel();
void mac_nativeDialogModalHelp();
+ bool showCocoaFontPanel();
+ bool hideCocoaFontPanel();
static bool sharedFontPanelAvailable;
#endif
diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp
index ed437ff..121ba62 100644
--- a/src/gui/dialogs/qmessagebox.cpp
+++ b/src/gui/dialogs/qmessagebox.cpp
@@ -314,6 +314,7 @@ void QMessageBoxPrivate::updateSize()
}
width = hardLimit;
}
+ }
#ifdef Q_WS_S60
// in S60 portait messageBoxes should always occupy maximum width
if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){
@@ -323,7 +324,6 @@ void QMessageBoxPrivate::updateSize()
width = qMin(QApplication::desktop()->size().height(), hardLimit);
}
#endif
- }
if (informativeLabel) {
label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp
index 6723b53..f21343e 100644
--- a/src/gui/dialogs/qprintpreviewdialog.cpp
+++ b/src/gui/dialogs/qprintpreviewdialog.cpp
@@ -273,7 +273,20 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
QWidget *pageEdit = new QWidget(toolbar);
QVBoxLayout *vboxLayout = new QVBoxLayout;
vboxLayout->setContentsMargins(0, 0, 0, 0);
+#ifdef Q_WS_MAC
+ // We query the widgets about their size and then we fix the size.
+ // This should do the trick for the laying out part...
+ QSize pageNumEditSize, pageNumLabelSize;
+ pageNumEditSize = pageNumEdit->minimumSizeHint();
+ pageNumLabelSize = pageNumLabel->minimumSizeHint();
+ pageNumEdit->resize(pageNumEditSize);
+ pageNumLabel->resize(pageNumLabelSize);
+#endif
QFormLayout *formLayout = new QFormLayout;
+#ifdef Q_WS_MAC
+ // We have to change the growth policy in Mac.
+ formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+#endif
formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit);
formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel);
vboxLayout->addLayout(formLayout);
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index 485bfbf..6e0331f 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -392,6 +392,11 @@ bool QEglContext::makeCurrent(EGLSurface surface)
return false;
}
+ if (surface == EGL_NO_SURFACE) {
+ qWarning() << "QEglContext::makeCurrent(): Cannot make invalid surface current";
+ return false;
+ }
+
// If lazyDoneCurrent() was called on the surface, then we may be able
// to assume that it is still current within the thread.
if (surface == currentSurface && currentContext(apiType) == this) {
@@ -417,7 +422,7 @@ bool QEglContext::makeCurrent(EGLSurface surface)
bool ok = eglMakeCurrent(QEgl::display(), surface, surface, ctx);
if (!ok)
- qWarning() << "QEglContext::makeCurrent():" << QEgl::errorString();
+ qWarning() << "QEglContext::makeCurrent(" << surface << "):" << QEgl::errorString();
return ok;
}
diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h
index ffb45aa..7dad9fe 100644
--- a/src/gui/egl/qegl_p.h
+++ b/src/gui/egl/qegl_p.h
@@ -55,10 +55,14 @@
QT_BEGIN_INCLUDE_NAMESPACE
+#if defined(QT_OPENGL_ES_2)
+# include <GLES2/gl2.h>
+#endif
+
#if defined(QT_GLES_EGL)
-#include <GLES/egl.h>
+# include <GLES/egl.h>
#else
-#include <EGL/egl.h>
+# include <EGL/egl.h>
#endif
#if defined(Q_WS_X11)
@@ -97,10 +101,14 @@ QT_END_INCLUDE_NAMESPACE
#include <QtGui/qpaintdevice.h>
+#include <QFlags>
+
QT_BEGIN_NAMESPACE
#define QEGL_NO_CONFIG ((EGLConfig)-1)
+
+
class QEglProperties;
namespace QEgl {
@@ -116,12 +124,14 @@ namespace QEgl {
BestPixelFormat
};
- enum ConfigOptions
+ enum ConfigOption
{
NoOptions = 0,
Translucent = 0x01,
Renderable = 0x02 // Config will be compatable with the paint engines (VG or GL)
};
+ Q_DECLARE_FLAGS(ConfigOptions, ConfigOption);
+
// Most of the time we use the same config for things like widgets & pixmaps, so rather than
// go through the eglChooseConfig loop every time, we use defaultConfig, which will return
@@ -153,6 +163,7 @@ namespace QEgl {
#endif
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QEgl::ConfigOptions);
QT_END_NAMESPACE
diff --git a/src/gui/egl/qegl_wince.cpp b/src/gui/egl/qegl_wince.cpp
index c07b20b..2d08805 100644
--- a/src/gui/egl/qegl_wince.cpp
+++ b/src/gui/egl/qegl_wince.cpp
@@ -53,8 +53,7 @@ QT_BEGIN_NAMESPACE
EGLNativeDisplayType QEgl::nativeDisplay()
{
- HWND win = (static_cast<QWidget*>(device))->winId();
- HDC myDc = GetDC(win);
+ HDC myDc = GetDC(0);
if (!myDc) {
qWarning("QEglContext::nativeDisplay(): WinCE display is not open");
return EGL_DEFAULT_DISPLAY;
diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp
index 483c01d..91423c8 100644
--- a/src/gui/egl/qegl_x11.cpp
+++ b/src/gui/egl/qegl_x11.cpp
@@ -41,18 +41,19 @@
#include <QtCore/qdebug.h>
-#include <private/qt_x11_p.h>
+#include <QtGui/private/qt_x11_p.h>
#include <QtGui/qx11info_x11.h>
-#include <private/qpixmapdata_p.h>
-#include <private/qpixmap_x11_p.h>
+#include <QtGui/private/qpixmapdata_p.h>
+#include <QtGui/private/qpixmap_x11_p.h>
+#include <QtGui/private/qimagepixmapcleanuphooks_p.h>
#include <QtGui/qpaintdevice.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qwidget.h>
#include <QtGui/qcolormap.h>
-#include "qegl_p.h"
-#include "qeglcontext_p.h"
+#include "QtGui/private/qegl_p.h"
+#include "QtGui/private/qeglcontext_p.h"
QT_BEGIN_NAMESPACE
@@ -404,9 +405,12 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig config, const QEg
else
surfaceAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB);
- return eglCreatePixmapSurface(QEgl::display(), config,
- (EGLNativePixmapType) x11PixmapData->handle(),
- surfaceAttribs.properties());
+ EGLSurface surf = eglCreatePixmapSurface(QEgl::display(), config,
+ (EGLNativePixmapType) x11PixmapData->handle(),
+ surfaceAttribs.properties());
+ x11PixmapData->gl_surface = (void*)surf;
+ QImagePixmapCleanupHooks::enableCleanupHooks(x11PixmapData);
+ return surf;
}
return EGL_NO_SURFACE;
diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp
index 636f469..b5d3103 100644
--- a/src/gui/egl/qeglproperties.cpp
+++ b/src/gui/egl/qeglproperties.cpp
@@ -39,16 +39,13 @@
**
****************************************************************************/
-#include "qeglproperties_p.h"
-
-QT_BEGIN_NAMESPACE
-
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
#include "qeglproperties_p.h"
#include "qeglcontext_p.h"
+QT_BEGIN_NAMESPACE
// Initialize a property block.
QEglProperties::QEglProperties()
diff --git a/src/gui/embedded/directfb.pri b/src/gui/embedded/directfb.pri
index d6d77b4..75d693e 100644
--- a/src/gui/embedded/directfb.pri
+++ b/src/gui/embedded/directfb.pri
@@ -15,7 +15,7 @@
#DEFINES += QT_DIRECTFB_TIMING
#DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION
#DEFINES += QT_NO_DIRECTFB_STRETCHBLIT
-#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS|DRAW_ROUNDED_RECT|DRAW_STATICTEXT
+DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS|DRAW_ROUNDED_RECT|DRAW_STATICTEXT
#DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\"
#DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\"
diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp
index 65a3fb5..a3fe1ab 100644
--- a/src/gui/embedded/qscreen_qws.cpp
+++ b/src/gui/embedded/qscreen_qws.cpp
@@ -2740,7 +2740,7 @@ void QScreen::compose(int level, const QRegion &exposed, QRegion &blend,
default:
break;
}
- spanData.setup(qwsServer->backgroundBrush(), 256, QPainter::CompositionMode_SourceOver);
+ spanData.setup(qwsServer->backgroundBrush(), 256, QPainter::CompositionMode_Source);
spanData.dx = off.x();
spanData.dy = off.y();
} else if (!surface->isBuffered()) {
diff --git a/src/gui/embedded/qwsmanager_qws.cpp b/src/gui/embedded/qwsmanager_qws.cpp
index d6ef148..79076c5 100644
--- a/src/gui/embedded/qwsmanager_qws.cpp
+++ b/src/gui/embedded/qwsmanager_qws.cpp
@@ -267,8 +267,10 @@ void QWSManager::mouseMoveEvent(QMouseEvent *e)
#ifndef QT_NO_CURSOR
- QWSDisplay *qwsd = QApplication::desktop()->qwsDisplay();
- qwsd->selectCursor(d->managed, regionToShape(d->cachedRegionAt()));
+ if (d->managed->minimumSize() != d->managed->maximumSize()) {
+ QWSDisplay *qwsd = QApplication::desktop()->qwsDisplay();
+ qwsd->selectCursor(d->managed, regionToShape(d->cachedRegionAt()));
+ }
#endif //QT_NO_CURSOR
if (d->activeRegion)
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 4f06f80..b712016 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -641,10 +641,10 @@
are children of a modal panel are not blocked.
The values are:
-
+
\value NonModal The panel is not modal and does not block input to
other panels. This is the default value for panels.
-
+
\value PanelModal The panel is modal to a single item hierarchy
and blocks input to its parent pane, all grandparent panels, and
all siblings of its parent and grandparent panels.
@@ -2182,6 +2182,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
}
// Certain properties are dropped as an item becomes invisible.
+ bool hasFocus = q_ptr->hasFocus();
if (!newVisible) {
if (scene) {
if (scene->d_func()->mouseGrabberItems.contains(q))
@@ -2191,7 +2192,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
if (q->isPanel() && panelModality != QGraphicsItem::NonModal)
scene->d_func()->leaveModal(q_ptr);
}
- if (q_ptr->hasFocus() && scene) {
+ if (hasFocus && scene) {
// Hiding the closest non-panel ancestor of the focus item
QGraphicsItem *focusItem = scene->focusItem();
bool clear = true;
@@ -2204,7 +2205,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
} while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
}
if (clear)
- q_ptr->clearFocus();
+ clearFocusHelper(/* giveFocusToParent = */ false);
}
if (q_ptr->isSelected())
q_ptr->setSelected(false);
@@ -2242,26 +2243,45 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
}
// Enable subfocus
- if (scene && newVisible) {
- QGraphicsItem *p = parent;
- bool done = false;
- while (p) {
- if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
- QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
- if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
- done = true;
- while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible())
- fsi = fsi->d_ptr->focusScopeItem;
- scene->setFocusItem(fsi);
+ if (scene) {
+ if (newVisible) {
+ // Item is shown
+ QGraphicsItem *p = parent;
+ bool done = false;
+ while (p) {
+ if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
+ if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
+ done = true;
+ while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible())
+ fsi = fsi->d_ptr->focusScopeItem;
+ fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
+ /* focusFromShow = */ true);
+ }
+ break;
}
- break;
+ p = p->d_ptr->parent;
}
- p = p->d_ptr->parent;
- }
- if (!done) {
- QGraphicsItem *fi = subFocusItem;
- if (fi && fi != scene->focusItem()) {
- scene->setFocusItem(fi);
+ if (!done) {
+ QGraphicsItem *fi = subFocusItem;
+ if (fi && fi != scene->focusItem()) {
+ scene->setFocusItem(fi);
+ }
+ }
+ } else {
+ // Item is hidden
+ if (hasFocus) {
+ QGraphicsItem *p = parent;
+ while (p) {
+ if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ if (p->d_ptr->visible) {
+ p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
+ /* focusFromShow = */ true);
+ }
+ break;
+ }
+ p = p->d_ptr->parent;
+ }
}
}
}
@@ -3112,13 +3132,13 @@ bool QGraphicsItem::hasFocus() const
*/
void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
{
- d_ptr->setFocusHelper(focusReason, /* climb = */ true);
+ d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromShow = */ false);
}
/*!
\internal
*/
-void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb)
+void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow)
{
// Disabled / unfocusable items cannot accept focus.
if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable))
@@ -3138,7 +3158,7 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim
while (p) {
if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
p->d_ptr->focusScopeItem = q_ptr;
- if (!p->focusItem()) {
+ if (!p->focusItem() && !focusFromShow) {
// If you call setFocus on a child of a focus scope that
// doesn't currently have a focus item, then stop.
return;
@@ -3179,24 +3199,35 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim
*/
void QGraphicsItem::clearFocus()
{
- // Pass focus to the closest parent focus scope.
- if (!d_ptr->inDestructor) {
- QGraphicsItem *p = d_ptr->parent;
- while (p) {
- if (p->flags() & ItemIsFocusScope) {
- p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false);
- return;
+ d_ptr->clearFocusHelper(/* giveFocusToParent = */ true);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent)
+{
+ if (giveFocusToParent) {
+ // Pass focus to the closest parent focus scope
+ if (!inDestructor) {
+ QGraphicsItem *p = parent;
+ while (p) {
+ if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false,
+ /* focusFromShow = */ false);
+ return;
+ }
+ p = p->d_ptr->parent;
}
- p = p->d_ptr->parent;
}
}
// Invisible items with focus must explicitly clear subfocus.
- d_ptr->clearSubFocus(this);
+ clearSubFocus(q_ptr);
- if (hasFocus()) {
+ if (q_ptr->hasFocus()) {
// If this item has the scene's input focus, clear it.
- d_ptr->scene->setFocusItem(0);
+ scene->setFocusItem(0);
}
}
@@ -10817,6 +10848,7 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
}
}
+// sourceRect must be in the given coordinate system
QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const
{
QRectF effectRectF;
@@ -10826,7 +10858,8 @@ QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem sy
if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
if (info) {
- effectRectF = item->graphicsEffect()->boundingRectFor(boundingRect(Qt::DeviceCoordinates));
+ QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect);
+ effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect);
if (unpadded)
*unpadded = (effectRectF.size() == sourceRect.size());
if (info && system == Qt::LogicalCoordinates)
@@ -10875,30 +10908,6 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
}
- if (deviceCoordinates) {
- // Clip to viewport rect.
- int left, top, right, bottom;
- effectRect.getCoords(&left, &top, &right, &bottom);
- if (left < 0) {
- if (offset)
- offset->rx() += -left;
- effectRect.setX(0);
- }
- if (top < 0) {
- if (offset)
- offset->ry() += -top;
- effectRect.setY(0);
- }
- // NB! We use +-1 for historical reasons (see QRect documentation).
- QPaintDevice *device = info->painter->device();
- const int deviceWidth = device->width();
- const int deviceHeight = device->height();
- if (right + 1 > deviceWidth)
- effectRect.setRight(deviceWidth - 1);
- if (bottom + 1 > deviceHeight)
- effectRect.setBottom(deviceHeight -1);
-
- }
if (effectRect.isEmpty())
return QPixmap();
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index d72833b..56f94a2 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -540,10 +540,10 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
- Q_PROPERTY(QPointF pos READ pos WRITE setPos)
- Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
- Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged)
+ Q_PROPERTY(QPointF pos READ pos WRITE setPos FINAL)
+ Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL)
+ Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL)
+ Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged FINAL)
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint)
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 4c4bfaf..de8cf56 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -414,7 +414,8 @@ public:
inline void markParentDirty(bool updateBoundingRect = false);
- void setFocusHelper(Qt::FocusReason focusReason, bool climb);
+ void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow);
+ void clearFocusHelper(bool giveFocusToParent);
void setSubFocus(QGraphicsItem *rootItem = 0);
void clearSubFocus(QGraphicsItem *rootItem = 0);
void resetFocusProxy();
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 365afdd..159c997 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -228,6 +228,7 @@
#include <QtCore/qstack.h>
#include <QtCore/qtimer.h>
#include <QtCore/qvarlengtharray.h>
+#include <QtCore/QMetaMethod>
#include <QtGui/qapplication.h>
#include <QtGui/qdesktopwidget.h>
#include <QtGui/qevent.h>
@@ -277,8 +278,6 @@ static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraph
hover->setAccepted(mouseEvent->isAccepted());
}
-int QGraphicsScenePrivate::changedSignalIndex;
-
/*!
\internal
*/
@@ -329,9 +328,10 @@ void QGraphicsScenePrivate::init()
index = new QGraphicsSceneBspTreeIndex(q);
// Keep this index so we can check for connected slots later on.
- if (!changedSignalIndex) {
- changedSignalIndex = signalIndex("changed(QList<QRectF>)");
- }
+ changedSignalIndex = signalIndex("changed(QList<QRectF>)");
+ processDirtyItemsIndex = q->metaObject()->indexOfSlot("_q_processDirtyItems()");
+ polishItemsIndex = q->metaObject()->indexOfSlot("_q_polishItems()");
+
qApp->d_func()->scene_list.append(q);
q->update();
}
@@ -2537,8 +2537,10 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
return;
}
- if (d->unpolishedItems.isEmpty())
- QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection);
+ if (d->unpolishedItems.isEmpty()) {
+ QMetaMethod method = metaObject()->method(d->polishItemsIndex);
+ method.invoke(this, Qt::QueuedConnection);
+ }
d->unpolishedItems.append(item);
item->d_ptr->pendingPolish = true;
@@ -4728,31 +4730,18 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
if (sourced->currentCachedSystem() != Qt::LogicalCoordinates
&& sourced->lastEffectTransform != painter->worldTransform())
{
- bool unclipped = false;
if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate
&& painter->worldTransform().type() <= QTransform::TxTranslate)
{
- QRectF itemRect = item->boundingRect();
- if (!item->d_ptr->children.isEmpty())
- itemRect |= item->childrenBoundingRect();
+ QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates);
+ QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect);
- QRectF oldSourceRect = sourced->lastEffectTransform.mapRect(itemRect);
- QRectF newSourceRect = painter->worldTransform().mapRect(itemRect);
-
- QRect oldEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), oldSourceRect);
- QRect newEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), newSourceRect);
-
- QRect deviceRect(0, 0, painter->device()->width(), painter->device()->height());
- if (deviceRect.contains(oldEffectRect) && deviceRect.contains(newEffectRect)) {
- sourced->setCachedOffset(newEffectRect.topLeft());
- unclipped = true;
- }
+ sourced->setCachedOffset(effectRect.topLeft());
+ } else {
+ sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);
}
sourced->lastEffectTransform = painter->worldTransform();
-
- if (!unclipped)
- sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);
}
item->d_ptr->graphicsEffect->draw(painter);
@@ -4892,7 +4881,9 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b
return;
if (!processDirtyItemsEmitted) {
- QMetaObject::invokeMethod(q_ptr, "_q_processDirtyItems", Qt::QueuedConnection);
+ QMetaMethod method = q_ptr->metaObject()->method(processDirtyItemsIndex);
+ method.invoke(q_ptr, Qt::QueuedConnection);
+// QMetaObject::invokeMethod(q_ptr, "_q_processDirtyItems", Qt::QueuedConnection);
processDirtyItemsEmitted = true;
}
@@ -5972,12 +5963,12 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
QList<QGesture *> allGestures = event->gestures();
DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
- << "Delivering gestures:" << allGestures;
+ << "Gestures:" << allGestures;
QSet<QGesture *> startedGestures;
- QPoint delta = graphicsView->mapFromGlobal(QPoint());
- QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y())
- * graphicsView->viewportTransform().inverted();
+ QPoint delta = viewport->mapFromGlobal(QPoint());
+ QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y())
+ * graphicsView->viewportTransform().inverted();
foreach (QGesture *gesture, allGestures) {
// cache scene coordinates of the hot spot
if (gesture->hasHotSpot()) {
@@ -6003,7 +5994,8 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
cachedTargetItems = cachedItemGestures.keys();
qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
- << "Conflicting gestures:" << conflictedGestures;
+ << "Normal gestures:" << normalGestures
+ << "Conflicting gestures:" << conflictedGestures;
// deliver conflicted gestures as override events AND remember
// initial gesture targets
@@ -6080,6 +6072,10 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
const Qt::GestureFlags flags = d->gestureContext.value(gesture->gestureType());
if (flags & Qt::IgnoredGesturesPropagateToParent)
parentPropagatedGestures.insert(gesture);
+ } else {
+ DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
+ << "no target for" << gesture << "at"
+ << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
}
}
qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index ca8b829..11e250e 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -87,7 +87,9 @@ public:
static QGraphicsScenePrivate *get(QGraphicsScene *q);
- static int changedSignalIndex;
+ int changedSignalIndex;
+ int processDirtyItemsIndex;
+ int polishItemsIndex;
QGraphicsScene::ItemIndexMethod indexMethod;
QGraphicsSceneIndex *index;
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 1ced3d7..a767987 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -3360,12 +3360,6 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
backgroundPainter.setClipRegion(d->backgroundPixmapExposed, Qt::ReplaceClip);
if (viewTransformed)
backgroundPainter.setTransform(viewTransform);
-#ifdef Q_WS_X11
-#undef X11
- if (backgroundPainter.paintEngine()->type() != QPaintEngine::X11)
-#define X11 qt_x11Data
-#endif
- backgroundPainter.setCompositionMode(QPainter::CompositionMode_Source);
QRectF backgroundExposedSceneRect = mapToScene(d->backgroundPixmapExposed.boundingRect()).boundingRect();
drawBackground(&backgroundPainter, backgroundExposedSceneRect);
d->backgroundPixmapExposed = QRegion();
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index bf6eb8d..fad51f4 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -982,7 +982,9 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
icon = *cachedIcon;
}
- if (icon.availableSizes().isEmpty())
+ // Note the qapp check is to allow lazy loading of static icons
+ // Supporting fallbacks will not work for this case.
+ if (qApp && icon.availableSizes().isEmpty())
return fallback;
return icon;
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index b35e80a..72ec2e8 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -85,19 +85,30 @@ static QString fallbackTheme()
}
QIconLoader::QIconLoader() :
- m_themeKey(1), m_supportsSvg(false)
+ m_themeKey(1), m_supportsSvg(false), m_initialized(false)
{
- m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName();
- if (m_systemTheme.isEmpty())
- m_systemTheme = fallbackTheme();
+}
+
+// We lazily initialize the loader to make static icons
+// work. Though we do not officially support this.
+void QIconLoader::ensureInitialized()
+{
+ if (!m_initialized) {
+ m_initialized = true;
+
+ Q_ASSERT(qApp);
+ m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName();
+ if (m_systemTheme.isEmpty())
+ m_systemTheme = fallbackTheme();
#ifndef QT_NO_LIBRARY
- QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid,
- QLatin1String("/iconengines"),
- Qt::CaseInsensitive);
- if (iconFactoryLoader.keys().contains(QLatin1String("svg")))
- m_supportsSvg = true;
+ QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid,
+ QLatin1String("/iconengines"),
+ Qt::CaseInsensitive);
+ if (iconFactoryLoader.keys().contains(QLatin1String("svg")))
+ m_supportsSvg = true;
#endif //QT_NO_LIBRARY
+ }
}
QIconLoader *QIconLoader::instance()
@@ -339,6 +350,9 @@ bool QIconLoaderEngine::hasIcon() const
// Lazily load the icon
void QIconLoaderEngine::ensureLoaded()
{
+
+ iconLoaderInstance()->ensureInitialized();
+
if (!(iconLoaderInstance()->themeKey() == m_key)) {
while (!m_entries.isEmpty())
diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h
index 19f2dda..a6b5f5b 100644
--- a/src/gui/image/qiconloader_p.h
+++ b/src/gui/image/qiconloader_p.h
@@ -169,6 +169,7 @@ public:
static QIconLoader *instance();
void updateSystemTheme();
void invalidateKey() { m_themeKey++; }
+ void ensureInitialized();
private:
QThemeIconEntries findIconHelper(const QString &themeName,
@@ -176,6 +177,7 @@ private:
QStringList &visited) const;
uint m_themeKey;
bool m_supportsSvg;
+ bool m_initialized;
mutable QString m_userTheme;
mutable QString m_systemTheme;
diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp
index 517fcb0..521e348 100644
--- a/src/gui/image/qimagepixmapcleanuphooks.cpp
+++ b/src/gui/image/qimagepixmapcleanuphooks.cpp
@@ -96,6 +96,11 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook)
void QImagePixmapCleanupHooks::executePixmapDataModificationHooks(QPixmapData* pmd)
{
QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
+ // the global destructor for the pixmap and image hooks might have
+ // been called already if the app is "leaking" global
+ // pixmaps/images
+ if (!h)
+ return;
for (int i = 0; i < h->pixmapModificationHooks.count(); ++i)
h->pixmapModificationHooks[i](pmd);
@@ -106,6 +111,11 @@ void QImagePixmapCleanupHooks::executePixmapDataModificationHooks(QPixmapData* p
void QImagePixmapCleanupHooks::executePixmapDataDestructionHooks(QPixmapData* pmd)
{
QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
+ // the global destructor for the pixmap and image hooks might have
+ // been called already if the app is "leaking" global
+ // pixmaps/images
+ if (!h)
+ return;
for (int i = 0; i < h->pixmapDestructionHooks.count(); ++i)
h->pixmapDestructionHooks[i](pmd);
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index ae62f06..474cd2e 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -831,21 +831,14 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
if (QPixmapCache::find(key, *this))
return true;
- bool ok;
-
- if (data) {
- ok = data->fromFile(fileName, format, flags);
- } else {
- QScopedPointer<QPixmapData> tmp(QPixmapData::create(0, 0, QPixmapData::PixmapType));
- ok = tmp->fromFile(fileName, format, flags);
- if (ok)
- data = tmp.take();
- }
-
- if (ok)
+ QScopedPointer<QPixmapData> tmp(QPixmapData::create(0, 0, data ? data->type : QPixmapData::PixmapType));
+ if (tmp->fromFile(fileName, format, flags)) {
+ data = tmp.take();
QPixmapCache::insert(key, *this);
+ return true;
+ }
- return ok;
+ return false;
}
/*!
@@ -2046,12 +2039,16 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
over the one you grab, you get pixels from the overlying window,
too. The mouse cursor is generally not grabbed.
- Note on X11that if the given \a window doesn't have the same depth
+ Note on X11 that if the given \a window doesn't have the same depth
as the root window, and another window partially or entirely
obscures the one you grab, you will \e not get pixels from the
overlying window. The contents of the obscured areas in the
pixmap will be undefined and uninitialized.
+ On Windows Vista and above grabbing a layered window, which is
+ created by setting the Qt::WA_TranslucentBackground attribute, will
+ not work. Instead grabbing the desktop widget should work.
+
\warning In general, grabbing an area outside the screen is not
safe. This depends on the underlying window system.
diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h
index 521a612..7575838 100644
--- a/src/gui/image/qpixmap_x11_p.h
+++ b/src/gui/image/qpixmap_x11_p.h
@@ -94,7 +94,7 @@ public:
static Qt::HANDLE createBitmapFromImage(const QImage &image);
- Qt::HANDLE gl_surface;
+ void* gl_surface;
#ifndef QT_NO_XRENDER
void convertToARGB32(bool preserveContents = true);
#endif
diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp
index 0abf51f..5355ad3 100644
--- a/src/gui/image/qpixmapfilter.cpp
+++ b/src/gui/image/qpixmapfilter.cpp
@@ -777,6 +777,9 @@ void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transp
Q_GUI_EXPORT QImage qt_halfScaled(const QImage &source)
{
+ if (source.width() < 2 || source.height() < 2)
+ return QImage();
+
QImage srcImage = source;
if (source.format() == QImage::Format_Indexed8) {
@@ -869,7 +872,7 @@ Q_GUI_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, boo
}
qreal scale = 1;
- if (radius >= 4) {
+ if (radius >= 4 && blurImage.width() >= 2 && blurImage.height() >= 2) {
blurImage = qt_halfScaled(blurImage);
scale = 2;
radius *= qreal(0.5);
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index 1ac8ace..cc60246 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -551,6 +551,21 @@ void QCoeFepInputContext::StartFepInlineEditL(const TDesC& aInitialInlineText,
m_formatRetriever = &aInlineTextFormatRetriever;
m_pointerHandler = &aPointerEventHandlerDuringInlineEdit;
+ // With T9 aInitialInlineText is typically empty when StartFepInlineEditL is called,
+ // but FEP requires that selected text is always removed at StartFepInlineEditL.
+ // Let's remove the selected text if aInitialInlineText is empty and there is selected text
+ if (m_preeditString.isEmpty()) {
+ int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt();
+ int replacementLength = qAbs(m_cursorPos-anchor);
+ if (replacementLength > 0) {
+ int replacementStart = m_cursorPos < anchor ? 0 : -replacementLength;
+ QList<QInputMethodEvent::Attribute> clearSelectionAttributes;
+ QInputMethodEvent clearSelectionEvent(QLatin1String(""), clearSelectionAttributes);
+ clearSelectionEvent.setCommitString(QLatin1String(""), replacementStart, replacementLength);
+ sendEvent(clearSelectionEvent);
+ }
+ }
+
applyFormat(&attributes);
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index bc6db90..2faf755 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -2568,6 +2568,7 @@ void QAbstractItemView::updateEditorGeometries()
QStyleOptionViewItemV4 option = d->viewOptionsV4();
QList<QEditorInfo>::iterator it = d->editors.begin();
QWidgetList editorsToRelease;
+ QWidgetList editorsToHide;
while (it != d->editors.end()) {
QModelIndex index = it->index;
QWidget *editor = it->editor;
@@ -2579,7 +2580,7 @@ void QAbstractItemView::updateEditorGeometries()
if (delegate)
delegate->updateEditorGeometry(editor, option, index);
} else {
- editor->hide();
+ editorsToHide << editor;
}
++it;
} else {
@@ -2588,8 +2589,11 @@ void QAbstractItemView::updateEditorGeometries()
}
}
- //we release the editor outside of the loop because it might change the focus and try
+ //we hide and release the editor outside of the loop because it might change the focus and try
//to change the d->editors list.
+ for (int i = 0; i < editorsToHide.count(); ++i) {
+ editorsToHide.at(i)->hide();
+ }
for (int i = 0; i < editorsToRelease.count(); ++i) {
d->releaseEditor(editorsToRelease.at(i));
}
@@ -3046,6 +3050,7 @@ void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget
if (!d->isIndexValid(index))
return;
if (QWidget *oldWidget = indexWidget(index)) {
+ d->persistent.remove(oldWidget);
d->removeEditor(oldWidget);
oldWidget->deleteLater();
}
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index 9069ce4..7d8e103 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -1297,14 +1297,8 @@ bool QItemDelegate::editorEvent(QEvent *event,
return false;
}
- Qt::CheckState state;
- if ( flags & Qt::ItemIsTristate ) {
- state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 );
- } else {
- state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
+ Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
? Qt::Unchecked : Qt::Checked);
- }
-
return model->setData(index, state, Qt::CheckStateRole);
}
diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp
index 9aac554..880f8ab 100644
--- a/src/gui/itemviews/qstyleditemdelegate.cpp
+++ b/src/gui/itemviews/qstyleditemdelegate.cpp
@@ -747,13 +747,8 @@ bool QStyledItemDelegate::editorEvent(QEvent *event,
return false;
}
- Qt::CheckState state;
- if ( flags & Qt::ItemIsTristate ) {
- state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 );
- } else {
- state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
+ Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
? Qt::Unchecked : Qt::Checked);
- }
return model->setData(index, state, Qt::CheckStateRole);
}
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index bdc1205..46fd9d0 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -1908,6 +1908,7 @@ QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) co
width, rowHeight(r)));
}
} else { // nothing moved
+ const int gridAdjust = showGrid() ? 1 : 0;
for (int i = 0; i < selection.count(); ++i) {
QItemSelectionRange range = selection.at(i);
if (range.parent() != d->root || !range.isValid())
@@ -1916,9 +1917,16 @@ QRegion QTableView::visualRegionForSelection(const QItemSelection &selection) co
const int rtop = rowViewportPosition(range.top());
const int rbottom = rowViewportPosition(range.bottom()) + rowHeight(range.bottom());
- const int rleft = columnViewportPosition(range.left());
- const int rright = columnViewportPosition(range.right()) + columnWidth(range.right());
- selectionRegion += QRect(QPoint(rleft, rtop), QPoint(rright, rbottom));
+ int rleft;
+ int rright;
+ if (isLeftToRight()) {
+ rleft = columnViewportPosition(range.left());
+ rright = columnViewportPosition(range.right()) + columnWidth(range.right());
+ } else {
+ rleft = columnViewportPosition(range.right());
+ rright = columnViewportPosition(range.left()) + columnWidth(range.left());
+ }
+ selectionRegion += QRect(QPoint(rleft, rtop), QPoint(rright - 1 - gridAdjust, rbottom - 1 - gridAdjust));
if (d->hasSpans()) {
foreach (QSpanCollection::Span *s,
d->spans.spansInRect(range.left(), range.top(), range.width(), range.height())) {
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 1145235..78184a9 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -679,16 +679,20 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto
d->defaultItemHeight = indexRowSizeHint(topLeft);
bool sizeChanged = false;
if (topViewIndex != -1) {
- if (topLeft == bottomRight) {
+ if (topLeft.row() == bottomRight.row()) {
int oldHeight = d->itemHeight(topViewIndex);
d->invalidateHeightCache(topViewIndex);
sizeChanged = (oldHeight != d->itemHeight(topViewIndex));
+ if (topLeft.column() == 0)
+ d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft);
} else {
int bottomViewIndex = d->viewIndex(bottomRight);
for (int i = topViewIndex; i <= bottomViewIndex; ++i) {
int oldHeight = d->itemHeight(i);
d->invalidateHeightCache(i);
sizeChanged |= (oldHeight != d->itemHeight(i));
+ if (topLeft.column() == 0)
+ d->viewItems[i].hasChildren = d->hasVisibleChildren(d->viewItems.at(i).index);
}
}
}
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 4ec2ae2..fea8c37 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -498,9 +498,7 @@ inline bool QApplicationPrivate::isAlien(QWidget *widget)
{
if (!widget)
return false;
-#if defined(Q_WS_MAC) // Fake alien behavior on the Mac :)
- return !widget->isWindow() && widget->window()->testAttribute(Qt::WA_DontShowOnScreen);
-#elif defined(Q_WS_QWS)
+#if defined(Q_WS_QWS)
return !widget->isWindow()
# ifdef Q_BACKINGSTORE_SUBSURFACES
&& !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface)
@@ -2311,6 +2309,19 @@ static bool qt_detectRTLLanguage()
" languages or to 'RTL' in right-to-left languages (such as Hebrew"
" and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
}
+#if defined(QT_MAC_USE_COCOA)
+static const char *application_menu_strings[] = {
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All")
+ };
+QString qt_mac_applicationmenu_string(int type)
+{
+ return qApp->translate("MAC_APPLICATION_MENU",
+ application_menu_strings[type]);
+}
+#endif
#endif
/*!\reimp
@@ -2339,6 +2350,9 @@ bool QApplication::event(QEvent *e)
#ifndef QT_NO_TRANSLATION
setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight);
#endif
+#if defined(QT_MAC_USE_COCOA)
+ qt_mac_post_retranslateAppMenu();
+#endif
QWidgetList list = topLevelWidgets();
for (int i = 0; i < list.size(); ++i) {
QWidget *w = list.at(i);
@@ -3013,7 +3027,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
return result;
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC)
/*
This function should only be called when the widget changes visibility, i.e.
when the \a widget is shown, hidden or deleted. This function does nothing
@@ -3073,7 +3087,7 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver);
#endif // QT_NO_CURSOR
}
-#endif // Q_WS_WIN || Q_WS_X11
+#endif // Q_WS_WIN || Q_WS_X11 || Q_WS_MAC
/*!
Returns the desktop widget (also called the root window).
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index babfc72..c7d0e48 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -184,7 +184,8 @@ bool qt_mac_app_fullscreen = false;
bool qt_scrollbar_jump_to_pos = false;
static bool qt_mac_collapse_on_dblclick = true;
extern int qt_antialiasing_threshold; // from qapplication.cpp
-QPointer<QWidget> qt_button_down; // widget got last button-down
+QWidget * qt_button_down; // widget got last button-down
+QPointer<QWidget> qt_last_mouse_receiver;
#ifndef QT_MAC_USE_COCOA
static bool qt_button_down_in_content; // whether the button_down was in the content area.
static bool qt_mac_previous_press_in_popup_mode = false;
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index e0a6103..6d71cfe 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -514,7 +514,7 @@ public:
int symbianResourceChange(const QSymbianEvent *symbianEvent);
#endif
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
void sendSyntheticEnterLeave(QWidget *widget);
#endif
@@ -543,6 +543,7 @@ public:
const QList<QTouchEvent::TouchPoint> &touchPoints);
#if defined(Q_WS_WIN)
+ static bool HasTouchSupport;
static PtrRegisterTouchWindow RegisterTouchWindow;
static PtrGetTouchInputInfo GetTouchInputInfo;
static PtrCloseTouchInputHandle CloseTouchInputHandle;
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index baefdfd..ccc39c9 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -597,9 +597,9 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod
TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode,
keyEvent.iCode);
int keyCode;
- if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used
- keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode);
- } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) {
+ if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used
+ keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode);
+ } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) {
// Normal characters keys.
keyCode = s60Keysym;
} else {
@@ -966,13 +966,26 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */)
qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle());
#ifdef Q_WS_S60
// If widget is fullscreen/minimized, hide status pane and button container otherwise show them.
- CEikStatusPane* statusPane = S60->statusPane();
- CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer();
+ CEikStatusPane *statusPane = S60->statusPane();
+ CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer();
TBool visible = !(qwidget->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized));
if (statusPane)
statusPane->MakeVisible(visible);
- if (buttonGroup)
- buttonGroup->MakeVisible(visible);
+ if (buttonGroup) {
+ // Visibility
+ const TBool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen;
+ const TBool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint;
+ buttonGroup->MakeVisible(visible || (isFullscreen && cbaVisibilityHint));
+
+ // Responsiviness
+ CEikCba *cba = static_cast<CEikCba *>( buttonGroup->ButtonGroup() ); // downcast from MEikButtonGroup
+ TUint cbaFlags = cba->ButtonGroupFlags();
+ if(qwidget->windowFlags() & Qt::WindowSoftkeysRespondHint)
+ cbaFlags |= EAknCBAFlagRespondWhenInvisible;
+ else
+ cbaFlags &= ~EAknCBAFlagRespondWhenInvisible;
+ cba->SetButtonGroupFlags(cbaFlags);
+ }
#endif
} else if (QApplication::activeWindow() == qwidget->window()) {
if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) {
@@ -1016,6 +1029,16 @@ void QSymbianControl::HandleResourceChange(int resourceType)
} else if (qwidget->isMaximized()) {
TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
SetExtent(r.iTl, r.Size());
+ } else if (!qwidget->isMinimized()){ // Normal geometry
+ if (!qwidget->testAttribute(Qt::WA_Resized)) {
+ qwidget->adjustSize();
+ qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize
+ }
+ if (!qwidget->testAttribute(Qt::WA_Moved)) {
+ TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect();
+ SetPosition(r.iTl);
+ qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position
+ }
}
break;
}
@@ -1229,7 +1252,7 @@ void qt_init(QApplicationPrivate * /* priv */, int)
S60->avkonComponentsSupportTransparency = (value==1) ? true : false;
}
}
-#endif
+#endif
if (touch) {
QApplicationPrivate::navigationMode = Qt::NavigationModeNone;
@@ -1450,6 +1473,9 @@ void QApplicationPrivate::closePopup(QWidget *popup)
QWidget *fw = QApplicationPrivate::active_window ? QApplicationPrivate::active_window->focusWidget()
: q_func()->focusWidget();
if (fw) {
+ if(fw->window()->isModal()) // restore pointer capture for modal window
+ fw->effectiveWinId()->SetPointerCapture(true);
+
if (fw != q_func()->focusWidget()) {
fw->setFocus(Qt::PopupFocusReason);
} else {
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 131b9bb..9872514 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -115,6 +115,8 @@ extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.c
# include <winable.h>
#endif
+#include "private/qwinnativepangesturerecognizer_win_p.h"
+
#ifndef WM_TOUCH
# define WM_TOUCH 0x0240
@@ -2524,6 +2526,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
result = false;
break;
+#if !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
case WM_GESTURE: {
GESTUREINFO gi;
memset(&gi, 0, sizeof(GESTUREINFO));
@@ -2556,6 +2559,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
result = true;
break;
}
+#endif // !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
#ifndef QT_NO_CURSOR
case WM_SETCURSOR: {
QCursor *ovr = QApplication::overrideCursor();
@@ -4012,12 +4016,45 @@ void QSessionManager::cancel()
#endif //QT_NO_SESSIONMANAGER
+bool QApplicationPrivate::HasTouchSupport = false;
PtrRegisterTouchWindow QApplicationPrivate::RegisterTouchWindow = 0;
PtrGetTouchInputInfo QApplicationPrivate::GetTouchInputInfo = 0;
PtrCloseTouchInputHandle QApplicationPrivate::CloseTouchInputHandle = 0;
void QApplicationPrivate::initializeMultitouch_sys()
{
+ static const IID QT_IID_IInkTablets = {0x112086D9, 0x7779, 0x4535, {0xA6, 0x99, 0x86, 0x2B, 0x43, 0xAC, 0x18, 0x63} };
+ static const IID QT_IID_IInkTablet2 = {0x90c91ad2, 0xfa36, 0x49d6, {0x95, 0x16, 0xce, 0x8d, 0x57, 0x0f, 0x6f, 0x85} };
+ static const CLSID QT_CLSID_InkTablets = {0x6E4FCB12, 0x510A, 0x4d40, {0x93, 0x04, 0x1D, 0xA1, 0x0A, 0xE9, 0x14, 0x7C} };
+
+ IInkTablets *iInkTablets = 0;
+ HRESULT hr = CoCreateInstance(QT_CLSID_InkTablets, NULL, CLSCTX_ALL, QT_IID_IInkTablets, (void**)&iInkTablets);
+ if (SUCCEEDED(hr)) {
+ long count = 0;
+ iInkTablets->get_Count(&count);
+ for (long i = 0; i < count; ++i) {
+ IInkTablet *iInkTablet = 0;
+ hr = iInkTablets->Item(i, &iInkTablet);
+ if (FAILED(hr))
+ continue;
+ IInkTablet2 *iInkTablet2 = 0;
+ hr = iInkTablet->QueryInterface(QT_IID_IInkTablet2, (void**)&iInkTablet2);
+ iInkTablet->Release();
+ if (FAILED(hr))
+ continue;
+ TabletDeviceKind kind;
+ hr = iInkTablet2->get_DeviceKind(&kind);
+ iInkTablet2->Release();
+ if (FAILED(hr))
+ continue;
+ if (kind == TDK_Touch) {
+ QApplicationPrivate::HasTouchSupport = true;
+ break;
+ }
+ }
+ iInkTablets->Release();
+ }
+
QLibrary library(QLatin1String("user32"));
// MinGW (g++ 3.4.5) accepts only C casts.
RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 3c2c743..20a7ff2 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -96,6 +96,11 @@ extern "C" {
}
#endif
+#ifndef QT_GUI_DOUBLE_CLICK_RADIUS
+#define QT_GUI_DOUBLE_CLICK_RADIUS 5
+#endif
+
+
//#define ALIEN_DEBUG
#if !defined(QT_NO_GLIB)
@@ -312,9 +317,14 @@ static const char * x11_atomnames = {
"_XEMBED\0"
"_XEMBED_INFO\0"
+ // Wacom old. (before version 0.10)
"Wacom Stylus\0"
"Wacom Cursor\0"
"Wacom Eraser\0"
+
+ // Tablet
+ "STYLUS\0"
+ "ERASER\0"
};
Q_GUI_EXPORT QX11Data *qt_x11Data = 0;
@@ -2340,12 +2350,12 @@ void qt_init(QApplicationPrivate *priv, int,
gotStylus = true;
}
#else
- if (devs->type == ATOM(XWacomStylus)) {
+ if (devs->type == ATOM(XWacomStylus) || devs->type == ATOM(XTabletStylus)) {
deviceType = QTabletEvent::Stylus;
if (wacomDeviceName()->isEmpty())
wacomDeviceName()->append(devs->name);
gotStylus = true;
- } else if (devs->type == ATOM(XWacomEraser)) {
+ } else if (devs->type == ATOM(XWacomEraser) || devs->type == ATOM(XTabletEraser)) {
deviceType = QTabletEvent::XFreeEraser;
gotEraser = true;
}
@@ -4194,8 +4204,8 @@ bool QETWidget::translateMouseEvent(const XEvent *event)
mouseButtonPressed == button &&
(long)event->xbutton.time -(long)mouseButtonPressTime
< QApplication::doubleClickInterval() &&
- qAbs(event->xbutton.x - mouseXPos) < 5 &&
- qAbs(event->xbutton.y - mouseYPos) < 5) {
+ qAbs(event->xbutton.x - mouseXPos) < QT_GUI_DOUBLE_CLICK_RADIUS &&
+ qAbs(event->xbutton.y - mouseYPos) < QT_GUI_DOUBLE_CLICK_RADIUS) {
type = QEvent::MouseButtonDblClick;
mouseButtonPressTime -= 2000; // no double-click next time
} else {
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index a59bb98..f7c0b6e 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -107,6 +107,12 @@ QT_BEGIN_NAMESPACE
store or retrieve the clipboard contents in response to timer or
non-user-input events.
+ \i Since there is no standard way to copy and paste files between
+ applications on X11, various MIME types and conventions are currently
+ in use. For instance, Nautilus expects files to be supplied with a
+ \c{x-special/gnome-copied-files} MIME type with data beginning with
+ the cut/copy action, a newline character, and the URL of the file.
+
\endlist
\section1 Notes for Mac OS X Users
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
index ab71a05..5dcf613 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
@@ -179,7 +179,7 @@ static void cleanupCocoaApplicationDelegate()
}
// This function will only be called when NSApp is actually running. Before
-// that, the kAEQuitApplication apple event will be sendt to
+// that, the kAEQuitApplication Apple event will be sent to
// QApplicationPrivate::globalAppleEventProcessor in qapplication_mac.mm
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
@@ -196,21 +196,18 @@ static void cleanupCocoaApplicationDelegate()
qAppInstance()->quit();
startedQuit = false;
}
+ return NSTerminateNow;
}
if (qtPrivate->threadData->eventLoops.size() == 0) {
// INVARIANT: No event loop is executing. This probably
// means that Qt is used as a plugin, or as a part of a native
- // Cocoa application. In any case it should be fine to
+ // Cocoa application. In any case it should be fine to
// terminate now:
return NSTerminateNow;
- } else {
- // Prevent Cocoa from terminating the application, since this simply
- // exits the program whithout allowing QApplication::exec() to return.
- // The call to QApplication::quit() above will instead quit the
- // application from the Qt side.
- return NSTerminateCancel;
}
+
+ return NSTerminateCancel;
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm
index 573b763..35d156a 100644
--- a/src/gui/kernel/qcocoamenuloader_mac.mm
+++ b/src/gui/kernel/qcocoamenuloader_mac.mm
@@ -48,6 +48,7 @@
#include <private/qt_mac_p.h>
#include <private/qmenubar_p.h>
#include <qmenubar.h>
+#include <private/qt_cocoa_helpers_mac_p.h>
QT_FORWARD_DECLARE_CLASS(QCFString)
QT_FORWARD_DECLARE_CLASS(QString)
@@ -58,6 +59,10 @@ QT_USE_NAMESPACE
- (void)awakeFromNib
{
+ servicesItem = [[appMenu itemWithTitle:@"Services"] retain];
+ hideAllOthersItem = [[appMenu itemWithTitle:@"Hide Others"] retain];
+ showAllItem = [[appMenu itemWithTitle:@"Show All"] retain];
+
// Get the names in the nib to match the app name set by Qt.
NSString *appName = reinterpret_cast<const NSString*>(QCFString::toCFStringRef(qAppName()));
[quitItem setTitle:[[quitItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
@@ -119,6 +124,10 @@ QT_USE_NAMESPACE
- (void)dealloc
{
+ [servicesItem release];
+ [hideAllOthersItem release];
+ [showAllItem release];
+
[lastAppSpecificItem release];
[theMenu release];
[appMenu release];
@@ -214,6 +223,17 @@ QT_USE_NAMESPACE
QMenuBarPrivate::macUpdateMenuBarImmediatly();
}
+- (void)qtTranslateApplicationMenu
+{
+#ifndef QT_NO_TRANSLATION
+ extern QString qt_mac_applicationmenu_string(int type);
+ [servicesItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(0))];
+ [hideItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(1).arg(qAppName()))];
+ [hideAllOthersItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(2))];
+ [showAllItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(3))];
+#endif
+}
+
- (IBAction)qtDispatcherToQAction:(id)sender
{
QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData);
diff --git a/src/gui/kernel/qcocoamenuloader_mac_p.h b/src/gui/kernel/qcocoamenuloader_mac_p.h
index 2504b8c..a75ad0a 100644
--- a/src/gui/kernel/qcocoamenuloader_mac_p.h
+++ b/src/gui/kernel/qcocoamenuloader_mac_p.h
@@ -67,7 +67,9 @@
IBOutlet NSMenuItem *aboutQtItem;
IBOutlet NSMenuItem *hideItem;
NSMenuItem *lastAppSpecificItem;
-
+ NSMenuItem *servicesItem;
+ NSMenuItem *hideAllOthersItem;
+ NSMenuItem *showAllItem;
}
- (void)ensureAppMenuInMenu:(NSMenu *)menu;
- (void)removeActionsFromAppMenu;
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 6a16403..f7cb21f 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -185,6 +185,9 @@ extern "C" {
extern NSString *NSTextInputReplacementRangeAttributeName;
}
+#ifdef ALIEN_DEBUG
+static int qCocoaViewCount = 0;
+#endif
@implementation QT_MANGLE_NAMESPACE(QCocoaView)
@@ -195,6 +198,12 @@ extern "C" {
[self finishInitWithQWidget:widget widgetPrivate:widgetprivate];
}
composingText = new QString();
+
+#ifdef ALIEN_DEBUG
+ ++qCocoaViewCount;
+ qDebug() << "init: qCocoaViewCount is" << qCocoaViewCount;
+#endif
+
composing = false;
sendKeyEvents = true;
[self setHidden:YES];
@@ -414,6 +423,12 @@ extern "C" {
{
delete composingText;
[[NSNotificationCenter defaultCenter] removeObserver:self];
+
+#ifdef ALIEN_DEBUG
+ --qCocoaViewCount;
+ qDebug() << "qCocoaViewCount is" << qCocoaViewCount;
+#endif
+
[super dealloc];
}
@@ -523,6 +538,10 @@ extern "C" {
CGContextClearRect(cg, NSRectToCGRect(aRect));
}
+ // Check for alien widgets, use qwidgetPrivate->drawWidget() to draw the widget if this
+ // is the case. This makes sure child widgets are drawn as well, Cocoa does not know about
+ // those and wont send them drawRect calls.
+ if (qwidget->testAttribute(Qt::WA_NativeWindow) && qt_widget_private(qwidget)->hasAlienChildren == false) {
if (engine && !qwidget->testAttribute(Qt::WA_NoSystemBackground)
&& (qwidget->isWindow() || qwidget->autoFillBackground())
|| qwidget->testAttribute(Qt::WA_TintedBackground)
@@ -542,6 +561,12 @@ extern "C" {
e.setErased(true);
#endif
qt_sendSpontaneousEvent(qwidget, &e);
+ } else {
+ qwidget->setAttribute(Qt::WA_WState_InPaintEvent, false); // QWidgetPrivate::drawWidget sets this
+ QWidgetPrivate *qwidgetPrivate = qt_widget_private(qwidget);
+ qwidgetPrivate->drawWidget(qwidget, qrgn, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen | QWidgetPrivate::DrawRecursive, 0);
+ }
+
if (!redirectionOffset.isNull())
QPainter::restoreRedirected(qwidget);
if (engine)
@@ -1003,7 +1028,10 @@ extern "C" {
{
if (!qwidget)
return NO;
- if (qwidget->isWindow())
+ // Before accepting the focus for a window, we check that
+ // the focusWidget (if any) is not contained in the same window.
+ if (qwidget->isWindow() && (!qApp->focusWidget()
+ || qApp->focusWidget()->window() != qwidget))
return YES; // Always do it, so that windows can accept key press events.
return qwidget->focusPolicy() != Qt::NoFocus;
}
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index 89ad94d..aa6720e 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -45,6 +45,7 @@
#include "private/qgesture_p.h"
#include "private/qgraphicsitem_p.h"
#include "private/qevent_p.h"
+#include "private/qapplication_p.h"
#include "qgesture.h"
#include "qevent.h"
#include "qgraphicsitem.h"
@@ -86,7 +87,8 @@ QGestureManager::QGestureManager(QObject *parent)
#endif
#if defined(Q_OS_WIN)
#if !defined(QT_NO_NATIVE_GESTURES)
- registerGestureRecognizer(new QWinNativePanGestureRecognizer);
+ if (QApplicationPrivate::HasTouchSupport)
+ registerGestureRecognizer(new QWinNativePanGestureRecognizer);
#endif
#else
registerGestureRecognizer(new QTapAndHoldGestureRecognizer);
diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp
index ac4cdc8..f5004b0 100644
--- a/src/gui/kernel/qguifunctions_wince.cpp
+++ b/src/gui/kernel/qguifunctions_wince.cpp
@@ -278,7 +278,14 @@ int qt_wince_get_version()
bool qt_wince_is_windows_mobile_65()
{
- return ((qt_wince_get_version() == 52) && (qt_wince_get_build() > 2000));
+ const DWORD dwFirstWM65BuildNumber = 21139;
+ OSVERSIONINFO osvi;
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ if (!GetVersionEx(&osvi))
+ return false;
+ return osvi.dwMajorVersion > 5
+ || (osvi.dwMajorVersion == 5 && (osvi.dwMinorVersion > 2 ||
+ (osvi.dwMinorVersion == 2 && osvi.dwBuildNumber >= dwFirstWM65BuildNumber)));
}
bool qt_wince_is_pocket_pc() {
diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp
index 4e6c847..d6d1042 100644
--- a/src/gui/kernel/qkeymapper_x11.cpp
+++ b/src/gui/kernel/qkeymapper_x11.cpp
@@ -1073,8 +1073,8 @@ static const unsigned int KeyTbl[] = {
XF86XK_AudioNext, Qt::Key_MediaNext,
XF86XK_AudioRecord, Qt::Key_MediaRecord,
XF86XK_Mail, Qt::Key_LaunchMail,
- XF86XK_MyComputer, Qt::Key_Launch0,
- XF86XK_Calculator, Qt::Key_Calculator,
+ XF86XK_MyComputer, Qt::Key_Launch0, // ### Qt 5: remap properly
+ XF86XK_Calculator, Qt::Key_Launch1,
XF86XK_Memo, Qt::Key_Memo,
XF86XK_ToDoList, Qt::Key_ToDoList,
XF86XK_Calendar, Qt::Key_Calendar,
@@ -1172,7 +1172,7 @@ static const unsigned int KeyTbl[] = {
XF86XK_Bluetooth, Qt::Key_Bluetooth,
XF86XK_Suspend, Qt::Key_Suspend,
XF86XK_Hibernate, Qt::Key_Hibernate,
- XF86XK_Launch0, Qt::Key_Launch2,
+ XF86XK_Launch0, Qt::Key_Launch2, // ### Qt 5: remap properly
XF86XK_Launch1, Qt::Key_Launch3,
XF86XK_Launch2, Qt::Key_Launch4,
XF86XK_Launch3, Qt::Key_Launch5,
@@ -1186,6 +1186,8 @@ static const unsigned int KeyTbl[] = {
XF86XK_LaunchB, Qt::Key_LaunchD,
XF86XK_LaunchC, Qt::Key_LaunchE,
XF86XK_LaunchD, Qt::Key_LaunchF,
+ XF86XK_LaunchE, Qt::Key_LaunchG,
+ XF86XK_LaunchF, Qt::Key_LaunchH,
// Qtopia keys
QTOPIAXK_Select, Qt::Key_Select,
diff --git a/src/gui/kernel/qmime_win.cpp b/src/gui/kernel/qmime_win.cpp
index e191d7b..2840843 100644
--- a/src/gui/kernel/qmime_win.cpp
+++ b/src/gui/kernel/qmime_win.cpp
@@ -640,14 +640,18 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
} else if (getCf(formatetc) == CF_INETURL_W) {
QList<QUrl> urls = mimeData->urls();
QByteArray result;
- QString url = urls.at(0).toString();
- result = QByteArray((const char *)url.utf16(), url.length() * sizeof(ushort));
+ if (!urls.isEmpty()) {
+ QString url = urls.at(0).toString();
+ result = QByteArray((const char *)url.utf16(), url.length() * sizeof(ushort));
+ }
result.append('\0');
result.append('\0');
return setData(result, pmedium);
} else if (getCf(formatetc) == CF_INETURL) {
QList<QUrl> urls = mimeData->urls();
- QByteArray result = urls.at(0).toString().toLocal8Bit();
+ QByteArray result;
+ if (!urls.isEmpty())
+ result = urls.at(0).toString().toLocal8Bit();
return setData(result, pmedium);
}
}
@@ -948,6 +952,8 @@ bool QWindowsMimeImage::convertFromMime(const FORMATETC &formatetc, const QMimeD
QDataStream s(&ba, QIODevice::WriteOnly);
s.setByteOrder(QDataStream::LittleEndian);// Intel byte order ####
if (cf == CF_DIB) {
+ if (img.format() > QImage::Format_ARGB32)
+ img = img.convertToFormat(QImage::Format_RGB32);
if (qt_write_dib(s, img))
return setData(ba, pmedium);
} else {
diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp
index 8ac1e31..3a0304c 100644
--- a/src/gui/kernel/qsoftkeymanager_s60.cpp
+++ b/src/gui/kernel/qsoftkeymanager_s60.cpp
@@ -60,7 +60,7 @@ const int LSK_POSITION = 0;
const int MSK_POSITION = 3;
const int RSK_POSITION = 2;
-QSoftKeyManagerPrivateS60::QSoftKeyManagerPrivateS60()
+QSoftKeyManagerPrivateS60::QSoftKeyManagerPrivateS60() : cbaHasImage(4) // 4 since MSK position index is 3
{
cachedCbaIconSize[0] = QSize(0,0);
cachedCbaIconSize[1] = QSize(0,0);
@@ -73,11 +73,21 @@ bool QSoftKeyManagerPrivateS60::skipCbaUpdate()
// Lets not update softkeys if
// 1. We don't have application panes, i.e. cba
// 2. Our CBA is not active, i.e. S60 native dialog or menu with custom CBA is shown
+ // 2.1. Except if thre is no current CBA at all and WindowSoftkeysRespondHint is set
+
// Note: Cannot use IsDisplayingMenuOrDialog since CBA update can be triggered before
// menu/dialog CBA is actually displayed i.e. it is being costructed.
CEikButtonGroupContainer *appUiCba = S60->buttonGroupContainer();
+ // CEikButtonGroupContainer::Current returns 0 if CBA is not visible at all
CEikButtonGroupContainer *currentCba = CEikButtonGroupContainer::Current();
- if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) || appUiCba != currentCba) {
+ // Check if softkey need to be update even they are not visible
+ bool cbaRespondsWhenInvisible = false;
+ QWidget *window = QApplication::activeWindow();
+ if (window && (window->windowFlags() & Qt::WindowSoftkeysRespondHint))
+ cbaRespondsWhenInvisible = true;
+
+ if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)
+ || (appUiCba != currentCba && !cbaRespondsWhenInvisible)) {
return true;
}
return false;
@@ -255,10 +265,14 @@ bool QSoftKeyManagerPrivateS60::setSoftkeyImage(CEikButtonGroupContainer *cba,
myimage->SetPicture( nBitmap, nMask ); // nBitmap and nMask ownership transfered
EikSoftkeyImage::SetImage(cba, *myimage, left); // Takes myimage ownership
+ cbaHasImage[position] = true;
ret = true;
} else {
// Restore softkey to text based
- EikSoftkeyImage::SetLabel(cba, left);
+ if (cbaHasImage[position]) {
+ EikSoftkeyImage::SetLabel(cba, left);
+ cbaHasImage[position] = false;
+ }
}
}
return ret;
@@ -274,7 +288,12 @@ bool QSoftKeyManagerPrivateS60::setSoftkey(CEikButtonGroupContainer &cba,
TPtrC nativeText = qt_QString2TPtrC(text);
int command = S60_COMMAND_START + position;
setNativeSoftkey(cba, position, command, nativeText);
- cba.DimCommand(command, !action->isEnabled());
+ // QMainWindow "Options" action is set to invisible in order it does not appear in context menu
+ // and all invisible actions are by default disabled.
+ // However we never want to dim options softkey, even it is set to invisible
+ QVariant property = action->property(MENU_ACTION_PROPERTY);
+ const bool dimmed = (property.isValid() && property.toBool()) ? false : !action->isEnabled();
+ cba.DimCommand(command, dimmed);
realSoftKeyActions.insert(command, action);
return true;
}
@@ -311,7 +330,10 @@ bool QSoftKeyManagerPrivateS60::setRightSoftkey(CEikButtonGroupContainer &cba)
if (windowType != Qt::Dialog && windowType != Qt::Popup) {
QString text(QSoftKeyManager::tr("Exit"));
TPtrC nativeText = qt_QString2TPtrC(text);
- EikSoftkeyImage::SetLabel(&cba, false);
+ if (cbaHasImage[RSK_POSITION]) {
+ EikSoftkeyImage::SetLabel(&cba, false);
+ cbaHasImage[RSK_POSITION] = false;
+ }
setNativeSoftkey(cba, RSK_POSITION, EAknSoftkeyExit, nativeText);
return true;
}
diff --git a/src/gui/kernel/qsoftkeymanager_s60_p.h b/src/gui/kernel/qsoftkeymanager_s60_p.h
index 823a2db..a5e5016 100644
--- a/src/gui/kernel/qsoftkeymanager_s60_p.h
+++ b/src/gui/kernel/qsoftkeymanager_s60_p.h
@@ -53,6 +53,7 @@
// We mean it.
//
+#include "qbitarray.h"
#include "private/qobject_p.h"
#include "private/qsoftkeymanager_common_p.h"
@@ -98,6 +99,7 @@ private:
private:
QHash<int, QAction*> realSoftKeyActions;
QSize cachedCbaIconSize[4];
+ QBitArray cbaHasImage;
};
diff --git a/src/gui/kernel/qsound_mac.mm b/src/gui/kernel/qsound_mac.mm
index 61e42ba..71fd663 100644
--- a/src/gui/kernel/qsound_mac.mm
+++ b/src/gui/kernel/qsound_mac.mm
@@ -174,6 +174,7 @@ NSSound *QAuServerMac::createNSSound(const QString &fileName, QSound *qSound)
NSSound * const nsSound = [[NSSound alloc] initWithContentsOfFile: nsFileName byReference:YES];
QMacSoundDelegate * const delegate = [[QMacSoundDelegate alloc] initWithQSound:qSound:this];
[nsSound setDelegate:delegate];
+ [nsFileName release];
return nsSound;
}
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index c776b2a..3fbd978 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -139,7 +139,7 @@ void QMacWindowFader::performFade()
extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // qapplication.cpp;
extern QWidget * mac_mouse_grabber;
-extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
+extern QWidget *qt_button_down; //qapplication_mac.cpp
void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds)
{
@@ -686,6 +686,12 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve
if ([event type] == NSKeyDown) {
qt_keymapper_private()->updateKeyMap(0, key_event, 0);
}
+
+ // Redirect keys to alien widgets.
+ if (widgetToGetEvent->testAttribute(Qt::WA_NativeWindow) == false) {
+ widgetToGetEvent = qApp->focusWidget();
+ }
+
if (widgetToGetEvent == 0)
return false;
@@ -940,7 +946,7 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev
[static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(tmpView) qt_qwidget];
}
} else {
- extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
+ extern QWidget * qt_button_down; //qapplication_mac.cpp
QPoint pos;
widgetToGetMouse = QApplicationPrivate::pickMouseReceiver(qwidget, qglobalPoint,
pos, eventType,
@@ -952,7 +958,20 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev
return false;
NSPoint localPoint = [tmpView convertPoint:windowPoint fromView:nil];
- QPoint qlocalPoint(localPoint.x, localPoint.y);
+ QPoint qlocalPoint = QPoint(localPoint.x, localPoint.y);
+
+ // Search for alien child widgets (either on this qwidget or on the popup)
+ if (widgetToGetMouse->testAttribute(Qt::WA_NativeWindow) == false || qt_widget_private(widgetToGetMouse)->hasAlienChildren) {
+ QPoint qScreenPoint = flipPoint(globalPoint).toPoint();
+#ifdef ALIEN_DEBUG
+ qDebug() << "alien mouse event" << qScreenPoint << possibleAlien;
+#endif
+ QWidget *possibleAlien = widgetToGetMouse->childAt(qlocalPoint);
+ if (possibleAlien) {
+ qlocalPoint = possibleAlien->mapFromGlobal(widgetToGetMouse->mapToGlobal(qlocalPoint));
+ widgetToGetMouse = possibleAlien;
+ }
+ }
EventRef carbonEvent = static_cast<EventRef>(const_cast<void *>([theEvent eventRef]));
if (qt_mac_sendMacEventToWidget(widgetToGetMouse, carbonEvent))
@@ -997,7 +1016,19 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev
}
[QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->localPoint = localPoint;
QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, buttons, keyMods);
- qt_sendSpontaneousEvent(widgetToGetMouse, &qme);
+
+#ifdef ALIEN_DEBUG
+ qDebug() << "sending mouse event to" << widgetToGetMouse;
+#endif
+ extern QWidget *qt_button_down;
+ extern QPointer<QWidget> qt_last_mouse_receiver;
+
+ if (qwidget->testAttribute(Qt::WA_NativeWindow) && qt_widget_private(qwidget)->hasAlienChildren == false)
+ qt_sendSpontaneousEvent(widgetToGetMouse, &qme);
+ else
+ QApplicationPrivate::sendMouseEvent(widgetToGetMouse, &qme, widgetToGetMouse, qwidget, &qt_button_down,
+ qt_last_mouse_receiver);
+
if (eventType == QEvent::MouseButtonPress && button == Qt::RightButton) {
QContextMenuEvent qcme(QContextMenuEvent::Mouse, qlocalPoint, qglobalPoint, keyMods);
qt_sendSpontaneousEvent(widgetToGetMouse, &qcme);
@@ -1355,4 +1386,12 @@ QMacCocoaAutoReleasePool::~QMacCocoaAutoReleasePool()
[(NSAutoreleasePool*)pool release];
}
+void qt_mac_post_retranslateAppMenu()
+{
+#ifdef QT_MAC_USE_COCOA
+ QMacCocoaAutoReleasePool pool;
+ qt_cocoaPostMessage([NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
index c43ea55..3fd62a4 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h
+++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
@@ -208,4 +208,6 @@ bool qt_cocoaPostMessage(id target, SEL selector);
#endif
+void qt_mac_post_retranslateAppMenu();
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 167557b..8af4df5 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -672,6 +672,9 @@ struct QX11Data
XWacomCursor,
XWacomEraser,
+ XTabletStylus,
+ XTabletEraser,
+
NPredefinedAtoms,
_QT_SETTINGS_TIMESTAMP = NPredefinedAtoms,
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index aa5d259..e5310ea 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -205,6 +205,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
, nativeGesturePanEnabled(0)
#elif defined(Q_WS_MAC)
, needWindowChange(0)
+ , hasAlienChildren(0)
, window_event(0)
, qd_hd(0)
#endif
@@ -1121,7 +1122,8 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
qFatal("QWidget: Cannot create a QWidget when no GUI is being used");
Q_ASSERT(allWidgets);
- allWidgets->insert(q);
+ if (allWidgets)
+ allWidgets->insert(q);
QWidget *desktopWidget = 0;
if (parentWidget && parentWidget->windowType() == Qt::Desktop) {
@@ -1168,6 +1170,10 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
if (f & Qt::MSWindowsOwnDC)
q->setAttribute(Qt::WA_NativeWindow);
+#ifdef Q_WS_MAC
+ q->setAttribute(Qt::WA_NativeWindow);
+#endif
+
q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute()
adjustQuitOnCloseAttribute();
@@ -1263,6 +1269,10 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
}
if (QWidget *parent = parentWidget()) {
+#ifdef Q_WS_MAC
+ if (testAttribute(Qt::WA_NativeWindow) == false)
+ parent->d_func()->hasAlienChildren = true;
+#endif
if (type & Qt::Window) {
if (!parent->testAttribute(Qt::WA_WState_Created))
parent->createWinId();
@@ -1433,7 +1443,7 @@ QWidget::~QWidget()
}
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
else if (!internalWinId() && isVisible()) {
qApp->d_func()->sendSyntheticEnterLeave(this);
#ifdef Q_WS_QWS
@@ -2306,6 +2316,9 @@ QWidget *QWidget::find(WId id)
WId QWidget::winId() const
{
if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
+#ifdef ALIEN_DEBUG
+ qDebug() << "QWidget::winId: creating native window for" << this;
+#endif
QWidget *that = const_cast<QWidget*>(this);
that->setAttribute(Qt::WA_NativeWindow);
that->d_func()->createWinId();
@@ -2318,6 +2331,10 @@ WId QWidget::winId() const
void QWidgetPrivate::createWinId(WId winid)
{
Q_Q(QWidget);
+
+#ifdef ALIEN_DEBUG
+ qDebug() << "QWidgetPrivate::createWinId for" << q << winid;
+#endif
const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow);
if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
if (!q->isWindow()) {
@@ -2360,6 +2377,9 @@ Ensures that the widget has a window system identifier, i.e. that it is known to
void QWidget::createWinId()
{
Q_D(QWidget);
+#ifdef ALIEN_DEBUG
+ qDebug() << "QWidget::createWinId" << this;
+#endif
// qWarning("QWidget::createWinId is obsolete, please fix your code.");
d->createWinId();
}
@@ -5249,7 +5269,15 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
QPaintEngine *paintEngine = pdev->paintEngine();
if (paintEngine) {
setRedirected(pdev, -offset);
+#ifdef Q_WS_MAC
+ // (Alien support) Special case for Mac when redirecting: If the paint device
+ // is of the Widget type we need to set WA_WState_InPaintEvent since painting
+ // outside the paint event is not supported on QWidgets. The attributeis
+ // restored further down.
+ if (pdev->devType() == QInternal::Widget)
+ static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent);
+#endif
if (sharedPainter)
paintEngine->d_func()->systemClip = toBePainted;
else
@@ -5290,6 +5318,10 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
//restore
if (paintEngine) {
+#ifdef Q_WS_MAC
+ if (pdev->devType() == QInternal::Widget)
+ static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false);
+#endif
restoreRedirected();
if (!sharedPainter)
paintEngine->d_func()->systemRect = QRect();
@@ -6468,7 +6500,7 @@ void QWidget::setTabOrder(QWidget* first, QWidget *second)
// QWidget *fp = first->d_func()->focus_prev;
QWidget *fn = first->d_func()->focus_next;
- if (fn == second)
+ if (fn == second || first == second)
return;
QWidget *sp = second->d_func()->focus_prev;
@@ -7321,7 +7353,7 @@ void QWidgetPrivate::hide_helper()
// next bit tries to move the focus if the focus widget is now
// hidden.
if (wasVisible) {
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
qApp->d_func()->sendSyntheticEnterLeave(q);
#endif
@@ -7453,7 +7485,7 @@ void QWidget::setVisible(bool visible)
d->show_helper();
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
qApp->d_func()->sendSyntheticEnterLeave(this);
#endif
}
@@ -7551,6 +7583,23 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden))
continue;
+#ifdef QT_MAC_USE_COCOA
+ // Before doing anything we need to make sure that we don't leave anything in a non-consistent state.
+ // When hiding a widget we need to make sure that no mouse_down events are active, because
+ // the mouse_up event will never be received by a hidden widget or one of its descendants.
+ // The solution is simple, before going through with this we check if there are any mouse_down events in
+ // progress, if so we check if it is related to this widget or not. If so, we just reset the mouse_down and
+ // then we continue.
+ // In X11 and Windows we send a mouse_release event, however we don't do that here because we were already
+ // ignoring that from before. I.e. Carbon did not send the mouse release event, so we will not send the
+ // mouse release event. There are two ways to interpret this:
+ // 1. If we don't send the mouse release event, the widget might get into an inconsistent state, i.e. it
+ // might be waiting for a release event that will never arrive.
+ // 2. If we send the mouse release event, then the widget might decide to trigger an action that is not
+ // supposed to trigger because it is not visible.
+ if(widget == qt_button_down)
+ qt_button_down = 0;
+#endif // QT_MAC_USE_COCOA
if (spontaneous)
widget->setAttribute(Qt::WA_Mapped, false);
else
@@ -7568,7 +7617,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
widget->d_func()->hide_sys();
}
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
qApp->d_func()->sendSyntheticEnterLeave(widget);
#endif
#ifndef QT_NO_ACCESSIBILITY
@@ -7943,13 +7992,16 @@ inline void setDisabledStyle(QWidget *w, bool setStyle)
// set/reset WS_DISABLED style.
if(w && w->isWindow() && w->isVisible() && w->isEnabled()) {
LONG dwStyle = GetWindowLong(w->winId(), GWL_STYLE);
+ LONG newStyle = dwStyle;
if (setStyle)
- dwStyle |= WS_DISABLED;
+ newStyle |= WS_DISABLED;
else
- dwStyle &= ~WS_DISABLED;
- SetWindowLong(w->winId(), GWL_STYLE, dwStyle);
- // we might need to repaint in some situations (eg. menu)
- w->repaint();
+ newStyle &= ~WS_DISABLED;
+ if (newStyle != dwStyle) {
+ SetWindowLong(w->winId(), GWL_STYLE, newStyle);
+ // we might need to repaint in some situations (eg. menu)
+ w->repaint();
+ }
}
}
#endif
@@ -9786,7 +9838,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
desktopWidget = parent;
bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
-#if defined(Q_WS_X11) || defined(Q_WS_WIN)
+#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC)
if (newParent && parent && !desktopWidget) {
if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
parent->d_func()->enforceNativeChildren();
@@ -10261,6 +10313,29 @@ const QPixmap *QWidget::icon() const
#endif // QT3_SUPPORT
+ /*!
+ \internal
+
+ This just sets the corresponding attribute bit to 1 or 0
+ */
+static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data,
+ QWidgetPrivate *d)
+{
+ if (attribute < int(8*sizeof(uint))) {
+ if (on)
+ data->widget_attributes |= (1<<attribute);
+ else
+ data->widget_attributes &= ~(1<<attribute);
+ } else {
+ const int x = attribute - 8*sizeof(uint);
+ const int int_off = x / (8*sizeof(uint));
+ if (on)
+ d->high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint))));
+ else
+ d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint))));
+ }
+}
+
/*!
Sets the attribute \a attribute on this widget if \a on is true;
otherwise clears the attribute.
@@ -10287,19 +10362,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
#endif
- if (attribute < int(8*sizeof(uint))) {
- if (on)
- data->widget_attributes |= (1<<attribute);
- else
- data->widget_attributes &= ~(1<<attribute);
- } else {
- const int x = attribute - 8*sizeof(uint);
- const int int_off = x / (8*sizeof(uint));
- if (on)
- d->high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint))));
- else
- d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint))));
- }
+ setAttribute_internal(attribute, on, data, d);
switch (attribute) {
@@ -10358,14 +10421,11 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
#ifdef Q_WS_MAC
{
// We can only have one of these set at a time
- static const int MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize,
- Qt::WA_MacMiniSize, 0 };
- for (int i = 0; MacSizes[i] != 0; ++i) {
- if (MacSizes[i] == attribute)
- continue;
- int macsize_x = MacSizes[i] - 8*sizeof(uint);
- int macsize_int_off = macsize_x / (8*sizeof(uint));
- d->high_attributes[macsize_int_off] &= ~(1<<(macsize_x-(macsize_int_off*8*sizeof(uint))));
+ const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize,
+ Qt::WA_MacMiniSize };
+ for (int i = 0; i < 3; ++i) {
+ if (MacSizes[i] != attribute)
+ setAttribute_internal(MacSizes[i], false, data, d);
}
d->macUpdateSizeAttribute();
}
@@ -10432,7 +10492,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
case Qt::WA_PaintOnScreen:
d->updateIsOpaque();
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
// Recreate the widget if it's already created as an alien widget and
// WA_PaintOnScreen is enabled. Paint on screen widgets must have win id.
// So must their children.
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index dcb87fc..4b45abd 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -152,6 +152,7 @@ static bool qt_mac_raise_process = true;
static OSWindowRef qt_root_win = 0;
QWidget *mac_mouse_grabber = 0;
QWidget *mac_keyboard_grabber = 0;
+extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
#ifndef QT_MAC_USE_COCOA
#ifdef QT_NAMESPACE
@@ -459,7 +460,13 @@ static bool qt_isGenuineQWidget(OSViewRef ref)
bool qt_isGenuineQWidget(const QWidget *window)
{
- return window && qt_isGenuineQWidget(OSViewRef(window->winId()));
+ if (!window)
+ return false;
+
+ if (!window->internalWinId())
+ return true; //alien
+
+ return qt_isGenuineQWidget(OSViewRef(window->internalWinId()));
}
Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget *w)
@@ -866,7 +873,6 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event,
& ~Qt::WindowMaximized));
QApplication::sendSpontaneousEvent(widget, &e);
}
- extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
qt_button_down = 0;
} else if(ekind == kEventWindowCollapsed) {
if (!widget->isMinimized()) {
@@ -894,7 +900,6 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event,
//we send a hide to be like X11/Windows
QEvent e(QEvent::Hide);
QApplication::sendSpontaneousEvent(widget, &e);
- extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
qt_button_down = 0;
} else if(ekind == kEventWindowToolbarSwitchMode) {
macSendToolbarChangeEvent(widget);
@@ -1268,6 +1273,11 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event,
if (widget->isVisible() && widget->updatesEnabled()) { //process the actual paint event.
if(widget->testAttribute(Qt::WA_WState_InPaintEvent))
qWarning("QWidget::repaint: Recursive repaint detected");
+ if (widget->isWindow() && !widget->d_func()->isOpaque
+ && !widget->testAttribute(Qt::WA_MacBrushedMetal)) {
+ QRect qrgnRect = qrgn.boundingRect();
+ CGContextClearRect(cg, CGRectMake(qrgnRect.x(), qrgnRect.y(), qrgnRect.width(), qrgnRect.height()));
+ }
QPoint redirectionOffset(0, 0);
QWidget *tl = widget->window();
@@ -1318,13 +1328,6 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event,
widget->d_func()->restoreRedirected();
}
- if (widget->isWindow() && !widget->d_func()->isOpaque
- && !widget->testAttribute(Qt::WA_MacBrushedMetal)) {
- QRect qrgnRect = qrgn.boundingRect();
- CGContextClearRect(cg, CGRectMake(qrgnRect.x(), qrgnRect.y(), qrgnRect.width(), qrgnRect.height()));
- }
-
-
if(!HIObjectIsOfClass((HIObjectRef)hiview, kObjectQWidget))
CallNextEventHandler(er, event);
@@ -1521,7 +1524,6 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event,
if (widget) {
qt_event_request_window_change(widget);
if (!HIViewIsVisible(HIViewRef(widget->winId()))) {
- extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
if (widget == qt_button_down)
qt_button_down = 0;
}
@@ -1530,7 +1532,6 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event,
break; }
case kEventClassMouse: {
bool send_to_app = false;
- extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
if(qt_button_down)
send_to_app = true;
if(send_to_app) {
@@ -2608,7 +2609,16 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
} else {
data.fstrut_dirty = false; // non-toplevel widgets don't have a frame, so no need to update the strut
- if(OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) {
+
+#ifdef QT_MAC_USE_COCOA
+ if (q->testAttribute(Qt::WA_NativeWindow) == false ||
+ q->internalWinId() != 0) {
+#ifdef ALIEN_DEBUG
+ qDebug() << "Skipping native widget creation for" << this;
+#endif
+ } else
+#endif
+ if (OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) {
#ifndef QT_MAC_USE_COCOA
HIRect bounds = CGRectMake(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height());
HIViewSetFrame(osview, &bounds);
@@ -2869,9 +2879,12 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
q->setAttribute(Qt::WA_WState_Visible, false);
q->setAttribute(Qt::WA_WState_Hidden, false);
adjustFlags(data.window_flags, q);
- // keep compatibility with previous versions, we need to preserve the created state
- // (but we recreate the winId for the widget being reparented, again for compatibility)
- if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created))) {
+ // keep compatibility with previous versions, we need to preserve the created state.
+ // (but we recreate the winId for the widget being reparented, again for compatibility,
+ // unless this is an alien widget. )
+ const bool nonWindowWithCreatedParent = !q->isWindow() && parent->testAttribute(Qt::WA_WState_Created);
+ const bool nativeWidget = q->internalWinId() != 0;
+ if (wasCreated || nativeWidget && nonWindowWithCreatedParent) {
createWinId();
if (q->isWindow()) {
#ifndef QT_MAC_USE_COCOA
@@ -2955,7 +2968,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
QPoint QWidget::mapToGlobal(const QPoint &pos) const
{
Q_D(const QWidget);
- if (!testAttribute(Qt::WA_WState_Created)) {
+ if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
QPoint p = pos + data->crect.topLeft();
return isWindow() ? p : parentWidget()->mapToGlobal(p);
}
@@ -2982,7 +2995,7 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
QPoint QWidget::mapFromGlobal(const QPoint &pos) const
{
Q_D(const QWidget);
- if (!testAttribute(Qt::WA_WState_Created)) {
+ if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
QPoint p = isWindow() ? pos : parentWidget()->mapFromGlobal(pos);
return p - data->crect.topLeft();
}
@@ -3320,10 +3333,20 @@ void QWidgetPrivate::update_sys(const QRegion &rgn)
}
#else
// Cocoa doesn't do regions, it seems more efficient to just update the bounding rect instead of a potential number of message passes for each rect.
- const QRect &boundingRect = rgn.boundingRect();
- [qt_mac_nativeview_for(q) setNeedsDisplayInRect:NSMakeRect(boundingRect.x(),
- boundingRect.y(), boundingRect.width(),
- boundingRect.height())];
+ const QRect & boundingRect = rgn.boundingRect();
+
+ // Alien support: get the first native ancestor widget (will be q itself in the non-alien case),
+ // map the coordinates from q space to NSView space and invalidate the rect.
+ QWidget *nativeParent = q->internalWinId() ? q : q->nativeParentWidget();
+ if (nativeParent == 0)
+ return;
+ const QRect nativeBoundingRect = QRect(
+ QPoint(q->mapTo(nativeParent, boundingRect.topLeft())),
+ QSize(boundingRect.size()));
+
+ [qt_mac_nativeview_for(nativeParent) setNeedsDisplayInRect:NSMakeRect(nativeBoundingRect.x(),
+ nativeBoundingRect.y(), nativeBoundingRect.width(),
+ nativeBoundingRect.height())];
#endif
}
@@ -3405,8 +3428,10 @@ void QWidgetPrivate::show_sys()
// The window is modally shaddowed, so we need to make
// sure that we don't pop in front of the modal window:
[window orderFront:window];
- if (NSWindow *modalWin = qt_mac_window_for(top))
- [modalWin orderFront:window];
+ if (!top->testAttribute(Qt::WA_DontShowOnScreen)) {
+ if (NSWindow *modalWin = qt_mac_window_for(top))
+ [modalWin orderFront:window];
+ }
}
#endif
if (q->windowType() == Qt::Popup) {
@@ -3465,7 +3490,6 @@ void QWidgetPrivate::hide_sys()
Q_Q(QWidget);
if((q->windowType() == Qt::Desktop)) //you can't hide the desktop!
return;
-
QMacCocoaAutoReleasePool pool;
if(q->isWindow()) {
#ifdef QT_MAC_USE_COCOA
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index efd9a0a..2cb8586 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -720,6 +720,7 @@ public:
#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
// This is new stuff
uint needWindowChange : 1;
+ uint hasAlienChildren : 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 ebd289c..7fb21d2 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -1042,7 +1042,13 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
Q_D(QWidget);
Qt::WindowStates oldstate = windowState();
- if (oldstate == newstate)
+
+ const TBool isFullscreen = newstate & Qt::WindowFullScreen;
+ const TBool cbaRequested = windowFlags() & Qt::WindowSoftkeysVisibleHint;
+ const TBool cbaVisible = CEikButtonGroupContainer::Current() ? true : false;
+ const TBool softkeyVisibilityChange = isFullscreen && (cbaRequested != cbaVisible);
+
+ if (oldstate == newstate && !softkeyVisibilityChange)
return;
if (isWindow()) {
@@ -1058,16 +1064,27 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
#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
+ // 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));
+ 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);
+ if (buttonGroup) {
+ // Visibility
+ buttonGroup->MakeVisible(visible || (isFullscreen && cbaRequested));
+
+ // Responsiviness
+ CEikCba *cba = static_cast<CEikCba *>( buttonGroup->ButtonGroup() ); // downcast from MEikButtonGroup
+ TUint cbaFlags = cba->ButtonGroupFlags();
+ if(windowFlags() & Qt::WindowSoftkeysRespondHint)
+ cbaFlags |= EAknCBAFlagRespondWhenInvisible;
+ else
+ cbaFlags &= ~EAknCBAFlagRespondWhenInvisible;
+ cba->SetButtonGroupFlags(cbaFlags);
+ }
#endif // Q_WS_S60
createWinId();
@@ -1080,7 +1097,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
const QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry;
if (newstate & Qt::WindowFullScreen)
- setGeometry(qApp->desktop()->screenGeometry(this));
+ setGeometry(qApp->desktop()->availableGeometry(this));
else if (newstate & Qt::WindowMaximized)
setGeometry(qApp->desktop()->availableGeometry(this));
else
@@ -1220,8 +1237,10 @@ void QWidget::releaseMouse()
{
if (!qt_nograb() && QWidgetPrivate::mouseGrabber == this) {
Q_ASSERT(testAttribute(Qt::WA_WState_Created));
- WId id = effectiveWinId();
- id->SetPointerCapture(false);
+ if(!window()->isModal()) {
+ WId id = effectiveWinId();
+ id->SetPointerCapture(false);
+ }
QWidgetPrivate::mouseGrabber = 0;
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 8cab387..2dcbfc3 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -2073,6 +2073,8 @@ void QWidgetPrivate::winSetupGestures()
if (!q || !q->isVisible() || !nativeGesturePanEnabled)
return;
+ if (!QApplicationPrivate::HasTouchSupport)
+ return;
QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
if (!qAppPriv->SetGestureConfig)
return;
diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h
index c65fa50..146b067 100644
--- a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h
+++ b/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h
@@ -54,6 +54,38 @@
//
#include <QGestureRecognizer>
+#include <objbase.h>
+
+class IInkRectangle;
+class TabletHardwareCapabilities;
+class TabletPropertyMetricUnit;
+DECLARE_INTERFACE_(IInkTablet, IDispatch)
+{
+ STDMETHOD(get_Name)(THIS_ BSTR *Name) PURE;
+ STDMETHOD(get_PlugAndPlayId)(THIS_ BSTR *Id) PURE;
+ STDMETHOD(get_MaximumInputRectangle)(THIS_ IInkRectangle **Rectangle) PURE;
+ STDMETHOD(get_HardwareCapabilities)(THIS_ TabletHardwareCapabilities *Capabilities) PURE;
+ STDMETHOD(IsPacketPropertySupported)(THIS_ BSTR packetPropertyName) PURE;
+ STDMETHOD(GetPropertyMetrics)(THIS_ BSTR propertyName, long *Minimum, long *Maximum, TabletPropertyMetricUnit *Units, float *Resolution) PURE;
+};
+enum TabletDeviceKind
+{
+ TDK_Mouse = 0,
+ TDK_Pen = 1,
+ TDK_Touch = 2
+};
+DECLARE_INTERFACE_(IInkTablet2, IDispatch)
+{
+ STDMETHOD(get_DeviceKind)(THIS_ TabletDeviceKind *Kind) PURE;
+};
+DECLARE_INTERFACE_(IInkTablets, IDispatch)
+{
+ STDMETHOD(get_Count)(THIS_ long *Count) PURE;
+ STDMETHOD(get__NewEnum)(THIS_ IUnknown **_NewEnum) PURE;
+ STDMETHOD(get_DefaultTablet)(THIS_ IInkTablet **DefaultTablet) PURE;
+ STDMETHOD(Item)(THIS_ long Index, IInkTablet **Tablet) PURE;
+ STDMETHOD(IsPacketPropertySupported)(THIS_ BSTR packetPropertyName, VARIANT_BOOL *Supported) PURE;
+};
QT_BEGIN_NAMESPACE
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index c73d9f4..8de9eaa 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -352,6 +352,10 @@ void QWidgetBackingStore::beginPaint(QRegion &toClean, QWidget *widget, QWindowS
// Always flush repainted areas.
dirtyOnScreen += toClean;
+#ifdef Q_WS_QWS
+ toClean.translate(tlwOffset);
+#endif
+
#ifdef QT_NO_PAINT_DEBUG
windowSurface->beginPaint(toClean);
#else
@@ -766,7 +770,12 @@ void QWidgetBackingStore::paintWindowDecoration()
if (decorationRegion.isEmpty())
return;
- windowSurface->beginPaint(decorationRegion);
+ //### The QWS decorations do not always paint the pixels they promise to paint.
+ // This causes painting problems with QWSMemorySurface. Since none of the other
+ // window surfaces actually use the region, passing an empty region is a safe
+ // workaround.
+
+ windowSurface->beginPaint(QRegion());
QPaintEngine *engine = windowSurface->paintDevice()->paintEngine();
Q_ASSERT(engine);
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 0b735a2..08d5572 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -543,19 +543,20 @@ void QColor::setNamedColor(const QString &name)
be used to construct a valid QColor object, otherwise returns
false.
- The algorithm used is the same as with \a setNamedColor().
+ It uses the same algorithm used in setNamedColor().
+
\sa setNamedColor()
*/
bool QColor::isValidColor(const QString &name)
{
- return QColor().setColorFromString(name);
+ return !name.isEmpty() && QColor().setColorFromString(name);
}
bool QColor::setColorFromString(const QString &name)
{
if (name.isEmpty()) {
invalidate();
- return false;
+ return true;
}
if (name.startsWith(QLatin1Char('#'))) {
@@ -2716,12 +2717,4 @@ QDataStream &operator>>(QDataStream &stream, QColor &color)
\sa QColor::rgb(), QColor::rgba()
*/
-/*! \fn void QColormap::initialize()
- \internal
-*/
-
-/*! \fn void QColormap::cleanup()
- \internal
-*/
-
QT_END_NAMESPACE
diff --git a/src/gui/painting/qcolormap.qdoc b/src/gui/painting/qcolormap.qdoc
index 56fabf7..22a73fd 100644
--- a/src/gui/painting/qcolormap.qdoc
+++ b/src/gui/painting/qcolormap.qdoc
@@ -150,3 +150,13 @@
Assigns the given \a colormap to \e this color map and returns
a reference to \e this color map.
*/
+
+/*!
+ \fn void QColormap::initialize()
+ \internal
+*/
+
+/*!
+ \fn void QColormap::cleanup()
+ \internal
+*/
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index acd286a..581b538 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -5072,7 +5072,7 @@ static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData)
static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
+#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -7820,7 +7820,6 @@ void qInitDrawhelperAsm()
CompositionFunction *functionForModeAsm = 0;
CompositionFunctionSolid *functionForModeSolidAsm = 0;
-#ifdef QT_NO_DEBUG
const uint features = qDetectCPUFeatures();
if (false) {
#ifdef QT_HAVE_SSE2
@@ -7944,8 +7943,6 @@ void qInitDrawhelperAsm()
}
#endif // IWMMXT
-#endif // QT_NO_DEBUG
-
#if defined(Q_CC_RVCT) && defined(QT_HAVE_ARMV6)
functionForModeAsm = qt_functionForMode_ARMv6;
functionForModeSolidAsm = qt_functionForModeSolid_ARMv6;
diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp
index d76c709..a62f06b 100644
--- a/src/gui/painting/qdrawutil.cpp
+++ b/src/gui/painting/qdrawutil.cpp
@@ -1081,7 +1081,7 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs,
according to the \a margins structure.
*/
-typedef QVarLengthArray<QPainter::Fragment, 16> QPixmapFragmentsArray;
+typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray;
/*!
\since 4.6
@@ -1102,7 +1102,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
{
- QPainter::Fragment d;
+ QPainter::PixmapFragment d;
d.opacity = 1.0;
d.rotation = 0.0;
diff --git a/src/gui/painting/qgraphicssystem_raster.cpp b/src/gui/painting/qgraphicssystem_raster.cpp
index f90aea0..909508e 100644
--- a/src/gui/painting/qgraphicssystem_raster.cpp
+++ b/src/gui/painting/qgraphicssystem_raster.cpp
@@ -41,19 +41,32 @@
#include "qgraphicssystem_raster_p.h"
+#ifdef Q_OS_SYMBIAN
+#include "private/qpixmap_s60_p.h"
+#include "private/qwindowsurface_s60_p.h"
+#else
#include "private/qpixmap_raster_p.h"
#include "private/qwindowsurface_raster_p.h"
+#endif
QT_BEGIN_NAMESPACE
QPixmapData *QRasterGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
{
+#ifdef Q_OS_SYMBIAN
+ return new QS60PixmapData(type);
+#else
return new QRasterPixmapData(type);
+#endif
}
QWindowSurface *QRasterGraphicsSystem::createWindowSurface(QWidget *widget) const
{
+#ifdef Q_OS_SYMBIAN
+ return new QS60WindowSurface(widget);
+#else
return new QRasterWindowSurface(widget);
+#endif
}
QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index a7c2a0b..bfcf7db 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -3390,7 +3390,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
};
for(int i = 0; i < glyphs.size(); i++) {
- QFontEngineFT::Glyph *glyph = gset->glyph_data.value(glyphs[i]);
+ QFontEngineFT::Glyph *glyph = gset->getGlyph(glyphs[i]);
if (!glyph || glyph->format != neededFormat) {
if (!lockedFace)
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 98762f0..1fd622d 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -970,8 +970,8 @@ void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, con
fill(path, brush);
}
-void QPaintEngineEx::drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount,
- const QPixmap &pixmap, QPainter::FragmentHints /*hints*/)
+void QPaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount,
+ const QPixmap &pixmap, QPainter::PixmapFragmentHints /*hints*/)
{
qreal oldOpacity = state()->opacity;
QTransform oldTransform = state()->matrix;
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index 2401b94..6c654bd 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -197,7 +197,8 @@ public:
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
- virtual void drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, const QPixmap &pixmap, QFlags<QPainter::FragmentHint> hints);
+ virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
+ QFlags<QPainter::PixmapFragmentHint> hints);
virtual void updateState(const QPaintEngineState &state);
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 9d83718..a1ed8f5 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5758,18 +5758,18 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit
/*!
\fn void QPainter::drawStaticText(const QPoint &position, const QStaticText &staticText)
-
\since 4.7
-
\overload
+
+ Draws the \a staticText at the \a position.
*/
/*!
\fn void QPainter::drawStaticText(int x, int y, const QStaticText &staticText)
-
\since 4.7
-
\overload
+
+ Draws the \a staticText at coordinates \a x and \a y.
*/
/*!
@@ -7994,10 +7994,11 @@ start_lengthVariant:
for (int i = 0; i < textLayout.lineCount(); i++) {
QTextLine line = textLayout.lineAt(i);
+ qreal advance = textLayout.engine()->lines[i].textAdvance.toReal();
if (tf & Qt::AlignRight)
- xoff = r.width() - line.naturalTextWidth();
+ xoff = r.width() - advance;
else if (tf & Qt::AlignHCenter)
- xoff = (r.width() - line.naturalTextWidth())/2;
+ xoff = (r.width() - advance)/2;
line.draw(painter, QPointF(r.x() + xoff + line.x(), r.y() + yoff));
}
@@ -8914,11 +8915,11 @@ QTransform QPainter::combinedTransform() const
This function is potentially faster than multiple calls to drawPixmap(),
since the backend can optimize state changes.
- \sa QPainter::Fragment, QPainter::FragmentHint
+ \sa QPainter::PixmapFragment, QPainter::PixmapFragmentHint
*/
-void QPainter::drawPixmapFragments(const Fragment *fragments, int fragmentCount,
- const QPixmap &pixmap, FragmentHints hints)
+void QPainter::drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount,
+ const QPixmap &pixmap, PixmapFragmentHints hints)
{
Q_D(QPainter);
@@ -8959,7 +8960,7 @@ void QPainter::drawPixmapFragments(const Fragment *fragments, int fragmentCount,
/*!
\since 4.7
- \class QPainter::Fragment
+ \class QPainter::PixmapFragment
\brief This class is used in conjunction with the
QPainter::drawPixmapFragments() function to specify how a pixmap, or
@@ -8980,73 +8981,73 @@ void QPainter::drawPixmapFragments(const Fragment *fragments, int fragmentCount,
/*!
\since 4.7
- This is a convenience function that returns a QPainter::Fragment that is
+ This is a convenience function that returns a QPainter::PixmapFragment that is
initialized with the \a pos, \a sourceRect, \a scaleX, \a scaleY, \a
rotation, \a opacity parameters.
*/
-QPainter::Fragment QPainter::Fragment::create(const QPointF &pos, const QRectF &sourceRect,
+QPainter::PixmapFragment QPainter::PixmapFragment::create(const QPointF &pos, const QRectF &sourceRect,
qreal scaleX, qreal scaleY, qreal rotation,
qreal opacity)
{
- Fragment fragment = {pos.x(), pos.y(), sourceRect.x(), sourceRect.y(), sourceRect.width(),
- sourceRect.height(), scaleX, scaleY, rotation, opacity};
+ PixmapFragment fragment = {pos.x(), pos.y(), sourceRect.x(), sourceRect.y(), sourceRect.width(),
+ sourceRect.height(), scaleX, scaleY, rotation, opacity};
return fragment;
}
/*!
- \variable QPainter::Fragment::x
+ \variable QPainter::PixmapFragment::x
\brief the x coordinate of center point in the target rectangle.
*/
/*!
- \variable QPainter::Fragment::y
+ \variable QPainter::PixmapFragment::y
\brief the y coordinate of the center point in the target rectangle.
*/
/*!
- \variable QPainter::Fragment::sourceLeft
+ \variable QPainter::PixmapFragment::sourceLeft
\brief the left coordinate of the source rectangle.
*/
/*!
- \variable QPainter::Fragment::sourceTop
+ \variable QPainter::PixmapFragment::sourceTop
\brief the top coordinate of the source rectangle.
*/
/*!
- \variable QPainter::Fragment::width
+ \variable QPainter::PixmapFragment::width
\brief the width of the source rectangle and is used to calculate the width
of the target rectangle.
*/
/*!
- \variable QPainter::Fragment::height
+ \variable QPainter::PixmapFragment::height
\brief the height of the source rectangle and is used to calculate the
height of the target rectangle.
*/
/*!
- \variable QPainter::Fragment::scaleX
+ \variable QPainter::PixmapFragment::scaleX
\brief the horizontal scale of the target rectangle.
*/
/*!
- \variable QPainter::Fragment::scaleY
+ \variable QPainter::PixmapFragment::scaleY
\brief the vertical scale of the target rectangle.
*/
/*!
- \variable QPainter::Fragment::rotation
+ \variable QPainter::PixmapFragment::rotation
\brief the rotation of the target rectangle in degrees. The target
rectangle is rotated after it has been scaled.
*/
/*!
- \variable QPainter::Fragment::opacity
+ \variable QPainter::PixmapFragment::opacity
\brief the opacity of the target rectangle, where 0.0 is fully transparent
and 1.0 is fully opaque.
@@ -9055,12 +9056,12 @@ QPainter::Fragment QPainter::Fragment::create(const QPointF &pos, const QRectF &
/*!
\since 4.7
- \enum QPainter::FragmentHint
+ \enum QPainter::PixmapFragmentHint
\value OpaqueHint Indicates that the pixmap fragments to be drawn are
opaque. Opaque fragments are potentially faster to draw.
- \sa QPainter::drawPixmapFragments(), QPainter::Fragment
+ \sa QPainter::drawPixmapFragments(), QPainter::PixmapFragment
*/
void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation)
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index bcb0b50..443925b 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -99,7 +99,7 @@ public:
Q_DECLARE_FLAGS(RenderHints, RenderHint)
- class Fragment {
+ class PixmapFragment {
public:
qreal x;
qreal y;
@@ -111,16 +111,16 @@ public:
qreal scaleY;
qreal rotation;
qreal opacity;
- static Fragment Q_GUI_EXPORT create(const QPointF &pos, const QRectF &sourceRect,
+ static PixmapFragment Q_GUI_EXPORT create(const QPointF &pos, const QRectF &sourceRect,
qreal scaleX = 1, qreal scaleY = 1,
qreal rotation = 0, qreal opacity = 1);
};
- enum FragmentHint {
+ enum PixmapFragmentHint {
OpaqueHint = 0x01
};
- Q_DECLARE_FLAGS(FragmentHints, FragmentHint)
+ Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)
QPainter();
explicit QPainter(QPaintDevice *);
@@ -375,8 +375,8 @@ public:
inline void drawPixmap(const QRect &r, const QPixmap &pm);
inline void drawPixmap(int x, int y, int w, int h, const QPixmap &pm);
- void drawPixmapFragments(const Fragment *fragments, int fragmentCount,
- const QPixmap &pixmap, FragmentHints hints = 0);
+ void drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount,
+ const QPixmap &pixmap, PixmapFragmentHints hints = 0);
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect,
Qt::ImageConversionFlags flags = Qt::AutoColor);
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index cf3957b..4418018 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -195,7 +195,7 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const
QFontEngineFT::QGlyphSet *gset = ft->loadTransformedGlyphSet(m_transform);
if (gset && ft->loadGlyphs(gset, &g, 1, format)) {
- QFontEngineFT::Glyph *glyph = gset->glyph_data.value(g);
+ QFontEngineFT::Glyph *glyph = gset->getGlyph(g);
const int bytesPerLine = (format == QFontEngineFT::Format_Mono ? ((glyph->width + 31) & ~31) >> 3
: (glyph->width + 3) & ~3);
return QImage(glyph->data, glyph->width, glyph->height, bytesPerLine, imageFormat);
diff --git a/src/gui/painting/qwindowsurface_qws.cpp b/src/gui/painting/qwindowsurface_qws.cpp
index d3fc9de..a816ed2 100644
--- a/src/gui/painting/qwindowsurface_qws.cpp
+++ b/src/gui/painting/qwindowsurface_qws.cpp
@@ -80,7 +80,7 @@ static void qt_insertWindowSurface(int winId, QWSWindowSurface *surface)
inline bool isWidgetOpaque(const QWidget *w)
{
- return w->d_func()->isOpaque;
+ return w->d_func()->isOpaque && !w->testAttribute(Qt::WA_TranslucentBackground);
}
static inline QScreen *getScreen(const QWidget *w)
@@ -873,6 +873,21 @@ bool QWSMemorySurface::isValid() const
return true;
}
+// ### copied from qwindowsurface_raster.cpp -- should be cross-platform
+void QWSMemorySurface::beginPaint(const QRegion &rgn)
+{
+ if (!isWidgetOpaque(window())) {
+ QPainter p(&img);
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ const QVector<QRect> rects = rgn.rects();
+ const QColor blank = Qt::transparent;
+ for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
+ p.fillRect(*it, blank);
+ }
+ }
+ QWSWindowSurface::beginPaint(rgn);
+}
+
// from qwindowsurface.cpp
extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
diff --git a/src/gui/painting/qwindowsurface_qws_p.h b/src/gui/painting/qwindowsurface_qws_p.h
index a8371c8..30900dc 100644
--- a/src/gui/painting/qwindowsurface_qws_p.h
+++ b/src/gui/painting/qwindowsurface_qws_p.h
@@ -176,6 +176,8 @@ public:
QImage image() const { return img; }
QPoint painterOffset() const;
+ void beginPaint(const QRegion &rgn);
+
bool lock(int timeout = -1);
void unlock();
diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp
index 6cc7455..1f68f2f 100644
--- a/src/gui/styles/qgtkpainter.cpp
+++ b/src/gui/styles/qgtkpainter.cpp
@@ -142,7 +142,7 @@ QPixmap QGtkPainter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect)
}
QGtkPainter::QGtkPainter(QPainter *_painter)
- : m_window(QGtkStylePrivate::gtkWidget(QLatin1String("GtkWindow")))
+ : m_window(QGtkStylePrivate::gtkWidget("GtkWindow"))
, m_painter(_painter)
, m_alpha(true)
, m_hflipped(false)
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index b5f052b..e2de43a 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -222,7 +222,7 @@ QPalette QGtkStyle::standardPalette() const
QPalette palette = QCleanlooksStyle::standardPalette();
if (d->isThemeAvailable()) {
GtkStyle *style = d->gtkStyle();
- GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
GtkWidget *gtkEntry = d->getTextColorWidget();
GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg;
@@ -253,7 +253,7 @@ QPalette QGtkStyle::standardPalette() const
palette.setColor(QPalette::Base, base);
QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box
- GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView"));
+ GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
GdkColor *gtkAltBase = NULL;
d->gtk_widget_style_get(gtkTreeView, "odd-row-color", &gtkAltBase, NULL);
if (gtkAltBase) {
@@ -421,14 +421,14 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
return 0;
case PM_ButtonShiftHorizontal: {
- GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
guint horizontal_shift;
d->gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL);
return horizontal_shift;
}
case PM_ButtonShiftVertical: {
- GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
guint vertical_shift;
d->gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL);
return vertical_shift;
@@ -438,7 +438,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
return 0;
case PM_MenuPanelWidth: {
- GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
+ GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
guint horizontal_padding = 0;
// horizontal-padding is used by Maemo to get thicker borders
if (!d->gtk_check_version(2, 10, 0))
@@ -495,7 +495,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
case PM_SliderThickness:
case PM_SliderControlThickness: {
- GtkWidget *gtkScale = d->gtkWidget(QLS("GtkHScale"));
+ GtkWidget *gtkScale = d->gtkWidget("GtkHScale");
gint val;
d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
if (metric == PM_SliderControlThickness)
@@ -506,7 +506,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
case PM_ScrollBarExtent: {
gint sliderLength;
gint trough_border;
- GtkWidget *hScrollbar = d->gtkWidget(QLS("GtkHScrollbar"));
+ GtkWidget *hScrollbar = d->gtkWidget("GtkHScrollbar");
d->gtk_widget_style_get(hScrollbar,
"trough-border", &trough_border,
"slider-width", &sliderLength,
@@ -519,34 +519,34 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
case PM_SliderLength:
gint val;
- d->gtk_widget_style_get(d->gtkWidget(QLS("GtkHScale")), "slider-length", &val, NULL);
+ d->gtk_widget_style_get(d->gtkWidget("GtkHScale"), "slider-length", &val, NULL);
return val;
case PM_ExclusiveIndicatorWidth:
case PM_ExclusiveIndicatorHeight:
case PM_IndicatorWidth:
case PM_IndicatorHeight: {
- GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
+ GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
gint size, spacing;
d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL);
return size + 2 * spacing;
}
case PM_MenuBarVMargin: {
- GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
+ GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
return qMax(0, gtkMenubar->style->ythickness);
}
case PM_ScrollView_ScrollBarSpacing:
{
gint spacing = 3;
- GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow"));
+ GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
Q_ASSERT(gtkScrollWindow);
d->gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL);
return spacing;
}
case PM_SubMenuOverlap: {
gint offset = 0;
- GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
+ GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
d->gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL);
return offset;
}
@@ -587,7 +587,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
{
if (d->isKDE4Session())
return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
- GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar"));
+ GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL);
switch (toolbar_style) {
@@ -610,7 +610,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
return int(false);
case SH_ComboBox_Popup: {
- GtkWidget *gtkComboBox = d->gtkWidget(QLS("GtkComboBox"));
+ GtkWidget *gtkComboBox = d->gtkWidget("GtkComboBox");
gboolean appears_as_list;
d->gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL);
return appears_as_list ? 0 : 1;
@@ -634,7 +634,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
if (widget && widget->isWindow())
scrollbars_within_bevel = true;
else if (!d->gtk_check_version(2, 12, 0)) {
- GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow"));
+ GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
d->gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
}
return !scrollbars_within_bevel;
@@ -712,7 +712,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkStyle *style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
"*.GtkScrolledWindow", "*.GtkScrolledWindow", d->gtk_window_get_type());
if (style)
- gtkFramePainter.paintShadow(d->gtkWidget(QLS("GtkFrame")), "viewport", pmRect,
+ gtkFramePainter.paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect,
option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
shadow_type, style);
QPixmapCache::insert(pmKey, pixmap);
@@ -739,7 +739,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
case PE_PanelTipLabel: {
- GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
+ GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
d->gtk_window_get_type());
gtkPainter.paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style);
@@ -754,7 +754,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
}
GtkShadowType shadow_type;
- GtkWidget *gtkStatusbarFrame = d->gtkWidget(QLS("GtkStatusbar.GtkFrame"));
+ GtkWidget *gtkStatusbarFrame = d->gtkWidget("GtkStatusbar.GtkFrame");
d->gtk_widget_style_get(gtkStatusbarFrame->parent, "shadow-type", &shadow_type, NULL);
gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
shadow_type, gtkStatusbarFrame->style);
@@ -763,7 +763,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_IndicatorHeaderArrow:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- GtkWidget *gtkTreeHeader = d->gtkWidget(QLS("GtkTreeView.GtkButton"));
+ GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton");
GtkStateType state = gtkPainter.gtkState(option);
style = gtkTreeHeader->style;
GtkArrowType type = GTK_ARROW_UP;
@@ -801,7 +801,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
rect.translate(2, 0);
GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED;
GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED;
- GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView"));
+ GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
GtkStateType state = GTK_STATE_NORMAL;
if (!(option->state & State_Enabled))
@@ -837,7 +837,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_IndicatorToolBarSeparator:
{
const int margin = 6;
- GtkWidget *gtkSeparator = d->gtkWidget(QLS("GtkToolbar.GtkSeparatorToolItem"));
+ GtkWidget *gtkSeparator = d->gtkWidget("GtkToolbar.GtkSeparatorToolItem");
if (option->state & State_Horizontal) {
const int offset = option->rect.width()/2;
QRect rect = option->rect.adjusted(offset, margin, 0, -margin);
@@ -857,7 +857,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
case PE_IndicatorToolBarHandle: {
- GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar"));
+ GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
GtkShadowType shadow_type;
d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
//Note when the toolbar is horizontal, the handle is vertical
@@ -905,7 +905,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkStateType state = gtkPainter.gtkState(option);
QColor arrowColor = option->palette.buttonText().color();
- GtkWidget *gtkArrow = d->gtkWidget(QLS("GtkArrow"));
+ GtkWidget *gtkArrow = d->gtkWidget("GtkArrow");
GdkColor color = fromQColor(arrowColor);
d->gtk_widget_modify_fg (gtkArrow, state, &color);
gtkPainter.paintArrow(gtkArrow, "button", arrowRect,
@@ -921,7 +921,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
case PE_PanelMenu: {
- GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
+ GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons
gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString());
}
@@ -933,7 +933,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
// This is only used by floating tool bars
if (qobject_cast<const QToolBar *>(widget)) {
- GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
+ GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
gtkPainter.paintBox( gtkMenubar, "toolbar", option->rect,
GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
gtkPainter.paintBox( gtkMenubar, "menu", option->rect,
@@ -942,7 +942,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
case PE_FrameLineEdit: {
- GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
+ GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
gboolean interior_focus;
@@ -976,7 +976,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_PanelLineEdit:
if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
+ GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
if (panel->lineWidth > 0)
proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget);
uint resolve_mask = option->palette.resolve();
@@ -994,7 +994,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_FrameTabWidget:
if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option)) {
- GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook"));
+ GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
style = gtkPainter.getStyle(gtkNotebook);
gtkPainter.setAlphaSupport(false);
GtkShadowType shadow = GTK_SHADOW_OUT;
@@ -1042,7 +1042,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkStateType state = gtkPainter.gtkState(option);
if (option->state & State_On || option->state & State_Sunken)
state = GTK_STATE_ACTIVE;
- GtkWidget *gtkButton = d->gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton"));
+ GtkWidget *gtkButton = isTool ? d->gtkWidget("GtkToolButton.GtkButton") : d->gtkWidget("GtkButton");
gint focusWidth, focusPad;
gboolean interiorFocus = false;
d->gtk_widget_style_get (gtkButton,
@@ -1098,14 +1098,14 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
else
shadow = GTK_SHADOW_OUT;
- GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton"));
+ GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
gint spacing;
d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);
QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
gtkPainter.setClipRect(option->rect);
// ### Note: Ubuntulooks breaks when the proper widget is passed
// Murrine engine requires a widget not to get RGBA check - warnings
- GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
+ GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
QString key(QLS("radiobutton"));
if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag
key += QLatin1Char('f');
@@ -1133,7 +1133,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
int spacing;
- GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
+ GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
QString key(QLS("checkbutton"));
if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag
key += QLatin1Char('f');
@@ -1275,7 +1275,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
// Draw prelight background
- GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
+ GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
if (option->state & State_MouseOver) {
QRect bgRect = textRect | checkBoxRect;
@@ -1348,7 +1348,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
GTK_SHADOW_IN : GTK_SHADOW_OUT;
- QString comboBoxPath = QLS(comboBox->editable ? "GtkComboBoxEntry" : "GtkComboBox");
+ const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox");
// We use the gtk widget to position arrows and separators for us
GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
@@ -1356,7 +1356,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
d->gtk_widget_size_allocate(gtkCombo, &geometry);
- QString buttonPath = comboBoxPath + QLS(".GtkToggleButton");
+ QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
+ : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath);
d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
@@ -1365,7 +1366,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
// Draw the combo box as a line edit with a button next to it
if (comboBox->editable || appears_as_list) {
GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
- QString entryPath = QLS(comboBox->editable ? "GtkComboBoxEntry.GtkEntry" : "GtkComboBox.GtkFrame");
+ QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame");
GtkWidget *gtkEntry = d->gtkWidget(entryPath);
d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
QRect frameRect = option->rect;
@@ -1391,11 +1392,11 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
else {
gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect,
option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_NONE, gtkEntry->style, entryPath + QString::number(focus));
+ GTK_SHADOW_NONE, gtkEntry->style, entryPath.toString() + QString::number(focus));
}
gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState,
- GTK_SHADOW_IN, gtkEntry->style, entryPath +
+ GTK_SHADOW_IN, gtkEntry->style, entryPath.toString() +
QString::number(focus) + QString::number(comboBox->editable) +
QString::number(option->direction));
if (focus)
@@ -1416,7 +1417,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
Q_ASSERT(gtkToggleButton);
gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState,
- shadow, gtkToggleButton->style, buttonPath +
+ shadow, gtkToggleButton->style, buttonPath.toString() +
QString::number(focus) + QString::number(option->direction));
if (focus)
GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
@@ -1429,12 +1430,17 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gtkCachedPainter.paintBox(gtkToggleButton, "button",
buttonRect, state,
shadow, gtkToggleButton->style,
- buttonPath + QString::number(focus));
+ buttonPath.toString() + QString::number(focus));
if (focus)
GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+ QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
+ : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
+
// Draw the separator between label and arrows
- QString vSeparatorPath = buttonPath + QLS(".GtkHBox.GtkVSeparator");
+ QHashableLatin1Literal vSeparatorPath = comboBox->editable
+ ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator")
+ : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator");
if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) {
QRect vLineRect(gtkVSeparator->allocation.x,
@@ -1444,7 +1450,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gtkCachedPainter.paintVline( gtkVSeparator, "vseparator",
vLineRect, state, gtkVSeparator->style,
- 0, vLineRect.height(), 0, vSeparatorPath);
+ 0, vLineRect.height(), 0, vSeparatorPath.toString());
gint interiorFocus = true;
@@ -1469,8 +1475,18 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
else
state = GTK_STATE_NORMAL;
- QString arrowPath = comboBoxPath + QLS(appears_as_list ? ".GtkToggleButton.GtkArrow"
- : ".GtkToggleButton.GtkHBox.GtkArrow");
+ QHashableLatin1Literal arrowPath("");
+ if (comboBox->editable) {
+ if (appears_as_list)
+ arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow");
+ else
+ arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkArrow");
+ } else {
+ if (appears_as_list)
+ arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkArrow");
+ else
+ arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow");
+ }
GtkWidget *gtkArrow = d->gtkWidget(arrowPath);
gfloat scale = 0.7;
@@ -1497,7 +1513,11 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (sunken) {
int xoff, yoff;
- GtkWidget *gtkButton = d->gtkWidget(comboBoxPath + QLS(".GtkToggleButton"));
+ const QHashableLatin1Literal toggleButtonPath = comboBox->editable
+ ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
+ : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
+
+ GtkWidget *gtkButton = d->gtkWidget(toggleButtonPath);
d->gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL);
d->gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL);
arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff);
@@ -1509,7 +1529,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gtkCachedPainter.setClipRect(option->rect);
gtkCachedPainter.paintArrow( gtkArrow, "arrow", arrowRect,
GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, TRUE,
- style, arrowPath + QString::number(option->direction));
+ style, arrowPath.toString() + QString::number(option->direction));
}
}
END_STYLE_PIXMAPCACHE;
@@ -1570,7 +1590,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QStyleOptionToolButton label = *toolbutton;
label.state = bflags;
- GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
QPalette pal = toolbutton->palette;
if (option->state & State_Enabled &&
option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) {
@@ -1605,8 +1625,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
case CC_ScrollBar:
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- GtkWidget *gtkHScrollBar = d->gtkWidget(QLS("GtkHScrollbar"));
- GtkWidget *gtkVScrollBar = d->gtkWidget(QLS("GtkVScrollbar"));
+ GtkWidget *gtkHScrollBar = d->gtkWidget("GtkHScrollbar");
+ GtkWidget *gtkVScrollBar = d->gtkWidget("GtkVScrollbar");
// Fill background in case the scrollbar is partially transparent
painter->fillRect(option->rect, option->palette.background());
@@ -1751,10 +1771,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
case CC_SpinBox:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- GtkWidget *gtkSpinButton = d->gtkWidget(
- spinBox->buttonSymbols == QAbstractSpinBox::NoButtons ?
- QLS("GtkEntry") :
- QLS("GtkSpinButton"));
+ GtkWidget *gtkSpinButton = spinBox->buttonSymbols == QAbstractSpinBox::NoButtons
+ ? d->gtkWidget("GtkEntry")
+ : d->gtkWidget("GtkSpinButton");
bool isEnabled = (spinBox->state & State_Enabled);
bool hover = isEnabled && (spinBox->state & State_MouseOver);
bool sunken = (spinBox->state & State_Sunken);
@@ -1906,8 +1925,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- GtkWidget *hScaleWidget = d->gtkWidget(QLS("GtkHScale"));
- GtkWidget *vScaleWidget = d->gtkWidget(QLS("GtkVScale"));
+ GtkWidget *hScaleWidget = d->gtkWidget("GtkHScale");
+ GtkWidget *vScaleWidget = d->gtkWidget("GtkVScale");
QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
@@ -2097,7 +2116,7 @@ void QGtkStyle::drawControl(ControlElement element,
switch (element) {
case CE_ProgressBarLabel:
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar"));
+ GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
if (!gtkProgressBar)
return;
@@ -2200,7 +2219,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (button->features & QStyleOptionButton::HasMenu)
ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
- GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
QPalette pal = button->palette;
int labelState = GTK_STATE_INSENSITIVE;
if (option->state & State_Enabled)
@@ -2221,7 +2240,7 @@ void QGtkStyle::drawControl(ControlElement element,
bool isRadio = (element == CE_RadioButton);
// Draw prelight background
- GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton"));
+ GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
if (option->state & State_MouseOver) {
gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect,
@@ -2289,7 +2308,7 @@ void QGtkStyle::drawControl(ControlElement element,
}
if (!cb->currentText.isEmpty() && !cb->editable) {
- GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox"));
+ GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
QPalette pal = cb->palette;
int labelState = GTK_STATE_INSENSITIVE;
@@ -2366,7 +2385,7 @@ void QGtkStyle::drawControl(ControlElement element,
// Draws the header in tables.
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
Q_UNUSED(header);
- GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView"));
+ GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
// Get the middle column
GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1);
Q_ASSERT(column);
@@ -2387,7 +2406,7 @@ void QGtkStyle::drawControl(ControlElement element,
#ifndef QT_NO_SIZEGRIP
case CE_SizeGrip: {
- GtkWidget *gtkStatusbar = d->gtkWidget(QLS("GtkStatusbar.GtkFrame"));
+ GtkWidget *gtkStatusbar = d->gtkWidget("GtkStatusbar.GtkFrame");
QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness);
gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
@@ -2399,7 +2418,7 @@ void QGtkStyle::drawControl(ControlElement element,
#endif // QT_NO_SIZEGRIP
case CE_MenuBarEmptyArea: {
- GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
+ GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
if (widget) { // See CE_MenuBarItem
@@ -2422,8 +2441,8 @@ void QGtkStyle::drawControl(ControlElement element,
painter->save();
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- GtkWidget *gtkMenubarItem = d->gtkWidget(QLS("GtkMenuBar.GtkMenuItem"));
- GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
+ GtkWidget *gtkMenubarItem = d->gtkWidget("GtkMenuBar.GtkMenuItem");
+ GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
style = gtkMenubarItem->style;
@@ -2479,7 +2498,7 @@ void QGtkStyle::drawControl(ControlElement element,
break;
case CE_Splitter: {
- GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
+ GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE,
!(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
style);
@@ -2499,7 +2518,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (toolbar->positionWithinLine != QStyleOptionToolBar::End)
rect.adjust(0, 0, 1, 0);
- GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar"));
+ GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
GtkShadowType shadow_type = GTK_SHADOW_NONE;
d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
gtkPainter.paintBox( gtkToolbar, "toolbar", rect,
@@ -2518,15 +2537,15 @@ void QGtkStyle::drawControl(ControlElement element,
const int windowsItemHMargin = 3; // menu item hor text margin
const int windowsItemVMargin = 26; // menu item ver text margin
const int windowsRightBorder = 15; // right border on windows
- GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) :
- d->gtkWidget(QLS("GtkMenu.GtkMenuItem"));
+ GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") :
+ d->gtkWidget("GtkMenu.GtkMenuItem");
style = gtkPainter.getStyle(gtkMenuItem);
QColor borderColor = option->palette.background().color().darker(160);
QColor shadow = option->palette.dark().color();
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
- GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
+ GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
painter->setPen(shadow.lighter(106));
gboolean wide_separators = 0;
gint separator_height = 0;
@@ -2570,7 +2589,7 @@ void QGtkStyle::drawControl(ControlElement element,
bool ignoreCheckMark = false;
gint checkSize;
- d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL);
+ d->gtk_widget_style_get(d->gtkWidget("GtkMenu.GtkCheckMenuItem"), "indicator-size", &checkSize, NULL);
int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize));
@@ -2781,7 +2800,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_PushButton:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget);
QStyleOptionButton subopt = *btn;
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
@@ -2807,7 +2826,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_TabBarTabShape:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook"));
+ GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
style = gtkPainter.getStyle(gtkNotebook);
QRect rect = option->rect;
@@ -2874,7 +2893,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_ProgressBarGroove:
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
Q_UNUSED(bar);
- GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar"));
+ GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
GtkStateType state = gtkPainter.gtkState(option);
gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style);
}
@@ -2884,7 +2903,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_ProgressBarContents:
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE;
- GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar"));
+ GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
style = gtkProgressBar->style;
gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style);
int xt = style->xthickness;
@@ -3042,7 +3061,7 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
case CC_SpinBox:
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton"));
+ GtkWidget *gtkSpinButton = d->gtkWidget("GtkSpinButton");
int center = spinbox->rect.height() / 2;
int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0;
int yt = spinbox->frame ? gtkSpinButton->style->ythickness : 0;
@@ -3096,15 +3115,19 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
// We employ the gtk widget to position arrows and separators for us
QString comboBoxPath = box->editable ? QLS("GtkComboBoxEntry") : QLS("GtkComboBox");
- GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
+ GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry")
+ : d->gtkWidget("GtkComboBox");
d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())};
d->gtk_widget_size_allocate(gtkCombo, &geometry);
int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget);
- QString arrowPath = comboBoxPath + QLS(".GtkToggleButton");
-
- if (!box->editable && !appears_as_list)
- arrowPath += QLS(".GtkHBox.GtkArrow");
+ QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton");
+ if (!box->editable) {
+ if (appears_as_list)
+ arrowPath = "GtkComboBox.GtkToggleButton";
+ else
+ arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow";
+ }
GtkWidget *arrowWidget = d->gtkWidget(arrowPath);
if (!arrowWidget)
@@ -3163,7 +3186,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
case CT_ToolButton:
if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness);
if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
QSize minSize(0, 25);
@@ -3181,14 +3204,14 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
int textMargin = 8;
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
- GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
+ GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
GtkRequisition sizeReq = {0, 0};
d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq);
newSize = QSize(size.width(), sizeReq.height);
break;
}
- GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem"));
+ GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem");
GtkStyle* style = gtkMenuItem->style;
// Note we get the perfect height for the default font since we
@@ -3210,12 +3233,12 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
case CT_SpinBox:
// QSpinBox does some nasty things that depends on CT_LineEdit
- newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2);
+ newSize = size + QSize(0, -d->gtkWidget("GtkSpinButton")->style->ythickness * 2);
break;
case CT_PushButton:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
gint focusPadding, focusWidth;
d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
@@ -3223,7 +3246,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness);
newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding));
- GtkWidget *gtkButtonBox = d->gtkWidget(QLS("GtkHButtonBox"));
+ GtkWidget *gtkButtonBox = d->gtkWidget("GtkHButtonBox");
gint minWidth = 85, minHeight = 0;
d->gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth,
"child-min-height", &minHeight, NULL);
@@ -3236,13 +3259,13 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
break;
case CT_Slider: {
- GtkWidget *gtkSlider = d->gtkWidget(QLS("GtkHScale"));
+ GtkWidget *gtkSlider = d->gtkWidget("GtkHScale");
newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness);
}
break;
case CT_LineEdit: {
- GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
+ GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness);
}
break;
@@ -3253,7 +3276,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
case CT_ComboBox:
if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox"));
+ GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget);
newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness);
@@ -3405,7 +3428,7 @@ QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option,
return option->rect;
case SE_PushButtonContents:
if (!d->gtk_check_version(2, 10, 0)) {
- GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
GtkBorder *border = 0;
d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL);
if (border) {
diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp
index a033407..3c6a1ef 100644
--- a/src/gui/styles/qgtkstyle_p.cpp
+++ b/src/gui/styles/qgtkstyle_p.cpp
@@ -60,6 +60,7 @@
#include <QtCore/QHash>
#include <QtCore/QUrl>
#include <QtCore/QLibrary>
+#include <QtCore/QDebug>
#include <private/qapplication_p.h>
#include <private/qiconloader_p.h>
@@ -91,8 +92,8 @@ Ptr_gtk_widget_set_default_direction QGtkStylePrivate::gtk_widget_set_default_di
Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_fg = 0;
Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_bg = 0;
Ptr_gtk_arrow_new QGtkStylePrivate::gtk_arrow_new = 0;
-Ptr_gtk_menu_item_new QGtkStylePrivate::gtk_menu_item_new = 0;
-Ptr_gtk_check_menu_item_new QGtkStylePrivate::gtk_check_menu_item_new = 0;
+Ptr_gtk_menu_item_new_with_label QGtkStylePrivate::gtk_menu_item_new_with_label = 0;
+Ptr_gtk_check_menu_item_new_with_label QGtkStylePrivate::gtk_check_menu_item_new_with_label = 0;
Ptr_gtk_menu_bar_new QGtkStylePrivate::gtk_menu_bar_new = 0;
Ptr_gtk_menu_new QGtkStylePrivate::gtk_menu_new = 0;
Ptr_gtk_button_new QGtkStylePrivate::gtk_button_new = 0;
@@ -233,17 +234,22 @@ static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *, gpointer)
}
}
-static QString classPath(GtkWidget *widget)
+static QHashableLatin1Literal classPath(GtkWidget *widget)
{
- char* class_path;
+ char *class_path;
QGtkStylePrivate::gtk_widget_path (widget, NULL, &class_path, NULL);
- QString path = QLS(class_path);
+
+ char *copy = class_path;
+ if (strncmp(copy, "GtkWindow.", 10) == 0)
+ copy += 10;
+ if (strncmp(copy, "GtkFixed.", 9) == 0)
+ copy += 9;
+
+ copy = strdup(copy);
+
g_free(class_path);
- // Remove the prefixes
- path.remove(QLS("GtkWindow."));
- path.remove(QLS("GtkFixed."));
- return path;
+ return QHashableLatin1Literal::fromData(copy);
}
@@ -261,6 +267,7 @@ bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e)
}
QList<QGtkStylePrivate *> QGtkStylePrivate::instances;
+QGtkStylePrivate::WidgetMap *QGtkStylePrivate::widgetMap = 0;
QGtkStylePrivate::QGtkStylePrivate()
: QCleanlooksStylePrivate()
@@ -282,7 +289,7 @@ void QGtkStylePrivate::init()
qApp->installEventFilter(&filter);
}
-GtkWidget* QGtkStylePrivate::gtkWidget(const QString &path)
+GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path)
{
GtkWidget *widget = gtkWidgetMap()->value(path);
if (!widget) {
@@ -292,10 +299,10 @@ GtkWidget* QGtkStylePrivate::gtkWidget(const QString &path)
return widget;
}
-GtkStyle* QGtkStylePrivate::gtkStyle(const QString &path)
+GtkStyle* QGtkStylePrivate::gtkStyle(const QHashableLatin1Literal &path)
{
- if (gtkWidgetMap()->contains(path))
- return gtkWidgetMap()->value(path)->style;
+ if (GtkWidget *w = gtkWidgetMap()->value(path))
+ return w->style;
return 0;
}
@@ -347,8 +354,8 @@ void QGtkStylePrivate::resolveGtk() const
gtk_widget_modify_fg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_fg");
gtk_widget_modify_bg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_bg");
gtk_arrow_new = (Ptr_gtk_arrow_new)libgtk.resolve("gtk_arrow_new");
- gtk_menu_item_new = (Ptr_gtk_menu_item_new)libgtk.resolve("gtk_menu_item_new");
- gtk_check_menu_item_new = (Ptr_gtk_check_menu_item_new)libgtk.resolve("gtk_check_menu_item_new");
+ gtk_menu_item_new_with_label = (Ptr_gtk_menu_item_new_with_label)libgtk.resolve("gtk_menu_item_new_with_label");
+ gtk_check_menu_item_new_with_label = (Ptr_gtk_check_menu_item_new_with_label)libgtk.resolve("gtk_check_menu_item_new_with_label");
gtk_menu_bar_new = (Ptr_gtk_menu_bar_new)libgtk.resolve("gtk_menu_bar_new");
gtk_menu_new = (Ptr_gtk_menu_new)libgtk.resolve("gtk_menu_new");
gtk_toolbar_new = (Ptr_gtk_toolbar_new)libgtk.resolve("gtk_toolbar_new");
@@ -439,7 +446,7 @@ void QGtkStylePrivate::initGtkMenu() const
GtkWidget *gtkMenuBar = QGtkStylePrivate::gtk_menu_bar_new();
setupGtkWidget(gtkMenuBar);
- GtkWidget *gtkMenuBarItem = QGtkStylePrivate::gtk_menu_item_new();
+ GtkWidget *gtkMenuBarItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
gtk_menu_shell_append((GtkMenuShell*)(gtkMenuBar), gtkMenuBarItem);
gtk_widget_realize(gtkMenuBarItem);
@@ -448,14 +455,11 @@ void QGtkStylePrivate::initGtkMenu() const
gtk_menu_item_set_submenu((GtkMenuItem*)(gtkMenuBarItem), gtkMenu);
gtk_widget_realize(gtkMenu);
- GtkWidget *gtkMenuItem = QGtkStylePrivate::gtk_menu_item_new();
- g_object_set(gtkMenuItem, "label", "X", NULL);
-
+ GtkWidget *gtkMenuItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem);
gtk_widget_realize(gtkMenuItem);
- GtkWidget *gtkCheckMenuItem = QGtkStylePrivate::gtk_check_menu_item_new();
- g_object_set(gtkCheckMenuItem, "label", "X", NULL);
+ GtkWidget *gtkCheckMenuItem = QGtkStylePrivate::gtk_check_menu_item_new_with_label("X");
gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem);
gtk_widget_realize(gtkCheckMenuItem);
@@ -497,7 +501,7 @@ void QGtkStylePrivate::initGtkWidgets() const
}
static QString themeName;
- if (!gtkWidgetMap()->contains(QLS("GtkWindow")) && themeName.isEmpty()) {
+ if (!gtkWidgetMap()->contains("GtkWindow") && themeName.isEmpty()) {
themeName = getThemeName();
if (themeName.isEmpty()) {
@@ -522,18 +526,18 @@ void QGtkStylePrivate::initGtkWidgets() const
QGtkStylePrivate::gtk_widget_realize(gtkWindow);
if (displayDepth == -1)
displayDepth = QGtkStylePrivate::gdk_drawable_get_depth(gtkWindow->window);
- gtkWidgetMap()->insert(QLS("GtkWindow"), gtkWindow);
+ gtkWidgetMap()->insert(QHashableLatin1Literal::fromData(strdup("GtkWindow")), gtkWindow);
// Make all other widgets. respect the text direction
if (qApp->layoutDirection() == Qt::RightToLeft)
QGtkStylePrivate::gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
- if (!gtkWidgetMap()->contains(QLS("GtkButton"))) {
+ if (!gtkWidgetMap()->contains("GtkButton")) {
GtkWidget *gtkButton = QGtkStylePrivate::gtk_button_new();
addWidget(gtkButton);
g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), 0);
- addWidget(QGtkStylePrivate::gtk_tool_button_new(NULL, NULL));
+ addWidget(QGtkStylePrivate::gtk_tool_button_new(NULL, "Qt"));
addWidget(QGtkStylePrivate::gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE));
addWidget(QGtkStylePrivate::gtk_hbutton_box_new());
addWidget(QGtkStylePrivate::gtk_check_button_new());
@@ -566,12 +570,12 @@ void QGtkStylePrivate::initGtkWidgets() const
// When styles change subwidgets can get rearranged
// as with the combo box. We need to update the widget map
// to reflect this;
- QHash<QString, GtkWidget*> oldMap = *gtkWidgetMap();
+ QHash<QHashableLatin1Literal, GtkWidget*> oldMap = *gtkWidgetMap();
gtkWidgetMap()->clear();
- QHashIterator<QString, GtkWidget*> it(oldMap);
+ QHashIterator<QHashableLatin1Literal, GtkWidget*> it(oldMap);
while (it.hasNext()) {
it.next();
- if (!it.key().contains(QLatin1Char('.'))) {
+ if (!strchr(it.key().data(), '.')) {
addAllSubWidgets(it.value());
}
}
@@ -586,8 +590,13 @@ void QGtkStylePrivate::initGtkWidgets() const
*/
void QGtkStylePrivate::cleanupGtkWidgets()
{
- if (gtkWidgetMap()->contains(QLS("GtkWindow"))) // Gtk will destroy all children
- gtk_widget_destroy(gtkWidgetMap()->value(QLS("GtkWindow")));
+ if (!widgetMap)
+ return;
+ if (widgetMap->contains("GtkWindow")) // Gtk will destroy all children
+ gtk_widget_destroy(widgetMap->value("GtkWindow"));
+ for (QHash<QHashableLatin1Literal, GtkWidget *>::const_iterator it = widgetMap->constBegin();
+ it != widgetMap->constEnd(); ++it)
+ free(const_cast<char *>(it.key().data()));
}
static bool resolveGConf()
@@ -678,7 +687,7 @@ QString QGtkStylePrivate::getThemeName()
int QGtkStylePrivate::getSpinboxArrowSize() const
{
const int MIN_ARROW_WIDTH = 6;
- GtkWidget *spinButton = gtkWidget(QLS("GtkSpinButton"));
+ GtkWidget *spinButton = gtkWidget("GtkSpinButton");
GtkStyle *style = spinButton->style;
gint size = pango_font_description_get_size (style->font_desc);
gint arrow_size;
@@ -698,17 +707,17 @@ bool QGtkStylePrivate::isKDE4Session()
void QGtkStylePrivate::applyCustomPaletteHash()
{
- QPalette menuPal = gtkWidgetPalette(QLS("GtkMenu"));
- GdkColor gdkBg = gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL];
+ QPalette menuPal = gtkWidgetPalette("GtkMenu");
+ GdkColor gdkBg = gtkWidget("GtkMenu")->style->bg[GTK_STATE_NORMAL];
QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
menuPal.setBrush(QPalette::Base, bgColor);
menuPal.setBrush(QPalette::Window, bgColor);
qApp->setPalette(menuPal, "QMenu");
- QPalette toolbarPal = gtkWidgetPalette(QLS("GtkToolbar"));
+ QPalette toolbarPal = gtkWidgetPalette("GtkToolbar");
qApp->setPalette(toolbarPal, "QToolBar");
- QPalette menuBarPal = gtkWidgetPalette(QLS("GtkMenuBar"));
+ QPalette menuBarPal = gtkWidgetPalette("GtkMenuBar");
qApp->setPalette(menuBarPal, "QMenuBar");
}
@@ -717,7 +726,7 @@ void QGtkStylePrivate::applyCustomPaletteHash()
*/
GtkWidget* QGtkStylePrivate::getTextColorWidget() const
{
- return gtkWidget(QLS("GtkEntry"));
+ return gtkWidget("GtkEntry");
}
void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
@@ -726,7 +735,7 @@ void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
static GtkWidget* protoLayout = 0;
if (!protoLayout) {
protoLayout = QGtkStylePrivate::gtk_fixed_new();
- QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value(QLS("GtkWindow"))), protoLayout);
+ QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout);
}
Q_ASSERT(protoLayout);
@@ -739,8 +748,19 @@ void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget)
{
if (Q_GTK_IS_WIDGET(widget)) {
- gtk_widget_realize(widget);
- gtkWidgetMap()->insert(classPath(widget), widget);
+ gtk_widget_realize(widget);
+ QHashableLatin1Literal widgetPath = classPath(widget);
+
+ WidgetMap *map = gtkWidgetMap();
+ WidgetMap::iterator it = map->find(widgetPath);
+ if (it != map->end()) {
+ free(const_cast<char *>(it.key().data()));
+ map->erase(it);
+ }
+ map->insert(widgetPath, widget);
+#ifdef DUMP_GTK_WIDGET_TREE
+ qWarning("Inserted Gtk Widget: %s", widgetPath.data());
+#endif
}
}
@@ -753,7 +773,7 @@ void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v)
}
// Updates window/windowtext palette based on the indicated gtk widget
-QPalette QGtkStylePrivate::gtkWidgetPalette(const QString &gtkWidgetName) const
+QPalette QGtkStylePrivate::gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const
{
GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName);
Q_ASSERT(gtkWidget);
@@ -1089,6 +1109,28 @@ QIcon QGtkStylePrivate::getFilesystemIcon(const QFileInfo &info)
return icon;
}
+bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2)
+{
+ return l1.size() == l2.size() || qstrcmp(l1.data(), l2.data()) == 0;
+}
+
+// copied from qHash.cpp
+uint qHash(const QHashableLatin1Literal &key)
+{
+ int n = key.size();
+ const uchar *p = reinterpret_cast<const uchar *>(key.data());
+ uint h = 0;
+ uint g;
+
+ while (n--) {
+ h = (h << 4) + *p++;
+ if ((g = (h & 0xf0000000)) != 0)
+ h ^= g >> 23;
+ h &= ~g;
+ }
+ return h;
+}
+
QT_END_NAMESPACE
#endif // !defined(QT_NO_STYLE_GTK)
diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h
index db5b9b9..5bb7550 100644
--- a/src/gui/styles/qgtkstyle_p.h
+++ b/src/gui/styles/qgtkstyle_p.h
@@ -56,6 +56,10 @@
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
+#include <QtCore/qstring.h>
+#include <QtCore/qstringbuilder.h>
+#include <QtCore/qcoreapplication.h>
+
#include <QtGui/QFileDialog>
#include <QtGui/QGtkStyle>
@@ -72,6 +76,54 @@ typedef unsigned long XID;
#define QLS(x) QLatin1String(x)
+QT_BEGIN_NAMESPACE
+
+// ### Qt 4.7 - merge with QLatin1Literal
+class QHashableLatin1Literal
+{
+public:
+ int size() const { return m_size; }
+ const char *data() const { return m_data; }
+
+ template <int N>
+ QHashableLatin1Literal(const char (&str)[N])
+ : m_size(N - 1), m_data(str) {}
+
+ QHashableLatin1Literal(const QHashableLatin1Literal &other)
+ : m_size(other.m_size), m_data(other.m_data)
+ {}
+
+ QHashableLatin1Literal &operator=(const QHashableLatin1Literal &other)
+ {
+ if (this == &other)
+ return *this;
+ *const_cast<int *>(&m_size) = other.m_size;
+ *const_cast<char **>(&m_data) = const_cast<char *>(other.m_data);
+ return *this;
+ }
+
+ QString toString() const { return QString::fromLatin1(m_data, m_size); }
+
+ static QHashableLatin1Literal fromData(const char *str)
+ {
+ return QHashableLatin1Literal(str, qstrlen(str));
+ }
+
+private:
+ QHashableLatin1Literal(const char *str, int length)
+ : m_size(length), m_data(str)
+ {}
+
+ const int m_size;
+ const char *m_data;
+};
+
+bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2);
+inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); }
+uint qHash(const QHashableLatin1Literal &key);
+
+QT_END_NAMESPACE
+
class GConf;
class GConfClient;
@@ -87,9 +139,9 @@ typedef void (*Ptr_gtk_widget_realize) (GtkWidget *);
typedef void (*Ptr_gtk_widget_set_default_direction) (GtkTextDirection);
typedef void (*Ptr_gtk_widget_modify_color)(GtkWidget *widget, GtkStateType state, const GdkColor *color);
typedef GtkWidget* (*Ptr_gtk_arrow_new)(GtkArrowType, GtkShadowType);
-typedef GtkWidget* (*Ptr_gtk_menu_item_new)(void);
+typedef GtkWidget* (*Ptr_gtk_menu_item_new_with_label)(const gchar *);
typedef GtkWidget* (*Ptr_gtk_separator_menu_item_new)(void);
-typedef GtkWidget* (*Ptr_gtk_check_menu_item_new)(void);
+typedef GtkWidget* (*Ptr_gtk_check_menu_item_new_with_label)(const gchar *);
typedef GtkWidget* (*Ptr_gtk_menu_bar_new)(void);
typedef GtkWidget* (*Ptr_gtk_menu_new)(void);
typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void);
@@ -252,7 +304,6 @@ typedef char* (*Ptr_gnome_icon_lookup_sync) (
GnomeIconLookupFlags flags,
GnomeIconLookupResultFlags *result);
-
class QGtkStylePrivate : public QCleanlooksStylePrivate
{
Q_DECLARE_PUBLIC(QGtkStyle)
@@ -262,8 +313,8 @@ public:
QGtkStyleFilter filter;
- static GtkWidget* gtkWidget(const QString &path);
- static GtkStyle* gtkStyle(const QString &path = QLatin1String("GtkWindow"));
+ static GtkWidget* gtkWidget(const QHashableLatin1Literal &path);
+ static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow"));
virtual void resolveGtk() const;
virtual void initGtkMenu() const;
@@ -306,9 +357,9 @@ public:
static Ptr_gtk_widget_set_default_direction gtk_widget_set_default_direction;
static Ptr_gtk_widget_modify_color gtk_widget_modify_fg;
static Ptr_gtk_widget_modify_color gtk_widget_modify_bg;
- static Ptr_gtk_menu_item_new gtk_menu_item_new;
+ static Ptr_gtk_menu_item_new_with_label gtk_menu_item_new_with_label;
static Ptr_gtk_arrow_new gtk_arrow_new;
- static Ptr_gtk_check_menu_item_new gtk_check_menu_item_new;
+ static Ptr_gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_label;
static Ptr_gtk_menu_bar_new gtk_menu_bar_new;
static Ptr_gtk_menu_new gtk_menu_new;
static Ptr_gtk_expander_new gtk_expander_new;
@@ -418,17 +469,25 @@ public:
static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync;
static Ptr_gnome_vfs_init gnome_vfs_init;
- virtual QPalette gtkWidgetPalette(const QString &gtkWidgetName) const;
+ virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const;
protected:
- typedef QHash<QString, GtkWidget*> WidgetMap;
+ typedef QHash<QHashableLatin1Literal, GtkWidget*> WidgetMap;
+
+ static inline void destroyWidgetMap()
+ {
+ cleanupGtkWidgets();
+ delete widgetMap;
+ widgetMap = 0;
+ }
static inline WidgetMap *gtkWidgetMap()
{
- static WidgetMap *map = 0;
- if (!map)
- map = new WidgetMap();
- return map;
+ if (!widgetMap) {
+ widgetMap = new WidgetMap();
+ qAddPostRoutine(destroyWidgetMap);
+ }
+ return widgetMap;
}
static QStringList extract_filter(const QString &rawFilter);
@@ -443,6 +502,7 @@ protected:
private:
static QList<QGtkStylePrivate *> instances;
+ static WidgetMap *widgetMap;
friend class QGtkStyleUpdateScheduler;
};
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 565cc2c..bf5a62e 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -759,13 +759,29 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
QApplication::setPalette(widgetPalette, "QMenuBar");
widgetPalette = *palette;
+ widgetPalette.setColor(QPalette::Text,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0));
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
+ QApplication::setPalette(widgetPalette, "QMenu");
+ widgetPalette = *palette;
+
widgetPalette.setColor(QPalette::WindowText,
s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0));
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 3, 0));
QApplication::setPalette(widgetPalette, "QTabBar");
widgetPalette = *palette;
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
+ QApplication::setPalette(widgetPalette, "QListView");
+ widgetPalette = *palette;
+
widgetPalette.setColor(QPalette::Text,
s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0));
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
QApplication::setPalette(widgetPalette, "QTableView");
widgetPalette = *palette;
@@ -789,6 +805,8 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
widgetPalette = *palette;
widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0));
+ widgetPalette.setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
QApplication::setPalette(widgetPalette, "QRadioButton");
QApplication::setPalette(widgetPalette, "QCheckBox");
widgetPalette = *palette;
@@ -1241,6 +1259,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
case CE_RadioButton:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
bool isRadio = (element == CE_RadioButton);
+ QStyleOptionButton subopt = *btn;
+
// Highlight needs to be drawn first, as it goes "underneath" the text and indicator.
if (btn->state & State_HasFocus) {
QStyleOptionFocusRect fropt;
@@ -1248,8 +1268,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
: SE_CheckBoxFocusRect, btn, widget);
drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
+
+ subopt.palette.setColor(QPalette::Active, QPalette::WindowText,
+ subopt.palette.highlightedText().color());
}
- QStyleOptionButton subopt = *btn;
subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
: SE_CheckBoxIndicator, btn, widget);
@@ -1408,7 +1430,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
} else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);}
// draw the focus rect
- if (isSelected | hasFocus) {
+ if (isSelected || hasFocus ) {
QRect highlightRect = option->rect.adjusted(1,1,-1,-1);
QAbstractItemView::SelectionBehavior selectionBehavior =
itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems;
@@ -1480,15 +1502,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
// draw the text
if (!voptAdj.text.isEmpty()) {
- if (isSelected) {
- if (qobject_cast<const QTableView *>(widget))
- voptAdj.palette.setColor(
- QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
- else
- voptAdj.palette.setColor(
- QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
- }
- painter->setPen(voptAdj.palette.text().color());
+ if (isSelected || hasFocus )
+ painter->setPen(voptAdj.palette.highlightedText().color());
+ else
+ painter->setPen(voptAdj.palette.text().color());
d->viewItemDrawText(painter, &voptAdj, textRect);
}
painter->restore();
@@ -1590,7 +1607,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const bool selected = optionTab.state & State_Selected;
if (selected)
optionTab.palette.setColor(QPalette::Active, QPalette::WindowText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option));
+ optionTab.palette.highlightedText().color());
const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast
|| optionTab.shape == QTabBar::RoundedWest
@@ -1723,7 +1740,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (!styleHint(SH_UnderlineShortcut, menuItem, widget))
text_flags |= Qt::TextHideMnemonic;
- if ((option->state & State_Selected) && (option->state & State_Enabled))
+ const bool selected = (option->state & State_Selected) && (option->state & State_Enabled);
+ if (selected)
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags);
QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget);
@@ -1793,6 +1811,10 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
painter->save();
painter->setOpacity(0.5);
}
+ if (selected)
+ optionMenuItem.palette.setColor(
+ QPalette::Active, QPalette::Text, optionMenuItem.palette.highlightedText().color());
+
QCommonStyle::drawItemText(painter, textRect, text_flags,
optionMenuItem.palette, enabled,
optionMenuItem.text, QPalette::Text);
diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp
index 071ec23..296c51c 100644
--- a/src/gui/styles/qstylehelper.cpp
+++ b/src/gui/styles/qstylehelper.cpp
@@ -54,24 +54,71 @@
#include <private/qt_cocoa_helpers_mac_p.h>
#endif
+#include <qstringbuilder.h>
+
QT_BEGIN_NAMESPACE
+// internal helper. Converts an integer value to an unique string token
+template <typename T>
+struct HexString
+{
+ inline HexString(const T t)
+ : val(t)
+ {}
+
+ inline void write(QChar *&dest) const
+ {
+ const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+ const char *c = reinterpret_cast<const char *>(&val);
+ for (uint i = 0; i < sizeof(T); ++i) {
+ *dest++ = hexChars[*c & 0xf];
+ *dest++ = hexChars[(*c & 0xf0) >> 4];
+ ++c;
+ }
+ }
+
+ const T val;
+};
+
+// specialization to enable fast concatenating of our string tokens to a string
+template <typename T>
+struct QConcatenable<HexString<T> >
+{
+ typedef HexString<T> type;
+ enum { ExactSize = true };
+ static int size(const HexString<T> &str) { return sizeof(str.val) * 2; }
+ static inline void appendTo(const HexString<T> &str, QChar *&out) { str.write(out); }
+};
+
namespace QStyleHelper {
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
{
const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option);
- QString tmp = QString::fromLatin1("%1-%2-%3-%4-%5-%6x%7").arg(key).arg(uint(option->state)).arg(option->direction)
- .arg(complexOption ? uint(complexOption->activeSubControls) : uint(0))
- .arg(option->palette.cacheKey()).arg(size.width()).arg(size.height());
+
+ QString tmp = key
+ % QLatin1Char('-')
+ % HexString<uint>(option->state)
+ % QLatin1Char('-')
+ % HexString<uint>(option->direction)
+ % QLatin1Char('-')
+ % HexString<uint>(complexOption ? uint(complexOption->activeSubControls) : 0u)
+ % QLatin1Char('-')
+ % HexString<quint64>(option->palette.cacheKey())
+ % QLatin1Char('-')
+ % HexString<uint>(size.width())
+ % QLatin1Char('x')
+ % HexString<uint>(size.height());
+
#ifndef QT_NO_SPINBOX
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- tmp.append(QLatin1Char('-'));
- tmp.append(QString::number(spinBox->buttonSymbols));
- tmp.append(QLatin1Char('-'));
- tmp.append(QString::number(spinBox->stepEnabled));
- tmp.append(QLatin1Char('-'));
- tmp.append(QLatin1Char(spinBox->frame ? '1' : '0'));
+ tmp = tmp
+ % QLatin1Char('-')
+ % HexString<uint>(spinBox->buttonSymbols)
+ % QLatin1Char('-')
+ % HexString<uint>(spinBox->stepEnabled)
+ % QLatin1Char('-')
+ % QLatin1Char(spinBox->frame ? '1' : '0');
}
#endif // QT_NO_SPINBOX
return tmp;
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index bc1bece..5376386 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -3457,10 +3457,17 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
case CE_RadioButton:
case CE_CheckBox:
- rule.drawRule(p, opt->rect);
- ParentStyle::drawControl(ce, opt, p, w);
- return;
-
+ if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
+ rule.drawRule(p, opt->rect);
+ ParentStyle::drawControl(ce, opt, p, w);
+ return;
+ } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ QStyleOptionButton butOpt(*btn);
+ rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
+ baseStyle()->drawControl(ce, &butOpt, p, w);
+ return;
+ }
+ break;
case CE_RadioButtonLabel:
case CE_CheckBoxLabel:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp
index a264b1b..6e77409 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/gui/styles/qwindowsmobilestyle.cpp
@@ -4040,25 +4040,26 @@ enum QSliderDirection { SliderUp, SliderDown, SliderLeft, SliderRight };
void QWindowsMobileStylePrivate::tintImagesButton(QColor color)
{
- if (currentTintButton == color)
+ if (currentTintButton == color)
return;
-
- imageTabEnd = QImage(tabend_xpm);
- imageTabSelectedEnd = QImage(tabselectedend_xpm);
- imageTabSelectedBegin = QImage(tabselectedbeginn_xpm);
- imageTabMiddle = QImage(tabmiddle_xpm);
- tintImage(&imageTabEnd, color, 0.0);
- tintImage(&imageTabSelectedEnd, color, 0.0);
- tintImage(&imageTabSelectedBegin, color, 0.0);
- tintImage(&imageTabMiddle, color, 0.0);
-
- if (!doubleControls) {
- int height = imageTabMiddle.height() / 2 + 1;
- imageTabEnd = imageTabEnd.scaledToHeight(height);
- imageTabMiddle = imageTabMiddle.scaledToHeight(height);
- imageTabSelectedEnd = imageTabSelectedEnd.scaledToHeight(height);
- imageTabSelectedBegin = imageTabSelectedBegin.scaledToHeight(height);
- }
+ currentTintButton = color;
+
+ imageTabEnd = QImage(tabend_xpm);
+ imageTabSelectedEnd = QImage(tabselectedend_xpm);
+ imageTabSelectedBegin = QImage(tabselectedbeginn_xpm);
+ imageTabMiddle = QImage(tabmiddle_xpm);
+ tintImage(&imageTabEnd, color, 0.0);
+ tintImage(&imageTabSelectedEnd, color, 0.0);
+ tintImage(&imageTabSelectedBegin, color, 0.0);
+ tintImage(&imageTabMiddle, color, 0.0);
+
+ if (!doubleControls) {
+ int height = imageTabMiddle.height() / 2 + 1;
+ imageTabEnd = imageTabEnd.scaledToHeight(height);
+ imageTabMiddle = imageTabMiddle.scaledToHeight(height);
+ imageTabSelectedEnd = imageTabSelectedEnd.scaledToHeight(height);
+ imageTabSelectedBegin = imageTabSelectedBegin.scaledToHeight(height);
+ }
}
void QWindowsMobileStylePrivate::tintImagesHigh(QColor color)
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 17ade64..6b40aad 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -746,7 +746,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format)
QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph) const
{
- Glyph *g = set->glyph_data.value(glyph);
+ Glyph *g = set->getGlyph(glyph);
if (g)
return g;
@@ -858,10 +858,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
}
}
- Glyph *g = set->glyph_data.value(glyph);
+ Glyph *g = set->getGlyph(glyph);
if (g && g->format == format) {
if (uploadToServer && !g->uploadedToServer) {
- set->glyph_data[glyph] = 0;
+ set->setGlyph(glyph, 0);
delete g;
g = 0;
} else {
@@ -1158,7 +1158,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
uploadGlyphToServer(set, glyph, g, &info, glyph_buffer_size);
}
- set->glyph_data[glyph] = g;
+ set->setGlyph(glyph, g);
return g;
}
@@ -1381,8 +1381,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor
}
gs = &transformedGlyphSets[0];
- qDeleteAll(gs->glyph_data);
- gs->glyph_data.clear();
+ gs->clear();
gs->id = allocateServerGlyphSet();
@@ -1398,7 +1397,7 @@ bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, G
FT_Face face = 0;
for (int i = 0; i < num_glyphs; ++i) {
- Glyph *glyph = gs->glyph_data.value(glyphs[i]);
+ Glyph *glyph = gs->getGlyph(glyphs[i]);
if (glyph == 0 || glyph->format != format) {
if (!face) {
face = lockFace();
@@ -1635,7 +1634,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlag
FT_Face face = 0;
if (flags & QTextEngine::DesignMetrics) {
for (int i = 0; i < glyphs->numGlyphs; i++) {
- Glyph *g = defaultGlyphSet.glyph_data.value(glyphs->glyphs[i]);
+ Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]);
if (g) {
glyphs->advances_x[i] = QFixed::fromFixed(g->linearAdvance);
} else {
@@ -1648,7 +1647,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlag
}
} else {
for (int i = 0; i < glyphs->numGlyphs; i++) {
- Glyph *g = defaultGlyphSet.glyph_data.value(glyphs->glyphs[i]);
+ Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]);
if (g) {
glyphs->advances_x[i] = QFixed(g->advance);
} else {
@@ -1677,7 +1676,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs)
QFixed ymax = 0;
QFixed xmax = 0;
for (int i = 0; i < glyphs.numGlyphs; i++) {
- Glyph *g = defaultGlyphSet.glyph_data.value(glyphs.glyphs[i]);
+ Glyph *g = defaultGlyphSet.getGlyph(glyphs.glyphs[i]);
if (!g) {
if (!face)
face = lockFace();
@@ -1719,7 +1718,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph)
{
FT_Face face = 0;
glyph_metrics_t overall;
- Glyph *g = defaultGlyphSet.glyph_data.value(glyph);
+ Glyph *g = defaultGlyphSet.getGlyph(glyph);
if (!g) {
face = lockFace();
g = loadGlyph(glyph, Format_None, true);
@@ -1783,8 +1782,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matr
transformedGlyphSets.prepend(QGlyphSet());
}
glyphSet = &transformedGlyphSets[0];
- qDeleteAll(glyphSet->glyph_data);
- glyphSet->glyph_data.clear();
+ glyphSet->clear();
glyphSet->id = allocateServerGlyphSet();
glyphSet->transformationMatrix = m;
}
@@ -1792,7 +1790,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matr
} else {
glyphSet = &defaultGlyphSet;
}
- Glyph * g = glyphSet->glyph_data.value(glyph);
+ Glyph * g = glyphSet->getGlyph(glyph);
if (!g) {
face = lockFace();
g = loadGlyphMetrics(glyphSet, glyph);
@@ -1881,7 +1879,7 @@ QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, int margin, const QTransfor
void QFontEngineFT::removeGlyphFromCache(glyph_t glyph)
{
- delete defaultGlyphSet.glyph_data.take(glyph);
+ defaultGlyphSet.removeGlyphFromCache(glyph);
}
int QFontEngineFT::glyphCount() const
@@ -1937,11 +1935,53 @@ QFontEngineFT::QGlyphSet::QGlyphSet()
transformationMatrix.yy = 0x10000;
transformationMatrix.xy = 0;
transformationMatrix.yx = 0;
+ memset(fast_glyph_data, 0, sizeof(fast_glyph_data));
+ fast_glyph_count = 0;
}
QFontEngineFT::QGlyphSet::~QGlyphSet()
{
+ clear();
+}
+
+void QFontEngineFT::QGlyphSet::clear()
+{
+ if (fast_glyph_count > 0) {
+ for (int i = 0; i < 256; ++i) {
+ if (fast_glyph_data[i]) {
+ delete fast_glyph_data[i];
+ fast_glyph_data[i] = 0;
+ }
+ }
+ fast_glyph_count = 0;
+ }
qDeleteAll(glyph_data);
+ glyph_data.clear();
+}
+
+void QFontEngineFT::QGlyphSet::removeGlyphFromCache(int index)
+{
+ if (index < 256) {
+ if (fast_glyph_data[index]) {
+ delete fast_glyph_data[index];
+ fast_glyph_data[index] = 0;
+ if (fast_glyph_count > 0)
+ --fast_glyph_count;
+ }
+ } else {
+ delete glyph_data.take(index);
+ }
+}
+
+void QFontEngineFT::QGlyphSet::setGlyph(int index, Glyph *glyph)
+{
+ if (index < 256) {
+ if (!fast_glyph_data[index])
+ ++fast_glyph_count;
+ fast_glyph_data[index] = glyph;
+ } else {
+ glyph_data.insert(index, glyph);
+ }
}
unsigned long QFontEngineFT::allocateServerGlyphSet()
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 98dd002..12b7da8 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -180,7 +180,21 @@ public:
FT_Matrix transformationMatrix;
unsigned long id; // server sided id, GlyphSet for X11
bool outline_drawing;
+
+ void removeGlyphFromCache(int index);
+ void clear();
+ inline Glyph *getGlyph(int index) const
+ {
+ if (index < 256)
+ return fast_glyph_data[index];
+ return glyph_data.value(index);
+ }
+ void setGlyph(int index, Glyph *glyph);
+
+private:
mutable QHash<int, Glyph *> glyph_data; // maps from glyph index to glyph data
+ mutable Glyph *fast_glyph_data[256]; // for fast lookup of glyphs < 256
+ mutable int fast_glyph_count;
};
virtual QFontEngine::FaceId faceId() const;
@@ -252,7 +266,7 @@ public:
QGlyphSet *defaultGlyphs() { return &defaultGlyphSet; }
GlyphFormat defaultGlyphFormat() const { return defaultFormat; }
- inline Glyph *cachedGlyph(glyph_t g) const { return defaultGlyphSet.glyph_data.value(g); }
+ inline Glyph *cachedGlyph(glyph_t g) const { return defaultGlyphSet.getGlyph(g); }
QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix);
bool loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, GlyphFormat format = Format_Render);
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 8fe4c47..1fabf12 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -282,8 +282,10 @@ QString QStaticText::text() const
}
/*!
- Sets the performance hint of the QStaticText. This hint can be used to customize how much
- caching is done internally to improve performance.
+ Sets the performance hint of the QStaticText according to the \a
+ performanceHint provided. The \a performanceHint is used to
+ customize how much caching is done internally to improve
+ performance.
The default is QStaticText::ModerateCaching.
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index 6750c09..e594b7e 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -59,23 +59,24 @@ class QSyntaxHighlighterPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QSyntaxHighlighter)
public:
- inline QSyntaxHighlighterPrivate() : rehighlightPending(false) {}
+ inline QSyntaxHighlighterPrivate()
+ : rehighlightPending(false), inReformatBlocks(false)
+ {}
QPointer<QTextDocument> doc;
void _q_reformatBlocks(int from, int charsRemoved, int charsAdded);
- void reformatBlock(QTextBlock block);
-
+ void reformatBlocks(int from, int charsRemoved, int charsAdded);
+ void reformatBlock(const QTextBlock &block);
+
inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) {
- QObject::disconnect(doc, SIGNAL(contentsChange(int,int,int)),
- q_func(), SLOT(_q_reformatBlocks(int,int,int)));
+ inReformatBlocks = true;
cursor.beginEditBlock();
int from = cursor.position();
cursor.movePosition(operation);
- _q_reformatBlocks(from, 0, cursor.position() - from);
+ reformatBlocks(from, 0, cursor.position() - from);
cursor.endEditBlock();
- QObject::connect(doc, SIGNAL(contentsChange(int,int,int)),
- q_func(), SLOT(_q_reformatBlocks(int,int,int)));
+ inReformatBlocks = false;
}
inline void _q_delayedRehighlight() {
@@ -83,17 +84,19 @@ public:
return;
rehighlightPending = false;
q_func()->rehighlight();
- return;
}
void applyFormatChanges();
QVector<QTextCharFormat> formatChanges;
QTextBlock currentBlock;
bool rehighlightPending;
+ bool inReformatBlocks;
};
void QSyntaxHighlighterPrivate::applyFormatChanges()
{
+ bool formatsChanged = false;
+
QTextLayout *layout = currentBlock.layout();
QList<QTextLayout::FormatRange> ranges = layout->additionalFormats();
@@ -101,19 +104,26 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
const int preeditAreaStart = layout->preeditAreaPosition();
const int preeditAreaLength = layout->preeditAreaText().length();
- QList<QTextLayout::FormatRange>::Iterator it = ranges.begin();
- while (it != ranges.end()) {
- if (it->start >= preeditAreaStart
- && it->start + it->length <= preeditAreaStart + preeditAreaLength)
- ++it;
- else
- it = ranges.erase(it);
+ if (preeditAreaLength != 0) {
+ QList<QTextLayout::FormatRange>::Iterator it = ranges.begin();
+ while (it != ranges.end()) {
+ if (it->start >= preeditAreaStart
+ && it->start + it->length <= preeditAreaStart + preeditAreaLength) {
+ ++it;
+ } else {
+ it = ranges.erase(it);
+ formatsChanged = true;
+ }
+ }
+ } else if (!ranges.isEmpty()) {
+ ranges.clear();
+ formatsChanged = true;
}
QTextCharFormat emptyFormat;
QTextLayout::FormatRange r;
- r.start = r.length = -1;
+ r.start = -1;
int i = 0;
while (i < formatChanges.count()) {
@@ -135,34 +145,46 @@ void QSyntaxHighlighterPrivate::applyFormatChanges()
r.length = i - r.start;
- if (r.start >= preeditAreaStart) {
- r.start += preeditAreaLength;
- } else if (r.start + r.length >= preeditAreaStart) {
- r.length += preeditAreaLength;
+ if (preeditAreaLength != 0) {
+ if (r.start >= preeditAreaStart)
+ r.start += preeditAreaLength;
+ else if (r.start + r.length >= preeditAreaStart)
+ r.length += preeditAreaLength;
}
ranges << r;
- r.start = r.length = -1;
+ formatsChanged = true;
+ r.start = -1;
}
if (r.start != -1) {
r.length = formatChanges.count() - r.start;
- if (r.start >= preeditAreaStart) {
- r.start += preeditAreaLength;
- } else if (r.start + r.length >= preeditAreaStart) {
- r.length += preeditAreaLength;
+ if (preeditAreaLength != 0) {
+ if (r.start >= preeditAreaStart)
+ r.start += preeditAreaLength;
+ else if (r.start + r.length >= preeditAreaStart)
+ r.length += preeditAreaLength;
}
ranges << r;
+ formatsChanged = true;
}
- layout->setAdditionalFormats(ranges);
+ if (formatsChanged) {
+ layout->setAdditionalFormats(ranges);
+ doc->markContentsDirty(currentBlock.position(), currentBlock.length());
+ }
}
void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, int charsAdded)
{
- Q_UNUSED(charsRemoved);
+ if (!inReformatBlocks)
+ reformatBlocks(from, charsRemoved, charsAdded);
+}
+
+void QSyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int charsAdded)
+{
rehighlightPending = false;
QTextBlock block = doc->findBlock(from);
@@ -191,21 +213,18 @@ void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, in
formatChanges.clear();
}
-void QSyntaxHighlighterPrivate::reformatBlock(QTextBlock block)
+void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block)
{
Q_Q(QSyntaxHighlighter);
Q_ASSERT_X(!currentBlock.isValid(), "QSyntaxHighlighter::reformatBlock()", "reFormatBlock() called recursively");
currentBlock = block;
- QTextBlock previous = block.previous();
formatChanges.fill(QTextCharFormat(), block.length() - 1);
q->highlightBlock(block.text());
applyFormatChanges();
- doc->markContentsDirty(block.position(), block.length());
-
currentBlock = QTextBlock();
}
@@ -349,8 +368,8 @@ void QSyntaxHighlighter::setDocument(QTextDocument *doc)
if (d->doc) {
connect(d->doc, SIGNAL(contentsChange(int,int,int)),
this, SLOT(_q_reformatBlocks(int,int,int)));
- QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight()));
d->rehighlightPending = true;
+ QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight()));
}
}
@@ -391,11 +410,16 @@ void QSyntaxHighlighter::rehighlight()
void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block)
{
Q_D(QSyntaxHighlighter);
- if (!d->doc)
+ if (!d->doc || !block.isValid() || block.document() != d->doc)
return;
+ const bool rehighlightPending = d->rehighlightPending;
+
QTextCursor cursor(block);
d->rehighlight(cursor, QTextCursor::EndOfBlock);
+
+ if (rehighlightPending)
+ d->rehighlightPending = rehighlightPending;
}
/*!
@@ -460,7 +484,6 @@ void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block)
void QSyntaxHighlighter::setFormat(int start, int count, const QTextCharFormat &format)
{
Q_D(QSyntaxHighlighter);
-
if (start < 0 || start >= d->formatChanges.count())
return;
@@ -628,7 +651,7 @@ QTextBlockUserData *QSyntaxHighlighter::currentBlockUserData() const
\since 4.4
Returns the current text block.
- */
+*/
QTextBlock QSyntaxHighlighter::currentBlock() const
{
Q_D(const QSyntaxHighlighter);
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 02eae98..b826588 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -81,7 +81,7 @@ public:
void generate(int start, int length, QFont::Capitalization caps)
{
if ((int)caps == (int)QFont::SmallCaps)
- generateScriptItemsSmallCaps(m_string.utf16(), start, length);
+ generateScriptItemsSmallCaps(reinterpret_cast<const ushort *>(m_string.unicode()), start, length);
else if(caps == QFont::Capitalize)
generateScriptItemsCapitalize(start, length);
else if(caps != QFont::MixedCase) {
@@ -1434,9 +1434,7 @@ void QTextEngine::itemize() const
layoutData->hasBidi = bidiItemize(const_cast<QTextEngine *>(this), analysis, control);
}
- const ushort *unicode = layoutData->string.utf16();
- // correctly assign script, isTab and isObject to the script analysis
- const ushort *uc = unicode;
+ const ushort *uc = reinterpret_cast<const ushort *>(layoutData->string.unicode());
const ushort *e = uc + length;
int lastScript = QUnicodeTables::Common;
while (uc < e) {
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index f36cbd2..5054b66 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -382,6 +382,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine
QFixed y;
QFixed width;
QFixed textWidth;
+ QFixed textAdvance;
int from;
signed int length : 29;
mutable uint justified : 1;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index af91603..cc6793d 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1875,6 +1875,7 @@ void QTextLine::layout_helper(int maxGlyphs)
line.textWidth += lbh.softHyphenWidth;
}
+ line.textAdvance = line.textWidth;
line.textWidth += lbh.rightBearing;
goto found;
@@ -1885,6 +1886,7 @@ void QTextLine::layout_helper(int maxGlyphs)
}
LB_DEBUG("reached end of line");
lbh.checkFullOtherwiseExtend(line);
+ line.textAdvance = line.textWidth;
line.textWidth += lbh.rightBearing;
found:
diff --git a/src/gui/util/qsystemtrayicon_mac.mm b/src/gui/util/qsystemtrayicon_mac.mm
index 348657e..d943c8c 100644
--- a/src/gui/util/qsystemtrayicon_mac.mm
+++ b/src/gui/util/qsystemtrayicon_mac.mm
@@ -529,7 +529,11 @@ private:
[item setToolTip:(NSString*)QCFString::toCFStringRef(action->toolTip())];
const QIcon icon = action->icon();
if(!icon.isNull()) {
+#ifndef QT_MAC_USE_COCOA
+ const short scale = GetMBarHeight();
+#else
const short scale = [[NSApp mainMenu] menuBarHeight];
+#endif
NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(icon.pixmap(QSize(scale, scale))));
[item setImage: nsimage];
[nsimage release];
diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp
index 4a6235c..7e2f20d 100644
--- a/src/gui/widgets/qabstractspinbox.cpp
+++ b/src/gui/widgets/qabstractspinbox.cpp
@@ -1248,8 +1248,11 @@ void QAbstractSpinBox::contextMenuEvent(QContextMenuEvent *event)
#else
Q_D(QAbstractSpinBox);
- d->reset();
QPointer<QMenu> menu = d->edit->createStandardContextMenu();
+ if (!menu)
+ return;
+
+ d->reset();
QAction *selAll = new QAction(tr("&Select All"), menu);
menu->insertAction(d->edit->d_func()->selectAllAction,
diff --git a/src/gui/widgets/qlabel_p.h b/src/gui/widgets/qlabel_p.h
index 21eb128..fba7224 100644
--- a/src/gui/widgets/qlabel_p.h
+++ b/src/gui/widgets/qlabel_p.h
@@ -55,7 +55,7 @@
#include "qlabel.h"
-#include "../text/qtextdocumentlayout_p.h"
+#include "private/qtextdocumentlayout_p.h"
#include "private/qtextcontrol_p.h"
#include "qtextdocumentfragment.h"
#include "qframe_p.h"
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index db099e8..9ec0feb 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
Updates the display text based of the current edit text
If the text has changed will emit displayTextChanged()
*/
-void QLineControl::updateDisplayText()
+void QLineControl::updateDisplayText(bool forceUpdate)
{
QString orig = m_textLayout.text();
QString str;
@@ -102,7 +102,7 @@ void QLineControl::updateDisplayText()
m_textLayout.endLayout();
m_ascent = qRound(l.ascent());
- if (str != orig)
+ if (str != orig || forceUpdate)
emit displayTextChanged(str);
}
@@ -476,7 +476,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
}
}
m_textLayout.setAdditionalFormats(formats);
- updateDisplayText();
+ updateDisplayText(/*force*/ true);
if (cursorPositionChanged)
emitCursorPositionChanged();
if (isGettingInput)
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index d6f2705..3f1bc2c 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -239,7 +239,7 @@ private:
void init(const QString &txt);
void removeSelectedText();
void internalSetText(const QString &txt, int pos = -1, bool edited = true);
- void updateDisplayText();
+ void updateDisplayText(bool forceUpdate = false);
void internalInsert(const QString &s);
void internalDelete(bool wasBackspace = false);
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 0ba8b9f..817547c 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -383,8 +383,6 @@ void QLineEdit::setText(const QString& text)
d->control->setText(text);
}
-// ### Qt 4.7: remove this #if guard
-#if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)
/*!
\since 4.7
@@ -414,7 +412,6 @@ void QLineEdit::setPlaceholderText(const QString& placeholderText)
update();
}
}
-#endif
/*!
\property QLineEdit::displayText
@@ -542,11 +539,16 @@ void QLineEdit::setEchoMode(EchoMode mode)
if (mode == (EchoMode)d->control->echoMode())
return;
Qt::InputMethodHints imHints = inputMethodHints();
- if (mode == Password) {
+ if (mode == Password || mode == NoEcho) {
imHints |= Qt::ImhHiddenText;
} else {
imHints &= ~Qt::ImhHiddenText;
}
+ if (mode != Normal) {
+ imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ } else {
+ imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ }
setInputMethodHints(imHints);
d->control->setEchoMode(mode);
update();
@@ -2038,9 +2040,10 @@ void QLineEdit::dropEvent(QDropEvent* e)
*/
void QLineEdit::contextMenuEvent(QContextMenuEvent *event)
{
- QMenu *menu = createStandardContextMenu();
- menu->setAttribute(Qt::WA_DeleteOnClose);
- menu->popup(event->globalPos());
+ if (QMenu *menu = createStandardContextMenu()) {
+ menu->setAttribute(Qt::WA_DeleteOnClose);
+ menu->popup(event->globalPos());
+ }
}
#if defined(Q_WS_WIN)
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
index fa04bfc..94e0dbe 100644
--- a/src/gui/widgets/qlineedit.h
+++ b/src/gui/widgets/qlineedit.h
@@ -83,10 +83,7 @@ class Q_GUI_EXPORT QLineEdit : public QWidget
Q_PROPERTY(bool undoAvailable READ isUndoAvailable)
Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
-// ### Qt 4.7: remove this #if guard
-#if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
-#endif
public:
explicit QLineEdit(QWidget* parent=0);
@@ -102,11 +99,8 @@ public:
QString displayText() const;
-// ### Qt 4.7: remove this #if guard
-#if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5)
QString placeholderText() const;
void setPlaceholderText(const QString &);
-#endif
int maxLength() const;
void setMaxLength(int);
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 4620597..bf926f8 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -119,6 +119,7 @@ void QMainWindowPrivate::init()
q->setAttribute(Qt::WA_Hover);
#ifdef QT_SOFTKEYS_ENABLED
menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, q);
+ menuBarAction->setVisible(false);
#endif
}
@@ -1478,7 +1479,8 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
return;
// ### Disable the unified toolbar when using anything but the native graphics system.
- if (windowSurface())
+ // ### Disable when using alien widgets as well
+ if (windowSurface() || testAttribute(Qt::WA_NativeWindow) == false)
return;
d->useHIToolBar = set;
diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm
index d92168a..9527057 100644
--- a/src/gui/widgets/qmainwindowlayout_mac.mm
+++ b/src/gui/widgets/qmainwindowlayout_mac.mm
@@ -463,6 +463,8 @@ void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar)
NSToolbarItem *item = static_cast<NSToolbarItem *>(it.key());
[[qt_mac_window_for(layoutState.mainWindow->window()) toolbar]
removeItemAtIndex:toolbarItemsCopy.indexOf(item)];
+ unifiedToolbarHash.remove(item);
+ qtoolbarsInUnifiedToolbarList.removeAll(toolbar);
#endif
break;
}
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 9a4916e..ebc05d9 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -260,9 +260,6 @@ void QMenuPrivate::updateActionRects() const
icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q);
const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);
const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
-
- const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
- const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
//for compatability now - will have to refactor this away..
@@ -336,7 +333,7 @@ void QMenuPrivate::updateActionRects() const
if (!sz.isEmpty()) {
- max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width()));
+ max_column_width = qMax(max_column_width, sz.width());
//wrapping
if (!scroll &&
y+sz.height()+vmargin > dh - (deskFw * 2)) {
@@ -350,6 +347,10 @@ void QMenuPrivate::updateActionRects() const
}
max_column_width += tabWidth; //finally add in the tab width
+ const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
+ const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
+ max_column_width = qMax(min_column_width, max_column_width);
+
//calculate position
const int base_y = vmargin + fw + topmargin +
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index 99c550f..43722a1 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -924,14 +924,27 @@ static QString qt_mac_menu_merge_text(QMacMenuAction *action)
else if (action->command == kHICommandQuit)
ret = QMenuBar::tr("Quit %1").arg(qAppName());
#else
- else if (action->menuItem == [loader aboutMenuItem])
- ret = QMenuBar::tr("About %1").arg(qAppName());
- else if (action->menuItem == [loader aboutQtMenuItem])
- ret = QMenuBar::tr("About Qt");
- else if (action->menuItem == [loader preferencesMenuItem])
- ret = QMenuBar::tr("Preferences");
- else if (action->menuItem == [loader quitMenuItem])
- ret = QMenuBar::tr("Quit %1").arg(qAppName());
+ else if (action->menuItem == [loader aboutMenuItem]) {
+ if (action->action->text() == QString("About %1").arg(qAppName()))
+ ret = QMenuBar::tr("About %1").arg(qAppName());
+ else
+ ret = action->action->text();
+ } else if (action->menuItem == [loader aboutQtMenuItem]) {
+ if (action->action->text() == QString("About Qt"))
+ ret = QMenuBar::tr("About Qt");
+ else
+ ret = action->action->text();
+ } else if (action->menuItem == [loader preferencesMenuItem]) {
+ if (action->action->text() == QString("Preferences"))
+ ret = QMenuBar::tr("Preferences");
+ else
+ ret = action->action->text();
+ } else if (action->menuItem == [loader quitMenuItem]) {
+ if (action->action->text() == QString("Quit %1").arg(qAppName()))
+ ret = QMenuBar::tr("About %1").arg(qAppName());
+ else
+ ret = action->action->text();
+ }
#endif
return ret;
}
@@ -1922,7 +1935,7 @@ static bool qt_mac_should_disable_menu(QMenuBar *menuBar)
if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) {
for (int i=0; i<topLevelWidgets.size(); ++i) {
QWidget *top = topLevelWidgets.at(i);
- if (w != top && [qt_mac_window_for(top) isVisible]) {
+ if (w != top && top->isVisible()) {
// INVARIANT: we found another visible window
// on screen other than our modalWidget. We therefore
// disable the menu bar to follow normal modality logic:
@@ -2180,3 +2193,4 @@ static OSMenuRef qt_mac_create_menu(QWidget *w)
QT_END_NAMESPACE
+
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index eae97a6..e46688c 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -256,6 +256,14 @@ void qt_symbian_show_submenu( CEikMenuPane* menuPane, int id)
{
SymbianMenuItem* menu = qt_symbian_find_menu(id, symbianMenus);
if (menu) {
+ // Normally first AddMenuItemL call for menuPane will create the item array.
+ // However if we don't have any items, we still need the item array. Otherwise
+ // menupane will crash. That's why we create item array here manually, and
+ // AddMenuItemL will then use the existing array.
+ CEikMenuPane::CItemArray* itemArray = q_check_ptr(new CEikMenuPane::CItemArray);
+ menuPane->SetItemArray(itemArray);
+ menuPane->SetItemArrayOwnedExternally(EFalse);
+
for (int i = 0; i < menu->children.count(); ++i)
QT_TRAP_THROWING(menuPane->AddMenuItemL(menu->children.at(i)->menuItemData));
}
diff --git a/src/gui/widgets/qscrollbar.cpp b/src/gui/widgets/qscrollbar.cpp
index 4eff260..c0eeb2f 100644
--- a/src/gui/widgets/qscrollbar.cpp
+++ b/src/gui/widgets/qscrollbar.cpp
@@ -523,6 +523,7 @@ bool QScrollBar::event(QEvent *event)
break;
#ifndef QT_NO_WHEELEVENT
case QEvent::Wheel: {
+ event->ignore();
// override wheel event without adding virtual function override
QWheelEvent *ev = static_cast<QWheelEvent *>(event);
int delta = ev->delta();