You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
4.8 KiB
177 lines
4.8 KiB
15 years ago
|
/*
|
||
|
KSysGuard, the KDE System Guard
|
||
|
|
||
|
Copyright (c) 1999 - 2001 Chris Schlaeger <cs@kde.org>
|
||
|
|
||
|
This program is free software; you can redistribute it and/or
|
||
|
modify it under the terms of version 2 of the GNU General Public
|
||
|
License as published by the Free Software Foundation.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this program; if not, write to the Free Software
|
||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
|
||
|
KSysGuard is currently maintained by Chris Schlaeger <cs@kde.org>.
|
||
|
Please do not commit any changes without consulting me first. Thanks!
|
||
|
|
||
|
*/
|
||
|
|
||
14 years ago
|
#include <tqimage.h>
|
||
|
#include <tqpushbutton.h>
|
||
|
#include <tqspinbox.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
|
#include "StyleSettings.h"
|
||
|
|
||
|
#include "StyleEngine.h"
|
||
|
|
||
|
using namespace KSGRD;
|
||
|
|
||
|
StyleEngine* KSGRD::Style;
|
||
|
|
||
|
StyleEngine::StyleEngine()
|
||
|
{
|
||
14 years ago
|
mFirstForegroundColor = TQColor( 0x6894c9 ); // light blue
|
||
|
mSecondForegroundColor = TQColor( 0x6894c9 ); // light blue
|
||
|
mAlarmColor = TQColor( 255, 0, 0 );
|
||
|
mBackgroundColor = TQColor( 0x313031 ); // almost black
|
||
15 years ago
|
mFontSize = 9;
|
||
|
|
||
14 years ago
|
mSensorColors.append( TQColor( 0x1889ff ) ); // soft blue
|
||
|
mSensorColors.append( TQColor( 0xff7f08 ) ); // reddish
|
||
|
mSensorColors.append( TQColor( 0xffeb14 ) ); // bright yellow
|
||
15 years ago
|
|
||
|
uint v = 0x00ff00;
|
||
|
for ( uint i = mSensorColors.count(); i < 32; ++i ) {
|
||
|
v = ( ( ( v + 82 ) & 0xff ) << 23 ) | ( v >> 8 );
|
||
14 years ago
|
mSensorColors.append( TQColor( v & 0xff, ( v >> 16 ) & 0xff, ( v >> 8 ) & 0xff ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
StyleEngine::~StyleEngine()
|
||
|
{
|
||
|
}
|
||
|
|
||
12 years ago
|
void StyleEngine::readProperties( TDEConfig *cfg )
|
||
15 years ago
|
{
|
||
|
mFirstForegroundColor = cfg->readColorEntry( "fgColor1", &mFirstForegroundColor );
|
||
|
mSecondForegroundColor = cfg->readColorEntry( "fgColor2", &mSecondForegroundColor );
|
||
|
mAlarmColor = cfg->readColorEntry( "alarmColor", &mAlarmColor );
|
||
|
mBackgroundColor = cfg->readColorEntry( "backgroundColor", &mBackgroundColor );
|
||
|
mFontSize = cfg->readNumEntry( "fontSize", mFontSize );
|
||
|
|
||
14 years ago
|
TQStringList list = cfg->readListEntry( "sensorColors" );
|
||
15 years ago
|
if ( !list.isEmpty() ) {
|
||
|
mSensorColors.clear();
|
||
14 years ago
|
TQStringList::Iterator it;
|
||
15 years ago
|
for ( it = list.begin(); it != list.end(); ++it )
|
||
14 years ago
|
mSensorColors.append( TQColor( *it ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
void StyleEngine::saveProperties( TDEConfig *cfg )
|
||
15 years ago
|
{
|
||
|
cfg->writeEntry( "fgColor1", mFirstForegroundColor );
|
||
|
cfg->writeEntry( "fgColor2", mSecondForegroundColor );
|
||
|
cfg->writeEntry( "alarmColor", mAlarmColor );
|
||
|
cfg->writeEntry( "backgroundColor", mBackgroundColor );
|
||
|
cfg->writeEntry( "fontSize", mFontSize );
|
||
|
|
||
14 years ago
|
TQStringList list;
|
||
|
TQValueList<TQColor>::Iterator it;
|
||
15 years ago
|
for ( it = mSensorColors.begin(); it != mSensorColors.end(); ++it )
|
||
|
list.append( (*it).name() );
|
||
|
|
||
|
cfg->writeEntry( "sensorColors", list );
|
||
|
}
|
||
|
|
||
14 years ago
|
const TQColor &StyleEngine::firstForegroundColor() const
|
||
15 years ago
|
{
|
||
|
return mFirstForegroundColor;
|
||
|
}
|
||
|
|
||
14 years ago
|
const TQColor &StyleEngine::secondForegroundColor() const
|
||
15 years ago
|
{
|
||
|
return mSecondForegroundColor;
|
||
|
}
|
||
|
|
||
14 years ago
|
const TQColor &StyleEngine::alarmColor() const
|
||
15 years ago
|
{
|
||
|
return mAlarmColor;
|
||
|
}
|
||
|
|
||
14 years ago
|
const TQColor &StyleEngine::backgroundColor() const
|
||
15 years ago
|
{
|
||
|
return mBackgroundColor;
|
||
|
}
|
||
|
|
||
|
uint StyleEngine::fontSize() const
|
||
|
{
|
||
|
return mFontSize;
|
||
|
}
|
||
|
|
||
14 years ago
|
const TQColor& StyleEngine::sensorColor( uint pos )
|
||
15 years ago
|
{
|
||
14 years ago
|
static TQColor dummy;
|
||
15 years ago
|
|
||
|
if ( pos < mSensorColors.count() )
|
||
13 years ago
|
return *mSensorColors.at( pos );
|
||
15 years ago
|
else
|
||
|
return dummy;
|
||
|
}
|
||
|
|
||
|
uint StyleEngine::numSensorColors() const
|
||
|
{
|
||
|
return mSensorColors.count();
|
||
|
}
|
||
|
|
||
|
void StyleEngine::configure()
|
||
|
{
|
||
|
mSettingsDialog = new StyleSettings( 0 );
|
||
|
|
||
|
mSettingsDialog->setFirstForegroundColor( mFirstForegroundColor );
|
||
|
mSettingsDialog->setSecondForegroundColor( mSecondForegroundColor );
|
||
|
mSettingsDialog->setAlarmColor( mAlarmColor );
|
||
|
mSettingsDialog->setBackgroundColor( mBackgroundColor );
|
||
|
mSettingsDialog->setFontSize( mFontSize );
|
||
|
mSettingsDialog->setSensorColors( mSensorColors );
|
||
|
|
||
14 years ago
|
connect( mSettingsDialog, TQT_SIGNAL( applyClicked() ),
|
||
|
this, TQT_SLOT( applyToWorksheet() ) );
|
||
15 years ago
|
|
||
|
if ( mSettingsDialog->exec() )
|
||
|
apply();
|
||
|
|
||
|
delete mSettingsDialog;
|
||
|
mSettingsDialog = 0;
|
||
|
}
|
||
|
|
||
|
void StyleEngine::applyToWorksheet()
|
||
|
{
|
||
|
apply();
|
||
|
emit applyStyleToWorksheet();
|
||
|
}
|
||
|
|
||
|
void StyleEngine::apply()
|
||
|
{
|
||
|
if ( !mSettingsDialog )
|
||
|
return;
|
||
|
|
||
|
mFirstForegroundColor = mSettingsDialog->firstForegroundColor();
|
||
|
mSecondForegroundColor = mSettingsDialog->secondForegroundColor();
|
||
|
mAlarmColor = mSettingsDialog->alarmColor();
|
||
|
mBackgroundColor = mSettingsDialog->backgroundColor();
|
||
|
mFontSize = mSettingsDialog->fontSize();
|
||
|
|
||
|
mSensorColors = mSettingsDialog->sensorColors();
|
||
|
}
|
||
|
|
||
|
#include "StyleEngine.moc"
|