Add Setting to disable smooth scrolling

This commit is contained in:
Preston 2020-10-07 09:57:22 -04:00
parent 7eb78bd524
commit d6e4a1e9cc
5 changed files with 136 additions and 20 deletions

View File

@ -50,15 +50,28 @@ if (!isDev) {
}) })
app.on('ready', (event, commandLine, workingDirectory) => { app.on('ready', (event, commandLine, workingDirectory) => {
createWindow() settingsDb.findOne({
_id: 'disableSmoothScrolling'
}, function (err, doc) {
if (err) {
app.exit(0)
return
}
if (isDev) { if (doc !== null && doc.value) {
installDevTools() app.commandLine.appendSwitch('disable-smooth-scrolling')
} }
if (isDebug) { createWindow()
mainWindow.webContents.openDevTools()
} if (isDev) {
installDevTools()
}
if (isDebug) {
mainWindow.webContents.openDevTools()
}
})
}) })
} else { } else {
app.quit() app.quit()
@ -69,15 +82,28 @@ if (!isDev) {
}) })
app.on('ready', () => { app.on('ready', () => {
createWindow() settingsDb.findOne({
_id: 'disableSmoothScrolling'
}, function (err, doc) {
if (err) {
app.exit(0)
return
}
if (isDev) { if (doc !== null && doc.value) {
installDevTools() app.commandLine.appendSwitch('disable-smooth-scrolling')
} }
if (isDebug) { createWindow()
mainWindow.webContents.openDevTools()
} if (isDev) {
installDevTools()
}
if (isDebug) {
mainWindow.webContents.openDevTools()
}
})
}) })
} }
@ -206,6 +232,18 @@ function createWindow () {
mainWindow.webContents.send('ping', process.argv) mainWindow.webContents.send('ping', process.argv)
} }
}) })
ipcMain.on('disableSmoothScrolling', () => {
app.commandLine.appendSwitch('disable-smooth-scrolling')
mainWindow.close()
createWindow()
})
ipcMain.on('enableSmoothScrolling', () => {
app.commandLine.appendSwitch('enable-smooth-scrolling')
mainWindow.close()
createWindow()
})
} }
app.on('window-all-closed', () => { app.on('window-all-closed', () => {

View File

@ -5,6 +5,7 @@ import FtSelect from '../ft-select/ft-select.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue' import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtSlider from '../ft-slider/ft-slider.vue' import FtSlider from '../ft-slider/ft-slider.vue'
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue' import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
import FtPrompt from '../ft-prompt/ft-prompt.vue'
export default Vue.extend({ export default Vue.extend({
name: 'ThemeSettings', name: 'ThemeSettings',
@ -13,7 +14,8 @@ export default Vue.extend({
'ft-select': FtSelect, 'ft-select': FtSelect,
'ft-toggle-switch': FtToggleSwitch, 'ft-toggle-switch': FtToggleSwitch,
'ft-slider': FtSlider, 'ft-slider': FtSlider,
'ft-flex-box': FtFlexBox 'ft-flex-box': FtFlexBox,
'ft-prompt': FtPrompt
}, },
data: function () { data: function () {
return { return {
@ -24,6 +26,12 @@ export default Vue.extend({
minUiScale: 50, minUiScale: 50,
maxUiScale: 300, maxUiScale: 300,
uiScaleStep: 5, uiScaleStep: 5,
disableSmoothScrollingToggleValue: false,
showRestartPrompt: false,
restartPromptValues: [
'yes',
'no'
],
baseThemeValues: [ baseThemeValues: [
'light', 'light',
'dark', 'dark',
@ -62,6 +70,21 @@ export default Vue.extend({
return this.$store.getters.getUiScale return this.$store.getters.getUiScale
}, },
disableSmoothScrolling: function () {
return this.$store.getters.getDisableSmoothScrolling
},
restartPromptMessage: function () {
return this.$t('Settings["The app needs to restart for changes to take effect. Restart and apply change?"]')
},
restartPromptNames: function () {
return [
this.$t('Yes'),
this.$t('No')
]
},
baseThemeNames: function () { baseThemeNames: function () {
return [ return [
this.$t('Settings.Theme Settings.Base Theme.Light'), this.$t('Settings.Theme Settings.Base Theme.Light'),
@ -96,6 +119,7 @@ export default Vue.extend({
this.currentMainColor = localStorage.getItem('mainColor').replace('main', '') this.currentMainColor = localStorage.getItem('mainColor').replace('main', '')
this.currentSecColor = localStorage.getItem('secColor').replace('sec', '') this.currentSecColor = localStorage.getItem('secColor').replace('sec', '')
this.expandSideBar = localStorage.getItem('expandSideBar') === 'true' this.expandSideBar = localStorage.getItem('expandSideBar') === 'true'
this.disableSmoothScrollingToggleValue = this.disableSmoothScrolling
}, },
methods: { methods: {
updateBaseTheme: function (theme) { updateBaseTheme: function (theme) {
@ -128,6 +152,30 @@ export default Vue.extend({
this.updateUiScale(parseInt(value)) this.updateUiScale(parseInt(value))
}, },
handleRestartPrompt: function (value) {
this.disableSmoothScrollingToggleValue = value
this.showRestartPrompt = true
},
handleSmoothScrolling: function (value) {
this.showRestartPrompt = false
if (value === null || value === 'no') {
this.disableSmoothScrollingToggleValue = !this.disableSmoothScrollingToggleValue
return
}
this.updateDisableSmoothScrolling(this.disableSmoothScrollingToggleValue)
const electron = require('electron')
if (this.disableSmoothScrollingToggleValue) {
electron.ipcRenderer.send('disableSmoothScrolling')
} else {
electron.ipcRenderer.send('enableSmoothScrolling')
}
},
updateMainColor: function (color) { updateMainColor: function (color) {
const mainColor = `main${color}` const mainColor = `main${color}`
const secColor = `sec${this.currentSecColor}` const secColor = `sec${this.currentSecColor}`
@ -158,7 +206,8 @@ export default Vue.extend({
...mapActions([ ...mapActions([
'updateBarColor', 'updateBarColor',
'updateUiScale' 'updateUiScale',
'updateDisableSmoothScrolling'
]) ])
} }
}) })

View File

@ -16,6 +16,11 @@
:default-value="expandSideBar" :default-value="expandSideBar"
@change="handleExpandSideBar" @change="handleExpandSideBar"
/> />
<ft-toggle-switch
:label="$t('Settings.Theme Settings.Disable Smooth Scrolling')"
:default-value="disableSmoothScrollingToggleValue"
@change="handleRestartPrompt"
/>
</ft-flex-box> </ft-flex-box>
<ft-flex-box> <ft-flex-box>
<ft-slider <ft-slider
@ -52,6 +57,13 @@
@change="updateSecColor" @change="updateSecColor"
/> />
</ft-flex-box> </ft-flex-box>
<ft-prompt
v-if="showRestartPrompt"
:label="restartPromptMessage"
:option-names="restartPromptNames"
:option-values="restartPromptValues"
@click="handleSmoothScrolling"
/>
</ft-card> </ft-card>
</template> </template>

View File

@ -60,7 +60,7 @@ const state = {
useTor: false, useTor: false,
proxy: 'SOCKS5://127.0.0.1:9050', proxy: 'SOCKS5://127.0.0.1:9050',
debugMode: false, debugMode: false,
disctractionFreeMode: false, disableSmoothScrolling: false,
hideWatchedSubs: false, hideWatchedSubs: false,
useRssFeeds: false, useRssFeeds: false,
usingElectron: true, usingElectron: true,
@ -191,6 +191,10 @@ const getters = {
return state.usingElectron return state.usingElectron
}, },
getDisableSmoothScrolling: () => {
return state.disableSmoothScrolling
},
getHideVideoViews: () => { getHideVideoViews: () => {
return state.hideVideoViews return state.hideVideoViews
}, },
@ -274,6 +278,9 @@ const actions = {
webframe.setZoomFactor(parseInt(result.value) / 100) webframe.setZoomFactor(parseInt(result.value) / 100)
commit('setUiScale', result.value) commit('setUiScale', result.value)
break break
case 'disableSmoothScrolling':
commit('setDisableSmoothScrolling', result.value)
break
case 'hideWatchedSubs': case 'hideWatchedSubs':
commit('setHideWatchedSubs', result.value) commit('setHideWatchedSubs', result.value)
break break
@ -584,6 +591,14 @@ const actions = {
}) })
}, },
updateDisableSmoothScrolling ({ commit }, disableSmoothScrolling) {
settingsDb.update({ _id: 'disableSmoothScrolling' }, { _id: 'disableSmoothScrolling', value: disableSmoothScrolling }, { upsert: true }, (err, numReplaced) => {
if (!err) {
commit('setDisableSmoothScrolling', disableSmoothScrolling)
}
})
},
updateHideVideoViews ({ commit }, hideVideoViews) { updateHideVideoViews ({ commit }, hideVideoViews) {
settingsDb.update({ _id: 'hideVideoViews' }, { _id: 'hideVideoViews', value: hideVideoViews }, { upsert: true }, (err, numReplaced) => { settingsDb.update({ _id: 'hideVideoViews' }, { _id: 'hideVideoViews', value: hideVideoViews }, { upsert: true }, (err, numReplaced) => {
if (!err) { if (!err) {
@ -740,9 +755,6 @@ const mutations = {
setDebugMode (state, debugMode) { setDebugMode (state, debugMode) {
state.debugMode = debugMode state.debugMode = debugMode
}, },
setDistractionFreeMode (state, disctractionFreeMode) {
state.disctractionFreeMode = disctractionFreeMode
},
setHideWatchedSubs (state, hideWatchedSubs) { setHideWatchedSubs (state, hideWatchedSubs) {
state.hideWatchedSubs = hideWatchedSubs state.hideWatchedSubs = hideWatchedSubs
}, },
@ -752,6 +764,9 @@ const mutations = {
setUsingElectron (state, usingElectron) { setUsingElectron (state, usingElectron) {
state.usingElectron = usingElectron state.usingElectron = usingElectron
}, },
setDisableSmoothScrolling (state, disableSmoothScrolling) {
state.disableSmoothScrolling = disableSmoothScrolling
},
setVideoView (state, videoView) { setVideoView (state, videoView) {
state.videoView = videoView state.videoView = videoView
}, },

View File

@ -90,6 +90,7 @@ History:
Settings: Settings:
# On Settings Page # On Settings Page
Settings: Settings Settings: Settings
The app needs to restart for changes to take effect. Restart and apply change?: The app needs to restart for changes to take effect. Restart and apply change?
General Settings: General Settings:
General Settings: General Settings General Settings: General Settings
Check for Updates: Check for Updates Check for Updates: Check for Updates
@ -121,6 +122,7 @@ Settings:
Theme Settings: Theme Settings Theme Settings: Theme Settings
Match Top Bar with Main Color: Match Top Bar with Main Color Match Top Bar with Main Color: Match Top Bar with Main Color
Expand Side Bar by Default: Expand Side Bar by Default Expand Side Bar by Default: Expand Side Bar by Default
Disable Smooth Scrolling: Disable Smooth Scrolling
UI Scale: UI Scale UI Scale: UI Scale
Base Theme: Base Theme:
Base Theme: Base Theme Base Theme: Base Theme