/*************************************************************************** * * * 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.h" #include "chm.moc" #include #include #include #include #include #include #include #include #include #include Chm::Chm(): KParts::MainWindow( 0L, "KChm" ) { setXMLFile( "chmnew_shell.rc" ); setupActions(); KLibFactory *factory = KLibLoader::self()->factory( "libchmnewpart" ); if (factory) { m_part = static_cast< KParts::ReadOnlyPart* >( factory->create( this, "chmnew_part", "KParts::ReadOnlyPart" ) ); if (m_part) { setCentralWidget( m_part->widget() ); createGUI( m_part ); } } else { KMessageBox::error( this, "Could not find our Part!" ); kapp->quit(); return; } setAutoSaveSettings(); connect( m_part->widget(), SIGNAL(signalSetStatusBarMessage(const QString&)), statusBar(), SLOT(message(const QString&)) ); } Chm::~Chm() { } void Chm::load(const KURL& url) { m_part->openURL( url ); } void Chm::setupActions() { KStdAction::open( this, SLOT(fileOpen()), actionCollection() ); KStdAction::quit( this, SLOT(slotQuit()), actionCollection() ); createStandardStatusBarAction(); setStandardToolBarMenuEnabled( true ); KStdAction::keyBindings( this, SLOT(optionsConfigureKeys()), actionCollection() ); KStdAction::configureToolbars( this, SLOT(optionsConfigureToolbars()), actionCollection() ); } void Chm::saveProperties(KConfig* /*config*/) { } void Chm::readProperties(KConfig* /*config*/) { } void Chm::optionsConfigureKeys() { KKeyDialog dlg( true, this ); dlg.insert( actionCollection(), "chmnew_shell.rc" ); dlg.insert( m_part->actionCollection(), "chmnew_part.rc" ); (void) dlg.configure( true ); } void Chm::optionsConfigureToolbars() { saveMainWindowSettings( KGlobal::config(), autoSaveGroup() ); KEditToolbar dlg(factory()); connect( &dlg, SIGNAL(newToolbarConfig()), this, SLOT(applyNewToolbarConfig()) ); dlg.exec(); } void Chm::applyNewToolbarConfig() { applyMainWindowSettings(KGlobal::config(), autoSaveGroup()); } void Chm::fileOpen() { KURL url = KFileDialog::getOpenURL( QString::null, QString::null, this ); if (url.isEmpty() == false) { if ( m_part->url().isEmpty() ) { load( url ); } else { Chm* newWin = new Chm; newWin->load( url ); newWin->show(); } } } void Chm::slotQuit() { exit(0); }