1
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:
nowrep 2013-01-31 02:08:28 +01:00
parent ccec3409c2
commit 4b2fd86fdd
4 changed files with 28 additions and 9 deletions

View File

@ -399,8 +399,10 @@ void MainApplication::loadSettings()
m_websettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, settings.value("allowJavaScriptCloseWindow", false).toBool());
#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());
m_websettings->setUserStyleSheetUrl(userStyleSheet(settings.value("userStyleSheet", QString()).toString()));
settings.endGroup();
settings.beginGroup("Browser-Fonts");
@ -834,7 +836,8 @@ void MainApplication::reloadUserStyleSheet()
{
Settings 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();
}
@ -880,11 +883,18 @@ RegisterQAppAssociation* MainApplication::associationManager()
}
#endif
QUrl MainApplication::userStyleSheet(const QString &filePath) const
QUrl MainApplication::userStyleSheet(const QString &filePath, bool ignoreSystemColors) const
{
// Set default white background for all sites
// Fixes issue with dark themes when sites don't set background
QString userStyle = "html{background-color:white;}";
QString userStyle;
if (ignoreSystemColors) {
// Set default white background for all sites
// Fixes issue with dark themes when sites don't set background
// 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;}";
QFile file(filePath);

View File

@ -148,7 +148,7 @@ private:
void translateApp();
void restoreOtherWindows();
QUrl userStyleSheet(const QString &filePath) const;
QUrl userStyleSheet(const QString &filePath, bool ignoreSystemColors) const;
CookieManager* m_cookiemanager;
BrowsingLibrary* m_browsingLibrary;

View File

@ -253,6 +253,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt());
ui->defaultZoom->setValue(settings.value("DefaultZoom", 100).toInt());
ui->xssAuditing->setChecked(settings.value("XSSAuditing", false).toBool());
ui->ignoreSystemColors->setChecked(settings.value("ignoreSystemColors", false).toBool());
//Cache
ui->pagesInCache->setValue(settings.value("maximumCachedPages", 3).toInt());
@ -898,6 +899,7 @@ void Preferences::saveSettings()
settings.setValue("LoadTabsOnActivation", ui->dontLoadTabsUntilSelected->isChecked());
settings.setValue("DefaultZoom", ui->defaultZoom->value());
settings.setValue("XSSAuditing", ui->xssAuditing->isChecked());
settings.setValue("ignoreSystemColors", ui->ignoreSystemColors->isChecked());
#ifdef Q_OS_WIN
settings.setValue("CheckDefaultBrowser", ui->checkDefaultBrowser->isChecked());
#endif

View File

@ -596,11 +596,11 @@
<item row="9" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>&lt;b&gt;Background&lt;b/&gt;</string>
<string>&lt;b&gt;Colors&lt;b/&gt;</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<spacer name="verticalSpacer_12">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -641,6 +641,13 @@
</property>
</widget>
</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>
</widget>
</widget>