Untitled

 avatar
unknown
plain_text
a year ago
1.6 kB
1
Indexable
auto addToolElement = [this, &toolElements](Movavi::Popcorn::PopcornAction * action, QString const & condition, ToolElement const & tool) {
		Statistics::setEventKey(action, tool.statisticsEvent, "EDIT_PANEL");
		Util::setCondition(action, condition);
		if (!tool.integrationTag.isEmpty())
			Util::setIntegrationTag(action, tool.integrationTag);

		assert(tool.callback && "Invalid action callback");
		connect(action, &QAction::triggered, this, tool.callback);
		toolElements.push_back(action);
	};

	QMap<QString, ToolElement> condition2tool = {
		{ "recordAudio", { QCoreApplication::translate("AddTrackButton.menu", "Record audio"), "AUDIO_RECORD_CLICKED", {}, [this] { emit voiceOverRequested(); } } },
		{ "videocapture", { QCoreApplication::translate("AddTrackButton.menu", "Record video"), "VIDEO_CAPTURE_CLICKED", "videocapture" } },
		{ "screencapture", { QCoreApplication::translate("AddTrackButton.menu", "Record screen"), "SCREEN_CAPTURE_CLICKED", "screencapture" } },
	};
	
	auto checkToolElementsBeforeAdding = [&condition2tool, &addToolElement](Movavi::Popcorn::PopcornAction * action, QString const & condition) {
		if (Configuration::menuActionsIds.contains(condition))
			addToolElement(action, condition, condition2tool.value(condition));
	};

	for (auto const & condition : Configuration::menuActionsIds)
	{
		assert(condition2tool.contains(condition) && "Unknown tool in EditPanel menu");
	}
	checkToolElementsBeforeAdding(m_ui->recordAudioAction, "recordAudio");
	checkToolElementsBeforeAdding(m_ui->videocaptureAction, "videocapture");
	checkToolElementsBeforeAdding(m_ui->screencaptureAction, "screencapture");