mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Add new option "Ignore system colors" for dark themes.
It will set default background of html element to white. However, this may break some sites, so let's just make this optional.
This commit is contained in:
parent
ccec3409c2
commit
4b2fd86fdd
@ -399,8 +399,10 @@ void MainApplication::loadSettings()
|
|||||||
m_websettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, settings.value("allowJavaScriptCloseWindow", false).toBool());
|
m_websettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, settings.value("allowJavaScriptCloseWindow", false).toBool());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const QUrl &styleSheet = userStyleSheet(settings.value("userStyleSheet", QString()).toString(),
|
||||||
|
settings.value("ignoreSystemColors", false).toBool());
|
||||||
|
m_websettings->setUserStyleSheetUrl(styleSheet);
|
||||||
setWheelScrollLines(settings.value("wheelScrollLines", wheelScrollLines()).toInt());
|
setWheelScrollLines(settings.value("wheelScrollLines", wheelScrollLines()).toInt());
|
||||||
m_websettings->setUserStyleSheetUrl(userStyleSheet(settings.value("userStyleSheet", QString()).toString()));
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup("Browser-Fonts");
|
settings.beginGroup("Browser-Fonts");
|
||||||
@ -834,7 +836,8 @@ void MainApplication::reloadUserStyleSheet()
|
|||||||
{
|
{
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.beginGroup("Web-Browser-Settings");
|
settings.beginGroup("Web-Browser-Settings");
|
||||||
m_websettings->setUserStyleSheetUrl(userStyleSheet(settings.value("userStyleSheet", QString()).toString()));
|
m_websettings->setUserStyleSheetUrl(userStyleSheet(settings.value("userStyleSheet", QString()).toString(),
|
||||||
|
settings.value("ignoreSystemColors", false).toBool()));
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -880,11 +883,18 @@ RegisterQAppAssociation* MainApplication::associationManager()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QUrl MainApplication::userStyleSheet(const QString &filePath) const
|
QUrl MainApplication::userStyleSheet(const QString &filePath, bool ignoreSystemColors) const
|
||||||
{
|
{
|
||||||
|
QString userStyle;
|
||||||
|
|
||||||
|
if (ignoreSystemColors) {
|
||||||
// Set default white background for all sites
|
// Set default white background for all sites
|
||||||
// Fixes issue with dark themes when sites don't set background
|
// Fixes issue with dark themes when sites don't set background
|
||||||
QString userStyle = "html{background-color:white;}";
|
// But it also brings issues with background of iframes that assumes
|
||||||
|
// background will by default will be transparent
|
||||||
|
userStyle += "html{background-color:white;}";
|
||||||
|
}
|
||||||
|
|
||||||
userStyle += AdBlockManager::instance()->elementHidingRules() + "{ display:none !important;}";
|
userStyle += AdBlockManager::instance()->elementHidingRules() + "{ display:none !important;}";
|
||||||
|
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
|
@ -148,7 +148,7 @@ private:
|
|||||||
void translateApp();
|
void translateApp();
|
||||||
void restoreOtherWindows();
|
void restoreOtherWindows();
|
||||||
|
|
||||||
QUrl userStyleSheet(const QString &filePath) const;
|
QUrl userStyleSheet(const QString &filePath, bool ignoreSystemColors) const;
|
||||||
|
|
||||||
CookieManager* m_cookiemanager;
|
CookieManager* m_cookiemanager;
|
||||||
BrowsingLibrary* m_browsingLibrary;
|
BrowsingLibrary* m_browsingLibrary;
|
||||||
|
@ -253,6 +253,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
|
|||||||
ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt());
|
ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt());
|
||||||
ui->defaultZoom->setValue(settings.value("DefaultZoom", 100).toInt());
|
ui->defaultZoom->setValue(settings.value("DefaultZoom", 100).toInt());
|
||||||
ui->xssAuditing->setChecked(settings.value("XSSAuditing", false).toBool());
|
ui->xssAuditing->setChecked(settings.value("XSSAuditing", false).toBool());
|
||||||
|
ui->ignoreSystemColors->setChecked(settings.value("ignoreSystemColors", false).toBool());
|
||||||
|
|
||||||
//Cache
|
//Cache
|
||||||
ui->pagesInCache->setValue(settings.value("maximumCachedPages", 3).toInt());
|
ui->pagesInCache->setValue(settings.value("maximumCachedPages", 3).toInt());
|
||||||
@ -898,6 +899,7 @@ void Preferences::saveSettings()
|
|||||||
settings.setValue("LoadTabsOnActivation", ui->dontLoadTabsUntilSelected->isChecked());
|
settings.setValue("LoadTabsOnActivation", ui->dontLoadTabsUntilSelected->isChecked());
|
||||||
settings.setValue("DefaultZoom", ui->defaultZoom->value());
|
settings.setValue("DefaultZoom", ui->defaultZoom->value());
|
||||||
settings.setValue("XSSAuditing", ui->xssAuditing->isChecked());
|
settings.setValue("XSSAuditing", ui->xssAuditing->isChecked());
|
||||||
|
settings.setValue("ignoreSystemColors", ui->ignoreSystemColors->isChecked());
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
settings.setValue("CheckDefaultBrowser", ui->checkDefaultBrowser->isChecked());
|
settings.setValue("CheckDefaultBrowser", ui->checkDefaultBrowser->isChecked());
|
||||||
#endif
|
#endif
|
||||||
|
@ -596,11 +596,11 @@
|
|||||||
<item row="9" column="0" colspan="2">
|
<item row="9" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_7">
|
<widget class="QLabel" name="label_7">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><b>Background<b/></string>
|
<string><b>Colors<b/></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="1">
|
<item row="12" column="1">
|
||||||
<spacer name="verticalSpacer_12">
|
<spacer name="verticalSpacer_12">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -641,6 +641,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="11" column="1">
|
||||||
|
<widget class="QCheckBox" name="ignoreSystemColors">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ignore system colors (for dark themes)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user