src/Viewer/viewmgr.cxx: enable/disable video encoding menu items.
It doesn't look like menubar items can be enabled/disabled using <property> or <expression>, so instead we write to the File menu's items tree /sim/menubar/default/menu[]/name[]/enabled. We also set /sim/video/encoding-path to '' or path of video file that we are encoding to.
This commit is contained in:
parent
e3b619dd05
commit
3351a785be
1 changed files with 34 additions and 0 deletions
|
@ -175,9 +175,40 @@ static void videoEncodingPopup(const std::string& message, int delay)
|
||||||
globals->get_commands()->execute("show-message", args);
|
globals->get_commands()->execute("show-message", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vidoEncodingUpdateStatus(const std::string& path)
|
||||||
|
{
|
||||||
|
fgSetString("/sim/video/encoding-path", path);
|
||||||
|
bool encoding = (path != "");
|
||||||
|
SGPropertyNode* node = fgGetNode("/sim/menubar/default");
|
||||||
|
|
||||||
|
/* Enable/disable menu items 'File/Video encode start' and 'File/Video
|
||||||
|
encode stop'. */
|
||||||
|
for (auto a: node->getChildren("menu"))
|
||||||
|
{
|
||||||
|
std::string name = a->getStringValue("name");
|
||||||
|
if (name == "file")
|
||||||
|
{
|
||||||
|
for (auto b: a->getChildren("item"))
|
||||||
|
{
|
||||||
|
std::string name = b->getStringValue("name");
|
||||||
|
if (name == "video-start")
|
||||||
|
{
|
||||||
|
b->setBoolValue("enabled", !encoding);
|
||||||
|
}
|
||||||
|
if (name == "video-stop")
|
||||||
|
{
|
||||||
|
b->setBoolValue("enabled", encoding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void videoEncodingError(const std::string& message)
|
static void videoEncodingError(const std::string& message)
|
||||||
{
|
{
|
||||||
globals->get_props()->setIntValue("/sim/video/error", 1);
|
globals->get_props()->setIntValue("/sim/video/error", 1);
|
||||||
|
vidoEncodingUpdateStatus("");
|
||||||
videoEncodingPopup(message, 15);
|
videoEncodingPopup(message, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,6 +502,8 @@ bool FGViewMgr::video_start(
|
||||||
videoEncodingError(e.what());
|
videoEncodingError(e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vidoEncodingUpdateStatus(path.str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,6 +512,7 @@ void FGViewMgr::video_stop()
|
||||||
if (_video_encoder)
|
if (_video_encoder)
|
||||||
{
|
{
|
||||||
_video_encoder.reset();
|
_video_encoder.reset();
|
||||||
|
vidoEncodingUpdateStatus("");
|
||||||
videoEncodingPopup("Video encoding stopped", 5);
|
videoEncodingPopup("Video encoding stopped", 5);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue