1 /***************************************************************************
2 keduca.cpp - description
4 begin : miƩ may 23 20:36:15 CEST 2001
5 copyright : (C) 2001 by Javier Campos
6 email : javi@asyris.org
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
20 #include "keduca_part.h"
21 #include "../libkeduca/kgallerydialog.h"
23 #include <kapplication.h>
25 #include <kstandarddirs.h>
26 #include <kfiledialog.h>
29 #include <kparts/componentfactory.h>
33 Keduca::Keduca( QWidget
* parent
, const char *name
, WFlags f
)
34 : KParts::MainWindow( parent
, name
, f
), _part( 0 )
36 setXMLFile( "keducaui.rc" );
38 _part
= KParts::ComponentFactory::createPartInstanceFromLibrary
< KParts::ReadOnlyPart
>
39 ( "libkeducapart", this, name
, this, "KEducaPart" );
43 setCentralWidget( _part
->widget() );
53 kdFatal() << "The library \"libkeducapart\" could not be found. Aborting." << endl
;
55 if (!initialGeometrySet())
56 resize( QSize(550, 450).expandedTo(minimumSizeHint()));
64 void Keduca::setupActions()
66 KStdAction::open( this, SLOT( slotFileOpen() ), actionCollection() );
67 (void)new KAction( i18n( "Open &Gallery..." ), 0, 0, this, SLOT( slotGallery() ),
68 actionCollection(), "open_gallery" );
69 _recentFiles
= KStdAction::openRecent(this, SLOT ( slotFileOpenURL(const KURL
&) ),
71 KStdAction::quit(kapp
, SLOT( quit() ), actionCollection());
74 void Keduca::slotFileOpen()
76 KURL url
= KFileDialog::getOpenURL( QString::null
, "application/x-edu", this, i18n("Open Educa File") );
78 slotFileOpenURL( url
);
81 void Keduca::slotFileOpenURL( const KURL
&url
)
83 if( !_part
->openURL(url
) ) return;
84 _recentFiles
->addURL( url
);
87 /*void Keduca::slotFileClose()
92 bool Keduca::queryClose()
98 void Keduca::configRead()
100 KConfig
*config
= KGlobal::config();
101 config
->setGroup( "keduca" );
102 applyMainWindowSettings( config
, "keduca" );
103 _recentFiles
->loadEntries(config
);
106 void Keduca::configWrite()
108 KConfig
*config
= KGlobal::config();
110 config
->setGroup( "keduca" );
111 saveMainWindowSettings( config
, "keduca" );
112 _recentFiles
->saveEntries(config
);
116 void Keduca::slotGallery()
121 void Keduca::initGallery(const KURL
&urlFile
)
123 KGalleryDialog galleries
;
125 if( !urlFile
.url().isEmpty() )
126 galleries
.putURL( urlFile
);
128 if( galleries
.exec() == QDialog::Accepted
)
129 slotFileOpenURL( galleries
.getURL() );