• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

kompare

  • sources
  • kde-4.14
  • kdesdk
  • kompare
  • libdialogpages
viewsettings.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  generalsettings.cpp
3  -------------------
4  begin : Sun Mar 4 2001
5  Copyright 2001-2003 Otto Bruggeman <otto.bruggeman@home.nl>
6  Copyright 2001-2003 John Firebaugh <jfirebaugh@kde.org>
7  Copyright 2007 Kevin Kofler <kevin.kofler@chello.at>
8 ****************************************************************************/
9 
10 /***************************************************************************
11 **
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License as published by
14 ** the Free Software Foundation; either version 2 of the License, or
15 ** (at your option) any later version.
16 **
17 ***************************************************************************/
18 
19 #include "viewsettings.h"
20 
21 #include <QtGui/QFont>
22 
23 #include <kconfig.h>
24 #include <kglobalsettings.h>
25 #include <kconfiggroup.h>
26 
27 using namespace Diff2;
28 
29 const QColor ViewSettings::default_removeColor (190, 237, 190);
30 const QColor ViewSettings::default_changeColor (237, 190, 190);
31 const QColor ViewSettings::default_addColor (190, 190, 237);
32 const QColor ViewSettings::default_appliedColor(237, 237, 190);
33 
34 ViewSettings::ViewSettings( QWidget* parent )
35  : SettingsBase( parent ),
36  m_removeColor( 0, 0, 0 ),
37  m_changeColor( 0, 0, 0),
38  m_addColor( 0, 0, 0),
39  m_appliedColor( 0, 0, 0),
40  m_scrollNoOfLines( 0 ),
41  m_tabToNumberOfSpaces( 0 )
42 {
43 }
44 
45 ViewSettings::~ViewSettings()
46 {
47 }
48 
49 void ViewSettings::loadSettings( KConfig* config )
50 {
51  KConfigGroup cfg( config, "View Options" );
52  m_removeColor = cfg.readEntry( "RemoveColor", default_removeColor );
53  m_changeColor = cfg.readEntry( "ChangeColor", default_changeColor );
54  m_addColor = cfg.readEntry( "AddColor", default_addColor );
55  m_appliedColor = cfg.readEntry( "AppliedColor", default_appliedColor );
56  m_scrollNoOfLines = cfg.readEntry ( "ScrollNoOfLines", 3 );
57  m_tabToNumberOfSpaces = cfg.readEntry ( "TabToNumberOfSpaces", 4 );
58 
59  QFont stdFixed = KGlobalSettings::fixedFont();
60  stdFixed.setPointSize( 10 );
61  m_font = cfg.readEntry ( "TextFont", stdFixed );
62 }
63 
64 void ViewSettings::saveSettings( KConfig* config )
65 {
66  KConfigGroup cfg( config, "View Options" );
67  cfg.writeEntry( "RemoveColor", m_removeColor );
68  cfg.writeEntry( "ChangeColor", m_changeColor );
69  cfg.writeEntry( "AddColor", m_addColor );
70  cfg.writeEntry( "AppliedColor", m_appliedColor );
71  cfg.writeEntry( "ScrollNoOfLines", m_scrollNoOfLines );
72  cfg.writeEntry( "TabToNumberOfSpaces", m_tabToNumberOfSpaces );
73 
74  cfg.writeEntry( "TextFont", m_font );
75 }
76 
77 QColor ViewSettings::colorForDifferenceType( int type, bool selected, bool applied )
78 {
79  // FIXME: does not belong here
80  QColor color;
81  if( applied )
82  color = m_appliedColor;
83  else
84  {
85  type = type & 0xFFFFFFEF; // remove the AppliedByBlend
86  switch( type ) {
87  case Difference::Unchanged: color = Qt::white; break;
88  case Difference::Change: color = m_changeColor; break;
89  case Difference::Insert: color = m_addColor; break;
90  case Difference::Delete: color = m_removeColor; break;
91  default: break;
92  }
93  }
94 
95  if( selected )
96  color = color.light( 110 );
97 
98  return color;
99 }
100 
101 #include "viewsettings.moc"
ViewSettings::default_changeColor
static const QColor default_changeColor
Definition: viewsettings.h:34
QWidget
QFont::setPointSize
void setPointSize(int pointSize)
QColor::light
QColor light(int factor) const
ViewSettings::m_scrollNoOfLines
int m_scrollNoOfLines
Definition: viewsettings.h:55
QFont
ViewSettings::m_removeColor
QColor m_removeColor
Definition: viewsettings.h:47
ViewSettings::m_tabToNumberOfSpaces
int m_tabToNumberOfSpaces
Definition: viewsettings.h:56
ViewSettings::default_appliedColor
static const QColor default_appliedColor
Definition: viewsettings.h:36
ViewSettings::default_addColor
static const QColor default_addColor
Definition: viewsettings.h:35
ViewSettings::loadSettings
virtual void loadSettings(KConfig *config)
Definition: viewsettings.cpp:49
QColor
ViewSettings::m_changeColor
QColor m_changeColor
Definition: viewsettings.h:48
ViewSettings::m_appliedColor
QColor m_appliedColor
Definition: viewsettings.h:50
ViewSettings::colorForDifferenceType
QColor colorForDifferenceType(int type, bool selected=false, bool applied=false)
Definition: viewsettings.cpp:77
ViewSettings::m_font
QFont m_font
Definition: viewsettings.h:58
viewsettings.h
ViewSettings::saveSettings
virtual void saveSettings(KConfig *config)
Definition: viewsettings.cpp:64
ViewSettings::~ViewSettings
~ViewSettings()
Definition: viewsettings.cpp:45
ViewSettings::m_addColor
QColor m_addColor
Definition: viewsettings.h:49
ViewSettings::ViewSettings
ViewSettings(QWidget *parent)
Definition: viewsettings.cpp:34
ViewSettings::default_removeColor
static const QColor default_removeColor
Definition: viewsettings.h:33
SettingsBase
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:40:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kompare

Skip menu "kompare"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal