summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-06-10 10:00:34 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-06-10 10:00:34 +0200
commit0eff16611f65c1459ab73bde1ad2175614dd84eb (patch)
tree3eec6162b3f9fd283c1fb675c7d437baf6c37565 /src
parent9095210c0b57f75fe2fecf7289fabbdfdf64e198 (diff)
parentebea15cb33da8063a630867e38eacf7857b0b936 (diff)
Merge remote-tracking branch 'origin/release' into stable
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qguiapplication.cpp4
-rw-r--r--src/gui/text/qfontengine_ft.cpp18
-rw-r--r--src/gui/text/qfontengine_ft_p.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.h5
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm13
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm68
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp3
-rw-r--r--src/tools/qdoc/htmlgenerator.cpp6
-rw-r--r--src/widgets/dialogs/qdialog.cpp11
10 files changed, 95 insertions, 36 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 2a1d7e3bcc..29a7e87d46 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -2251,8 +2251,8 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E
if (!p->receivedExpose) {
if (p->resizeEventPending) {
// as a convenience for plugins, send a resize event before the first expose event if they haven't done so
- QSize size = p->geometry.size();
- QResizeEvent e(size, size);
+ // window->geometry() should have a valid size as soon as a handle exists.
+ QResizeEvent e(window->geometry().size(), p->geometry.size());
QGuiApplication::sendSpontaneousEvent(window, &e);
p->resizeEventPending = false;
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 10225febcb..4545645dc6 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1316,6 +1316,12 @@ void QFontEngineFT::doKerning(QGlyphLayout *g, QFontEngine::ShaperFlags flags) c
unlockFace();
}
}
+
+ if (shouldUseDesignMetrics(flags) && !(fontDef.styleStrategy & QFont::ForceIntegerMetrics))
+ flags |= DesignMetrics;
+ else
+ flags &= ~DesignMetrics;
+
QFontEngine::doKerning(g, flags);
}
@@ -1571,12 +1577,18 @@ bool QFontEngineFT::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs
return true;
}
+bool QFontEngineFT::shouldUseDesignMetrics(QFontEngine::ShaperFlags flags) const
+{
+ if (!FT_IS_SCALABLE(freetype->face))
+ return false;
+
+ return default_hint_style == HintNone || default_hint_style == HintLight || (flags & DesignMetrics);
+}
+
void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
{
FT_Face face = 0;
- bool design = (default_hint_style == HintNone ||
- default_hint_style == HintLight ||
- (flags & DesignMetrics)) && FT_IS_SCALABLE(freetype->face);
+ bool design = shouldUseDesignMetrics(flags);
for (int i = 0; i < glyphs->numGlyphs; i++) {
Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs->glyphs[i]) : 0;
// Since we are passing Format_None to loadGlyph, use same default format logic as loadGlyph
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 434eb76c33..e09fa6f94f 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -325,6 +325,7 @@ private:
friend class QFontEngineMultiFontConfig;
int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const;
+ bool shouldUseDesignMetrics(ShaperFlags flags) const;
GlyphFormat defaultFormat;
FT_Matrix matrix;
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h
index 9100b9b15f..7224ee2ff8 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.h
+++ b/src/plugins/platforms/cocoa/qcocoamenu.h
@@ -49,6 +49,8 @@
QT_BEGIN_NAMESPACE
+class QCocoaMenuBar;
+
class QCocoaMenu : public QPlatformMenu
{
public:
@@ -87,6 +89,8 @@ public:
QList<QCocoaMenuItem *> items() const;
QList<QCocoaMenuItem *> merged() const;
+ void setMenuBar(QCocoaMenuBar *menuBar);
+ QCocoaMenuBar *menuBar() const;
private:
QCocoaMenuItem *itemOrNull(int index) const;
void insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem);
@@ -97,6 +101,7 @@ private:
NSObject *m_delegate;
bool m_enabled;
quintptr m_tag;
+ QCocoaMenuBar *m_menuBar;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 25ece7349c..d4cf83a380 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -215,7 +215,8 @@ QT_BEGIN_NAMESPACE
QCocoaMenu::QCocoaMenu() :
m_enabled(true),
- m_tag(0)
+ m_tag(0),
+ m_menuBar(0)
{
m_delegate = [[QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) alloc] initWithMenu:this];
m_nativeItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
@@ -534,4 +535,14 @@ void QCocoaMenu::syncModalState(bool modal)
}
}
+void QCocoaMenu::setMenuBar(QCocoaMenuBar *menuBar)
+{
+ m_menuBar = menuBar;
+}
+
+QCocoaMenuBar *QCocoaMenu::menuBar() const
+{
+ return m_menuBar;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.h b/src/plugins/platforms/cocoa/qcocoamenubar.h
index 8086676cc5..7a1bda74a4 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.h
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.h
@@ -75,6 +75,8 @@ private:
static QCocoaMenuBar *findGlobalMenubar();
bool shouldDisable(QCocoaWindow *active) const;
+ void insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu);
+ void removeNativeMenu(QCocoaMenu *menu);
QList<QCocoaMenu*> m_menus;
NSMenu *m_nativeMenu;
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index e280cf4581..73331db40d 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -83,9 +83,24 @@ QCocoaMenuBar::~QCocoaMenuBar()
}
}
-void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *before)
+void QCocoaMenuBar::insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu)
{
QCocoaAutoReleasePool pool;
+
+ if (beforeMenu) {
+ NSUInteger nativeIndex = [m_nativeMenu indexOfItem:beforeMenu->nsMenuItem()];
+ [m_nativeMenu insertItem: menu->nsMenuItem() atIndex: nativeIndex];
+ } else {
+ [m_nativeMenu addItem: menu->nsMenuItem()];
+ }
+
+ menu->setMenuBar(this);
+ syncMenu(static_cast<QPlatformMenu *>(menu));
+ [m_nativeMenu setSubmenu: menu->nsMenu() forItem: menu->nsMenuItem()];
+}
+
+void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *before)
+{
QCocoaMenu *menu = static_cast<QCocoaMenu *>(platformMenu);
QCocoaMenu *beforeMenu = static_cast<QCocoaMenu *>(before);
#ifdef QT_COCOA_ENABLE_MENU_DEBUG
@@ -96,39 +111,36 @@ void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *befor
qWarning() << Q_FUNC_INFO << "This menu already belongs to the menubar, remove it first";
return;
}
- if (beforeMenu) {
- if (!m_menus.contains(beforeMenu)) {
- qWarning() << Q_FUNC_INFO << "The before menu does not belong to the menubar";
- return;
- }
- m_menus.insert(m_menus.indexOf(beforeMenu), menu);
- NSUInteger nativeIndex = [m_nativeMenu indexOfItem:beforeMenu->nsMenuItem()];
- [m_nativeMenu insertItem: menu->nsMenuItem() atIndex: nativeIndex];
- } else {
- m_menus.append(menu);
- [m_nativeMenu addItem: menu->nsMenuItem()];
+
+ if (beforeMenu && !m_menus.contains(beforeMenu)) {
+ qWarning() << Q_FUNC_INFO << "The before menu does not belong to the menubar";
+ return;
}
- platformMenu->setParent(this);
- syncMenu(platformMenu);
- [m_nativeMenu setSubmenu: menu->nsMenu() forItem: menu->nsMenuItem()];
+ m_menus.insert(beforeMenu ? m_menus.indexOf(beforeMenu) : m_menus.size(), menu);
+ if (!menu->menuBar())
+ insertNativeMenu(menu, beforeMenu);
}
-void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu)
+void QCocoaMenuBar::removeNativeMenu(QCocoaMenu *menu)
{
QCocoaAutoReleasePool pool;
+ if (menu->menuBar() == this)
+ menu->setMenuBar(0);
+ NSUInteger realIndex = [m_nativeMenu indexOfItem:menu->nsMenuItem()];
+ [m_nativeMenu removeItemAtIndex: realIndex];
+}
+
+void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu)
+{
QCocoaMenu *menu = static_cast<QCocoaMenu *>(platformMenu);
if (!m_menus.contains(menu)) {
qWarning() << Q_FUNC_INFO << "Trying to remove a menu that does not belong to the menubar";
return;
}
m_menus.removeOne(menu);
-
- if (platformMenu->parent() == this)
- platformMenu->setParent(0);
- NSUInteger realIndex = [m_nativeMenu indexOfItem:menu->nsMenuItem()];
- [m_nativeMenu removeItemAtIndex: realIndex];
+ removeNativeMenu(menu);
}
void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
@@ -207,6 +219,20 @@ void QCocoaMenuBar::updateMenuBarImmediately()
m->syncModalState(disableForModal);
}
+ // reparent shared menu items if necessary.
+ // We browse the list in reverse order to be sure that the next items are redrawn before the current ones,
+ // in this way we are sure that "beforeMenu" (see below) is part of the native menu before "m" is redraw
+ for (int i = mb->m_menus.size() - 1; i >= 0; i--) {
+ QCocoaMenu *m = mb->m_menus.at(i);
+ QCocoaMenuBar *menuBar = m->menuBar();
+ if (menuBar != mb) {
+ QCocoaMenu *beforeMenu = i < (mb->m_menus.size() - 1) ? mb->m_menus.at(i + 1) : 0;
+ if (menuBar)
+ menuBar->removeNativeMenu(m);
+ mb->insertNativeMenu(m, beforeMenu);
+ }
+ }
+
QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
[loader ensureAppMenuInMenu:mb->nsMenu()];
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 814892b43a..fc2ba454df 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -433,6 +433,9 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
return 0;
if (requested.flags != obtained.flags)
window->setFlags(obtained.flags);
+ // Trigger geometry change signals of QWindow.
+ if ((obtained.flags & Qt::Desktop) != Qt::Desktop && requested.geometry != obtained.geometry)
+ QWindowSystemInterface::handleGeometryChange(window, obtained.geometry);
return new QWindowsWindow(window, obtained);
}
diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp
index 7e1467f300..3d6f04decf 100644
--- a/src/tools/qdoc/htmlgenerator.cpp
+++ b/src/tools/qdoc/htmlgenerator.cpp
@@ -1755,12 +1755,12 @@ void HtmlGenerator::generateHeader(const QString& title,
if (shortVersion.count(QChar('.')) == 2)
shortVersion.truncate(shortVersion.lastIndexOf(QChar('.')));
if (!project.isEmpty())
- shortVersion = project + QLatin1Char(' ') + shortVersion + QLatin1String(": ");
+ shortVersion = QLatin1String(" | ") + project + QLatin1Char(' ') + shortVersion;
else
- shortVersion = QLatin1String("Qt ") + shortVersion + QLatin1String(": ");
+ shortVersion = QLatin1String(" | ") + QLatin1String("Qt ") + shortVersion ;
// Generating page title
- out() << " <title>" << shortVersion << protectEnc(title) << "</title>\n";
+ out() << " <title>" << protectEnc(title) << shortVersion << "</title>\n";
// Include style sheet and script links.
out() << headerStyles;
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index a76c88dc5e..2cda99a269 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -150,12 +150,11 @@ void QDialogPrivate::deletePlatformHelper()
provide a \l{#return}{return value}, and they can have \l{#default}{default buttons}. QDialogs can also have a QSizeGrip in their
lower-right corner, using setSizeGripEnabled().
- Note that QDialog (an any other widget that has type Qt::Dialog) uses
- the parent widget slightly differently from other classes in Qt. A
- dialog is always a top-level widget, but if it has a parent, its
- default location is centered on top of the parent's top-level widget
- (if it is not top-level itself). It will also share the parent's
- taskbar entry.
+ Note that QDialog (and any other widget that has type \c Qt::Dialog) uses
+ the parent widget slightly differently from other classes in Qt. A dialog is
+ always a top-level widget, but if it has a parent, its default location is
+ centered on top of the parent's top-level widget (if it is not top-level
+ itself). It will also share the parent's taskbar entry.
Use the overload of the QWidget::setParent() function to change
the ownership of a QDialog widget. This function allows you to