~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to ksysguard/gui/StyleEngine.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    KSysGuard, the KDE System Guard
 
3
 
 
4
    Copyright (c) 1999 - 2001 Chris Schlaeger <cs@kde.org>
 
5
 
 
6
    This program is free software; you can redistribute it and/or
 
7
    modify it under the terms of the GNU General Public
 
8
    License version 2 or at your option version 3 as published by
 
9
    the Free Software Foundation.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 
 
20
*/
 
21
 
 
22
#include <QImage>
 
23
#include <QPushButton>
 
24
#include <QSpinBox>
 
25
 
 
26
#include <kconfig.h>
 
27
#include <kconfiggroup.h>
 
28
#include <klocale.h>
 
29
#include <QList>
 
30
 
 
31
#include "StyleEngine.h"
 
32
using namespace KSGRD;
 
33
 
 
34
StyleEngine* KSGRD::Style;
 
35
 
 
36
StyleEngine::StyleEngine(QObject * parent) : QObject(parent)
 
37
{
 
38
  mFirstForegroundColor = QColor( 0x888888 );  // Gray
 
39
  mSecondForegroundColor = QColor( 0x888888 ); // Gray
 
40
  mAlarmColor = QColor( 255, 0, 0 );
 
41
  mBackgroundColor = Qt::white;       // white
 
42
  mFontSize = 8;
 
43
 
 
44
  mSensorColors.append( QColor( 0x0057ae ) );  // soft blue
 
45
  mSensorColors.append( QColor( 0xe20800 ) );  // reddish
 
46
  mSensorColors.append( QColor( 0xf3c300 ) );  // bright yellow
 
47
 
 
48
  uint v = 0x00ff00;
 
49
  for ( uint i = mSensorColors.count(); i < 32; ++i ) {
 
50
    v = ( ( ( v + 82 ) & 0xff ) << 23 ) | ( v >> 8 );
 
51
    mSensorColors.append( QColor( v & 0xff, ( v >> 16 ) & 0xff, ( v >> 8 ) & 0xff ) );
 
52
  }
 
53
}
 
54
 
 
55
StyleEngine::~StyleEngine()
 
56
{
 
57
}
 
58
 
 
59
void StyleEngine::readProperties( const KConfigGroup& cfg )
 
60
{
 
61
  mFirstForegroundColor = cfg.readEntry( "fgColor1", mFirstForegroundColor );
 
62
  mSecondForegroundColor = cfg.readEntry( "fgColor2", mSecondForegroundColor );
 
63
  mAlarmColor = cfg.readEntry( "alarmColor", mAlarmColor );
 
64
  mBackgroundColor = cfg.readEntry( "backgroundColor", mBackgroundColor );
 
65
  mFontSize = cfg.readEntry( "fontSize", mFontSize );
 
66
 
 
67
  QStringList list = cfg.readEntry( "sensorColors",QStringList() );
 
68
  if ( !list.isEmpty() ) {
 
69
    mSensorColors.clear();
 
70
    QStringList::Iterator it;
 
71
    for ( it = list.begin(); it != list.end(); ++it )
 
72
      mSensorColors.append( QColor( *it ) );
 
73
  }
 
74
}
 
75
 
 
76
void StyleEngine::saveProperties( KConfigGroup& )
 
77
{
 
78
}
 
79
 
 
80
const QColor &StyleEngine::firstForegroundColor() const
 
81
{
 
82
  return mFirstForegroundColor;
 
83
}
 
84
 
 
85
const QColor &StyleEngine::secondForegroundColor() const
 
86
{
 
87
  return mSecondForegroundColor;
 
88
}
 
89
 
 
90
const QColor &StyleEngine::alarmColor() const
 
91
{
 
92
  return mAlarmColor;
 
93
}
 
94
 
 
95
const QColor &StyleEngine::backgroundColor() const
 
96
{
 
97
  return mBackgroundColor;
 
98
}
 
99
 
 
100
uint StyleEngine::fontSize() const
 
101
{
 
102
  return mFontSize;
 
103
}
 
104
 
 
105
const QColor& StyleEngine::sensorColor( int pos )
 
106
{
 
107
  static QColor dummy;
 
108
 
 
109
  if ( pos < mSensorColors.count() )
 
110
    return mSensorColors.at( pos );
 
111
  else
 
112
    return dummy;
 
113
}
 
114
 
 
115
uint StyleEngine::numSensorColors() const
 
116
{
 
117
  return mSensorColors.count();
 
118
}
 
119
 
 
120
#include "StyleEngine.moc"