Skip to content

Commit

Permalink
Merge pull request #529 from Pat1enceLos/fixSubtitlePos
Browse files Browse the repository at this point in the history
 fix(main.js): prevent set window size frequently with the same key
  • Loading branch information
ipy authored Mar 18, 2019
2 parents cac6975 + 569146d commit 5b0320a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ new Vue({
},
computed: {
...mapGetters(['volume', 'muted', 'intrinsicWidth', 'intrinsicHeight', 'ratio', 'winWidth', 'winPos', 'winSize', 'chosenStyle', 'chosenSize', 'mediaHash', 'subtitleList',
'currentSubtitleId', 'audioTrackList', 'isFullScreen', 'paused', 'singleCycle', 'isFocused', 'originSrc', 'defaultDir', 'ableToPushCurrentSubtitle', 'displayLanguage', 'calculatedNoSub']),
'currentSubtitleId', 'audioTrackList', 'isFullScreen', 'paused', 'singleCycle', 'isFocused', 'originSrc', 'defaultDir', 'ableToPushCurrentSubtitle', 'displayLanguage', 'calculatedNoSub', 'sizePercent']),
updateFullScreen() {
if (this.isFullScreen) {
return {
Expand Down Expand Up @@ -1063,7 +1063,7 @@ new Vue({
await this.createMenu();
},
changeWindowSize(key) {
if (!this.originSrc) {
if (!this.originSrc || key === this.sizePercent) {
return;
}
let newSize = [];
Expand All @@ -1088,6 +1088,7 @@ new Vue({
windowRect,
newSize,
);
this.$store.dispatch('updateSizePercent', key);
const rect = newPosition.concat(newSize);
this.$electron.ipcRenderer.send('callMainWindowMethod', 'setSize', rect.slice(2, 4));
this.$electron.ipcRenderer.send('callMainWindowMethod', 'setPosition', rect.slice(0, 2));
Expand Down
11 changes: 10 additions & 1 deletion src/renderer/store/modules/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const state = {
isFocused: true,
isMaximized: false,
isMinimized: false,
sizePercent: 1,
};

const getters = {
Expand All @@ -20,6 +21,7 @@ const getters = {
isFocused: state => state.isFocused,
isMaximized: state => state.isMaximized,
isMinimized: state => state.isMinimized,
sizePercent: state => state.sizePercent,
};

const mutations = {
Expand All @@ -44,9 +46,16 @@ const mutations = {
isMinimized(state, payload) {
state.isMinimized = payload;
},
sizePercentUpdate(state, payload) {
state.sizePercent = payload;
},
};

const actions = {};
const actions = {
updateSizePercent({ commit }, delta) {
commit('sizePercentUpdate', delta);
},
};

export default {
state,
Expand Down

0 comments on commit 5b0320a

Please sign in to comment.