1 /***************************************************************************
2 keducaeditorstartdialog.cpp - description
4 begin : Fri May 10 2002
5 copyright : (C) 2002 by Klas Kalass
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 ***************************************************************************/
17 #include <qradiobutton.h>
18 #include <qbuttongroup.h>
21 #include <kurlrequester.h>
22 #include <kmessagebox.h>
25 #include <kcombobox.h>
27 #include "keducaeditorstartdialog.h"
28 #include "keducabuilder.h"
32 KEducaEditorStartDialog::KEducaEditorStartDialog(KEducaBuilder
* parent
, const char* name
, bool modal
, WFlags fl
)
33 :KEducaEditorStartDialogBase(parent
, name
, modal
, fl
),
35 _maxRecentDocumentItems(20)
37 newDocumentRB
->setFocus();
40 buildRecentFilesList();
43 urlRequester
->setFilter( "application/x-edu");
45 connect( startChoiceBtnGrp
, SIGNAL( clicked(int) ),
46 this, SLOT( slotChoiceChanged(int) ) );
49 /** based on code in kaction.cpp
51 void KEducaEditorStartDialog::buildRecentFilesList()
56 KConfig
*config
= KGlobal::config();
58 oldGroup
= config
->group();
60 config
->setGroup( "RecentFiles" );
63 for( unsigned int i
= 1 ; i
<= _maxRecentDocumentItems
; i
++ )
65 key
= QString( "File%1" ).arg( i
);
66 value
= config
->readEntry( key
, QString::null
);
69 recentDocumentCB
->insertURL( KURL(value
) );
72 config
->setGroup( oldGroup
);
75 KEducaEditorStartDialog::~KEducaEditorStartDialog() {
79 void KEducaEditorStartDialog::slotChoiceChanged(int id
) {
83 KURL
KEducaEditorStartDialog::getURL()const{
86 return KURL(urlRequester
->url());
89 return KURL(recentDocumentCB
->currentText());
98 int KEducaEditorStartDialog::exec() {
99 int ret
= KEducaEditorStartDialogBase::exec();
100 if ( ret
== KEducaEditorStartDialogBase::Rejected
)
101 _choice
= KEducaEditorStartDialog::Rejected
;
106 void KEducaEditorStartDialog::accept() {
107 if (((_choice
== OpenDoc
|| _choice
== OpenRecentDoc
)
108 && getURL().isEmpty())) {
109 KMessageBox::sorry(this, i18n("You need to specify the file to open!"));
111 KEducaEditorStartDialogBase::accept();
114 #include "keducaeditorstartdialog.moc"