• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • app
kwritemain.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
3 Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
4 Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "kwritemain.h"
22#include "kwritemain.moc"
23
24#include <kate/document.h>
25#include <kate/view.h>
26
27#include <tdetexteditor/configinterface.h>
28#include <tdetexteditor/sessionconfiginterface.h>
29#include <tdetexteditor/viewcursorinterface.h>
30#include <tdetexteditor/printinterface.h>
31#include <tdetexteditor/encodinginterface.h>
32#include <tdetexteditor/editorchooser.h>
33#include <tdetexteditor/popupmenuinterface.h>
34
35#include <tdeio/netaccess.h>
36
37#include <dcopclient.h>
38#include <kurldrag.h>
39#include <kencodingfiledialog.h>
40#include <tdediroperator.h>
41#include <kiconloader.h>
42#include <tdeaboutdata.h>
43#include <kstatusbar.h>
44#include <kstdaction.h>
45#include <tdeaction.h>
46#include <kdebug.h>
47#include <tdeglobal.h>
48#include <tdeapplication.h>
49#include <tdelocale.h>
50#include <kurl.h>
51#include <tdeconfig.h>
52#include <tdecmdlineargs.h>
53#include <tdemessagebox.h>
54#include <kkeydialog.h>
55#include <kedittoolbar.h>
56#include <tdeparts/event.h>
57#include <tdemenubar.h>
58
59#include <tqdropsite.h>
60#include <tqdragobject.h>
61#include <tqvbox.h>
62#include <tqtextcodec.h>
63#include <tqlayout.h>
64
65// StatusBar field IDs
66#define KWRITE_ID_GEN 1
67
68TQPtrList<KTextEditor::Document> KWrite::docList;
69TQPtrList<KWrite> KWrite::winList;
70
71KWrite::KWrite (KTextEditor::Document *doc)
72 : m_view(0),
73 m_recentFiles(0),
74 m_paShowPath(0),
75 m_paShowStatusBar(0)
76{
77 if ( !doc )
78 {
79 if ( !(doc = KTextEditor::EditorChooser::createDocument(0,"KTextEditor::Document")) )
80 {
81 KMessageBox::error(this, i18n("A TDE text-editor component could not be found;\n"
82 "please check your TDE installation."));
83 kapp->exit(1);
84 }
85
86 docList.append(doc);
87 }
88
89 m_view = doc->createView (this, 0L);
90
91 setCentralWidget(m_view);
92
93 setupActions();
94 setupStatusBar();
95
96 setAcceptDrops(true);
97
98 connect(m_view,TQ_SIGNAL(newStatus()),this,TQ_SLOT(newCaption()));
99 connect(m_view,TQ_SIGNAL(viewStatusMsg(const TQString &)),this,TQ_SLOT(newStatus(const TQString &)));
100 connect(m_view->document(),TQ_SIGNAL(fileNameChanged()),this,TQ_SLOT(newCaption()));
101 connect(m_view->document(),TQ_SIGNAL(fileNameChanged()),this,TQ_SLOT(slotFileNameChanged()));
102 connect(m_view,TQ_SIGNAL(dropEventPass(TQDropEvent *)),this,TQ_SLOT(slotDropEvent(TQDropEvent *)));
103
104 setXMLFile( "kwriteui.rc" );
105 createShellGUI( true );
106 guiFactory()->addClient( m_view );
107
108 // install a working kate part popup dialog thingy
109 if (static_cast<Kate::View*>(m_view->tqt_cast("Kate::View")))
110 static_cast<Kate::View*>(m_view->tqt_cast("Kate::View"))->installPopup ((TQPopupMenu*)(factory()->container("tdetexteditor_popup", this)) );
111
112 // init with more usefull size, stolen from konq :)
113 if (!initialGeometrySet())
114 resize( TQSize(700, 480).expandedTo(minimumSizeHint()));
115
116 // call it as last thing, must be sure everything is already set up ;)
117 setAutoSaveSettings ();
118
119 readConfig ();
120
121 winList.append (this);
122
123 show ();
124}
125
126KWrite::~KWrite()
127{
128 winList.remove (this);
129
130 if (m_view->document()->views().count() == 1)
131 {
132 docList.remove(m_view->document());
133 delete m_view->document();
134 }
135
136 kapp->config()->sync ();
137}
138
139void KWrite::setupActions()
140{
141 KStdAction::close( this, TQ_SLOT(slotFlush()), actionCollection(), "file_close" )->setWhatsThis(i18n("Use this to close the current document"));
142
143 // setup File menu
144 KStdAction::print(this, TQ_SLOT(printDlg()), actionCollection())->setWhatsThis(i18n("Use this command to print the current document"));
145 KStdAction::openNew( this, TQ_SLOT(slotNew()), actionCollection(), "file_new" )->setWhatsThis(i18n("Use this command to create a new document"));
146 KStdAction::open( this, TQ_SLOT( slotOpen() ), actionCollection(), "file_open" )->setWhatsThis(i18n("Use this command to open an existing document for editing"));
147
148 m_recentFiles = KStdAction::openRecent(this, TQ_SLOT(slotOpen(const KURL&)),
149 actionCollection());
150 m_recentFiles->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again."));
151
152 TDEAction *a=new TDEAction(i18n("&New Window"), "window-new", 0, this, TQ_SLOT(newView()),
153 actionCollection(), "view_new_view");
154 a->setWhatsThis(i18n("Create another view containing the current document"));
155
156 a=new TDEAction(i18n("Choose Editor Component..."),0,this,TQ_SLOT(changeEditor()),
157 actionCollection(),"settings_choose_editor");
158 a->setWhatsThis(i18n("Override the system wide setting for the default editing component"));
159
160 KStdAction::quit(this, TQ_SLOT(close()), actionCollection())->setWhatsThis(i18n("Close the current document view"));
161
162 // setup Settings menu
163 setStandardToolBarMenuEnabled(true);
164
165 m_paShowStatusBar = KStdAction::showStatusbar(this, TQ_SLOT(toggleStatusBar()), actionCollection(), "settings_show_statusbar");
166 m_paShowStatusBar->setWhatsThis(i18n("Use this command to show or hide the view's statusbar"));
167
168 m_paShowPath = new TDEToggleAction(i18n("Sho&w Path"), 0, this, TQ_SLOT(newCaption()),
169 actionCollection(), "set_showPath");
170 m_paShowPath->setCheckedState(i18n("Hide Path"));
171 m_paShowPath->setWhatsThis(i18n("Show the complete document path in the window caption"));
172 a=KStdAction::keyBindings(this, TQ_SLOT(editKeys()), actionCollection());
173 a->setWhatsThis(i18n("Configure the application's keyboard shortcut assignments."));
174
175 a=KStdAction::configureToolbars(this, TQ_SLOT(editToolbars()), actionCollection());
176 a->setWhatsThis(i18n("Configure which items should appear in the toolbar(s)."));
177}
178
179void KWrite::setupStatusBar()
180{
181 statusBar()->insertItem("", KWRITE_ID_GEN);
182}
183
184// load on url
185void KWrite::loadURL(const KURL &url)
186{
187 m_view->document()->openURL(url);
188}
189
190// is closing the window wanted by user ?
191bool KWrite::queryClose()
192{
193 if (m_view->document()->views().count() > 1)
194 return true;
195
196 if (m_view->document()->queryClose())
197 {
198 writeConfig();
199
200 return true;
201 }
202
203 return false;
204}
205
206void KWrite::changeEditor()
207{
208 KWriteEditorChooser choose(this);
209 choose.exec();
210}
211
212void KWrite::slotFlush ()
213{
214 m_view->document()->closeURL();
215}
216
217void KWrite::slotNew()
218{
219 new KWrite();
220}
221
222void KWrite::slotOpen()
223{
224 if (KTextEditor::encodingInterface(m_view->document()))
225 {
226 KEncodingFileDialog::Result r=KEncodingFileDialog::getOpenURLsAndEncoding(
227 KTextEditor::encodingInterface(m_view->document())->encoding(),
228 m_view->document()->url().url(),TQString::null,this,i18n("Open File"));
229
230 for (KURL::List::Iterator i=r.URLs.begin(); i != r.URLs.end(); ++i)
231 {
232 encoding = r.encoding;
233 slotOpen ( *i );
234 }
235 }
236 else
237 {
238 KURL::List l=KFileDialog::getOpenURLs(m_view->document()->url().url(),TQString::null,this,TQString::null);
239 for (KURL::List::Iterator i=l.begin(); i != l.end(); ++i)
240 {
241 slotOpen ( *i );
242 }
243 }
244}
245
246void KWrite::slotOpen( const KURL& url )
247{
248 if (url.isEmpty()) return;
249
250 if (!TDEIO::NetAccess::exists(url, true, this))
251 {
252 KMessageBox::error (this, i18n("The given file could not be read, check if it exists or if it is readable for the current user."));
253 return;
254 }
255
256 if (m_view->document()->isModified() || !m_view->document()->url().isEmpty())
257 {
258 KWrite *t = new KWrite();
259 if (KTextEditor::encodingInterface(t->m_view->document())) KTextEditor::encodingInterface(t->m_view->document())->setEncoding(encoding);
260 t->loadURL(url);
261 }
262 else
263 {
264 if (KTextEditor::encodingInterface(m_view->document())) KTextEditor::encodingInterface(m_view->document())->setEncoding(encoding);
265 loadURL(url);
266 }
267}
268
269void KWrite::slotFileNameChanged()
270{
271 if ( ! m_view->document()->url().isEmpty() )
272 m_recentFiles->addURL( m_view->document()->url() );
273}
274
275void KWrite::newView()
276{
277 new KWrite(m_view->document());
278}
279
280void KWrite::toggleStatusBar()
281{
282 if( m_paShowStatusBar->isChecked() )
283 statusBar()->show();
284 else
285 statusBar()->hide();
286}
287
288void KWrite::editKeys()
289{
290 KKeyDialog dlg;
291 dlg.insert(actionCollection());
292 if( m_view )
293 dlg.insert(m_view->actionCollection());
294 dlg.configure();
295}
296
297void KWrite::editToolbars()
298{
299 saveMainWindowSettings( kapp->config(), "MainWindow" );
300 KEditToolbar *dlg = new KEditToolbar(guiFactory());
301 connect( dlg, TQ_SIGNAL(newToolbarConfig()), this, TQ_SLOT(slotNewToolbarConfig()) );
302 dlg->exec();
303 delete dlg;
304}
305
306void KWrite::slotNewToolbarConfig()
307{
308 applyMainWindowSettings( kapp->config(), "MainWindow" );
309}
310
311
312void KWrite::printNow()
313{
314 KTextEditor::printInterface(m_view->document())->print ();
315}
316
317void KWrite::printDlg()
318{
319 KTextEditor::printInterface(m_view->document())->printDialog ();
320}
321
322void KWrite::newStatus(const TQString &msg)
323{
324 newCaption();
325
326 statusBar()->changeItem(msg,KWRITE_ID_GEN);
327}
328
329void KWrite::newCaption()
330{
331 if (m_view->document()->url().isEmpty()) {
332 setCaption(i18n("Untitled"),m_view->document()->isModified());
333 }
334 else
335 {
336 TQString c;
337 if (!m_paShowPath->isChecked())
338 {
339 c = m_view->document()->url().fileName();
340
341 //File name shouldn't be too long - Maciek
342 if (c.length() > 64)
343 c = c.left(64) + "...";
344 }
345 else
346 {
347 c = m_view->document()->url().prettyURL();
348
349 //File name shouldn't be too long - Maciek
350 if (c.length() > 64)
351 c = "..." + c.right(64);
352 }
353
354 setCaption (c, m_view->document()->isModified());
355 }
356}
357
358void KWrite::dragEnterEvent( TQDragEnterEvent *event )
359{
360 event->accept(KURLDrag::canDecode(event));
361}
362
363void KWrite::dropEvent( TQDropEvent *event )
364{
365 slotDropEvent(event);
366}
367
368void KWrite::slotDropEvent( TQDropEvent *event )
369{
370 KURL::List textlist;
371
372 if (!KURLDrag::decode(event, textlist))
373 return;
374
375 for (KURL::List::Iterator i=textlist.begin(); i != textlist.end(); ++i)
376 slotOpen (*i);
377}
378
379void KWrite::slotEnableActions( bool enable )
380{
381 TQValueList<TDEAction *> actions = actionCollection()->actions();
382 TQValueList<TDEAction *>::ConstIterator it = actions.begin();
383 TQValueList<TDEAction *>::ConstIterator end = actions.end();
384
385 for (; it != end; ++it )
386 (*it)->setEnabled( enable );
387
388 actions = m_view->actionCollection()->actions();
389 it = actions.begin();
390 end = actions.end();
391
392 for (; it != end; ++it )
393 (*it)->setEnabled( enable );
394}
395
396//common config
397void KWrite::readConfig(TDEConfig *config)
398{
399 config->setGroup("General Options");
400
401 m_paShowStatusBar->setChecked( config->readBoolEntry("ShowStatusBar") );
402 m_paShowPath->setChecked( config->readBoolEntry("ShowPath") );
403
404 m_recentFiles->loadEntries(config, "Recent Files");
405
406 if (m_view && KTextEditor::configInterface(m_view->document()))
407 KTextEditor::configInterface(m_view->document())->readConfig(config);
408
409 if( m_paShowStatusBar->isChecked() )
410 statusBar()->show();
411 else
412 statusBar()->hide();
413}
414
415void KWrite::writeConfig(TDEConfig *config)
416{
417 config->setGroup("General Options");
418
419 config->writeEntry("ShowStatusBar",m_paShowStatusBar->isChecked());
420 config->writeEntry("ShowPath",m_paShowPath->isChecked());
421
422 m_recentFiles->saveEntries(config, "Recent Files");
423
424 if (m_view && KTextEditor::configInterface(m_view->document()))
425 KTextEditor::configInterface(m_view->document())->writeConfig(config);
426
427 config->sync ();
428}
429
430//config file
431void KWrite::readConfig()
432{
433 TDEConfig *config = kapp->config();
434 readConfig(config);
435}
436
437void KWrite::writeConfig()
438{
439 TDEConfig *config = kapp->config();
440 writeConfig(config);
441}
442
443// session management
444void KWrite::restore(TDEConfig *config, int n)
445{
446 readPropertiesInternal(config, n);
447}
448
449void KWrite::readProperties(TDEConfig *config)
450{
451 readConfig(config);
452
453 if (KTextEditor::sessionConfigInterface(m_view))
454 KTextEditor::sessionConfigInterface(m_view)->readSessionConfig(config);
455}
456
457void KWrite::saveProperties(TDEConfig *config)
458{
459 writeConfig(config);
460 config->writeEntry("DocumentNumber",docList.find(m_view->document()) + 1);
461
462 if (KTextEditor::sessionConfigInterface(m_view))
463 KTextEditor::sessionConfigInterface(m_view)->writeSessionConfig(config);
464}
465
466void KWrite::saveGlobalProperties(TDEConfig *config) //save documents
467{
468 config->setGroup("Number");
469 config->writeEntry("NumberOfDocuments",docList.count());
470
471 for (uint z = 1; z <= docList.count(); z++)
472 {
473 TQString buf = TQString("Document %1").arg(z);
474 config->setGroup(buf);
475
476 KTextEditor::Document *doc = docList.at(z - 1);
477
478 if (KTextEditor::configInterface(doc))
479 KTextEditor::configInterface(doc)->writeSessionConfig(config);
480 }
481
482 for (uint z = 1; z <= winList.count(); z++)
483 {
484 TQString buf = TQString("Window %1").arg(z);
485 config->setGroup(buf);
486
487 config->writeEntry("DocumentNumber",docList.find(winList.at(z-1)->view()->document()) + 1);
488 }
489}
490
491//restore session
492void KWrite::restore()
493{
494 TDEConfig *config = kapp->sessionConfig();
495
496 if (!config)
497 return;
498
499 int docs, windows;
500 TQString buf;
501 KTextEditor::Document *doc;
502 KWrite *t;
503
504 config->setGroup("Number");
505 docs = config->readNumEntry("NumberOfDocuments");
506 windows = config->readNumEntry("NumberOfWindows");
507
508 for (int z = 1; z <= docs; z++)
509 {
510 buf = TQString("Document %1").arg(z);
511 config->setGroup(buf);
512 doc=KTextEditor::EditorChooser::createDocument(0,"KTextEditor::Document");
513
514 if (KTextEditor::configInterface(doc))
515 KTextEditor::configInterface(doc)->readSessionConfig(config);
516 docList.append(doc);
517 }
518
519 for (int z = 1; z <= windows; z++)
520 {
521 buf = TQString("Window %1").arg(z);
522 config->setGroup(buf);
523 t = new KWrite(docList.at(config->readNumEntry("DocumentNumber") - 1));
524 t->restore(config,z);
525 }
526}
527
528static TDECmdLineOptions options[] =
529{
530 { "stdin", I18N_NOOP("Read the contents of stdin"), 0},
531 { "encoding <argument>", I18N_NOOP("Set encoding for the file to open"), 0 },
532 { "line <argument>", I18N_NOOP("Navigate to this line"), 0 },
533 { "column <argument>", I18N_NOOP("Navigate to this column"), 0 },
534 { "+[URL]", I18N_NOOP("Document to open"), 0 },
535 TDECmdLineLastOption
536};
537
538extern "C" TDE_EXPORT int kdemain(int argc, char **argv)
539{
540 Kate::Document::setFileChangedDialogsActivated (true);
541
542 TDELocale::setMainCatalogue("kate"); //lukas: set this to have the kwritepart translated using kate message catalog
543
544 // here we go, construct the KWrite version
545 // TQString kWriteVersion = TQString ("%1.%2.%3").arg(KDE::versionMajor() + 1).arg(KDE::versionMinor()).arg(KDE::versionRelease());
549 TQString kWriteVersion = TQString ("4.5.%1").arg(KDE::versionMajor());
550
551 TDEAboutData aboutData ( "kwrite",
552 I18N_NOOP("KWrite"),
553 kWriteVersion.latin1(),
554 I18N_NOOP( "KWrite - Text Editor" ), TDEAboutData::License_LGPL_V2,
555 I18N_NOOP( "(c) 2000-2005 The Kate Authors" ), 0 );
556
557 aboutData.addAuthor ("Christoph Cullmann", I18N_NOOP("Maintainer"), "cullmann@kde.org", "http://www.babylon2k.de");
558 aboutData.addAuthor ("Anders Lund", I18N_NOOP("Core Developer"), "anders@alweb.dk", "http://www.alweb.dk");
559 aboutData.addAuthor ("Joseph Wenninger", I18N_NOOP("Core Developer"), "jowenn@kde.org","http://stud3.tuwien.ac.at/~e9925371");
560 aboutData.addAuthor ("Hamish Rodda",I18N_NOOP("Core Developer"), "rodda@kde.org");
561 aboutData.addAuthor ("Waldo Bastian", I18N_NOOP( "The cool buffersystem" ), "bastian@kde.org" );
562 aboutData.addAuthor ("Charles Samuels", I18N_NOOP("The Editing Commands"), "charles@kde.org");
563 aboutData.addAuthor ("Matt Newell", I18N_NOOP("Testing, ..."), "newellm@proaxis.com");
564 aboutData.addAuthor ("Michael Bartl", I18N_NOOP("Former Core Developer"), "michael.bartl1@chello.at");
565 aboutData.addAuthor ("Michael McCallum", I18N_NOOP("Core Developer"), "gholam@xtra.co.nz");
566 aboutData.addAuthor ("Jochen Wilhemly", I18N_NOOP( "KWrite Author" ), "digisnap@cs.tu-berlin.de" );
567 aboutData.addAuthor ("Michael Koch",I18N_NOOP("KWrite port to KParts"), "koch@kde.org");
568 aboutData.addAuthor ("Christian Gebauer", 0, "gebauer@kde.org" );
569 aboutData.addAuthor ("Simon Hausmann", 0, "hausmann@kde.org" );
570 aboutData.addAuthor ("Glen Parker",I18N_NOOP("KWrite Undo History, Kspell integration"), "glenebob@nwlink.com");
571 aboutData.addAuthor ("Scott Manson",I18N_NOOP("KWrite XML Syntax highlighting support"), "sdmanson@alltel.net");
572 aboutData.addAuthor ("John Firebaugh",I18N_NOOP("Patches and more"), "jfirebaugh@kde.org");
573
574 aboutData.addCredit ("Matteo Merli",I18N_NOOP("Highlighting for RPM Spec-Files, Perl, Diff and more"), "merlim@libero.it");
575 aboutData.addCredit ("Rocky Scaletta",I18N_NOOP("Highlighting for VHDL"), "rocky@purdue.edu");
576 aboutData.addCredit ("Yury Lebedev",I18N_NOOP("Highlighting for SQL"),"");
577 aboutData.addCredit ("Chris Ross",I18N_NOOP("Highlighting for Ferite"),"");
578 aboutData.addCredit ("Nick Roux",I18N_NOOP("Highlighting for ILERPG"),"");
579 aboutData.addCredit ("Carsten Niehaus", I18N_NOOP("Highlighting for LaTeX"),"");
580 aboutData.addCredit ("Per Wigren", I18N_NOOP("Highlighting for Makefiles, Python"),"");
581 aboutData.addCredit ("Jan Fritz", I18N_NOOP("Highlighting for Python"),"");
582 aboutData.addCredit ("Daniel Naber","","");
583 aboutData.addCredit ("Roland Pabel",I18N_NOOP("Highlighting for Scheme"),"");
584 aboutData.addCredit ("Cristi Dumitrescu",I18N_NOOP("PHP Keyword/Datatype list"),"");
585 aboutData.addCredit ("Carsten Pfeiffer", I18N_NOOP("Very nice help"), "");
586 aboutData.addCredit (I18N_NOOP("All people who have contributed and I have forgotten to mention"),"","");
587
588 aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"), I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));
589
590 TDECmdLineArgs::init( argc, argv, &aboutData );
591 TDECmdLineArgs::addCmdLineOptions( options );
592
593 TDEApplication a;
594
595 TDEGlobal::locale()->insertCatalogue("katepart");
596
597 DCOPClient *client = kapp->dcopClient();
598 if (!client->isRegistered())
599 {
600 client->attach();
601 client->registerAs("kwrite");
602 }
603
604 TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
605
606 if (kapp->isRestored())
607 {
608 KWrite::restore();
609 }
610 else
611 {
612 bool nav = false;
613 int line = 0, column = 0;
614
615 TQTextCodec *codec = args->isSet("encoding") ? TQTextCodec::codecForName(args->getOption("encoding")) : 0;
616
617 if (args->isSet ("line"))
618 {
619 line = args->getOption ("line").toInt();
620 nav = true;
621 }
622
623 if (args->isSet ("column"))
624 {
625 column = args->getOption ("column").toInt();
626 nav = true;
627 }
628
629 if ( args->count() == 0 )
630 {
631 KWrite *t = new KWrite;
632
633 if( args->isSet( "stdin" ) )
634 {
635 TQTextIStream input(stdin);
636
637 // set chosen codec
638 if (codec)
639 input.setCodec (codec);
640
641 TQString line;
642 TQString text;
643
644 do
645 {
646 line = input.readLine();
647 text.append( line + "\n" );
648 } while( !line.isNull() );
649
650
651 KTextEditor::EditInterface *doc = KTextEditor::editInterface (t->view()->document());
652 if( doc )
653 doc->setText( text );
654 }
655
656 if (nav && KTextEditor::viewCursorInterface(t->view()))
657 KTextEditor::viewCursorInterface(t->view())->setCursorPosition (line, column);
658 }
659 else
660 {
661 for ( int z = 0; z < args->count(); z++ )
662 {
663 KWrite *t = new KWrite();
664
665 // this file is no local dir, open it, else warn
666 bool noDir = !args->url(z).isLocalFile() || !TQDir (args->url(z).path()).exists();
667
668 if (noDir)
669 {
670 if (Kate::document (t->view()->document()))
671 Kate::Document::setOpenErrorDialogsActivated (false);
672
673 if (codec && KTextEditor::encodingInterface(t->view()->document()))
674 KTextEditor::encodingInterface(t->view()->document())->setEncoding(codec->name());
675
676 t->loadURL( args->url( z ) );
677
678 if (Kate::document (t->view()->document()))
679 Kate::Document::setOpenErrorDialogsActivated (true);
680
681 if (nav && KTextEditor::viewCursorInterface(t->view()))
682 KTextEditor::viewCursorInterface(t->view())->setCursorPosition (line, column);
683 }
684 else
685 KMessageBox::sorry( t, i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.").arg(args->url(z).url()) );
686 }
687 }
688 }
689
690 // no window there, uh, ohh, for example borked session config !!!
691 // create at least one !!
692 if (KWrite::noWindows())
693 new KWrite();
694
695 return a.exec ();
696}
697
698KWriteEditorChooser::KWriteEditorChooser(TQWidget *):
699 KDialogBase(KDialogBase::Plain,i18n("Choose Editor Component"),KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Cancel)
700{
701 (new TQVBoxLayout(plainPage()))->setAutoAdd(true);
702 m_chooser=new KTextEditor::EditorChooser(plainPage(),"Editor Chooser");
703 setMainWidget(m_chooser);
704 m_chooser->readAppSetting();
705}
706
707KWriteEditorChooser::~KWriteEditorChooser() {
708;
709}
710
711void KWriteEditorChooser::slotOk() {
712 m_chooser->writeAppSetting();
713 KDialogBase::slotOk();
714}

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kate

Skip menu "kate"
  • kate
  • libkonq
  • twin
  •   lib
Generated for kate by doxygen 1.9.8
This website is maintained by Timothy Pearson.