Commit 1f6e8a47 authored by Albert Freeman's avatar Albert Freeman Committed by Luigi Toscano

Custom background color

Summary:
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.

{F4257766}

Other less important information:
https://git.reviewboard.kde.org/r/130219/
https://mail.kde.org/pipermail/okular-devel/2017-September/025520.html

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: https://phabricator.kde.org/D8051
parent d176914e
......@@ -197,7 +197,7 @@ ki18n_wrap_ui(okularcore_SRCS
core/chooseenginewidget.ui
)
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
conf/dlgpresentationbase.ui
)
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 * )
#endif
}
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 );
protected:
void showEvent( QShowEvent * ) override;
......
......@@ -2,12 +2,15 @@
<ui version="4.0">
<class>DlgGeneralBase</class>
<widget class="QWidget" name="DlgGeneralBase">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>558</width>
<height>575</height>
<height>632</height>
</rect>
</property>
<layout class="QVBoxLayout">
......@@ -140,6 +143,30 @@
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="KColorButton" name="kcfg_BackgroundColor">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="kcfg_UseCustomBackgroundColor">
<property name="text">
<string>Use custom background color</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
......@@ -439,9 +466,39 @@ For files which were opened before the previous zoom is applied.</string>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
<slots>
<slot>useDefaultBackgroundColor()</slot>
</slots>
</customwidget>
</customwidgets>
<includes>
<include location="global">kiconloader.h</include>
</includes>
<resources/>
<connections/>
<connections>
<connection>
<sender>kcfg_UseCustomBackgroundColor</sender>
<signal>toggled(bool)</signal>
<receiver>DlgGeneralBase</receiver>
<slot>setCustomBackgroundColorButton(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>130</x>
<y>229</y>
</hint>
<hint type="destinationlabel">
<x>203</x>
<y>-9</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>setCustomBackgroundColorButton(bool)</slot>
</slots>
</ui>
......@@ -290,6 +290,11 @@
<entry key="ShowSourceLocationsGraphically" type="Bool" >
<default>false</default>
</entry>
<entry key="UseCustomBackgroundColor" type="Bool" >
<default>false</default>
</entry>
<entry key="BackgroundColor" type="Color" >
</entry>
</group>
<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();
else
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