Skip to content

Commit

Permalink
Merge branch 'rc' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jneilliii authored Jan 6, 2022
2 parents 1514123 + c444df4 commit 558d20c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions octoprint_prusaslicerthumbnails/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ def find_best_thumbnail(self, gcode_encoded_images):
# Return size and trimmed string
return (200, 200), image[9:]


# Check for simage
for image in gcode_encoded_images:
if image.startswith(';simage:'):
# Return size and trimmed string
return (100, 100), image[8:]

# Image not found
return None

# Check for simage
for image in gcode_encoded_images:
if image.startswith(';simage:'):
Expand Down Expand Up @@ -161,6 +171,7 @@ def on_event(self, event, payload):
if event in ["FileAdded", "FileRemoved"] and payload["storage"] == "local" and "gcode" in payload["type"]:
thumbnail_path = self.regex_extension.sub(".png", payload["path"])
thumbnail_filename = "{}/{}".format(self.get_plugin_data_folder(), thumbnail_path)

if os.path.exists(thumbnail_filename):
os.remove(thumbnail_filename)
if event == "FileAdded":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ $(function() {

self.onBeforeBinding = function() {
// inject filelist thumbnail into template
let regex = /<div class="btn-group action-buttons">([\s\S]*)<.div>/mi;

let regex = /<div class="btn-group action-buttons">([\s\S]*)<.div>/mi;
let template = '<div class="btn btn-mini" data-bind="click: function() { if ($root.loginState.isUser()) { $root.prusaslicerthumbnails_open_thumbnail($data) } else { return; } }, visible: ($data.thumbnail_src == \'prusaslicerthumbnails\' && $root.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail() == false)" title="Show Thumbnail" style="display: none;"><i class="fa fa-image"></i></div>';

let inline_thumbnail_template = '<div class="inline_prusa_thumbnail" ' +
Expand All @@ -78,6 +79,7 @@ $(function() {
'style: {\'width\': (!$root.thumbnailPositionLeft()) ? $root.thumbnailScaleValue() : \'100%\' }" ' +
'style="display: none;"/></div>';


$("#files_template_machinecode").text(function () {
var return_value = inline_thumbnail_template + $(this).text();
return_value = return_value.replace(regex, '<div class="btn-group action-buttons">$1 ' + template + '></div>');
Expand Down Expand Up @@ -117,6 +119,7 @@ $(function() {
});
self.settingsViewModel.settings.plugins.prusaslicerthumbnails.state_panel_thumbnail_scale_value.subscribe(function(newValue){
$('#prusaslicer_state_thumbnail').attr({'width': self.settingsViewModel.settings.plugins.prusaslicerthumbnails.state_panel_thumbnail_scale_value() + '%'});

});

// observe alignment changes
Expand Down Expand Up @@ -169,6 +172,7 @@ $(function() {
}
});
};

}

OCTOPRINT_VIEWMODELS.push({
Expand Down

0 comments on commit 558d20c

Please sign in to comment.