2003-01-29 21:23:55 +00:00
|
|
|
// 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 <kcombobox.h>
|
|
|
|
#include <klineedit.h>
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kurllabel.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
|
|
|
|
#include "optionDialogSpecialWidget.h"
|
2004-09-04 14:19:57 +00:00
|
|
|
#include "prefs.h"
|
2003-01-29 21:23:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Constructs a optionDialogWidget_base which is a child of 'parent', with
|
|
|
|
// the name 'name' and widget flags set to 'f'.
|
2005-06-07 10:36:52 +00:00
|
|
|
optionDialogSpecialWidget::optionDialogSpecialWidget( QWidget* parent, const char* name, Qt::WFlags fl )
|
2003-01-29 21:23:55 +00:00
|
|
|
: optionDialogSpecialWidget_base( parent, name, fl )
|
|
|
|
{
|
|
|
|
// 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";
|
2005-06-26 20:33:06 +00:00
|
|
|
editorCommandString += "kate --use --line %l %f";
|
2004-02-07 17:07:34 +00:00
|
|
|
editorDescriptionString += i18n("Kate perfectly supports inverse search.");
|
2003-01-29 21:23:55 +00:00
|
|
|
|
2003-02-06 21:39:28 +00:00
|
|
|
editorNameString += "Kile";
|
|
|
|
editorCommandString += "kile %f --line %l";
|
|
|
|
editorDescriptionString += i18n("Kile works very well");
|
|
|
|
|
2003-01-29 21:23:55 +00:00
|
|
|
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";
|
2003-05-09 10:28:43 +00:00
|
|
|
editorCommandString += "gvim --servername KDVI --remote-silent +%l %f";
|
2003-01-29 21:23:55 +00:00
|
|
|
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.");
|
|
|
|
|
2005-06-09 07:51:57 +00:00
|
|
|
for(int i=0; i<editorNameString.count(); i++)
|
2003-01-29 21:23:55 +00:00
|
|
|
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.
|
2004-09-04 14:19:57 +00:00
|
|
|
QString currentEditorCommand = Prefs::editorCommand();
|
2003-01-29 21:23:55 +00:00
|
|
|
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);
|
|
|
|
|
2004-09-04 14:19:57 +00:00
|
|
|
connect(kcfg_EditorCommand, SIGNAL( textChanged (const QString &) ), this, SLOT( slotUserDefdEditorCommand( const QString & ) ) );
|
2003-01-29 21:23:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
optionDialogSpecialWidget::~optionDialogSpecialWidget()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2004-09-04 14:19:57 +00:00
|
|
|
kcfg_EditorCommand->setText(editorCommandString[item]);
|
|
|
|
kcfg_EditorCommand->setReadOnly(true);
|
2003-01-29 21:23:55 +00:00
|
|
|
EditorCommand = editorCommandString[item];
|
|
|
|
} else {
|
2004-09-04 14:19:57 +00:00
|
|
|
kcfg_EditorCommand->setText(usersEditorCommand);
|
|
|
|
kcfg_EditorCommand->setReadOnly(false);
|
2003-01-29 21:23:55 +00:00
|
|
|
EditorCommand = usersEditorCommand;
|
|
|
|
isUserDefdEditor = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void optionDialogSpecialWidget::slotExtraHelpButton( const QString & )
|
|
|
|
{
|
|
|
|
kapp->invokeHelp( "inv-search", "kdvi" );
|
|
|
|
}
|
|
|
|
|
2005-08-26 18:18:29 +00:00
|
|
|
void optionDialogSpecialWidget::apply()
|
2003-01-29 21:23:55 +00:00
|
|
|
{
|
2004-09-04 14:19:57 +00:00
|
|
|
Prefs::setEditorCommand(EditorCommand);
|
2003-01-29 21:23:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#include "optionDialogSpecialWidget.moc"
|