+++ /dev/null
-/***************************************************************************
-* 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 "prefs.h"
-
-#include <klocale.h>
-#include <kfontdialog.h>
-#include <kcolordialog.h>
-#include <kpushbutton.h>
-#include <ktextedit.h>
-#include <kcolorbutton.h>
-#include <kurllabel.h>
-#include <kmessagebox.h>
-#include <kapplication.h>
-#include <kiconloader.h>
-
-#include <qlayout.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qlistbox.h>
-#include <qmessagebox.h>
-#include <qcheckbox.h>
-#include <qspinbox.h>
-#include <qbuttongroup.h>
-#include <qvbox.h>
-
-#include "libkita/kita_misc.h"
-#include "libkita/boardmanager.h"
-#include "libkita/config_xt.h"
-#include "libkita/asciiart.h"
-#include "aboneprefpage.h"
-#include "login_page.h"
-#include "write_page.h"
-
-using namespace Kita;
-
-KitaPreferences::KitaPreferences( QWidget* parent )
- : KConfigDialog( parent, "Kita Preferences", Kita::Config::self(), IconList )
-{
- enableButtonApply( FALSE );
- enableButton( Help, FALSE );
- // 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)
-
- m_facePage = new Kita::FacePrefPage( 0 );
- addPage( m_facePage, i18n( "Face" ), "view_detailed" );
-
- connect( m_facePage, SIGNAL( fontChanged( const QFont& ) ),
- SIGNAL( fontChanged( const QFont& ) ) );
-
- m_asciiArtPage = new Kita::AsciiArtPrefPage( 0 );
- addPage( m_asciiArtPage, i18n( "AsciiArt" ), "kita" );
-
- m_uiPage = new Kita::UIPrefPage( 0 );
- addPage( m_uiPage, i18n( "User Interface" ), "configure" );
-
- m_abonePage = new Kita::AbonePrefPage( 0 );
- addPage( m_abonePage, i18n( "Abone" ), "kita" );
-
- m_loginPage = new Kita::LoginPrefPage( 0 );
- addPage( m_loginPage, i18n( "Login" ), "connect_established" );
-
- m_writePage = new Kita::WritePrefPage( 0 );
- addPage( m_writePage, i18n( "Write" ), "edit" );
-
- connect( m_facePage, SIGNAL( changed() ), SLOT( slotChanged() ) );
- connect( m_asciiArtPage, SIGNAL( changed() ), SLOT( slotChanged() ) );
- connect( m_uiPage, SIGNAL( changed() ), SLOT( slotChanged() ) );
- connect( m_abonePage, SIGNAL( changed() ), SLOT( slotChanged() ) );
- connect( m_loginPage, SIGNAL( changed() ), SLOT( slotChanged() ) );
- connect( m_writePage, SIGNAL( changed() ), SLOT( slotChanged() ) );
-
- connect( this, SIGNAL( aboutToShowPage( QWidget* ) ), SLOT( slotAboutToShowPage( QWidget* ) ) );
-}
-
-void KitaPreferences::slotApply()
-{
- qDebug( "activePageIndex = %d", activePageIndex() );
- switch ( activePageIndex() ) {
- // TODO: refactoring.
- case 0:
- // face
- m_facePage->apply();
- break;
- case 1:
- // asciiart
- m_asciiArtPage->apply();
- break;
- case 2:
- // user interface
- m_uiPage->apply();
- break;
- case 3:
- // abone
- m_abonePage->apply();
- break;
- case 4:
- // login
- break;
- case 5:
- // write
- break;
- }
- enableButtonApply( FALSE );
-}
-
-void KitaPreferences::slotDefault()
-{
- switch ( activePageIndex() ) {
- case 0:
- // face
- m_facePage->reset();
- break;
- case 1:
- // asciiart
- m_asciiArtPage->reset();
- break;
- case 2:
- // user
- m_uiPage->reset();
- break;
- case 3:
- // abone
- break;
- case 4:
- // login
- break;
- case 5:
- // write
- break;
- case 6:
- // debug
- break;
- }
- enableButtonApply( TRUE );
-}
-
-void KitaPreferences::slotChanged()
-{
- enableButtonApply( TRUE );
-}
-
-void KitaPreferences::slotOk()
-{
- m_facePage->apply();
- m_asciiArtPage->apply();
- m_uiPage->apply();
- m_abonePage->apply();
-
- KDialogBase::slotOk();
-}
-
-void KitaPreferences::slotAboutToShowPage( QWidget* page )
-{
- if ( activePageIndex() == 1 ) {
- // ascii art
- m_asciiArtPage->init();
- }
-}
-
-AsciiArtPrefPage::AsciiArtPrefPage( QWidget* parent )
- : AsciiArtPrefBase( parent )
-{
- init();
-
- connect( asciiArtText, SIGNAL( textChanged() ), SIGNAL( changed() ) );
-}
-
-void AsciiArtPrefPage::init()
-{
- asciiArtText->setText( Kita::AsciiArtConfig::asciiArtList().join( "\n" ) );
- asciiArtText->setFont( Kita::Config::threadFont() );
-}
-
-void AsciiArtPrefPage::apply()
-{
- QString text = asciiArtText->text();
- QStringList list = QStringList::split( '\n', text );
-
- Kita::AsciiArtConfig::setAsciiArtList( list );
-}
-
-void AsciiArtPrefPage::reset()
-{
-}
-
-UIPrefPage::UIPrefPage( QWidget* parent )
- : UIPrefBase( parent )
-{
- connect( editFileAssociation, SIGNAL( leftClickedURL() ), SLOT( slotEditFileAssociation() ) );
-}
-
-void UIPrefPage::apply()
-{
-}
-
-void UIPrefPage::reset()
-{
- kcfg_AlwaysUseTab->setChecked( TRUE );
- kcfg_MarkTime->setValue( 24 );
- kcfg_ShowMailAddress->setChecked( FALSE );
- kcfg_ShowNum->setValue( 100 );
- kcfg_ListSortOrder->setButton( Kita::Config::EnumListSortOrder::Mark );
- kcfg_PartMimeList->setText( "image/gif,image/jpeg,image/png,image/x-bmp" );
- kcfg_UsePart->setChecked( TRUE );
-}
-
-void UIPrefPage::slotEditFileAssociation()
-{
- KApplication::kdeinitExec( "kcmshell", "filetypes" );
-}
-
-FacePrefPage::FacePrefPage( QWidget* parent )
- : FacePrefBase( parent )
-{
- // font
- connect( listFontButton, SIGNAL( clicked() ), SLOT( slotFontButtonClicked() ) );
-
- connect( threadFontButton, SIGNAL( clicked() ),
- SLOT( slotThreadFontButtonClicked() ) );
-
- connect( popupFontButton, SIGNAL( clicked() ),
- SLOT( slotPopupFontButtonClicked() ) );
-
- updateButtons();
-
- m_threadFontchanged = FALSE;
- m_threadColorChanged = FALSE;
-
- // color
- threadColorButton->setColor( Kita::Config::threadColor() );
- threadBackgroundColorButton->setColor( Kita::Config::threadBackground() );
- popupColorButton->setColor( Kita::Config::popupColor() );
- popupBackgroundColorButton->setColor( Kita::Config::popupBackground() );
-
- connect( threadColorButton, SIGNAL( changed( const QColor& ) ), SIGNAL( changed() ) );
- connect( threadBackgroundColorButton, SIGNAL( changed( const QColor& ) ), SIGNAL( changed() ) );
- connect( threadColorButton, SIGNAL( changed( const QColor& ) ), SLOT( slotColorChanged() ) );
- connect( threadBackgroundColorButton, SIGNAL( changed( const QColor& ) ), SLOT( slotColorChanged() ) );
- connect( popupColorButton, SIGNAL( changed( const QColor& ) ), SIGNAL( changed() ) );
- connect( popupBackgroundColorButton, SIGNAL( changed( const QColor& ) ), SIGNAL( changed() ) );
-}
-
-void FacePrefPage::apply()
-{
- // font
- QFont font = listFontButton->font();
- Kita::Config::setFont( font );
- emit fontChanged( font );
-
- if ( m_threadFontchanged ) {
- QFont threadFont = threadFontButton->font();
- Kita::Config::setThreadFont( threadFont );
- }
- m_threadFontchanged = FALSE;
-
- QFont popupFont = popupFontButton->font();
- Kita::Config::setPopupFont( popupFont );
-
- // color
- if ( m_threadColorChanged ) {
- Kita::Config::setThreadColor( threadColorButton->color() );
- Kita::Config::setThreadBackground( threadBackgroundColorButton->color() );
- }
- m_threadColorChanged = FALSE;
- Kita::Config::setPopupColor( popupColorButton->color() );
- Kita::Config::setPopupBackground( popupBackgroundColorButton->color() );
-}
-
-void FacePrefPage::reset()
-{
- // font
- QFont font;
- listFontButton->setText( Kita::fontToString( font ) );
- listFontButton->setFont( font );
-
- threadFontButton->setText( Kita::fontToString( font ) );
- threadFontButton->setFont( font );
- m_threadFontchanged = TRUE;
-
- popupFontButton->setText( Kita::fontToString( font ) );
- popupFontButton->setFont( font );
-
- // color
- threadColorButton->setColor( Qt::black );
- threadBackgroundColorButton->setColor( Qt::white );
- popupColorButton->setColor( Qt::black );
- popupBackgroundColorButton->setColor( Qt::yellow );
- m_threadColorChanged = TRUE;
-}
-
-void FacePrefPage::updateButtons()
-{
- QFont font = Kita::Config::font();
- listFontButton->setText( Kita::fontToString( font ) );
- listFontButton->setFont( font );
-
- QFont threadFont = Kita::Config::threadFont();
- threadFontButton->setText( Kita::fontToString( threadFont ) );
- threadFontButton->setFont( threadFont );
-
- QFont popupFont = Kita::Config::popupFont();
- popupFontButton->setText( Kita::fontToString( popupFont ) );
- popupFontButton->setFont( popupFont );
-}
-
-void FacePrefPage::slotThreadFontButtonClicked()
-{
- QFont threadFont = threadFontButton->font();
-
- if ( KFontDialog::getFont( threadFont, FALSE, this ) == QDialog::Accepted ) {
- threadFontButton->setText( Kita::fontToString( threadFont ) );
- threadFontButton->setFont( threadFont );
- emit changed();
- m_threadFontchanged = TRUE;
- }
-}
-
-void FacePrefPage::slotFontButtonClicked()
-{
- QFont font = listFontButton->font();
-
- if ( KFontDialog::getFont( font, FALSE, this ) == QDialog::Accepted ) {
- listFontButton->setText( Kita::fontToString( font ) );
- listFontButton->setFont( font );
- emit changed();
- }
-}
-
-void FacePrefPage::slotPopupFontButtonClicked()
-{
- QFont font = popupFontButton->font();
-
- if ( KFontDialog::getFont( font, FALSE, this ) == QDialog::Accepted ) {
- popupFontButton->setText( Kita::fontToString( font ) );
- popupFontButton->setFont( font );
- emit changed();
- }
-}
-
-void FacePrefPage::slotColorChanged()
-{
- m_threadColorChanged = TRUE;
-}