Add a configuration page for the text editor used for source references links (that is, the ones used also for inverse search).
Factor out the editor commands structure. svn path=/trunk/KDE/kdegraphics/okular/; revision=873570remotes/origin/old/work/tiff-improvements
parent
9deffda3d0
commit
4da5b7a105
8 changed files with 242 additions and 4 deletions
@ -0,0 +1,68 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> * |
||||
* * |
||||
* 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 "dlgeditor.h" |
||||
|
||||
#include "core/texteditors_p.h" |
||||
|
||||
#include <klocale.h> |
||||
|
||||
#include "ui_dlgeditorbase.h" |
||||
|
||||
DlgEditor::DlgEditor( QWidget * parent ) |
||||
: QWidget( parent ) |
||||
{ |
||||
m_dlg = new Ui_DlgEditorBase(); |
||||
m_dlg->setupUi( this ); |
||||
|
||||
m_editors = Okular::buildEditorsMap(); |
||||
|
||||
connect( m_dlg->kcfg_ExternalEditor, SIGNAL( currentIndexChanged( int ) ), this, SLOT( editorChanged( int ) ) ); |
||||
|
||||
m_dlg->kcfg_ExternalEditor->addItem( i18nc( "Text editor", "Custom Text Editor" ) ); |
||||
m_dlg->kcfg_ExternalEditor->addItem( i18nc( "Text editor", "Kate" ), 1 ); |
||||
m_dlg->kcfg_ExternalEditor->addItem( i18nc( "Text editor", "SciTE" ), 2 ); |
||||
|
||||
m_dlg->kcfg_ExternalEditorCommand->setWhatsThis( i18nc( "@info:whatsthis", |
||||
"<qt>Set the command of a custom text editor to be launched.<br />\n" |
||||
"You can also put few placeholders:\n" |
||||
"<ul>\n" |
||||
" <li>%f - the file name</li>\n" |
||||
" <li>%l - the line of the file to be reached</li>\n" |
||||
" <li>%c - the column of the file to be reached</li>\n" |
||||
"</ul>\n" |
||||
"If %f is not specified, then the file name is appended to the specified " |
||||
"command." ) ); |
||||
} |
||||
|
||||
DlgEditor::~DlgEditor() |
||||
{ |
||||
delete m_dlg; |
||||
} |
||||
|
||||
void DlgEditor::editorChanged( int which ) |
||||
{ |
||||
const int whichEditor = m_dlg->kcfg_ExternalEditor->itemData( which ).toInt(); |
||||
const QHash< int, QString >::const_iterator it = m_editors.constFind( whichEditor ); |
||||
QString editor; |
||||
if ( it != m_editors.constEnd() ) |
||||
editor = it.value(); |
||||
|
||||
if ( !editor.isEmpty() ) |
||||
{ |
||||
m_dlg->stackCommands->setCurrentIndex( 1 ); |
||||
m_dlg->leReadOnlyCommand->setText( editor ); |
||||
} |
||||
else |
||||
{ |
||||
m_dlg->stackCommands->setCurrentIndex( 0 ); |
||||
} |
||||
} |
||||
|
||||
#include "dlgeditor.moc" |
||||
@ -0,0 +1,34 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> * |
||||
* * |
||||
* 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. * |
||||
***************************************************************************/ |
||||
|
||||
#ifndef DLGEDITOR_H |
||||
#define DLGEDITOR_H |
||||
|
||||
#include <qhash.h> |
||||
#include <qwidget.h> |
||||
|
||||
class Ui_DlgEditorBase; |
||||
|
||||
class DlgEditor : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
DlgEditor( QWidget * parent = 0 ); |
||||
virtual ~DlgEditor(); |
||||
|
||||
private slots: |
||||
void editorChanged( int which ); |
||||
|
||||
private: |
||||
Ui_DlgEditorBase * m_dlg; |
||||
QHash< int, QString > m_editors; |
||||
}; |
||||
|
||||
#endif |
||||
@ -0,0 +1,98 @@ |
||||
<ui version="4.0" > |
||||
<class>DlgEditorBase</class> |
||||
<widget class="QWidget" name="DlgEditorBase" > |
||||
<property name="geometry" > |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>375</width> |
||||
<height>108</height> |
||||
</rect> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout_3" > |
||||
<property name="margin" > |
||||
<number>0</number> |
||||
</property> |
||||
<item> |
||||
<widget class="QGroupBox" name="groupBox_2" > |
||||
<property name="title" > |
||||
<string>Editor</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout" > |
||||
<item row="0" column="0" > |
||||
<widget class="QLabel" name="label" > |
||||
<property name="text" > |
||||
<string>Editor:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1" > |
||||
<widget class="QComboBox" name="kcfg_ExternalEditor" > |
||||
<property name="whatsThis" > |
||||
<string comment="@info:whatsthis" >Choose the editor you want to launch when Okular wants to open a source file.</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item rowspan="2" row="1" column="1" > |
||||
<widget class="QStackedWidget" name="stackCommands" > |
||||
<property name="currentIndex" > |
||||
<number>1</number> |
||||
</property> |
||||
<widget class="QWidget" name="page" > |
||||
<layout class="QVBoxLayout" name="verticalLayout_2" > |
||||
<property name="margin" > |
||||
<number>0</number> |
||||
</property> |
||||
<item> |
||||
<widget class="QLineEdit" name="kcfg_ExternalEditorCommand" /> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<widget class="QWidget" name="page_2" > |
||||
<layout class="QVBoxLayout" name="verticalLayout" > |
||||
<property name="margin" > |
||||
<number>0</number> |
||||
</property> |
||||
<item> |
||||
<widget class="QLineEdit" name="leReadOnlyCommand" > |
||||
<property name="readOnly" > |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0" > |
||||
<widget class="QLabel" name="label_2" > |
||||
<property name="text" > |
||||
<string>Command:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer> |
||||
<property name="orientation" > |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
<property name="sizeType" > |
||||
<enum>QSizePolicy::Expanding</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0" > |
||||
<size> |
||||
<width>20</width> |
||||
<height>4</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<layoutdefault spacing="6" margin="11" /> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
||||
@ -0,0 +1,33 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> * |
||||
* * |
||||
* 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. * |
||||
***************************************************************************/ |
||||
|
||||
#ifndef OKULAR_TEXTEDITORS_P_H |
||||
#define OKULAR_TEXTEDITORS_P_H |
||||
|
||||
#include "settings.h" |
||||
|
||||
#include <qhash.h> |
||||
#include <qstring.h> |
||||
|
||||
namespace Okular |
||||
{ |
||||
|
||||
static inline QHash< int, QString > buildEditorsMap() |
||||
{ |
||||
QHash< int, QString > editors; |
||||
editors.insert( Settings::EnumExternalEditor::Kate, |
||||
QString::fromLatin1( "kate --use --line %l --column %c" ) ); |
||||
editors.insert( Settings::EnumExternalEditor::Scite, |
||||
QString::fromLatin1( "scite %f \"-goto:%l,%c\"" ) ); |
||||
return editors; |
||||
} |
||||
|
||||
} |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue