Help: Remove unnecessary class

By using connect to a function directly.

Change-Id: Iab06810203720f26eba908293438a6d12631ea15
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Eike Ziller
2017-07-12 11:44:57 +02:00
parent 5299b81a4d
commit 4388b5b6cd
2 changed files with 20 additions and 40 deletions

View File

@@ -40,17 +40,6 @@ namespace Internal {
class MacWebKitHelpViewer;
class MacWebKitHelpWidgetPrivate;
class MacResponderHack : public QObject
{
Q_OBJECT
public:
MacResponderHack(QObject *parent);
private:
void responderHack(QWidget *old, QWidget *now);
};
class MacWebKitHelpWidget : public QMacCocoaViewContainer
{
Q_OBJECT

View File

@@ -530,6 +530,25 @@ void MacWebKitHelpWidget::showToolTip()
// #pragma mark -- MacWebKitHelpViewer
static void responderHack(QWidget *old, QWidget *now)
{
// On focus change, Qt does not make the corresponding QNSView firstResponder.
// That breaks when embedding native NSView into a Qt hierarchy. When the focus is changed
// by clicking with the mouse into a widget, everything is fine, because Cocoa automatically
// adapts firstResponder in that case, but it breaks when setting the Qt focus from code.
Q_UNUSED(old)
if (!now)
return;
@autoreleasepool {
NSView *view;
if (QMacCocoaViewContainer *viewContainer = qobject_cast<QMacCocoaViewContainer *>(now))
view = viewContainer->cocoaView();
else
view = reinterpret_cast<NSView *>(now->effectiveWinId());
[view.window makeFirstResponder:view];
}
}
MacWebKitHelpViewer::MacWebKitHelpViewer(QWidget *parent)
: HelpViewer(parent),
m_widget(new MacWebKitHelpWidget(this))
@@ -537,7 +556,7 @@ MacWebKitHelpViewer::MacWebKitHelpViewer(QWidget *parent)
static bool responderHackInstalled = false;
if (!responderHackInstalled) {
responderHackInstalled = true;
new MacResponderHack(qApp);
QObject::connect(qApp, &QApplication::focusChanged, &responderHack);
}
@autoreleasepool {
@@ -888,33 +907,5 @@ void MacWebKitHelpViewer::goToHistoryItem()
}
}
// #pragma mark -- MacResponderHack
MacResponderHack::MacResponderHack(QObject *parent)
: QObject(parent)
{
connect(qApp, &QApplication::focusChanged,
this, &MacResponderHack::responderHack);
}
void MacResponderHack::responderHack(QWidget *old, QWidget *now)
{
// On focus change, Qt does not make the corresponding QNSView firstResponder.
// That breaks when embedding native NSView into a Qt hierarchy. When the focus is changed
// by clicking with the mouse into a widget, everything is fine, because Cocoa automatically
// adapts firstResponder in that case, but it breaks when setting the Qt focus from code.
Q_UNUSED(old)
if (!now)
return;
@autoreleasepool {
NSView *view;
if (QMacCocoaViewContainer *viewContainer = qobject_cast<QMacCocoaViewContainer *>(now))
view = viewContainer->cocoaView();
else
view = (NSView *)now->effectiveWinId();
[view.window makeFirstResponder:view];
}
}
} // Internal
} // Help