Example #1
0
	void onComponentComplete(WGContextMenu* contextMenu)
	{
		auto context = QQmlEngine::contextForObject(contextMenu);
		assert(context != nullptr);

		auto componentContextProperty = context->contextProperty("componentContext");
		assert(componentContextProperty.isValid());
		auto componentContextVariant = QtHelpers::toVariant(componentContextProperty);
		assert(!componentContextVariant.isVoid());
		auto componentContext = componentContextVariant.value<IComponentContext*>();
		assert(componentContext != nullptr);
		pContext_ = componentContext;

		auto viewProperty = context->contextProperty("View");
		if (viewProperty.isValid())
		{
			view_ = qvariant_cast<QQuickWidget*>(viewProperty);
		}

		auto windowIdProperty = context->contextProperty("windowId");
		if (windowIdProperty.isValid())
		{
			windowId_ = windowIdProperty.toString().toUtf8().data();
		}

		destroyMenu();
		createMenu();
		prepareMenu();
	}
Example #2
0
	void PhotosTab::HandleCollectionSelected (const QModelIndex& index)
	{
		auto rootCtx = ImagesView_->rootContext ();
		if (!rootCtx->contextProperty ("listingMode").toBool ())
		{
			QMetaObject::invokeMethod (ImagesView_->rootObject (),
					"showImage",
					Q_ARG (QVariant, QUrl ()));

			rootCtx->setContextProperty ("listingMode", true);
		}

		rootCtx->setContextProperty ("collRootIndex", QVariant::fromValue (index));

		SelectedID_.clear ();
		SelectedCollection_ = index.data (CollectionRole::ID).toString ();

		emit tabRecoverDataChanged ();
	}