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
18 #include "exporttosvgdialog.h"
19 #include "exporttosvgdialog.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>
29 #include <kmessagebox.h>
30 #include <kpushbutton.h>
31 #include <kurlrequester.h>
33 ExportToSVGDialog::ExportToSVGDialog( KigWidget
* v
, const KigPart
* part
)
34 : ExportToSVGDialogBase( v
, "Export to SVG 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() );
44 QString formats
= i18n( "*.svg|Scalable Vector Graphics (*.svg)" );
46 URLRequester
->setFilter( formats
);
47 URLRequester
->setMode( KFile::File
| KFile::LocalOnly
);
48 URLRequester
->setCaption( i18n( "Export as SVG" ) );
50 connect( OKButton
, SIGNAL( clicked() ), this, SLOT( slotOKPressed() ) );
51 connect( CancelButton
, SIGNAL( clicked() ), this, SLOT( slotCancelPressed() ) );
54 void ExportToSVGDialog::slotOKPressed()
56 QString filename
= URLRequester
->url();
57 if ( filename
.isEmpty() )
59 KMessageBox::sorry( mv
, i18n( "Please enter a file name." ) );
62 QFile
file( filename
);
65 int ret
= KMessageBox::warningYesNo( mv
,
66 i18n( "The file \"%1\" already exists. Do you wish to overwrite it?" )
67 .arg( filename
), i18n( "Overwrite File?" ) );
68 if ( ret
!= KMessageBox::Yes
) return;
72 if ( ! file.open( IO_WriteOnly ) )
74 KMessageBox::sorry( mv,
75 i18n( "The file \"%1\" could not be opened. Please "
76 "check if the file permissions are set correctly." )
84 void ExportToSVGDialog::slotCancelPressed()
89 ExportToSVGDialog::~ExportToSVGDialog()
93 QString
ExportToSVGDialog::fileName()
95 return URLRequester
->url();
98 bool ExportToSVGDialog::showAxes()
100 return showAxesCheckBox
->isOn();
103 bool ExportToSVGDialog::showGrid()
105 return showGridCheckBox
->isOn();