diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch) | |
tree | d3bb9f5d25a2dc09ca81adecf39621d871534297 /keduca/keduca | |
download | tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.tar.gz tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'keduca/keduca')
-rw-r--r-- | keduca/keduca/Makefile.am | 40 | ||||
-rw-r--r-- | keduca/keduca/configdialogbase.ui | 100 | ||||
-rw-r--r-- | keduca/keduca/kcheckeduca.cpp | 85 | ||||
-rw-r--r-- | keduca/keduca/kcheckeduca.h | 44 | ||||
-rw-r--r-- | keduca/keduca/keduca.cpp | 130 | ||||
-rw-r--r-- | keduca/keduca/keduca.h | 76 | ||||
-rw-r--r-- | keduca/keduca/keduca.kcfg | 30 | ||||
-rw-r--r-- | keduca/keduca/keduca_part.cpp | 96 | ||||
-rw-r--r-- | keduca/keduca/keduca_part.desktop | 16 | ||||
-rw-r--r-- | keduca/keduca/keduca_part.h | 87 | ||||
-rw-r--r-- | keduca/keduca/keduca_partui.rc | 8 | ||||
-rw-r--r-- | keduca/keduca/keducaprefs.cpp | 112 | ||||
-rw-r--r-- | keduca/keduca/keducaprefs.h | 62 | ||||
-rw-r--r-- | keduca/keduca/keducaui.rc | 9 | ||||
-rw-r--r-- | keduca/keduca/keducaview.cpp | 629 | ||||
-rw-r--r-- | keduca/keduca/keducaview.h | 147 | ||||
-rw-r--r-- | keduca/keduca/kgroupeduca.cpp | 102 | ||||
-rw-r--r-- | keduca/keduca/kgroupeduca.h | 57 | ||||
-rw-r--r-- | keduca/keduca/kquestion.cpp | 123 | ||||
-rw-r--r-- | keduca/keduca/kquestion.h | 79 | ||||
-rw-r--r-- | keduca/keduca/kradioeduca.cpp | 83 | ||||
-rw-r--r-- | keduca/keduca/kradioeduca.h | 51 | ||||
-rw-r--r-- | keduca/keduca/main.cpp | 68 | ||||
-rw-r--r-- | keduca/keduca/settings.kcfgc | 4 |
24 files changed, 2238 insertions, 0 deletions
diff --git a/keduca/keduca/Makefile.am b/keduca/keduca/Makefile.am new file mode 100644 index 00000000..fb713daf --- /dev/null +++ b/keduca/keduca/Makefile.am @@ -0,0 +1,40 @@ +# set the include path for X, qt and KDE +INCLUDES= -I../libkeduca $(all_includes) + +# The binary program keduca +bin_PROGRAMS = keduca +keduca_LDFLAGS = $(all_libraries) +keduca_LDADD = $(LIB_KFILE) $(LIB_KPARTS) ../libkeduca/libkeduca.la +keduca_SOURCES = main.cpp keduca.cpp + +# Convenience library +#noinst_LTLIBRARIES = libkeduca_common.la + +#libkeduca_common_la_SOURCES = kradioeduca.cpp kquestion.cpp kgroupeduca.cpp keducaview.cpp \ +# keducaprefs.cpp kcheckeduca.cpp +#libkeduca_common_la_LDFLAGS = $(all_libraries) -no-undefined +#libkeduca_common_la_LIBADD = ../libkeduca/libkeduca.la + +# The KParts Component +kde_module_LTLIBRARIES = libkeducapart.la +libkeducapart_la_LDFLAGS = $(KDE_PLUGIN) $(all_libraries) +libkeducapart_la_LIBADD = ../libkeduca/libkeduca.la $(LIB_KPARTS) +libkeducapart_la_SOURCES = keduca_part.cpp kradioeduca.cpp kquestion.cpp \ + kgroupeduca.cpp keducaview.cpp keducaprefs.cpp \ + kcheckeduca.cpp settings.kcfgc configdialogbase.ui + +EXTRA_DIST = main.cpp keduca.cpp keduca.h kcheckeduca.cpp kcheckeduca.h keducaprefs.cpp \ +keducaprefs.h keducaui.rc keducaview.cpp keducaview.h kgroupeduca.cpp kgroupeduca.h kquestion.cpp \ +kquestion.h kradioeduca.cpp kradioeduca.h + +METASOURCES = AUTO + +rcdir = $(kde_datadir)/keduca +rc_DATA = keducaui.rc keduca_partui.rc + +# Install the Part's desktop file +kde_services_DATA = keduca_part.desktop + +kde_kcfg_DATA = keduca.kcfg + +include ../../admin/Doxyfile.am diff --git a/keduca/keduca/configdialogbase.ui b/keduca/keduca/configdialogbase.ui new file mode 100644 index 00000000..bb526841 --- /dev/null +++ b/keduca/keduca/configdialogbase.ui @@ -0,0 +1,100 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>ConfigDialogBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>ConfigDialogBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>332</width> + <height>273</height> + </rect> + </property> + <property name="caption"> + <string>KEduca Config Dialog</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>kcfg_ResultFinish</cstring> + </property> + <property name="title"> + <string>Show Results</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>testEnd</cstring> + </property> + <property name="text"> + <string>At the end of the test</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>afterEachQuestion</cstring> + </property> + <property name="text"> + <string>After answering each question</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>orderingButtonGroup</cstring> + </property> + <property name="title"> + <string>Ordering</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>kcfg_RandomQuestions</cstring> + </property> + <property name="text"> + <string>Show questions in random order</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>kcfg_RandomAnswers</cstring> + </property> + <property name="text"> + <string>Show answers in random order</string> + </property> + </widget> + </vbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>41</width> + <height>51</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/keduca/keduca/kcheckeduca.cpp b/keduca/keduca/kcheckeduca.cpp new file mode 100644 index 00000000..8fe6b557 --- /dev/null +++ b/keduca/keduca/kcheckeduca.cpp @@ -0,0 +1,85 @@ +/*************************************************************************** + kcheckeduca.cpp - description + ------------------- + begin : Tue Sep 5 2000 + copyright : (C) 2000 by Javier Campos Morales + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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 "kcheckeduca.h" +#include "kcheckeduca.moc" + +#include <qstyle.h> +#include <kaccelmanager.h> + +KCheckEduca::KCheckEduca(QWidget *parent, const char *name ) : QCheckBox(parent,name) +{ + _doc = 0; + KAcceleratorManager::setNoAccel( this ); +} + +KCheckEduca::~KCheckEduca() +{ + delete _doc; +} + +/** */ +void KCheckEduca::drawButtonLabel( QPainter *p){ + int x, y, w, h; + int extra_width, indicator_width; + + extra_width = 8; + indicator_width = style().pixelMetric(QStyle::PM_IndicatorWidth, 0); + + y = 0; + x = indicator_width + extra_width; //### + w = width() - x; + h = height(); + + QRect cr(x,y,w,h); + + _doc = new QSimpleRichText( text(), font() ); + _doc->setWidth( 10 ); + + _doc->setWidth(p, cr.width() ); + int rw = _doc->widthUsed() + extra_width; + int rh = _doc->height(); + int xo = 0; + int yo = 0; + + resize( width(), rh); + + yo = (cr.height()-rh)/2; + + if ( !isEnabled() ) { + QColorGroup cg = colorGroup(); + cg.setColor( QColorGroup::Text, cg.light() ); + _doc->draw(p, cr.x()+xo+1, cr.y()+yo+1, cr, cg, 0); + } + _doc->draw(p, cr.x()+xo, cr.y()+yo, cr, colorGroup(), 0); + + if ( hasFocus() ) { +// QRect br = style().itemRect( p, x, y, rw, rh+yo, +// AlignLeft|AlignVCenter|ShowPrefix, +// isEnabled(), +// pixmap(), text().visual() ); + QRect br(x,y,rw,rh+yo); + + br.setLeft( br.left()-3 ); + br.setRight( br.right()+2 ); + br.setTop( br.top()-2 ); + br.setBottom( br.bottom()+2); + br = br.intersect( QRect(0,0,rw, rh+yo ) ); + + style().drawPrimitive( QStyle::PE_FocusRect, p, br, colorGroup()); + } +} diff --git a/keduca/keduca/kcheckeduca.h b/keduca/keduca/kcheckeduca.h new file mode 100644 index 00000000..a874b62d --- /dev/null +++ b/keduca/keduca/kcheckeduca.h @@ -0,0 +1,44 @@ +/*************************************************************************** + kcheckeduca.h - description + ------------------- + begin : Tue Sep 5 2000 + copyright : (C) 2000 by Javier Campos Morales + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef KCHECKEDUCA_H +#define KCHECKEDUCA_H + +#include <qcheckbox.h> + +#include <qsimplerichtext.h> + +/**KCheck with wordwrap and rich text support + *@author Javier Campos Morales + */ + +class KCheckEduca : public QCheckBox { + Q_OBJECT + +public: + KCheckEduca(QWidget *parent=0, const char *name=0); + ~KCheckEduca(); + +protected: + void drawButtonLabel( QPainter *); + +private: + /** Rich text */ + QSimpleRichText *_doc; +}; + +#endif diff --git a/keduca/keduca/keduca.cpp b/keduca/keduca/keduca.cpp new file mode 100644 index 00000000..8abc874b --- /dev/null +++ b/keduca/keduca/keduca.cpp @@ -0,0 +1,130 @@ +/*************************************************************************** + keduca.cpp - description + ------------------- + begin : mié may 23 20:36:15 CEST 2001 + copyright : (C) 2001 by Javier Campos + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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 "keduca.h" +#include "keduca.moc" +#include "keduca_part.h" +#include "../libkeduca/kgallerydialog.h" + +#include <kapplication.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kfiledialog.h> +#include <kdebug.h> + +#include <kparts/componentfactory.h> + +#include <qlabel.h> + +Keduca::Keduca( QWidget* parent, const char *name, WFlags f ) + : KParts::MainWindow( parent, name, f ), _part( 0 ) +{ + setXMLFile( "keducaui.rc" ); + + _part = KParts::ComponentFactory::createPartInstanceFromLibrary< KParts::ReadOnlyPart > + ( "libkeducapart", this, name, this, "KEducaPart" ); + + if ( _part ) + { + setCentralWidget( _part->widget() ); + + setupActions(); + + configRead(); + + createGUI( _part ); + } + else + { + kdFatal() << "The library \"libkeducapart\" could not be found. Aborting." << endl; + } + if (!initialGeometrySet()) + resize( QSize(550, 450).expandedTo(minimumSizeHint())); +} + +Keduca::~Keduca() +{ +} + + +void Keduca::setupActions() +{ + KStdAction::open( this, SLOT( slotFileOpen() ), actionCollection() ); + (void)new KAction( i18n( "Open &Gallery..." ), 0, 0, this, SLOT( slotGallery() ), +actionCollection(), "open_gallery" ); + _recentFiles = KStdAction::openRecent(this, SLOT ( slotFileOpenURL(const KURL &) ), +actionCollection()); + KStdAction::quit(kapp, SLOT( quit() ), actionCollection()); +} + +void Keduca::slotFileOpen() +{ + KURL url = KFileDialog::getOpenURL( QString::null, "application/x-edu", this, i18n("Open Educa File") ); + if( !url.isEmpty() ) + slotFileOpenURL( url ); +} + +void Keduca::slotFileOpenURL( const KURL &url ) +{ + if( !_part->openURL(url) ) return; + _recentFiles->addURL( url ); +} + +/*void Keduca::slotFileClose() +{ + init(); +}*/ + +bool Keduca::queryClose() +{ + configWrite(); + return( TRUE ); +} + +void Keduca::configRead() +{ + KConfig *config = KGlobal::config(); + config->setGroup( "keduca" ); + applyMainWindowSettings( config, "keduca" ); + _recentFiles->loadEntries(config); +} + +void Keduca::configWrite() +{ + KConfig *config = KGlobal::config(); + + config->setGroup( "keduca" ); + saveMainWindowSettings( config, "keduca" ); + _recentFiles->saveEntries(config); + config->sync(); +} + +void Keduca::slotGallery() +{ + initGallery(); +} + +void Keduca::initGallery(const KURL &urlFile) +{ + KGalleryDialog galleries; + + if( !urlFile.url().isEmpty() ) + galleries.putURL( urlFile ); + + if( galleries.exec() == QDialog::Accepted ) + slotFileOpenURL( galleries.getURL() ); +} diff --git a/keduca/keduca/keduca.h b/keduca/keduca/keduca.h new file mode 100644 index 00000000..c5c5c99b --- /dev/null +++ b/keduca/keduca/keduca.h @@ -0,0 +1,76 @@ +/*************************************************************************** + keduca.h - description + ------------------- + begin : mié may 23 20:36:15 CEST 2001 + copyright : (C) 2001 by Javier Campos + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef KEDUCA_H +#define KEDUCA_H + +/* +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +*/ + +#include <kapplication.h> +#include <kparts/mainwindow.h> +#include <kparts/part.h> +#include <kaction.h> + +/** The KEduca TestMaster. + This will execute the Test/Examen as defined by the KEduca Document. */ +class Keduca : public KParts::MainWindow +{ + Q_OBJECT + +public: + /** construtor */ + Keduca(QWidget* parent=0, const char *name=0, WFlags f = WType_TopLevel | WDestructiveClose); + /** destructor */ + ~Keduca(); + /** Open gallery window */ + void initGallery(const KURL &urlFile=KURL()); + +private: + /** Configures the actions */ + void setupActions(); + /** Write settings */ + void configWrite(); + /** Read settings */ + void configRead(); + /** Close the window */ + bool queryClose(); + + // Private attributes + + /** Recent files */ + KRecentFilesAction *_recentFiles; + /** A KEDUCA file main view */ + KParts::ReadOnlyPart *_part; + +public slots: + /** Open a file */ + void slotFileOpenURL( const KURL &url ); + /** Open new file */ + void slotFileOpen(); + +private slots: + /** Close actual document */ + /*void slotFileClose();*/ + /** Open gallery dialog */ + void slotGallery(); +}; + +#endif diff --git a/keduca/keduca/keduca.kcfg b/keduca/keduca/keduca.kcfg new file mode 100644 index 00000000..077d19a8 --- /dev/null +++ b/keduca/keduca/keduca.kcfg @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > +<kcfgfile name="keducarc"/> + <group name="Options"> + <entry name="RandomAnswers" type="Bool"> + <label>Display answers in random order.</label> + <default>false</default> + </entry> + <entry name="RandomQuestions" type="Bool"> + <label>Display answers in random order.</label> + <default>false</default> + </entry> + <entry name="ResultFinish" type="Enum"> + <label>Show results only at the end of the test.</label> + <choices> + <choice name="testEnd"/> + <choice name="afterEachQuestion"/> + </choices> + <default>testEnd</default> + </entry> + </group> + <group name="keducaview"> + <entry name="Splitter_size" type="IntList"> + <label>How the screen is divided in KEducaView.</label> + </entry> + </group> +</kcfg>
\ No newline at end of file diff --git a/keduca/keduca/keduca_part.cpp b/keduca/keduca/keduca_part.cpp new file mode 100644 index 00000000..c5d13f68 --- /dev/null +++ b/keduca/keduca/keduca_part.cpp @@ -0,0 +1,96 @@ +/* + * + * KEduca - Interactive Tests and Exams for KDE + * + * Copyright (c) + * + * 2004: Henrique Pinto <henrique.pinto@kdemail.net> + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "keduca_part.h" +#include "keducaview.h" +#include "settings.h" +#include "configdialogbase.h" + +#include <kaboutdata.h> +#include <kparts/genericfactory.h> +#include <kstdaction.h> +#include <kconfigdialog.h> + +typedef KParts::GenericFactory<KEducaPart> KEducaPartFactory; +K_EXPORT_COMPONENT_FACTORY( libkeducapart, KEducaPartFactory ) + +KEducaPart::KEducaPart( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const QStringList &/*args*/ ) + : KParts::ReadOnlyPart( parent, name ) +{ + setInstance( KEducaPartFactory::instance() ); + + m_view = new KEducaView( parentWidget, widgetName ); + m_view->show(); + setWidget( m_view ); + + setupActions(); + + setXMLFile( "keduca_partui.rc" ); +} + +KEducaPart::~KEducaPart() +{ +} + +KAboutData* KEducaPart::createAboutData() +{ + KAboutData *data = new KAboutData( "keduca", I18N_NOOP( "KEducaPart" ), + "0.2", I18N_NOOP( "KEduca KParts Component" ), + KAboutData::License_GPL, + "(c) 2004, Henrique Pinto <henrique.pinto@kdemail.net>" + ); + return data; +} + +bool KEducaPart::openFile() +{ + return m_view->openURL( KURL( m_file ) ); +} + +void KEducaPart::setupActions() +{ + KStdAction::preferences( this, SLOT( slotConfigure() ), actionCollection(), "configure" ); +} + +void KEducaPart::slotConfigure() +{ + if ( KConfigDialog::showDialog( "KEducaSettings" ) ) + return; + + KConfigDialog *dialog = new KConfigDialog( widget(), "KEducaSettings", Settings::self() ); + ConfigDialogBase *confDlg = new ConfigDialogBase( 0, "ConfigDialogBase" ); + dialog->addPage( confDlg, i18n("General"), "keduca" ); + + connect( dialog, SIGNAL( settingsChanged() ), SLOT( updateConfiguration() ) ); + + dialog->show(); +} + +void KEducaPart::updateConfiguration() +{ + Settings::writeConfig(); +} + +#include "keduca_part.moc" diff --git a/keduca/keduca/keduca_part.desktop b/keduca/keduca/keduca_part.desktop new file mode 100644 index 00000000..730d099d --- /dev/null +++ b/keduca/keduca/keduca_part.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Type=Service +Name=KEduca +Name[af]=Keduca +Name[ar]=التعليم Ùƒ +Name[bn]=কে-à¦à¦¡à§à¦•à¦¾ +Name[hi]=के-à¤à¤œà¤¼à¥à¤•à¤¾ +Name[mn]=КСургалт +Name[ne]=केडीई इडॠ+Name[pa]=ਕੇ-ਸਿੱਖਿਆ +Name[sv]=Keduca +Name[ta]=கேயà¯à®Ÿà®¿à®¯à¯à®•à®¾ +Name[ven]=Pfunzo ya K +MimeType=application/x-edu +ServiceTypes=KParts/ReadOnlyPart +X-KDE-Library=libkeducapart diff --git a/keduca/keduca/keduca_part.h b/keduca/keduca/keduca_part.h new file mode 100644 index 00000000..98a720fc --- /dev/null +++ b/keduca/keduca/keduca_part.h @@ -0,0 +1,87 @@ +/* + * + * KEduca - Interactive Tests and Exams for KDE + * + * Copyright (c) + * + * 2004: Henrique Pinto <henrique.pinto@kdemail.net> + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KEDUCA_PART_H +#define KEDUCA_PART_H + +#include <kparts/part.h> + +class KEducaView; +class KAboutData; + +/** + * KPart component for KEduca + * @author Henrique Pinto <henrique.pinto@kdemail.net> + */ +class KEducaPart : public KParts::ReadOnlyPart +{ + Q_OBJECT + public: + /* + * Constructor. + */ + KEducaPart( QWidget *parentWidget, const char *widgetName, QObject *parent, + const char *name, const QStringList &args ); + + /* + * Destructor. + */ + virtual ~KEducaPart(); + + /* + * Returns information about this part. + */ + static KAboutData* createAboutData(); + + protected: + /* + * Opens the file indicated in the m_file member variable. + * Returns true on success, false if errors occured. + */ + virtual bool openFile(); + + protected slots: + /* + * Shows the configuration dialog. + */ + void slotConfigure(); + + /* + * Updates the configuration in case the user has changed it in + * the Config Dialog. + */ + void updateConfiguration(); + + private: + /* + * Sets the KActions for this part. + */ + void setupActions(); + + /* + * The widget for this part. + */ + KEducaView *m_view; +}; + +#endif // KEDUCA_PART_H diff --git a/keduca/keduca/keduca_partui.rc b/keduca/keduca/keduca_partui.rc new file mode 100644 index 00000000..4873cc4f --- /dev/null +++ b/keduca/keduca/keduca_partui.rc @@ -0,0 +1,8 @@ +<!DOCTYPE kpartgui > +<kpartgui version="2" name="KEducaPart" > +<MenuBar> + <Menu name="settings"><text>&Settings</text> + <Action name="configure"/> + </Menu> +</MenuBar> +</kpartgui> diff --git a/keduca/keduca/keducaprefs.cpp b/keduca/keduca/keducaprefs.cpp new file mode 100644 index 00000000..b43f59e2 --- /dev/null +++ b/keduca/keduca/keducaprefs.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** + keducaprefs.cpp - description + ------------------- + begin : Sat Jun 2 2001 + copyright : (C) 2001 by Javier Campos + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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 "keducaprefs.h" +#include "keducaprefs.moc" + +#include <klocale.h> +#include <kiconloader.h> +#include <kconfig.h> + +#include <qlayout.h> +#include <qvbox.h> +#include <qbuttongroup.h> + + +KEducaPrefs::KEducaPrefs(QWidget *parent, const char *name, bool modal ) : KDialogBase(IconList, i18n("Configure"), Ok|Cancel, Ok, parent, name, modal, true) +{ + setPageGeneral(); + configRead(); +} + +KEducaPrefs::~KEducaPrefs(){} + +/** Set page general */ +void KEducaPrefs::setPageGeneral() +{ + QVBox *mainFrame = addVBoxPage( i18n("Miscellaneous"), i18n("Various Settings"), DesktopIcon("misc")); + + + + QButtonGroup *buttonGroup1 = new QButtonGroup( mainFrame, "ButtonGroup1" ); + buttonGroup1->setTitle( i18n( "General" ) ); + buttonGroup1->setColumnLayout(0, Qt::Vertical ); + buttonGroup1->layout()->setSpacing( 0 ); + buttonGroup1->layout()->setMargin( 0 ); + QVBoxLayout *buttonGroup1Layout = new QVBoxLayout( buttonGroup1->layout() ); + buttonGroup1Layout->setAlignment( Qt::AlignTop ); + buttonGroup1Layout->setSpacing( 6 ); + buttonGroup1Layout->setMargin( 11 ); + + _resultAfterNext = new QRadioButton( buttonGroup1, "RadioButton1" ); + _resultAfterNext->setText( i18n( "Show results of the answer after press next" ) ); + buttonGroup1Layout->addWidget( _resultAfterNext ); + + _resultAfterFinish = new QRadioButton( buttonGroup1, "RadioButton2" ); + _resultAfterFinish->setText( i18n( "Show results when finish the test" ) ); + buttonGroup1Layout->addWidget( _resultAfterFinish ); + + QGroupBox *GroupBox1 = new QGroupBox( mainFrame, "GroupBox7" ); + GroupBox1->setTitle( i18n( "Order" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 0 ); + GroupBox1->layout()->setMargin( 0 ); + QVBoxLayout *GroupBox1Layout = new QVBoxLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + GroupBox1Layout->setSpacing( 6 ); + GroupBox1Layout->setMargin( 11 ); + + _randomQuestions = new QCheckBox( GroupBox1, "CheckBox1" ); + _randomQuestions->setText( i18n( "Show questions in random order" ) ); + GroupBox1Layout->addWidget( _randomQuestions ); + + _randomAnswers = new QCheckBox( GroupBox1, "CheckBox2" ); + _randomAnswers->setText( i18n( "Show answers in random order" ) ); + GroupBox1Layout->addWidget( _randomAnswers ); +} + +/** Read settings */ +void KEducaPrefs::configRead() +{ + KConfig *config = KGlobal::config(); + config->setGroup("Options"); + QSize defaultSize(500,400); + resize( config->readSizeEntry("Geometry", &defaultSize ) ); + config->readBoolEntry("ResultFinish", true ) ? _resultAfterFinish->setChecked(true) : _resultAfterNext->setChecked(true); + config->readBoolEntry("RandomQuestions", false ) ? _randomQuestions->setChecked(true) : _randomQuestions->setChecked(false); + config->readBoolEntry("RandomAnswers", false ) ? _randomAnswers->setChecked(true) : _randomAnswers->setChecked(false); +} + +/** Write settings */ +void KEducaPrefs::configWrite() +{ + KConfig *config = KGlobal::config(); + config->setGroup("Options"); + config->writeEntry("Geometry", size() ); + config->writeEntry("ResultFinish", _resultAfterFinish->isChecked() ); + config->writeEntry("RandomQuestions", _randomQuestions->isChecked() ); + config->writeEntry("RandomAnswers", _randomAnswers->isChecked() ); + config->sync(); +} + +/** Push ok button */ +void KEducaPrefs::slotOk() +{ + configWrite(); + accept(); +} + diff --git a/keduca/keduca/keducaprefs.h b/keduca/keduca/keducaprefs.h new file mode 100644 index 00000000..b1493798 --- /dev/null +++ b/keduca/keduca/keducaprefs.h @@ -0,0 +1,62 @@ +/*************************************************************************** + keducaprefs.h - description + ------------------- + begin : Sat Jun 2 2001 + copyright : (C) 2001 by Javier Campos + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef KEDUCAPREFS_H +#define KEDUCAPREFS_H + +#include <kdialogbase.h> + +#include <qradiobutton.h> +#include <qcheckbox.h> + +/** Preferences for KEduca TestMaster (class KEduca) + *@author Javier Campos + */ + +class KEducaPrefs : public KDialogBase { + Q_OBJECT + +public: + KEducaPrefs(QWidget *parent=0, const char *name=0, bool modal=true); + ~KEducaPrefs(); + +private: + + // Private methods + + /** Set page general */ + void setPageGeneral(); + /** Write settings */ + void configWrite(); + /** Read settings */ + void configRead(); + + // Private attributes + + /** Show result after next */ + QRadioButton *_resultAfterNext; + /** Show results after finish */ + QRadioButton *_resultAfterFinish; + QCheckBox *_randomQuestions; + QCheckBox *_randomAnswers; + +private slots: + /** Push ok button */ + void slotOk(); +}; + +#endif diff --git a/keduca/keduca/keducaui.rc b/keduca/keduca/keducaui.rc new file mode 100644 index 00000000..6273bdcb --- /dev/null +++ b/keduca/keduca/keducaui.rc @@ -0,0 +1,9 @@ +<!DOCTYPE kpartgui > +<kpartgui version="3" name="keducaTestMaster" > +<MenuBar> + <Menu name="file"><text>&File</text> + <Action name="open_gallery"/> + </Menu> + <Merge/> +</MenuBar> +</kpartgui> diff --git a/keduca/keduca/keducaview.cpp b/keduca/keduca/keducaview.cpp new file mode 100644 index 00000000..cd6c1782 --- /dev/null +++ b/keduca/keduca/keducaview.cpp @@ -0,0 +1,629 @@ +/*************************************************************************** + keducaview.cpp - description + ------------------- + begin : Thu May 24 2001 + copyright : (C) 2001 by Javier Campos + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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 "keducaview.h" +#include "keducaview.moc" +#include "settings.h" +#include "../libkeduca/fileread.h" +#include "kquestion.h" +#include "kgroupeduca.h" + +#include <stdlib.h> + +#include <klocale.h> +#include <kstandarddirs.h> +#include <kmessagebox.h> +#include <kfiledialog.h> +#include <kpushbutton.h> +#include <kdebug.h> +#include <kio/netaccess.h> + +#include <qtimer.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qtextedit.h> + +KEducaView::KEducaView( QWidget *parent, const char *name ) + : QWidgetStack( parent, name ), _keducaFile( 0 ), _timeoutTimer( 0 ) +{ + init(); +} + +KEducaView::~KEducaView() +{ + delete _questionText; + delete _buttonGroup; + delete _split; + delete _buttonNext; + delete _buttonSave; + delete _viewResults; + delete _keducaFile; +} + +/** Init graphical interface */ +void KEducaView::init() +{ + // Intro Screen + _introWidget = new QLabel( this, "introScreen" ); + _introWidget->setBackgroundColor( Qt::white ); + _introWidget->setAlignment( AlignCenter ); + _introWidget->setPixmap( QPixmap( locate("data","keduca/pics/keduca_init.png") ) ); + addWidget( _introWidget, 0 ); + + // Info Widget + _infoWidget = new QVBox( this, "infoWidget" ); + _viewInfo = new QTextEdit( _infoWidget ); + _viewInfo->setReadOnly( true ); + _buttonStartTest = new KPushButton( i18n( "&Start Test" ), _infoWidget ); + connect( _buttonStartTest, SIGNAL( clicked() ), SLOT( slotButtonNext() ) ); + addWidget( _infoWidget, 1 ); + + // Question Widget + _questionWidget = new QVBox( this, "questionWidget" ); + _split = new QSplitter( QSplitter::Vertical, _questionWidget ); + _questionText = new KQuestion( _split, "kquestion" ); + _buttonGroup = new KGroupEduca( _split, "ButtonGroup" ); + _buttonGroup->setRadioButtonExclusive( true ); + _buttonNext = new KPushButton( i18n( "&Next >>" ), _questionWidget, "ButtonNext" ); + connect( _buttonNext, SIGNAL( clicked() ), SLOT( slotButtonNext() ) ); + addWidget( _questionWidget, 2 ); + + // Results Widget + _resultsWidget = new QVBox( this, "resultsWidget" ); + _viewResults = new QTextEdit( _resultsWidget ); + _viewResults->setReadOnly( true ); + _buttonSave = new KPushButton( i18n( "&Save Results..." ), _resultsWidget ); + connect( _buttonSave, SIGNAL( clicked() ), SLOT( slotButtonSave() ) ); + /* FIXME: This is a hack + * The results widget can be shown only in the end of the test (when you should be shown the + * option to save the results) or at the middle of the test, after each question (when there should + * be a "Next" button). + */ + _buttonResultsNext = new KPushButton( i18n( "&Next >>" ), _resultsWidget ); + connect( _buttonResultsNext, SIGNAL( clicked() ), SLOT( slotButtonNext() ) ); + _buttonResultsNext->hide(); + addWidget( _resultsWidget, 3 ); + + raiseWidget( _introWidget ); + + // Restore splitter size + _split->setSizes( Settings::splitter_size() ); +} + +void KEducaView::slotButtonStartTest() +{ + raiseWidget( _questionWidget ); + showRecord(); +} + +/** Button Next action */ +void KEducaView::slotButtonNext() +{ + // stop the timer + if (_timeoutTimer) + { + _currentTime += _questionText->getCurrentTime(); + _timeoutTimer->stop(); + _questionText->countdown(0); + } + + if( ( visibleWidget() == _questionWidget ) && !_isInitStatus ) + setResults(); + + _buttonGroup->clearAnswers(); + + if( ( Settings::resultFinish()== Settings::EnumResultFinish::afterEachQuestion ) + && _questionText->isVisible() ) + { + showResults( _currentResults + "<HR>" + currentStatusPoints() ); + } + else + { + if( questionNext() ) + showRecord(); + else + { + configWrite(); + showResults( setFinalResult() + currentStatusPoints() + "<HR><P>" + _results + "</HTML>" +); + } + } +} + +/** Button Save action */ +void KEducaView::slotButtonSave() +{ + KFileDialog *dialog=new KFileDialog(QString::null, QString::null, this, "file dialog", true); + dialog->setCaption( i18n("Save Results As") ); + dialog->setKeepLocation( true ); + dialog->setOperationMode( KFileDialog::Saving ); + QStringList mimeFilter( "text/html"); + dialog->setMimeFilter( mimeFilter ); + KURL newURL; + QString outputFormat ("text/html"); + + bool bOk; + do { + bOk=true; + if(dialog->exec()==QDialog::Accepted) { + newURL=dialog->selectedURL(); + outputFormat=dialog->currentMimeFilter(); + } + else + { + bOk = false; + break; + } + kdDebug()<<"Requested saving to file "<<newURL.prettyURL() <<endl; + + if ( QFileInfo( newURL.path() ).extension().isEmpty() ) { + // No more extensions in filters. We need to get it from the mimetype. + QString extension = ".html"; + newURL.setPath( newURL.path() + extension ); + } + + if ( KIO::NetAccess::exists( newURL, false, this ) ) { // this file exists => ask for confirmation + bOk = KMessageBox::warningContinueCancel( this, + i18n("A document with this name already exists.\n"\ + "Do you want to overwrite it?"), + i18n("Warning"), i18n("Overwrite") ) == KMessageBox::Continue; + } + } while ( !bOk ); + + delete dialog; + if( bOk ) { + if (!_keducaFile->saveResults( newURL, _viewResults->text() )) + { + kdDebug()<< "saving of file failed" <<endl; + KMessageBox::sorry( this, i18n("Save failed.") ); + } + }else { + kdDebug()<< "KControlDoc: no valid filename selected" <<endl; + } +} + +/** Show record, returns false if there is no record to show. */ +void KEducaView::showRecord() +{ + QString questionTextTemp = ""; + + raiseWidget( _questionWidget ); + + _keducaFileIndex++; + bool MultiAnswer = _keducaFile->isMultiAnswer(); + + // SHOW QUESTION ******************************************************************* + _questionText->setPixmap( _keducaFile->getPicturePixmap() ); + questionTextTemp = "<table width=100%><tr><td><b>" + + i18n("Question %1").arg(_keducaFileIndex) + "</b>"; + + if( _keducaFile->getTotalPoints() > 0 ) + questionTextTemp += "</td><td align=center bgColor=#336699><font color=#ffffff><b>" + + _keducaFile->getQuestion( FileRead::QF_POINTS ) + + " " + i18n("Points") + + "</b></font>"; + + questionTextTemp += "</tr></td></table><hr/><table><tr><td>" + + _keducaFile->getQuestion( FileRead::QF_TEXT ) + + "</td></tr></table>"; + + _questionText->setText( questionTextTemp ); + + // SHOW ANSWERS ******************************************************************** + if( MultiAnswer ) + _buttonGroup->setType( KGroupEduca::Check ); + else + _buttonGroup->setType( KGroupEduca::Radio ); + + + if( Settings::randomAnswers() ) + { + _randomAnswers.clear(); + QValueList<unsigned int> tmpRandom; + unsigned int index; + for( index = 0 ; index < _keducaFile->recordAnswerCount() ; index ++ ) + { tmpRandom.append( index ); } + for( index = 0 ; index < _keducaFile->recordAnswerCount() ; index ++ ) + { + unsigned int random = rand() % tmpRandom.count(); + QValueList<unsigned int>::iterator itTmpRandom = tmpRandom.begin(); + for( unsigned int i = 0; i < random; i++) { ++itTmpRandom; } + _keducaFile->recordAnswerAt( (*itTmpRandom) ); + _randomAnswers.append( (*itTmpRandom) ); + _buttonGroup->insertAnswer( _keducaFile->getAnswer(FileRead::AF_TEXT) ); + tmpRandom.remove( itTmpRandom ); + } + } + else + { + _keducaFile->recordAnswerFirst(); + while( !_keducaFile->recordAnswerEOF() ) + { + if( !_keducaFile->getAnswer(FileRead::AF_TEXT).isEmpty() ) + _buttonGroup->insertAnswer( _keducaFile->getAnswer(FileRead::AF_TEXT) ); + _keducaFile->recordAnswerNext(); + }; + } + + + // START THE TIMER ***************************************************************** + if( _keducaFile->getQuestionInt(FileRead::QF_TIME) > 0 ) + { + KMessageBox::information( this, + i18n( "You have %1 seconds to complete this question.\n\n" + "Press OK when you are ready." ) + .arg( _keducaFile->getQuestion(FileRead::QF_TIME) ) ); + } + + int timeout = _keducaFile->getQuestionInt(FileRead::QF_TIME); + if (timeout > 0) + { + if (!_timeoutTimer) + { + _timeoutTimer = new QTimer(this); + connect(_timeoutTimer, SIGNAL(timeout()), + this, SLOT(questionTimedOut())); + } + _timeoutTimer->start(1000*timeout); + _questionText->countdown(timeout); + _questionText->countdownVisible(true); + } + else + { + _questionText->countdownVisible(false); + } +} + +void KEducaView::questionTimedOut() +{ + _currentTime += _keducaFile->getQuestionInt(FileRead::QF_TIME); + slotButtonNext(); +} + +/** Show results */ +void KEducaView::showResults( const QString &text ) +{ + _viewResults->setText( text ); + + if ( _keducaFile->recordEOF() ) + { + _buttonSave->show(); + _buttonResultsNext->hide(); + } + else + { + _buttonSave->hide(); + _buttonResultsNext->show(); + } + + raiseWidget( _resultsWidget ); +} + +/** Set results */ +void KEducaView::setResults() +{ + bool isCorrect = true; + QString yourAnswer = ""; + QString correctAnswer = ""; + QValueList<uint>::iterator itRandom = _randomAnswers.begin(); + + Settings::randomAnswers() ? _keducaFile->recordAnswerAt(*itRandom) : _keducaFile->recordAnswerFirst(); + + for( unsigned index = 0 ; index < _keducaFile->recordAnswerCount() ; index++ ) + { + QString answertext = _keducaFile->getAnswer( FileRead::AF_TEXT ); + if( !answertext.isEmpty() ) + { + if(_buttonGroup->isChecked(index) != _keducaFile->getAnswerValue()) + { + isCorrect=false; + if(_buttonGroup->isChecked(index)) yourAnswer += "<BR><FONT COLOR=#b84747><B>" + answertext + "</B></FONT>"; + if(_keducaFile->getAnswerValue()) correctAnswer += "<BR><FONT COLOR=#006b6b><B>" + answertext + "</B></FONT>"; + } + else + { + if(_buttonGroup->isChecked(index)) yourAnswer += "<BR><B>" + answertext + "</B>"; + if(_keducaFile->getAnswerValue()) correctAnswer += "<BR><FONT COLOR=#006b6b><B>" + answertext + "</B></FONT>"; + } + } + if( Settings::randomAnswers() ) + { + ++itRandom; + _keducaFile->recordAnswerAt(*itRandom); + } + else + _keducaFile->recordAnswerNext(); + } + + if( isCorrect) + { + _correctAnswer++; + if( _keducaFile->getTotalPoints() > 0 ) + _correctPoints += _keducaFile->getQuestionInt(FileRead::QF_POINTS); + } + else + { + _incorrectAnswer++; + if( _keducaFile->getTotalPoints() > 0 ) + _incorrectPoints += _keducaFile->getQuestionInt(FileRead::QF_POINTS); + } + + _results += getTableQuestion( isCorrect, correctAnswer, yourAnswer ); +} + +/** Set results */ +QString KEducaView::setFinalResult() +{ + QString finalResult = ""; + + if( !_keducaFile->isResult() ) return ""; + + finalResult = "<TABLE WIDTH=100% BORDER=0 BGCOLOR=#EEEEDD CELLSPACING=0><TR><TD BGCOLOR=#DDDDCC COLSPAN=2 ALIGN=CENTER><FONT COLOR=#222211><B>" + + i18n("Result") + + "</B></FONT></TD></TR>"; + + _keducaFile->recordResultFirst(); + while( !_keducaFile->recordResultEOF() ) + { + if( _correctPoints >= _keducaFile->getResultInt(FileRead::RS_MIN) && + _correctPoints <= _keducaFile->getResultInt(FileRead::RS_MAX) ) + { + if( _keducaFile->getResult(FileRead::RS_PICTURE).isEmpty() ) + finalResult += "<TR><TD COLSPAN=2 ALIGN=CENTER>"; + else + finalResult += "<TR><TD><IMG SRC=" + _keducaFile->getResult(FileRead::RS_PICTURE) + " : </TD><TD>"; + + finalResult += _keducaFile->getResult(FileRead::RS_TEXT) + "</TD><TR>"; + } + _keducaFile->recordResultNext(); + } + + finalResult += "</TABLE>"; + + return finalResult; +} + +/** Open url */ +bool KEducaView::openURL( const KURL &url) +{ + _keducaFile = new FileRead(); + if ( !_keducaFile->openFile( url ) ) + return false; + + _isInitStatus = true; + _results = "<HTML>"; + _correctAnswer = 0; + _correctPoints = 0; + _currentTime = 0; + _incorrectAnswer = 0; + _incorrectPoints = 0; + _keducaFileIndex = 0; + + if( Settings::randomQuestions() ) + { + unsigned int index; + for( index = 0 ; index < _keducaFile->getTotalQuestions() ; index ++ ) + { _randomQuestions.append( index ); } + } + + _keducaFile->recordFirst(); + _keducaFile->recordAnswerFirst(); + + _viewInfo->setText( getInformation() ); + raiseWidget( _infoWidget ); + + return true; +} + +/** Write settings */ +void KEducaView::configWrite() +{ + Settings::setSplitter_size( _split->sizes() ); + Settings::writeConfig(); +} + +/** current Status Points */ +QString KEducaView::currentStatusPoints() +{ + QString tempStatus; + + tempStatus = insertTable() + + insertRow( i18n("Statistics"), true, 4) + + insertRow( i18n("Correct questions"), + QString().setNum( _correctAnswer ), + i18n("Incorrect questions"), + QString().setNum( _incorrectAnswer ), true); + + if( _keducaFile->getTotalPoints() > 0 ) + tempStatus += insertRow( i18n("Total points"), true, 4 ) + + insertRow( i18n("Correct points"), + QString().setNum( _correctPoints ), + i18n("Incorrect points"), + QString().setNum( _incorrectPoints ), true ); + + if( _keducaFile->getTotalTime() > 0 ) + tempStatus += insertRow( i18n("Time"), true, 4 ) + + insertRow( i18n("Total time"), + QString().setNum( _keducaFile->getTotalTime() ), + i18n("Time in tests"), + QString().setNum( _currentTime ), true ); + tempStatus += insertTableClose(); + return tempStatus; +} + +/** Set HTML table view with correct and incorrect answers */ +QString KEducaView::getTableQuestion( bool isCorrect, const QString &correct, const QString &incorrect) +{ + _currentResults = "<TABLE WIDTH=100% BORDER=0><TR><TD VALIGN=TOP WIDTH=70><IMG WIDTH=64 HEIGHT=64 SRC="; + if( isCorrect ) + _currentResults += locate("data","keduca/pics/keduca_correct_64.png"); + else + _currentResults += locate("data","keduca/pics/keduca_incorrect_64.png"); + + _currentResults += "></TD><TD VALIGN=TOP>"; + + _currentResults += "<B><FONT COLOR=#336699>" + _keducaFile->getQuestion( FileRead::QF_TEXT ) + "</FONT></B>"; + + if( _keducaFile->getQuestionInt(FileRead::QF_POINTS) > 0 ) + _currentResults += "<SMALL> ( " + _keducaFile->getQuestion(FileRead::QF_POINTS) + " " + i18n("Points") + " )</SMALL>"; + + _currentResults += "<HR><SMALL>"; + + if( isCorrect ) + _currentResults += i18n( "The answer is: "); + else + _currentResults += i18n( "The correct answer is: "); + + _currentResults += correct + "<BR>"; + + if( !isCorrect ) + { + _currentResults += i18n( "Your answer was: "); + _currentResults += incorrect; + } + + _currentResults += "</SMALL></TD></TR></TABLE><P>"; + return _currentResults; +} + +/** Define the next questions (random, secuencial) */ +bool KEducaView::questionNext() +{ + if( !Settings::randomQuestions() && !_isInitStatus ) + { + _keducaFile->recordNext(); + return _keducaFile->recordEOF() ? false : true; + } + + if( _isInitStatus ) + { + _isInitStatus = false; + if( !Settings::randomQuestions() ) return true; + } + + if( _randomQuestions.count() > 0 ) + { + unsigned int randomQuestion = rand() % _randomQuestions.count(); + QValueList<uint>::iterator itRandom = _randomQuestions.begin(); + for( unsigned int i = 0; i < randomQuestion; ++i) + { ++itRandom; } + _keducaFile->recordAt( (*itRandom) ); + _randomQuestions.remove( itRandom ); + return true; + } + else + return false; +} + +/** Get document information */ +QString KEducaView::getInformation() +{ + + QString tmp = ""; + + if ( _keducaFile ) + { + if( !(_keducaFile->getHeader("startupinfo")).isEmpty() ) + { + tmp += insertTable( "<img src=" + locate("data","keduca/pics/alert.png") + ">", 2 ) +// + insertRow( i18n("Additional Information")+"<br>", true, 2 ) + + insertRow( _keducaFile->getHeader("startupinfo") + "<br>", false ) + + insertTableClose(); + } + + tmp += insertTable( "<img src=" + locate("data","keduca/pics/info.png") + ">", 2 ); + tmp += insertRow( i18n("Information")+"<br>", true, 2); + tmp += insertRow( i18n("Title"), _keducaFile->getHeader("title"), true ); + tmp += insertRow( i18n("Category"), _keducaFile->getHeader("category"), true ); + tmp += insertRow( i18n("Type"), _keducaFile->getHeader("type"), true ); + tmp += insertRow( i18n("Language"), _keducaFile->getHeader("language"), true ); + tmp += insertTableClose(); + } + else + { + tmp += "<html><body>"; + tmp += "<img src=" + locate("data","keduca/pics/keduca_init.png") + "/>"; + tmp += "</body></html>"; + } + + return tmp; +} + +/** Init table with title and colspan */ +QString KEducaView::insertTable( const QString &title, unsigned int col){ + QString tmp; + + tmp = "<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 BGCOLOR=#EEEEDD>"; + + if( !title.isEmpty() ) { + tmp += "<TR><TD "; + + if( col > 0 ) tmp += "COLSPAN=" + QString().setNum( col ) + " "; + + tmp += "ALIGN=CENTER><FONT COLOR=#222211><B>" + + title + + "</B></FONT></TD></TR>"; + } + return tmp; +} + +/** Insert row */ +QString KEducaView::insertRow( const QString &text, bool title, unsigned colSpan ){ + QString tmp; + tmp = "<TR><TD"; + if( colSpan>0 ) tmp+= " COLSPAN=" + QString().setNum(colSpan); + if( title ) tmp += " ALIGN=CENTER"; + tmp += ">"; + if( title ) tmp += "<B>"; + tmp += text; + if( title ) tmp += "</B>"; + tmp += "</TD></TR>"; + return tmp; +} + +/** Insert row */ +QString KEducaView::insertRow( const QString &label, const QString &field, bool formBased ){ + QString tmp; + tmp = "<TR><TD"; + if( formBased ) tmp += " ALIGN=RIGHT"; + tmp += ">" + label; + if( formBased ) tmp += ": "; + tmp += "</TD><TD>" + field + "</TD></TR>"; + return tmp; +} + +QString KEducaView::insertRow( const QString &label1, const QString &field1, const QString &label2, const QString &field2, bool formBased ){ + QString tmp; + tmp = "<TR><TD"; + if( formBased ) tmp += " ALIGN=RIGHT"; + tmp += ">" + label1; + if( formBased ) tmp += ": "; + tmp += "</TD><TD>" + field1 + "</TD>"; + tmp += "<TD"; + if( formBased ) tmp += " ALIGN=RIGHT"; + tmp += ">" + label2; + if( formBased ) tmp += ": "; + tmp += "</TD><TD>" + field2 + "</TD></TR>"; + return tmp; +} + + +/** Close current table */ +QString KEducaView::insertTableClose(){ + return "</TABLE>"; +} + diff --git a/keduca/keduca/keducaview.h b/keduca/keduca/keducaview.h new file mode 100644 index 00000000..78bce53c --- /dev/null +++ b/keduca/keduca/keducaview.h @@ -0,0 +1,147 @@ +/*************************************************************************** + keducaview.h - description + ------------------- + begin : Thu May 24 2001 + copyright : (C) 2001 by Javier Campos + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef KEDUCAVIEW_H +#define KEDUCAVIEW_H + +#include <kurl.h> + +#include <qlayout.h> +#include <qsplitter.h> +#include <qwidgetstack.h> + +class QTimer; +class QTextEdit; +class QLabel; + +class KPushButton; + +class FileRead; +class KQuestion; +class KGroupEduca; + +/**Main view of keduca file (questions and answers) + This is the widget for asking questions and allowing selection of answers + as used by KEduca TestMaster (class KEduca) + *@author Javier Campos + */ + +class KEducaView : public QWidgetStack +{ + Q_OBJECT + +public: + KEducaView(QWidget *parent=0, const char *name=0); + ~KEducaView(); + /** Open url */ + bool openURL( const KURL &url); + FileRead const *getKeducaFile() const {return _keducaFile; } + +private: + + // Private methods + + /** Init graphical interface */ + void init(); + /** Show record, returns false if there is no record to show. */ + void showRecord(); + /** Show results */ + void showResults( const QString &text ); + /** Set results */ + void setResults(); + /** Set results */ + QString setFinalResult(); + /** Write settings */ + void configWrite(); + /** current results Points */ + QString currentStatusPoints(); + /** Set HTML table view with correct and incorrect answers */ + QString getTableQuestion( bool isCorrect, const QString &correct, const QString &incorrect); + /** Define the next questions (random, secuencial) */ + bool questionNext(); + + QString getInformation(); + /** Init table with title and colspan */ + QString insertTable( const QString &title = "", unsigned int col=0); + /** Insert row */ + QString insertRow( const QString &text, bool title, unsigned int colSpan=0 ); + QString insertRow( const QString &label, const QString &field, bool formBased ); + QString insertRow( const QString &label1, const QString &field1, const QString &label2, const QString &field2, bool formBased ); + /** Close current table */ + QString insertTableClose(); + + // Private attributes + + /** Widgets */ + QLabel *_introWidget; + QWidget *_infoWidget, *_questionWidget, *_resultsWidget; + /** Push Buttons */ + KPushButton *_buttonNext; + KPushButton *_buttonSave; + KPushButton *_buttonResultsNext; // FIXME: this is a hack + KPushButton *_buttonStartTest; + /** Group of answers. This is a frame an check or radio buttons. */ + KGroupEduca *_buttonGroup; + /** KEDUCA file */ + FileRead *_keducaFile; + /** A question text with pixmaps and movies support */ + KQuestion *_questionText; + /** A question text with pixmaps and movies support */ + QTextEdit *_viewResults; + QTextEdit *_viewInfo; + /** Current record */ + int _keducaFileIndex; + /** Current results */ + QString _results; + /** Main vbox */ + QVBoxLayout *_vbox2; + /** Main splitt */ + QSplitter *_split; + /** Current results */ + QString _currentResults; + /** If is init window */ + bool _isInitStatus; + QTimer *_timeoutTimer; + /** Num of correct answers */ + int _correctAnswer; + /** Number of incorrect answers */ + int _incorrectAnswer; + /** Number of correct answers in points*/ + int _correctPoints; + /** Number of incorrect answers in points*/ + int _incorrectPoints; + /** Current time */ + int _currentTime; + /** Show results when finish? */ + bool _showResultFinish; + /** Show random questions */ + bool _showRandomQuestions; + /** Show random answers */ + bool _showRandomAnswers; + /** Save real order by random questions */ + QValueList<uint> _randomQuestions; + /** Save real order by random answers */ + QValueList<uint> _randomAnswers; +private slots: + /** Button Next action */ + void slotButtonNext(); + void slotButtonSave(); + void slotButtonStartTest(); + void questionTimedOut(); +}; + +#endif diff --git a/keduca/keduca/kgroupeduca.cpp b/keduca/keduca/kgroupeduca.cpp new file mode 100644 index 00000000..7cdb8b38 --- /dev/null +++ b/keduca/keduca/kgroupeduca.cpp @@ -0,0 +1,102 @@ +/*************************************************************************** + kgroupeduca.cpp - description + ------------------- + begin : Thu Sep 7 2000 + copyright : (C) 2000 by Javier Campos Morales + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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 "kgroupeduca.h" +#include "kgroupeduca.moc" +#include "kcheckeduca.h" +#include "kradioeduca.h" + +#include <klocale.h> + +KGroupEduca::KGroupEduca(QWidget *parent, const char *name ) : QVButtonGroup(i18n("Answers"), parent, name) +{ + _sv = new QScrollView(this); + _sv->setVScrollBarMode(QScrollView::Auto); + _sv->setHScrollBarMode(QScrollView::Auto); + _sv->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); + _vbox2 = new QVBox( _sv->viewport() ); + _vbox2->setSpacing( 6 ); + _vbox2->setMargin( 11 ); + _sv->viewport()->setBackgroundMode( _vbox2->backgroundMode() ); + _sv->setStaticBackground(true); + _sv->addChild( _vbox2 ); + _typeMode = Radio; +} + +KGroupEduca::~KGroupEduca(){ +} + +/** Insert a check or radio button */ +void KGroupEduca::insertAnswer( const QString& text) +{ + QButton *answer = 0; + + switch( _typeMode ) + { + case Radio: + answer = new KRadioEduca( _vbox2 ); + break; + case Check: + answer = new KCheckEduca( _vbox2 ); + break; + } + answer->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0 ) ); + answer->setText( text ); + answer->show(); + insert(answer); +} + +/** Set type */ +void KGroupEduca::setType(ButtonType type) +{ + _typeMode = type; +} + +/** Clear all kradio or kcheck answers */ +void KGroupEduca::clearAnswers() +{ + unsigned int maxButton = count(); + for( unsigned int i=0 ; i<maxButton ; ++i ) + { + QButton *tmpButton; + if( (tmpButton = find(i)) ) + remove(tmpButton); + delete tmpButton; + } + +} + +/** Return if is checked radio or check buttons */ +bool KGroupEduca::isChecked(int id) +{ + switch( _typeMode ) + { + case Radio: + { + KRadioEduca *tmpRadioButton = (KRadioEduca*) find(id); + if(tmpRadioButton != 0) return tmpRadioButton->isChecked(); + } + break; + case Check: + { + KCheckEduca *tmpCheckButton = (KCheckEduca*) find(id); + if(tmpCheckButton != 0) return tmpCheckButton->isChecked(); + } + break; + } + return 0; +} diff --git a/keduca/keduca/kgroupeduca.h b/keduca/keduca/kgroupeduca.h new file mode 100644 index 00000000..f0dbd904 --- /dev/null +++ b/keduca/keduca/kgroupeduca.h @@ -0,0 +1,57 @@ +/*************************************************************************** + kgroupeduca.h - description + ------------------- + begin : Thu Sep 7 2000 + copyright : (C) 2000 by Javier Campos Morales + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef KGROUPEDUCA_H +#define KGROUPEDUCA_H + +#include <qvbuttongroup.h> +#include <qscrollview.h> +#include <qvbox.h> + +/** + *@author Javier Campos Morales + */ +class KGroupEduca : public QVButtonGroup { + Q_OBJECT + +public: + enum ButtonType { Radio, Check }; + + KGroupEduca(QWidget *parent=0, const char *name=0); + ~KGroupEduca(); + /** Insert a check or radio button */ + void insertAnswer( const QString& text); + /** Set type */ + void setType(ButtonType Type); + /** Clear all kradio or kcheck answers */ + void clearAnswers(); + /** Return if is checked radio or check buttons */ + bool isChecked(int id); + +protected: + QVBox* _vbox2; + +private: + + // Private attributes + + QScrollView *_sv; + /** Type mode */ + ButtonType _typeMode; +}; + +#endif diff --git a/keduca/keduca/kquestion.cpp b/keduca/keduca/kquestion.cpp new file mode 100644 index 00000000..262f89b3 --- /dev/null +++ b/keduca/keduca/kquestion.cpp @@ -0,0 +1,123 @@ +/*************************************************************************** + kquestion.cpp - description + ------------------- + begin : Tue May 22 2001 + copyright : (C) 2001 by Javier Campos Morales + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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 "kquestion.h" +#include "kquestion.moc" + +#include <qlayout.h> +#include <qpixmap.h> +#include <qvbox.h> +#include <qtimer.h> + +#include <kprogress.h> +#include <klocale.h> + +KQuestion::KQuestion( QWidget *parent, const char *name ) + : QHBox( parent, name ), _countdownTimer( 0 ) +{ + initGUI(); +} + +KQuestion::~KQuestion() +{ +} + +/** Init graphical interface */ +void KQuestion::initGUI() +{ + setFrameShape( QFrame::Box ); + setFrameShadow( QFrame::Plain ); + setPalette( QPalette( Qt::white ) ); + + QVBox *picBox = new QVBox( this ); + + _picture = new QLabel( picBox, "PixmapLabel1" ); + _picture->setScaledContents( FALSE ); + _picture->setPalette( QPalette( Qt::white ) ); + + _countdownWidget = new KProgress( picBox ); + _countdownWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, + QSizePolicy::Preferred ) ); + _countdownWidget->setFormat( i18n( "%v seconds left" ) ); + + _view = new QTextEdit( this, "TextView1" ); + _view->setReadOnly( true ); + _view->setFrameShape( QTextEdit::NoFrame ); + _view->setHScrollBarMode( QTextEdit::AlwaysOff ); + _view->setTextFormat( QTextEdit::RichText ); + _view->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, true ) ); +} + +/** Set text */ +void KQuestion::setText( const QString &text) +{ + _view->setText( text ); +} + +/** Set pixmap */ +void KQuestion::setPixmap( const QPixmap pixmap) +{ + _picture->setPixmap( pixmap ); +} + +void KQuestion::countdown(int starttime) +{ + _totalCount = starttime; + _currentCount = starttime; + if (starttime > 0) + { + if (!_countdownTimer) + { + _countdownTimer = new QTimer(this); + connect(_countdownTimer, SIGNAL(timeout()), + this, SLOT(countDownOne())); + } + _countdownTimer->start(1000); + // make one step less than time passes by in seconds + // so that the user will see when time is up + _countdownWidget->setTotalSteps(starttime); + _countdownWidget->setProgress(starttime); + }else{ + _countdownTimer->stop(); + _countdownWidget->reset(); + } +} + +void KQuestion::countDownOne() +{ + _currentCount--; + //_countdownWidget->setProgress(_totalCount - _currentCount); + _countdownWidget->advance(-1); + + if (_currentCount == 0) + _countdownTimer->stop(); +} + +void KQuestion::countdownVisible(bool visible) +{ + if (visible) + _countdownWidget->show(); + else + _countdownWidget->hide(); +} + +/** Get current time */ +int KQuestion::getCurrentTime() +{ + return _totalCount - _currentCount; +} diff --git a/keduca/keduca/kquestion.h b/keduca/keduca/kquestion.h new file mode 100644 index 00000000..1753375e --- /dev/null +++ b/keduca/keduca/kquestion.h @@ -0,0 +1,79 @@ +/*************************************************************************** + kquestion.h - description + ------------------- + begin : Tue May 22 2001 + copyright : (C) 2001 by Javier Campos Morales + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#ifndef KQUESTION_H +#define KQUESTION_H + +#include <qhbox.h> +#include <qtextedit.h> +#include <qlabel.h> + +class QTimer; +class KProgress; + +/**Question view + * The Widget that is used to display the Question. + *@author Javier Campos Morales + */ +class KQuestion : public QHBox +{ + Q_OBJECT + +public: + KQuestion(QWidget *parent=0, const char *name=0); + ~KQuestion(); + /** Set pixmap */ + void setPixmap( const QPixmap pixmap); + /** Set text */ + void setText( const QString &text); + + /** show a countdown, starting at "starttime" and counting + down to 0, each second one count. + + 0 disables the countdown. + */ + void countdown(int starttime); + + void countdownVisible(bool visible); + + /** Get current time */ + int getCurrentTime(); + +private slots: + void countDownOne(); + +private: + + // Private methods + + /** Init graphical interface */ + void initGUI(); + + // Private attributes + + /** Main View */ + QTextEdit *_view; + /** Main Picture */ + QLabel *_picture; + QTimer *_countdownTimer; + KProgress *_countdownWidget; + int _currentCount; + int _totalCount; +}; + +#endif diff --git a/keduca/keduca/kradioeduca.cpp b/keduca/keduca/kradioeduca.cpp new file mode 100644 index 00000000..94f26eeb --- /dev/null +++ b/keduca/keduca/kradioeduca.cpp @@ -0,0 +1,83 @@ +/*************************************************************************** + kradioeduca.cpp - description + ------------------- + begin : Wed Sep 6 2000 + copyright : (C) 2000 by Javier Campos Morales + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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 "kradioeduca.h" +#include "kradioeduca.moc" +#include <qstyle.h> +#include <kaccelmanager.h> + +KRadioEduca::KRadioEduca(QWidget *parent, const char *name) : QRadioButton(parent,name) +{ + _doc=0; + KAcceleratorManager::setNoAccel(this); +} + +KRadioEduca::~KRadioEduca() +{ + delete _doc; +} + +/** reimpl */ +void KRadioEduca::drawButtonLabel( QPainter *p) +{ + int x, y, w, h; + int extra_width, indicator_width; + extra_width = 8; + indicator_width = style().pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, 0); + + y = 0; + x = indicator_width + extra_width; //### + w = width() - x; + h = height(); + + QRect cr(x,y,w,h); + + _doc = new QSimpleRichText( text(), font() ); + _doc->setWidth( 10 ); + + _doc->setWidth(p, cr.width() ); + int rw = _doc->widthUsed() + extra_width; + int rh = _doc->height(); + int xo = 0; + int yo = 0; + + resize( width(), rh); + + yo = (cr.height()-rh)/2; + + if (!isEnabled() ) { + QColorGroup cg = colorGroup(); + cg.setColor( QColorGroup::Text, cg.light() ); + _doc->draw(p, cr.x()+xo+1, cr.y()+yo+1, cr, cg, 0); + } + _doc->draw(p, cr.x()+xo, cr.y()+yo, cr, colorGroup(), 0); + + if ( hasFocus() ) { +// QRect br = style().itemRect( p, x, y, rw, rh+yo, +// AlignLeft|AlignVCenter|ShowPrefix, +// isEnabled(), +// pixmap(), text().visual() ); + QRect br(x,y,rw,rh+yo); + + br.setLeft( br.left()-3 ); + br.setRight( br.right()+2 ); + br.setTop( br.top()-2 ); + br.setBottom( br.bottom()+2); + br = br.intersect( QRect(0,0,rw, rh+yo ) ); + style().drawPrimitive( QStyle::PE_FocusRect, p, br, colorGroup()); + } +} diff --git a/keduca/keduca/kradioeduca.h b/keduca/keduca/kradioeduca.h new file mode 100644 index 00000000..b17276d9 --- /dev/null +++ b/keduca/keduca/kradioeduca.h @@ -0,0 +1,51 @@ +/*************************************************************************** + kradioeduca.h - description + ------------------- + begin : Wed Sep 6 2000 + copyright : (C) 2000 by Javier Campos Morales + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef KRADIOEDUCA_H +#define KRADIOEDUCA_H + + +#include <qradiobutton.h> +#include <qsimplerichtext.h> + +/**QRadioButton with wordwrap and richtext features + *@author Javier Campos Morales + */ +class KRadioEduca : public QRadioButton { + Q_OBJECT + +public: + KRadioEduca(QWidget *parent=0, const char *name=0); + ~KRadioEduca(); + +protected: + + // Protected methods + + /** reimpl */ + void drawButtonLabel( QPainter *p); + +private: + + // Private attributes + + /** Rich Text */ + QSimpleRichText *_doc; + +}; + +#endif diff --git a/keduca/keduca/main.cpp b/keduca/keduca/main.cpp new file mode 100644 index 00000000..9b33280b --- /dev/null +++ b/keduca/keduca/main.cpp @@ -0,0 +1,68 @@ +/*************************************************************************** + main.cpp - description + ------------------- + begin : mié may 23 20:36:15 CEST 2001 + copyright : (C) 2001 by Javier Campos + email : javi@asyris.org +***************************************************************************/ + +/*************************************************************************** + * * + * 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 <kcmdlineargs.h> +#include <kaboutdata.h> +#include <kdebug.h> + +#include <qfileinfo.h> +#include "keduca.h" + +static const char description[] = I18N_NOOP("Form-based tests and exams"); +static const char version[] = "1.3"; + +static KCmdLineOptions options[] = +{ + { "+file", I18N_NOOP("File to load"), 0 }, + KCmdLineLastOption +}; + +int main(int argc, char *argv[]) +{ + KAboutData aboutData( "keduca", I18N_NOOP("KEduca"), + version, description, KAboutData::License_GPL, + "(c) 2001, Javier Campos", 0, "http://keduca.sourceforge.net", "submit@bugs.kde.org"); + aboutData.addAuthor("Javier Campos",I18N_NOOP( "Original Author" ), "javi@asyris.org"); + aboutData.addAuthor("Klas Kalass",I18N_NOOP( "Maintainer 2002-2004" ), "klas@kde.org"); + aboutData.addAuthor("Henrique Pinto",I18N_NOOP( "Current Maintainer" ), "henrique.pinto@kdemail.net"); + aboutData.addAuthor("Anne-Marie Mahfouf",I18N_NOOP( "Various fixes and cleanups" ), "annma@kde.org"); + + aboutData.addCredit("Nenad Grujicic", I18N_NOOP("Icons"), "mengele@linuxo.org"); + + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + + KApplication a; + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + // start as KEduca TestMaster + Keduca *keducaTestMaster = new Keduca(); + a.setMainWidget(keducaTestMaster); + keducaTestMaster->show(); + + if ( args->count() > 0 ) + { + if( QFileInfo( KURL(args->url(0)).url() ).extension() == "edugallery" ) + keducaTestMaster->initGallery( args->url(0) ); + else + keducaTestMaster->slotFileOpenURL( args->url(0) ); + } + + args->clear(); + + return a.exec(); +} diff --git a/keduca/keduca/settings.kcfgc b/keduca/keduca/settings.kcfgc new file mode 100644 index 00000000..2a9bec07 --- /dev/null +++ b/keduca/keduca/settings.kcfgc @@ -0,0 +1,4 @@ +File=keduca.kcfg +ClassName=Settings +Singleton=true +Mutators=true
\ No newline at end of file |