21#include "KoMainWindow.h"
22#include "KoDocument.h"
24#include "KoFilterManager.h"
25#include "KoDocumentInfo.h"
26#include "KoDocumentInfoDlg.h"
27#include "KoQueryTrader.h"
28#include "KoMainWindowIface.h"
30#include "KoFileDialog.h"
31#include "Koversiondialog.h"
35#include <tdeaboutdata.h>
37#include <tdeversion.h>
38#include <kstdaction.h>
39#include <tdeapplication.h>
40#include <tdemessagebox.h>
41#include <kstandarddirs.h>
42#include <tdeio/netaccess.h>
43#include <kkeydialog.h>
44#include <kedittoolbar.h>
46#include <kpushbutton.h>
48#include <tdetempfile.h>
49#include <tderecentdocument.h>
50#include <tdeparts/partmanager.h>
51#include <tdeparts/plugin.h>
52#include <tdeparts/event.h>
54#include <kstatusbar.h>
55#include <tdeglobalsettings.h>
56#include <ksharedptr.h>
58#include <tqobjectlist.h>
66 KoPartManager( TQWidget * parent,
const char * name = 0L )
77 virtual bool eventFilter( TQObject *obj, TQEvent *ev )
79 if ( !obj->isWidgetType() || ::tqt_cast<KoFrame *>( obj ) )
81 return KParts::PartManager::eventFilter( obj, ev );
85class KoMainWindowPrivate
93 bMainWindowGUIBuilt =
false;
101 m_toolbarList.setAutoDelete(
true );
108 m_paPrintPreview = 0;
117 m_isImporting =
false;
118 m_isExporting =
false;
119 m_windowSizeDirty =
false;
120 m_lastExportSpecialOutputFlag = 0;
125 m_koSpeaker = kospeaker;
131 ~KoMainWindowPrivate()
138 TQPtrList<KoView> m_rootViews;
144 TQLabel * statusBarLabel;
147 TQPtrList<TDEAction> m_splitViewActionList;
150 TQPtrList<TDEAction> m_veryHackyActionList;
151 TQSplitter *m_splitter;
154 KoMainWindowIface *m_dcopObject;
156 TQPtrList <TDEAction> m_toolbarList;
158 bool bMainWindowGUIBuilt;
162 bool m_windowSizeDirty;
179 KURL m_lastExportURL;
180 TQCString m_lastExportFormat;
181 int m_lastExportSpecialOutputFlag;
183 TDESharedPtr<KoSpeaker> m_koSpeaker;
187 :
KParts::MainWindow( 0, 0L, name )
191 d =
new KoMainWindowPrivate;
193 d->m_manager =
new KoPartManager(
this );
195 connect( d->m_manager, TQ_SIGNAL( activePartChanged(
KParts::Part * ) ),
196 this, TQ_SLOT( slotActivePartChanged(
KParts::Part * ) ) );
204 TQStringList allFiles = TDEGlobal::dirs()->findAllResources(
"data",
"koffice/koffice_shell.rc" );
205 setXMLFile( findMostRecentXMLFile( allFiles, doc ) );
206 setLocalXMLFile( locateLocal(
"data",
"koffice/koffice_shell.rc" ) );
220 d->m_reloadfile =
new TDEAction( i18n(
"Reload"), 0,
224 d->m_versionsfile =
new TDEAction( i18n(
"Versions..."), 0,
228 d->m_importFile =
new TDEAction( i18n(
"I&mport..." ), 0,
231 d->m_exportFile =
new TDEAction( i18n(
"E&xport..." ), 0,
237 d->m_paDocInfo =
new TDEAction( i18n(
"&Document Information" ),
"documentinfo", 0,
244 d->m_paDocInfo->setEnabled(
false );
245 d->m_paSaveAs->setEnabled(
false );
246 d->m_reloadfile->setEnabled(
false );
247 d->m_versionsfile->setEnabled(
false );
248 d->m_importFile->setEnabled(
true );
249 d->m_exportFile->setEnabled(
false );
250 d->m_paSave->setEnabled(
false );
251 d->m_paPrint->setEnabled(
false );
252 d->m_paPrintPreview->setEnabled(
false );
253 d->m_sendfile->setEnabled(
false);
254 d->m_paCloseFile->setEnabled(
false);
256 d->m_splitter=
new TQSplitter(TQt::Vertical,
this,
"mw-splitter");
257 setCentralWidget( d->m_splitter );
261 d->m_veryHackyActionList.append(
262 new TDEAction(i18n(
"&Close All Views"),
"window-close",
267 d->m_splitViewActionList.append(
new TDEAction(i18n(
"&Split View"),
"view_split", 0,
270 d->m_removeView=
new TDEAction(i18n(
"&Remove View"),
"view_remove", 0,
271 this, TQ_SLOT(slotRemoveView()),
273 d->m_splitViewActionList.append(d->m_removeView);
274 d->m_removeView->setEnabled(
false);
275 d->m_orientation=
new TDESelectAction(i18n(
"Splitter &Orientation"),
"view_orientation", 0,
276 this, TQ_SLOT(slotSetOrientation()),
279 items << i18n(
"&Vertical")
280 << i18n(
"&Horizontal");
281 d->m_orientation->setItems(items);
282 d->m_orientation->setCurrentItem(
static_cast<int>(d->m_splitter->orientation()));
283 d->m_splitViewActionList.append(d->m_orientation);
284 d->m_splitViewActionList.append(
new TDEActionSeparator(
this));
291 d->bMainWindowGUIBuilt =
true;
296 const int deskWidth = TDEGlobalSettings::desktopGeometry(
this).width();
297 if (deskWidth > 1100)
306 config->setGroup(
"MainWindow" );
319 d->m_rootDoc->removeShell(
this);
322 if (d->m_docToOpen) {
323 d->m_docToOpen->removeShell(
this);
324 delete d->m_docToOpen;
329 d->m_manager->setActivePart(0);
331 if(d->m_rootViews.findRef(d->m_activeView)==-1) {
332 delete d->m_activeView;
335 d->m_rootViews.setAutoDelete(
true );
336 d->m_rootViews.clear();
341 if ( d->m_rootDoc && d->m_rootDoc->viewCount() == 0 &&
342 !d->m_rootDoc->isEmbedded())
357 if ( d->m_rootDoc == doc )
360 if (d->m_docToOpen && d->m_docToOpen != doc) {
361 d->m_docToOpen->removeShell(
this);
362 delete d->m_docToOpen;
369 TQPtrList<KoView> oldRootViews = d->m_rootViews;
370 d->m_rootViews.clear();
382 d->m_rootViews.append( doc->
createView( d->m_splitter,
"view" ) );
383 d->m_rootViews.current()->setPartManager( d->m_manager );
385 d->m_rootViews.current()->show();
387 if ( !d->m_rootDoc->shells().contains(
this ) )
388 d->m_rootDoc->addShell(
this );
389 d->m_removeView->setEnabled(
false);
390 d->m_orientation->setEnabled(
false);
393 bool enable = d->m_rootDoc != 0 ? true :
false;
394 d->m_paDocInfo->setEnabled( enable );
395 d->m_paSave->setEnabled( enable );
396 d->m_paSaveAs->setEnabled( enable );
397 d->m_importFile->setEnabled( enable );
398 d->m_exportFile->setEnabled( enable );
399 d->m_paPrint->setEnabled( enable );
400 d->m_paPrintPreview->setEnabled( enable );
401 d->m_sendfile->setEnabled( enable);
402 d->m_paCloseFile->setEnabled( enable);
405 d->m_manager->setActivePart( d->m_rootDoc, d->m_rootViews.current() );
407 oldRootViews.setAutoDelete(
true );
408 oldRootViews.clear();
410 if ( oldRootDoc && oldRootDoc->
viewCount() == 0 )
417void KoMainWindow::updateReloadFileAction(
KoDocument *doc)
419 d->m_reloadfile->setEnabled( doc && !doc->
url().isEmpty() );
422void KoMainWindow::updateVersionsFileAction(
KoDocument *doc)
425 d->m_versionsfile->setEnabled( doc && !doc->
url().isEmpty()&&doc->
isModified());
432 d->m_rootViews = views;
433 bool enable = d->m_rootDoc != 0 ? true :
false;
434 d->m_paDocInfo->setEnabled( enable );
435 d->m_paSave->setEnabled( enable );
436 d->m_paSaveAs->setEnabled( enable );
437 d->m_exportFile->setEnabled( enable );
438 d->m_paPrint->setEnabled( enable );
439 d->m_paPrintPreview->setEnabled( enable );
440 d->m_sendfile->setEnabled( enable);
441 d->m_paCloseFile->setEnabled( enable );
446 kdDebug(30003) <<
"KoMainWindow::addRecentURL url=" << url.prettyURL() << endl;
449 if ( !url.isEmpty() )
452 if ( url.isLocalFile() )
454 TQString path = url.path( -1 );
455 TQStringList tmpDirs = TDEGlobal::dirs()->resourceDirs(
"tmp" );
456 for ( TQStringList::Iterator it = tmpDirs.begin() ; ok && it != tmpDirs.end() ; ++it )
457 if ( path.contains( *it ) )
460 TDERecentDocument::add(path);
463 TDERecentDocument::add(url.url(-1),
true);
474 TDEConfig * config =
instance() ?
instance()->config() : TDEGlobal::config();
475 kdDebug(30003) <<
this <<
" Saving recent files list into config. instance()=" <<
instance() << endl;
490 TDEConfig * config =
instance() ?
instance()->config() : TDEGlobal::config();
513 caption =
static_cast<KoDocumentInfoAbout *
>(page)->title();
515 const TQString url =
rootDocument()->
url().prettyURL( 0, KURL::StripFileProtocol );
516 if ( !caption.isEmpty() && !url.isEmpty() )
517 caption = TQString(
"%1 - %2" ).arg( caption ).arg( url );
518 else if ( caption.isEmpty() )
523 d->m_paSave->setToolTip( i18n(
"Save as %1").arg(
rootDocument()->url().fileName(
false)) );
525 d->m_paSave->setToolTip( i18n(
"Save") );
540KoView *KoMainWindow::rootView()
const
542 if(d->m_rootViews.find(d->m_activeView)!=-1)
543 return d->m_activeView;
544 return d->m_rootViews.first();
554 if ( !TDEIO::NetAccess::exists(url,
true,0) )
561 return openDocumentInternal( url );
567 if (!TDEIO::NetAccess::exists(url,
true,0) )
576 TQString mime = KMimeType::findByURL(url)->name();
577 if ( mime.isEmpty() || mime == KMimeType::defaultMimeType() )
579 if ( url.isLocalFile() )
581 newdoc->setMimeTypeAfterLoading( mime );
585 return openDocumentInternal( url, newdoc );
589bool KoMainWindow::openDocumentInternal(
const KURL & url,
KoDocument *newdoc )
599 connect(newdoc, TQ_SIGNAL(sigProgress(
int)),
this, TQ_SLOT(slotProgress(
int)));
600 connect(newdoc, TQ_SIGNAL(completed()),
this, TQ_SLOT(slotLoadCompleted()));
601 connect(newdoc, TQ_SIGNAL(canceled(
const TQString & )),
this, TQ_SLOT(slotLoadCanceled(
const TQString & )));
610 updateReloadFileAction(newdoc);
611 updateVersionsFileAction( newdoc );
616void KoMainWindow::slotLoadCompleted()
618 kdDebug(30003) <<
"KoMainWindow::slotLoadCompleted" << endl;
627 else if ( doc && !doc->
isEmpty() )
642 disconnect(newdoc, TQ_SIGNAL(sigProgress(
int)),
this, TQ_SLOT(slotProgress(
int)));
643 disconnect(newdoc, TQ_SIGNAL(completed()),
this, TQ_SLOT(slotLoadCompleted()));
644 disconnect(newdoc, TQ_SIGNAL(canceled(
const TQString & )),
this, TQ_SLOT(slotLoadCanceled(
const TQString & )));
647void KoMainWindow::slotLoadCanceled(
const TQString & errMsg )
649 kdDebug(30003) <<
"KoMainWindow::slotLoadCanceled" << endl;
650 if ( !errMsg.isEmpty() )
655 disconnect(newdoc, TQ_SIGNAL(sigProgress(
int)),
this, TQ_SLOT(slotProgress(
int)));
656 disconnect(newdoc, TQ_SIGNAL(completed()),
this, TQ_SLOT(slotLoadCompleted()));
657 disconnect(newdoc, TQ_SIGNAL(canceled(
const TQString & )),
this, TQ_SLOT(slotLoadCanceled(
const TQString & )));
663void KoMainWindow::slotSaveCanceled(
const TQString &errMsg )
665 kdDebug(30003) <<
"KoMainWindow::slotSaveCanceled" << endl;
666 if ( !errMsg.isEmpty() )
671void KoMainWindow::slotSaveCompleted()
673 kdDebug(30003) <<
"KoMainWindow::slotSaveCompleted" << endl;
675 disconnect(pDoc, TQ_SIGNAL(sigProgress(
int)),
this, TQ_SLOT(slotProgress(
int)));
676 disconnect(pDoc, TQ_SIGNAL(completed()),
this, TQ_SLOT(slotSaveCompleted()));
677 disconnect(pDoc, TQ_SIGNAL(canceled(
const TQString & )),
678 this, TQ_SLOT(slotSaveCanceled(
const TQString & )));
682bool KoMainWindow::exportConfirmation(
const TQCString &outputFormat )
684 if (!
rootDocument()->wantExportConfirmation())
return true;
685 KMimeType::Ptr mime = KMimeType::mimeType( outputFormat );
687 const bool neverHeardOfIt = ( mime->name() == KMimeType::defaultMimeType() );
688 TQString comment = neverHeardOfIt ?
689 i18n(
"%1 (unknown file type)" ).arg( outputFormat.data() )
699 i18n(
"<qt>Saving as a %1 may result in some loss of formatting."
700 "<p>Do you still want to save in this format?</qt>" )
701 .arg( TQString(
"<b>%1</b>" ).arg( comment ) ),
702 i18n(
"Confirm Save" ),
703 KStdGuiItem::save (),
704 "NonNativeSaveConfirmation",
713 i18n(
"<qt>Exporting as a %1 may result in some loss of formatting."
714 "<p>Do you still want to export to this format?</qt>" )
715 .arg( TQString(
"<b>%1</b>" ).arg( comment ) ),
716 i18n(
"Confirm Export" ),
718 "NonNativeExportConfirmation",
723 return (ret == KMessageBox::Continue);
733 if ( pDoc->
url().isEmpty() )
742 connect(pDoc, TQ_SIGNAL(sigProgress(
int)),
this, TQ_SLOT(slotProgress(
int)));
743 connect(pDoc, TQ_SIGNAL(completed()),
this, TQ_SLOT(slotSaveCompleted()));
744 connect(pDoc, TQ_SIGNAL(canceled(
const TQString & )),
745 this, TQ_SLOT(slotSaveCanceled(
const TQString & )));
747 KURL oldURL = pDoc->
url();
748 TQString oldFile = pDoc->
file();
750 TQCString oldOutputFormat = pDoc->outputMimeType();
751 int oldSpecialOutputFlag = pDoc->specialOutputFlag();
752 KURL suggestedURL = pDoc->
url();
755 if (mimeFilter.findIndex (oldOutputFormat) < 0 && !
isExporting())
757 kdDebug(30003) <<
"KoMainWindow::saveDocument no export filter for '" << oldOutputFormat <<
"'" << endl;
763 TQString suggestedFilename = suggestedURL.fileName ();
764 if ( !suggestedFilename.isEmpty () )
766 int c = suggestedFilename.findRev (
'.');
768 KMimeType::Ptr mime = KMimeType::mimeType( _native_format );
769 TQString ext = mime->property(
"X-TDE-NativeExtension" ).toString();
773 suggestedFilename += ext;
775 suggestedFilename = suggestedFilename.left (c) + ext;
782 suggestedFilename = suggestedFilename.left (c);
786 suggestedURL.setFileName (suggestedFilename);
795 if ( pDoc->
url().isEmpty() || saveas )
799 bool justChangingFilterOptions =
false;
802 TQString(),
this,
"file dialog",
true);
805 dialog->setCaption( i18n(
"Save Document As") );
807 dialog->setCaption( i18n(
"Export Document As") );
809 dialog->setOperationMode( KFileDialog::Saving );
810 dialog->setSpecialMimeFilter( mimeFilter,
812 isExporting() ? d->m_lastExportSpecialOutputFlag : oldSpecialOutputFlag,
817 TQCString outputFormat = _native_format;
818 int specialOutputFlag = 0;
822 if(dialog->exec()==TQDialog::Accepted) {
823 newURL=dialog->selectedURL();
824 outputFormat=dialog->currentMimeFilter().latin1();
825 specialOutputFlag = dialog->specialEntrySelected();
826 kdDebug(30003) <<
"KoMainWindow::saveDocument outputFormat = " << outputFormat << endl;
829 justChangingFilterOptions = (newURL == pDoc->
url()) &&
830 (outputFormat == pDoc->
mimeType()) &&
831 (specialOutputFlag == oldSpecialOutputFlag);
833 justChangingFilterOptions = (newURL == d->m_lastExportURL) &&
834 (outputFormat == d->m_lastExportFormat) &&
835 (specialOutputFlag == d->m_lastExportSpecialOutputFlag);
843 if ( newURL.isEmpty() )
850 if ( specialOutputFlag == KoDocument::SaveAsDirectoryStore ) {
851 TQString fileName = newURL.fileName();
852 if ( fileName !=
"content.xml" ) {
853 newURL.addPath(
"content.xml" );
859 if ( TDEIO::NetAccess::exists( newURL,
false ,
this ) && !justChangingFilterOptions )
862 i18n(
"A document with this name already exists.\n"\
863 "Do you want to overwrite it?"),
864 i18n(
"Warning") ) == KMessageBox::Yes;
872 bool wantToSave =
true;
877 wantToSave = exportConfirmation( outputFormat );
910 ret = pDoc->
saveAs( newURL );
914 kdDebug(30003) <<
"Successful Save As!" << endl;
919 kdDebug(30003) <<
"Failed Save As!" << endl;
926 ret = pDoc->
exp0rt( newURL );
931 d->m_lastExportURL = newURL;
932 d->m_lastExportFormat = outputFormat;
933 d->m_lastExportSpecialOutputFlag = specialOutputFlag;
950 (needConfirm && exportConfirmation( oldOutputFormat ))
958 kdDebug(30003) <<
"Failed Save!" << endl;
979 if ( wasModified && pDoc->outputMimeType() != _native_format )
984 if (!ret && reset_url)
991void KoMainWindow::closeEvent(TQCloseEvent *e) {
993 saveWindowSettings();
999void KoMainWindow::saveWindowSettings()
1004 instance()->config()->setGroup(
"MainWindow" );
1007 d->m_windowSizeDirty =
false;
1011 TDEGlobal::config()->sync();
1016void KoMainWindow::resizeEvent( TQResizeEvent * e )
1018 d->m_windowSizeDirty =
true;
1019 KParts::MainWindow::resizeEvent( e );
1028 if ( !d->m_forQuit &&
rootDocument()->shellCount() > 1 )
1033 if ( d->m_rootDoc->isEmbedded() )
1037 if ( d->m_rootDoc->isModified() )
1044 if ( name.isEmpty() )
1047 if ( name.isEmpty() )
1048 name = i18n(
"Untitled" );
1051 i18n(
"<p>The document <b>'%1'</b> has been modified.</p><p>Do you want to save it?</p>" ).arg(name),
1053 KStdGuiItem::save(),
1054 KStdGuiItem::discard());
1057 case KMessageBox::Yes : {
1058 d->m_rootDoc->setDoNotSaveExtDoc();
1059 bool isNative = ( d->m_rootDoc->outputMimeType() == d->m_rootDoc->nativeFormatMimeType() );
1064 case KMessageBox::No :
1073 if ( d->m_rootDoc->queryCloseExternalChildren() == KMessageBox::Cancel )
1091 connect(newdoc, TQ_SIGNAL(sigProgress(
int)),
this, TQ_SLOT(slotProgress(
int)));
1092 disconnect(newdoc, TQ_SIGNAL(sigProgress(
int)),
this, TQ_SLOT(slotProgress(
int)));
1094 if ( ( !doc && ( initDocFlags == KoDocument::InitDocFileNew ) ) || ( doc && !doc->
isEmpty() ) )
1105 delete d->m_rootDoc;
1120 KFileDialog *dialog =
new KFileDialog(
":OpenDialog", TQString(),
this,
"file dialog",
true);
1122 dialog->setCaption( i18n(
"Open Document") );
1124 dialog->setCaption( i18n(
"Import Document") );
1128 KoFilterManager::Import,
1130 dialog->setMimeFilter( mimeFilter );
1131 if(dialog->exec()!=TQDialog::Accepted) {
1135 KURL url( dialog->selectedURL() );
1138 if ( url.isEmpty() )
1171 KoDocumentInfoDlg *dlg =
new KoDocumentInfoDlg( docInfo,
this,
"documentInfoDlg" );
1186 saveWindowSettings();
1188 delete d->m_rootDoc;
1202 kdDebug(30003) <<
"KoMainWindow::slotFilePrint : No root view!" << endl;
1206 KPrinter printer(
true );
1208 TQString fileName = rootView()->
koDocument()->
url().fileName();
1211 KMimeType::Ptr mime = KMimeType::mimeType( rootView()->koDocument()->outputMimeType() );
1213 TQString extension = mime->property(
"X-TDE-NativeExtension" ).toString();
1215 if ( fileName.endsWith( extension ) )
1216 fileName.truncate( fileName.length() - extension.length() );
1219 if ( title.isEmpty() )
1221 if ( title.isEmpty() ) {
1226 printer.setDocName( title );
1227 printer.setDocFileName( fileName );
1228 printer.setDocDirectory( rootView()->koDocument()->url().directory() );
1234 if ( quick || printer.setup(
this ) )
1235 rootView()->
print( printer );
1248 kdWarning() <<
"KoMainWindow::slotFilePrint : No root view!" << endl;
1251 KPrinter printer(
false );
1257 printer.setFromTo( printer.minPage(), printer.maxPage() );
1258 printer.setPreviewOnly(
true );
1261 TQString oldFileName = printer.outputFileName();
1262 printer.setOutputFileName( tmpFile.name() );
1263 int oldNumCopies = printer.numCopies();
1264 printer.setNumCopies( 1 );
1267 TQString oldKDEPreview = printer.option(
"kde-preview" );
1268 printer.setOption(
"kde-preview",
"0" );
1270 rootView()->
print(printer);
1274 printer.setOutputFileName( oldFileName );
1275 printer.setNumCopies( oldNumCopies );
1276 printer.setOption(
"kde-preview", oldKDEPreview );
1281 guiFactory()->configureShortcuts();
1300 if( !d->m_activeView )
1304 factory->plugActionList(d->m_activeView,
"view_closeallviews",
1305 d->m_veryHackyActionList);
1308 if(d->m_rootViews.findRef(d->m_activeView)!=-1)
1309 factory->plugActionList(d->m_activeView,
"view_split",
1310 d->m_splitViewActionList );
1330 kdWarning(30003) <<
"slotToolbarToggled : Toolbar " << sender()->name() <<
" not found!" << endl;
1335 TQWidget *tb =
toolBar( tbName);
1336 return !tb->isHidden();
1341 TQWidget * tb =
toolBar( tbName );
1344 kdWarning(30003) <<
"KoMainWindow: toolbar " << tbName <<
" not found." << endl;
1353 TQPtrListIterator<TDEAction> it( d->m_toolbarList );
1354 for ( ; it.current() ; ++it )
1355 if ( !strcmp( it.current()->name(), tbName ) )
1365 d->m_rootViews.append(d->m_rootDoc->createView(d->m_splitter,
"splitted-view"));
1366 d->m_rootViews.current()->show();
1367 d->m_rootViews.current()->setPartManager( d->m_manager );
1368 d->m_manager->setActivePart( d->m_rootDoc, d->m_rootViews.current() );
1369 d->m_removeView->setEnabled(
true);
1370 d->m_orientation->setEnabled(
true);
1379 if(d->m_rootDoc && d->m_rootDoc->isEmbedded()) {
1381 d->m_rootDoc->removeShell(
this);
1382 TQPtrListIterator<KoMainWindow> it(d->m_rootDoc->shells());
1383 while (it.current()) {
1384 it.current()->hide();
1385 delete it.current();
1398void KoMainWindow::slotRemoveView() {
1400 if(d->m_rootViews.findRef(d->m_activeView)!=-1)
1401 view=d->m_rootViews.current();
1403 view=d->m_rootViews.first();
1405 if ( !d->m_rootViews.removeRef(view) )
1406 kdWarning() <<
"view not found in d->m_rootViews!" << endl;
1408 if(d->m_rootViews.count()==1)
1410 d->m_removeView->setEnabled(
false);
1411 d->m_orientation->setEnabled(
false);
1414 d->m_manager->setActivePart( 0, 0 );
1419 d->m_rootViews.first()->setPartManager( d->m_manager );
1420 d->m_manager->setActivePart( d->m_rootDoc, d->m_rootViews.first() );
1422 if(d->m_rootViews.count()==1)
1423 d->m_splitted=
false;
1426void KoMainWindow::slotSetOrientation() {
1427 d->m_splitter->setOrientation(
static_cast<TQt::Orientation
>
1428 (d->m_orientation->currentItem()));
1431void KoMainWindow::slotProgress(
int value) {
1434 if ( d->m_progress )
1436 statusBar()->removeWidget(d->m_progress);
1437 delete d->m_progress;
1440 d->m_firstTime=
true;
1447 TQObjectList *l = queryList(
"TQStatusBar" );
1448 if ( !l || !l->first() ) {
1450 TQApplication::sendPostedEvents(
this, TQEvent::ChildInserted );
1455 if ( d->m_progress )
1457 statusBar()->removeWidget(d->m_progress);
1458 delete d->m_progress;
1464 statusBar()->addWidget( d->m_progress, 0,
true );
1465 d->m_progress->show();
1466 d->m_firstTime=
false;
1468 d->m_progress->setProgress(value);
1469 kapp->processEvents();
1473void KoMainWindow::slotActivePartChanged(
KParts::Part *newPart )
1483 if ( d->m_activePart && d->m_activePart == newPart && !d->m_splitted )
1491 setUpdatesEnabled(
false );
1493 if ( d->m_activeView )
1496 TQApplication::sendEvent( d->m_activePart, &ev );
1497 TQApplication::sendEvent( d->m_activeView, &ev );
1503 d->m_toolbarList.clear();
1506 if ( !d->bMainWindowGUIBuilt )
1513 if ( newPart && d->m_manager->activeWidget() && d->m_manager->activeWidget()->inherits(
"KoView" ) )
1515 d->m_activeView = (
KoView *)d->m_manager->activeWidget();
1516 d->m_activePart = newPart;
1523 factory->plugActionList(d->m_activeView,
"view_closeallviews",
1524 d->m_veryHackyActionList);
1526 if(d->m_rootViews.findRef(d->m_activeView)!=-1)
1527 factory->plugActionList(d->m_activeView,
"view_split", d->m_splitViewActionList );
1534 TQPtrList<TQWidget> toolBarList =
factory->containers(
"ToolBar" );
1535 TQPtrListIterator<TQWidget> it( toolBarList );
1536 for ( ; it.current() ; ++it )
1538 if ( it.current()->inherits(
"TDEToolBar") )
1544 connect( act, TQ_SIGNAL( toggled(
bool ) ),
this, TQ_SLOT(
slotToolbarToggled(
bool ) ) );
1546 d->m_toolbarList.append( act );
1549 kdWarning(30003) <<
"Toolbar list contains a " << it.current()->className() <<
" which is not a toolbar!" << endl;
1556 TQApplication::sendEvent( d->m_activePart, &ev );
1557 TQApplication::sendEvent( d->m_activeView, &ev );
1561 d->m_activeView = 0L;
1562 d->m_activePart = 0L;
1564 setUpdatesEnabled(
true );
1569 if ( !d->statusBarLabel )
1571 d->statusBarLabel =
new TQLabel(
statusBar() );
1572 statusBar()->addWidget( d->statusBarLabel, 1,
true );
1574 return d->statusBarLabel;
1584 if ( !d->m_dcopObject )
1586 d->m_dcopObject =
new KoMainWindowIface(
this );
1589 return d->m_dcopObject;
1600 TQString theSubject;
1609 TQCString
const tmp_mimetype =
rootDocument()->outputMimeType();
1612 u.setPath(tmpfile.name());
1619 fileURL = tmpfile.name();
1620 theSubject = i18n(
"Document");
1621 urls.append( fileURL );
1630 theSubject = i18n(
"Document - %1").arg(
rootDocument()->url().fileName(
false));
1631 urls.append( fileURL );
1634 kdDebug(30003) <<
"(" << fileURL <<
")" << endl;
1636 if (!fileURL.isEmpty())
1638 kapp->invokeMailer(TQString(), TQString(), TQString(), theSubject,
1647 KoVersionDialog *dlg =
new KoVersionDialog(
this );
1659 i18n(
"You will lose all your changes!\n"
1660 "Do you want to continue?"),
1661 i18n(
"Warning") ) == KMessageBox::Yes;
1665 KURL url = pDoc->
url();
1666 if ( pDoc && !pDoc->
isEmpty() )
1669 delete d->m_rootDoc;
1679 kdDebug(30003) <<
"slotImportFile()" << endl;
1681 d->m_isImporting =
true;
1683 d->m_isImporting =
false;
1688 kdDebug(30003) <<
"slotExportFile()" << endl;
1690 d->m_isExporting =
true;
1692 d->m_isExporting =
false;
1697 return d->m_isImporting;
1702 return d->m_isExporting;
1707 d->m_docToOpen = doc;
1710#include <KoMainWindow.moc>
This file is part of the KDE/KOffice project.
KKbdAccessExtensions is an object that improves accessibility for motor impaired users who may not be...
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
static int questionYesNo(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
static int warningYesNoCancel(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
static int warningContinueCancel(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonContinue=KStdGuiItem::cont(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
virtual void setInstance(TDEInstance *instance)
void setIgnoreScrollBars(bool ignore)
PartManager(TQWidget *parent, const char *name=0L)
void setActivationButtonMask(short int buttonMask)
void setSelectionPolicy(SelectionPolicy policy)
void setAllowNestedParts(bool allow)
virtual void setSelectable(bool selectable)
static void loadPlugins(TQObject *parent, const TDEInstance *instance)
virtual bool saveAs(const KURL &url)
void plugActionList(const TQString &name, const TQPtrList< TDEAction > &actionList)
void unplugActionList(const TQString &name)
virtual TDEInstance * instance() const
virtual void setXMLFile(const TQString &file, bool merge=false, bool setXMLDoc=true)
KXMLGUIFactory * factory() const
virtual TDEActionCollection * actionCollection() const
void removeClient(KXMLGUIClient *client)
void addClient(KXMLGUIClient *client)
Represents an available KOffice component that supports the document interface.
KoDocument * createDoc(KoDocument *parent=0, const char *name=0) const
Uses the factory of the component to create a document.
The KOffice document class.
void resetURL()
Sets the document URL to empty URL KParts doesn't allow this, but KOffice apps have e....
void removeAutoSaveFiles()
Performs a cleanup of unneeded backup files.
virtual int supportedSpecialFormats() const
Return the set of SupportedSpecialFormats that the application wants to offer in the "Save" file dial...
bool checkAutoSaveFile()
Called by koApplication to check for an autosave file in $HOME.
KoView * createView(TQWidget *parent=0, const char *name=0)
Create a new view for the document.
static TQCString readNativeFormatMimeType(TDEInstance *instance=0)
Used by KoApplication, and by KoMainWindow, when no document exists yet.
virtual TQStringList extraNativeMimeTypes() const
Returns a list of the mimetypes considered "native", i.e.
bool isNativeFormat(const TQCString &mimetype) const
Checks whether a given mimetype can be handled natively.
TQString & file()
Only use these functions to restore m_file (in KoMainWindow) after a failed save (remember to use set...
virtual void removeShell(KoMainWindow *shell)
Removes the shell from the list.
static TQStringList readExtraNativeMimeTypes(TDEInstance *instance=0)
Used by KoMainWindow, when no document exists yet.
TQCString mimeType() const
Returns the actual mimetype of the document.
bool isEmbedded() const
Is the document embedded?
bool import(const KURL &url)
Opens the document given by url, without storing the URL in the KoDocument.
bool confirmNonNativeSave(const bool exporting) const
Returns true if this document was the result of opening a foreign file format and if the user hasn't ...
virtual void addShell(KoMainWindow *shell)
Appends the shell to the list of shells which show this document as their root document.
virtual void setModified(bool _mod)
Sets the modified flag on the document.
virtual void initEmpty()
Initialize an empty document using default values.
virtual bool openURL(const KURL &url)
Reimplemented from KParts::ReadWritePart for internal reasons (for the autosave functionality)
KoDocumentInfo * documentInfo() const
virtual TQCString nativeFormatMimeType() const
To be preferred when a document exists.
bool exp0rt(const KURL &url)
Saves the document as url without changing the state of the KoDocument (URL, modified flag etc....
void setURL(const KURL &url)
Sets the document URL to url KParts doesn't really allow this, but it is needed for undo of setStoreI...
bool isModified() const
Returns true if this document or any of its internal child documents are modified.
void setOutputMimeType(const TQCString &mimeType, int specialOutputFlag=0)
Set the format in which the document should be saved.
static KService::Ptr readNativeService(TDEInstance *instance=0)
With the help of instance or TDEApplication::instance() this method figures out which ....
virtual void showStartUpWidget(KoMainWindow *parent, bool alwaysShow=false)
Creates and shows the start up widget.
virtual bool isEmpty() const
void setFile(const TQString &file)
Only use these functions to restore m_file (in KoMainWindow) after a failed save (remember to use set...
virtual void setTitleModified()
Tells the document that its title has been modified, either because the modified status changes (this...
Extension to KFileDialog in order to add special entries to the filter combo, like "save as koffice-1...
static TQStringList mimeFilter()
The same method as KoFilterManager::mimeFilter but suited for KoShell.
Main window for a KOffice application.
bool isImporting() const
Returns whether or not the current slotFileOpen() or openDocument() call is actually an import operat...
KoMainWindow(TDEInstance *instance, const char *_name=0)
Constructor.
virtual void slotToolbarToggled(bool toggle)
Shows or hides a toolbar.
void slotEmailFile()
Slot for eMailing the document using KMail.
virtual void slotConfigureKeys()
Configure key bindings.
void slotFilePrintPreview()
Show a print preview.
virtual void slotConfigureToolbars()
Configure toolbars.
virtual void slotNewToolbarConfig()
Post toolbar config.
virtual void slotDocumentInfo()
Show a dialog with author and document information.
void setRootDocumentDirect(KoDocument *doc, const TQPtrList< KoView > &views)
Special method for KOShell, to allow switching the root document (and its views) among a set of them.
virtual void slotFileClose()
Closes the document.
void slotImportFile()
File --> Import.
void saveRecentFiles()
Save the list of recent files.
bool isExporting() const
Returns whether or not the current slotFileSave[As]() or saveDocument() call is actually an export op...
void slotReloadFile()
Reload file.
virtual bool saveDocument(bool saveas=false, bool silent=false)
Saves the document, asking for a filename if necessary.
void print(bool quick)
Prints the document.
virtual void slotSplitView()
View splitting stuff.
void setDocToOpen(KoDocument *doc)
This is used to handle the document used at start up before it actually added as root document.
virtual bool queryClose()
Ask user about saving changes to the document upon exit.
virtual void setRootDocument(KoDocument *doc)
Called when a document is assigned to this mainwindow.
void slotExportFile()
File --> Export.
TQLabel * statusBarLabel()
Get hold of the label in the statusbar, to write messages to it.
virtual void slotFileOpen()
Slot for opening a saved file.
~KoMainWindow()
Destructor.
virtual void slotFilePrint()
Prints the actual document.
virtual void slotFileSave()
Saves the current document with the current name.
virtual KoDocument * createDoc() const
Create a new empty document.
virtual void slotCloseAllViews()
Close all views.
void saveDialogShown()
This signals is emmitted before the save dialog is shown.
virtual void slotFileSaveAs()
Saves the current document with a new name.
virtual void slotFileOpenRecent(const KURL &)
Slot for opening a file among the recently opened files.
void slotVersionsFile()
This will call a dialogbox to add version to list of files.
void showToolbar(const char *tbName, bool shown)
The application should call this to show or hide a toolbar.
virtual KoDocument * rootDocument() const
Retrieves the document that is displayed in the mainwindow.
bool toolbarIsVisible(const char *tbName)
void setMaxRecentItems(uint _number)
Sets the maximum number of recent documents entries.
virtual bool openDocument(const KURL &url)
Load the desired document and show it.
void addRecentURL(const KURL &url)
The document opened a URL -> store into recent documents list.
virtual void slotFileQuit()
Closes the shell.
void reloadRecentFileList()
Reloads the recent documents list.
virtual void updateCaption()
Update caption from document info - call when document info (title in the about page) changes.
void chooseNewDocument(int initDocFlags)
Helper method for slotFileNew and slotFileClose.
void documentSaved()
This signal is emitted if the document has been saved successfully.
virtual void slotFileNew()
Slot for opening a new document.
KoSpeaker is a singleton object that provides Text-to-Speech services for KOffice applications.
static bool isKttsdInstalled()
Returns whether the KTTSD deamon is installed in the system.
This class is used to display a KoDocument.
KoDocument * koDocument() const
Retrieves the document object of this view.
virtual void print(KPrinter &printer)
Overload this method with your own printing code.
virtual void setupPrinter(KPrinter &printer)
Overload this method to setup KPrinter before the actual printing.
TDEToolBar * toolBar(const char *name=0)
void setStandardToolBarMenuEnabled(bool enable)
virtual void setCaption(const TQString &caption)
bool initialGeometrySet() const
void saveMainWindowSettings(TDEConfig *config, const TQString &groupName=TQString::null)
void resetAutoSaveSettings()
void saveWindowSize(TDEConfig *config) const
static TQPtrList< TDEMainWindow > * memberList
virtual void closeEvent(TQCloseEvent *)
void restoreWindowSize(TDEConfig *config)
void setAutoSaveSettings(const TQString &groupName=TQString::fromLatin1("MainWindow"), bool saveWindowSize=true)
void applyMainWindowSettings(TDEConfig *config, const TQString &groupName, bool force)
void loadEntries(TDEConfig *config, TQString groupname=TQString::null)
void setMaxItems(uint maxItems)
void removeURL(const KURL &url)
void addURL(const KURL &url)
void saveEntries(TDEConfig *config, TQString groupname=TQString::null)
void setCheckedState(const KGuiItem &checkedItem)
virtual void setChecked(bool)
This file is part of the KDE/KOffice project.
TDEAction * close(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * save(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDERecentFilesAction * openRecent(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * configureToolbars(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * mail(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * open(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * quit(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * printPreview(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * openNew(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * saveAs(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * print(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
const char * name(StdAction id)
TDEAction * keyBindings(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)