Apply saved settings
Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
This commit is contained in:
parent
c887232dff
commit
bbce8c6ee1
@ -36,7 +36,10 @@ class Readability(Falkon.PluginInterface, QtCore.QObject):
|
|||||||
self.config = {
|
self.config = {
|
||||||
"settingsFile": os.path.join(settingsPath, "readability", "settings.ini"),
|
"settingsFile": os.path.join(settingsPath, "readability", "settings.ini"),
|
||||||
"icon": "dark",
|
"icon": "dark",
|
||||||
"contextMenu": False
|
"contextMenu": False,
|
||||||
|
"colorTheme": "sepia",
|
||||||
|
"font": "sans-serif",
|
||||||
|
"fontSize": 5
|
||||||
}
|
}
|
||||||
self.buttons = {}
|
self.buttons = {}
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
@ -153,7 +156,16 @@ class Readability(Falkon.PluginInterface, QtCore.QObject):
|
|||||||
self.scriptCall = self.scriptCall.replace("{toolbar.js}", self.scriptToolbar)
|
self.scriptCall = self.scriptCall.replace("{toolbar.js}", self.scriptToolbar)
|
||||||
self.scriptCall = self.scriptCall.replace("{style.css}", self.style)
|
self.scriptCall = self.scriptCall.replace("{style.css}", self.style)
|
||||||
|
|
||||||
self.view.page().runJavaScript(self.scriptCall)
|
initConfigScript = "initConfig('{}', '{}', {});".format(
|
||||||
|
self.config["colorTheme"],
|
||||||
|
self.config["font"],
|
||||||
|
self.config["fontSize"]
|
||||||
|
)
|
||||||
|
|
||||||
|
self.view.page().runJavaScript(
|
||||||
|
self.scriptCall + initConfigScript,
|
||||||
|
Falkon.WebPage.SafeJsWorld
|
||||||
|
)
|
||||||
|
|
||||||
def showSettings(self, parent):
|
def showSettings(self, parent):
|
||||||
settings = SettingsDialog(self.config, parent)
|
settings = SettingsDialog(self.config, parent)
|
||||||
@ -167,6 +179,9 @@ class Readability(Falkon.PluginInterface, QtCore.QObject):
|
|||||||
settings.beginGroup("Readability")
|
settings.beginGroup("Readability")
|
||||||
settings.setValue("icon", self.config["icon"])
|
settings.setValue("icon", self.config["icon"])
|
||||||
settings.setValue("showInContextMenu", self.config["contextMenu"])
|
settings.setValue("showInContextMenu", self.config["contextMenu"])
|
||||||
|
settings.setValue("colorTheme", self.config["colorTheme"])
|
||||||
|
settings.setValue("font", self.config["font"])
|
||||||
|
settings.setValue("fontSize", self.config["fontSize"])
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
|
|
||||||
settings.sync()
|
settings.sync()
|
||||||
@ -179,6 +194,9 @@ class Readability(Falkon.PluginInterface, QtCore.QObject):
|
|||||||
self.config["contextMenu"] = str2bool(
|
self.config["contextMenu"] = str2bool(
|
||||||
settings.value("showInContextMenu", self.config["contextMenu"])
|
settings.value("showInContextMenu", self.config["contextMenu"])
|
||||||
)
|
)
|
||||||
|
self.config["colorTheme"] = str(settings.value("colorTheme", self.config["colorTheme"]))
|
||||||
|
self.config["font"] = str(settings.value("font", self.config["font"]))
|
||||||
|
self.config["fontSize"] = int(settings.value("fontSize", self.config["fontSize"]))
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
|
|
||||||
def onConfigUpdate(self):
|
def onConfigUpdate(self):
|
||||||
|
@ -108,4 +108,28 @@ function renderPage(article){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callReadability();
|
function initConfig(colorTheme, font, fontSize){
|
||||||
|
switch(colorTheme) {
|
||||||
|
case "light":
|
||||||
|
switchToLight();
|
||||||
|
break;
|
||||||
|
case "dark":
|
||||||
|
switchToDark();
|
||||||
|
break;
|
||||||
|
case "sepia":
|
||||||
|
default:
|
||||||
|
switchToSepia();
|
||||||
|
}
|
||||||
|
switch(font){
|
||||||
|
case "serif":
|
||||||
|
switchToSerif();
|
||||||
|
break;
|
||||||
|
case "sans-serif":
|
||||||
|
default:
|
||||||
|
switchToSansSerif();
|
||||||
|
}
|
||||||
|
|
||||||
|
fontSizeSet(fontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
callReadability();
|
||||||
|
@ -143,3 +143,17 @@ function fontSizeMinus(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fontSizeSet(fontSize){
|
||||||
|
if (fontSize < 1 || fontSize > 9)
|
||||||
|
return
|
||||||
|
|
||||||
|
var container = document.getElementById('container');
|
||||||
|
for (var i = 0; i < container.classList.length; i++){
|
||||||
|
if(container.classList[i].indexOf('font-size') > -1){
|
||||||
|
container.classList.remove(container.classList[i]);
|
||||||
|
container.classList.add('font-size' + fontSize);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user