filters
ExportDialog.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qtextcodec.h>
00022
00023 #include <klocale.h>
00024 #include <kcharsets.h>
00025 #include <kglobal.h>
00026 #include <kdebug.h>
00027 #include <kapplication.h>
00028 #include <kcombobox.h>
00029 #include <kmessagebox.h>
00030 #include <qlabel.h>
00031 #include <qlayout.h>
00032 #include <qradiobutton.h>
00033 #include <qvbuttongroup.h>
00034 #include <qcheckbox.h>
00035 #include <kurlrequester.h>
00036
00037 #include <ExportDialogUI.h>
00038 #include <ExportDialog.h>
00039
00040 HtmlExportDialog :: HtmlExportDialog(QWidget* parent)
00041 : KDialogBase(parent, 0, true, i18n("KWord's HTML Export Filter"), Ok|Cancel, No, true),
00042 m_dialog(new ExportDialogUI(this))
00043 {
00044
00045 kapp->restoreOverrideCursor();
00046
00047 QStringList encodingList;
00048
00049 encodingList += i18n( "Descriptive encoding name", "Recommended ( %1 )" ).arg( "UTF-8" );
00050 encodingList += i18n( "Descriptive encoding name", "Locale ( %1 )" ).arg( QTextCodec::codecForLocale()->name() );
00051 encodingList += KGlobal::charsets()->descriptiveEncodingNames();
00052
00053 m_dialog->comboBoxEncoding->insertStringList( encodingList );
00054
00055 m_dialog->KURL_ExternalCSS->setMode( KFile::ExistingOnly );
00056
00057 connect(m_dialog->radioModeEnhanced, SIGNAL( toggled( bool ) ),
00058 SLOT( setCSSEnabled( bool ) ) );
00059 connect(m_dialog->checkExternalCSS, SIGNAL( toggled( bool ) ),
00060 m_dialog->KURL_ExternalCSS, SLOT( setEnabled( bool ) ) );
00061
00062 setMainWidget(m_dialog);
00063 }
00064
00065 HtmlExportDialog :: ~HtmlExportDialog(void)
00066 {
00067 kapp->setOverrideCursor(Qt::waitCursor);
00068 }
00069
00070 void HtmlExportDialog::setCSSEnabled( bool b )
00071 {
00072 m_dialog->checkExternalCSS->setEnabled( b );
00073 m_dialog->KURL_ExternalCSS->setEnabled( b && m_dialog->checkExternalCSS->isChecked() );
00074 }
00075
00076 bool HtmlExportDialog::isXHtml(void) const
00077 {
00078 if(m_dialog->radioDocType1==m_dialog->buttonGroup1->selected())
00079 return false;
00080 else if(m_dialog->radioDocType2==m_dialog->buttonGroup1->selected())
00081 return true;
00082 return true;
00083 }
00084
00085 QTextCodec* HtmlExportDialog::getCodec(void) const
00086 {
00087 const QString strCodec( KGlobal::charsets()->encodingForName( m_dialog->comboBoxEncoding->currentText() ) );
00088 kdDebug(30503) << "Encoding: " << strCodec << endl;
00089
00090 bool ok = false;
00091 QTextCodec* codec = QTextCodec::codecForName( strCodec.utf8() );
00092
00093
00094 if ( codec )
00095 {
00096 ok = true;
00097 }
00098 else
00099 {
00100 codec = KGlobal::charsets()->codecForName( strCodec, ok );
00101 }
00102
00103
00104 if ( !codec || !ok )
00105 {
00106
00107 kdWarning(30503) << "Cannot find encoding:" << strCodec << endl;
00108
00109 KMessageBox::error( 0, i18n("Cannot find encoding: %1").arg( strCodec ) );
00110 return 0;
00111 }
00112
00113 return codec;
00114 }
00115
00116 HtmlExportDialog::Mode HtmlExportDialog::getMode(void) const
00117 {
00118 if( m_dialog->radioModeEnhanced->isChecked() )
00119 {
00120 if( m_dialog->checkExternalCSS->isChecked() )
00121 {
00122 return CustomCSS;
00123 }
00124 else
00125 {
00126 return DefaultCSS;
00127 }
00128 }
00129 else if ( m_dialog->radioModeBasic->isChecked() )
00130 {
00131 return Basic;
00132 }
00133 else if ( m_dialog->radioModeLight->isChecked() )
00134 {
00135 return Light;
00136 }
00137 return DefaultCSS;
00138 }
00139
00140 QString HtmlExportDialog::cssURL(void) const
00141 {
00142 return m_dialog->KURL_ExternalCSS->url();
00143 }
00144
00145 #include <ExportDialog.moc>
|