moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kig / filters / exporttolatexdialog.cc
blob095e3ff2b4ab62fbb31c88ef4a5df0492474f590
1 // Copyright (C) 2004 Pino Toscano <toscano.pino@tiscali.it>
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
16 // 02111-1307, USA.
18 #include "exporttolatexdialog.h"
19 #include "exporttolatexdialog.moc"
21 #include "../kig/kig_document.h"
22 #include "../kig/kig_part.h"
23 #include "../kig/kig_view.h"
25 #include <qcheckbox.h>
27 #include <kiconloader.h>
28 #include <klocale.h>
29 #include <kmessagebox.h>
30 #include <kpushbutton.h>
31 #include <kurlrequester.h>
33 ExportToLatexDialog::ExportToLatexDialog( KigWidget* v, const KigPart* part )
34 : ExportToLatexDialogBase( v, "Export to latex dialog", true ),
35 mv( v ), mpart( part )
37 KIconLoader* l = part->instance()->iconLoader();
38 OKButton->setIconSet( QIconSet( l->loadIcon( "button_ok", KIcon::Small ) ) );
39 CancelButton->setIconSet( QIconSet( l->loadIcon( "button_cancel", KIcon::Small ) ) );
41 showGridCheckBox->setChecked( part->document().grid() );
42 showAxesCheckBox->setChecked( part->document().axes() );
43 showExtraFrameCheckBox->setChecked( false );
45 QString formats = i18n( "*.tex|Latex Documents (*.tex)" );
47 URLRequester->setFilter( formats );
48 URLRequester->setMode( KFile::File | KFile::LocalOnly );
49 URLRequester->setCaption( i18n( "Export as Latex" ) );
51 connect( OKButton, SIGNAL( clicked() ), this, SLOT( slotOKPressed() ) );
52 connect( CancelButton, SIGNAL( clicked() ), this, SLOT( slotCancelPressed() ) );
55 void ExportToLatexDialog::slotOKPressed()
57 QString filename = URLRequester->url();
58 if ( filename.isEmpty() )
60 KMessageBox::sorry( mv, i18n( "Please enter a file name." ) );
61 return;
63 QFile file( filename );
64 if ( file.exists() )
66 int ret = KMessageBox::warningYesNo( mv,
67 i18n( "The file \"%1\" already exists. Do you wish to overwrite it?" )
68 .arg( filename ), i18n( "Overwrite File?" ) );
69 if ( ret != KMessageBox::Yes ) return;
72 accept();
75 void ExportToLatexDialog::slotCancelPressed()
77 reject();
80 ExportToLatexDialog::~ExportToLatexDialog()
84 QString ExportToLatexDialog::fileName()
86 return URLRequester->url();
89 bool ExportToLatexDialog::showAxes()
91 return showAxesCheckBox->isOn();
94 bool ExportToLatexDialog::showGrid()
96 return showGridCheckBox->isOn();
99 bool ExportToLatexDialog::extraFrame()
101 return showExtraFrameCheckBox->isOn();