Skip to content

Commit

Permalink
Merge pull request #2183 from error414/fix-copy-layout-electron
Browse files Browse the repository at this point in the history
fix copy OSD layout for electron
  • Loading branch information
MrD-RC authored Oct 8, 2024
2 parents baa2854 + 26e45d1 commit ae0f6a8
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tabs/osd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3213,22 +3213,26 @@ OSD.GUI.updateAll = function() {
}
});

paste.on('click', function() {
paste.on('click', async function() {
if(layout_clipboard.filled == true){

var oldLayout = JSON.parse(JSON.stringify(OSD.data.layouts[OSD.data.selected_layout]))
OSD.data.layouts[OSD.data.selected_layout] = JSON.parse(JSON.stringify(layout_clipboard.layout));
layouts.trigger('change');
OSD.data.layouts[OSD.data.selected_layout].forEach(function(item, index){

for(var index in OSD.data.layouts[OSD.data.selected_layout])
{
var item = OSD.data.layouts[OSD.data.selected_layout][index];
if(!(item.isVisible === false && oldLayout[index].isVisible === false) && (oldLayout[index].x !== item.x || oldLayout[index].y !== item.y || oldLayout[index].position !== item.position || oldLayout[index].isVisible !== item.isVisible)){
OSD.saveItem({id: index});
await OSD.saveItem({id: index});
}
});
}

GUI.log(i18n.getMessage('osdLayoutPasteFromClipboard'));
}
});

clear.on('click', function() {
clear.on('click', async function() {
var oldLayout = JSON.parse(JSON.stringify(OSD.data.layouts[OSD.data.selected_layout]));

var clearedLayout = [];
Expand All @@ -3240,12 +3244,15 @@ OSD.GUI.updateAll = function() {

OSD.data.layouts[OSD.data.selected_layout] = clearedLayout;
layouts.trigger('change');
OSD.data.layouts[OSD.data.selected_layout].forEach(function(item, index){

for(var index in OSD.data.layouts[OSD.data.selected_layout]) {
var item = OSD.data.layouts[OSD.data.selected_layout][index];
if(oldLayout[index].isVisible === true){
OSD.saveItem({id: index});
await OSD.saveItem({id: index});
}
});
GUI.log(chrome.i18n.getMessage('osdClearLayout'));
}

GUI.log(i18n.getMessage('osdClearLayout'));
});


Expand Down

0 comments on commit ae0f6a8

Please sign in to comment.