/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#include "pref.h"
#include "kitaconfig.h"
KitaPreferences::KitaPreferences()
- : KDialogBase(TreeList, i18n("Kita Preferences"),
- Help|Default|Ok|Apply|Cancel, Ok)
+ : KDialogBase( TreeList, i18n( "Kita Preferences" ),
+ Help | Default | Ok | Apply | Cancel, Ok )
{
// this is the base class for your preferences dialog. it is now
// a Treelist dialog.. but there are a number of other
// possibilities (including Tab, Swallow, and just Plain)
- QFrame* fontFrame = addPage( i18n( "Font" ), i18n( "Font" ) );
+ QFrame * fontFrame = addPage( i18n( "Font" ), i18n( "Font" ) );
m_fontPage = new KitaFontPrefPage( fontFrame );
connect( m_fontPage, SIGNAL( fontChanged( const QFont& ) ),
- SIGNAL( fontChanged( const QFont& ) ) );
+ SIGNAL( fontChanged( const QFont& ) ) );
connect( m_fontPage, SIGNAL( threadFontChanged( const QFont& ) ),
- SIGNAL( threadFontChanged( const QFont& ) ) );
+ SIGNAL( threadFontChanged( const QFont& ) ) );
- QFrame* colorFrame = addPage( i18n( "Color" ), i18n( "Color" ) );
+ QFrame * colorFrame = addPage( i18n( "Color" ), i18n( "Color" ) );
m_colorPage = new KitaColorPrefPage( colorFrame );
}
-KitaFontPrefPage::KitaFontPrefPage( QWidget *parent )
- : KitaFontPrefBase(parent)
+KitaFontPrefPage::KitaFontPrefPage( QWidget* parent )
+ : KitaFontPrefBase( parent )
{
- fontButton->setText(KitaConfig::font().family());
- fontButton->setFont(KitaConfig::font());
- connect(fontButton, SIGNAL(clicked()), SLOT(slotFontButtonClicked()));
-
- threadFontButton->setText( KitaConfig::threadFont().family() );
- threadFontButton->setFont( KitaConfig::threadFont() );
- connect( threadFontButton, SIGNAL( clicked() ),
- SLOT( slotThreadFontButtonClicked() ) );
+ connect( fontButton, SIGNAL( clicked() ), SLOT( slotFontButtonClicked() ) );
+
+ connect( threadFontButton, SIGNAL( clicked() ),
+ SLOT( slotThreadFontButtonClicked() ) );
+
+ updateButtons();
}
void KitaFontPrefPage::slotFontButtonClicked()
{
- QFont font = fontButton->font();
+ QFont font = fontButton->font();
- if( KFontDialog::getFont(font, false, this) == QDialog::Accepted ) {
- fontButton->setText(font.family());
- fontButton->setFont(font);
- emit fontChanged(font);
- }
+ if ( KFontDialog::getFont( font, false, this ) == QDialog::Accepted ) {
+ emit fontChanged( font );
+ }
+ updateButtons();
}
void KitaFontPrefPage::slotThreadFontButtonClicked()
{
- QFont font = threadFontButton->font();
+ QFont font = threadFontButton->font();
+
+ if ( KFontDialog::getFont( font, false, this ) == QDialog::Accepted ) {
+ emit threadFontChanged( font );
+ }
+ updateButtons();
+}
+
+void KitaFontPrefPage::updateButtons()
+{
+ QFont font = KitaConfig::font();
+ fontButton->setText( font.family() + " " + QString::number( font.pointSize() ) );
+ fontButton->setFont( font );
- if( KFontDialog::getFont( font, false, this ) == QDialog::Accepted ) {
- threadFontButton->setText( font.family() );
- threadFontButton->setFont( font );
- emit threadFontChanged( font );
- }
+ QFont threadFont = KitaConfig::threadFont();
+ threadFontButton->setText( threadFont.family() + " " + QString::number( threadFont.pointSize() ) );
+ threadFontButton->setFont( threadFont );
}
KitaColorPrefPage::KitaColorPrefPage( QWidget *parent )
- : KitaColorPrefBase(parent)
+ : KitaColorPrefBase( parent )
{
// FIXME: refactoring.
-/* QPixmap textPixmap( 30, 10 );
- textPixmap.fill( Qt::black );
- colorList->insertItem( textPixmap, "text" );
+ /* QPixmap textPixmap( 30, 10 );
+ textPixmap.fill( Qt::black );
+ colorList->insertItem( textPixmap, "text" );
- QPixmap backPixmap( 30, 10 );
- backPixmap.fill( Qt::white );
- colorList->insertItem( backPixmap, "background" );*/
+ QPixmap backPixmap( 30, 10 );
+ backPixmap.fill( Qt::white );
+ colorList->insertItem( backPixmap, "background" );*/
QPixmap popupTextPixmap( 30, 10 );
popupTextPixmap.fill( KitaConfig::popupColor() );
colorList->insertItem( popupBackPixmap, i18n( "popup background" ) );
connect( changeButton, SIGNAL( clicked() ),
- SLOT( slotChangeButtonClicked() ) );
+ SLOT( slotChangeButtonClicked() ) );
}
void KitaColorPrefPage::slotChangeButtonClicked()
int index = colorList->currentItem();
if ( index == -1 ) {
- return;
+ return ;
}
QColor newColor;
QColor defaultColor;
// FIXME: refactoring.
- switch( index ) {
- case 0:
- defaultColor = KitaConfig::popupColor();
- break;
- case 1:
- defaultColor = KitaConfig::popupBackgroundColor();
- break;
- default:
- return;
+ switch ( index ) {
+ case 0:
+ defaultColor = KitaConfig::popupColor();
+ break;
+ case 1:
+ defaultColor = KitaConfig::popupBackgroundColor();
+ break;
+ default:
+ return ;
}
int result = KColorDialog::getColor( newColor, defaultColor );
if ( result == KColorDialog::Rejected ) {
- return;
+ return ;
}
QPixmap newPixmap( 30, 10 );
// FIXME: refactoring.
- switch( index ) {
- case 0:
- KitaConfig::setPopupColor( newColor );
- newPixmap.fill( newColor );
- colorList->changeItem( newPixmap, i18n( "popup text" ), index );
- break;
- case 1:
- KitaConfig::setPopupBackgroundColor( newColor );
- newPixmap.fill( newColor );
- colorList->changeItem( newPixmap, i18n( "popup background" ), index );
- break;
- default:
- return;
+ switch ( index ) {
+ case 0:
+ KitaConfig::setPopupColor( newColor );
+ newPixmap.fill( newColor );
+ colorList->changeItem( newPixmap, i18n( "popup text" ), index );
+ break;
+ case 1:
+ KitaConfig::setPopupBackgroundColor( newColor );
+ newPixmap.fill( newColor );
+ colorList->changeItem( newPixmap, i18n( "popup background" ), index );
+ break;
+ default:
+ return ;
}
}
/***************************************************************************
- * Copyright (C) 2003 by Hideki Ikemoto *
- * ikemo@users.sourceforge.jp *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
+* Copyright (C) 2003 by Hideki Ikemoto *
+* ikemo@users.sourceforge.jp *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
#ifndef _KITAPREF_H_
#define _KITAPREF_H_
KitaPreferences();
private:
- KitaFontPrefPage *m_fontPage;
- KitaColorPrefPage *m_colorPage;
+ KitaFontPrefPage* m_fontPage;
+ KitaColorPrefPage* m_colorPage;
signals:
- void fontChanged( const QFont& );
- void threadFontChanged( const QFont& );
+ void fontChanged( const QFont& );
+ void threadFontChanged( const QFont& );
};
class KitaFontPrefPage : public KitaFontPrefBase
Q_OBJECT
public:
- KitaFontPrefPage( QWidget *parent = 0 );
+ KitaFontPrefPage( QWidget* parent = 0 );
public slots:
- void slotFontButtonClicked();
- void slotThreadFontButtonClicked();
+ void slotFontButtonClicked();
+ void slotThreadFontButtonClicked();
+
+private:
+ void updateButtons();
signals:
- void fontChanged( const QFont& );
- void threadFontChanged( const QFont & );
+ void fontChanged( const QFont& );
+ void threadFontChanged( const QFont& );
};
class KitaColorPrefPage : public KitaColorPrefBase
Q_OBJECT
public:
- KitaColorPrefPage( QWidget *parent = 0 );
+ KitaColorPrefPage( QWidget* parent = 0 );
public slots:
void slotChangeButtonClicked();