[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [okular] /: Custom background color
From:       Nathaniel Graham <null () kde ! org>
Date:       2017-10-01 1:45:44
Message-ID: E1dyTKC-0005hq-8o () code ! kde ! org
[Download RAW message or body]

Git commit 6b5a7c9a1a00dec994cfb03b0abf369539168758 by Nathaniel Graham.
Committed on 01/10/2017 at 01:45.
Pushed by ngraham into branch 'master'.

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

M  +2    -2    CMakeLists.txt
M  +7    -0    conf/dlggeneral.cpp
M  +3    -0    conf/dlggeneral.h
M  +59   -2    conf/dlggeneralbase.ui
M  +5    -0    conf/okular.kcfg
M  +6    -1    ui/pageview.cpp

https://commits.kde.org/okular/6b5a7c9a1a00dec994cfb03b0abf369539168758

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c5b7ac0..5b749127 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/conf/dlggeneral.cpp b/conf/dlggeneral.cpp
index 964a655b..8836566a 100644
--- a/conf/dlggeneral.cpp
+++ b/conf/dlggeneral.cpp
@@ -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 );
+}
diff --git a/conf/dlggeneral.h b/conf/dlggeneral.h
index f363d260..6939efbc 100644
--- a/conf/dlggeneral.h
+++ b/conf/dlggeneral.h
@@ -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;
 
diff --git a/conf/dlggeneralbase.ui b/conf/dlggeneralbase.ui
index cf4ebca0..089ac43c 100644
--- a/conf/dlggeneralbase.ui
+++ b/conf/dlggeneralbase.ui
@@ -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>
diff --git a/conf/okular.kcfg b/conf/okular.kcfg
index 69ea8cf6..8b2f356a 100644
--- a/conf/okular.kcfg
+++ b/conf/okular.kcfg
@@ -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">
diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index 9766422b..a9132ac0 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic