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.
202 lines
5.5 KiB
202 lines
5.5 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 <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqlistbox.h>
|
||
|
#include <tqpixmap.h>
|
||
|
#include <tqpushbutton.h>
|
||
|
#include <tqspinbox.h>
|
||
|
#include <tqtabwidget.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeaccelmanager.h>
|
||
15 years ago
|
#include <kcolorbutton.h>
|
||
|
#include <kcolordialog.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
|
#include "StyleSettings.h"
|
||
|
|
||
14 years ago
|
StyleSettings::StyleSettings( TQWidget *parent, const char *name )
|
||
15 years ago
|
: KDialogBase( Tabbed, i18n( "Global Style Settings" ), Help | Ok | Apply |
|
||
|
Cancel, Ok, parent, name, true, true )
|
||
|
{
|
||
14 years ago
|
TQFrame *page = addPage( i18n( "Display Style" ) );
|
||
14 years ago
|
TQGridLayout *layout = new TQGridLayout( page, 6, 2, 0, spacingHint() );
|
||
15 years ago
|
|
||
14 years ago
|
TQLabel *label = new TQLabel( i18n( "First foreground color:" ), page );
|
||
14 years ago
|
layout->addWidget( label, 0, 0 );
|
||
15 years ago
|
|
||
|
mFirstForegroundColor = new KColorButton( page );
|
||
14 years ago
|
layout->addWidget( mFirstForegroundColor, 0, 1 );
|
||
15 years ago
|
label->setBuddy( mFirstForegroundColor );
|
||
|
|
||
14 years ago
|
label = new TQLabel( i18n( "Second foreground color:" ), page );
|
||
14 years ago
|
layout->addWidget( label, 1, 0 );
|
||
15 years ago
|
|
||
|
mSecondForegroundColor = new KColorButton( page );
|
||
14 years ago
|
layout->addWidget( mSecondForegroundColor, 1, 1 );
|
||
15 years ago
|
label->setBuddy( mSecondForegroundColor );
|
||
|
|
||
14 years ago
|
label = new TQLabel( i18n( "Alarm color:" ), page );
|
||
14 years ago
|
layout->addWidget( label, 2, 0 );
|
||
15 years ago
|
|
||
|
mAlarmColor = new KColorButton( page );
|
||
14 years ago
|
layout->addWidget( mAlarmColor, 2, 1 );
|
||
15 years ago
|
label->setBuddy( mAlarmColor );
|
||
|
|
||
14 years ago
|
label = new TQLabel( i18n( "Background color:" ), page );
|
||
14 years ago
|
layout->addWidget( label, 3, 0 );
|
||
15 years ago
|
|
||
|
mBackgroundColor = new KColorButton( page );
|
||
14 years ago
|
layout->addWidget( mBackgroundColor, 3, 1 );
|
||
15 years ago
|
label->setBuddy( mBackgroundColor );
|
||
|
|
||
14 years ago
|
label = new TQLabel( i18n( "Font size:" ), page );
|
||
14 years ago
|
layout->addWidget( label, 4, 0 );
|
||
15 years ago
|
|
||
14 years ago
|
mFontSize = new TQSpinBox( 7, 48, 1, page );
|
||
15 years ago
|
mFontSize->setValue( 8 );
|
||
14 years ago
|
layout->addWidget( mFontSize, 4, 1 );
|
||
15 years ago
|
label->setBuddy( mFontSize );
|
||
|
|
||
14 years ago
|
layout->setRowStretch( 5, 1 );
|
||
15 years ago
|
|
||
|
page = addPage( i18n( "Sensor Colors" ) );
|
||
14 years ago
|
layout = new TQGridLayout( page, 1, 2, 0, spacingHint() );
|
||
15 years ago
|
|
||
14 years ago
|
mColorListBox = new TQListBox( page );
|
||
14 years ago
|
layout->addWidget( mColorListBox, 0, 0 );
|
||
15 years ago
|
|
||
14 years ago
|
mEditColorButton = new TQPushButton( i18n( "Change Color..." ), page );
|
||
15 years ago
|
mEditColorButton->setEnabled( false );
|
||
14 years ago
|
layout->addWidget( mEditColorButton, 0, 1, Qt::AlignTop );
|
||
15 years ago
|
|
||
14 years ago
|
connect( mColorListBox, TQT_SIGNAL( selectionChanged( TQListBoxItem* ) ),
|
||
|
TQT_SLOT( selectionChanged( TQListBoxItem* ) ) );
|
||
|
connect( mColorListBox, TQT_SIGNAL( doubleClicked( TQListBoxItem* ) ),
|
||
|
TQT_SLOT( editSensorColor() ) );
|
||
|
connect( mEditColorButton, TQT_SIGNAL( clicked() ),
|
||
|
TQT_SLOT( editSensorColor() ) );
|
||
15 years ago
|
|
||
12 years ago
|
TDEAcceleratorManager::manage( this );
|
||
15 years ago
|
}
|
||
|
|
||
|
StyleSettings::~StyleSettings()
|
||
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
void StyleSettings::setFirstForegroundColor( const TQColor &color )
|
||
15 years ago
|
{
|
||
|
mFirstForegroundColor->setColor( color );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQColor StyleSettings::firstForegroundColor() const
|
||
15 years ago
|
{
|
||
|
return mFirstForegroundColor->color();
|
||
|
}
|
||
|
|
||
14 years ago
|
void StyleSettings::setSecondForegroundColor( const TQColor &color )
|
||
15 years ago
|
{
|
||
|
mSecondForegroundColor->setColor( color );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQColor StyleSettings::secondForegroundColor() const
|
||
15 years ago
|
{
|
||
|
return mSecondForegroundColor->color();
|
||
|
}
|
||
|
|
||
14 years ago
|
void StyleSettings::setAlarmColor( const TQColor &color )
|
||
15 years ago
|
{
|
||
|
mAlarmColor->setColor( color );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQColor StyleSettings::alarmColor() const
|
||
15 years ago
|
{
|
||
|
return mAlarmColor->color();
|
||
|
}
|
||
|
|
||
14 years ago
|
void StyleSettings::setBackgroundColor( const TQColor &color )
|
||
15 years ago
|
{
|
||
|
mBackgroundColor->setColor( color );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQColor StyleSettings::backgroundColor() const
|
||
15 years ago
|
{
|
||
|
return mBackgroundColor->color();
|
||
|
}
|
||
|
|
||
|
void StyleSettings::setFontSize( uint size )
|
||
|
{
|
||
|
mFontSize->setValue( size );
|
||
|
}
|
||
|
|
||
|
uint StyleSettings::fontSize() const
|
||
|
{
|
||
|
return mFontSize->value();
|
||
|
}
|
||
|
|
||
14 years ago
|
void StyleSettings::setSensorColors( const TQValueList<TQColor> &list )
|
||
15 years ago
|
{
|
||
|
mColorListBox->clear();
|
||
|
|
||
|
for ( uint i = 0; i < list.count(); ++i ) {
|
||
14 years ago
|
TQPixmap pm( 12, 12 );
|
||
13 years ago
|
pm.fill( *list.at( i ) );
|
||
15 years ago
|
mColorListBox->insertItem( pm, i18n( "Color %1" ).arg( i ) );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
TQValueList<TQColor> StyleSettings::sensorColors()
|
||
15 years ago
|
{
|
||
14 years ago
|
TQValueList<TQColor> list;
|
||
15 years ago
|
|
||
|
for ( uint i = 0; i < mColorListBox->count(); ++i )
|
||
14 years ago
|
list.append( TQColor( mColorListBox->pixmap( i )->convertToImage().pixel( 1, 1 ) ) );
|
||
15 years ago
|
|
||
|
return list;
|
||
|
}
|
||
|
|
||
|
void StyleSettings::editSensorColor()
|
||
|
{
|
||
|
int pos = mColorListBox->currentItem();
|
||
|
|
||
|
if ( pos < 0 )
|
||
|
return;
|
||
|
|
||
14 years ago
|
TQColor color = mColorListBox->pixmap( pos )->convertToImage().pixel( 1, 1 );
|
||
15 years ago
|
|
||
|
if ( KColorDialog::getColor( color ) == KColorDialog::Accepted ) {
|
||
14 years ago
|
TQPixmap pm( 12, 12 );
|
||
15 years ago
|
pm.fill( color );
|
||
|
mColorListBox->changeItem( pm, mColorListBox->text( pos ), pos );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void StyleSettings::selectionChanged( TQListBoxItem *item )
|
||
15 years ago
|
{
|
||
|
mEditColorButton->setEnabled( item != 0 );
|
||
|
}
|
||
|
|
||
|
#include "StyleSettings.moc"
|