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>
73 #include <kuniqueapplication.h>
75 #include <kdesktopfile.h>
76 #include <khelpmenu.h>
77 #include <tdemultitabbar.h>
79 #include <tdemenubar.h>
80 #include <kstringhandler.h>
82 #include <tqptrvector.h>
88 uint KateMainWindow::uniqueID = 1;
90 KateMainWindow::KateMainWindow (TDEConfig *sconfig,
const TQString &sgroup)
91 : KateMDI::MainWindow (0,(TQString(TQString(
"__KateMainWindow#%1").arg(uniqueID))).latin1())
103 if (!initialGeometrySet())
105 int scnum = TQApplication::desktop()->screenNumber(parentWidget());
106 TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
113 sconfig->setGroup (sgroup);
114 size.setWidth (sconfig->readNumEntry( TQString::fromLatin1(
"Width %1").arg(desk.width()), 0 ));
115 size.setHeight (sconfig->readNumEntry( TQString::fromLatin1(
"Height %1").arg(desk.height()), 0 ));
135 size.setWidth (
KateApp::self()->config()->readNumEntry( TQString::fromLatin1(
"Width %1").arg(desk.width()), 0 ));
136 size.setHeight (
KateApp::self()->config()->readNumEntry( TQString::fromLatin1(
"Height %1").arg(desk.height()), 0 ));
139 size = TQSize (kMin (700, desk.width()), kMin(480, desk.height()));
147 startRestore (sconfig, sgroup);
149 m_mainWindow =
new Kate::MainWindow (
this);
152 m_dcop =
new KateMainWindowDCOPIface (
this);
160 setStandardToolBarMenuEnabled(
true );
161 setXMLFile(
"kateui.rc" );
162 createShellGUI (
true );
164 KatePluginManager::self()->enableAllPluginsGUI (
this);
167 Kate::Document::registerCommand(KateExternalToolsCommand::self());
170 documentMenu = (TQPopupMenu*)factory()->container(
"documents",
this);
171 connect(documentMenu, TQT_SIGNAL(aboutToShow()),
this, TQT_SLOT(documentMenuAboutToShow()));
174 for (uint i = 0; i < KateDocManager::self()->documents(); i++)
175 slotDocumentCreated (KateDocManager::self()->document(i));
177 connect(KateDocManager::self(),TQT_SIGNAL(documentCreated(Kate::Document *)),
this,TQT_SLOT(slotDocumentCreated(Kate::Document *)));
182 m_viewManager->restoreViewConfiguration (sconfig, sgroup);
186 setAcceptDrops(
true);
189 KateMainWindow::~KateMainWindow()
200 KatePluginManager::self()->disableAllPluginsGUI (
this);
205 void KateMainWindow::setupMainWindow ()
207 setToolViewStyle( KMultiTabBar::KDEV3ICON );
209 m_tabWidget =
new KateTabWidget (centralWidget());
211 m_viewManager =
new KateViewManager (
this);
213 KateMDI::ToolView *ft = createToolView(
"kate_filelist", KMultiTabBar::Left, SmallIcon(
"application-vnd.tde.tdemultiple"), i18n(
"Documents"));
214 filelist =
new KateFileList (
this, m_viewManager, ft,
"filelist");
217 KateMDI::ToolView *t = createToolView(
"kate_fileselector", KMultiTabBar::Left, SmallIcon(
"document-open"), i18n(
"Filesystem Browser"));
218 fileselector =
new KateFileSelector(
this, m_viewManager, t,
"operator");
219 connect(fileselector->dirOperator(),TQT_SIGNAL(fileSelected(
const KFileItem*)),
this,TQT_SLOT(fileSelected(
const KFileItem*)));
221 KateMDI::ToolView *st = createToolView(
"kate_sessionpanel", KMultiTabBar::Left, SmallIcon(
"view_choose"), i18n(
"Sessions"));
222 m_sessionpanel =
new KateSessionPanel(
this, m_viewManager, st,
"sessionpanel");
227 t = createToolView(
"kate_greptool", KMultiTabBar::Bottom, SmallIcon(
"filefind"), i18n(
"Find in Files") );
228 greptool =
new GrepTool( t,
"greptool" );
229 connect(greptool, TQT_SIGNAL(itemSelected(
const TQString &,
int)),
this, TQT_SLOT(slotGrepToolItemSelected(
const TQString &,
int)));
230 connect(t,TQT_SIGNAL(visibleChanged(
bool)),
this, TQT_SLOT(updateGrepDir (
bool)));
234 t = createToolView(
"kate_console", KMultiTabBar::Bottom, SmallIcon(
"konsole"), i18n(
"Terminal"));
242 void KateMainWindow::setupActions()
246 KStdAction::openNew( TQT_TQOBJECT(m_viewManager), TQT_SLOT( slotDocumentNew() ), actionCollection(),
"file_new" )->setWhatsThis(i18n(
"Create a new document"));
247 KStdAction::open( TQT_TQOBJECT(m_viewManager), TQT_SLOT( slotDocumentOpen() ), actionCollection(),
"file_open" )->setWhatsThis(i18n(
"Open an existing document for editing"));
249 fileOpenRecent = KStdAction::openRecent (TQT_TQOBJECT(m_viewManager), TQT_SLOT(openURL (
const KURL&)), actionCollection());
250 fileOpenRecent->setWhatsThis(i18n(
"This lists files which you have opened recently, and allows you to easily open them again."));
252 a=
new TDEAction( i18n(
"Save A&ll"),
"save_all", CTRL+Key_L, KateDocManager::self(), TQT_SLOT( saveAll() ), actionCollection(),
"file_save_all" );
253 a->setWhatsThis(i18n(
"Save all open, modified documents to disk."));
255 KStdAction::close( TQT_TQOBJECT(m_viewManager), TQT_SLOT( slotDocumentClose() ), actionCollection(),
"file_close" )->setWhatsThis(i18n(
"Close the current document."));
257 a=
new TDEAction( i18n(
"Clos&e All" ), 0, TQT_TQOBJECT(
this), TQT_SLOT( slotDocumentCloseAll() ), actionCollection(),
"file_close_all" );
258 a->setWhatsThis(i18n(
"Close all open documents."));
260 KStdAction::mail( TQT_TQOBJECT(
this), TQT_SLOT(slotMail()), actionCollection() )->setWhatsThis(i18n(
"Send one or more of the open documents as email attachments."));
262 KStdAction::quit( TQT_TQOBJECT(
this), TQT_SLOT( slotFileQuit() ), actionCollection(),
"file_quit" )->setWhatsThis(i18n(
"Close this window"));
264 a=
new TDEAction(i18n(
"&New Window"),
"window-new", 0, TQT_TQOBJECT(
this), TQT_SLOT(newWindow()), actionCollection(),
"view_new_view");
265 a->setWhatsThis(i18n(
"Create a new Kate view (a new window with the same document list)."));
270 externalTools->setWhatsThis( i18n(
"Launch external helper applications") );
273 TDEToggleAction* showFullScreenAction = KStdAction::fullScreen( 0, 0, actionCollection(),
this);
274 connect( showFullScreenAction,TQT_SIGNAL(toggled(
bool)),
this,TQT_SLOT(slotFullScreen(
bool)));
276 documentOpenWith =
new TDEActionMenu(i18n(
"Open W&ith"), actionCollection(),
"file_open_with");
277 documentOpenWith->setWhatsThis(i18n(
"Open the current document using another application registered for its file type, or an application of your choice."));
278 connect(documentOpenWith->popupMenu(), TQT_SIGNAL(aboutToShow()),
this, TQT_SLOT(mSlotFixOpenWithMenu()));
279 connect(documentOpenWith->popupMenu(), TQT_SIGNAL(activated(
int)),
this, TQT_SLOT(slotOpenWithMenuAction(
int)));
281 a=KStdAction::keyBindings(TQT_TQOBJECT(
this), TQT_SLOT(editKeys()), actionCollection());
282 a->setWhatsThis(i18n(
"Configure the application's keyboard shortcut assignments."));
284 a=KStdAction::configureToolbars(TQT_TQOBJECT(
this), TQT_SLOT(slotEditToolbars()), actionCollection());
285 a->setWhatsThis(i18n(
"Configure which items should appear in the toolbar(s)."));
287 TDEAction* settingsConfigure = KStdAction::preferences(TQT_TQOBJECT(
this), TQT_SLOT(slotConfigure()), actionCollection(),
"settings_configure");
288 settingsConfigure->setWhatsThis(i18n(
"Configure various aspects of this application and the editing component."));
292 new TDEAction(i18n(
"&Pipe to Console"),
"pipe", 0, TQT_TQOBJECT(console), TQT_SLOT(slotPipeToConsole()), actionCollection(),
"tools_pipe_to_terminal");
295 KStdAction::tipOfDay( TQT_TQOBJECT(
this), TQT_SLOT( tipOfTheDay() ), actionCollection() )->setWhatsThis(i18n(
"This shows useful tips on the use of this application."));
297 if (KatePluginManager::self()->pluginList().count() > 0)
299 a=
new TDEAction(i18n(
"&Plugins Handbook"), 0, TQT_TQOBJECT(
this), TQT_SLOT(pluginHelp()), actionCollection(),
"help_plugins_contents");
300 a->setWhatsThis(i18n(
"This shows help files for various available plugins."));
303 connect(m_viewManager,TQT_SIGNAL(viewChanged()),TQT_TQOBJECT(
this),TQT_SLOT(slotWindowActivated()));
304 connect(m_viewManager,TQT_SIGNAL(viewChanged()),TQT_TQOBJECT(
this),TQT_SLOT(slotUpdateOpenWith()));
306 slotWindowActivated ();
309 new TDEAction(i18n(
"&New"),
"list-add", 0,
310 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotNewSession()), actionCollection(),
"session_new");
311 new TDEAction(i18n(
"&Save"),
"document-save", 0,
312 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSaveSession()), actionCollection(),
"session_save");
313 new TDEAction(i18n(
"Save &As..."),
"document-save-as", 0,
314 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSaveSessionAs()), actionCollection(),
"session_save_as");
315 new TDEAction(i18n(
"&Rename"),
"edit_user", 0,
316 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotRenameSession()), actionCollection(),
"session_rename");
317 new TDEAction(i18n(
"&Delete"),
"edit-delete", 0,
318 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotDeleteSession()), actionCollection(),
"session_delete");
319 new TDEAction(i18n(
"Re&load"),
"reload", 0,
320 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotReloadSession()), actionCollection(),
"session_reload");
321 new TDEAction(i18n(
"Acti&vate"),
"forward", 0,
322 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotActivateSession()), actionCollection(),
"session_activate");
323 new TDEToggleAction(i18n(
"Toggle read &only"),
"encrypted", 0,
324 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSessionToggleReadOnly()), actionCollection(),
"session_toggle_read_only");
325 new TDEAction(i18n(
"Move &Up"),
"go-up", 0,
326 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSessionMoveUp()), actionCollection(),
"session_move_up");
327 new TDEAction(i18n(
"Move Do&wn"),
"go-down", 0,
328 TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSessionMoveDown()), actionCollection(),
"session_move_down");
329 new KateSessionListActionMenu(
this, i18n(
"Sele&ct session"), actionCollection(),
"session_list");
331 connect(m_sessionpanel, TQT_SIGNAL(selectionChanged()), TQT_TQOBJECT(
this), TQT_SLOT(slotSelectionChanged()));
334 KateTabWidget *KateMainWindow::tabWidget ()
339 void KateMainWindow::slotDocumentCloseAll() {
340 if (queryClose_internal())
341 KateDocManager::self()->closeAllDocuments(
false);
344 bool KateMainWindow::queryClose_internal() {
345 uint documentCount=KateDocManager::self()->documents();
347 if ( !showModOnDiskPrompt() )
350 TQPtrList<Kate::Document> modifiedDocuments=KateDocManager::self()->modifiedDocumentList();
351 bool shutdown=(modifiedDocuments.count()==0);
354 shutdown=KateSaveModifiedDialog::queryClose(
this,modifiedDocuments);
357 if ( KateDocManager::self()->documents() > documentCount ) {
358 KMessageBox::information (
this,
359 i18n (
"New file opened while trying to close Kate, closing aborted."),
360 i18n (
"Closing Aborted"));
370 bool KateMainWindow::queryClose()
376 return queryClose_internal();
388 if (queryClose_internal() &&
KateApp::self()->query_session_close())
398 void KateMainWindow::newWindow ()
403 void KateMainWindow::slotEditToolbars()
405 saveMainWindowSettings(
KateApp::self()->config(),
"MainWindow" );
406 KEditToolbar dlg( factory() );
407 connect( &dlg, TQT_SIGNAL(newToolbarConfig()),
this, TQT_SLOT(slotNewToolbarConfig()) );
411 void KateMainWindow::slotNewToolbarConfig()
413 applyMainWindowSettings(
KateApp::self()->config(),
"MainWindow" );
416 void KateMainWindow::slotFileQuit()
421 void KateMainWindow::readOptions ()
425 config->setGroup(
"General");
426 showSessionName = config->readBoolEntry(
"Show session name",
false);
427 syncKonsole = config->readBoolEntry(
"Sync Konsole",
true);
428 useInstance = config->readBoolEntry(
"UseInstance",
false);
429 modNotification = config->readBoolEntry(
"Modified Notification",
false);
430 KateDocManager::self()->setSaveMetaInfos(config->readBoolEntry(
"Save Meta Infos",
true));
431 KateDocManager::self()->setDaysMetaInfos(config->readNumEntry(
"Days Meta Infos", 30));
433 m_viewManager->setShowFullPath(config->readBoolEntry(
"Show Full Path in Title",
false));
435 fileOpenRecent->setMaxItems( config->readNumEntry(
"Number of recent files", fileOpenRecent->maxItems() ) );
436 fileOpenRecent->loadEntries(config,
"Recent Files");
438 fileselector->readConfig(config,
"fileselector");
441 void KateMainWindow::saveOptions ()
444 config->setGroup(
"General");
447 config->writeEntry(
"Show Console", console->isVisible());
449 config->writeEntry(
"Show Console",
false);
451 config->writeEntry(
"Show session name", showSessionName);
452 config->writeEntry(
"Save Meta Infos", KateDocManager::self()->getSaveMetaInfos());
453 config->writeEntry(
"Days Meta Infos", KateDocManager::self()->getDaysMetaInfos());
454 config->writeEntry(
"Show Full Path in Title", m_viewManager->getShowFullPath());
455 config->writeEntry(
"Sync Konsole", syncKonsole);
456 config->writeEntry(
"UseInstance", useInstance);
458 fileOpenRecent->saveEntries(config,
"Recent Files");
459 fileselector->writeConfig(config,
"fileselector");
460 filelist->writeConfig(config,
"Filelist");
465 void KateMainWindow::slotWindowActivated ()
467 if (m_viewManager->activeView())
469 if (console && syncKonsole)
471 static TQString path;
472 TQString newPath = m_viewManager->activeView()->getDoc()->url().directory();
474 if ( newPath != path )
477 console->cd (KURL( path ));
481 updateCaption (m_viewManager->activeView()->getDoc());
485 centralWidget()->setFocusProxy (m_viewManager->activeView());
488 void KateMainWindow::slotUpdateOpenWith()
490 if (m_viewManager->activeView())
491 documentOpenWith->setEnabled(!m_viewManager->activeView()->document()->url().isEmpty());
493 documentOpenWith->setEnabled(
false);
496 void KateMainWindow::documentMenuAboutToShow()
499 while (documentMenu->count() > 3)
500 documentMenu->removeItemAt (3);
502 TQListViewItem * item = filelist->firstChild();
505 TQString name = KStringHandler::rsqueeze( ((KateFileListItem *)item)->document()->docName(), 150 );
506 Kate::Document* doc = ((KateFileListItem *)item)->document();
507 documentMenu->insertItem (
508 doc->isModified() ? i18n(
"'document name [*]', [*] means modified",
"%1 [*]").arg(name) : name,
509 m_viewManager, TQT_SLOT (activateView (
int)), 0,
510 ((KateFileListItem *)item)->documentNumber () );
512 item = item->nextSibling();
514 if (m_viewManager->activeView())
515 documentMenu->setItemChecked ( m_viewManager->activeView()->getDoc()->documentNumber(),
true);
518 void KateMainWindow::slotGrepToolItemSelected(
const TQString &filename,
int linenumber)
521 fileURL.setPath( filename );
522 m_viewManager->openURL( fileURL );
523 if ( m_viewManager->activeView() == 0 )
return;
524 m_viewManager->activeView()->gotoLineNumber( linenumber );
529 void KateMainWindow::dragEnterEvent( TQDragEnterEvent *event )
531 event->accept(KURLDrag::canDecode(event));
534 void KateMainWindow::dropEvent( TQDropEvent *event )
536 slotDropEvent(event);
539 void KateMainWindow::slotDropEvent( TQDropEvent * event )
542 if (!KURLDrag::decode(event, textlist))
return;
544 for (KURL::List::Iterator i=textlist.begin(); i != textlist.end(); ++i)
546 m_viewManager->openURL (*i);
550 void KateMainWindow::editKeys()
552 KKeyDialog dlg (
false,
this );
554 TQPtrList<KXMLGUIClient> clients = guiFactory()->clients();
556 for( TQPtrListIterator<KXMLGUIClient> it( clients ); it.current(); ++it )
557 dlg.insert ( (*it)->actionCollection(), (*it)->instance()->aboutData()->programName() );
559 dlg.insert( externalTools->actionCollection(), i18n(
"External Tools") );
563 TQPtrList<Kate::Document> l=KateDocManager::self()->documentList();
564 for (uint i=0;i<l.count();i++) {
566 l.at(i)->reloadXML();
567 TQPtrList<class KTextEditor::View> l1=l.at(i)->views ();
568 for (uint i1=0;i1<l1.count();i1++) {
569 l1.at(i1)->reloadXML();
574 externalTools->actionCollection()->writeShortcutSettings(
"Shortcuts",
new TDEConfig(
"externaltools",
false,
false,
"appdata") );
577 void KateMainWindow::openURL (
const TQString &name)
579 m_viewManager->openURL (KURL(name));
582 void KateMainWindow::slotConfigure()
584 if (!m_viewManager->activeView())
587 KateConfigDialog* dlg =
new KateConfigDialog (
this, m_viewManager->activeView());
596 KURL KateMainWindow::activeDocumentUrl()
600 Kate::View *v = m_viewManager->activeView();
602 return v->getDoc()->url();
606 void KateMainWindow::fileSelected(
const KFileItem * )
608 const KFileItemList *list=fileselector->dirOperator()->selectedItems();
610 for (KFileItemListIterator it(*list); (tmp = it.current()); ++it)
612 m_viewManager->openURL(tmp->url());
613 fileselector->dirOperator()->view()->setSelected(tmp,
false);
618 void KateMainWindow::mSlotFixOpenWithMenu()
621 documentOpenWith->popupMenu()->clear();
623 KMimeType::Ptr mime = KMimeType::findByURL( m_viewManager->activeView()->getDoc()->url() );
626 TDETrader::OfferList offers = TDETrader::self()->query(mime->name(),
"Type == 'Application'");
628 for(TDETrader::OfferList::Iterator it = offers.begin(); it != offers.end(); ++it) {
629 if ((*it)->name() ==
"Kate")
continue;
630 documentOpenWith->popupMenu()->insertItem( SmallIcon( (*it)->icon() ), (*it)->name() );
633 documentOpenWith->popupMenu()->insertItem(i18n(
"&Other..."));
636 void KateMainWindow::slotOpenWithMenuAction(
int idx)
639 list.append( m_viewManager->activeView()->getDoc()->url() );
640 TQString appname = documentOpenWith->popupMenu()->text(idx);
642 appname = appname.remove(
'&');
643 if ( appname.compare(i18n(
"Other...")) == 0 ) {
645 KOpenWithDlg dlg(list);
647 KRun::run(*dlg.service(), list);
651 TQString qry = TQString(
"((Type == 'Application') and (Name == '%1'))").arg( appname.latin1() );
652 KMimeType::Ptr mime = KMimeType::findByURL( m_viewManager->activeView()->getDoc()->url() );
653 TDETrader::OfferList offers = TDETrader::self()->query(mime->name(), qry);
655 if (!offers.isEmpty()) {
656 KService::Ptr app = offers.first();
657 KRun::run(*app, list);
660 KMessageBox::error(
this, i18n(
"Application '%1' not found!").arg(appname.latin1()), i18n(
"Application Not Found!"));
663 void KateMainWindow::pluginHelp()
665 KateApp::self()->invokeHelp (TQString::null,
"kate-plugins");
668 void KateMainWindow::slotMail()
681 TQPtrListIterator<Kate::Document> it(attDocs);
682 for ( ; it.current(); ++it ) {
685 if ( doc->url().isEmpty() ) {
687 int r = KMessageBox::questionYesNo(
this,
688 i18n(
"<p>The current document has not been saved, and "
689 "cannot be attached to an email message."
690 "<p>Do you want to save it and proceed?"),
691 i18n(
"Cannot Send Unsaved File"),KStdGuiItem::saveAs(),KStdGuiItem::cancel() );
692 if ( r == KMessageBox::Yes ) {
693 Kate::View *v = (Kate::View*)doc->views().first();
694 int sr = v->saveAs();
695 if ( sr == Kate::View::SAVE_OK ) { ;
698 if ( sr != Kate::View::SAVE_CANCEL )
699 KMessageBox::sorry(
this, i18n(
"The file could not be saved. Please check "
700 "if you have write permission.") );
707 if ( doc->isModified() ) {
709 int r = KMessageBox::warningYesNoCancel(
this,
710 i18n(
"<p>The current file:<br><strong>%1</strong><br>has been "
711 "modified. Modifications will not be available in the attachment."
712 "<p>Do you want to save it before sending it?").arg(doc->url().prettyURL()),
713 i18n(
"Save Before Sending?"), KStdGuiItem::save(), i18n(
"Do Not Save") );
715 case KMessageBox::Cancel:
717 case KMessageBox::Yes:
719 if ( doc->isModified() ) {
720 KMessageBox::sorry(
this, i18n(
"The file could not be saved. Please check "
721 "if you have write permission.") );
730 urls << doc->url().url();
732 if ( ! urls.count() )
743 void KateMainWindow::tipOfTheDay()
745 KTipDialog::showTip(
this, TQString::null,
true );
748 void KateMainWindow::slotFullScreen(
bool t)
756 void KateMainWindow::updateGrepDir (
bool visible)
762 if ( m_viewManager->activeView() )
764 if ( m_viewManager->activeView()->getDoc()->url().isLocalFile() )
766 greptool->updateDirName( m_viewManager->activeView()->getDoc()->url().directory() );
771 bool KateMainWindow::event( TQEvent *e )
773 uint type = e->type();
774 if ( type == TQEvent::WindowActivate && modNotification )
776 showModOnDiskPrompt();
778 return KateMDI::MainWindow::event( e );
781 bool KateMainWindow::showModOnDiskPrompt()
785 DocVector list( KateDocManager::self()->documents() );
787 for( doc = KateDocManager::self()->firstDocument(); doc; doc = KateDocManager::self()->nextDocument() )
789 if ( KateDocManager::self()->documentInfo( doc )->modifiedOnDisc )
791 list.insert( cnt, doc );
796 if ( cnt && !m_modignore )
801 bool res = mhdlg.exec();
809 void KateMainWindow::slotDocumentCreated (Kate::Document *doc)
811 connect(doc,TQT_SIGNAL(modStateChanged(Kate::Document *)),
this,TQT_SLOT(updateCaption(Kate::Document *)));
812 connect(doc,TQT_SIGNAL(nameChanged(Kate::Document *)),
this,TQT_SLOT(slotNameChanged(Kate::Document *)));
813 connect(doc,TQT_SIGNAL(nameChanged(Kate::Document *)),
this,TQT_SLOT(slotUpdateOpenWith()));
818 void KateMainWindow::slotNameChanged(Kate::Document *doc)
821 if (!doc->url().isEmpty())
822 fileOpenRecent->addURL(doc->url());
825 void KateMainWindow::updateCaption(Kate::Document *doc)
827 if (!m_viewManager->activeView())
829 setCaption (
"",
false);
833 if (!(m_viewManager->activeView()->getDoc() == doc))
837 if (m_viewManager->activeView()->getDoc()->url().isEmpty() || (!m_viewManager->getShowFullPath()))
839 c = m_viewManager->activeView()->getDoc()->docName();
843 c = m_viewManager->activeView()->getDoc()->url().prettyURL();
849 if (!sessName.isEmpty())
851 sessName = TQString(
"%1: ").arg(sessName);
853 setCaption(KStringHandler::lsqueeze(sessName,32) + KStringHandler::lsqueeze(c,64),
854 m_viewManager->activeView()->getDoc()->isModified());
858 setCaption(KStringHandler::lsqueeze(c,64), m_viewManager->activeView()->getDoc()->isModified());
862 void KateMainWindow::saveProperties(TDEConfig *config)
864 TQString grp=config->group();
866 saveSession(config, grp);
867 m_viewManager->saveViewConfiguration (config, grp);
869 config->setGroup(grp);
872 void KateMainWindow::readProperties(TDEConfig *config)
874 TQString grp=config->group();
876 startRestore(config, grp);
878 m_viewManager->restoreViewConfiguration (config, grp);
880 config->setGroup(grp);
884 void KateMainWindow::slotSelectionChanged()
886 TDEActionCollection *mwac = actionCollection();
887 TDEActionPtrList actionList = m_sessionpanel->m_actionCollection->actions();
888 TDEActionPtrList::ConstIterator spa_it;
889 for (spa_it = actionList.begin(); spa_it != actionList.end(); ++spa_it)
891 TDEAction *a = mwac->action((*spa_it)->name());
892 TDEToggleAction *ta =
dynamic_cast<TDEToggleAction*
>(a);
895 ta->setChecked((dynamic_cast<TDEToggleAction*>(*spa_it))->isChecked());
899 a->setEnabled((*spa_it)->isEnabled());
905 void KateMainWindow::activateSession(
int sessionId)
907 if (sessionId < 0 || sessionId ==
KateApp::self()->sessionManager()->getActiveSessionId())
913 TQListViewItem *item = m_sessionpanel->m_listview->firstChild();
915 while (item && idx < sessionId)
917 item = item->nextSibling();
920 if (idx == sessionId && item)
923 m_sessionpanel->m_listview->setSelected(item,
true);
924 m_sessionpanel->slotActivateSession();
929 KateSessionListActionMenu::KateSessionListActionMenu(KateMainWindow *mw,
const TQString &text, TQObject *parent,
const char *name)
930 : TDEActionMenu(text, parent, name), m_mainWindow(mw)
932 connect(popupMenu(), TQT_SIGNAL(aboutToShow()),
this, TQT_SLOT(slotAboutToShow()));
936 void KateSessionListActionMenu::slotAboutToShow()
938 popupMenu()->clear();
941 for (
int idx = 0; idx < (int)sessions.count(); ++idx)
943 popupMenu()->insertItem(sessions[idx]->getSessionName(), m_mainWindow, TQT_SLOT(activateSession(
int)), 0, idx);