mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 10:55:37 +00:00
make the option dialog more modular, for future interaction with kviewshell
svn path=/trunk/kdegraphics/kdvi/; revision=203637
This commit is contained in:
parent
aea47c1472
commit
bc3b74b17a
|
@ -13,10 +13,12 @@ noinst_PROGRAMS = squeeze
|
|||
METASOURCES = AUTO
|
||||
|
||||
kdvipart_la_SOURCES = kdvi_multipage.cpp \
|
||||
dviwin.cpp bigEndianByteReader.cpp optiondialog.cpp infodialog.cpp \
|
||||
dviwin.cpp bigEndianByteReader.cpp infodialog.cpp \
|
||||
psheader.c dviwin_draw.cpp dviwin_export.cpp dviwin_textsearch.cpp \
|
||||
dvi_init.cpp font.cpp fontpool.cpp fontprogress.cpp pk.cpp psgs.cpp \
|
||||
special.cpp util.cpp vf.cpp glyph.cpp selection.cpp history.cpp
|
||||
special.cpp util.cpp vf.cpp glyph.cpp selection.cpp history.cpp \
|
||||
optiondialog.cpp optionDialogFontsWidget.cpp optionDialogFontsWidget_base.ui \
|
||||
optionDialogSpecialWidget.cpp optionDialogSpecialWidget_base.ui
|
||||
|
||||
kdvipart_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
|
||||
kdvipart_la_LIBADD = -lkdeprint -lkparts \
|
||||
|
|
6
TODO
6
TODO
|
@ -3,8 +3,9 @@ ToDo-List for kdvi
|
|||
URGENT / URGENT BUGFIXING
|
||||
|
||||
o Proper handling of the base-url
|
||||
o give source-information in the status line
|
||||
o "File not found" is not centered
|
||||
o don't show REFERENCES, URLS in the title bar
|
||||
o don't show temporary file names in the titlebar
|
||||
o add "tt.dvi.gz" to the list of recent files, not "/tmp/kviews....."
|
||||
|
||||
HIGHLY DESIRABLE
|
||||
|
||||
|
@ -24,6 +25,5 @@ o Internal printing using QPrinter
|
|||
o Magnifier window
|
||||
o Two page view
|
||||
o Support for even more TeX specials
|
||||
o dynamical storage allocation for hyperlinks (see dviwin.h)
|
||||
o more robust Error handling with throw/catch; no need to abort just because a PK-file is bad.
|
||||
|
||||
|
|
58
optionDialogFontsWidget.cpp
Normal file
58
optionDialogFontsWidget.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
// optionDiologWidget.cpp
|
||||
//
|
||||
// Part of KDVI - A DVI previewer for the KDE desktop environemt
|
||||
//
|
||||
// (C) 2003 Stefan Kebekus
|
||||
// Distributed under the GPL
|
||||
|
||||
// Add header files alphabetically
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include <kconfig.h>
|
||||
#include <kcombobox.h>
|
||||
#include <kinstance.h>
|
||||
#include <klocale.h>
|
||||
#include <qcheckbox.h>
|
||||
|
||||
#include "fontpool.h"
|
||||
#include "optionDialogFontsWidget.h"
|
||||
|
||||
|
||||
// Constructs a optionDialogWidget_base which is a child of 'parent', with
|
||||
// the name 'name' and widget flags set to 'f'.
|
||||
optionDialogFontsWidget::optionDialogFontsWidget( QWidget* parent, const char* name, WFlags fl )
|
||||
: optionDialogFontsWidget_base( parent, name, fl )
|
||||
{
|
||||
instance = 0;
|
||||
config = 0;
|
||||
instance = new KInstance("kdvi");
|
||||
config = instance->config();
|
||||
|
||||
// Important! The default values here must be the same as in kdvi_multipage.cpp
|
||||
for(int i=0; i<NumberOfMFModes; i++)
|
||||
metafontMode->insertItem(QString("%1 dpi / %2").arg(MFResolutions[i]).arg(MFModenames[i]));
|
||||
|
||||
config->setGroup("kdvi");
|
||||
metafontMode->setCurrentItem( config->readNumEntry( "MetafontMode" , DefaultMFMode ));
|
||||
fontGenerationCheckBox->setChecked( config->readBoolEntry( "MakePK", true ) );
|
||||
}
|
||||
|
||||
optionDialogFontsWidget::~optionDialogFontsWidget()
|
||||
{
|
||||
if (config != 0L)
|
||||
delete config;
|
||||
if (instance != 0L)
|
||||
delete instance;
|
||||
}
|
||||
|
||||
void optionDialogFontsWidget::apply(void)
|
||||
{
|
||||
config->setGroup("kdvi");
|
||||
config->writeEntry( "MetafontMode", metafontMode->currentItem() );
|
||||
config->writeEntry( "MakePK", fontGenerationCheckBox->isChecked() );
|
||||
config->sync();
|
||||
}
|
||||
|
||||
|
||||
#include "optionDialogFontsWidget.moc"
|
34
optionDialogFontsWidget.h
Normal file
34
optionDialogFontsWidget.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
// optionDiologWidget.h
|
||||
//
|
||||
// Part of KDVI - A DVI previewer for the KDE desktop environemt
|
||||
//
|
||||
// (C) 2003 Stefan Kebekus
|
||||
// Distributed under the GPL
|
||||
|
||||
#ifndef OPTIONDIALOGFONTSWIDGET_H
|
||||
#define OPTIONDIALOGFONTSWIDGET_H
|
||||
|
||||
// Add header files alphabetically
|
||||
|
||||
#include "optionDialogFontsWidget_base.h"
|
||||
|
||||
class KConfig;
|
||||
class KInstance;
|
||||
|
||||
class optionDialogFontsWidget : public optionDialogFontsWidget_base
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
optionDialogFontsWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
|
||||
~optionDialogFontsWidget();
|
||||
|
||||
public slots:
|
||||
void apply(void);
|
||||
|
||||
private:
|
||||
KInstance *instance;
|
||||
KConfig *config;
|
||||
};
|
||||
|
||||
#endif // OPTIONDIALOGFONTSWIDGET_H
|
98
optionDialogFontsWidget_base.ui
Normal file
98
optionDialogFontsWidget_base.ui
Normal file
|
@ -0,0 +1,98 @@
|
|||
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
|
||||
<class>optionDialogFontsWidget_base</class>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>optionDialogFontsWidget_base</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>237</width>
|
||||
<height>203</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>TeX Fonts</string>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QButtonGroup">
|
||||
<property name="name">
|
||||
<cstring>buttonGroup1</cstring>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>NoFrame</enum>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string></string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel1</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Metafont mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KComboBox" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>metafontMode</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>LaserJet 4 is usually a good choice.</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string><p>Chooses the type of bitmap fonts used for the display. As a general rule, the higher the dpi value, the better quality of the output. On the other hand, large dpi fonts use more resources and make KDVI slower.</p>
|
||||
<p>If you are low on hard disk space, or have a slow machine, you may want to choose the same setting that is also used by dvips. That way you avoid to generate several bitmap versions of the same font.</p></string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QCheckBox">
|
||||
<property name="name">
|
||||
<cstring>fontGenerationCheckBox</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>generate missing fonts</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>If in doubt, switch on!</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string>Allows KDVI to use MetaFont to produce bitmap fonts. Unless you have a very specific reason, you probably want to switch this on.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</vbox>
|
||||
</widget>
|
||||
<slots>
|
||||
<slot>buttonGroup1_clicked(int)</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
<includehint>kcombobox.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|
148
optionDialogSpecialWidget.cpp
Normal file
148
optionDialogSpecialWidget.cpp
Normal file
|
@ -0,0 +1,148 @@
|
|||
// optionDialogSpecialWidget.cpp
|
||||
//
|
||||
// Part of KDVI - A DVI previewer for the KDE desktop environemt
|
||||
//
|
||||
// (C) 2003 Stefan Kebekus
|
||||
// Distributed under the GPL
|
||||
|
||||
// Add header files alphabetically
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include <kapplication.h>
|
||||
#include <kconfig.h>
|
||||
#include <kcombobox.h>
|
||||
#include <kinstance.h>
|
||||
#include <klineedit.h>
|
||||
#include <klocale.h>
|
||||
#include <kurllabel.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qlabel.h>
|
||||
|
||||
#include "optionDialogSpecialWidget.h"
|
||||
|
||||
|
||||
// Constructs a optionDialogWidget_base which is a child of 'parent', with
|
||||
// the name 'name' and widget flags set to 'f'.
|
||||
optionDialogSpecialWidget::optionDialogSpecialWidget( QWidget* parent, const char* name, WFlags fl )
|
||||
: optionDialogSpecialWidget_base( parent, name, fl )
|
||||
{
|
||||
instance = 0;
|
||||
config = 0;
|
||||
instance = new KInstance("kdvi");
|
||||
config = instance->config();
|
||||
config->setGroup("kdvi");
|
||||
|
||||
// Set up the list of known and supported editors
|
||||
editorNameString += i18n("User-Defined Editor");
|
||||
editorCommandString += "";
|
||||
editorDescriptionString += i18n("Enter the command line below.");
|
||||
|
||||
editorNameString += "Emacs / emacsclient";
|
||||
editorCommandString += "emacsclient --no-wait +%l %f || emacs +%l %f";
|
||||
editorDescriptionString += i18n("Click 'Help' to learn how to set up Emacs.");
|
||||
|
||||
editorNameString += "Kate";
|
||||
editorCommandString += "kate %f";
|
||||
editorDescriptionString += i18n("Kate does not jump to line");
|
||||
|
||||
editorNameString += "NEdit";
|
||||
editorCommandString += "ncl -noask -line %l %f || nc -noask -line %l %f";
|
||||
editorDescriptionString += i18n("NEdit perfectly supports inverse search.");
|
||||
|
||||
editorNameString += "VIM - Vi IMproved / GUI";
|
||||
editorCommandString += "gvim --servername kdvi --remote +%l %f";
|
||||
editorDescriptionString += i18n("VIM version 6.0 or greater works just fine.");
|
||||
|
||||
editorNameString += "XEmacs / gnuclient";
|
||||
editorCommandString += "gnuclient -q +%l %f || xemacs +%l %f";
|
||||
editorDescriptionString += i18n("Click 'Help' to learn how to set up XEmacs.");
|
||||
|
||||
|
||||
showSpecialCheck->setChecked(config->readBoolEntry("ShowPS", true));
|
||||
showHyperLinksCheck->setChecked(config->readBoolEntry("ShowHyperLinks", true));
|
||||
for(unsigned int i=0; i<editorNameString.count(); i++)
|
||||
editorChoice->insertItem(editorNameString[i]);
|
||||
// Set the proper editor on the "Rendering-Page", try to recognize
|
||||
// the editor command from the config-file. If the editor command is
|
||||
// not recognized, switch to "User defined editor". That way, kdvi
|
||||
// stays compatible even if the EditorCommands[] change between
|
||||
// different versions of kdvi.
|
||||
QString currentEditorCommand = config->readEntry( "EditorCommand", "" );
|
||||
int i;
|
||||
for(i = editorCommandString.count()-1; i>0; i--)
|
||||
if (editorCommandString[i] == currentEditorCommand)
|
||||
break;
|
||||
if (i == 0)
|
||||
usersEditorCommand = currentEditorCommand;
|
||||
slotComboBox(i);
|
||||
|
||||
connect(urll, SIGNAL(leftClickedURL(const QString&)), this, SLOT(slotExtraHelpButton(const QString&)));
|
||||
connect(editorChoice, SIGNAL( activated( int ) ), this, SLOT( slotComboBox( int ) ) );
|
||||
|
||||
// Editor description strings (and their translations) vary in
|
||||
// size. Find the longest description string available to make sure
|
||||
// that the page is always large enough.
|
||||
int maximumWidth = 0;
|
||||
for ( QStringList::Iterator it = editorDescriptionString.begin(); it != editorDescriptionString.end(); ++it ) {
|
||||
int width = editorDescription->fontMetrics().width(*it);
|
||||
if (width > maximumWidth)
|
||||
maximumWidth = width;
|
||||
}
|
||||
editorDescription->setMinimumWidth(maximumWidth+10);
|
||||
|
||||
editorCallingCommand->setReadOnly(true);
|
||||
connect(editorCallingCommand, SIGNAL( textChanged (const QString &) ), this, SLOT( slotUserDefdEditorCommand( const QString & ) ) );
|
||||
}
|
||||
|
||||
optionDialogSpecialWidget::~optionDialogSpecialWidget()
|
||||
{
|
||||
if (config != 0L)
|
||||
delete config;
|
||||
if (instance != 0L)
|
||||
delete instance;
|
||||
}
|
||||
|
||||
void optionDialogSpecialWidget::slotUserDefdEditorCommand( const QString &text )
|
||||
{
|
||||
if (isUserDefdEditor == true)
|
||||
EditorCommand = usersEditorCommand = text;
|
||||
}
|
||||
|
||||
|
||||
void optionDialogSpecialWidget::slotComboBox(int item)
|
||||
{
|
||||
if (item != editorChoice->currentItem())
|
||||
editorChoice->setCurrentItem(item);
|
||||
|
||||
editorDescription->setText(editorDescriptionString[item]);
|
||||
|
||||
if (item != 0) {
|
||||
isUserDefdEditor = false;
|
||||
editorCallingCommand->setText(editorCommandString[item]);
|
||||
editorCallingCommand->setReadOnly(true);
|
||||
EditorCommand = editorCommandString[item];
|
||||
} else {
|
||||
editorCallingCommand->setText(usersEditorCommand);
|
||||
editorCallingCommand->setReadOnly(false);
|
||||
EditorCommand = usersEditorCommand;
|
||||
isUserDefdEditor = true;
|
||||
}
|
||||
}
|
||||
|
||||
void optionDialogSpecialWidget::slotExtraHelpButton( const QString & )
|
||||
{
|
||||
kapp->invokeHelp( "inv-search", "kdvi" );
|
||||
}
|
||||
|
||||
void optionDialogSpecialWidget::apply(void)
|
||||
{
|
||||
config->setGroup("kdvi");
|
||||
config->writeEntry( "ShowPS", showSpecialCheck->isChecked() );
|
||||
config->writeEntry( "ShowHyperLinks", showHyperLinksCheck->isChecked() );
|
||||
config->writeEntry( "EditorCommand", EditorCommand );
|
||||
config->sync();
|
||||
}
|
||||
|
||||
|
||||
#include "optionDialogSpecialWidget.moc"
|
41
optionDialogSpecialWidget.h
Normal file
41
optionDialogSpecialWidget.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
// optionDialogSpecialWidget.h
|
||||
//
|
||||
// Part of KDVI - A DVI previewer for the KDE desktop environemt
|
||||
//
|
||||
// (C) 2003 Stefan Kebekus
|
||||
// Distributed under the GPL
|
||||
|
||||
#ifndef OPTIONDIALOGSPECIALWIDGET_H
|
||||
#define OPTIONDIALOGSPECIALWIDGET_H
|
||||
|
||||
// Add header files alphabetically
|
||||
|
||||
#include "optionDialogSpecialWidget_base.h"
|
||||
|
||||
class KConfig;
|
||||
class KInstance;
|
||||
|
||||
class optionDialogSpecialWidget : public optionDialogSpecialWidget_base
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
optionDialogSpecialWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
|
||||
~optionDialogSpecialWidget();
|
||||
|
||||
public slots:
|
||||
void apply(void);
|
||||
void slotComboBox(int item);
|
||||
void slotUserDefdEditorCommand( const QString &text );
|
||||
void slotExtraHelpButton( const QString &anchor);
|
||||
|
||||
private:
|
||||
KInstance *instance;
|
||||
KConfig *config;
|
||||
QStringList editorNameString, editorCommandString, editorDescriptionString;
|
||||
QString EditorCommand;
|
||||
bool isUserDefdEditor;
|
||||
QString usersEditorCommand;
|
||||
};
|
||||
|
||||
#endif // OPTIONDIALOGSPECIALWIDGET_H
|
167
optionDialogSpecialWidget_base.ui
Normal file
167
optionDialogSpecialWidget_base.ui
Normal file
|
@ -0,0 +1,167 @@
|
|||
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
|
||||
<class>optionDialogSpecialWidget_base</class>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>optionDialogSpecialWidget_base</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>293</width>
|
||||
<height>203</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Form1</string>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QCheckBox">
|
||||
<property name="name">
|
||||
<cstring>showSpecialCheck</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show PostScript specials</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>If in doubt, switch on</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string>Some DVI files contain PostScript graphics. If switched on, KDVI will use the ghostview PostScript interpreter to display these. You probably want to switch this option on, unless you have a DVI-file whose PostScript part is broken, or too large for your machine.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox">
|
||||
<property name="name">
|
||||
<cstring>showHyperLinksCheck</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Hyperlinks</string>
|
||||
</property>
|
||||
<property name="autoRepeat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>If in doubt, switch on!</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string>For your convenience, some DVI files contain hyperlinks which are cross-references or point to external documents. You probably want to switch this option on, unless you don't want the blue underlines which KDVI uses to mark the hyperlinks.</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QButtonGroup">
|
||||
<property name="name">
|
||||
<cstring>buttonGroup3</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Editor for inverse search</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="KURLLabel" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>urll</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>What is 'inverse search'? </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>AlignVCenter|AlignRight</set>
|
||||
</property>
|
||||
<property name="url" stdset="0">
|
||||
<string>inv-search</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>spacer1</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QLabel" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Editor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KComboBox" row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>editorChoice</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Choose an editor which is used in inverse search.</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string><p>Some DVI-files contain 'inverse search' information. If such a DVI-file is loaded, you can click with the right mouse into KDVI, an editor opens, loads the TeX-file and jumps to the proper position. You can select you favourite editor here. If in doubt, 'nedit' is usually a good choice.</p>
|
||||
<p>Check the KDVI manual to see how to prepare DVI-files which support the inverse search.</p></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel3</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="3" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel4</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Shell Command:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="2" column="1">
|
||||
<property name="name">
|
||||
<cstring>editorDescription</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Explains about the editor's capabilities in conjunction with inverse search.</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string><p>Not all editors are well-suited for inverse search. For instance, many editors have no command like 'If the file is not yet loaded, load it. Otherwise, bring the window with the file to the front'. If you are using an editor like this, clicking into the DVI file will always open a new editor, even if the TeX-file is already open. Likewise, many editors have no command line argument that would allow KDVI to specify the exact line which you wish to edit.</p>
|
||||
<p>If you feel that KDVI's support for a certain editor is not well-done, please write to kebekus@kde.org.</p></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KLineEdit" row="3" column="1">
|
||||
<property name="name">
|
||||
<cstring>editorCallingCommand</cstring>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Shell-command line used to start the editor.</string>
|
||||
</property>
|
||||
<property name="whatsThis" stdset="0">
|
||||
<string>If you are using inverse search, KDVI uses this command line to start the editor. The field '%f' is replaced with the filename, and '%l' is replaced with the line number.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
<includehint>kurllabel.h</includehint>
|
||||
<includehint>kcombobox.h</includehint>
|
||||
<includehint>klineedit.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|
246
optiondialog.cpp
246
optiondialog.cpp
|
@ -1,250 +1,52 @@
|
|||
/*
|
||||
* kdvi: KDE dvi viewer
|
||||
* This file: Copyright (C) 2000 Espen Sand, espen@kde.org
|
||||
* Based on ealier dialog code
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
// optiondialog.cpp
|
||||
//
|
||||
// Part of KDVI - A DVI previewer for the KDE desktop environemt
|
||||
//
|
||||
// (C) 2003 Stefan Kebekus
|
||||
// Distributed under the GPL
|
||||
|
||||
// Add header files alphabetically
|
||||
|
||||
#include <config.h>
|
||||
#include <kapplication.h>
|
||||
#include <kcombobox.h>
|
||||
#include <kconfig.h>
|
||||
#include <kdebug.h>
|
||||
#include <kglobal.h>
|
||||
#include <kinstance.h>
|
||||
#include <klineedit.h>
|
||||
#include <klocale.h>
|
||||
#include <kurllabel.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qfontmetrics.h>
|
||||
#include <qgrid.h>
|
||||
#include <qgroupbox.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qtooltip.h>
|
||||
#include <qvbox.h>
|
||||
#include <qwhatsthis.h>
|
||||
|
||||
#include "fontpool.h"
|
||||
#include "optiondialog.h"
|
||||
|
||||
#include "optionDialogFontsWidget.h"
|
||||
#include "optionDialogSpecialWidget.h"
|
||||
|
||||
|
||||
OptionDialog::OptionDialog( QWidget *parent, const char *name, bool modal )
|
||||
:KDialogBase( Tabbed, i18n("Preferences"), Help|Ok|Apply|Cancel, Ok,
|
||||
parent, name, modal )
|
||||
{
|
||||
_instance = new KInstance("kdvi");
|
||||
setHelp("opts", "kdvi");
|
||||
|
||||
// Set up the list of known and supported editors
|
||||
EditorNames += i18n("User-Defined Editor");
|
||||
EditorCommands += "";
|
||||
EditorDescriptions += i18n("Enter the command line below.");
|
||||
QWidget *page;
|
||||
page = new optionDialogFontsWidget(addVBoxPage(i18n("TeX Fonts")));
|
||||
connect(this, SIGNAL(apply()), page, SLOT(apply()));
|
||||
connect(this, SIGNAL(okClicked()), page, SLOT(apply()));
|
||||
|
||||
EditorNames += "Emacs / emacsclient";
|
||||
EditorCommands += "emacsclient --no-wait +%l %f || emacs +%l %f";
|
||||
EditorDescriptions += i18n("Click 'Help' to learn how to set up Emacs.");
|
||||
|
||||
EditorNames += "Kate";
|
||||
EditorCommands += "kate %f";
|
||||
EditorDescriptions += i18n("Kate does not jump to line");
|
||||
|
||||
EditorNames += "NEdit";
|
||||
EditorCommands += "ncl -noask -line %l %f || nc -noask -line %l %f";
|
||||
EditorDescriptions += i18n("NEdit perfectly supports inverse search.");
|
||||
|
||||
EditorNames += "VIM - Vi IMproved / GUI";
|
||||
EditorCommands += "gvim --servername kdvi --remote +%l %f";
|
||||
EditorDescriptions += i18n("VIM version 6.0 or greater works just fine.");
|
||||
|
||||
EditorNames += "XEmacs / gnuclient";
|
||||
EditorCommands += "gnuclient -q +%l %f || xemacs +%l %f";
|
||||
EditorDescriptions += i18n("Click 'Help' to learn how to set up XEmacs.");
|
||||
|
||||
|
||||
makeFontPage();
|
||||
makeRenderingPage();
|
||||
|
||||
KConfig *config = _instance->config();
|
||||
config->setGroup("kdvi");
|
||||
|
||||
// Font page
|
||||
// Important! The default values here must be the same as in kdvi_multipage.cpp
|
||||
for(int i=0; i<NumberOfMFModes; i++)
|
||||
mFont.metafontMode->insertItem(QString("%1 dpi / %2").arg(MFResolutions[i]).arg(MFModenames[i]));
|
||||
mFont.metafontMode->setCurrentItem( config->readNumEntry( "MetafontMode" , DefaultMFMode ));
|
||||
mFont.fontPathCheck->setChecked( config->readBoolEntry( "MakePK", true ) );
|
||||
|
||||
// Rendering page
|
||||
mRender.showSpecialCheck->setChecked(config->readBoolEntry("ShowPS", true));
|
||||
mRender.showHyperLinksCheck->setChecked(config->readBoolEntry("ShowHyperLinks", true));
|
||||
for(unsigned int i=0; i<EditorNames.count(); i++)
|
||||
mRender.editorChoice->insertItem(EditorNames[i]);
|
||||
// Set the proper editor on the "Rendering-Page", try to recognize
|
||||
// the editor command from the config-file. If the editor command is
|
||||
// not recognized, switch to "User defined editor". That way, kdvi
|
||||
// stays compatible even if the EditorCommands[] change between
|
||||
// different versions of kdvi.
|
||||
QString currentEditorCommand = config->readEntry( "EditorCommand", "" );
|
||||
int i;
|
||||
for(i = EditorCommands.count()-1; i>0; i--)
|
||||
if (EditorCommands[i] == currentEditorCommand)
|
||||
break;
|
||||
if (i == 0)
|
||||
usersEditorCommand = currentEditorCommand;
|
||||
slotComboBox(i);
|
||||
page = new optionDialogSpecialWidget(addVBoxPage(i18n("DVI Specials")));
|
||||
connect(this, SIGNAL(apply()), page, SLOT(apply()));
|
||||
connect(this, SIGNAL(okClicked()), page, SLOT(apply()));
|
||||
}
|
||||
|
||||
|
||||
void OptionDialog::show()
|
||||
void OptionDialog::slotOk(void)
|
||||
{
|
||||
KConfig *config = _instance->config();
|
||||
config->reparseConfiguration();
|
||||
config->setGroup("kdvi");
|
||||
|
||||
mFont.metafontMode->setCurrentItem( config->readNumEntry( "MetafontMode" , DefaultMFMode ));
|
||||
mFont.fontPathCheck->setChecked( config->readBoolEntry( "MakePK", true ) );
|
||||
|
||||
// Rendering page
|
||||
mRender.showSpecialCheck->setChecked( config->readBoolEntry( "ShowPS", true));
|
||||
mRender.showHyperLinksCheck->setChecked(config->readBoolEntry("ShowHyperLinks", true));
|
||||
|
||||
if( isVisible() == false )
|
||||
showPage(0);
|
||||
KDialogBase::show();
|
||||
}
|
||||
|
||||
void OptionDialog::slotOk()
|
||||
{
|
||||
slotApply();
|
||||
// Beware! I could not connect preferencesChanged to the signal
|
||||
// okClicked because slots are called in arbitrary order.
|
||||
emit okClicked();
|
||||
emit preferencesChanged();
|
||||
accept();
|
||||
}
|
||||
|
||||
void OptionDialog::slotApply()
|
||||
void OptionDialog::slotApply(void)
|
||||
{
|
||||
KConfig *config = _instance->config();
|
||||
config->setGroup("kdvi");
|
||||
|
||||
config->writeEntry( "MetafontMode", mFont.metafontMode->currentItem() );
|
||||
config->writeEntry( "MakePK", mFont.fontPathCheck->isChecked() );
|
||||
config->writeEntry( "ShowPS", mRender.showSpecialCheck->isChecked() );
|
||||
config->writeEntry( "ShowHyperLinks", mRender.showHyperLinksCheck->isChecked() );
|
||||
config->writeEntry( "EditorCommand", EditorCommand );
|
||||
|
||||
config->sync();
|
||||
|
||||
// Beware! I could not connect preferencesChanged to the signal
|
||||
// apply because slots are called in arbitrary order.
|
||||
emit okClicked();
|
||||
emit preferencesChanged();
|
||||
}
|
||||
|
||||
void OptionDialog::slotUserDefdEditorCommand( const QString &text )
|
||||
{
|
||||
if (isUserDefdEditor == true)
|
||||
EditorCommand = usersEditorCommand = text;
|
||||
}
|
||||
|
||||
void OptionDialog::slotComboBox(int item)
|
||||
{
|
||||
if (item != mRender.editorChoice->currentItem())
|
||||
mRender.editorChoice->setCurrentItem(item);
|
||||
|
||||
mRender.editorDescription->setText(EditorDescriptions[item]);
|
||||
|
||||
if (item != 0) {
|
||||
isUserDefdEditor = false;
|
||||
mRender.editorCallingCommand->setText(EditorCommands[item]);
|
||||
mRender.editorCallingCommand->setReadOnly(true);
|
||||
EditorCommand = EditorCommands[item];
|
||||
} else {
|
||||
mRender.editorCallingCommand->setText(usersEditorCommand);
|
||||
mRender.editorCallingCommand->setReadOnly(false);
|
||||
EditorCommand = usersEditorCommand;
|
||||
isUserDefdEditor = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OptionDialog::slotExtraHelpButton( const QString &anchor)
|
||||
{
|
||||
kapp->invokeHelp( anchor, "kdvi" );
|
||||
}
|
||||
|
||||
void OptionDialog::makeFontPage()
|
||||
{
|
||||
QGrid *page = addGridPage( 2, QGrid::Horizontal, i18n("Fonts") );
|
||||
|
||||
new QLabel( i18n("Metafont mode:"), page );
|
||||
mFont.metafontMode = new KComboBox( page );
|
||||
QToolTip::add( mFont.metafontMode, i18n("LaserJet 4 is usually a good choice.") );
|
||||
QWhatsThis::add( mFont.metafontMode, i18n("Chooses the type of bitmap fonts used for the display. As a general rule, the higher the dpi value, the better quality of the output. On the other hand, large dpi fonts use more resources and make KDVI slower. \nIf you are low on hard disk space, or have a slow machine, you may want to choose the same setting that is also used by dvips. That way you avoid to generate several bitmap versions of the same font.") );
|
||||
|
||||
mFont.fontPathCheck = new QCheckBox( i18n("Generate missing fonts"), page );
|
||||
QToolTip::add( mFont.fontPathCheck, i18n("If in doubt, switch on!") );
|
||||
QWhatsThis::add( mFont.fontPathCheck, i18n("Allows KDVI to use MetaFont to produce bitmap fonts. Unless you have a very specific reason, you probably want to switch this on.") );
|
||||
}
|
||||
|
||||
void OptionDialog::makeRenderingPage()
|
||||
{
|
||||
QVBox *page = addVBoxPage( i18n("DVI Specials") );
|
||||
|
||||
mRender.showSpecialCheck = new QCheckBox( i18n("Show PostScript specials"), page );
|
||||
QToolTip::add( mRender.showSpecialCheck, i18n("If in doubt, switch on!") );
|
||||
QWhatsThis::add( mRender.showSpecialCheck, i18n("Some DVI files contain PostScript graphics. If switched on, KDVI will use the ghostview PostScript interpreter to display these. You probably want to switch this option on, unless you have a DVI-file whose PostScript part is broken, or too large for your machine.") );
|
||||
|
||||
mRender.showHyperLinksCheck = new QCheckBox( i18n("Show hyperlinks"), page );
|
||||
QToolTip::add( mRender.showHyperLinksCheck, i18n("If in doubt, switch on!") );
|
||||
QWhatsThis::add( mRender.showHyperLinksCheck, i18n("For your convenience, some DVI files contain hyperlinks which are cross-references or point to external documents. You probably want to switch this option on, unless you don't want the blue underlines which KDVI uses to mark the hyperlinks.") );
|
||||
|
||||
QGroupBox *editorBox = new QGroupBox( 2, Horizontal, i18n("Editor for Inverse Search"), page );
|
||||
|
||||
new QLabel( "", editorBox );
|
||||
KURLLabel *urll = new KURLLabel("inv-search", i18n("What is 'inverse search'?"), editorBox, "inverse search help");
|
||||
urll->setAlignment(Qt::AlignRight);
|
||||
connect(urll, SIGNAL(leftClickedURL(const QString&)), SLOT(slotExtraHelpButton(const QString&)));
|
||||
|
||||
new QLabel( i18n("Editor:"), editorBox );
|
||||
mRender.editorChoice = new KComboBox( editorBox );
|
||||
connect(mRender.editorChoice, SIGNAL( activated( int ) ), this, SLOT( slotComboBox( int ) ) );
|
||||
QToolTip::add( mRender.editorChoice, i18n("Choose an editor which is used in inverse search.") );
|
||||
QWhatsThis::add( mRender.editorChoice, i18n("Some DVI-files contain 'inverse search' information. If such a DVI-file is loaded, you can click with the right mouse into KDVI, an editor opens, loads the TeX-file and jumps to the proper position. You can select you favourite editor here. If in doubt, 'nedit' is usually a good choice.\nCheck the KDVI manual to see how to prepare DVI-files which support the inverse search.") );
|
||||
|
||||
// Editor description strings (and their translations) vary in
|
||||
// size. Find the longest description string available to make sure
|
||||
// that the page is always large enough.
|
||||
new QLabel( i18n("Description:"), editorBox );
|
||||
mRender.editorDescription = new QLabel( editorBox );
|
||||
int maximumWidth = 0;
|
||||
for ( QStringList::Iterator it = EditorDescriptions.begin(); it != EditorDescriptions.end(); ++it ) {
|
||||
int width = mRender.editorDescription->fontMetrics().width(*it);
|
||||
if (width > maximumWidth)
|
||||
maximumWidth = width;
|
||||
}
|
||||
mRender.editorDescription->setMinimumWidth(maximumWidth+10);
|
||||
QToolTip::add( mRender.editorDescription, i18n("Explains about the editor's capabilities in conjunction with inverse search.") );
|
||||
QWhatsThis::add( mRender.editorDescription, i18n("Not all editors are well-suited for inverse search. For instance, many editors have no command like 'If the file is not yet loaded, load it. Otherwise, bring the window with the file to the front'. If you are using an editor like this, clicking into the DVI file will always open a new editor, even if the TeX-file is already open. Likewise, many editors have no command line argument that would allow KDVI to specify the exact line which you wish to edit.\nIf you feel that KDVI's support for a certain editor is not well-done, please write to kebekus@kde.org.") );
|
||||
|
||||
new QLabel( i18n("Shell command:"), editorBox );
|
||||
mRender.editorCallingCommand = new KLineEdit( editorBox );
|
||||
mRender.editorCallingCommand->setReadOnly(true);
|
||||
connect(mRender.editorCallingCommand, SIGNAL( textChanged (const QString &) ), this, SLOT( slotUserDefdEditorCommand( const QString & ) ) );
|
||||
QToolTip::add( mRender.editorCallingCommand, i18n("Shell-command line used to start the editor.") );
|
||||
QWhatsThis::add( mRender.editorCallingCommand, i18n("If you are using inverse search, KDVI uses this command line to start the editor. The field '%f' is replaced with the filename, and '%l' is replaced with the line number.") );
|
||||
}
|
||||
|
||||
|
||||
#include "optiondialog.moc"
|
||||
|
|
|
@ -1,33 +1,12 @@
|
|||
/*
|
||||
* kdvi: KDE dvi viewer
|
||||
* This file: Copyright (C) 2000 Espen Sand, espen@kde.org
|
||||
* Based on ealier dialog code
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
#ifndef _OPTION_DIALOG_H_
|
||||
#define _OPTION_DIALOG_H_
|
||||
// optiondialog.h
|
||||
//
|
||||
// Part of KDVI - A DVI previewer for the KDE desktop environemt
|
||||
//
|
||||
// (C) 2003 Stefan Kebekus
|
||||
// Distributed under the GPL
|
||||
|
||||
class KComboBox;
|
||||
class KInstance;
|
||||
class KLineEdit;
|
||||
class QCheckBox;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QSpinBox;
|
||||
#ifndef OPTIONDIALOG
|
||||
#define OPTIONDIALOG
|
||||
|
||||
#include <kdialogbase.h>
|
||||
|
||||
|
@ -35,54 +14,15 @@ class OptionDialog : public KDialogBase
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
struct FontItems
|
||||
{
|
||||
int pageIndex;
|
||||
KComboBox *metafontMode;
|
||||
QCheckBox *fontPathCheck;
|
||||
};
|
||||
|
||||
struct RenderItems
|
||||
{
|
||||
int pageIndex;
|
||||
QCheckBox *showSpecialCheck;
|
||||
QCheckBox *showHyperLinksCheck;
|
||||
KComboBox *editorChoice;
|
||||
QLabel *editorDescription;
|
||||
KLineEdit *editorCallingCommand;
|
||||
};
|
||||
|
||||
public:
|
||||
OptionDialog( QWidget *parent=0, const char *name=0, bool modal=true);
|
||||
virtual void show();
|
||||
QString EditorCommand;
|
||||
|
||||
protected slots:
|
||||
void slotOk();
|
||||
void slotApply();
|
||||
void slotComboBox(int item);
|
||||
void slotUserDefdEditorCommand( const QString & );
|
||||
void slotExtraHelpButton( const QString &);
|
||||
|
||||
private:
|
||||
void makeFontPage();
|
||||
void makeRenderingPage();
|
||||
void slotOk(void);
|
||||
void slotApply(void);
|
||||
|
||||
signals:
|
||||
void preferencesChanged();
|
||||
|
||||
private:
|
||||
bool isUserDefdEditor;
|
||||
QString usersEditorCommand;
|
||||
FontItems mFont;
|
||||
RenderItems mRender;
|
||||
|
||||
QStringList EditorNames;
|
||||
QStringList EditorCommands;
|
||||
QStringList EditorDescriptions;
|
||||
|
||||
KInstance *_instance;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue