OSDN Git Service

display font size
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sun, 4 Jan 2004 11:17:30 +0000 (11:17 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sun, 4 Jan 2004 11:17:30 +0000 (11:17 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@783 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/pref.cpp
kita/src/pref.h

index 0422e4a..bfe57be 100644 (file)
@@ -1,12 +1,12 @@
 /***************************************************************************
- *   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( QWidgetparent )
+        : 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() );
@@ -99,7 +106,7 @@ KitaColorPrefPage::KitaColorPrefPage( QWidget *parent )
     colorList->insertItem( popupBackPixmap, i18n( "popup background" ) );
 
     connect( changeButton, SIGNAL( clicked() ),
-                           SLOT( slotChangeButtonClicked() ) );
+             SLOT( slotChangeButtonClicked() ) );
 }
 
 void KitaColorPrefPage::slotChangeButtonClicked()
@@ -107,44 +114,44 @@ 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 ;
     }
 }
 
index e3cef55..9bf5d1e 100644 (file)
@@ -1,12 +1,12 @@
 /***************************************************************************
- *   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_
@@ -28,12 +28,12 @@ public:
     KitaPreferences();
 
 private:
-    KitaFontPrefPage *m_fontPage;
-    KitaColorPrefPage *m_colorPage;
+    KitaFontPrefPagem_fontPage;
+    KitaColorPrefPagem_colorPage;
 
 signals:
-  void fontChanged( const QFont& );
-  void threadFontChanged( const QFont& );
+    void fontChanged( const QFont& );
+    void threadFontChanged( const QFont& );
 };
 
 class KitaFontPrefPage : public KitaFontPrefBase
@@ -41,15 +41,18 @@ class KitaFontPrefPage : public KitaFontPrefBase
     Q_OBJECT
 
 public:
-    KitaFontPrefPage( QWidget *parent = 0 );
+    KitaFontPrefPage( QWidgetparent = 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
@@ -57,7 +60,7 @@ class KitaColorPrefPage : public KitaColorPrefBase
     Q_OBJECT
 
 public:
-    KitaColorPrefPage( QWidget *parent = 0 );
+    KitaColorPrefPage( QWidgetparent = 0 );
 
 public slots:
     void slotChangeButtonClicked();