moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / keduca / keduca / keduca.cpp
blob8abc874b9e20461fc552fd96b07cbbdfa0cdadd1
1 /***************************************************************************
2 keduca.cpp - description
3 -------------------
4 begin : miƩ may 23 20:36:15 CEST 2001
5 copyright : (C) 2001 by Javier Campos
6 email : javi@asyris.org
7 ***************************************************************************/
9 /***************************************************************************
10 * *
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. *
15 * *
16 ***************************************************************************/
18 #include "keduca.h"
19 #include "keduca.moc"
20 #include "keduca_part.h"
21 #include "../libkeduca/kgallerydialog.h"
23 #include <kapplication.h>
24 #include <klocale.h>
25 #include <kstandarddirs.h>
26 #include <kfiledialog.h>
27 #include <kdebug.h>
29 #include <kparts/componentfactory.h>
31 #include <qlabel.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" );
41 if ( _part )
43 setCentralWidget( _part->widget() );
45 setupActions();
47 configRead();
49 createGUI( _part );
51 else
53 kdFatal() << "The library \"libkeducapart\" could not be found. Aborting." << endl;
55 if (!initialGeometrySet())
56 resize( QSize(550, 450).expandedTo(minimumSizeHint()));
59 Keduca::~Keduca()
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 &) ),
70 actionCollection());
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") );
77 if( !url.isEmpty() )
78 slotFileOpenURL( url );
81 void Keduca::slotFileOpenURL( const KURL &url )
83 if( !_part->openURL(url) ) return;
84 _recentFiles->addURL( url );
87 /*void Keduca::slotFileClose()
89 init();
90 }*/
92 bool Keduca::queryClose()
94 configWrite();
95 return( TRUE );
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);
113 config->sync();
116 void Keduca::slotGallery()
118 initGallery();
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() );