Commit 6b5a7c9a authored by Nathaniel Graham's avatar Nathaniel Graham

Custom background color

BUG: 182994

Adds an option to the config dialog that enables background color (the color around the displayed page) to be changed (while by default preserving the Qt toolkit selection as not to affect existing users).

Reasons for this change:
Accessibility, eye strain, aesthetic reasons, color displayed on monitor can affect power consumption (how: depends on display technology).
Many people want this change occording to Bugzilla and other sources.

Maintenance: Nearly no additional maintenance:
This is no new subsystem but a trivial feature with no complex code dependencies, and we are already showing a colour selection dialog and setting colours in other places in Okular.


Other less important information:

Test Plan:
Tested everything, it all works:
Toggled the custom background color, changed custom background color, removed okular settings file (with: "rm ~/.config/okular*") to verify it uses the usual qt theme colour by default (where the settings file remembered the custom color).

Reviewers: #okular, aacid, elvisangelaccio, rkflx, ngraham

Reviewed By: ngraham

Subscribers: aacid, ltoscano, ngraham

Tags: #okular

Differential Revision:
parent 24b48165
......@@ -197,7 +197,7 @@ ki18n_wrap_ui(okularcore_SRCS
kconfig_add_kcfg_files(okularcore_SRCS conf/settings_core.kcfgc )
kconfig_add_kcfg_files(okularcore_SRCS conf/settings_core.kcfgc)
add_library(okularcore SHARED ${okularcore_SRCS})
generate_export_header(okularcore BASE_NAME okularcore EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/core/okularcore_export.h")
......@@ -323,7 +323,7 @@ ki18n_wrap_ui(okularpart_SRCS
kconfig_add_kcfg_files(okularpart_SRCS conf/settings.kcfgc )
kconfig_add_kcfg_files(okularpart_SRCS conf/settings.kcfgc)
add_library(okularpart SHARED ${okularpart_SRCS})
generate_export_header(okularpart BASE_NAME okularpart)
......@@ -14,6 +14,7 @@
#include <config-okular.h>
#include "ui_dlggeneralbase.h"
#include "settings.h"
DlgGeneral::DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode )
: QWidget( parent )
......@@ -21,6 +22,8 @@ DlgGeneral::DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode )
m_dlg = new Ui_DlgGeneralBase();
m_dlg->setupUi( this );
setCustomBackgroundColorButton( Okular::Settings::useCustomBackgroundColor() );
if( embedMode == Okular::ViewerWidgetMode )
m_dlg->kcfg_SyncThumbnailsViewport->setVisible( false );
......@@ -48,3 +51,7 @@ void DlgGeneral::showEvent( QShowEvent * )
void DlgGeneral::setCustomBackgroundColorButton( bool value )
m_dlg->kcfg_BackgroundColor->setEnabled( value );
......@@ -24,6 +24,9 @@ class DlgGeneral : public QWidget
explicit DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode );
virtual ~DlgGeneral();
public slots:
void setCustomBackgroundColorButton( bool value );
void showEvent( QShowEvent * ) override;
......@@ -2,12 +2,15 @@
<ui version="4.0">
<widget class="QWidget" name="DlgGeneralBase">
<property name="enabled">
<property name="geometry">
<layout class="QVBoxLayout">
......@@ -140,6 +143,30 @@
<layout class="QGridLayout" name="gridLayout_2">
<property name="horizontalSpacing">
<property name="verticalSpacing">
<item row="1" column="1">
<widget class="KColorButton" name="kcfg_BackgroundColor">
<property name="enabled">
<item row="1" column="0">
<widget class="QCheckBox" name="kcfg_UseCustomBackgroundColor">
<property name="text">
<string>Use custom background color</string>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
......@@ -439,9 +466,39 @@ For files which were opened before the previous zoom is applied.</string>
<include location="global">kiconloader.h</include>
<hint type="sourcelabel">
<hint type="destinationlabel">
......@@ -290,6 +290,11 @@
<entry key="ShowSourceLocationsGraphically" type="Bool" >
<entry key="UseCustomBackgroundColor" type="Bool" >
<entry key="BackgroundColor" type="Color" >
<group name="Search" >
<entry key="SearchCaseSensitive" type="Bool">
......@@ -3416,7 +3416,12 @@ QList< Okular::RegularAreaRect * > PageView::textSelections( const QPoint& start
void PageView::drawDocumentOnPainter( const QRect & contentsRect, QPainter * p )
QColor backColor = viewport()->palette().color( QPalette::Dark );
QColor backColor;
if ( Okular::Settings::useCustomBackgroundColor() )
backColor = Okular::Settings::backgroundColor();
backColor = viewport()->palette().color( QPalette::Dark );
// when checking if an Item is contained in contentsRect, instead of
// growing PageViewItems rects (for keeping outline into account), we
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment