/*************************************************************************** * * * begin : 07 May 2004 * * copyright : (C) 2003 by Samokhvalov Anton :) * * * ***************************************************************************/ /*************************************************************************** * * * 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 "chm_part.h" #include "chm_part.moc" #include #include #include #include #include #include #include #include #include "MainView.h" #include "SizeBox.h" #include "Encoding.h" typedef KParts::GenericFactory ChmPartFactory; K_EXPORT_COMPONENT_FACTORY( libchmnewpart, ChmPartFactory ) ChmPart::ChmPart( QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, const QStringList & /*args*/ ): KParts::ReadOnlyPart( parent, name ) { setInstance( ChmPartFactory::instance() ); setXMLFile( "chmnew_part.rc" ); m_widget = new MainView( "", actionCollection(), parentWidget, widgetName ); setWidget( m_widget ); KStdAction::up( this, SLOT(slotUp()), actionCollection(), "up" ); KStdAction::back( this, SLOT(slotBack()), actionCollection(), "back" ); KStdAction::forward( this, SLOT(slotForward()), actionCollection(), "forward" ); KStdAction::home( this, SLOT(slotHome()), actionCollection(), "home" ); slotChangeState( false, false, false ); SizeBox* sb = new SizeBox( 0, "sb" ); Encoding* enc = new Encoding( 0, "enc" ); new KWidgetAction( sb, "size_box", KShortcut(), this, 0, actionCollection(), "name" ); new KWidgetAction( enc, "select_encoding", KShortcut(), this, 0, actionCollection(), "select_encoding" ); KAction* hide = new KToggleAction( i18n("Hide topic tree"), "view_remove", 0, actionCollection(), "hide_tree" ); connect( hide, SIGNAL(toggled(bool)), m_widget, SLOT(slotHideTopicTree(bool)) ); connect( sb, SIGNAL(sizeChanged(int)), m_widget, SLOT(slotSetZoom(int)) ); connect( enc, SIGNAL(codecChanged(QTextCodec*)), m_widget, SLOT(slotSetCodec(QTextCodec*)) ); connect( m_widget, SIGNAL(codecChanged(QTextCodec*)), enc, SLOT(slotSetCodec(QTextCodec*)) ); connect( m_widget, SIGNAL(changeState(bool,bool,bool)), this, SLOT(slotChangeState(bool,bool,bool)) ); } ChmPart::~ChmPart() { } KAboutData *ChmPart::createAboutData() { KAboutData *aboutData = new KAboutData("chmnewpart", I18N_NOOP("ChmNewPart"), "0.1"); aboutData->addAuthor("Anton Samokhvalov", 0, "red___hat@mail.ru"); return aboutData; } bool ChmPart::openFile() { return m_widget->openFile( m_file ); } void ChmPart::slotUp() { m_widget->up(); } void ChmPart::slotBack() { m_widget->back(); } void ChmPart::slotForward() { m_widget->forward(); } void ChmPart::slotHome() { m_widget->home(); } void ChmPart::slotChangeState( bool up, bool back, bool forward ) { actionCollection()->action( "up" )->setEnabled( up ); actionCollection()->action( "back" )->setEnabled( back ); actionCollection()->action( "forward" )->setEnabled( forward ); }