Standalone Viewer to view folders

I assigned this command to the action "Ctrl+dbclk" in the File Type "All Folders":

@ifset:VIEW=Thumbnails
Show FULLSCREEN USEEXISTING=yes,avoid
@ifset:else
go openindual

When viewing a folder with thumbnail, the picture in the folder will be viewed. However, the picture viewed is not necessarily the source picture displayed as a thumbnail.
I know the thumbnail source can be anywhere, but I want to be as consistent as possible when the thumbnail source is in the currently viewed folder.

Not important: When viewing a folder without thumbnail, also view the file in the folder.

Running the viewer on a folder will add all images directly below the folder to the viewer, and start with the first image (usually the first file in alphabetical order).

It doesn't do anything with the folder's thumbnail or folder.jpg or whatever is displayed in the thumbnail. To view those, you'd have to specify their paths.

Thanks for the explanation, I did it via script.

function OnClick(clickData)
{
	var tab = clickData.func.sourcetab;
	var cmd = clickData.func.command;
	if (tab.format.view == "thumbnails") {
		cmd.clearFiles;
		var folderEnum = DOpus.FSUtil.ReadDir(tab.getFocusItem);
		while (!folderEnum.complete) {
			var folderItem = folderEnum.next();
			cmd.addFile(folderItem);
		}
		if (cmd.filecount) cmd.RunCommand('Show FULLSCREEN USEEXISTING=yes,avoid')
		return
	}
	cmd.RunCommand('go openindual');
}

I seem to have found a bug.
Works:

function OnClick(clickData)
{
	var tab = clickData.func.sourcetab;
	var cmd = clickData.func.command;
	cmd.RunCommand('show');
	var viewer = DOpus.viewers.lastactive;
	DOpus.Output(viewer.current)
}

Not work:

function OnClick(clickData)
{
	var tab = clickData.func.sourcetab;
	var cmd = clickData.func.command;
	cmd.RunCommand('show');
	var viewer = clickData.func.viewer;
	DOpus.Output(viewer.current)
}

That isn't a bug. The clickData object give to a command run from a lister won't know anything about a viewer which hadn't opened yet when it was made. :slight_smile:

If your script runs a command to open a viewer, it can use the Command.Results object to obtain the viewer.

Same thing, I think it's confusing.

function OnClick(clickData)
{
	var tab = clickData.func.sourcetab;
	var cmd = clickData.func.command;
	cmd.RunCommand('show');
	//var viewer = clickData.func.viewer;
	DOpus.Output(cmd.results.newviewers.current)
}

Is there any way to replicate this for videos, now that Dopus 13 has a functioning video plugin?

cmd.results.newviewers returns a collection, not a single viewer.

function OnClick(clickData)
{
	var tab = clickData.func.sourcetab;
	var cmd = clickData.func.command;
	cmd.RunCommand('show');
	DOpus.Output(cmd.results.newviewers(0).current)
}

You could adapt Recursive Slideshow on Selected Folders to filter on Movies instead of Images, and/or change which folder it enumerates, or whether it's recursive.

I didn't notice newviewer(s). :sweat_smile:

@osmanas If you don't want to include subfolders:

function OnClick(clickData)
{
	var tab = clickData.func.sourcetab;
	var cmd = clickData.func.command;
	if (tab.format.view == "thumbnails") {
		cmd.clearFiles;
		var folderEnum = DOpus.FSUtil.ReadDir(tab.getFocusItem);
		while (!folderEnum.complete) {
			var folderItem = folderEnum.next();
			if (folderItem.metadata == "video")
			    cmd.addFile(folderItem);
		}
		if (cmd.filecount) cmd.RunCommand('Show FULLSCREEN USEEXISTING=yes,avoid')
		return
	}
	cmd.RunCommand('go openindual');
}