Пример #1
0
bool qtnStartInplaceEdit(QWidget* editor)
{
    if (!editor)
        return false;

    if (g_inplaceEditor)
    {
        Q_ASSERT(false);
        qtnStopInplaceEdit();
    }

    QCoreApplication* app = QCoreApplication::instance();
    if (!app)
    {
        Q_ASSERT(false);
        return false;
    }

    g_inplaceEditor = editor;
    g_inplaceEditorHandler = new QtnInplaceEditorHandler();

    // move focus to editor
    if (QApplication::focusWidget() != g_inplaceEditor->focusWidget())
        g_inplaceEditor->setFocus();

    // connect to editor destroyed signal
    QObject::connect(  g_inplaceEditor, &QObject::destroyed
                     , g_inplaceEditorHandler, &QtnInplaceEditorHandler::OnEditorDestroyed);

    // install application event filter
    app->installEventFilter(g_inplaceEditorHandler);

    return true;
}
QApplicationActivityObserver * QApplicationActivityObserver::instance()
{
	static QMutex mymutex;
	static QScopedPointer<QApplicationActivityObserver> instance;
	QMutexLocker locker(&mymutex);

	// Creating instance
	if (instance.isNull())
	{
		instance.reset(new QApplicationActivityObserver());
	}

	// Installing event filter
	static bool installed_filter = false;
	if (!installed_filter)
	{
		QCoreApplication * app = QCoreApplication::instance();
		if (app)
		{
			app->installEventFilter(instance.data());
			installed_filter = true;
			qDebug()<<__FUNCTION__<<"Successfully installed event filter.";
		}
		else
		{
			qWarning()<<__FUNCTION__<<"installing event filter failed because QCoreApplication instance doesn't exist, will try later.";
		}
	}

	return instance.data();
}
Пример #3
0
void grabUVContext::toolOnSetup( MEvent &event )
{
	MPxTexContext::toolOnSetup( event );

	QCoreApplication *app = qApp;
	app->installEventFilter(this);
}