1 /***************************************************************************
2 * Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #include "dlgeditor.h"
12 #include "core/texteditors_p.h"
16 #include "ui_dlgeditorbase.h"
18 DlgEditor::DlgEditor( QWidget
* parent
)
21 m_dlg
= new Ui_DlgEditorBase();
22 m_dlg
->setupUi( this );
24 m_editors
= Okular::buildEditorsMap();
26 connect( m_dlg
->kcfg_ExternalEditor
, SIGNAL( currentIndexChanged( int ) ), this, SLOT( editorChanged( int ) ) );
28 m_dlg
->kcfg_ExternalEditor
->addItem( i18nc( "Text editor", "Custom Text Editor" ) );
29 m_dlg
->kcfg_ExternalEditor
->addItem( i18nc( "Text editor", "Kate" ), 1 );
30 m_dlg
->kcfg_ExternalEditor
->addItem( i18nc( "Text editor", "Kile" ), 2 );
31 m_dlg
->kcfg_ExternalEditor
->addItem( i18nc( "Text editor", "SciTE" ), 3 );
32 m_dlg
->kcfg_ExternalEditor
->addItem( i18nc( "Text editor", "Emacs client" ), 4 );
34 m_dlg
->kcfg_ExternalEditorCommand
->setWhatsThis( i18nc( "@info:whatsthis",
35 "<qt>Set the command of a custom text editor to be launched.<br />\n"
36 "You can also put few placeholders:\n"
38 " <li>%f - the file name</li>\n"
39 " <li>%l - the line of the file to be reached</li>\n"
40 " <li>%c - the column of the file to be reached</li>\n"
42 "If %f is not specified, then the file name is appended to the specified "
46 DlgEditor::~DlgEditor()
51 void DlgEditor::editorChanged( int which
)
53 const int whichEditor
= m_dlg
->kcfg_ExternalEditor
->itemData( which
).toInt();
54 const QHash
< int, QString
>::const_iterator it
= m_editors
.constFind( whichEditor
);
56 if ( it
!= m_editors
.constEnd() )
59 if ( !editor
.isEmpty() )
61 m_dlg
->stackCommands
->setCurrentIndex( 1 );
62 m_dlg
->leReadOnlyCommand
->setText( editor
);
66 m_dlg
->stackCommands
->setCurrentIndex( 0 );
70 #include "dlgeditor.moc"