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=873570
remotes/origin/old/work/tiff-improvements
Pino Toscano 18 years ago
parent 9deffda3d0
commit 4da5b7a105
  1. 2
      CMakeLists.txt
  2. 68
      conf/dlgeditor.cpp
  3. 34
      conf/dlgeditor.h
  4. 98
      conf/dlgeditorbase.ui
  5. 3
      conf/preferencesdialog.cpp
  6. 2
      conf/preferencesdialog.h
  7. 6
      core/document.cpp
  8. 33
      core/texteditors_p.h

@ -117,6 +117,7 @@ set(okularpart_SRCS
conf/preferencesdialog.cpp
conf/dlgaccessibility.cpp
conf/dlgdebug.cpp
conf/dlgeditor.cpp
conf/dlggeneral.cpp
conf/dlgidentity.cpp
conf/dlgperformance.cpp
@ -159,6 +160,7 @@ set(okularpart_SRCS
kde4_add_ui_files(okularpart_SRCS
conf/dlgaccessibilitybase.ui
conf/dlgeditorbase.ui
conf/dlggeneralbase.ui
conf/dlgidentitybase.ui
conf/dlgperformancebase.ui

@ -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>

@ -18,6 +18,7 @@
#include "dlgaccessibility.h"
#include "dlgpresentation.h"
#include "dlgidentity.h"
#include "dlgeditor.h"
#include "dlgdebug.h"
PreferencesDialog::PreferencesDialog( QWidget * parent, KConfigSkeleton * skeleton )
@ -28,6 +29,7 @@ PreferencesDialog::PreferencesDialog( QWidget * parent, KConfigSkeleton * skelet
m_accessibility = new DlgAccessibility( this );
m_presentation = new DlgPresentation( this );
m_identity = new DlgIdentity( this );
m_editor = new DlgEditor( this );
#ifdef OKULAR_DEBUG_CONFIGPAGE
m_debug = new DlgDebug( this );
#endif
@ -39,6 +41,7 @@ PreferencesDialog::PreferencesDialog( QWidget * parent, KConfigSkeleton * skelet
i18n("Options for Presentation Mode") );
addPage( m_identity, i18n("Identity"), "preferences-desktop-personal",
i18n("Identity Settings") );
addPage( m_editor, i18n("Editor"), "accessories-text-editor", i18n("Editor Options") );
#ifdef OKULAR_DEBUG_CONFIGPAGE
addPage( m_debug, "Debug", "system-run", "Debug options" );
#endif

@ -21,6 +21,7 @@ class DlgPerformance;
class DlgAccessibility;
class DlgPresentation;
class DlgIdentity;
class DlgEditor;
class DlgDebug;
class PreferencesDialog : public KConfigDialog
@ -42,6 +43,7 @@ class PreferencesDialog : public KConfigDialog
DlgAccessibility * m_accessibility;
DlgPresentation * m_presentation;
DlgIdentity * m_identity;
DlgEditor * m_editor;
DlgDebug * m_debug;
};

@ -66,6 +66,7 @@
#include "settings.h"
#include "sourcereference.h"
#include "sourcereference_p.h"
#include "texteditors_p.h"
#include "view.h"
#include "view_p.h"
@ -2813,10 +2814,7 @@ void Document::processSourceReference( const SourceReference * ref )
// init the editors table if empty (on first run, usually)
if ( editors.isEmpty() )
{
editors[ Settings::EnumExternalEditor::Kate ] =
QLatin1String( "kate --use --line %l --column %c" );
editors[ Settings::EnumExternalEditor::Scite ] =
QLatin1String( "scite %f \"-goto:%l,%c\"" );
editors = buildEditorsMap();
}
QHash< int, QString >::const_iterator it = editors.constFind( Settings::externalEditor() );

@ -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…
Cancel
Save