forked from qt-creator/qt-creator
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:
@@ -40,17 +40,6 @@ namespace Internal {
|
|||||||
class MacWebKitHelpViewer;
|
class MacWebKitHelpViewer;
|
||||||
class MacWebKitHelpWidgetPrivate;
|
class MacWebKitHelpWidgetPrivate;
|
||||||
|
|
||||||
class MacResponderHack : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MacResponderHack(QObject *parent);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void responderHack(QWidget *old, QWidget *now);
|
|
||||||
};
|
|
||||||
|
|
||||||
class MacWebKitHelpWidget : public QMacCocoaViewContainer
|
class MacWebKitHelpWidget : public QMacCocoaViewContainer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -530,6 +530,25 @@ void MacWebKitHelpWidget::showToolTip()
|
|||||||
|
|
||||||
// #pragma mark -- MacWebKitHelpViewer
|
// #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)
|
MacWebKitHelpViewer::MacWebKitHelpViewer(QWidget *parent)
|
||||||
: HelpViewer(parent),
|
: HelpViewer(parent),
|
||||||
m_widget(new MacWebKitHelpWidget(this))
|
m_widget(new MacWebKitHelpWidget(this))
|
||||||
@@ -537,7 +556,7 @@ MacWebKitHelpViewer::MacWebKitHelpViewer(QWidget *parent)
|
|||||||
static bool responderHackInstalled = false;
|
static bool responderHackInstalled = false;
|
||||||
if (!responderHackInstalled) {
|
if (!responderHackInstalled) {
|
||||||
responderHackInstalled = true;
|
responderHackInstalled = true;
|
||||||
new MacResponderHack(qApp);
|
QObject::connect(qApp, &QApplication::focusChanged, &responderHack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@autoreleasepool {
|
@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
|
} // Internal
|
||||||
} // Help
|
} // Help
|
||||||
|
|||||||
Reference in New Issue
Block a user