22 #include "katemainwindow.h"
23 #include "katemainwindow.moc"
25 #include "kateconfigdialog.h"
26 #include "kateconsole.h"
27 #include "katedocmanager.h"
28 #include "katepluginmanager.h"
29 #include "kateconfigplugindialogpage.h"
30 #include "kateviewmanager.h"
32 #include "katefileselector.h"
33 #include "katefilelist.h"
34 #include "katesessionpanel.h"
35 #include "kategrepdialog.h"
36 #include "katemailfilesdialog.h"
37 #include "katemainwindowiface.h"
38 #include "kateexternaltools.h"
39 #include "katesavemodifieddialog.h"
40 #include "katemwmodonhddialog.h"
41 #include "katesession.h"
42 #include "katetabwidget.h"
44 #include "../interfaces/mainwindow.h"
45 #include "../interfaces/toolviewmanager.h"
47 #include <dcopclient.h>
48 #include <kinstance.h>
49 #include <tdeaboutdata.h>
50 #include <tdeaction.h>
51 #include <tdecmdlineargs.h>
53 #include <kdialogbase.h>
54 #include <tdediroperator.h>
55 #include <kdockwidget.h>
56 #include <kedittoolbar.h>
57 #include <tdefiledialog.h>
58 #include <kglobalaccel.h>
59 #include <tdeglobal.h>
60 #include <tdeglobalsettings.h>
61 #include <kiconloader.h>
62 #include <kkeydialog.h>
63 #include <tdelocale.h>
64 #include <tdemessagebox.h>
65 #include <kmimetype.h>
66 #include <kopenwith.h>
67 #include <tdepopupmenu.h>
68 #include <ksimpleconfig.h>
69 #include <kstatusbar.h>
70 #include <kstdaction.h>
71 #include <kstandarddirs.h>
74 #include <kdesktopfile.h>
75 #include <khelpmenu.h>
76 #include <tdemultitabbar.h>
78 #include <tdemenubar.h>
79 #include <kstringhandler.h>
81 #include <tqptrvector.h>
87 uint KateMainWindow::uniqueID = 1;
89 KateMainWindow::KateMainWindow (TDEConfig *sconfig,
const TQString &sgroup)
90 : KateMDI::MainWindow (0,(TQString(TQString(
"__KateMainWindow#%1").arg(uniqueID))).latin1())
102 if (!initialGeometrySet())
104 int scnum = TQApplication::desktop()->screenNumber(parentWidget());
105 TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
112 sconfig->setGroup (sgroup);
113 size.setWidth (sconfig->readNumEntry( TQString::fromLatin1(
"Width %1").arg(desk.width()), 0 ));
114 size.setHeight (sconfig->readNumEntry( TQString::fromLatin1(
"Height %1").arg(desk.height()), 0 ));
134 size.setWidth (
KateApp::self()->config()->readNumEntry( TQString::fromLatin1(
"Width %1").arg(desk.width()), 0 ));
135 size.setHeight (
KateApp::self()->config()->readNumEntry( TQString::fromLatin1(
"Height %1").arg(desk.height()), 0 ));
138 size = TQSize (kMin (700, desk.width()), kMin(480, desk.height()));
146 startRestore (sconfig, sgroup);
148 m_mainWindow =
new Kate::MainWindow (
this);
151 m_dcop =
new KateMainWindowDCOPIface (
this);
153 m_mainWindow->installEventFilter(
this);
161 setStandardToolBarMenuEnabled(
true );
162 setXMLFile(
"kateui.rc" );
163 createShellGUI (
true );
165 KatePluginManager::self()->enableAllPluginsGUI (
this);
168 Kate::Document::registerCommand(KateExternalToolsCommand::self());
171 documentMenu = (TQPopupMenu*)factory()->container(
"documents",
this);
172 connect(documentMenu, TQ_SIGNAL(aboutToShow()),
this, TQ_SLOT(documentMenuAboutToShow()));
175 for (uint i = 0; i < KateDocManager::self()->documents(); i++)
176 slotDocumentCreated (KateDocManager::self()->document(i));
178 connect(KateDocManager::self(),TQ_SIGNAL(documentCreated(Kate::Document *)),
this,TQ_SLOT(slotDocumentCreated(Kate::Document *)));
183 m_viewManager->restoreViewConfiguration (sconfig, sgroup);
187 setAcceptDrops(
true);
190 KateMainWindow::~KateMainWindow()
201 KatePluginManager::self()->disableAllPluginsGUI (
this);
206 void KateMainWindow::setupMainWindow ()
208 setToolViewStyle( KMultiTabBar::KDEV3ICON );
210 m_tabWidget =
new KateTabWidget (centralWidget());
212 m_viewManager =
new KateViewManager (
this);
214 KateMDI::ToolView *ft = createToolView(
"kate_filelist", KMultiTabBar::Left, SmallIcon(
"application-vnd.tde.tdemultiple"), i18n(
"Documents"));
215 filelist =
new KateFileList (
this, m_viewManager, ft,
"filelist");
217 filelist->viewport()->installEventFilter(
this);
219 KateMDI::ToolView *t = createToolView(
"kate_fileselector", KMultiTabBar::Left, SmallIcon(
"document-open"), i18n(
"Filesystem Browser"));
220 fileselector =
new KateFileSelector(
this, m_viewManager, t,
"operator");
221 connect(fileselector->dirOperator(),TQ_SIGNAL(fileSelected(
const KFileItem*)),
this,TQ_SLOT(fileSelected(
const KFileItem*)));
223 KateMDI::ToolView *st = createToolView(
"kate_sessionpanel", KMultiTabBar::Left, SmallIcon(
"view_choose"), i18n(
"Sessions"));
224 m_sessionpanel =
new KateSessionPanel(
this, m_viewManager, st,
"sessionpanel");
229 t = createToolView(
"kate_greptool", KMultiTabBar::Bottom, SmallIcon(
"filefind"), i18n(
"Find in Files") );
230 greptool =
new GrepTool( t,
"greptool" );
231 connect(greptool, TQ_SIGNAL(itemSelected(
const TQString &,
int)),
this, TQ_SLOT(slotGrepToolItemSelected(
const TQString &,
int)));
232 connect(t,TQ_SIGNAL(visibleChanged(
bool)),
this, TQ_SLOT(updateGrepDir (
bool)));
236 t = createToolView(
"kate_console", KMultiTabBar::Bottom, SmallIcon(
"konsole"), i18n(
"Terminal"));
244 void KateMainWindow::setupActions()
248 KStdAction::openNew( m_viewManager, TQ_SLOT( slotDocumentNew() ), actionCollection(),
"file_new" )->setWhatsThis(i18n(
"Create a new document"));
249 KStdAction::open( m_viewManager, TQ_SLOT( slotDocumentOpen() ), actionCollection(),
"file_open" )->setWhatsThis(i18n(
"Open an existing document for editing"));
251 fileOpenRecent = KStdAction::openRecent (m_viewManager, TQ_SLOT(openURL (
const KURL&)), actionCollection());
252 fileOpenRecent->setWhatsThis(i18n(
"This lists files which you have opened recently, and allows you to easily open them again."));
254 a=
new TDEAction( i18n(
"Save A&ll"),
"save_all", CTRL+Key_L, KateDocManager::self(), TQ_SLOT( saveAll() ), actionCollection(),
"file_save_all" );
255 a->setWhatsThis(i18n(
"Save all open, modified documents to disk."));
257 KStdAction::close( m_viewManager, TQ_SLOT( slotDocumentClose() ), actionCollection(),
"file_close" )->setWhatsThis(i18n(
"Close the current document."));
259 a=
new TDEAction( i18n(
"Clos&e All" ), 0,
this, TQ_SLOT( slotDocumentCloseAll() ), actionCollection(),
"file_close_all" );
260 a->setWhatsThis(i18n(
"Close all open documents."));
262 KStdAction::mail(
this, TQ_SLOT(slotMail()), actionCollection() )->setWhatsThis(i18n(
"Send one or more of the open documents as email attachments."));
264 KStdAction::quit(
this, TQ_SLOT( slotFileQuit() ), actionCollection(),
"file_quit" )->setWhatsThis(i18n(
"Close this window"));
266 a=
new TDEAction(i18n(
"&New Window"),
"window-new", 0,
this, TQ_SLOT(newWindow()), actionCollection(),
"view_new_view");
267 a->setWhatsThis(i18n(
"Create a new Kate view (a new window with the same document list)."));
272 externalTools->setWhatsThis( i18n(
"Launch external helper applications") );
275 TDEToggleAction* showFullScreenAction = KStdAction::fullScreen( 0, 0, actionCollection(),
this);
276 connect( showFullScreenAction,TQ_SIGNAL(toggled(
bool)),
this,TQ_SLOT(slotFullScreen(
bool)));
278 documentOpenWith =
new TDEActionMenu(i18n(
"Open W&ith"), actionCollection(),
"file_open_with");
279 documentOpenWith->setWhatsThis(i18n(
"Open the current document using another application registered for its file type, or an application of your choice."));
280 connect(documentOpenWith->popupMenu(), TQ_SIGNAL(aboutToShow()),
this, TQ_SLOT(mSlotFixOpenWithMenu()));
281 connect(documentOpenWith->popupMenu(), TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(slotOpenWithMenuAction(
int)));
283 a=KStdAction::keyBindings(
this, TQ_SLOT(editKeys()), actionCollection());
284 a->setWhatsThis(i18n(
"Configure the application's keyboard shortcut assignments."));
286 a=KStdAction::configureToolbars(
this, TQ_SLOT(slotEditToolbars()), actionCollection());
287 a->setWhatsThis(i18n(
"Configure which items should appear in the toolbar(s)."));
289 TDEAction* settingsConfigure = KStdAction::preferences(
this, TQ_SLOT(slotConfigure()), actionCollection(),
"settings_configure");
290 settingsConfigure->setWhatsThis(i18n(
"Configure various aspects of this application and the editing component."));
294 new TDEAction(i18n(
"&Pipe to Console"),
"pipe", 0, console, TQ_SLOT(slotPipeToConsole()), actionCollection(),
"tools_pipe_to_terminal");
297 KStdAction::tipOfDay(
this, TQ_SLOT( tipOfTheDay() ), actionCollection() )->setWhatsThis(i18n(
"This shows useful tips on the use of this application."));
299 if (KatePluginManager::self()->pluginList().count() > 0)
301 a=
new TDEAction(i18n(
"&Plugins Handbook"), 0,
this, TQ_SLOT(pluginHelp()), actionCollection(),
"help_plugins_contents");
302 a->setWhatsThis(i18n(
"This shows help files for various available plugins."));
305 connect(m_viewManager,TQ_SIGNAL(viewChanged()),
this,TQ_SLOT(slotWindowActivated()));
306 connect(m_viewManager,TQ_SIGNAL(viewChanged()),
this,TQ_SLOT(slotUpdateOpenWith()));
308 slotWindowActivated ();
311 new TDEAction(i18n(
"&New"),
"list-add", 0,
312 m_sessionpanel, TQ_SLOT(slotNewSession()), actionCollection(),
"session_new");
313 new TDEAction(i18n(
"&Save"),
"document-save", 0,
314 m_sessionpanel, TQ_SLOT(slotSaveSession()), actionCollection(),
"session_save");
315 new TDEAction(i18n(
"Save &As..."),
"document-save-as", 0,
316 m_sessionpanel, TQ_SLOT(slotSaveSessionAs()), actionCollection(),
"session_save_as");
317 new TDEAction(i18n(
"&Rename"),
"edit_user", 0,
318 m_sessionpanel, TQ_SLOT(slotRenameSession()), actionCollection(),
"session_rename");
319 new TDEAction(i18n(
"&Delete"),
"edit-delete", 0,
320 m_sessionpanel, TQ_SLOT(slotDeleteSession()), actionCollection(),
"session_delete");
321 new TDEAction(i18n(
"Re&load"),
"reload", 0,
322 m_sessionpanel, TQ_SLOT(slotReloadSession()), actionCollection(),
"session_reload");
323 new TDEAction(i18n(
"Acti&vate"),
"forward", 0,
324 m_sessionpanel, TQ_SLOT(slotActivateSession()), actionCollection(),
"session_activate");
325 new TDEToggleAction(i18n(
"Toggle read &only"),
"encrypted", 0,
326 m_sessionpanel, TQ_SLOT(slotSessionToggleReadOnly()), actionCollection(),
"session_toggle_read_only");
327 new TDEAction(i18n(
"Move &Up"),
"go-up", 0,
328 m_sessionpanel, TQ_SLOT(slotSessionMoveUp()), actionCollection(),
"session_move_up");
329 new TDEAction(i18n(
"Move Do&wn"),
"go-down", 0,
330 m_sessionpanel, TQ_SLOT(slotSessionMoveDown()), actionCollection(),
"session_move_down");
331 new KateSessionListActionMenu(
this, i18n(
"Sele&ct session"), actionCollection(),
"session_list");
333 connect(m_sessionpanel, TQ_SIGNAL(selectionChanged()),
this, TQ_SLOT(slotSelectionChanged()));
336 KateTabWidget *KateMainWindow::tabWidget ()
341 void KateMainWindow::slotDocumentCloseAll() {
342 if (queryClose_internal())
343 KateDocManager::self()->closeAllDocuments(
false);
346 bool KateMainWindow::queryClose_internal() {
347 uint documentCount=KateDocManager::self()->documents();
349 if ( !showModOnDiskPrompt() )
354 TQPtrList<Kate::Document> modifiedDocuments=KateDocManager::self()->modifiedDocumentList();
355 bool shutdown = (modifiedDocuments.count() == 0);
359 shutdown = KateSaveModifiedDialog::queryClose(
this,modifiedDocuments);
362 if ( KateDocManager::self()->documents() > documentCount ) {
363 KMessageBox::information (
this,
364 i18n (
"New file opened while trying to close Kate, closing aborted."),
365 i18n (
"Closing Aborted"));
380 bool KateMainWindow::queryClose()
386 return queryClose_internal();
398 if (queryClose_internal())
408 void KateMainWindow::newWindow ()
413 void KateMainWindow::slotEditToolbars()
415 saveMainWindowSettings(
KateApp::self()->config(),
"MainWindow" );
416 KEditToolbar dlg( factory() );
417 connect( &dlg, TQ_SIGNAL(newToolbarConfig()),
this, TQ_SLOT(slotNewToolbarConfig()) );
421 void KateMainWindow::slotNewToolbarConfig()
423 applyMainWindowSettings(
KateApp::self()->config(),
"MainWindow" );
426 void KateMainWindow::slotFileQuit()
431 void KateMainWindow::readOptions ()
435 config->setGroup(
"General");
436 showSessionName = config->readBoolEntry(
"Show session name",
false);
437 syncKonsole = config->readBoolEntry(
"Sync Konsole",
true);
438 useInstance = config->readBoolEntry(
"UseInstance",
false);
439 modNotification = config->readBoolEntry(
"Modified Notification",
false);
440 KateDocManager::self()->setSaveMetaInfos(config->readBoolEntry(
"Save Meta Infos",
true));
441 KateDocManager::self()->setDaysMetaInfos(config->readNumEntry(
"Days Meta Infos", 30));
443 m_viewManager->setShowFullPath(config->readBoolEntry(
"Show Full Path in Title",
false));
445 fileOpenRecent->setMaxItems( config->readNumEntry(
"Number of recent files", fileOpenRecent->maxItems() ) );
446 fileOpenRecent->loadEntries(config,
"Recent Files");
448 fileselector->readConfig(config,
"fileselector");
451 void KateMainWindow::saveOptions ()
454 config->setGroup(
"General");
457 config->writeEntry(
"Show Console", console->isVisible());
459 config->writeEntry(
"Show Console",
false);
461 config->writeEntry(
"Show session name", showSessionName);
462 config->writeEntry(
"Save Meta Infos", KateDocManager::self()->getSaveMetaInfos());
463 config->writeEntry(
"Days Meta Infos", KateDocManager::self()->getDaysMetaInfos());
464 config->writeEntry(
"Show Full Path in Title", m_viewManager->getShowFullPath());
465 config->writeEntry(
"Sync Konsole", syncKonsole);
466 config->writeEntry(
"UseInstance", useInstance);
468 fileOpenRecent->saveEntries(config,
"Recent Files");
469 fileselector->writeConfig(config,
"fileselector");
470 filelist->writeConfig(config,
"Filelist");
475 void KateMainWindow::slotWindowActivated ()
477 if (m_viewManager->activeView())
479 if (console && syncKonsole)
481 static TQString path;
482 TQString newPath = m_viewManager->activeView()->getDoc()->url().directory();
484 if ( newPath != path )
487 console->cd (KURL( path ));
491 updateCaption (m_viewManager->activeView()->getDoc());
495 centralWidget()->setFocusProxy (m_viewManager->activeView());
498 void KateMainWindow::slotUpdateOpenWith()
500 if (m_viewManager->activeView())
501 documentOpenWith->setEnabled(!m_viewManager->activeView()->document()->url().isEmpty());
503 documentOpenWith->setEnabled(
false);
506 void KateMainWindow::documentMenuAboutToShow()
509 while (documentMenu->count() > 3)
510 documentMenu->removeItemAt (3);
512 TQListViewItem * item = filelist->firstChild();
515 TQString name = KStringHandler::rsqueeze( ((KateFileListItem *)item)->document()->docName(), 150 );
516 Kate::Document* doc = ((KateFileListItem *)item)->document();
517 documentMenu->insertItem (
518 doc->isModified() ? i18n(
"'document name [*]', [*] means modified",
"%1 [*]").arg(name) : name,
519 m_viewManager, TQ_SLOT (activateView (
int)), 0,
520 ((KateFileListItem *)item)->documentNumber () );
522 item = item->nextSibling();
524 if (m_viewManager->activeView())
525 documentMenu->setItemChecked ( m_viewManager->activeView()->getDoc()->documentNumber(),
true);
528 void KateMainWindow::slotGrepToolItemSelected(
const TQString &filename,
int linenumber)
531 fileURL.setPath( filename );
532 m_viewManager->openURL( fileURL );
533 if ( m_viewManager->activeView() == 0 )
return;
534 m_viewManager->activeView()->gotoLineNumber( linenumber );
539 void KateMainWindow::dragEnterEvent( TQDragEnterEvent *event )
541 event->accept(KURLDrag::canDecode(event));
544 void KateMainWindow::dropEvent( TQDropEvent *event )
546 slotDropEvent(event);
549 void KateMainWindow::slotDropEvent( TQDropEvent * event )
552 if (!KURLDrag::decode(event, textlist))
return;
554 for (KURL::List::Iterator i=textlist.begin(); i != textlist.end(); ++i)
556 m_viewManager->openURL (*i);
560 void KateMainWindow::editKeys()
562 KKeyDialog dlg (
false,
this );
564 TQPtrList<KXMLGUIClient> clients = guiFactory()->clients();
566 for( TQPtrListIterator<KXMLGUIClient> it( clients ); it.current(); ++it )
567 dlg.insert ( (*it)->actionCollection(), (*it)->instance()->aboutData()->programName() );
569 dlg.insert( externalTools->actionCollection(), i18n(
"External Tools") );
573 TQPtrList<Kate::Document> l=KateDocManager::self()->documentList();
574 for (uint i=0;i<l.count();i++) {
576 l.at(i)->reloadXML();
577 TQPtrList<class KTextEditor::View> l1=l.at(i)->views ();
578 for (uint i1=0;i1<l1.count();i1++) {
579 l1.at(i1)->reloadXML();
584 externalTools->actionCollection()->writeShortcutSettings(
"Shortcuts",
new TDEConfig(
"externaltools",
false,
false,
"appdata") );
587 void KateMainWindow::openURL (
const TQString &name)
589 m_viewManager->openURL (KURL(name));
592 void KateMainWindow::slotConfigure()
594 if (!m_viewManager->activeView())
597 KateConfigDialog* dlg =
new KateConfigDialog (
this, m_viewManager->activeView());
606 KURL KateMainWindow::activeDocumentUrl()
610 Kate::View *v = m_viewManager->activeView();
612 return v->getDoc()->url();
616 void KateMainWindow::fileSelected(
const KFileItem * )
618 const KFileItemList *list=fileselector->dirOperator()->selectedItems();
620 for (KFileItemListIterator it(*list); (tmp = it.current()); ++it)
622 m_viewManager->openURL(tmp->url());
623 fileselector->dirOperator()->view()->setSelected(tmp,
false);
628 void KateMainWindow::mSlotFixOpenWithMenu()
631 documentOpenWith->popupMenu()->clear();
633 KMimeType::Ptr mime = KMimeType::findByURL( m_viewManager->activeView()->getDoc()->url() );
636 TDETrader::OfferList offers = TDETrader::self()->query(mime->name(),
"Type == 'Application'");
638 for(TDETrader::OfferList::Iterator it = offers.begin(); it != offers.end(); ++it) {
639 if ((*it)->name() ==
"Kate")
continue;
640 documentOpenWith->popupMenu()->insertItem( SmallIcon( (*it)->icon() ), (*it)->name() );
643 documentOpenWith->popupMenu()->insertItem(i18n(
"&Other..."));
646 void KateMainWindow::slotOpenWithMenuAction(
int idx)
649 list.append( m_viewManager->activeView()->getDoc()->url() );
650 TQString appname = documentOpenWith->popupMenu()->text(idx);
652 appname = appname.remove(
'&');
653 if ( appname.compare(i18n(
"Other...")) == 0 ) {
655 KOpenWithDlg dlg(list);
657 KRun::run(*dlg.service(), list);
661 TQString qry = TQString(
"((Type == 'Application') and (Name == '%1'))").arg( appname.latin1() );
662 KMimeType::Ptr mime = KMimeType::findByURL( m_viewManager->activeView()->getDoc()->url() );
663 TDETrader::OfferList offers = TDETrader::self()->query(mime->name(), qry);
665 if (!offers.isEmpty()) {
666 KService::Ptr app = offers.first();
667 KRun::run(*app, list);
670 KMessageBox::error(
this, i18n(
"Application '%1' not found!").arg(appname.latin1()), i18n(
"Application Not Found!"));
673 void KateMainWindow::pluginHelp()
675 KateApp::self()->invokeHelp (TQString::null,
"kate-plugins");
678 void KateMainWindow::slotMail()
691 TQPtrListIterator<Kate::Document> it(attDocs);
692 for ( ; it.current(); ++it ) {
695 if ( doc->url().isEmpty() ) {
697 int r = KMessageBox::questionYesNo(
this,
698 i18n(
"<p>The current document has not been saved, and "
699 "cannot be attached to an email message."
700 "<p>Do you want to save it and proceed?"),
701 i18n(
"Cannot Send Unsaved File"),KStdGuiItem::saveAs(),KStdGuiItem::cancel() );
702 if ( r == KMessageBox::Yes ) {
703 Kate::View *v = (Kate::View*)doc->views().first();
704 int sr = v->saveAs();
705 if ( sr == Kate::View::SAVE_OK ) { ;
708 if ( sr != Kate::View::SAVE_CANCEL )
709 KMessageBox::sorry(
this, i18n(
"The file could not be saved. Please check "
710 "if you have write permission.") );
717 if ( doc->isModified() ) {
719 int r = KMessageBox::warningYesNoCancel(
this,
720 i18n(
"<p>The current file:<br><strong>%1</strong><br>has been "
721 "modified. Modifications will not be available in the attachment."
722 "<p>Do you want to save it before sending it?").arg(doc->url().prettyURL()),
723 i18n(
"Save Before Sending?"), KStdGuiItem::save(), i18n(
"Do Not Save") );
725 case KMessageBox::Cancel:
727 case KMessageBox::Yes:
729 if ( doc->isModified() ) {
730 KMessageBox::sorry(
this, i18n(
"The file could not be saved. Please check "
731 "if you have write permission.") );
740 urls << doc->url().url();
742 if ( ! urls.count() )
753 void KateMainWindow::tipOfTheDay()
755 KTipDialog::showTip(
this, TQString::null,
true );
758 void KateMainWindow::slotFullScreen(
bool t)
766 void KateMainWindow::updateGrepDir (
bool visible)
772 if ( m_viewManager->activeView() )
774 if ( m_viewManager->activeView()->getDoc()->url().isLocalFile() )
776 greptool->updateDirName( m_viewManager->activeView()->getDoc()->url().directory() );
781 bool KateMainWindow::event( TQEvent *e )
783 uint type = e->type();
784 if ( type == TQEvent::WindowActivate && modNotification )
786 showModOnDiskPrompt();
788 return KateMDI::MainWindow::event( e );
791 bool KateMainWindow::showModOnDiskPrompt()
795 DocVector list( KateDocManager::self()->documents() );
797 for( doc = KateDocManager::self()->firstDocument(); doc; doc = KateDocManager::self()->nextDocument() )
799 if ( KateDocManager::self()->documentInfo( doc )->modifiedOnDisc )
801 list.insert( cnt, doc );
806 if ( cnt && !m_modignore )
811 bool res = mhdlg.exec();
819 void KateMainWindow::slotDocumentCreated (Kate::Document *doc)
821 connect(doc,TQ_SIGNAL(modStateChanged(Kate::Document *)),
this,TQ_SLOT(updateCaption(Kate::Document *)));
822 connect(doc,TQ_SIGNAL(nameChanged(Kate::Document *)),
this,TQ_SLOT(slotNameChanged(Kate::Document *)));
823 connect(doc,TQ_SIGNAL(nameChanged(Kate::Document *)),
this,TQ_SLOT(slotUpdateOpenWith()));
828 void KateMainWindow::slotNameChanged(Kate::Document *doc)
831 if (!doc->url().isEmpty())
832 fileOpenRecent->addURL(doc->url());
835 void KateMainWindow::updateCaption(Kate::Document *doc)
837 if (!m_viewManager->activeView())
839 setCaption (
"",
false);
843 if (!(m_viewManager->activeView()->getDoc() == doc))
847 if (m_viewManager->activeView()->getDoc()->url().isEmpty() || (!m_viewManager->getShowFullPath()))
849 c = m_viewManager->activeView()->getDoc()->docName();
853 c = m_viewManager->activeView()->getDoc()->url().pathOrURL();
859 if (!sessName.isEmpty())
861 sessName = TQString(
"%1: ").arg(sessName);
863 setCaption(KStringHandler::lsqueeze(sessName,32) + KStringHandler::lsqueeze(c,64),
864 m_viewManager->activeView()->getDoc()->isModified());
868 setCaption(KStringHandler::lsqueeze(c,64), m_viewManager->activeView()->getDoc()->isModified());
872 void KateMainWindow::saveProperties(TDEConfig *config)
874 TQString grp=config->group();
876 saveSession(config, grp);
877 m_viewManager->saveViewConfiguration (config, grp);
879 config->setGroup(grp);
882 void KateMainWindow::readProperties(TDEConfig *config)
884 TQString grp=config->group();
886 startRestore(config, grp);
888 m_viewManager->restoreViewConfiguration (config, grp);
890 config->setGroup(grp);
893 bool KateMainWindow::eventFilter(TQObject *obj, TQEvent *ev)
895 if (ev->type() == TQEvent::MouseButtonRelease)
897 TQMouseEvent *mouseEvent =
static_cast<TQMouseEvent *
>(ev);
898 switch (mouseEvent->button())
900 case TQMouseEvent::HistoryBackButton:
901 filelist->slotPrevDocument();
903 case TQMouseEvent::HistoryForwardButton:
904 filelist->slotNextDocument();
912 void KateMainWindow::slotSelectionChanged()
914 TDEActionCollection *mwac = actionCollection();
915 TDEActionPtrList actionList = m_sessionpanel->m_actionCollection->actions();
916 TDEActionPtrList::ConstIterator spa_it;
917 for (spa_it = actionList.begin(); spa_it != actionList.end(); ++spa_it)
919 TDEAction *a = mwac->action((*spa_it)->name());
920 TDEToggleAction *ta =
dynamic_cast<TDEToggleAction*
>(a);
923 ta->setChecked((
dynamic_cast<TDEToggleAction*
>(*spa_it))->isChecked());
927 a->setEnabled((*spa_it)->isEnabled());
933 void KateMainWindow::activateSession(
int sessionId)
935 if (sessionId < 0 || sessionId ==
KateApp::self()->sessionManager()->getActiveSessionId())
941 TQListViewItem *item = m_sessionpanel->m_listview->firstChild();
943 while (item && idx < sessionId)
945 item = item->nextSibling();
948 if (idx == sessionId && item)
951 m_sessionpanel->m_listview->setSelected(item,
true);
952 m_sessionpanel->slotActivateSession();
957 KateSessionListActionMenu::KateSessionListActionMenu(KateMainWindow *mw,
const TQString &text, TQObject *parent,
const char *name)
958 : TDEActionMenu(text, parent, name), m_mainWindow(mw)
960 connect(popupMenu(), TQ_SIGNAL(aboutToShow()),
this, TQ_SLOT(slotAboutToShow()));
964 void KateSessionListActionMenu::slotAboutToShow()
966 popupMenu()->clear();
969 for (
int idx = 0; idx < (int)sessions.count(); ++idx)
971 popupMenu()->insertItem(sessions[idx]->getSessionName(), m_mainWindow, TQ_SLOT(activateSession(
int)), 0, idx);
bool query_session_close()
to be called when the application is about to quit
void reparse_config()
called after the config dialog has been closed.
KateMainWindow * newMainWindow(TDEConfig *sconfig=0, const TQString &sgroup="")
window management
void shutdownKate(KateMainWindow *win)
kate shutdown
KateMainWindow * mainWindow(uint n)
give back the window you want
static KateApp * self()
static accessor to avoid casting ;)
KateMainWindow * activeMainWindow()
give back current active main window can only be 0 at app start or exit
KateSessionManager * sessionManager()
accessor to session manager
void removeMainWindow(KateMainWindow *mainWindow)
removes the mainwindow given, DOES NOT DELETE IT
KateConsole This class is used for the internal terminal emulator It uses internally the konsole part...
This is a dialog for choosing which of the open files to mail.
TQPtrList< Kate::Document > selectedDocs()
A dialog for handling multiple documents modified on disk from within KateMainWindow.
TQPtrList< KateSession > & getSessionsList()
const TQString & getActiveSessionName()