Untitled
unknown
plain_text
2 years ago
1.8 kB
6
Indexable
QList<QAction *> toolElements;
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 checkToolElements = [this, &condition2tool, &addToolElement]() {
if (Configuration::menuActionsIds.contains("recordAudio"))
addToolElement(m_ui->recordAudioAction, "recordAudio", condition2tool.value("recordAudio"));
if (Configuration::menuActionsIds.contains("videocapture"))
addToolElement(m_ui->videocaptureAction, "videocapture", condition2tool.value("videocapture"));
if (Configuration::menuActionsIds.contains("screencapture"))
addToolElement(m_ui->screencaptureAction, "screencapture", condition2tool.value("screencapture"));
};
for (auto const & condition : Configuration::menuActionsIds)
{
assert(condition2tool.contains(condition) && "Unknown tool in EditPanel menu");
}
checkToolElements();Editor is loading...