Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.6 kB
1
Indexable
Never
QList<QAction *> toolActions;
	auto configureToolElement = [this, &toolActions](PopcornAction * action, QString const & condition, QString const & statisticsEvent, QString const & integrationTag = {}, std::function<void()> callback = {}) {
		if (!Configuration::menuActionsIds.contains(condition))
			return;
		Statistics::setEventKey(action, statisticsEvent, "EDIT_PANEL");
		Util::setCondition(action, condition);
		if (!integrationTag.isEmpty())
			Util::setIntegrationTag(action, integrationTag);
		if (callback)
			connect(action, &QAction::triggered, this, callback);
		toolActions.push_back(action);
	};

	auto existedAction = [this](QString const & condition) 
	{
		if (condition == m_ui->recordAudioAction->objectName()) 
			return  m_ui->recordAudioAction; 
		else if(condition == m_ui->screencaptureAction->objectName())
			return m_ui->screencaptureAction;
		else if (condition == m_ui->videocaptureAction->objectName())
			return m_ui->videocaptureAction;
	};

	configureToolElement(m_ui->recordAudioAction, "recordAudio", "AUDIO_RECORD_CLICKED", {}, [this] { emit voiceOverRequested(); });
	configureToolElement(m_ui->screencaptureAction, "screencapture", "SCREEN_CAPTURE_CLICKED", "screencapture");
	configureToolElement(m_ui->videocaptureAction, "videocapture", "VIDEO_CAPTURE_CLICKED", "videocapture");
	
	Workaround::Ui::apply(m_popup);
	m_popup->addActions(actions);
	if (!toolActions.empty())
	{
		m_popup->addSeparator();		
	}

	for (auto const & condition : Configuration::menuActionsIds)
	{
		auto actionName = condition + "Action";
		m_popup->addAction(existedAction(actionName));
	}