Index: trunk/kdebase/kant/view/kantviewmanager.cpp =================================================================== --- trunk/kdebase/kant/view/kantviewmanager.cpp (revision 84694) +++ trunk/kdebase/kant/view/kantviewmanager.cpp (revision 84695) @@ -1,1035 +1,1036 @@ /*************************************************************************** kantviewmanager.cpp - description ------------------- begin : Wed Jan 3 2001 copyright : (C) 2001 by Christoph "Crossfire" Cullmann email : crossfire@babylon2k.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "kantviewmanager.h" #include "kantviewmanager.moc" #include #include #include #include KantVMListBoxItem::KantVMListBoxItem (const QPixmap &pixmap,const QString &text, long docID) : KantListBoxItem (pixmap, text ) { myDocID = docID; } KantVMListBoxItem::~KantVMListBoxItem () { } long KantVMListBoxItem::docID () { return myDocID; } KantViewManager::KantViewManager (QWidget *parent, KantDocManager *docManager, KantSidebar *sidebar) : KantPluginIface (parent) { // no memleaks viewList.setAutoDelete(true); viewSpaceList.setAutoDelete(true); myViewID = 0; this->docManager = docManager; this->sidebar = sidebar; // sizemanagment grid = new QGridLayout( this, 1, 1 ); KantViewSpace* vs = new KantViewSpace( this ); connect(this, SIGNAL(statusChanged(KantView *, int, int, int, int, QString)), vs, SLOT(slotStatusChanged(KantView *, int, int, int, int, QString))); vs->setActive( true ); vs->installEventFilter( this ); grid->addWidget( vs, 0, 0); viewSpaceList.append(vs); listbox = new KListBox (sidebar); fileselector = new KantFileSelector(0, "operator"); fileselector->dirOperator()->setView(KFile::Simple); sidebar->addWidget (fileselector, i18n("Fileselector")); sidebar->addWidget (listbox, i18n("Files")); connect(listbox,SIGNAL(highlighted(QListBoxItem *)),this,SLOT(activateView(QListBoxItem *))); connect(listbox,SIGNAL(selected(QListBoxItem *)),this,SLOT(activateView(QListBoxItem *))); connect(fileselector->dirOperator(),SIGNAL(fileSelected(const KFileViewItem*)),this,SLOT(fileSelected(const KFileViewItem*))); connect( this, SIGNAL(viewChanged()), this, SLOT(slotViewChanged()) ); } KantViewManager::~KantViewManager () { } bool KantViewManager::createView ( bool newDoc, KURL url, KantView *origView ) { KantDocument *doc; // create doc if (newDoc) { QFileInfo* fi; if ( (!url.isEmpty()) && (url.filename() != 0) ) { // if this is a local file, get some information if ( url.isLocalFile() ) { fi = new QFileInfo(url.path()); if (!fi->exists()) { kdDebug()<fileOpenRecent->addURL( KURL( url.prettyURL() ) ); } else fi = new QFileInfo(); doc = docManager->createDoc (fi); } else doc = (KantDocument *)origView->doc(); // create view KantView *view = new KantView (this, doc, (QString("KantViewIface%1").arg(myViewID)).latin1()); connect(view,SIGNAL(newStatus()),this,SLOT(setWindowCaption())); connect(view,SIGNAL(newStatus()),this,SLOT(slotSetModified())); myViewID++; viewList.append (view); KConfig *config = ((KantMainWindow*)topLevelWidget())->config; config->setGroup("kwrite"); doc->readConfig( config ); view->readConfig( config ); if (!newDoc) view->copySettings(origView); view->init(); if (newDoc) { view->newDoc(); if (!url.isEmpty()) { view->doc()->openURL ( url ); if (url.filename() != 0) view->setCaption (url.filename()); else { view->setCaption (i18n("Untitled %1").arg(doc->docID())); } } else { view->setCaption (i18n("Untitled %1").arg(doc->docID())); } } else view->setCaption (origView->caption()); // if new document insert KantListItem in listbox if (newDoc) listbox->insertItem (new KantVMListBoxItem (SmallIcon("null"),view->caption(), doc->docID()) ); view->installPopup ((QPopupMenu*)((KMainWindow *)topLevelWidget ())->factory()->container("view_popup", (KMainWindow *)topLevelWidget ()) ); connect(view,SIGNAL(newCurPos()),this,SLOT(statusMsgOther())); connect(view,SIGNAL(newStatus()),this,SLOT(statusMsgOther())); connect(view, SIGNAL(newUndo()), this, SLOT(statusMsgOther())); connect(view,SIGNAL(statusMsg(const QString &)),this,SLOT(statusMsg(const QString &))); connect(view,SIGNAL(dropEventPass(QDropEvent *)), (KMainWindow *)topLevelWidget (),SLOT(slotDropEvent(QDropEvent *))); connect(view,SIGNAL(gotFocus(KantView *)),this,SLOT(activateSpace(KantView *))); activeViewSpace()->addView( view ); activateView( view ); return true; } bool KantViewManager::deleteView (KantView *view, bool force, bool delViewSpace, bool createNew) { if (!view) return true; KantViewSpace *viewspace = (KantViewSpace *)view->parentWidget()->parentWidget(); bool removeDoc = false; if (view->isLastView()) { // If !force query user to close doc if (!force) { if (!view->canDiscard()) return false; } removeDoc = true; } // clear caption of mainwindow if this is the current view ;-) if ( view == activeView() ) topLevelWidget()->setCaption ( "" ); viewspace->removeView (view); // Remove hole doc KantDocument *dDoc; if (removeDoc) { for (uint i = 0; i < listbox->count(); i++) { if (((KantVMListBoxItem *) listbox->item (i)) ->docID() == ((KantDocument *) view->doc())->docID()) { // QT BUGFIX - if you remove the last item of a listbox it crashs after the next insert !!!!! if (listbox->count() > 1) listbox->removeItem( i ); else listbox->clear(); } } dDoc = (KantDocument *) view->doc(); } // remove view from list and memory !! viewList.remove (view); if (removeDoc) docManager->deleteDoc (dDoc); if (delViewSpace) if ( viewspace->viewCount() == 0 ) removeViewSpace( viewspace ); if (createNew && (viewList.count() < 1)) createView (true, 0L, 0L); emit viewChanged (); return true; } KantViewSpace* KantViewManager::activeViewSpace () { QListIterator it(viewSpaceList); for (; it.current(); ++it) { if ( it.current()->isActiveSpace() ) return it.current(); } if (viewSpaceList.count() > 0) { viewSpaceList.first()->setActive( true ); return viewSpaceList.first(); } return 0L; } KantView* KantViewManager::activeView () { QListIterator it(viewList); for (; it.current(); ++it) { if ( it.current()->isActive() ) return it.current(); } if (viewList.count() > 0) { viewList.first()->setActive( true ); return viewList.first(); } return 0L; } void KantViewManager::setActiveSpace ( KantViewSpace* vs ) { if (activeViewSpace()) activeViewSpace()->setActive( false ); vs->setActive( true ); } void KantViewManager::setActiveView ( KantView* view ) { //kdDebug()<<"setActiveView()"<setActive( false ); view->setActive( true ); } void KantViewManager::activateSpace (KantView* v) { if (!v) return; KantViewSpace* vs = (KantViewSpace*)v->parentWidget()->parentWidget(); if (!vs->isActiveSpace()) { setActiveSpace (vs); activateView(v); } } void KantViewManager::activateView ( KantView *view ) { if (!view) return; //kdDebug()<<"activateView"<doc())->isModOnHD(); if (!view->isActive()) { if ( !activeViewSpace()->showView (view) ) { // since it wasn't found, give'em a new one kdDebug()<<"Sometimes things aren't what they seem..."<count(); i++) { if ( ((KantVMListBoxItem *) listbox->item (i))->docID() == ((KantDocument *) view->doc())->docID() ) listbox->setCurrentItem( i ); } emit viewChanged (); } } void KantViewManager::activateView( QListBoxItem *item ) { activateView( ((KantVMListBoxItem *)item)->docID() ); } void KantViewManager::activateView( int docID ) { if ( activeViewSpace()->showView(docID) ) { activateView( activeViewSpace()->currentView() ); } else { QListIterator it(viewList); for ( ;it.current(); ++it) { if ( ( (KantDocument *)it.current()->doc() )->docID() == docID ) { createView( false, 0L, it.current() ); //activateView( current ); return; } } } } long KantViewManager::viewCount () { return viewList.count(); } long KantViewManager::viewSpaceCount () { return viewSpaceList.count(); } void KantViewManager::slotViewChanged() { if ( activeView() && !activeView()->hasFocus()) activeView()->setFocus(); } void KantViewManager::activateNextView() { viewList.findRef (activeView()); viewList.next(); if (viewList.current()) viewList.current()->setFocus(); else viewList.first(); } void KantViewManager::activatePrevView() { viewList.findRef (activeView()); viewList.prev(); if (viewList.current()) viewList.current()->setFocus(); else viewList.last(); } void KantViewManager::deleteLastView () { deleteView (activeView (), true, true, false); } void KantViewManager::statusMsg (const QString &msg) { if (activeView() == 0) return; bool readOnly = activeView()->isReadOnly(); int config = activeView()->config(); int ovr = 0; if (readOnly) ovr = 0; else { if (config & KWrite::cfOvr) { ovr=1; } else { ovr=2; } } int mod = 0; if (activeView()->isModified()) mod = 1; // anders: since activeView() loops, lets ask it only once! KantView* v = activeView(); emit statusChanged (v, v->currentLine() + 1, v->currentColumn() + 1, ovr, mod, QString(msg)); emit statChanged (); } void KantViewManager::statusMsgOther () { if (activeView() == 0) return; // anders: since activeView() loops, lets ask it only once! KantView* v = activeView(); bool readOnly = v->isReadOnly(); int config = v->config(); int ovr = 0; if (readOnly) ovr = 0; else { if (config & KWrite::cfOvr) { ovr=1; } else { ovr=2; } } int mod = (int)v->isModified(); QString msg = v->doc()->url().prettyURL(); if (msg.isEmpty()) msg = v->caption(); emit statusChanged (v, v->currentLine() + 1, v->currentColumn() + 1, ovr, mod, msg); emit statChanged (); } void KantViewManager::fileSelected(const KFileViewItem *file) { KURL u(file->urlString()); openURL( u ); } void KantViewManager::slotWindowNext() { long id = docManager->findDoc ((KantDocument *) activeView ()->doc()) - 1; if (id < 0) id = docManager->docCount () - 1; listbox->setCurrentItem( id ); } void KantViewManager::slotWindowPrev() { long id = docManager->findDoc ((KantDocument *) activeView ()->doc()) + 1; if (id >= docManager->docCount () ) id = 0; listbox->setCurrentItem( id ); } void KantViewManager::slotDocumentNew () { createView (true, 0L, 0L); } void KantViewManager::slotDocumentOpen () { KURL::List urls = KFileDialog::getOpenURLs(QString::null, QString::null, 0L, i18n("Open File...")); for (KURL::List::Iterator i=urls.begin(); i != urls.end(); ++i) { openURL( *i ); } } void KantViewManager::setUnmodified(long docId, const QString &text) { for (uint i = 0; i < listbox->count(); i++) { if (((KantVMListBoxItem *) listbox->item (i)) ->docID() == docId) { ((KantVMListBoxItem *)listbox->item(i))->setPixmap(SmallIcon("null")); ((KantVMListBoxItem *)listbox->item(i))->setBold(false); if (!text.isNull()) ((KantVMListBoxItem *)listbox->item(i))->setText(text); listbox->triggerUpdate(false); break; } } } void KantViewManager::setModified(long docId, const QString &text) { for (uint i = 0; i < listbox->count(); i++) { if (((KantVMListBoxItem *) listbox->item (i)) ->docID() == docId) { ((KantVMListBoxItem *)listbox->item(i))->setPixmap(SmallIcon("modified")); ((KantVMListBoxItem *)listbox->item(i))->setBold(true); if (!text.isNull()) ((KantVMListBoxItem *)listbox->item(i))->setText(text); listbox->triggerUpdate(false); break; } } } void KantViewManager::slotDocumentSave () { if (activeView() == 0) return; KantView *current = activeView(); if( current->doc()->isModified() ) { if( !current->doc()->url().isEmpty() && current->doc()->isReadWrite() ) { current->doc()->save(); setUnmodified(((KantDocument *)current->doc())->docID(),QString()); } else slotDocumentSaveAs(); } } void KantViewManager::slotDocumentSaveAll () { QListIterator it(viewList); for ( ;it.current(); ++it) { KantView* current = it.current(); if( current->doc()->isModified() ) { if( !current->doc()->url().isEmpty() && current->doc()->isReadWrite() ) { current->doc()->save(); setUnmodified(((KantDocument *)current->doc())->docID(),QString()); } else slotDocumentSaveAs(); } } } void KantViewManager::slotDocumentSaveAs () { if (activeView() == 0) return; KantView *current = activeView(); KURL url = KFileDialog::getSaveURL(QString::null, QString::null, 0L, i18n("Save File...")); if( !url.isEmpty() ) { current->doc()->saveAs( url ); current->setCaption (url.filename()); setWindowCaption(); for (uint i = 0; i < listbox->count(); i++) { if (((KantVMListBoxItem *) listbox->item (i)) ->docID() == ((KantDocument *) current->doc())->docID()) setUnmodified(((KantDocument *)current->doc())->docID(),current->caption()); } } } void KantViewManager::slotDocumentClose () { if (!activeView()) return; long docID = ((KantDocument *)activeView()->doc())->docID(); QList closeList; QListIterator it(viewList); for ( ;it.current(); ++it) { KantView* current = it.current(); if ( ((KantDocument *)current->doc())->docID() == docID ) { closeList.append (current); } } bool done = false; while ( closeList.at(0) ) { KantView *view = closeList.at(0); done = deleteView (view); closeList.remove (view); if (!done) return; } if (activeView()) { listbox->setSelected(listbox->currentItem(), true); } } void KantViewManager::slotDocumentCloseAll () { if (docManager->docCount () == 0) return; bool done = false; uint viewCounter = viewCount(); uint i = 0; while (i <= viewCounter) { done = deleteView(activeView()); if (!done) return; else i++; } } void KantViewManager::slotUndo () { if (activeView() == 0) return; activeView()->undo(); } void KantViewManager::slotRedo () { if (activeView() == 0) return; activeView()->redo(); } void KantViewManager::slotUndoHistory () { if (activeView() == 0) return; activeView()->undoHistory(); } void KantViewManager::slotCut () { if (activeView() == 0) return; activeView()->cut(); } void KantViewManager::slotCopy () { if (activeView() == 0) return; activeView()->copy(); } void KantViewManager::slotPaste () { if (activeView() == 0) return; activeView()->paste(); } void KantViewManager::slotSelectAll () { if (activeView() == 0) return; activeView()->selectAll(); } void KantViewManager::slotDeselectAll () { if (activeView() == 0) return; activeView()->deselectAll(); } void KantViewManager::slotInvertSelection () { if (activeView() == 0) return; activeView()->invertSelection(); } void KantViewManager::slotFind () { if (activeView() == 0) return; activeView()->find(); } void KantViewManager::slotFindAgain () { if (activeView() == 0) return; activeView()->findAgain(); } void KantViewManager::slotFindAgainB () { if (activeView() == 0) return; activeView()->searchAgain(true); } void KantViewManager::slotReplace () { if (activeView() == 0) return; activeView()->replace(); } void KantViewManager::slotIndent() { KantView* v = activeView(); if (v) v->indent(); } void KantViewManager::slotUnIndent() { KantView* v = activeView(); if (v) v->unIndent(); } void KantViewManager::slotInsertFile () { if (activeView() == 0) return; activeView()->insertFile(); } void KantViewManager::slotSpellcheck () { if (activeView() == 0) return; activeView()->spellcheck(); } void KantViewManager::slotGotoLine () { if (activeView() == 0) return; activeView()->gotoLine(); } void KantViewManager::slotHlDlg () { if (activeView() == 0) return; activeView()->hlDlg(); KWriteFactory::instance()->config()->sync(); KConfig *config = KWriteFactory::instance()->config(); activeView()->writeConfig(config); activeView()->doc()->writeConfig(config); KWriteFactory::instance()->config()->sync(); } void KantViewManager::slotSetHl (int n) { if (activeView() == 0) return; activeView()->setHl(n); } void KantViewManager::addBookmark () { if (activeView() == 0) return; activeView()->addBookmark(); } void KantViewManager::setBookmark () { if (activeView() == 0) return; activeView()->setBookmark(); } void KantViewManager::clearBookmarks () { if (activeView() == 0) return; activeView()->clearBookmarks(); } void KantViewManager::openURL (KURL url) { if ( !docManager->isOpen( url ) ) createView (true, url, 0L); else activateView( docManager->findDoc( url ) ); } void KantViewManager::openConstURL (const KURL& url) { if ( !docManager->isOpen( url ) ) createView (true, url, 0L); else activateView( docManager->findDoc( url ) ); } void KantViewManager::printNow() { if (!activeView()) return; activeView()->printDlg (); } void KantViewManager::printDlg() { if (!activeView()) return; activeView()->printDlg (); } void KantViewManager::splitViewSpace(bool isHoriz) { if (!activeView()) return; bool isFirstTime = activeViewSpace()->parentWidget() == this; QValueList sizes; if (! isFirstTime) sizes = ((QSplitter*)activeViewSpace()->parentWidget())->sizes(); Qt::Orientation o = isHoriz ? Qt::Vertical : Qt::Horizontal; QSplitter* s = new QSplitter(o, activeViewSpace()->parentWidget()); s->setOpaqueResize( useOpaqueResize ); if (! isFirstTime) { viewSpaceList.findRef(activeViewSpace()); uint at = viewSpaceList.at(); if ( (at < (viewSpaceList.count() - 1)) && (viewSpaceList.at(at +1)->parentWidget() == activeViewSpace()->parentWidget() ) ) ((QSplitter*)s->parentWidget())->moveToFirst( s ); } activeViewSpace()->reparent( s, 0, QPoint(), true ); KantViewSpace* vs = new KantViewSpace( s ); if (isFirstTime) grid->addWidget(s, 0, 0); else ((QSplitter*)s->parentWidget())->setSizes( sizes ); sizes.clear(); int sz = isHoriz ? s->height()/2 : s->width()/2; sizes.append(sz); sizes.append(sz); s->setSizes( sizes ); s->show(); connect(this, SIGNAL(statusChanged(KantView *, int, int, int, int, QString)), vs, SLOT(slotStatusChanged(KantView *, int, int, int, int, QString))); viewSpaceList.append( vs ); vs->installEventFilter( this ); //s->moveToLast( vs ); activeViewSpace()->setActive( false ); vs->setActive( true ); vs->show(); createView (false, 0L, (KantView *)activeView()); } void KantViewManager::removeViewSpace (KantViewSpace *viewspace) { // abort if viewspace is 0 if (!viewspace) return; // abort if this is the last viewspace if (viewSpaceList.count() < 2) return; QSplitter* p = (QSplitter*)viewspace->parentWidget(); QSplitter* pp=0L; QValueList ppsizes; if (viewSpaceList.count() > 2 && p->parentWidget() != this) { pp = (QSplitter*)p->parentWidget(); ppsizes = pp->sizes(); } //KantViewSpace *next = viewSpaceList.prev(); KantViewSpace* next; if (viewSpaceList.find(viewspace) == 0) next = viewSpaceList.next(); else next = viewSpaceList.prev(); // here, reparent views in viewspace that are last views, delete the rest. int vsvc = viewspace->viewCount(); while (vsvc > 0) { if (viewspace->currentView()) { kdDebug()<currentView(); if (v->isLastView()) { viewspace->removeView(v); next->addView( v, false ); } else { deleteView( v, false, false, false ); } } else kdDebug()<<"removeViewSpace(): PANIC!!"<viewCount(); } viewSpaceList.remove( viewspace ); while (p->children ()) { ((QWidget *)(( QList*)p->children())->first())->reparent( p->parentWidget(), 0, QPoint(), true ); } delete p; if (!ppsizes.isEmpty()) pp->setSizes( ppsizes ); viewSpaceList.find( activeViewSpace() ); if (viewSpaceList.current()->parentWidget() == this) grid->addWidget( viewSpaceList.current(), 0, 0); viewSpaceList.current()->setActive( true ); emit viewChanged(); } void KantViewManager::slotCloseCurrentViewSpace() { removeViewSpace(activeViewSpace()); } void KantViewManager::setWindowCaption() { if (activeView()) { QString c; if (activeView()->doc()->url().isEmpty() || (! showFullPath)) c = activeView()->caption(); else c = activeView()->doc()->url().prettyURL(); ((KantMainWindow*)topLevelWidget())->setCaption( c,activeView()->isModified()); } } void KantViewManager::setShowFullPath( bool enable ) { showFullPath = enable; setWindowCaption(); } void KantViewManager::setUseOpaqueResize( bool enable ) { useOpaqueResize = enable; // TODO: loop through splitters and set this prop } void KantViewManager::slotSetModified() { if (!activeView()) return; if ( ( ((KantDocument *) activeView()->doc())->isModified() ) ) setModified(((KantDocument *) activeView()->doc())->docID(),QString()); else setUnmodified(((KantDocument *) activeView()->doc())->docID(),QString()); } void KantViewManager::saveAllDocsAtCloseDown(KConfig* config) { QValueList seen; KantView* v; int id; QStringList data; QStringList list; int vc = viewCount(); uint i = 0; while ( i <= vc ) { v = activeView(); id = ((KantDocument*)v->doc())->docID(); // save to config if not seen if ( ! seen.contains( id ) && ! v->doc()->url().isEmpty() ) { seen.append( id ); data.clear(); // TODO: should we tjeck for local file here? // add URL, cursor position data.append( v->doc()->url().prettyURL() );//URL data.append( QString("%1.%2").arg(v->currentLine()).arg(v->currentColumn()) );// CURSOR //data.append();// LASTMOD // write entry config->setGroup("open files"); config->writeEntry( QString("File%1").arg(id), data ); list.append( QString("File%1").arg(id) ); } if( ! deleteView( v ) ) return; i++; } config->setGroup("open files"); config->writeEntry( "list", list ); } void KantViewManager::reloadCurrentDoc() { if (! activeView() ) return; - ((KantDocument*)activeView()->doc())->reloadFile(); + if (activeView()->canDiscard()) + ((KantDocument*)activeView()->doc())->reloadFile(); } Index: trunk/kdebase/kant/mainwindow/kantmainwindow.cpp =================================================================== --- trunk/kdebase/kant/mainwindow/kantmainwindow.cpp (revision 84694) +++ trunk/kdebase/kant/mainwindow/kantmainwindow.cpp (revision 84695) @@ -1,1015 +1,1015 @@ /*************************************************************************** kantmainwindow.cpp - description ------------------- begin : Wed Jan 3 2001 copyright : (C) 2001 by Christoph "Crossfire" Cullmann email : crossfire@babylon2k.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "kantmainwindow.h" #include "kantmainwindow.moc" #include //#include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../console/kantconsole.h" #include "../document/kantdocmanager.h" #include "../kwrite/kwdialog.h" #include "../pluginmanager/kantpluginmanager.h" #include "../pluginmanager/kantconfigplugindialogpage.h" #include "../project/kantprojectmanager.h" #include "../view/kantviewmanager.h" #include "kantmenuitem.h" #define POP_(x) kdDebug() << #x " = " << flush << x << endl KantMainWindow::KantMainWindow(KantPluginManager *_pluginManager) : KDockMainWindow (0, "Main Window"), DCOPObject ("KantIface" ), m_pFilterShellProcess (NULL) { pluginManager=_pluginManager; config = kapp->config(); setXMLFile( "kantui.rc" ); setAcceptDrops(true); setupMainWindow(); setupActions(); createGUI(); readProperties(config); // connect slot for updating menustatus of "project" QPopupMenu* pm_project = (QPopupMenu*)factory()->container("project", this); connect(pm_project, SIGNAL(aboutToShow()), this, SLOT(projectMenuAboutToShow())); // connect settings menu aboutToshow QPopupMenu* pm_set = (QPopupMenu*)factory()->container("settings", this); connect(pm_set, SIGNAL(aboutToShow()), this, SLOT(settingsMenuAboutToShow())); setUpdatesEnabled(false); // QObject *jw1=new QObject(this); // KXMLGUIClient *gui=new KXMLGUIClient(this); KParts::Plugin::loadPlugins(viewManager,pluginManager->plugins); KParts::GUIActivateEvent ev( true ); QApplication::sendEvent( viewManager, &ev ); // guiFactory()->addClient( gui ); QList plugins =KParts:: Plugin::pluginObjects( viewManager ); QListIterator pIt( plugins ); for (; pIt.current(); ++pIt ) guiFactory()->addClient( pIt.current() ); setUpdatesEnabled(true); installEventFilter(this); } KantMainWindow::~KantMainWindow() { delete m_pFilterShellProcess; } void KantMainWindow::setupMainWindow () { docManager = new KantDocManager (); sidebarDock = createDockWidget( "sidebarDock", 0 ); sidebar = new KantSidebar (sidebarDock); sidebar->setMinimumSize(100,100); sidebarDock->setWidget( sidebar ); consoleDock = createDockWidget( "consoleDock", 0 ); console = new KantConsole (consoleDock, "console"); console->installEventFilter( this ); console->setMinimumSize(50,50); consoleDock->setWidget( console ); mainDock = createDockWidget( "mainDock", 0 ); mainDock->setGeometry(100, 100, 100, 100); viewManager = new KantViewManager (mainDock, docManager, sidebar); viewManager->setMinimumSize(200,200); mainDock->setWidget(viewManager); setView( mainDock ); setMainDockWidget( mainDock ); mainDock->setEnableDocking ( KDockWidget::DockNone ); sidebarDock->manualDock ( mainDock, KDockWidget::DockLeft, 20 ); consoleDock->manualDock ( mainDock, KDockWidget::DockBottom, 20 ); sidebarDock->setFocusPolicy(QWidget::ClickFocus); consoleDock->setFocusPolicy(QWidget::ClickFocus); projectManager = new KantProjectManager (docManager, viewManager, statusBar()); statusBar()->hide(); } bool KantMainWindow::eventFilter(QObject* o, QEvent* e) { if (e->type() == QEvent::KeyPress) { QKeyEvent *ke=(QKeyEvent*)e; if (ke->key()==goNext->accel()) { kdDebug()<<"Jump next view registered in Konsole"; slotGoNext(); return true; } else if (ke->key()==goPrev->accel()) { kdDebug()<<"Jump prev view registered in Konsole"; slotGoPrev(); return true; } } if (o == this && e->type() == QEvent::FocusIn) { kdDebug()<<"focus in"<popupMenu(), SIGNAL(aboutToShow()), this, SLOT(bookmarkMenuAboutToShow())); toolsSpell = KStdAction::spelling(viewManager, SLOT(slotSpellcheck()), actionCollection()); new KAction ( i18n("Fi<er Text..."), "edit_filter", CTRL + Key_Backslash, this, SLOT( slotEditFilter() ), actionCollection(), "edit_filter" ); viewSplitVert = new KAction( i18n("Split &Vertical"), "view_left_right", CTRL+SHIFT+Key_L, viewManager, SLOT( slotSplitViewSpaceVert() ), actionCollection(), "view_split_vert"); viewSplitHoriz = new KAction( i18n("Split &Horizontal"), "view_top_bottom", CTRL+SHIFT+Key_T, viewManager, SLOT( slotSplitViewSpaceHoriz() ), actionCollection(), "view_split_horiz"); closeCurrentViewSpace = new KAction( i18n("Close &Current"), "remove_view", CTRL+SHIFT+Key_R, viewManager, SLOT( slotCloseCurrentViewSpace() ), actionCollection(), "view_close_current_space"); goNext=new KAction(i18n("Next View"),Key_F8,viewManager, SLOT(activateNextView()),actionCollection(),"go_next"); goPrev=new KAction(i18n("Previous View"),SHIFT+Key_F8,viewManager, SLOT(activatePrevView()),actionCollection(),"go_prev"); windowNext = KStdAction::back(viewManager, SLOT(slotWindowNext()), actionCollection()); windowPrev = KStdAction::forward(viewManager, SLOT(slotWindowPrev()), actionCollection()); docListMenu = new KActionMenu(i18n("&Document List"), actionCollection(), "doc_list"); connect(docListMenu->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(docListMenuAboutToShow())); - documentReload = new KAction(i18n("&Reload"), "reload", Key_F5, viewManager, SLOT(reloadCurrentDoc()), actionCollection(), "document_reload"); + documentReload = new KAction(i18n("&Reload"), "reload", Key_F4, viewManager, SLOT(reloadCurrentDoc()), actionCollection(), "document_reload"); setHighlightConf = new KAction(i18n("Configure Highlighti&ng..."), 0, viewManager, SLOT(slotHlDlg()),actionCollection(), "set_confHighlight"); setHighlight = new KSelectAction(i18n("&Highlight Mode"), 0, actionCollection(), "set_highlight"); connect(setHighlight, SIGNAL(activated(int)), viewManager, SLOT(slotSetHl(int))); QStringList list; for (int z = 0; z < HlManager::self()->highlights(); z++) list.append(i18n(HlManager::self()->hlName(z))); setHighlight->setItems(list); KStdAction::keyBindings(this, SLOT(editKeys()), actionCollection()); KStdAction::configureToolbars(this, SLOT(slotEditToolbars()), actionCollection(), "set_configure_toolbars"); // toggle sidebar -anders settingsShowSidebar = new KToggleAction(i18n("Show Side&bar"), CTRL+Key_B, this, SLOT(slotSettingsShowSidebar()), actionCollection(), "settings_show_sidebar"); settingsShowConsole = new KToggleAction(i18n("Show &Console"), CTRL+Key_K, this, SLOT(slotSettingsShowConsole()), actionCollection(), "settings_show_console"); // allow full path in title -anders settingsShowFullPath = new KToggleAction(i18n("Show Full &Path in Title"), 0, this, SLOT(slotSettingsShowFullPath()), actionCollection(), "settings_show_full_path"); settingsShowToolbar = KStdAction::showToolbar(this, SLOT(slotSettingsShowToolbar()), actionCollection(), "settings_show_toolbar"); settingsConfigure = KStdAction::preferences(this, SLOT(slotConfigure()), actionCollection(), "settings_configure"); settingsShowFullScreen = new KToggleAction(i18n("Show &Fullscreen"),0,this,SLOT(slotSettingsShowFullScreen()),actionCollection(),"settings_show_fullscreen"); // KActions for Project projectNew = new KAction(i18n("&New"), 0, projectManager, SLOT(slotProjectNew()), actionCollection(),"project_new"); projectOpen = new KAction(i18n("&Open"), 0, projectManager, SLOT(slotProjectOpen()), actionCollection(),"project_open"); projectSave = new KAction(i18n("&Save"), 0, projectManager, SLOT(slotProjectSave()), actionCollection(),"project_save"); projectSaveAs = new KAction(i18n("&SaveAs"), 0, projectManager, SLOT(slotProjectSaveAs()), actionCollection(),"project_save_as"); projectConfigure = new KAction(i18n("&Configure"), 0, projectManager, SLOT(slotProjectConfigure()), actionCollection(),"project_configure"); projectCompile = new KAction(i18n("&Compile"), Key_F5, projectManager, SLOT(slotProjectCompile()), actionCollection(),"project_compile"); projectRun = new KAction(i18n("&Run"), 0, projectManager, SLOT(slotProjectRun()), actionCollection(),"project_run"); // KActions for Plugins pluginsAdd = new KAction(i18n("&Add"), 0, this, SLOT(slotPluginsAdd()), actionCollection(),"plugins_add"); pluginsDelete = new KAction(i18n("&Delete"), 0, this, SLOT(slotPluginsDelete()), actionCollection(),"plugins_delete"); connect(viewManager,SIGNAL(viewChanged()),this,SLOT(slotWindowActivated())); connect(viewManager,SIGNAL(statChanged()),this,SLOT(slotCurrentDocChanged())); sidebarFocusNext = new KAction(i18n("Next Sidebar &Widget"), CTRL+SHIFT+Key_B, this, SLOT(slotSidebarFocusNext()), actionCollection(), "sidebar_focus_next"); slotWindowActivated (); } bool KantMainWindow::queryClose() { saveProperties(config); // viewManager->slotDocumentCloseAll(); viewManager->saveAllDocsAtCloseDown( config ); if ( (!docManager->currentDoc()) || ((!viewManager->activeView()->doc()->isModified()) && (docManager->docCount() == 1))) { if (viewManager->activeView()) viewManager->deleteLastView (); return true; } return false; } void KantMainWindow::newWindow () { KantMainWindow *newWin = new KantMainWindow (pluginManager); newWin->viewManager->openURL( KURL() ); newWin->show (); } void KantMainWindow::slotEditToolbars() { KEditToolbar dlg(factory());//(actionCollection()); if (dlg.exec()) createGUI(); } void splitString (QString q, char c, QStringList &list) // PCP { // screw the OnceAndOnlyOnce Principle! int pos; QString item; while ( (pos = q.find(c)) >= 0) { item = q.left(pos); list.append(item); q.remove(0,pos+1); } list.append(q); } static void // PCP slipInNewText (KantView & view, QString pre, QString marked, QString post, bool reselect) { int preDeleteLine = -1, preDeleteCol = -1; view.getCursorPosition (&preDeleteLine, &preDeleteCol); assert (preDeleteLine > -1); assert (preDeleteCol > -1); // shoot me for strlen() but it worked better than .length() for some reason... // POP_(marked.latin1 ()); if (strlen (marked.latin1 ()) > 0) view.keyDelete (); int line = -1, col = -1; view.getCursorPosition (&line, &col); assert (line > -1); assert (col > -1); view.insertText (pre + marked + post); // all this muck to leave the cursor exactly where the user // put it... // Someday we will can all this (unless if it already // is canned and I didn't find it...) // The second part of the if disrespects the display bugs // when we try to reselect. TODO: fix those bugs, and we can // un-break this if... // TODO: fix OnceAndOnlyOnce between this module and plugin_kanthtmltools.cpp if (reselect && preDeleteLine == line && -1 == marked.find ('\n')) if (preDeleteLine == line && preDeleteCol == col) { view.setCursorPosition (line, col + pre.length () + marked.length () - 1); for (int x (strlen (marked.latin1())); x--;) view.shiftCursorLeft (); } else { view.setCursorPosition (line, col += pre.length ()); for (int x (strlen (marked.latin1())); x--;) view.shiftCursorRight (); } } static QString // PCP KantPrompt ( char const * strTitle, char const * strPrompt, KantMainWindow * that ) { bool ok (false); // TODO: Make this a "memory edit" field with a combo box // containing prior entries QString text ( QInputDialog::getText ( that -> tr( strTitle ), that -> tr( strPrompt ), QString::null, &ok, that ) ); if (!ok) text = ""; return text; } void KantMainWindow::slotFilterReceivedStdout (KProcess * pProcess, char * got, int len) { assert (pProcess == m_pFilterShellProcess); if (got && len) { // TODO: got a better idea? while (len--) m_strFilterOutput += *got++; // POP_(m_strFilterOutput); } } void KantMainWindow::slotFilterReceivedStderr (KProcess * pProcess, char * got, int len) { slotFilterReceivedStdout (pProcess, got, len); } void KantMainWindow::slotFilterProcessExited (KProcess * pProcess) { assert (pProcess == m_pFilterShellProcess); if (!viewManager) return; KantView * kv (viewManager -> activeView ()); if (!kv) return; QString marked (kv -> markedText ()); if (strlen (marked.latin1 ()) > 0) kv -> keyDelete (); kv -> insertText (m_strFilterOutput); // slipInNewText (*kv, "", m_strFilterOutput, "", false); m_strFilterOutput = ""; } static void // PCP slipInFilter (KShellProcess & shell, KantView & view, QString command) { QString marked (view.markedText ()); // POP_(command.latin1 ()); shell.clearArguments (); shell << command.latin1 (); shell.start (KProcess::NotifyOnExit, KProcess::All); shell.writeStdin (marked.latin1 (), marked.length ()); // TODO: Put up a modal dialog to defend the text from further // keystrokes while the command is out. With a cancel button... } void KantMainWindow::slotFilterCloseStdin (KProcess * pProcess) { assert (pProcess == m_pFilterShellProcess); pProcess -> closeStdin (); } void KantMainWindow::slotEditFilter () // PCP { if (!viewManager) return; KantView * kv (viewManager -> activeView ()); if (!kv) return; QString text ( KantPrompt ( "Filter", "Enter command to pipe selected text thru", this ) ); if ( !text.isEmpty () ) { m_strFilterOutput = ""; if (!m_pFilterShellProcess) { m_pFilterShellProcess = new KShellProcess; connect ( m_pFilterShellProcess, SIGNAL(wroteStdin(KProcess *)), this, SLOT(slotFilterCloseStdin (KProcess *))); connect ( m_pFilterShellProcess, SIGNAL(receivedStdout(KProcess*,char*,int)), this, SLOT(slotFilterReceivedStdout(KProcess*,char*,int)) ); connect ( m_pFilterShellProcess, SIGNAL(receivedStderr(KProcess*,char*,int)), this, SLOT(slotFilterReceivedStderr(KProcess*,char*,int)) ); connect ( m_pFilterShellProcess, SIGNAL(processExited(KProcess*)), this, SLOT(slotFilterProcessExited(KProcess*) ) ) ; } slipInFilter (*m_pFilterShellProcess, *kv, text); } } void KantMainWindow::slotFileQuit() { // viewManager->slotDocumentCloseAll(); viewManager->saveAllDocsAtCloseDown( config ); close(); } void KantMainWindow::readProperties(KConfig *config) { /* readConfig(config); kWrite->readSessionConfig(config);*/ config->setGroup("General"); sidebarDock->resize( config->readSizeEntry("Sidebar:size", new QSize(150, height())) ); settingsShowSidebar->setChecked( config->readBoolEntry("Show Sidebar", true) ); resize( config->readSizeEntry( "size", new QSize(600, 400) ) ); viewManager->setShowFullPath(config->readBoolEntry("Show Full Path in Title", false)); settingsShowFullPath->setChecked(viewManager->getShowFullPath()); settingsShowToolbar->setChecked(config->readBoolEntry("Show Toolbar", true)); slotSettingsShowToolbar(); viewManager->setUseOpaqueResize(config->readBoolEntry("Opaque Resize", true)); fileOpenRecent->loadEntries(config, "Recent Files"); viewManager->fileselector->readConfig(config, "fileselector"); viewManager->fileselector->setView(KFile::Default); sidebar->readConfig( config ); readDockConfig(); } void KantMainWindow::saveProperties(KConfig *config) { /* writeConfig(config); config->writeEntry("DocumentNumber",docList.find(kWrite->doc()) + 1); kWrite->writeSessionConfig(config); */ config->setGroup("General"); config->writeEntry("Show Sidebar", sidebar->isVisible()); config->writeEntry("size", size()); config->writeEntry("Show Full Path in Title", viewManager->getShowFullPath()); config->writeEntry("Show Toolbar", settingsShowToolbar->isChecked()); config->writeEntry("Opaque Resize", viewManager->useOpaqueResize); fileOpenRecent->saveEntries(config, "Recent Files"); viewManager->fileselector->saveConfig(config, "fileselector"); sidebar->saveConfig( config ); writeDockConfig(); } void KantMainWindow::saveGlobalProperties(KConfig * /*config*/ ) { /*int z; char buf[16]; KWriteDoc *doc; config->setGroup("Number"); config->writeEntry("NumberOfDocuments",docList.count()); for (z = 1; z <= (int) docList.count(); z++) { sprintf(buf,"Document%d",z); config->setGroup(buf); doc = docList.at(z - 1); doc->writeSessionConfig(config); } */ } void KantMainWindow::slotWindowActivated () { if (viewManager->activeView() == 0) { fileSave->setEnabled(false); fileSaveAs->setEnabled(false); filePrint->setEnabled(false); fileClose->setEnabled(false); editUndo->setEnabled(false); editRedo->setEnabled(false); editUndoHist->setEnabled(false); editCut->setEnabled(false); editCopy->setEnabled(false); editPaste->setEnabled(false); editSelectAll->setEnabled(false); editDeselectAll->setEnabled(false); editInvertSelection->setEnabled(false); editFind->setEnabled(false); editFindNext->setEnabled(false); editReplace->setEnabled(false); editInsert->setEnabled(false); toolsSpell->setEnabled(false); setHighlightConf->setEnabled(false); setHighlight->setEnabled(false); gotoLine->setEnabled(false); } if (viewManager->activeView() != 0) { fileSave->setEnabled(viewManager->activeView()->doc()->isModified()); fileSaveAs->setEnabled(true); filePrint->setEnabled(true); fileClose->setEnabled(true); editCut->setEnabled(true); editCopy->setEnabled(true); editPaste->setEnabled(true); editSelectAll->setEnabled(true); editDeselectAll->setEnabled(true); editInvertSelection->setEnabled(true); editFind->setEnabled(true); editFindNext->setEnabled(true); editReplace->setEnabled(true); editInsert->setEnabled(true); toolsSpell->setEnabled(true); setHighlightConf->setEnabled(true); setHighlight->setEnabled(true); gotoLine->setEnabled(true); } if (viewManager->viewCount () == 0 ) { fileCloseAll->setEnabled(false); windowNext->setEnabled(false); windowPrev->setEnabled(false); viewSplitVert->setEnabled(false); viewSplitHoriz->setEnabled(false); docListMenu->setEnabled(false); } else { fileCloseAll->setEnabled(true); docListMenu->setEnabled(true); if (viewManager->viewCount () > 1) { windowNext->setEnabled(true); windowPrev->setEnabled(true); } else { windowNext->setEnabled(false); windowPrev->setEnabled(false); } viewSplitVert->setEnabled(true); viewSplitHoriz->setEnabled(true); } if (viewManager->viewSpaceCount() == 1) closeCurrentViewSpace->setEnabled(false); else closeCurrentViewSpace->setEnabled(true); } void KantMainWindow::slotCurrentDocChanged() { if (!viewManager->activeView()) return; fileSave->setEnabled( viewManager->activeView()->doc()->isModified() ); if (!(viewManager->activeView()->undoState() & 1)) { editUndo->setEnabled(false); } else { editUndo->setEnabled(true); } if (!(viewManager->activeView()->undoState() & 2)) { editRedo->setEnabled(false); } else { editRedo->setEnabled(true); } if (!(viewManager->activeView()->undoState() & 1) && !(viewManager->activeView()->undoState() & 2)) { editUndoHist->setEnabled(false); } else { editUndoHist->setEnabled(true); } } void KantMainWindow::docListMenuAboutToShow() { docListMenu->popupMenu()->clear(); if (docManager->docCount() == 0) return; int z=0; int i=1; int id = 0; docListMenu->popupMenu()->polish(); // adjust system settings QFont fMod = docListMenu->popupMenu()->font(); fMod.setBold( TRUE ); QFont fUnMod = docListMenu->popupMenu()->font(); QString Entry; while ( zdocCount() ) { if ( (!docManager->nthDoc(z)->url().isEmpty()) && (docManager->nthDoc(z)->url().filename() != 0) ) { Entry=QString("&%1 ").arg(i)+docManager->nthDoc(z)->url().filename(); } else { Entry=QString("&%1 ").arg(i)+i18n("Untitled %1").arg(docManager->nthDoc(z)->docID()); } id=docListMenu->popupMenu()->insertItem(new KantMenuItem(Entry, docManager->nthDoc(z)->isModified() ? fMod : fUnMod, docManager->nthDoc(z)->isModified() ? SmallIcon("modified") : SmallIcon("null")) ); docListMenu->popupMenu()->connectItem(id, viewManager, SLOT( activateView ( int ) ) ); docListMenu->popupMenu()->setItemParameter( id, docManager->nthDoc(z)->docID() ); if (viewManager->activeView()) docListMenu->popupMenu()->setItemChecked( id, ((KantDocument *)viewManager->activeView()->doc())->docID() == docManager->nthDoc(z)->docID() ); z++; i++; } } void KantMainWindow::bookmarkMenuAboutToShow() { bookmarkMenu->popupMenu()->clear(); viewManager->activeView()->doUpdateBookmarks(); QList l = viewManager->activeView()->bmActions(); QListIterator it(l); for (; it.current(); ++it) it.current()->plug( bookmarkMenu->popupMenu() ); } void KantMainWindow::slotPluginsAdd() { } void KantMainWindow::slotPluginsDelete() { } void KantMainWindow::projectMenuAboutToShow() { // projectCompile->setEnabled(true); PCP - the best thing to do here would be to test for an executable 'builder.sh' in the current directory... projectConfigure->setEnabled(false); projectRun->setEnabled(false); if (projectManager->projectFile.isEmpty()) projectSave->setEnabled(false); else projectSave->setEnabled(true); if (docManager->docCount () == 0) projectSaveAs->setEnabled(false); else projectSaveAs->setEnabled(true); } void KantMainWindow::dragEnterEvent( QDragEnterEvent *event ) { event->accept(QUriDrag::canDecode(event)); } void KantMainWindow::dropEvent( QDropEvent *event ) { slotDropEvent(event); } void KantMainWindow::slotDropEvent( QDropEvent * event ) { KURL::List textlist; if (!KURLDrag::decode(event, textlist)) return; for (KURL::List::Iterator i=textlist.begin(); i != textlist.end(); ++i) { viewManager->openURL (*i); } } void KantMainWindow::editKeys() { KKeyDialog::configureKeys(actionCollection(), xmlFile()); } void KantMainWindow::slotSettingsShowSidebar() { sidebarDock->changeHideShowState(); } void KantMainWindow::slotSettingsShowConsole() { consoleDock->changeHideShowState(); // Anders: focus at show if( consoleDock->isVisible() ) console->setFocus(); } void KantMainWindow::settingsMenuAboutToShow() { settingsShowSidebar->setChecked( sidebarDock->isVisible() ); settingsShowConsole->setChecked( consoleDock->isVisible() ); } void KantMainWindow::openURL (const QString &name) { viewManager->openURL (KURL(name)); } void KantMainWindow::ShowErrorMessage (const QString & strFileName, int nLine, const QString & strMessage) { // TODO put the error delivery stuff here instead of after the piper POP_(strFileName.latin1()); POP_(nLine); POP_(strMessage.latin1()); } void KantMainWindow::slotSettingsShowFullPath() { viewManager->setShowFullPath( settingsShowFullPath->isChecked() ); } void KantMainWindow::slotSettingsShowToolbar() { if (settingsShowToolbar->isChecked()) toolBar()->show(); else toolBar()->hide(); } void KantMainWindow::slotConfigure() { KDialogBase* dlg = new KDialogBase(KDialogBase::IconList, "Configure Kant", KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, this, "configdialog");//KantConfigDlg(this); QFrame* frGeneral = dlg->addPage(i18n("General"), i18n("General Options"), BarIcon("misc", KIcon::SizeMedium)); QGridLayout* gridFrG = new QGridLayout(frGeneral); gridFrG->setSpacing( 6 ); // opaque resize of view splitters QCheckBox* cb_opaqueResize = new QCheckBox( frGeneral ); cb_opaqueResize->setText(i18n("Show &Content when resizing views")); gridFrG->addMultiCellWidget( cb_opaqueResize, 0, 0, 0, 1 ); cb_opaqueResize->setChecked(viewManager->useOpaqueResize); // reopen files QCheckBox* cb_reopenFiles = new QCheckBox( frGeneral ); cb_reopenFiles->setText(i18n("Reopen &Files at startup")); gridFrG->addMultiCellWidget( cb_reopenFiles, 1, 1, 0, 1 ); config->setGroup("open files"); cb_reopenFiles->setChecked( config->readBoolEntry("reopen at startup", true) ); // editor widgets from kwrite/kwdialog // color options QStringList path; path << i18n("Editor") << i18n("Colors"); QVBox *page = dlg->addVBoxPage(path, i18n("Colors"), BarIcon("colorize", KIcon::SizeMedium) ); ColorConfig *colorConfig = new ColorConfig(page); // some kwrite tabs needs a kwrite as an arg! KantView* v = viewManager->activeView(); KSpellConfig * ksc = 0L; IndentConfigTab * indentConfig = 0L; SelectConfigTab * selectConfig = 0L; EditConfigTab * editConfig = 0L; QColor* colors = 0L; // the test can go if we are sure we allways have 1 view if (v) { // indent options page=dlg->addVBoxPage(i18n("Indent"), i18n("Indent Options"), BarIcon("rightjust", KIcon::SizeMedium) ); indentConfig = new IndentConfigTab(page, v); // select options page=dlg->addVBoxPage(i18n("Select"), QString::null, BarIcon("misc") ); selectConfig = new SelectConfigTab(page, v); // edit options page=dlg->addVBoxPage(i18n("Edit"), QString::null, BarIcon("edit", KIcon::SizeMedium ) ); editConfig = new EditConfigTab(page, v); // spell checker page = dlg->addVBoxPage( i18n("Spelling"), i18n("Spell checker behavior"), BarIcon("spellcheck", KIcon::SizeMedium) ); ksc = new KSpellConfig(page, 0L, v->ksConfig(), false ); colors = v->getColors(); colorConfig->setColors( colors ); page=dlg->addVBoxPage(i18n("Plugins"),i18n("Configure plugins"), BarIcon("misc",KIcon::SizeMedium)); (void)new KantConfigPluginPage(page); } if (dlg->exec()) { viewManager->setUseOpaqueResize(cb_opaqueResize->isChecked()); config->setGroup("open files"); config->writeEntry("reopen at startup", cb_reopenFiles->isChecked()); if (viewManager->viewCount()) { ksc->writeGlobalSettings(); colorConfig->getColors( colors ); config->setGroup("kwrite"); v->writeConfig( config ); v->doc()->writeConfig( config ); v->applyColors(); config->sync(); // all docs need to reread config. QListIterator dit (docManager->docList); for (; dit.current(); ++dit) { dit.current()->readConfig( config ); } QListIterator it (viewManager->viewList); for (; it.current(); ++it) { v = it.current(); indentConfig->getData( v ); selectConfig->getData( v ); editConfig->getData( v ); } // repeat some calls: kwrite has a bad design. config->setGroup("kwrite"); v->writeConfig( config ); v->doc()->writeConfig( config ); config->sync(); } } delete dlg; dlg = 0; } //Set focus to next input element void KantMainWindow::slotGoNext() { QFocusEvent::setReason(QFocusEvent::Tab); /*res= */focusNextPrevChild(true); //TRUE == NEXT , FALSE = PREV QFocusEvent::resetReason(); } //Set focus to previous input element void KantMainWindow::slotGoPrev() { QFocusEvent::setReason(QFocusEvent::Tab); /*res= */focusNextPrevChild(false); //TRUE == NEXT , FALSE = PREV QFocusEvent::resetReason(); } void KantMainWindow::slotSettingsShowFullScreen() { if (settingsShowFullScreen->isChecked()) { showFullScreen(); } else { showNormal(); } } void KantMainWindow::reopenDocuments(bool isRestore) { // read the list and loop around it. config->setGroup("open files"); if (config->readBoolEntry("reopen at startup", true) || isRestore ) { QStringList list = config->readListEntry("list"); for ( int i = list.count() - 1; i > -1; i-- ) { config->setGroup("open files"); QStringList data = config->readListEntry( list[i] ); // open file viewManager->openURL( KURL(data[0]) ); // restore cursor position int dot, line, col; dot = data[1].find("."); line = data[1].left(dot).toInt(); col = data[1].mid(dot + 1, 100).toInt(); if (viewManager->activeView()->numLines() >= line) // HACK-- viewManager->activeView()->setCursorPosition(line, col); } config->writeEntry("list", ""); config->sync(); } } void KantMainWindow::slotSidebarFocusNext() { if (! sidebarDock->isVisible()) { slotSettingsShowSidebar(); return; } sidebar->focusNextWidget(); } void KantMainWindow::focusInEvent(QFocusEvent* /* e */) { kdDebug()<<"focusIn"<checkAllModOnHD(); }