2006-03-05 17:24:44 +00:00
/**
2007-08-31 05:53:55 +00:00
* \ file GuiPrefs . cpp
2006-03-05 17:24:44 +00:00
* This file is part of LyX , the document processor .
* Licence details can be found in the file COPYING .
*
* \ author John Levon
2007-10-23 03:48:02 +00:00
* \ author Bo Peng
2006-03-05 17:24:44 +00:00
*
* Full author contact details are available in file CREDITS .
*/
# include <config.h>
2007-08-31 05:53:55 +00:00
# include "GuiPrefs.h"
2006-03-05 17:24:44 +00:00
2008-05-23 08:43:07 +00:00
# include "ColorCache.h"
2008-05-07 22:42:44 +00:00
# include "FileDialog.h"
2007-04-25 07:13:54 +00:00
# include "GuiApplication.h"
2008-05-07 22:42:44 +00:00
# include "GuiFontExample.h"
2007-10-09 14:10:55 +00:00
# include "GuiFontLoader.h"
2008-05-07 22:42:44 +00:00
# include "GuiKeySymbol.h"
2019-03-22 14:11:46 +01:00
# include "GuiLyXFiles.h"
# include "GuiView.h"
2008-05-07 22:42:44 +00:00
# include "qt_helpers.h"
2011-09-24 16:39:17 +00:00
# include "Validator.h"
2006-03-05 17:24:44 +00:00
2010-10-29 19:27:55 +00:00
# include "Author.h"
2007-10-07 09:47:12 +00:00
# include "BufferList.h"
# include "Color.h"
2009-02-09 23:30:24 +00:00
# include "ColorSet.h"
2007-05-17 08:31:00 +00:00
# include "ConverterCache.h"
2008-05-23 08:43:07 +00:00
# include "FontEnums.h"
2007-10-07 09:47:12 +00:00
# include "FuncRequest.h"
2007-10-16 17:48:37 +00:00
# include "KeyMap.h"
2007-10-18 15:48:51 +00:00
# include "KeySequence.h"
2008-05-07 22:42:44 +00:00
# include "Language.h"
2007-10-16 17:48:37 +00:00
# include "LyXAction.h"
2010-04-20 16:49:49 +00:00
# include "LyX.h"
2007-10-07 09:47:12 +00:00
# include "PanelStack.h"
# include "Session.h"
2009-08-08 17:05:31 +00:00
# include "SpellChecker.h"
2006-03-05 17:24:44 +00:00
2008-02-18 07:14:42 +00:00
# include "support/debug.h"
2007-10-20 20:50:56 +00:00
# include "support/FileName.h"
# include "support/filetools.h"
2008-02-18 07:14:42 +00:00
# include "support/gettext.h"
2011-07-14 17:00:35 +00:00
# include "support/lassert.h"
2006-03-05 17:24:44 +00:00
# include "support/lstrings.h"
2012-08-23 15:08:21 +02:00
# include "support/Messages.h"
2006-03-05 17:24:44 +00:00
# include "support/os.h"
2007-10-20 20:50:56 +00:00
# include "support/Package.h"
2006-03-05 17:24:44 +00:00
2007-10-25 20:36:17 +00:00
# include "graphics/GraphicsTypes.h"
2007-04-28 20:44:46 +00:00
# include "frontends/alert.h"
2007-04-25 07:13:54 +00:00
# include "frontends/Application.h"
2008-05-23 08:43:07 +00:00
# include "frontends/FontLoader.h"
2007-04-25 07:13:54 +00:00
2008-05-14 10:34:19 +00:00
# include <QAbstractItemModel>
2007-04-25 07:13:54 +00:00
# include <QCheckBox>
# include <QColorDialog>
# include <QFontDatabase>
2007-10-17 05:13:34 +00:00
# include <QHeaderView>
2007-04-25 07:13:54 +00:00
# include <QLineEdit>
2008-06-25 15:02:18 +00:00
# include <QMessageBox>
2007-04-25 07:13:54 +00:00
# include <QPushButton>
# include <QSpinBox>
# include <QString>
2007-10-16 17:48:37 +00:00
# include <QTreeWidget>
# include <QTreeWidgetItem>
2007-04-25 07:13:54 +00:00
# include <QValidator>
# include <iomanip>
# include <sstream>
2007-09-03 05:59:32 +00:00
# include <algorithm>
2017-04-02 14:55:33 +02:00
# include <math.h>
2007-04-25 07:13:54 +00:00
2006-03-05 17:24:44 +00:00
using namespace Ui ;
2007-12-12 10:16:00 +00:00
using namespace std ;
2007-12-12 18:57:56 +00:00
using namespace lyx : : support ;
using namespace lyx : : support : : os ;
2007-04-25 07:13:54 +00:00
namespace lyx {
namespace frontend {
2008-03-05 23:10:53 +00:00
/////////////////////////////////////////////////////////////////////
//
// Browser Helpers
//
/////////////////////////////////////////////////////////////////////
/** Launch a file dialog and return the chosen file.
filename : a suggested filename .
title : the title of the dialog .
2011-06-01 13:18:08 +00:00
filters : * . ps etc .
2008-03-05 23:10:53 +00:00
dir1 = ( name , dir ) , dir2 = ( name , dir ) : extra buttons on the dialog .
*/
QString browseFile ( QString const & filename ,
QString const & title ,
2008-04-20 19:56:01 +00:00
QStringList const & filters ,
2008-03-05 23:10:53 +00:00
bool save = false ,
QString const & label1 = QString ( ) ,
QString const & dir1 = QString ( ) ,
QString const & label2 = QString ( ) ,
2008-10-05 14:11:04 +00:00
QString const & dir2 = QString ( ) ,
QString const & fallback_dir = QString ( ) )
2008-03-05 23:10:53 +00:00
{
QString lastPath = " . " ;
if ( ! filename . isEmpty ( ) )
lastPath = onlyPath ( filename ) ;
2008-10-05 14:11:04 +00:00
else if ( ! fallback_dir . isEmpty ( ) )
lastPath = fallback_dir ;
2008-03-05 23:10:53 +00:00
2014-04-21 16:50:56 +02:00
FileDialog dlg ( title ) ;
2017-12-20 12:17:04 +01:00
dlg . setButton1 ( label1 , dir1 ) ;
2008-03-05 23:10:53 +00:00
dlg . setButton2 ( label2 , dir2 ) ;
FileDialog : : Result result ;
if ( save )
2010-04-21 01:19:28 +00:00
result = dlg . save ( lastPath , filters , onlyFileName ( filename ) ) ;
2008-03-05 23:10:53 +00:00
else
2010-04-21 01:19:28 +00:00
result = dlg . open ( lastPath , filters , onlyFileName ( filename ) ) ;
2008-03-05 23:10:53 +00:00
return result . second ;
}
/** Launch a file dialog and return the chosen directory.
pathname : a suggested pathname .
title : the title of the dialog .
dir1 = ( name , dir ) , dir2 = ( name , dir ) : extra buttons on the dialog .
*/
QString browseDir ( QString const & pathname ,
QString const & title ,
QString const & label1 = QString ( ) ,
QString const & dir1 = QString ( ) ,
QString const & label2 = QString ( ) ,
QString const & dir2 = QString ( ) )
{
QString lastPath = " . " ;
if ( ! pathname . isEmpty ( ) )
lastPath = onlyPath ( pathname ) ;
2014-04-21 16:50:56 +02:00
FileDialog dlg ( title ) ;
2008-03-05 23:10:53 +00:00
dlg . setButton1 ( label1 , dir1 ) ;
dlg . setButton2 ( label2 , dir2 ) ;
FileDialog : : Result const result =
2010-04-21 01:19:28 +00:00
dlg . opendir ( lastPath , onlyFileName ( pathname ) ) ;
2008-03-05 23:10:53 +00:00
return result . second ;
}
2008-03-06 00:07:19 +00:00
} // namespace frontend
2008-04-20 21:05:35 +00:00
2011-06-01 13:18:08 +00:00
QString browseRelToParent ( QString const & filename , QString const & relpath ,
2008-04-20 19:56:01 +00:00
QString const & title , QStringList const & filters , bool save ,
2008-03-05 23:10:53 +00:00
QString const & label1 , QString const & dir1 ,
QString const & label2 , QString const & dir2 )
{
2011-06-01 13:18:08 +00:00
QString const fname = makeAbsPath ( filename , relpath ) ;
2008-04-20 21:05:35 +00:00
2008-03-05 23:10:53 +00:00
QString const outname =
2008-03-06 00:07:19 +00:00
frontend : : browseFile ( fname , title , filters , save , label1 , dir1 , label2 , dir2 ) ;
2008-03-05 23:10:53 +00:00
QString const reloutname =
2011-06-01 13:18:08 +00:00
toqstr ( makeRelPath ( qstring_to_ucs4 ( outname ) , qstring_to_ucs4 ( relpath ) ) ) ;
2008-03-05 23:10:53 +00:00
if ( reloutname . startsWith ( " ../ " ) )
return outname ;
else
return reloutname ;
}
2007-10-07 09:47:12 +00:00
2011-06-01 13:18:08 +00:00
QString browseRelToSub ( QString const & filename , QString const & relpath ,
QString const & title , QStringList const & filters , bool save ,
QString const & label1 , QString const & dir1 ,
QString const & label2 , QString const & dir2 )
{
QString const fname = makeAbsPath ( filename , relpath ) ;
QString const outname =
frontend : : browseFile ( fname , title , filters , save , label1 , dir1 , label2 , dir2 ) ;
QString const reloutname =
toqstr ( makeRelPath ( qstring_to_ucs4 ( outname ) , qstring_to_ucs4 ( relpath ) ) ) ;
QString testname = reloutname ;
testname . remove ( QRegExp ( " ^( \\ . \\ ./)+ " ) ) ;
2014-12-07 18:35:28 +01:00
2011-06-01 13:18:08 +00:00
if ( testname . contains ( " / " ) )
return outname ;
else
return reloutname ;
}
2008-04-20 21:05:35 +00:00
2007-04-25 07:13:54 +00:00
/////////////////////////////////////////////////////////////////////
//
// Helpers
//
/////////////////////////////////////////////////////////////////////
2008-03-05 23:10:53 +00:00
namespace frontend {
2013-05-12 18:30:59 +02:00
QString const catLookAndFeel = N_ ( " Look & Feel " ) ;
QString const catEditing = N_ ( " Editing " ) ;
QString const catLanguage = N_ ( " Language Settings " ) ;
QString const catOutput = N_ ( " Output " ) ;
QString const catFiles = N_ ( " File Handling " ) ;
2008-03-19 13:11:14 +00:00
2007-11-24 22:15:52 +00:00
static void parseFontName ( QString const & mangled0 ,
string & name , string & foundry )
2007-09-15 15:42:22 +00:00
{
2007-12-12 19:28:07 +00:00
string mangled = fromqstr ( mangled0 ) ;
2007-11-24 22:15:52 +00:00
size_t const idx = mangled . find ( ' [ ' ) ;
if ( idx = = string : : npos | | idx = = 0 ) {
name = mangled ;
foundry . clear ( ) ;
} else {
name = mangled . substr ( 0 , idx - 1 ) ,
foundry = mangled . substr ( idx + 1 , mangled . size ( ) - idx - 2 ) ;
}
2007-09-15 15:42:22 +00:00
}
2007-04-25 07:13:54 +00:00
static void setComboxFont ( QComboBox * cb , string const & family ,
string const & foundry )
{
2007-09-15 15:42:22 +00:00
QString fontname = toqstr ( family ) ;
if ( ! foundry . empty ( ) )
fontname + = " [ " + toqstr ( foundry ) + ' ] ' ;
2008-03-05 23:10:53 +00:00
for ( int i = 0 ; i ! = cb - > count ( ) ; + + i ) {
2007-09-15 15:42:22 +00:00
if ( cb - > itemText ( i ) = = fontname ) {
2007-04-25 07:13:54 +00:00
cb - > setCurrentIndex ( i ) ;
return ;
}
}
// Try matching without foundry name
// We count in reverse in order to prefer the Xft foundry
2007-09-15 15:42:22 +00:00
for ( int i = cb - > count ( ) ; - - i > = 0 ; ) {
2018-02-22 00:15:07 -05:00
string name , fnt_foundry ;
parseFontName ( cb - > itemText ( i ) , name , fnt_foundry ) ;
2007-11-24 22:15:52 +00:00
if ( compare_ascii_no_case ( name , family ) = = 0 ) {
2007-04-25 07:13:54 +00:00
cb - > setCurrentIndex ( i ) ;
return ;
}
}
// family alone can contain e.g. "Helvetica [Adobe]"
2007-11-24 22:15:52 +00:00
string tmpname , tmpfoundry ;
parseFontName ( toqstr ( family ) , tmpname , tmpfoundry ) ;
2007-04-25 07:13:54 +00:00
// We count in reverse in order to prefer the Xft foundry
2007-11-23 21:39:51 +00:00
for ( int i = cb - > count ( ) ; - - i > = 0 ; ) {
2018-02-22 00:15:07 -05:00
string name , fnt_foundry ;
parseFontName ( cb - > itemText ( i ) , name , fnt_foundry ) ;
if ( compare_ascii_no_case ( name , fnt_foundry ) = = 0 ) {
2007-04-25 07:13:54 +00:00
cb - > setCurrentIndex ( i ) ;
return ;
}
}
// Bleh, default fonts, and the names couldn't be found. Hack
// for bug 1063.
QFont font ;
2007-11-18 20:36:52 +00:00
QString const font_family = toqstr ( family ) ;
if ( font_family = = guiApp - > romanFontName ( ) ) {
2007-04-25 07:13:54 +00:00
font . setStyleHint ( QFont : : Serif ) ;
2007-11-18 20:36:52 +00:00
font . setFamily ( font_family ) ;
} else if ( font_family = = guiApp - > sansFontName ( ) ) {
2007-04-25 07:13:54 +00:00
font . setStyleHint ( QFont : : SansSerif ) ;
2007-11-18 20:36:52 +00:00
font . setFamily ( font_family ) ;
} else if ( font_family = = guiApp - > typewriterFontName ( ) ) {
2007-04-25 07:13:54 +00:00
font . setStyleHint ( QFont : : TypeWriter ) ;
2007-11-18 20:36:52 +00:00
font . setFamily ( font_family ) ;
2007-04-25 07:13:54 +00:00
} else {
2008-04-20 21:05:35 +00:00
LYXERR0 ( " FAILED to find the default font: ' "
< < foundry < < " ', ' " < < family < < ' \' ' ) ;
2007-04-25 07:13:54 +00:00
return ;
}
QFontInfo info ( font ) ;
2007-11-24 22:15:52 +00:00
string default_font_name , dummyfoundry ;
parseFontName ( info . family ( ) , default_font_name , dummyfoundry ) ;
2008-04-20 21:05:35 +00:00
LYXERR0 ( " Apparent font is " < < default_font_name ) ;
2007-04-25 07:13:54 +00:00
for ( int i = 0 ; i < cb - > count ( ) ; + + i ) {
2008-04-20 21:05:35 +00:00
LYXERR0 ( " Looking at " < < cb - > itemText ( i ) ) ;
2007-04-25 07:13:54 +00:00
if ( compare_ascii_no_case ( fromqstr ( cb - > itemText ( i ) ) ,
default_font_name ) = = 0 ) {
cb - > setCurrentIndex ( i ) ;
return ;
}
}
2008-04-20 21:05:35 +00:00
LYXERR0 ( " FAILED to find the font: ' "
< < foundry < < " ', ' " < < family < < ' \' ' ) ;
2007-04-25 07:13:54 +00:00
}
/////////////////////////////////////////////////////////////////////
//
2010-04-15 14:25:25 +00:00
// PrefOutput
2007-04-25 07:13:54 +00:00
//
/////////////////////////////////////////////////////////////////////
2010-04-15 14:25:25 +00:00
PrefOutput : : PrefOutput ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catOutput , N_ ( " General " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2011-09-12 14:22:05 +00:00
dviCB - > setValidator ( new NoNewLineValidator ( dviCB ) ) ;
pdfCB - > setValidator ( new NoNewLineValidator ( pdfCB ) ) ;
2010-04-15 14:25:25 +00:00
connect ( plaintextLinelengthSB , SIGNAL ( valueChanged ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2010-04-20 16:49:49 +00:00
connect ( overwriteCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2010-04-16 21:27:37 +00:00
connect ( dviCB , SIGNAL ( editTextChanged ( QString ) ) ,
2010-04-16 08:09:07 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2010-04-16 21:27:37 +00:00
connect ( pdfCB , SIGNAL ( editTextChanged ( QString ) ) ,
2010-04-16 08:09:07 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2015-05-27 18:10:38 -04:00
connect ( printerPaperTypeED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( printerLandscapeED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( printerPaperSizeED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
printerPaperTypeED - > setValidator ( new NoNewLineValidator ( printerPaperTypeED ) ) ;
printerLandscapeED - > setValidator ( new NoNewLineValidator ( printerLandscapeED ) ) ;
printerPaperSizeED - > setValidator ( new NoNewLineValidator ( printerPaperSizeED ) ) ;
2010-04-16 08:09:07 +00:00
dviCB - > addItem ( " " ) ;
2011-02-12 20:24:09 +00:00
dviCB - > addItem ( " xdvi -sourceposition '$$n: \\ $$t' $$o " ) ;
2011-02-12 22:54:52 +00:00
dviCB - > addItem ( " yap -1 -s \" $$n $$t \" $$o " ) ;
2012-08-26 11:42:43 +02:00
dviCB - > addItem ( " okular --unique \" $$o#src:$$n $$f \" " ) ;
2011-04-08 12:00:51 +00:00
dviCB - > addItem ( " synctex view -i $$n:0:$$t -o $$o -x \" evince -i %{page+1} $$o \" " ) ;
2010-04-16 08:09:07 +00:00
pdfCB - > addItem ( " " ) ;
pdfCB - > addItem ( " CMCDDE SUMATRA control [ForwardSearch( \\ \" $$o \\ \" , \\ \" $$t \\ \" ,$$n,0,0,1)] " ) ;
2016-08-21 23:33:01 +02:00
pdfCB - > addItem ( " SumatraPDF -reuse-instance \" $$o \" -forward-search \" $$t \" $$n " ) ;
2010-04-16 22:57:37 +00:00
pdfCB - > addItem ( " synctex view -i $$n:0:$$t -o $$o -x \" xpdf -raise -remote $$t.tmp $$o %{page+1} \" " ) ;
2012-08-26 11:42:43 +02:00
pdfCB - > addItem ( " okular --unique \" $$o#src:$$n $$f \" " ) ;
2014-07-13 20:08:43 +02:00
pdfCB - > addItem ( " qpdfview --unique \" $$o#src:$$f:$$n:0 \" " ) ;
2011-04-08 12:00:51 +00:00
pdfCB - > addItem ( " synctex view -i $$n:0:$$t -o $$o -x \" evince -i %{page+1} $$o \" " ) ;
2010-04-18 23:52:08 +00:00
pdfCB - > addItem ( " /Applications/Skim.app/Contents/SharedSupport/displayline $$n $$o $$t " ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefOutput : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
2010-04-15 14:25:25 +00:00
rc . plaintext_linelen = plaintextLinelengthSB - > value ( ) ;
2010-04-16 08:09:07 +00:00
rc . forward_search_dvi = fromqstr ( dviCB - > currentText ( ) ) ;
rc . forward_search_pdf = fromqstr ( pdfCB - > currentText ( ) ) ;
2010-04-20 16:49:49 +00:00
switch ( overwriteCO - > currentIndex ( ) ) {
case 0 :
rc . export_overwrite = NO_FILES ;
break ;
case 1 :
rc . export_overwrite = MAIN_FILE ;
break ;
case 2 :
rc . export_overwrite = ALL_FILES ;
break ;
}
2015-05-27 18:10:38 -04:00
rc . print_paper_flag = fromqstr ( printerPaperTypeED - > text ( ) ) ;
rc . print_landscape_flag = fromqstr ( printerLandscapeED - > text ( ) ) ;
rc . print_paper_dimension_flag = fromqstr ( printerPaperSizeED - > text ( ) ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefOutput : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
2010-04-15 14:25:25 +00:00
plaintextLinelengthSB - > setValue ( rc . plaintext_linelen ) ;
2010-04-16 08:09:07 +00:00
dviCB - > setEditText ( toqstr ( rc . forward_search_dvi ) ) ;
pdfCB - > setEditText ( toqstr ( rc . forward_search_pdf ) ) ;
2010-04-20 16:49:49 +00:00
switch ( rc . export_overwrite ) {
case NO_FILES :
overwriteCO - > setCurrentIndex ( 0 ) ;
break ;
case MAIN_FILE :
overwriteCO - > setCurrentIndex ( 1 ) ;
break ;
case ALL_FILES :
overwriteCO - > setCurrentIndex ( 2 ) ;
break ;
}
2015-05-27 18:10:38 -04:00
printerPaperTypeED - > setText ( toqstr ( rc . print_paper_flag ) ) ;
printerLandscapeED - > setText ( toqstr ( rc . print_landscape_flag ) ) ;
printerPaperSizeED - > setText ( toqstr ( rc . print_paper_dimension_flag ) ) ;
2007-04-25 07:13:54 +00:00
}
/////////////////////////////////////////////////////////////////////
//
2008-01-30 21:20:56 +00:00
// PrefInput
2007-04-25 07:13:54 +00:00
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefInput : : PrefInput ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catEditing , N_ ( " Keyboard/Mouse " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
connect ( keymapCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( firstKeymapED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( secondKeymapED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2008-01-30 21:20:56 +00:00
connect ( mouseWheelSpeedSB , SIGNAL ( valueChanged ( double ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2010-07-17 22:29:42 +00:00
connect ( scrollzoomEnableCB , SIGNAL ( clicked ( ) ) ,
2010-09-19 22:00:25 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2010-07-17 22:29:42 +00:00
connect ( scrollzoomValueCO , SIGNAL ( activated ( int ) ) ,
2010-09-19 22:00:25 +00:00
this , SIGNAL ( changed ( ) ) ) ;
connect ( dontswapCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2015-02-08 17:41:28 +01:00
connect ( mmPasteCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2010-09-19 22:00:25 +00:00
// reveal checkbox for switching Ctrl and Meta on Mac:
bool swapcb = false ;
2014-08-25 20:08:59 +02:00
# ifdef Q_OS_MAC
2010-09-19 22:00:25 +00:00
# if QT_VERSION > 0x040600
swapcb = true ;
# endif
# endif
dontswapCB - > setVisible ( swapcb ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefInput : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
// FIXME: can derive CB from the two EDs
rc . use_kbmap = keymapCB - > isChecked ( ) ;
rc . primary_kbmap = internal_path ( fromqstr ( firstKeymapED - > text ( ) ) ) ;
rc . secondary_kbmap = internal_path ( fromqstr ( secondKeymapED - > text ( ) ) ) ;
2008-01-30 21:20:56 +00:00
rc . mouse_wheel_speed = mouseWheelSpeedSB - > value ( ) ;
2010-07-17 22:29:42 +00:00
if ( scrollzoomEnableCB - > isChecked ( ) ) {
switch ( scrollzoomValueCO - > currentIndex ( ) ) {
case 0 :
2010-07-22 14:51:35 +00:00
rc . scroll_wheel_zoom = LyXRC : : SCROLL_WHEEL_ZOOM_CTRL ;
2010-07-17 22:29:42 +00:00
break ;
case 1 :
2010-07-22 14:51:35 +00:00
rc . scroll_wheel_zoom = LyXRC : : SCROLL_WHEEL_ZOOM_SHIFT ;
2010-07-17 22:29:42 +00:00
break ;
case 2 :
2010-07-22 14:51:35 +00:00
rc . scroll_wheel_zoom = LyXRC : : SCROLL_WHEEL_ZOOM_ALT ;
2010-07-17 22:29:42 +00:00
break ;
}
} else {
2010-07-22 14:51:35 +00:00
rc . scroll_wheel_zoom = LyXRC : : SCROLL_WHEEL_ZOOM_OFF ;
2010-07-17 22:29:42 +00:00
}
2010-09-19 22:00:25 +00:00
rc . mac_dontswap_ctrl_meta = dontswapCB - > isChecked ( ) ;
2015-02-08 17:41:28 +01:00
rc . mouse_middlebutton_paste = mmPasteCB - > isChecked ( ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefInput : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
// FIXME: can derive CB from the two EDs
keymapCB - > setChecked ( rc . use_kbmap ) ;
firstKeymapED - > setText ( toqstr ( external_path ( rc . primary_kbmap ) ) ) ;
secondKeymapED - > setText ( toqstr ( external_path ( rc . secondary_kbmap ) ) ) ;
2008-01-30 21:20:56 +00:00
mouseWheelSpeedSB - > setValue ( rc . mouse_wheel_speed ) ;
2010-07-22 14:51:35 +00:00
switch ( rc . scroll_wheel_zoom ) {
2010-07-17 22:29:42 +00:00
case LyXRC : : SCROLL_WHEEL_ZOOM_OFF :
scrollzoomEnableCB - > setChecked ( false ) ;
break ;
case LyXRC : : SCROLL_WHEEL_ZOOM_CTRL :
scrollzoomEnableCB - > setChecked ( true ) ;
scrollzoomValueCO - > setCurrentIndex ( 0 ) ;
break ;
case LyXRC : : SCROLL_WHEEL_ZOOM_SHIFT :
scrollzoomEnableCB - > setChecked ( true ) ;
scrollzoomValueCO - > setCurrentIndex ( 1 ) ;
break ;
2010-07-18 10:04:59 +00:00
case LyXRC : : SCROLL_WHEEL_ZOOM_ALT :
2010-07-17 22:29:42 +00:00
scrollzoomEnableCB - > setChecked ( true ) ;
scrollzoomValueCO - > setCurrentIndex ( 2 ) ;
break ;
}
2010-09-19 22:00:25 +00:00
dontswapCB - > setChecked ( rc . mac_dontswap_ctrl_meta ) ;
2015-02-08 17:41:28 +01:00
mmPasteCB - > setChecked ( rc . mouse_middlebutton_paste ) ;
2007-04-25 07:13:54 +00:00
}
2008-05-19 20:52:24 +00:00
QString PrefInput : : testKeymap ( QString const & keymap )
2007-04-25 07:13:54 +00:00
{
2008-05-19 20:52:24 +00:00
return form_ - > browsekbmap ( internalPath ( keymap ) ) ;
2007-04-25 07:13:54 +00:00
}
2008-01-30 21:20:56 +00:00
void PrefInput : : on_firstKeymapPB_clicked ( bool )
2007-04-25 07:13:54 +00:00
{
QString const file = testKeymap ( firstKeymapED - > text ( ) ) ;
if ( ! file . isEmpty ( ) )
firstKeymapED - > setText ( file ) ;
}
2008-01-30 21:20:56 +00:00
void PrefInput : : on_secondKeymapPB_clicked ( bool )
2007-04-25 07:13:54 +00:00
{
QString const file = testKeymap ( secondKeymapED - > text ( ) ) ;
if ( ! file . isEmpty ( ) )
secondKeymapED - > setText ( file ) ;
}
2008-01-30 21:20:56 +00:00
void PrefInput : : on_keymapCB_toggled ( bool keymap )
2007-04-25 07:13:54 +00:00
{
firstKeymapLA - > setEnabled ( keymap ) ;
secondKeymapLA - > setEnabled ( keymap ) ;
firstKeymapED - > setEnabled ( keymap ) ;
secondKeymapED - > setEnabled ( keymap ) ;
firstKeymapPB - > setEnabled ( keymap ) ;
secondKeymapPB - > setEnabled ( keymap ) ;
}
2010-07-17 22:29:42 +00:00
void PrefInput : : on_scrollzoomEnableCB_toggled ( bool enabled )
{
scrollzoomValueCO - > setEnabled ( enabled ) ;
}
2014-12-07 18:35:28 +01:00
2008-03-18 17:31:17 +00:00
/////////////////////////////////////////////////////////////////////
//
// PrefCompletion
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefCompletion : : PrefCompletion ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catEditing , N_ ( " Input Completion " ) , form )
2008-03-18 17:31:17 +00:00
{
setupUi ( this ) ;
connect ( inlineDelaySB , SIGNAL ( valueChanged ( double ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( inlineMathCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( inlineTextCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( inlineDotsCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( popupDelaySB , SIGNAL ( valueChanged ( double ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( popupMathCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2009-06-13 22:23:19 +00:00
connect ( autocorrectionCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2008-03-18 17:31:17 +00:00
connect ( popupTextCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( popupAfterCompleteCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( cursorTextCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2012-01-02 22:47:04 +00:00
connect ( minlengthSB , SIGNAL ( valueChanged ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2008-03-18 17:31:17 +00:00
}
2009-05-20 20:00:31 +00:00
void PrefCompletion : : on_inlineTextCB_clicked ( )
{
2009-05-22 21:35:18 +00:00
enableCB ( ) ;
2009-05-20 20:00:31 +00:00
}
void PrefCompletion : : on_popupTextCB_clicked ( )
2009-05-22 21:35:18 +00:00
{
enableCB ( ) ;
}
void PrefCompletion : : enableCB ( )
2009-05-20 20:00:31 +00:00
{
cursorTextCB - > setEnabled (
popupTextCB - > isChecked ( ) | | inlineTextCB - > isChecked ( ) ) ;
}
2014-12-19 11:35:37 +01:00
void PrefCompletion : : applyRC ( LyXRC & rc ) const
2008-03-18 17:31:17 +00:00
{
rc . completion_inline_delay = inlineDelaySB - > value ( ) ;
rc . completion_inline_math = inlineMathCB - > isChecked ( ) ;
rc . completion_inline_text = inlineTextCB - > isChecked ( ) ;
rc . completion_inline_dots = inlineDotsCB - > isChecked ( ) ? 13 : - 1 ;
rc . completion_popup_delay = popupDelaySB - > value ( ) ;
rc . completion_popup_math = popupMathCB - > isChecked ( ) ;
2009-06-13 22:23:19 +00:00
rc . autocorrection_math = autocorrectionCB - > isChecked ( ) ;
2008-03-18 17:31:17 +00:00
rc . completion_popup_text = popupTextCB - > isChecked ( ) ;
rc . completion_cursor_text = cursorTextCB - > isChecked ( ) ;
rc . completion_popup_after_complete =
popupAfterCompleteCB - > isChecked ( ) ;
2012-01-02 22:47:04 +00:00
rc . completion_minlength = minlengthSB - > value ( ) ;
2008-03-18 17:31:17 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefCompletion : : updateRC ( LyXRC const & rc )
2008-03-18 17:31:17 +00:00
{
inlineDelaySB - > setValue ( rc . completion_inline_delay ) ;
inlineMathCB - > setChecked ( rc . completion_inline_math ) ;
inlineTextCB - > setChecked ( rc . completion_inline_text ) ;
inlineDotsCB - > setChecked ( rc . completion_inline_dots ! = - 1 ) ;
popupDelaySB - > setValue ( rc . completion_popup_delay ) ;
popupMathCB - > setChecked ( rc . completion_popup_math ) ;
2009-06-13 22:23:19 +00:00
autocorrectionCB - > setChecked ( rc . autocorrection_math ) ;
2008-03-18 17:31:17 +00:00
popupTextCB - > setChecked ( rc . completion_popup_text ) ;
cursorTextCB - > setChecked ( rc . completion_cursor_text ) ;
popupAfterCompleteCB - > setChecked ( rc . completion_popup_after_complete ) ;
2015-05-17 17:27:12 +02:00
enableCB ( ) ;
2012-01-02 22:47:04 +00:00
minlengthSB - > setValue ( rc . completion_minlength ) ;
2008-03-18 17:31:17 +00:00
}
2007-04-25 07:13:54 +00:00
/////////////////////////////////////////////////////////////////////
//
// PrefLatex
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefLatex : : PrefLatex ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catOutput , N_ ( " LaTeX " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2011-09-12 14:22:05 +00:00
latexDviPaperED - > setValidator ( new NoNewLineValidator ( latexDviPaperED ) ) ;
latexBibtexED - > setValidator ( new NoNewLineValidator ( latexBibtexED ) ) ;
latexJBibtexED - > setValidator ( new NoNewLineValidator ( latexJBibtexED ) ) ;
latexIndexED - > setValidator ( new NoNewLineValidator ( latexIndexED ) ) ;
latexJIndexED - > setValidator ( new NoNewLineValidator ( latexJIndexED ) ) ;
latexNomenclED - > setValidator ( new NoNewLineValidator ( latexNomenclED ) ) ;
latexChecktexED - > setValidator ( new NoNewLineValidator ( latexChecktexED ) ) ;
2007-10-25 20:36:17 +00:00
connect ( latexChecktexED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2009-05-08 10:07:32 +00:00
connect ( latexBibtexCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( latexBibtexED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2017-01-14 12:13:33 +01:00
connect ( latexJBibtexCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2009-04-13 09:53:40 +00:00
connect ( latexJBibtexED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2009-05-08 10:07:32 +00:00
connect ( latexIndexCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( latexIndexED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2009-04-13 09:53:40 +00:00
connect ( latexJIndexED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-04-25 07:13:54 +00:00
connect ( latexAutoresetCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( latexDviPaperED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2011-09-12 14:22:01 +00:00
connect ( latexNomenclED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-09-02 20:17:36 +00:00
# if defined(__CYGWIN__) || defined(_WIN32)
pathCB - > setVisible ( true ) ;
2008-06-25 15:02:18 +00:00
connect ( pathCB , SIGNAL ( clicked ( ) ) ,
2007-09-02 20:17:36 +00:00
this , SIGNAL ( changed ( ) ) ) ;
# else
pathCB - > setVisible ( false ) ;
# endif
2007-04-25 07:13:54 +00:00
}
2009-05-08 10:07:32 +00:00
void PrefLatex : : on_latexBibtexCO_activated ( int n )
{
QString const bibtex = latexBibtexCO - > itemData ( n ) . toString ( ) ;
if ( bibtex . isEmpty ( ) ) {
latexBibtexED - > clear ( ) ;
2017-01-14 12:13:33 +01:00
latexBibtexOptionsLA - > setText ( qt_ ( " C&ommand: " ) ) ;
2009-05-08 10:07:32 +00:00
return ;
}
2009-10-17 22:52:16 +00:00
for ( LyXRC : : CommandSet : : const_iterator it = bibtex_alternatives . begin ( ) ;
2009-05-08 10:07:32 +00:00
it ! = bibtex_alternatives . end ( ) ; + + it ) {
QString const bib = toqstr ( * it ) ;
int ind = bib . indexOf ( " " ) ;
QString sel_command = bib . left ( ind ) ;
2009-05-27 22:24:05 +00:00
QString sel_options = ind < 0 ? QString ( ) : bib . mid ( ind + 1 ) ;
2009-05-08 10:07:32 +00:00
if ( bibtex = = sel_command ) {
2009-05-27 22:24:05 +00:00
if ( ind < 0 )
2009-05-08 10:07:32 +00:00
latexBibtexED - > clear ( ) ;
else
latexBibtexED - > setText ( sel_options . trimmed ( ) ) ;
}
}
latexBibtexOptionsLA - > setText ( qt_ ( " &Options: " ) ) ;
}
2017-01-14 12:13:33 +01:00
void PrefLatex : : on_latexJBibtexCO_activated ( int n )
{
QString const jbibtex = latexJBibtexCO - > itemData ( n ) . toString ( ) ;
if ( jbibtex . isEmpty ( ) ) {
latexJBibtexED - > clear ( ) ;
latexJBibtexOptionsLA - > setText ( qt_ ( " Co&mmand: " ) ) ;
return ;
}
for ( LyXRC : : CommandSet : : const_iterator it = jbibtex_alternatives . begin ( ) ;
it ! = jbibtex_alternatives . end ( ) ; + + it ) {
QString const bib = toqstr ( * it ) ;
int ind = bib . indexOf ( " " ) ;
QString sel_command = bib . left ( ind ) ;
QString sel_options = ind < 0 ? QString ( ) : bib . mid ( ind + 1 ) ;
if ( jbibtex = = sel_command ) {
if ( ind < 0 )
latexJBibtexED - > clear ( ) ;
else
latexJBibtexED - > setText ( sel_options . trimmed ( ) ) ;
}
}
latexJBibtexOptionsLA - > setText ( qt_ ( " Opt&ions: " ) ) ;
}
2009-05-08 10:07:32 +00:00
void PrefLatex : : on_latexIndexCO_activated ( int n )
{
QString const index = latexIndexCO - > itemData ( n ) . toString ( ) ;
if ( index . isEmpty ( ) ) {
latexIndexED - > clear ( ) ;
latexIndexOptionsLA - > setText ( qt_ ( " Co&mmand: " ) ) ;
return ;
}
2009-10-17 22:52:16 +00:00
for ( LyXRC : : CommandSet : : const_iterator it = index_alternatives . begin ( ) ;
2009-05-08 10:07:32 +00:00
it ! = index_alternatives . end ( ) ; + + it ) {
QString const idx = toqstr ( * it ) ;
int ind = idx . indexOf ( " " ) ;
QString sel_command = idx . left ( ind ) ;
2009-05-27 22:24:05 +00:00
QString sel_options = ind < 0 ? QString ( ) : idx . mid ( ind + 1 ) ;
2009-05-08 10:07:32 +00:00
if ( index = = sel_command ) {
2009-05-27 22:24:05 +00:00
if ( ind < 0 )
2009-05-08 10:07:32 +00:00
latexIndexED - > clear ( ) ;
else
latexIndexED - > setText ( sel_options . trimmed ( ) ) ;
}
}
latexIndexOptionsLA - > setText ( qt_ ( " Op&tions: " ) ) ;
}
2014-12-19 11:35:37 +01:00
void PrefLatex : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
2009-05-28 00:25:40 +00:00
// If bibtex is not empty, bibopt contains the options, otherwise
// it is a customized bibtex command with options.
2009-05-08 10:07:32 +00:00
QString const bibtex = latexBibtexCO - > itemData (
latexBibtexCO - > currentIndex ( ) ) . toString ( ) ;
2009-05-28 00:25:40 +00:00
QString const bibopt = latexBibtexED - > text ( ) ;
2009-05-08 10:07:32 +00:00
if ( bibtex . isEmpty ( ) )
2009-05-28 00:25:40 +00:00
rc . bibtex_command = fromqstr ( bibopt ) ;
else if ( bibopt . isEmpty ( ) )
rc . bibtex_command = fromqstr ( bibtex ) ;
2009-05-08 10:07:32 +00:00
else
2009-05-28 00:25:40 +00:00
rc . bibtex_command = fromqstr ( bibtex ) + " " + fromqstr ( bibopt ) ;
2009-05-08 10:07:32 +00:00
2017-01-14 12:13:33 +01:00
// If jbibtex is not empty, jbibopt contains the options, otherwise
// it is a customized bibtex command with options.
QString const jbibtex = latexJBibtexCO - > itemData (
latexJBibtexCO - > currentIndex ( ) ) . toString ( ) ;
QString const jbibopt = latexJBibtexED - > text ( ) ;
if ( jbibtex . isEmpty ( ) )
rc . jbibtex_command = fromqstr ( jbibopt ) ;
else if ( jbibopt . isEmpty ( ) )
rc . jbibtex_command = fromqstr ( jbibtex ) ;
else
rc . jbibtex_command = fromqstr ( jbibtex ) + " " + fromqstr ( jbibopt ) ;
2009-05-28 00:25:40 +00:00
// If index is not empty, idxopt contains the options, otherwise
// it is a customized index command with options.
2009-05-08 10:07:32 +00:00
QString const index = latexIndexCO - > itemData (
latexIndexCO - > currentIndex ( ) ) . toString ( ) ;
2009-05-28 00:25:40 +00:00
QString const idxopt = latexIndexED - > text ( ) ;
2009-05-08 10:07:32 +00:00
if ( index . isEmpty ( ) )
2009-05-28 00:25:40 +00:00
rc . index_command = fromqstr ( idxopt ) ;
else if ( idxopt . isEmpty ( ) )
rc . index_command = fromqstr ( index ) ;
2009-05-08 10:07:32 +00:00
else
2009-05-28 00:25:40 +00:00
rc . index_command = fromqstr ( index ) + " " + fromqstr ( idxopt ) ;
2009-05-08 10:07:32 +00:00
2007-04-25 07:13:54 +00:00
rc . chktex_command = fromqstr ( latexChecktexED - > text ( ) ) ;
2009-04-16 06:43:43 +00:00
rc . jindex_command = fromqstr ( latexJIndexED - > text ( ) ) ;
2008-08-23 09:44:00 +00:00
rc . nomencl_command = fromqstr ( latexNomenclED - > text ( ) ) ;
2007-04-25 07:13:54 +00:00
rc . auto_reset_options = latexAutoresetCB - > isChecked ( ) ;
rc . view_dvi_paper_option = fromqstr ( latexDviPaperED - > text ( ) ) ;
2007-09-02 20:17:36 +00:00
# if defined(__CYGWIN__) || defined(_WIN32)
rc . windows_style_tex_paths = pathCB - > isChecked ( ) ;
# endif
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefLatex : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
2009-05-08 10:07:32 +00:00
latexBibtexCO - > clear ( ) ;
2017-01-13 19:18:35 +01:00
latexBibtexCO - > addItem ( qt_ ( " Automatic " ) , " automatic " ) ;
2009-05-08 10:07:32 +00:00
latexBibtexCO - > addItem ( qt_ ( " Custom " ) , QString ( ) ) ;
2009-10-17 22:52:16 +00:00
for ( LyXRC : : CommandSet : : const_iterator it = rc . bibtex_alternatives . begin ( ) ;
2009-05-08 10:07:32 +00:00
it ! = rc . bibtex_alternatives . end ( ) ; + + it ) {
QString const command = toqstr ( * it ) . left ( toqstr ( * it ) . indexOf ( " " ) ) ;
latexBibtexCO - > addItem ( command , command ) ;
}
bibtex_alternatives = rc . bibtex_alternatives ;
QString const bib = toqstr ( rc . bibtex_command ) ;
int ind = bib . indexOf ( " " ) ;
QString sel_command = bib . left ( ind ) ;
2009-05-27 22:24:05 +00:00
QString sel_options = ind < 0 ? QString ( ) : bib . mid ( ind + 1 ) ;
2009-05-08 10:07:32 +00:00
int pos = latexBibtexCO - > findData ( sel_command ) ;
if ( pos ! = - 1 ) {
latexBibtexCO - > setCurrentIndex ( pos ) ;
latexBibtexED - > setText ( sel_options . trimmed ( ) ) ;
latexBibtexOptionsLA - > setText ( qt_ ( " &Options: " ) ) ;
} else {
latexBibtexED - > setText ( toqstr ( rc . bibtex_command ) ) ;
latexBibtexCO - > setCurrentIndex ( 0 ) ;
2017-01-14 12:13:33 +01:00
latexBibtexOptionsLA - > setText ( qt_ ( " C&ommand: " ) ) ;
}
latexJBibtexCO - > clear ( ) ;
latexJBibtexCO - > addItem ( qt_ ( " Automatic " ) , " automatic " ) ;
latexJBibtexCO - > addItem ( qt_ ( " Custom " ) , QString ( ) ) ;
for ( LyXRC : : CommandSet : : const_iterator it = rc . jbibtex_alternatives . begin ( ) ;
it ! = rc . jbibtex_alternatives . end ( ) ; + + it ) {
QString const command = toqstr ( * it ) . left ( toqstr ( * it ) . indexOf ( " " ) ) ;
latexJBibtexCO - > addItem ( command , command ) ;
}
jbibtex_alternatives = rc . jbibtex_alternatives ;
QString const jbib = toqstr ( rc . jbibtex_command ) ;
ind = jbib . indexOf ( " " ) ;
sel_command = jbib . left ( ind ) ;
sel_options = ind < 0 ? QString ( ) : jbib . mid ( ind + 1 ) ;
pos = latexJBibtexCO - > findData ( sel_command ) ;
if ( pos ! = - 1 ) {
latexJBibtexCO - > setCurrentIndex ( pos ) ;
latexJBibtexED - > setText ( sel_options . trimmed ( ) ) ;
latexJBibtexOptionsLA - > setText ( qt_ ( " Opt&ions: " ) ) ;
} else {
latexJBibtexED - > setText ( toqstr ( rc . bibtex_command ) ) ;
latexJBibtexCO - > setCurrentIndex ( 0 ) ;
latexJBibtexOptionsLA - > setText ( qt_ ( " Co&mmand: " ) ) ;
2009-05-08 10:07:32 +00:00
}
latexIndexCO - > clear ( ) ;
latexIndexCO - > addItem ( qt_ ( " Custom " ) , QString ( ) ) ;
2009-10-17 22:52:16 +00:00
for ( LyXRC : : CommandSet : : const_iterator it = rc . index_alternatives . begin ( ) ;
2009-05-08 10:07:32 +00:00
it ! = rc . index_alternatives . end ( ) ; + + it ) {
QString const command = toqstr ( * it ) . left ( toqstr ( * it ) . indexOf ( " " ) ) ;
latexIndexCO - > addItem ( command , command ) ;
}
index_alternatives = rc . index_alternatives ;
QString const idx = toqstr ( rc . index_command ) ;
ind = idx . indexOf ( " " ) ;
sel_command = idx . left ( ind ) ;
2009-05-27 22:24:05 +00:00
sel_options = ind < 0 ? QString ( ) : idx . mid ( ind + 1 ) ;
2009-05-08 10:07:32 +00:00
pos = latexIndexCO - > findData ( sel_command ) ;
if ( pos ! = - 1 ) {
latexIndexCO - > setCurrentIndex ( pos ) ;
latexIndexED - > setText ( sel_options . trimmed ( ) ) ;
latexIndexOptionsLA - > setText ( qt_ ( " Op&tions: " ) ) ;
} else {
latexIndexED - > setText ( toqstr ( rc . index_command ) ) ;
latexIndexCO - > setCurrentIndex ( 0 ) ;
latexIndexOptionsLA - > setText ( qt_ ( " Co&mmand: " ) ) ;
}
2007-04-25 07:13:54 +00:00
latexChecktexED - > setText ( toqstr ( rc . chktex_command ) ) ;
2009-04-13 09:53:40 +00:00
latexJIndexED - > setText ( toqstr ( rc . jindex_command ) ) ;
2008-08-23 09:44:00 +00:00
latexNomenclED - > setText ( toqstr ( rc . nomencl_command ) ) ;
2007-04-25 07:13:54 +00:00
latexAutoresetCB - > setChecked ( rc . auto_reset_options ) ;
latexDviPaperED - > setText ( toqstr ( rc . view_dvi_paper_option ) ) ;
2007-09-02 20:17:36 +00:00
# if defined(__CYGWIN__) || defined(_WIN32)
pathCB - > setChecked ( rc . windows_style_tex_paths ) ;
# endif
2007-04-25 07:13:54 +00:00
}
/////////////////////////////////////////////////////////////////////
//
// PrefScreenFonts
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefScreenFonts : : PrefScreenFonts ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catLookAndFeel , N_ ( " Screen Fonts " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2007-10-25 20:36:17 +00:00
connect ( screenRomanCO , SIGNAL ( activated ( QString ) ) ,
2009-05-23 10:15:18 +00:00
this , SLOT ( selectRoman ( QString ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenSansCO , SIGNAL ( activated ( QString ) ) ,
2009-05-23 10:15:18 +00:00
this , SLOT ( selectSans ( QString ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenTypewriterCO , SIGNAL ( activated ( QString ) ) ,
2009-05-23 10:15:18 +00:00
this , SLOT ( selectTypewriter ( QString ) ) ) ;
2007-04-25 07:13:54 +00:00
QFontDatabase fontdb ;
QStringList families ( fontdb . families ( ) ) ;
for ( QStringList : : Iterator it = families . begin ( ) ; it ! = families . end ( ) ; + + it ) {
screenRomanCO - > addItem ( * it ) ;
screenSansCO - > addItem ( * it ) ;
screenTypewriterCO - > addItem ( * it ) ;
}
2007-10-25 20:36:17 +00:00
connect ( screenRomanCO , SIGNAL ( activated ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenSansCO , SIGNAL ( activated ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenTypewriterCO , SIGNAL ( activated ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
connect ( screenZoomSB , SIGNAL ( valueChanged ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenTinyED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenSmallestED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenSmallerED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenSmallED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenNormalED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenLargeED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenLargerED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenLargestED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenHugeED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( screenHugerED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-09-15 15:42:22 +00:00
screenTinyED - > setValidator ( new QDoubleValidator ( screenTinyED ) ) ;
screenSmallestED - > setValidator ( new QDoubleValidator ( screenSmallestED ) ) ;
screenSmallerED - > setValidator ( new QDoubleValidator ( screenSmallerED ) ) ;
screenSmallED - > setValidator ( new QDoubleValidator ( screenSmallED ) ) ;
screenNormalED - > setValidator ( new QDoubleValidator ( screenNormalED ) ) ;
screenLargeED - > setValidator ( new QDoubleValidator ( screenLargeED ) ) ;
screenLargerED - > setValidator ( new QDoubleValidator ( screenLargerED ) ) ;
screenLargestED - > setValidator ( new QDoubleValidator ( screenLargestED ) ) ;
screenHugeED - > setValidator ( new QDoubleValidator ( screenHugeED ) ) ;
screenHugerED - > setValidator ( new QDoubleValidator ( screenHugerED ) ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefScreenFonts : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
2007-10-25 18:27:08 +00:00
LyXRC const oldrc = rc ;
2007-04-25 07:13:54 +00:00
2007-11-24 22:15:52 +00:00
parseFontName ( screenRomanCO - > currentText ( ) ,
rc . roman_font_name , rc . roman_font_foundry ) ;
parseFontName ( screenSansCO - > currentText ( ) ,
rc . sans_font_name , rc . sans_font_foundry ) ;
parseFontName ( screenTypewriterCO - > currentText ( ) ,
rc . typewriter_font_name , rc . typewriter_font_foundry ) ;
2007-04-25 07:13:54 +00:00
2017-09-06 18:11:31 +02:00
rc . defaultZoom = screenZoomSB - > value ( ) ;
2019-06-14 16:42:02 +02:00
rc . font_sizes [ TINY_SIZE ] = widgetToDoubleStr ( screenTinyED ) ;
rc . font_sizes [ SCRIPT_SIZE ] = widgetToDoubleStr ( screenSmallestED ) ;
rc . font_sizes [ FOOTNOTE_SIZE ] = widgetToDoubleStr ( screenSmallerED ) ;
rc . font_sizes [ SMALL_SIZE ] = widgetToDoubleStr ( screenSmallED ) ;
rc . font_sizes [ NORMAL_SIZE ] = widgetToDoubleStr ( screenNormalED ) ;
rc . font_sizes [ LARGE_SIZE ] = widgetToDoubleStr ( screenLargeED ) ;
rc . font_sizes [ LARGER_SIZE ] = widgetToDoubleStr ( screenLargerED ) ;
rc . font_sizes [ LARGEST_SIZE ] = widgetToDoubleStr ( screenLargestED ) ;
rc . font_sizes [ HUGE_SIZE ] = widgetToDoubleStr ( screenHugeED ) ;
rc . font_sizes [ HUGER_SIZE ] = widgetToDoubleStr ( screenHugerED ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefScreenFonts : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
setComboxFont ( screenRomanCO , rc . roman_font_name ,
rc . roman_font_foundry ) ;
setComboxFont ( screenSansCO , rc . sans_font_name ,
rc . sans_font_foundry ) ;
setComboxFont ( screenTypewriterCO , rc . typewriter_font_name ,
rc . typewriter_font_foundry ) ;
2009-05-23 10:15:18 +00:00
selectRoman ( screenRomanCO - > currentText ( ) ) ;
selectSans ( screenSansCO - > currentText ( ) ) ;
selectTypewriter ( screenTypewriterCO - > currentText ( ) ) ;
2007-04-25 07:13:54 +00:00
2017-09-06 18:11:31 +02:00
screenZoomSB - > setValue ( rc . defaultZoom ) ;
2010-12-29 13:50:22 +00:00
updateScreenFontSizes ( rc ) ;
}
void PrefScreenFonts : : updateScreenFontSizes ( LyXRC const & rc )
{
2019-06-14 16:42:02 +02:00
doubleToWidget ( screenTinyED , rc . font_sizes [ TINY_SIZE ] ) ;
doubleToWidget ( screenSmallestED , rc . font_sizes [ SCRIPT_SIZE ] ) ;
doubleToWidget ( screenSmallerED , rc . font_sizes [ FOOTNOTE_SIZE ] ) ;
doubleToWidget ( screenSmallED , rc . font_sizes [ SMALL_SIZE ] ) ;
doubleToWidget ( screenNormalED , rc . font_sizes [ NORMAL_SIZE ] ) ;
doubleToWidget ( screenLargeED , rc . font_sizes [ LARGE_SIZE ] ) ;
doubleToWidget ( screenLargerED , rc . font_sizes [ LARGER_SIZE ] ) ;
doubleToWidget ( screenLargestED , rc . font_sizes [ LARGEST_SIZE ] ) ;
doubleToWidget ( screenHugeED , rc . font_sizes [ HUGE_SIZE ] ) ;
doubleToWidget ( screenHugerED , rc . font_sizes [ HUGER_SIZE ] ) ;
2007-04-25 07:13:54 +00:00
}
2007-10-25 20:36:17 +00:00
2009-05-23 10:15:18 +00:00
void PrefScreenFonts : : selectRoman ( const QString & name )
2007-04-25 07:13:54 +00:00
{
screenRomanFE - > set ( QFont ( name ) , name ) ;
}
2009-05-23 10:15:18 +00:00
void PrefScreenFonts : : selectSans ( const QString & name )
2007-04-25 07:13:54 +00:00
{
screenSansFE - > set ( QFont ( name ) , name ) ;
}
2009-05-23 10:15:18 +00:00
void PrefScreenFonts : : selectTypewriter ( const QString & name )
2007-04-25 07:13:54 +00:00
{
screenTypewriterFE - > set ( QFont ( name ) , name ) ;
}
/////////////////////////////////////////////////////////////////////
//
// PrefColors
//
/////////////////////////////////////////////////////////////////////
2007-09-11 21:27:57 +00:00
2008-05-19 20:52:24 +00:00
PrefColors : : PrefColors ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catLookAndFeel , N_ ( " Colors " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
// FIXME: all of this initialization should be put into the controller.
// See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg113301.html
// for some discussion of why that is not trivial.
2007-05-09 20:16:31 +00:00
QPixmap icon ( 32 , 32 ) ;
2007-10-25 12:41:02 +00:00
for ( int i = 0 ; i < Color_ignore ; + + i ) {
ColorCode lc = static_cast < ColorCode > ( i ) ;
if ( lc = = Color_none
2011-03-18 15:12:03 +00:00
| | lc = = Color_black
| | lc = = Color_white
| | lc = = Color_blue
2015-05-14 22:23:44 +02:00
| | lc = = Color_brown
2011-03-18 15:12:03 +00:00
| | lc = = Color_cyan
2015-05-14 22:23:44 +02:00
| | lc = = Color_darkgray
| | lc = = Color_gray
| | lc = = Color_green
| | lc = = Color_lightgray
| | lc = = Color_lime
2011-03-18 15:12:03 +00:00
| | lc = = Color_magenta
2015-05-14 22:23:44 +02:00
| | lc = = Color_olive
| | lc = = Color_orange
| | lc = = Color_pink
| | lc = = Color_purple
| | lc = = Color_red
| | lc = = Color_teal
| | lc = = Color_violet
2011-03-18 15:12:03 +00:00
| | lc = = Color_yellow
| | lc = = Color_inherit
| | lc = = Color_ignore )
continue ;
2007-04-25 07:13:54 +00:00
lcolors_ . push_back ( lc ) ;
2007-07-30 13:48:46 +00:00
}
2015-11-16 08:19:16 +01:00
qSort ( lcolors_ . begin ( ) , lcolors_ . end ( ) , ColorSorter ) ;
2007-10-25 12:41:02 +00:00
vector < ColorCode > : : const_iterator cit = lcolors_ . begin ( ) ;
vector < ColorCode > : : const_iterator const end = lcolors_ . end ( ) ;
2007-09-11 21:27:57 +00:00
for ( ; cit ! = end ; + + cit ) {
2010-03-31 00:46:50 +00:00
( void ) new QListWidgetItem ( QIcon ( icon ) ,
2007-07-30 13:48:46 +00:00
toqstr ( lcolor . getGUIName ( * cit ) ) , lyxObjectsLW ) ;
2007-04-25 07:13:54 +00:00
}
2007-05-09 20:16:31 +00:00
curcolors_ . resize ( lcolors_ . size ( ) ) ;
newcolors_ . resize ( lcolors_ . size ( ) ) ;
2007-04-25 07:13:54 +00:00
// End initialization
connect ( colorChangePB , SIGNAL ( clicked ( ) ) ,
2009-05-23 10:15:24 +00:00
this , SLOT ( changeColor ( ) ) ) ;
2018-12-22 18:44:58 +01:00
connect ( colorResetPB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( resetColor ( ) ) ) ;
connect ( colorResetAllPB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( resetAllColor ( ) ) ) ;
2007-05-09 20:09:03 +00:00
connect ( lyxObjectsLW , SIGNAL ( itemSelectionChanged ( ) ) ,
2009-05-23 10:15:24 +00:00
this , SLOT ( changeLyxObjectsSelection ( ) ) ) ;
2007-04-25 07:13:54 +00:00
connect ( lyxObjectsLW , SIGNAL ( itemActivated ( QListWidgetItem * ) ) ,
2009-05-23 10:15:24 +00:00
this , SLOT ( changeColor ( ) ) ) ;
2010-08-08 23:11:02 +00:00
connect ( syscolorsCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2010-08-09 12:15:02 +00:00
connect ( syscolorsCB , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( changeSysColor ( ) ) ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefColors : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
2010-08-08 23:11:02 +00:00
LyXRC oldrc = rc ;
2007-09-15 15:42:22 +00:00
for ( unsigned int i = 0 ; i < lcolors_ . size ( ) ; + + i )
if ( curcolors_ [ i ] ! = newcolors_ [ i ] )
2008-05-19 20:52:24 +00:00
form_ - > setColor ( lcolors_ [ i ] , newcolors_ [ i ] ) ;
2010-08-08 23:11:02 +00:00
rc . use_system_colors = syscolorsCB - > isChecked ( ) ;
if ( oldrc . use_system_colors ! = rc . use_system_colors )
guiApp - > colorCache ( ) . clear ( ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefColors : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
2018-12-22 18:44:58 +01:00
for ( size_type i = 0 ; i < lcolors_ . size ( ) ; + + i ) {
2010-08-09 12:15:02 +00:00
QColor color = QColor ( guiApp - > colorCache ( ) . get ( lcolors_ [ i ] , false ) ) ;
2007-05-09 20:16:31 +00:00
QPixmap coloritem ( 32 , 32 ) ;
coloritem . fill ( color ) ;
2018-12-22 18:44:58 +01:00
lyxObjectsLW - > item ( int ( i ) ) - > setIcon ( QIcon ( coloritem ) ) ;
2007-05-09 20:16:31 +00:00
newcolors_ [ i ] = curcolors_ [ i ] = color . name ( ) ;
}
2010-08-08 23:11:02 +00:00
syscolorsCB - > setChecked ( rc . use_system_colors ) ;
2009-05-23 10:15:24 +00:00
changeLyxObjectsSelection ( ) ;
2018-12-22 18:44:58 +01:00
setDisabledResets ( ) ;
2007-04-25 07:13:54 +00:00
}
2008-03-08 16:15:10 +00:00
2009-05-23 10:15:24 +00:00
void PrefColors : : changeColor ( )
2007-04-25 07:13:54 +00:00
{
int const row = lyxObjectsLW - > currentRow ( ) ;
2007-05-09 20:09:03 +00:00
// just to be sure
2007-09-15 15:42:22 +00:00
if ( row < 0 )
return ;
2007-05-09 20:09:03 +00:00
2018-12-22 18:44:58 +01:00
QString const color = newcolors_ [ size_t ( row ) ] ;
QColor const c = QColorDialog : : getColor ( QColor ( color ) , qApp - > focusWidget ( ) ) ;
2007-04-25 07:13:54 +00:00
2018-12-22 18:44:58 +01:00
if ( setColor ( row , c , color ) ) {
setDisabledResets ( ) ;
2007-04-25 07:13:54 +00:00
// emit signal
changed ( ) ;
}
}
2018-12-22 18:44:58 +01:00
void PrefColors : : resetColor ( )
{
int const row = lyxObjectsLW - > currentRow ( ) ;
// just to be sure
if ( row < 0 )
return ;
QString const color = newcolors_ [ size_t ( row ) ] ;
QColor const c = getDefaultColorByRow ( row ) ;
if ( setColor ( row , c , color ) ) {
setDisabledResets ( ) ;
// emit signal
changed ( ) ;
}
}
void PrefColors : : resetAllColor ( )
{
bool isChanged = false ;
colorResetAllPB - > setDisabled ( true ) ;
for ( int irow = 0 , count = lyxObjectsLW - > count ( ) ; irow < count ; + + irow ) {
QString const color = newcolors_ [ size_t ( irow ) ] ;
QColor const c = getDefaultColorByRow ( irow ) ;
if ( setColor ( irow , c , color ) )
isChanged = true ;
}
if ( isChanged ) {
setDisabledResets ( ) ;
// emit signal
changed ( ) ;
}
}
bool PrefColors : : setColor ( int const row , QColor const new_color ,
QString const old_color )
{
if ( new_color . isValid ( ) & & new_color . name ( ) ! = old_color ) {
newcolors_ [ size_t ( row ) ] = new_color . name ( ) ;
QPixmap coloritem ( 32 , 32 ) ;
coloritem . fill ( new_color ) ;
lyxObjectsLW - > item ( row ) - > setIcon ( QIcon ( coloritem ) ) ;
return true ;
}
return false ;
}
void PrefColors : : setDisabledResets ( )
{
int const row = lyxObjectsLW - > currentRow ( ) ;
// set disable reset buttons ...
if ( row > = 0 )
colorResetPB - > setDisabled ( isDefaultColor ( row , newcolors_ [ size_t ( row ) ] ) ) ;
colorResetAllPB - > setDisabled ( true ) ;
// ... in between process qt events to give quicker visual feedback to the user ...
guiApp - > processEvents ( ) ;
// ... set disable Reset All button
for ( int irow = 0 , count = lyxObjectsLW - > count ( ) ; irow < count ; + + irow ) {
if ( ! isDefaultColor ( irow , newcolors_ [ size_t ( irow ) ] ) ) {
colorResetAllPB - > setDisabled ( false ) ;
// the break condition might hide performance issues
// if a non-default color is at the top of the list
break ;
}
}
}
bool PrefColors : : isDefaultColor ( int const row , QString const color )
{
return color = = getDefaultColorByRow ( row ) . name ( ) ;
}
QColor PrefColors : : getDefaultColorByRow ( int const row )
{
ColorSet const defaultcolor ;
return defaultcolor . getX11Name ( lcolors_ [ size_t ( row ) ] ) . c_str ( ) ;
}
2010-08-09 12:15:02 +00:00
void PrefColors : : changeSysColor ( )
{
for ( int row = 0 ; row < lyxObjectsLW - > count ( ) ; + + row ) {
// skip colors that are taken from system palette
2016-11-06 08:45:09 +01:00
bool const disable = syscolorsCB - > isChecked ( )
2018-12-22 18:44:58 +01:00
& & guiApp - > colorCache ( ) . isSystem ( lcolors_ [ size_t ( row ) ] ) ;
2010-08-09 12:15:02 +00:00
2016-11-06 08:45:09 +01:00
QListWidgetItem * const item = lyxObjectsLW - > item ( row ) ;
Qt : : ItemFlags const flags = item - > flags ( ) ;
2010-08-09 12:15:02 +00:00
2016-11-06 08:45:09 +01:00
if ( disable )
item - > setFlags ( flags & ~ Qt : : ItemIsEnabled ) ;
else
item - > setFlags ( flags | Qt : : ItemIsEnabled ) ;
}
2010-08-09 12:15:02 +00:00
}
2018-12-22 18:44:58 +01:00
2009-05-23 10:15:24 +00:00
void PrefColors : : changeLyxObjectsSelection ( )
2007-05-09 20:09:03 +00:00
{
2018-12-22 18:44:58 +01:00
int currentRow = lyxObjectsLW - > currentRow ( ) ;
colorChangePB - > setDisabled ( currentRow < 0 ) ;
if ( currentRow < 0 )
colorResetPB - > setDisabled ( true ) ;
else
colorResetPB - > setDisabled (
isDefaultColor ( currentRow , newcolors_ [ size_t ( currentRow ) ] ) ) ;
2007-05-09 20:09:03 +00:00
}
2007-04-25 07:13:54 +00:00
/////////////////////////////////////////////////////////////////////
//
// PrefDisplay
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefDisplay : : PrefDisplay ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catLookAndFeel , N_ ( " Display " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2008-06-16 17:16:15 +00:00
connect ( displayGraphicsCB , SIGNAL ( toggled ( bool ) ) , this , SIGNAL ( changed ( ) ) ) ;
2008-06-13 07:34:55 +00:00
connect ( instantPreviewCO , SIGNAL ( activated ( int ) ) , this , SIGNAL ( changed ( ) ) ) ;
2009-09-21 00:44:43 +00:00
connect ( previewSizeSB , SIGNAL ( valueChanged ( double ) ) , this , SIGNAL ( changed ( ) ) ) ;
connect ( paragraphMarkerCB , SIGNAL ( toggled ( bool ) ) , this , SIGNAL ( changed ( ) ) ) ;
}
void PrefDisplay : : on_instantPreviewCO_currentIndexChanged ( int index )
{
2011-01-03 17:21:22 +00:00
previewSizeSB - > setEnabled ( index ! = 0 ) ;
}
2014-12-19 11:35:37 +01:00
void PrefDisplay : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
switch ( instantPreviewCO - > currentIndex ( ) ) {
2011-01-03 17:21:22 +00:00
case 0 :
rc . preview = LyXRC : : PREVIEW_OFF ;
break ;
case 1 :
2019-02-26 16:37:41 +01:00
rc . preview = LyXRC : : PREVIEW_NO_MATH ;
2011-01-03 17:21:22 +00:00
break ;
case 2 :
2019-02-26 16:37:41 +01:00
rc . preview = LyXRC : : PREVIEW_ON ;
2011-01-03 17:21:22 +00:00
break ;
2007-04-25 07:13:54 +00:00
}
2008-06-13 07:34:55 +00:00
rc . display_graphics = displayGraphicsCB - > isChecked ( ) ;
2009-09-21 00:44:43 +00:00
rc . preview_scale_factor = previewSizeSB - > value ( ) ;
2009-08-19 22:46:43 +00:00
rc . paragraph_markers = paragraphMarkerCB - > isChecked ( ) ;
2007-04-25 07:13:54 +00:00
2007-08-10 11:47:12 +00:00
// FIXME!! The graphics cache no longer has a changeDisplay method.
2007-04-25 07:13:54 +00:00
#if 0
if ( old_value ! = rc . display_graphics ) {
2007-10-25 20:36:17 +00:00
graphics : : GCache & gc = graphics : : GCache : : get ( ) ;
2007-04-25 07:13:54 +00:00
gc . changeDisplay ( ) ;
}
# endif
}
2014-12-19 11:35:37 +01:00
void PrefDisplay : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
switch ( rc . preview ) {
case LyXRC : : PREVIEW_OFF :
instantPreviewCO - > setCurrentIndex ( 0 ) ;
break ;
case LyXRC : : PREVIEW_NO_MATH :
instantPreviewCO - > setCurrentIndex ( 1 ) ;
break ;
case LyXRC : : PREVIEW_ON :
instantPreviewCO - > setCurrentIndex ( 2 ) ;
break ;
}
2008-06-13 07:34:55 +00:00
displayGraphicsCB - > setChecked ( rc . display_graphics ) ;
2009-09-21 00:44:43 +00:00
previewSizeSB - > setValue ( rc . preview_scale_factor ) ;
2009-08-19 22:46:43 +00:00
paragraphMarkerCB - > setChecked ( rc . paragraph_markers ) ;
2011-01-03 17:21:22 +00:00
previewSizeSB - > setEnabled (
rc . display_graphics
& & rc . preview ! = LyXRC : : PREVIEW_OFF ) ;
2007-04-25 07:13:54 +00:00
}
/////////////////////////////////////////////////////////////////////
//
// PrefPaths
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefPaths : : PrefPaths ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( QString ( ) , N_ ( " Paths " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2009-11-22 22:18:24 +00:00
2009-05-23 10:30:47 +00:00
connect ( workingDirPB , SIGNAL ( clicked ( ) ) , this , SLOT ( selectWorkingdir ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( workingDirED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2009-11-22 22:18:24 +00:00
connect ( templateDirPB , SIGNAL ( clicked ( ) ) , this , SLOT ( selectTemplatedir ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( templateDirED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2009-11-22 22:18:24 +00:00
connect ( exampleDirPB , SIGNAL ( clicked ( ) ) , this , SLOT ( selectExampledir ( ) ) ) ;
connect ( exampleDirED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2009-11-22 22:18:24 +00:00
connect ( backupDirPB , SIGNAL ( clicked ( ) ) , this , SLOT ( selectBackupdir ( ) ) ) ;
connect ( backupDirED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2009-11-22 22:18:24 +00:00
connect ( lyxserverDirPB , SIGNAL ( clicked ( ) ) , this , SLOT ( selectLyxPipe ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( lyxserverDirED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2009-11-22 22:18:24 +00:00
connect ( thesaurusDirPB , SIGNAL ( clicked ( ) ) , this , SLOT ( selectThesaurusdir ( ) ) ) ;
2008-11-16 18:48:25 +00:00
connect ( thesaurusDirED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2009-11-22 22:18:24 +00:00
connect ( tempDirPB , SIGNAL ( clicked ( ) ) , this , SLOT ( selectTempdir ( ) ) ) ;
connect ( tempDirED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2009-11-22 22:18:24 +00:00
2011-02-08 14:48:46 +00:00
# if defined(USE_HUNSPELL)
2009-11-22 22:18:24 +00:00
connect ( hunspellDirPB , SIGNAL ( clicked ( ) ) , this , SLOT ( selectHunspelldir ( ) ) ) ;
2009-11-22 22:15:20 +00:00
connect ( hunspellDirED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2011-02-08 14:48:46 +00:00
# else
hunspellDirPB - > setEnabled ( false ) ;
hunspellDirED - > setEnabled ( false ) ;
# endif
2009-11-22 22:18:24 +00:00
connect ( pathPrefixED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
Introduce the possibility of setting a prefix for the TEXINPUTS environment
variable. This is done in the preferences, much like as the PATH prefix.
A single '.' in the paths will get replaced with the current document dir
and also non-absolute paths will be prefixed with that dir.
The default semantics of TEXINPUTS apply, such that, for example, if a
path is terminated with a double slash, all subdirectories will be also
searched by both the TeX engine and ancillary programs such as dvi
previewers or dvips. As an example, if the prefix is set to ".:figs", the
TEXINPUTS variable will be set as ".:<docdir>:<docdir>/figs:$ORIGTEXINPUTS",
where <docdir> is the document directory.
The initial '.' is necessary to address the actual current dir (this will
be the temp dir at preview time), while if TEXINPUTS was initially unset,
such that $ORIGTEXINPUTS is empty, a colon (or semicolon on Windows) will
end the path list. This is very important, because we don't want to replace
the system directories but to complement them and, in order to do that, an
empty element has to be present in the list. Indeed, according to the
TEXINPUTS semantics, an empty element means the standard search path.
This works whether TEXINPUTS is originally set or not, because if the
original TEXINPUTS starts with a colon (meaning that the standard search
path is wanted there) we will have an empty element at that point,
otherwise the final colon will simply serve as a path separator.
Of course, on Windows a ';' has to be used as a path separator. LyX will
take care of transforming the platform path list into one understandable
by the TeX engine. For example, this will be the case for a Cygwin version
of LyX using a native Windows TeX engine or viceversa. I tested all of
this and it works for me.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38681 a592a061-630c-0410-9148-cb99ea01b6c8
2011-05-09 23:25:51 +00:00
connect ( texinputsPrefixED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2011-09-12 14:22:05 +00:00
pathPrefixED - > setValidator ( new NoNewLineValidator ( pathPrefixED ) ) ;
texinputsPrefixED - > setValidator ( new NoNewLineValidator ( texinputsPrefixED ) ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefPaths : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
rc . document_path = internal_path ( fromqstr ( workingDirED - > text ( ) ) ) ;
2007-11-25 18:26:58 +00:00
rc . example_path = internal_path ( fromqstr ( exampleDirED - > text ( ) ) ) ;
2007-04-25 07:13:54 +00:00
rc . template_path = internal_path ( fromqstr ( templateDirED - > text ( ) ) ) ;
rc . backupdir_path = internal_path ( fromqstr ( backupDirED - > text ( ) ) ) ;
rc . tempdir_path = internal_path ( fromqstr ( tempDirED - > text ( ) ) ) ;
2008-11-16 18:48:25 +00:00
rc . thesaurusdir_path = internal_path ( fromqstr ( thesaurusDirED - > text ( ) ) ) ;
2009-08-08 17:05:31 +00:00
rc . hunspelldir_path = internal_path ( fromqstr ( hunspellDirED - > text ( ) ) ) ;
2007-04-25 07:13:54 +00:00
rc . path_prefix = internal_path_list ( fromqstr ( pathPrefixED - > text ( ) ) ) ;
Introduce the possibility of setting a prefix for the TEXINPUTS environment
variable. This is done in the preferences, much like as the PATH prefix.
A single '.' in the paths will get replaced with the current document dir
and also non-absolute paths will be prefixed with that dir.
The default semantics of TEXINPUTS apply, such that, for example, if a
path is terminated with a double slash, all subdirectories will be also
searched by both the TeX engine and ancillary programs such as dvi
previewers or dvips. As an example, if the prefix is set to ".:figs", the
TEXINPUTS variable will be set as ".:<docdir>:<docdir>/figs:$ORIGTEXINPUTS",
where <docdir> is the document directory.
The initial '.' is necessary to address the actual current dir (this will
be the temp dir at preview time), while if TEXINPUTS was initially unset,
such that $ORIGTEXINPUTS is empty, a colon (or semicolon on Windows) will
end the path list. This is very important, because we don't want to replace
the system directories but to complement them and, in order to do that, an
empty element has to be present in the list. Indeed, according to the
TEXINPUTS semantics, an empty element means the standard search path.
This works whether TEXINPUTS is originally set or not, because if the
original TEXINPUTS starts with a colon (meaning that the standard search
path is wanted there) we will have an empty element at that point,
otherwise the final colon will simply serve as a path separator.
Of course, on Windows a ';' has to be used as a path separator. LyX will
take care of transforming the platform path list into one understandable
by the TeX engine. For example, this will be the case for a Cygwin version
of LyX using a native Windows TeX engine or viceversa. I tested all of
this and it works for me.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38681 a592a061-630c-0410-9148-cb99ea01b6c8
2011-05-09 23:25:51 +00:00
rc . texinputs_prefix = internal_path_list ( fromqstr ( texinputsPrefixED - > text ( ) ) ) ;
2007-04-25 07:13:54 +00:00
// FIXME: should be a checkbox only
rc . lyxpipes = internal_path ( fromqstr ( lyxserverDirED - > text ( ) ) ) ;
}
2014-12-19 11:35:37 +01:00
void PrefPaths : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
workingDirED - > setText ( toqstr ( external_path ( rc . document_path ) ) ) ;
2007-11-25 18:26:58 +00:00
exampleDirED - > setText ( toqstr ( external_path ( rc . example_path ) ) ) ;
2007-04-25 07:13:54 +00:00
templateDirED - > setText ( toqstr ( external_path ( rc . template_path ) ) ) ;
backupDirED - > setText ( toqstr ( external_path ( rc . backupdir_path ) ) ) ;
tempDirED - > setText ( toqstr ( external_path ( rc . tempdir_path ) ) ) ;
2008-11-16 18:48:25 +00:00
thesaurusDirED - > setText ( toqstr ( external_path ( rc . thesaurusdir_path ) ) ) ;
2009-08-08 17:05:31 +00:00
hunspellDirED - > setText ( toqstr ( external_path ( rc . hunspelldir_path ) ) ) ;
2007-04-25 07:13:54 +00:00
pathPrefixED - > setText ( toqstr ( external_path_list ( rc . path_prefix ) ) ) ;
Introduce the possibility of setting a prefix for the TEXINPUTS environment
variable. This is done in the preferences, much like as the PATH prefix.
A single '.' in the paths will get replaced with the current document dir
and also non-absolute paths will be prefixed with that dir.
The default semantics of TEXINPUTS apply, such that, for example, if a
path is terminated with a double slash, all subdirectories will be also
searched by both the TeX engine and ancillary programs such as dvi
previewers or dvips. As an example, if the prefix is set to ".:figs", the
TEXINPUTS variable will be set as ".:<docdir>:<docdir>/figs:$ORIGTEXINPUTS",
where <docdir> is the document directory.
The initial '.' is necessary to address the actual current dir (this will
be the temp dir at preview time), while if TEXINPUTS was initially unset,
such that $ORIGTEXINPUTS is empty, a colon (or semicolon on Windows) will
end the path list. This is very important, because we don't want to replace
the system directories but to complement them and, in order to do that, an
empty element has to be present in the list. Indeed, according to the
TEXINPUTS semantics, an empty element means the standard search path.
This works whether TEXINPUTS is originally set or not, because if the
original TEXINPUTS starts with a colon (meaning that the standard search
path is wanted there) we will have an empty element at that point,
otherwise the final colon will simply serve as a path separator.
Of course, on Windows a ';' has to be used as a path separator. LyX will
take care of transforming the platform path list into one understandable
by the TeX engine. For example, this will be the case for a Cygwin version
of LyX using a native Windows TeX engine or viceversa. I tested all of
this and it works for me.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38681 a592a061-630c-0410-9148-cb99ea01b6c8
2011-05-09 23:25:51 +00:00
texinputsPrefixED - > setText ( toqstr ( external_path_list ( rc . texinputs_prefix ) ) ) ;
2007-04-25 07:13:54 +00:00
// FIXME: should be a checkbox only
lyxserverDirED - > setText ( toqstr ( external_path ( rc . lyxpipes ) ) ) ;
}
2009-05-23 10:30:47 +00:00
void PrefPaths : : selectExampledir ( )
2007-11-25 18:26:58 +00:00
{
2008-04-20 19:56:01 +00:00
QString file = browseDir ( internalPath ( exampleDirED - > text ( ) ) ,
2008-03-05 23:10:53 +00:00
qt_ ( " Select directory for example files " ) ) ;
if ( ! file . isEmpty ( ) )
exampleDirED - > setText ( file ) ;
2007-11-25 18:26:58 +00:00
}
2009-05-23 10:30:47 +00:00
void PrefPaths : : selectTemplatedir ( )
2007-04-25 07:13:54 +00:00
{
2008-04-20 19:56:01 +00:00
QString file = browseDir ( internalPath ( templateDirED - > text ( ) ) ,
2008-03-05 23:10:53 +00:00
qt_ ( " Select a document templates directory " ) ) ;
if ( ! file . isEmpty ( ) )
templateDirED - > setText ( file ) ;
2007-04-25 07:13:54 +00:00
}
2009-05-23 10:30:47 +00:00
void PrefPaths : : selectTempdir ( )
2007-04-25 07:13:54 +00:00
{
2008-04-20 19:56:01 +00:00
QString file = browseDir ( internalPath ( tempDirED - > text ( ) ) ,
2008-03-05 23:10:53 +00:00
qt_ ( " Select a temporary directory " ) ) ;
if ( ! file . isEmpty ( ) )
tempDirED - > setText ( file ) ;
2007-04-25 07:13:54 +00:00
}
2009-05-23 10:30:47 +00:00
void PrefPaths : : selectBackupdir ( )
2007-04-25 07:13:54 +00:00
{
2008-04-20 19:56:01 +00:00
QString file = browseDir ( internalPath ( backupDirED - > text ( ) ) ,
2008-03-05 23:10:53 +00:00
qt_ ( " Select a backups directory " ) ) ;
if ( ! file . isEmpty ( ) )
backupDirED - > setText ( file ) ;
2007-04-25 07:13:54 +00:00
}
2009-05-23 10:30:47 +00:00
void PrefPaths : : selectWorkingdir ( )
2007-04-25 07:13:54 +00:00
{
2008-04-20 19:56:01 +00:00
QString file = browseDir ( internalPath ( workingDirED - > text ( ) ) ,
2008-03-05 23:10:53 +00:00
qt_ ( " Select a document directory " ) ) ;
if ( ! file . isEmpty ( ) )
workingDirED - > setText ( file ) ;
2007-04-25 07:13:54 +00:00
}
2009-05-23 10:30:47 +00:00
void PrefPaths : : selectThesaurusdir ( )
2008-11-16 18:48:25 +00:00
{
QString file = browseDir ( internalPath ( thesaurusDirED - > text ( ) ) ,
qt_ ( " Set the path to the thesaurus dictionaries " ) ) ;
if ( ! file . isEmpty ( ) )
thesaurusDirED - > setText ( file ) ;
}
2009-08-08 17:05:31 +00:00
void PrefPaths : : selectHunspelldir ( )
{
QString file = browseDir ( internalPath ( hunspellDirED - > text ( ) ) ,
qt_ ( " Set the path to the Hunspell dictionaries " ) ) ;
if ( ! file . isEmpty ( ) )
hunspellDirED - > setText ( file ) ;
}
2009-05-23 10:30:47 +00:00
void PrefPaths : : selectLyxPipe ( )
2007-04-25 07:13:54 +00:00
{
2008-03-05 23:10:53 +00:00
QString file = form_ - > browse ( internalPath ( lyxserverDirED - > text ( ) ) ,
qt_ ( " Give a filename for the LyX server pipe " ) ) ;
if ( ! file . isEmpty ( ) )
lyxserverDirED - > setText ( file ) ;
2007-04-25 07:13:54 +00:00
}
/////////////////////////////////////////////////////////////////////
//
// PrefSpellchecker
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefSpellchecker : : PrefSpellchecker ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catLanguage , N_ ( " Spellchecker " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2010-07-08 07:56:29 +00:00
// FIXME: this check should test the target platform (darwin)
2010-07-11 21:30:47 +00:00
# if defined(USE_MACOSX_PACKAGING)
2010-08-14 15:19:05 +00:00
spellcheckerCB - > addItem ( qt_ ( " Native " ) , QString ( " native " ) ) ;
2010-07-08 07:56:29 +00:00
# define CONNECT_APPLESPELL
# else
# undef CONNECT_APPLESPELL
# endif
2009-11-23 14:03:19 +00:00
# if defined(USE_ASPELL)
2010-12-03 15:14:00 +00:00
spellcheckerCB - > addItem ( qt_ ( " Aspell " ) , QString ( " aspell " ) ) ;
2010-01-22 15:26:38 +00:00
# endif
# if defined(USE_ENCHANT)
2010-12-03 15:14:00 +00:00
spellcheckerCB - > addItem ( qt_ ( " Enchant " ) , QString ( " enchant " ) ) ;
2009-11-23 14:03:19 +00:00
# endif
# if defined(USE_HUNSPELL)
2010-12-03 15:14:00 +00:00
spellcheckerCB - > addItem ( qt_ ( " Hunspell " ) , QString ( " hunspell " ) ) ;
2009-11-23 14:03:19 +00:00
# endif
2009-08-08 17:05:31 +00:00
2010-07-08 07:56:29 +00:00
# if defined(CONNECT_APPLESPELL) || defined(USE_ASPELL) || defined(USE_ENCHANT) || defined(USE_HUNSPELL)
2009-11-23 14:03:19 +00:00
connect ( spellcheckerCB , SIGNAL ( currentIndexChanged ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( altLanguageED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( escapeCharactersED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( compoundWordCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( spellcheckContinuouslyCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2010-02-13 16:22:39 +00:00
connect ( spellcheckNotesCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2011-09-12 14:22:05 +00:00
altLanguageED - > setValidator ( new NoNewLineValidator ( altLanguageED ) ) ;
escapeCharactersED - > setValidator ( new NoNewLineValidator ( escapeCharactersED ) ) ;
2010-03-08 13:22:56 +00:00
# else
2009-11-23 14:03:19 +00:00
spellcheckerCB - > setEnabled ( false ) ;
altLanguageED - > setEnabled ( false ) ;
escapeCharactersED - > setEnabled ( false ) ;
compoundWordCB - > setEnabled ( false ) ;
spellcheckContinuouslyCB - > setEnabled ( false ) ;
2010-02-13 16:22:39 +00:00
spellcheckNotesCB - > setEnabled ( false ) ;
2010-03-08 13:22:56 +00:00
# endif
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefSpellchecker : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
2011-01-16 20:30:23 +00:00
string const speller = fromqstr ( spellcheckerCB - >
itemData ( spellcheckerCB - > currentIndex ( ) ) . toString ( ) ) ;
if ( ! speller . empty ( ) )
rc . spellchecker = speller ;
2008-11-15 18:47:25 +00:00
rc . spellchecker_alt_lang = fromqstr ( altLanguageED - > text ( ) ) ;
rc . spellchecker_esc_chars = fromqstr ( escapeCharactersED - > text ( ) ) ;
rc . spellchecker_accept_compound = compoundWordCB - > isChecked ( ) ;
2009-03-29 19:57:30 +00:00
rc . spellcheck_continuously = spellcheckContinuouslyCB - > isChecked ( ) ;
2010-02-13 16:22:39 +00:00
rc . spellcheck_notes = spellcheckNotesCB - > isChecked ( ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefSpellchecker : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
2010-01-22 15:26:38 +00:00
spellcheckerCB - > setCurrentIndex (
spellcheckerCB - > findData ( toqstr ( rc . spellchecker ) ) ) ;
2008-11-15 18:47:25 +00:00
altLanguageED - > setText ( toqstr ( rc . spellchecker_alt_lang ) ) ;
escapeCharactersED - > setText ( toqstr ( rc . spellchecker_esc_chars ) ) ;
compoundWordCB - > setChecked ( rc . spellchecker_accept_compound ) ;
2010-07-13 14:13:47 +00:00
spellcheckContinuouslyCB - > setChecked ( rc . spellcheck_continuously ) ;
2010-02-13 16:22:39 +00:00
spellcheckNotesCB - > setChecked ( rc . spellcheck_notes ) ;
2007-04-25 07:13:54 +00:00
}
2010-09-29 19:05:28 +00:00
void PrefSpellchecker : : on_spellcheckerCB_currentIndexChanged ( int index )
{
QString spellchecker = spellcheckerCB - > itemData ( index ) . toString ( ) ;
2014-12-07 18:35:28 +01:00
2011-07-21 15:33:56 +00:00
compoundWordCB - > setEnabled ( spellchecker = = QString ( " aspell " ) ) ;
2010-09-29 19:05:28 +00:00
}
2014-12-07 18:35:28 +01:00
2007-04-25 07:13:54 +00:00
/////////////////////////////////////////////////////////////////////
//
// PrefConverters
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefConverters : : PrefConverters ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catFiles , N_ ( " Converters " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
connect ( converterNewPB , SIGNAL ( clicked ( ) ) ,
2009-05-23 10:30:52 +00:00
this , SLOT ( updateConverter ( ) ) ) ;
2007-04-25 07:13:54 +00:00
connect ( converterRemovePB , SIGNAL ( clicked ( ) ) ,
2009-05-23 10:30:52 +00:00
this , SLOT ( removeConverter ( ) ) ) ;
2007-04-25 07:13:54 +00:00
connect ( converterModifyPB , SIGNAL ( clicked ( ) ) ,
2009-05-23 10:30:52 +00:00
this , SLOT ( updateConverter ( ) ) ) ;
2007-04-25 07:13:54 +00:00
connect ( convertersLW , SIGNAL ( currentRowChanged ( int ) ) ,
2009-05-23 10:30:52 +00:00
this , SLOT ( switchConverter ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( converterFromCO , SIGNAL ( activated ( QString ) ) ,
2009-05-23 12:52:23 +00:00
this , SLOT ( changeConverter ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( converterToCO , SIGNAL ( activated ( QString ) ) ,
2009-05-23 12:52:23 +00:00
this , SLOT ( changeConverter ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( converterED , SIGNAL ( textEdited ( QString ) ) ,
2009-05-23 12:52:23 +00:00
this , SLOT ( changeConverter ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( converterFlagED , SIGNAL ( textEdited ( QString ) ) ,
2009-05-23 12:52:23 +00:00
this , SLOT ( changeConverter ( ) ) ) ;
2007-04-25 07:13:54 +00:00
connect ( converterNewPB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( converterRemovePB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( converterModifyPB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( maxAgeLE , SIGNAL ( textEdited ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2016-11-05 01:00:44 +01:00
connect ( needauthForbiddenCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-04-25 07:13:54 +00:00
2011-09-12 14:22:05 +00:00
converterED - > setValidator ( new NoNewLineValidator ( converterED ) ) ;
converterFlagED - > setValidator ( new NoNewLineValidator ( converterFlagED ) ) ;
2017-04-02 14:55:33 +02:00
maxAgeLE - > setValidator ( new QDoubleValidator ( 0 , HUGE_VAL , 6 , maxAgeLE ) ) ;
2007-09-02 20:17:36 +00:00
//converterDefGB->setFocusProxy(convertersLW);
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefConverters : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
rc . use_converter_cache = cacheCB - > isChecked ( ) ;
2016-11-05 01:00:44 +01:00
rc . use_converter_needauth_forbidden = needauthForbiddenCB - > isChecked ( ) ;
rc . use_converter_needauth = needauthCB - > isChecked ( ) ;
2009-07-12 15:44:26 +00:00
rc . converter_cache_maxage = int ( widgetToDouble ( maxAgeLE ) * 86400.0 ) ;
2007-04-25 07:13:54 +00:00
}
2017-07-27 15:30:30 +02:00
static void setCheckboxBlockSignals ( QCheckBox * cb , bool checked ) {
cb - > blockSignals ( true ) ;
cb - > setChecked ( checked ) ;
cb - > blockSignals ( false ) ;
}
2014-12-19 11:35:37 +01:00
void PrefConverters : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
cacheCB - > setChecked ( rc . use_converter_cache ) ;
2016-11-05 01:00:44 +01:00
needauthForbiddenCB - > setChecked ( rc . use_converter_needauth_forbidden ) ;
2017-07-27 15:30:30 +02:00
setCheckboxBlockSignals ( needauthCB , rc . use_converter_needauth ) ;
2007-04-25 07:13:54 +00:00
QString max_age ;
2009-07-12 15:44:26 +00:00
doubleToWidget ( maxAgeLE , ( double ( rc . converter_cache_maxage ) / 86400.0 ) , ' g ' , 6 ) ;
2007-04-25 07:13:54 +00:00
updateGui ( ) ;
}
void PrefConverters : : updateGui ( )
{
2016-08-28 01:27:37 +01:00
QString const pattern ( " %1 -> %2 " ) ;
2007-09-19 10:16:44 +00:00
form_ - > formats ( ) . sort ( ) ;
form_ - > converters ( ) . update ( form_ - > formats ( ) ) ;
2007-04-25 07:13:54 +00:00
// save current selection
2016-08-28 01:27:37 +01:00
QString current =
pattern
. arg ( converterFromCO - > currentText ( ) )
. arg ( converterToCO - > currentText ( ) ) ;
2007-04-25 07:13:54 +00:00
converterFromCO - > clear ( ) ;
converterToCO - > clear ( ) ;
2016-08-28 01:27:37 +01:00
for ( Format const & f : form_ - > formats ( ) ) {
QString const name = toqstr ( translateIfPossible ( f . prettyname ( ) ) ) ;
converterFromCO - > addItem ( name ) ;
converterToCO - > addItem ( name ) ;
2007-04-25 07:13:54 +00:00
}
// currentRowChanged(int) is also triggered when updating the listwidget
2009-05-23 10:30:52 +00:00
// block signals to avoid unnecessary calls to switchConverter()
2007-04-25 07:13:54 +00:00
convertersLW - > blockSignals ( true ) ;
convertersLW - > clear ( ) ;
2016-08-28 01:27:37 +01:00
for ( Converter const & c : form_ - > converters ( ) ) {
2008-05-25 09:42:41 +00:00
QString const name =
2016-08-28 01:27:37 +01:00
pattern
. arg ( toqstr ( translateIfPossible ( c . From ( ) - > prettyname ( ) ) ) )
. arg ( toqstr ( translateIfPossible ( c . To ( ) - > prettyname ( ) ) ) ) ;
int type = form_ - > converters ( ) . getNumber ( c . From ( ) - > name ( ) ,
c . To ( ) - > name ( ) ) ;
2008-05-25 09:42:41 +00:00
new QListWidgetItem ( name , convertersLW , type ) ;
2007-04-25 07:13:54 +00:00
}
convertersLW - > sortItems ( Qt : : AscendingOrder ) ;
convertersLW - > blockSignals ( false ) ;
// restore selection
2016-08-28 01:27:37 +01:00
if ( current ! = pattern . arg ( QString ( ) ) . arg ( QString ( ) ) ) {
2007-04-25 07:13:54 +00:00
QList < QListWidgetItem * > const item =
convertersLW - > findItems ( current , Qt : : MatchExactly ) ;
2007-09-15 15:42:22 +00:00
if ( ! item . isEmpty ( ) )
2007-04-25 07:13:54 +00:00
convertersLW - > setCurrentItem ( item . at ( 0 ) ) ;
}
// select first element if restoring failed
if ( convertersLW - > currentRow ( ) = = - 1 )
convertersLW - > setCurrentRow ( 0 ) ;
updateButtons ( ) ;
}
2009-05-23 10:30:52 +00:00
void PrefConverters : : switchConverter ( )
2007-04-25 07:13:54 +00:00
{
int const cnr = convertersLW - > currentItem ( ) - > type ( ) ;
Converter const & c ( form_ - > converters ( ) . get ( cnr ) ) ;
2014-12-07 18:35:28 +01:00
converterFromCO - > setCurrentIndex ( form_ - > formats ( ) . getNumber ( c . from ( ) ) ) ;
converterToCO - > setCurrentIndex ( form_ - > formats ( ) . getNumber ( c . to ( ) ) ) ;
converterED - > setText ( toqstr ( c . command ( ) ) ) ;
converterFlagED - > setText ( toqstr ( c . flags ( ) ) ) ;
2007-04-25 07:13:54 +00:00
updateButtons ( ) ;
}
2009-05-23 12:52:23 +00:00
void PrefConverters : : changeConverter ( )
2007-04-25 07:13:54 +00:00
{
updateButtons ( ) ;
}
void PrefConverters : : updateButtons ( )
{
2012-10-21 21:14:16 +02:00
if ( form_ - > formats ( ) . empty ( ) )
2010-05-10 21:30:57 +00:00
return ;
2007-09-19 10:16:44 +00:00
Format const & from = form_ - > formats ( ) . get ( converterFromCO - > currentIndex ( ) ) ;
Format const & to = form_ - > formats ( ) . get ( converterToCO - > currentIndex ( ) ) ;
2007-04-25 07:13:54 +00:00
int const sel = form_ - > converters ( ) . getNumber ( from . name ( ) , to . name ( ) ) ;
2007-10-25 20:36:17 +00:00
bool const known = sel > = 0 ;
2007-04-25 07:13:54 +00:00
bool const valid = ! ( converterED - > text ( ) . isEmpty ( )
| | from . name ( ) = = to . name ( ) ) ;
2012-05-29 14:21:29 +02:00
string old_command ;
string old_flag ;
if ( convertersLW - > count ( ) > 0 ) {
int const cnr = convertersLW - > currentItem ( ) - > type ( ) ;
Converter const & c = form_ - > converters ( ) . get ( cnr ) ;
2014-12-07 18:35:28 +01:00
old_command = c . command ( ) ;
old_flag = c . flags ( ) ;
2012-05-29 14:21:29 +02:00
}
2008-05-19 19:58:05 +00:00
string const new_command = fromqstr ( converterED - > text ( ) ) ;
string const new_flag = fromqstr ( converterFlagED - > text ( ) ) ;
2007-04-25 07:13:54 +00:00
2008-05-19 19:58:05 +00:00
bool modified = ( old_command ! = new_command | | old_flag ! = new_flag ) ;
2007-04-25 07:13:54 +00:00
converterModifyPB - > setEnabled ( valid & & known & & modified ) ;
converterNewPB - > setEnabled ( valid & & ! known ) ;
converterRemovePB - > setEnabled ( known ) ;
maxAgeLE - > setEnabled ( cacheCB - > isChecked ( ) ) ;
maxAgeLA - > setEnabled ( cacheCB - > isChecked ( ) ) ;
}
// FIXME: user must
// specify unique from/to or it doesn't appear. This is really bad UI
// this is why we can use the same function for both new and modify
2009-05-23 10:30:52 +00:00
void PrefConverters : : updateConverter ( )
2007-04-25 07:13:54 +00:00
{
2007-09-15 15:42:22 +00:00
Format const & from = form_ - > formats ( ) . get ( converterFromCO - > currentIndex ( ) ) ;
Format const & to = form_ - > formats ( ) . get ( converterToCO - > currentIndex ( ) ) ;
2007-04-25 07:13:54 +00:00
string const flags = fromqstr ( converterFlagED - > text ( ) ) ;
string const command = fromqstr ( converterED - > text ( ) ) ;
2007-09-15 15:42:22 +00:00
Converter const * old =
form_ - > converters ( ) . getConverter ( from . name ( ) , to . name ( ) ) ;
2007-04-25 07:13:54 +00:00
form_ - > converters ( ) . add ( from . name ( ) , to . name ( ) , command , flags ) ;
2007-09-15 15:42:22 +00:00
if ( ! old )
2007-04-25 07:13:54 +00:00
form_ - > converters ( ) . updateLast ( form_ - > formats ( ) ) ;
updateGui ( ) ;
2007-05-17 08:31:00 +00:00
// Remove all files created by this converter from the cache, since
// the modified converter might create different files.
ConverterCache : : get ( ) . remove_all ( from . name ( ) , to . name ( ) ) ;
2007-04-25 07:13:54 +00:00
}
2009-05-23 10:30:52 +00:00
void PrefConverters : : removeConverter ( )
2007-04-25 07:13:54 +00:00
{
2007-09-15 15:42:22 +00:00
Format const & from = form_ - > formats ( ) . get ( converterFromCO - > currentIndex ( ) ) ;
Format const & to = form_ - > formats ( ) . get ( converterToCO - > currentIndex ( ) ) ;
2007-04-25 07:13:54 +00:00
form_ - > converters ( ) . erase ( from . name ( ) , to . name ( ) ) ;
updateGui ( ) ;
2007-05-17 08:31:00 +00:00
// Remove all files created by this converter from the cache, since
// a possible new converter might create different files.
ConverterCache : : get ( ) . remove_all ( from . name ( ) , to . name ( ) ) ;
2007-04-25 07:13:54 +00:00
}
void PrefConverters : : on_cacheCB_stateChanged ( int state )
{
maxAgeLE - > setEnabled ( state = = Qt : : Checked ) ;
maxAgeLA - > setEnabled ( state = = Qt : : Checked ) ;
changed ( ) ;
}
2016-11-05 01:00:44 +01:00
void PrefConverters : : on_needauthForbiddenCB_toggled ( bool checked )
{
needauthCB - > setEnabled ( ! checked ) ;
}
2017-07-27 00:01:51 +02:00
void PrefConverters : : on_needauthCB_toggled ( bool checked )
{
2017-07-27 15:30:30 +02:00
if ( checked ) {
changed ( ) ;
2017-07-27 00:01:51 +02:00
return ;
2017-07-27 15:30:30 +02:00
}
2017-07-27 00:01:51 +02:00
int ret = frontend : : Alert : : prompt (
_ ( " SECURITY WARNING! " ) , _ ( " Unchecking this option has the effect that potentially harmful converters would be run without asking your permission first. This is UNSAFE and NOT recommended, unless you know what you are doing. Are you sure you would like to proceed ? The recommended and safe answer is NO! " ) ,
0 , 0 , _ ( " &No " ) , _ ( " &Yes " ) ) ;
if ( ret = = 1 )
changed ( ) ;
else
2017-07-27 15:30:30 +02:00
setCheckboxBlockSignals ( needauthCB , true ) ;
2017-07-27 00:01:51 +02:00
}
2007-04-25 07:13:54 +00:00
/////////////////////////////////////////////////////////////////////
//
2008-05-19 20:52:24 +00:00
// FormatValidator
2007-04-25 07:13:54 +00:00
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
class FormatValidator : public QValidator
{
public :
FormatValidator ( QWidget * , Formats const & f ) ;
void fixup ( QString & input ) const ;
QValidator : : State validate ( QString & input , int & pos ) const ;
private :
virtual QString toString ( Format const & format ) const = 0 ;
int nr ( ) const ;
Formats const & formats_ ;
} ;
2008-06-25 15:02:18 +00:00
FormatValidator : : FormatValidator ( QWidget * parent , Formats const & f )
2007-09-15 17:09:57 +00:00
: QValidator ( parent ) , formats_ ( f )
2007-04-25 07:13:54 +00:00
{
}
2007-09-15 17:09:57 +00:00
void FormatValidator : : fixup ( QString & input ) const
2007-04-25 07:13:54 +00:00
{
2007-09-15 17:09:57 +00:00
Formats : : const_iterator cit = formats_ . begin ( ) ;
Formats : : const_iterator end = formats_ . end ( ) ;
for ( ; cit ! = end ; + + cit ) {
2008-05-19 20:52:24 +00:00
QString const name = toString ( * cit ) ;
2007-09-15 17:09:57 +00:00
if ( distance ( formats_ . begin ( ) , cit ) = = nr ( ) ) {
2008-05-19 20:52:24 +00:00
input = name ;
2007-09-15 17:09:57 +00:00
return ;
2007-04-25 07:13:54 +00:00
}
}
}
2007-09-20 04:27:16 +00:00
QValidator : : State FormatValidator : : validate ( QString & input , int & /*pos*/ ) const
2007-04-25 07:13:54 +00:00
{
2007-09-15 17:09:57 +00:00
Formats : : const_iterator cit = formats_ . begin ( ) ;
Formats : : const_iterator end = formats_ . end ( ) ;
bool unknown = true ;
for ( ; unknown & & cit ! = end ; + + cit ) {
2008-05-19 20:52:24 +00:00
QString const name = toString ( * cit ) ;
2007-09-15 17:09:57 +00:00
if ( distance ( formats_ . begin ( ) , cit ) ! = nr ( ) )
2008-05-19 20:52:24 +00:00
unknown = name ! = input ;
2007-04-25 07:13:54 +00:00
}
2007-09-15 17:09:57 +00:00
2008-06-25 15:02:18 +00:00
if ( unknown & & ! input . isEmpty ( ) )
2007-09-15 17:09:57 +00:00
return QValidator : : Acceptable ;
else
return QValidator : : Intermediate ;
2007-04-25 07:13:54 +00:00
}
2007-09-15 17:09:57 +00:00
int FormatValidator : : nr ( ) const
2007-04-25 07:13:54 +00:00
{
2007-09-15 17:09:57 +00:00
QComboBox * p = qobject_cast < QComboBox * > ( parent ( ) ) ;
return p - > itemData ( p - > currentIndex ( ) ) . toInt ( ) ;
2007-04-25 07:13:54 +00:00
}
2008-05-19 20:52:24 +00:00
/////////////////////////////////////////////////////////////////////
//
// FormatNameValidator
//
/////////////////////////////////////////////////////////////////////
2007-04-25 07:13:54 +00:00
2008-05-19 20:52:24 +00:00
class FormatNameValidator : public FormatValidator
2007-04-25 07:13:54 +00:00
{
2008-05-19 20:52:24 +00:00
public :
FormatNameValidator ( QWidget * parent , Formats const & f )
: FormatValidator ( parent , f )
{ }
private :
QString toString ( Format const & format ) const
{
return toqstr ( format . name ( ) ) ;
}
} ;
2007-04-25 07:13:54 +00:00
2008-05-19 20:52:24 +00:00
/////////////////////////////////////////////////////////////////////
//
// FormatPrettynameValidator
//
/////////////////////////////////////////////////////////////////////
2007-04-25 07:13:54 +00:00
2008-05-19 20:52:24 +00:00
class FormatPrettynameValidator : public FormatValidator
2007-04-25 07:13:54 +00:00
{
2008-05-19 20:52:24 +00:00
public :
FormatPrettynameValidator ( QWidget * parent , Formats const & f )
: FormatValidator ( parent , f )
{ }
private :
QString toString ( Format const & format ) const
{
2016-08-28 01:27:37 +01:00
return toqstr ( translateIfPossible ( format . prettyname ( ) ) ) ;
2008-05-19 20:52:24 +00:00
}
} ;
2007-04-25 07:13:54 +00:00
2008-05-19 20:52:24 +00:00
/////////////////////////////////////////////////////////////////////
//
// PrefFileformats
//
/////////////////////////////////////////////////////////////////////
2007-04-25 07:13:54 +00:00
2008-05-19 20:52:24 +00:00
PrefFileformats : : PrefFileformats ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catFiles , N_ ( " File Formats " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2011-09-12 14:22:05 +00:00
2007-09-15 17:09:57 +00:00
formatED - > setValidator ( new FormatNameValidator ( formatsCB , form_ - > formats ( ) ) ) ;
formatsCB - > setValidator ( new FormatPrettynameValidator ( formatsCB , form_ - > formats ( ) ) ) ;
2011-09-13 20:42:23 +00:00
extensionsED - > setValidator ( new NoNewLineValidator ( extensionsED ) ) ;
2011-09-12 14:22:05 +00:00
shortcutED - > setValidator ( new NoNewLineValidator ( shortcutED ) ) ;
editorED - > setValidator ( new NoNewLineValidator ( editorED ) ) ;
viewerED - > setValidator ( new NoNewLineValidator ( viewerED ) ) ;
copierED - > setValidator ( new NoNewLineValidator ( copierED ) ) ;
2007-04-25 07:13:54 +00:00
connect ( documentCB , SIGNAL ( clicked ( ) ) ,
2007-09-15 17:09:57 +00:00
this , SLOT ( setFlags ( ) ) ) ;
2007-04-25 07:13:54 +00:00
connect ( vectorCB , SIGNAL ( clicked ( ) ) ,
2007-09-15 17:09:57 +00:00
this , SLOT ( setFlags ( ) ) ) ;
2011-02-13 09:34:10 +00:00
connect ( exportMenuCB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( setFlags ( ) ) ) ;
2007-09-15 17:09:57 +00:00
connect ( formatsCB - > lineEdit ( ) , SIGNAL ( editingFinished ( ) ) ,
this , SLOT ( updatePrettyname ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( formatsCB - > lineEdit ( ) , SIGNAL ( textEdited ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2009-04-07 05:01:08 +00:00
connect ( defaultFormatCB , SIGNAL ( activated ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2013-06-01 16:58:34 +02:00
connect ( defaultOTFFormatCB , SIGNAL ( activated ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2017-09-09 08:56:04 +02:00
connect ( defaultPlatexFormatCB , SIGNAL ( activated ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2009-09-05 15:11:43 +00:00
connect ( viewerCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( editorCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-04-25 07:13:54 +00:00
}
2008-05-25 09:42:41 +00:00
namespace {
2016-08-28 01:27:37 +01:00
string const l10n_shortcut ( docstring const & prettyname , string const & shortcut )
2008-05-25 09:42:41 +00:00
{
if ( shortcut . empty ( ) )
return string ( ) ;
string l10n_format =
2016-08-28 01:27:37 +01:00
to_utf8 ( _ ( to_utf8 ( prettyname ) + ' | ' + shortcut ) ) ;
2008-05-25 09:42:41 +00:00
return split ( l10n_format , ' | ' ) ;
}
2017-07-23 13:11:54 +02:00
} // namespace
2008-05-25 09:42:41 +00:00
2014-12-19 11:35:37 +01:00
void PrefFileformats : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
2009-04-07 05:01:08 +00:00
QString const default_format = defaultFormatCB - > itemData (
defaultFormatCB - > currentIndex ( ) ) . toString ( ) ;
rc . default_view_format = fromqstr ( default_format ) ;
2013-06-01 16:58:34 +02:00
QString const default_otf_format = defaultOTFFormatCB - > itemData (
defaultOTFFormatCB - > currentIndex ( ) ) . toString ( ) ;
rc . default_otf_view_format = fromqstr ( default_otf_format ) ;
2017-09-09 08:56:04 +02:00
QString const default_platex_format = defaultPlatexFormatCB - > itemData (
defaultPlatexFormatCB - > currentIndex ( ) ) . toString ( ) ;
rc . default_platex_view_format = fromqstr ( default_platex_format ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefFileformats : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
2009-09-05 15:11:43 +00:00
viewer_alternatives = rc . viewer_alternatives ;
editor_alternatives = rc . editor_alternatives ;
2009-04-07 05:01:08 +00:00
bool const init = defaultFormatCB - > currentText ( ) . isEmpty ( ) ;
2007-09-03 20:28:26 +00:00
updateView ( ) ;
2009-04-07 05:01:08 +00:00
if ( init ) {
2013-06-01 16:58:34 +02:00
int pos =
2009-11-22 00:19:50 +00:00
defaultFormatCB - > findData ( toqstr ( rc . default_view_format ) ) ;
2009-04-07 05:01:08 +00:00
defaultFormatCB - > setCurrentIndex ( pos ) ;
2013-06-01 16:58:34 +02:00
pos = defaultOTFFormatCB - > findData ( toqstr ( rc . default_otf_view_format ) ) ;
defaultOTFFormatCB - > setCurrentIndex ( pos ) ;
defaultOTFFormatCB - > setCurrentIndex ( pos ) ;
2017-09-09 08:56:04 +02:00
pos = defaultPlatexFormatCB - > findData ( toqstr ( rc . default_platex_view_format ) ) ;
defaultPlatexFormatCB - > setCurrentIndex ( pos ) ;
defaultPlatexFormatCB - > setCurrentIndex ( pos ) ;
2009-04-07 05:01:08 +00:00
}
2007-04-25 07:13:54 +00:00
}
2007-09-03 20:28:26 +00:00
void PrefFileformats : : updateView ( )
2007-04-25 07:13:54 +00:00
{
2007-09-15 17:09:57 +00:00
QString const current = formatsCB - > currentText ( ) ;
2009-04-07 05:01:08 +00:00
QString const current_def = defaultFormatCB - > currentText ( ) ;
2013-06-01 16:58:34 +02:00
QString const current_def_otf = defaultOTFFormatCB - > currentText ( ) ;
2017-09-09 08:56:04 +02:00
QString const current_def_platex = defaultPlatexFormatCB - > currentText ( ) ;
2007-04-25 07:13:54 +00:00
2009-04-07 10:59:03 +00:00
// update comboboxes with formats
2007-09-15 17:09:57 +00:00
formatsCB - > blockSignals ( true ) ;
2009-04-07 05:01:08 +00:00
defaultFormatCB - > blockSignals ( true ) ;
2013-06-01 16:58:34 +02:00
defaultOTFFormatCB - > blockSignals ( true ) ;
2017-09-09 08:56:04 +02:00
defaultPlatexFormatCB - > blockSignals ( true ) ;
2007-09-15 17:09:57 +00:00
formatsCB - > clear ( ) ;
2009-04-07 10:59:03 +00:00
defaultFormatCB - > clear ( ) ;
2013-06-01 16:58:34 +02:00
defaultOTFFormatCB - > clear ( ) ;
2017-09-09 08:56:04 +02:00
defaultPlatexFormatCB - > clear ( ) ;
2007-09-15 17:09:57 +00:00
form_ - > formats ( ) . sort ( ) ;
2016-11-09 15:42:43 +01:00
for ( Format const & f : form_ - > formats ( ) ) {
2016-08-28 01:27:37 +01:00
QString const prettyname = toqstr ( translateIfPossible ( f . prettyname ( ) ) ) ;
formatsCB - > addItem ( prettyname ,
QVariant ( form_ - > formats ( ) . getNumber ( f . name ( ) ) ) ) ;
if ( f . viewer ( ) . empty ( ) )
2013-06-01 16:58:34 +02:00
continue ;
2016-08-28 01:27:37 +01:00
if ( form_ - > converters ( ) . isReachable ( " xhtml " , f . name ( ) )
| | form_ - > converters ( ) . isReachable ( " dviluatex " , f . name ( ) )
| | form_ - > converters ( ) . isReachable ( " luatex " , f . name ( ) )
| | form_ - > converters ( ) . isReachable ( " xetex " , f . name ( ) ) ) {
defaultFormatCB - > addItem ( prettyname ,
QVariant ( toqstr ( f . name ( ) ) ) ) ;
defaultOTFFormatCB - > addItem ( prettyname ,
QVariant ( toqstr ( f . name ( ) ) ) ) ;
2017-09-09 08:56:04 +02:00
} else {
if ( form_ - > converters ( ) . isReachable ( " latex " , f . name ( ) )
| | form_ - > converters ( ) . isReachable ( " pdflatex " , f . name ( ) ) )
defaultFormatCB - > addItem ( prettyname ,
2016-08-28 01:27:37 +01:00
QVariant ( toqstr ( f . name ( ) ) ) ) ;
2017-09-09 08:56:04 +02:00
if ( form_ - > converters ( ) . isReachable ( " platex " , f . name ( ) ) )
defaultPlatexFormatCB - > addItem ( prettyname ,
QVariant ( toqstr ( f . name ( ) ) ) ) ;
}
2009-04-07 05:01:08 +00:00
}
2007-04-25 07:13:54 +00:00
2013-06-01 16:58:34 +02:00
// restore selections
2009-04-07 05:01:08 +00:00
int item = formatsCB - > findText ( current , Qt : : MatchExactly ) ;
2007-09-15 17:09:57 +00:00
formatsCB - > setCurrentIndex ( item < 0 ? 0 : item ) ;
on_formatsCB_currentIndexChanged ( item < 0 ? 0 : item ) ;
2009-04-07 05:01:08 +00:00
item = defaultFormatCB - > findText ( current_def , Qt : : MatchExactly ) ;
defaultFormatCB - > setCurrentIndex ( item < 0 ? 0 : item ) ;
2013-06-01 16:58:34 +02:00
item = defaultOTFFormatCB - > findText ( current_def_otf , Qt : : MatchExactly ) ;
defaultOTFFormatCB - > setCurrentIndex ( item < 0 ? 0 : item ) ;
2017-09-09 08:56:04 +02:00
item = defaultPlatexFormatCB - > findText ( current_def_platex , Qt : : MatchExactly ) ;
defaultPlatexFormatCB - > setCurrentIndex ( item < 0 ? 0 : item ) ;
2007-09-15 17:09:57 +00:00
formatsCB - > blockSignals ( false ) ;
2009-04-07 05:01:08 +00:00
defaultFormatCB - > blockSignals ( false ) ;
2013-06-01 16:58:34 +02:00
defaultOTFFormatCB - > blockSignals ( false ) ;
2017-09-09 08:56:04 +02:00
defaultPlatexFormatCB - > blockSignals ( false ) ;
2007-04-25 07:13:54 +00:00
}
2007-09-15 17:09:57 +00:00
void PrefFileformats : : on_formatsCB_currentIndexChanged ( int i )
2007-04-25 07:13:54 +00:00
{
2012-10-21 21:14:16 +02:00
if ( form_ - > formats ( ) . empty ( ) )
2010-05-10 21:30:57 +00:00
return ;
2007-09-15 17:09:57 +00:00
int const nr = formatsCB - > itemData ( i ) . toInt ( ) ;
Format const f = form_ - > formats ( ) . get ( nr ) ;
2007-04-25 07:13:54 +00:00
formatED - > setText ( toqstr ( f . name ( ) ) ) ;
2007-09-15 17:09:57 +00:00
copierED - > setText ( toqstr ( form_ - > movers ( ) . command ( f . name ( ) ) ) ) ;
2011-09-13 20:42:23 +00:00
extensionsED - > setText ( toqstr ( f . extensions ( ) ) ) ;
2012-02-21 20:29:44 +00:00
mimeED - > setText ( toqstr ( f . mime ( ) ) ) ;
2008-05-25 09:42:41 +00:00
shortcutED - > setText (
toqstr ( l10n_shortcut ( f . prettyname ( ) , f . shortcut ( ) ) ) ) ;
2007-04-25 07:13:54 +00:00
documentCB - > setChecked ( ( f . documentFormat ( ) ) ) ;
vectorCB - > setChecked ( ( f . vectorFormat ( ) ) ) ;
2011-02-13 09:34:10 +00:00
exportMenuCB - > setChecked ( ( f . inExportMenu ( ) ) ) ;
exportMenuCB - > setEnabled ( ( f . documentFormat ( ) ) ) ;
2009-09-05 15:11:43 +00:00
updateViewers ( ) ;
updateEditors ( ) ;
2007-09-15 17:09:57 +00:00
}
2007-04-25 07:13:54 +00:00
2007-09-15 17:09:57 +00:00
void PrefFileformats : : setFlags ( )
{
int flags = Format : : none ;
if ( documentCB - > isChecked ( ) )
flags | = Format : : document ;
if ( vectorCB - > isChecked ( ) )
flags | = Format : : vector ;
2011-02-13 09:34:10 +00:00
if ( exportMenuCB - > isChecked ( ) )
flags | = Format : : export_menu ;
2007-09-15 17:09:57 +00:00
currentFormat ( ) . setFlags ( flags ) ;
2011-02-13 09:34:10 +00:00
exportMenuCB - > setEnabled ( documentCB - > isChecked ( ) ) ;
2007-09-15 17:09:57 +00:00
changed ( ) ;
2007-04-25 07:13:54 +00:00
}
2007-09-15 17:09:57 +00:00
void PrefFileformats : : on_copierED_textEdited ( const QString & s )
2007-04-25 07:13:54 +00:00
{
2007-09-15 17:09:57 +00:00
string const fmt = fromqstr ( formatED - > text ( ) ) ;
form_ - > movers ( ) . set ( fmt , fromqstr ( s ) ) ;
changed ( ) ;
2007-04-25 07:13:54 +00:00
}
2011-09-13 20:42:23 +00:00
void PrefFileformats : : on_extensionsED_textEdited ( const QString & s )
2007-04-25 07:13:54 +00:00
{
2011-09-13 20:42:23 +00:00
currentFormat ( ) . setExtensions ( fromqstr ( s ) ) ;
2007-09-15 17:09:57 +00:00
changed ( ) ;
}
2007-04-25 07:13:54 +00:00
2011-09-13 20:42:23 +00:00
2007-09-15 17:09:57 +00:00
void PrefFileformats : : on_viewerED_textEdited ( const QString & s )
{
currentFormat ( ) . setViewer ( fromqstr ( s ) ) ;
changed ( ) ;
}
2007-04-25 07:13:54 +00:00
2007-09-15 17:09:57 +00:00
void PrefFileformats : : on_editorED_textEdited ( const QString & s )
{
currentFormat ( ) . setEditor ( fromqstr ( s ) ) ;
changed ( ) ;
}
2012-02-21 20:29:44 +00:00
void PrefFileformats : : on_mimeED_textEdited ( const QString & s )
{
currentFormat ( ) . setMime ( fromqstr ( s ) ) ;
changed ( ) ;
}
2007-09-15 17:09:57 +00:00
void PrefFileformats : : on_shortcutED_textEdited ( const QString & s )
{
2008-05-25 09:42:41 +00:00
string const new_shortcut = fromqstr ( s ) ;
if ( new_shortcut = = l10n_shortcut ( currentFormat ( ) . prettyname ( ) ,
currentFormat ( ) . shortcut ( ) ) )
return ;
currentFormat ( ) . setShortcut ( new_shortcut ) ;
2007-09-15 17:09:57 +00:00
changed ( ) ;
}
void PrefFileformats : : on_formatED_editingFinished ( )
{
string const newname = fromqstr ( formatED - > displayText ( ) ) ;
2010-08-07 11:31:28 +00:00
string const oldname = currentFormat ( ) . name ( ) ;
if ( newname = = oldname )
2007-09-15 17:09:57 +00:00
return ;
2010-08-07 11:31:28 +00:00
if ( form_ - > converters ( ) . formatIsUsed ( oldname ) ) {
Alert : : error ( _ ( " Format in use " ) ,
_ ( " You cannot change a format's short name "
" if the format is used by a converter. "
" Please remove the converter first. " ) ) ;
updateView ( ) ;
return ;
}
2007-09-15 17:09:57 +00:00
currentFormat ( ) . setName ( newname ) ;
changed ( ) ;
}
void PrefFileformats : : on_formatED_textChanged ( const QString & )
{
QString t = formatED - > text ( ) ;
int p = 0 ;
bool valid = formatED - > validator ( ) - > validate ( t , p ) = = QValidator : : Acceptable ;
setValid ( formatLA , valid ) ;
}
void PrefFileformats : : on_formatsCB_editTextChanged ( const QString & )
{
QString t = formatsCB - > currentText ( ) ;
int p = 0 ;
bool valid = formatsCB - > validator ( ) - > validate ( t , p ) = = QValidator : : Acceptable ;
setValid ( formatsLA , valid ) ;
}
void PrefFileformats : : updatePrettyname ( )
{
2008-05-25 09:42:41 +00:00
QString const newname = formatsCB - > currentText ( ) ;
2016-08-28 01:27:37 +01:00
if ( newname = = toqstr ( translateIfPossible ( currentFormat ( ) . prettyname ( ) ) ) )
2007-09-15 17:09:57 +00:00
return ;
2016-08-28 01:27:37 +01:00
currentFormat ( ) . setPrettyname ( qstring_to_ucs4 ( newname ) ) ;
2007-04-25 07:13:54 +00:00
formatsChanged ( ) ;
2007-09-15 17:09:57 +00:00
updateView ( ) ;
changed ( ) ;
2007-04-25 07:13:54 +00:00
}
2009-10-17 22:58:44 +00:00
namespace {
void updateComboBox ( LyXRC : : Alternatives const & alts ,
string const & fmt , QComboBox * combo )
{
2014-12-07 18:35:28 +01:00
LyXRC : : Alternatives : : const_iterator it =
2009-10-17 22:58:44 +00:00
alts . find ( fmt ) ;
if ( it ! = alts . end ( ) ) {
LyXRC : : CommandSet const & cmds = it - > second ;
2014-12-07 18:35:28 +01:00
LyXRC : : CommandSet : : const_iterator sit =
2009-10-17 22:58:44 +00:00
cmds . begin ( ) ;
2014-12-07 18:35:28 +01:00
LyXRC : : CommandSet : : const_iterator const sen =
2009-10-17 22:58:44 +00:00
cmds . end ( ) ;
for ( ; sit ! = sen ; + + sit ) {
QString const qcmd = toqstr ( * sit ) ;
combo - > addItem ( qcmd , qcmd ) ;
}
}
}
2017-07-23 13:11:54 +02:00
} // namespace
2009-10-17 22:58:44 +00:00
2009-09-05 15:11:43 +00:00
void PrefFileformats : : updateViewers ( )
{
Format const f = currentFormat ( ) ;
2009-11-22 00:19:50 +00:00
viewerCO - > blockSignals ( true ) ;
2009-09-05 15:11:43 +00:00
viewerCO - > clear ( ) ;
viewerCO - > addItem ( qt_ ( " None " ) , QString ( ) ) ;
2009-10-17 22:58:44 +00:00
updateComboBox ( viewer_alternatives , f . name ( ) , viewerCO ) ;
2009-09-05 15:11:43 +00:00
viewerCO - > addItem ( qt_ ( " Custom " ) , QString ( " custom viewer " ) ) ;
2009-11-22 00:19:50 +00:00
viewerCO - > blockSignals ( false ) ;
2009-09-05 15:11:43 +00:00
int pos = viewerCO - > findData ( toqstr ( f . viewer ( ) ) ) ;
if ( pos ! = - 1 ) {
viewerED - > clear ( ) ;
viewerED - > setEnabled ( false ) ;
viewerCO - > setCurrentIndex ( pos ) ;
} else {
viewerED - > setEnabled ( true ) ;
viewerED - > setText ( toqstr ( f . viewer ( ) ) ) ;
viewerCO - > setCurrentIndex ( viewerCO - > findData ( toqstr ( " custom viewer " ) ) ) ;
}
}
void PrefFileformats : : updateEditors ( )
{
Format const f = currentFormat ( ) ;
2009-11-22 00:19:50 +00:00
editorCO - > blockSignals ( true ) ;
2009-09-05 15:11:43 +00:00
editorCO - > clear ( ) ;
editorCO - > addItem ( qt_ ( " None " ) , QString ( ) ) ;
2009-10-17 22:58:44 +00:00
updateComboBox ( editor_alternatives , f . name ( ) , editorCO ) ;
2009-09-05 15:11:43 +00:00
editorCO - > addItem ( qt_ ( " Custom " ) , QString ( " custom editor " ) ) ;
2009-11-22 00:19:50 +00:00
editorCO - > blockSignals ( false ) ;
2009-09-05 15:11:43 +00:00
int pos = editorCO - > findData ( toqstr ( f . editor ( ) ) ) ;
if ( pos ! = - 1 ) {
editorED - > clear ( ) ;
editorED - > setEnabled ( false ) ;
editorCO - > setCurrentIndex ( pos ) ;
} else {
editorED - > setEnabled ( true ) ;
2009-11-19 23:37:16 +00:00
editorED - > setText ( toqstr ( f . editor ( ) ) ) ;
2009-09-06 09:42:31 +00:00
editorCO - > setCurrentIndex ( editorCO - > findData ( toqstr ( " custom editor " ) ) ) ;
2009-09-05 15:11:43 +00:00
}
}
void PrefFileformats : : on_viewerCO_currentIndexChanged ( int i )
{
2009-10-16 16:17:52 +00:00
bool const custom = viewerCO - > itemData ( i ) . toString ( ) = = " custom viewer " ;
viewerED - > setEnabled ( custom ) ;
if ( ! custom )
currentFormat ( ) . setViewer ( fromqstr ( viewerCO - > itemData ( i ) . toString ( ) ) ) ;
2009-09-05 15:11:43 +00:00
}
void PrefFileformats : : on_editorCO_currentIndexChanged ( int i )
{
2009-11-19 23:37:16 +00:00
bool const custom = editorCO - > itemData ( i ) . toString ( ) = = " custom editor " ;
2009-10-16 16:17:52 +00:00
editorED - > setEnabled ( custom ) ;
if ( ! custom )
2009-11-22 00:19:50 +00:00
currentFormat ( ) . setEditor ( fromqstr ( editorCO - > itemData ( i ) . toString ( ) ) ) ;
2009-09-05 15:11:43 +00:00
}
2007-09-15 17:09:57 +00:00
Format & PrefFileformats : : currentFormat ( )
2007-04-25 07:13:54 +00:00
{
2007-09-15 17:09:57 +00:00
int const i = formatsCB - > currentIndex ( ) ;
int const nr = formatsCB - > itemData ( i ) . toInt ( ) ;
return form_ - > formats ( ) . get ( nr ) ;
}
2007-04-25 07:13:54 +00:00
2007-09-15 17:09:57 +00:00
void PrefFileformats : : on_formatNewPB_clicked ( )
{
2016-08-28 01:27:37 +01:00
form_ - > formats ( ) . add ( " " , " " , docstring ( ) , " " , " " , " " , " " , Format : : none ) ;
2007-09-15 17:09:57 +00:00
updateView ( ) ;
formatsCB - > setCurrentIndex ( 0 ) ;
formatsCB - > setFocus ( Qt : : OtherFocusReason ) ;
2007-04-25 07:13:54 +00:00
}
2007-09-15 17:09:57 +00:00
void PrefFileformats : : on_formatRemovePB_clicked ( )
2007-04-25 07:13:54 +00:00
{
2007-09-15 17:09:57 +00:00
int const i = formatsCB - > currentIndex ( ) ;
int const nr = formatsCB - > itemData ( i ) . toInt ( ) ;
2007-04-25 07:13:54 +00:00
string const current_text = form_ - > formats ( ) . get ( nr ) . name ( ) ;
if ( form_ - > converters ( ) . formatIsUsed ( current_text ) ) {
Alert : : error ( _ ( " Format in use " ) ,
_ ( " Cannot remove a Format used by a Converter. "
" Remove the converter first. " ) ) ;
return ;
}
form_ - > formats ( ) . erase ( current_text ) ;
formatsChanged ( ) ;
2007-09-15 17:09:57 +00:00
updateView ( ) ;
on_formatsCB_editTextChanged ( formatsCB - > currentText ( ) ) ;
changed ( ) ;
2007-04-25 07:13:54 +00:00
}
/////////////////////////////////////////////////////////////////////
//
// PrefLanguage
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefLanguage : : PrefLanguage ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catLanguage , N_ ( " Language " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2008-02-10 19:51:23 +00:00
connect ( visualCursorRB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( logicalCursorRB , SIGNAL ( clicked ( ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
connect ( markForeignCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2019-07-19 17:23:20 +02:00
connect ( respectOSkbdCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2019-07-21 11:37:54 +02:00
connect ( explicitDocLangBeginCB , SIGNAL ( clicked ( ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2019-07-21 11:37:54 +02:00
connect ( explicitDocLangEndCB , SIGNAL ( clicked ( ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2010-11-20 13:34:14 +00:00
connect ( languagePackageCO , SIGNAL ( activated ( int ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( languagePackageED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2010-11-20 13:34:14 +00:00
connect ( globalCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( startCommandED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( endCommandED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2008-06-25 13:32:27 +00:00
connect ( uiLanguageCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2010-06-05 07:44:44 +00:00
connect ( defaultDecimalPointLE , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2011-10-27 11:52:11 +00:00
connect ( defaultLengthUnitCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-04-25 07:13:54 +00:00
2011-09-12 14:22:05 +00:00
languagePackageED - > setValidator ( new NoNewLineValidator ( languagePackageED ) ) ;
startCommandED - > setValidator ( new NoNewLineValidator ( startCommandED ) ) ;
endCommandED - > setValidator ( new NoNewLineValidator ( endCommandED ) ) ;
2010-11-30 18:38:32 +00:00
defaultDecimalPointLE - > setInputMask ( " X; " ) ;
defaultDecimalPointLE - > setMaxLength ( 1 ) ;
2008-06-25 13:32:27 +00:00
2011-10-27 11:52:11 +00:00
defaultLengthUnitCO - > addItem ( lyx : : qt_ ( unit_name_gui [ Length : : CM ] ) , Length : : CM ) ;
defaultLengthUnitCO - > addItem ( lyx : : qt_ ( unit_name_gui [ Length : : IN ] ) , Length : : IN ) ;
2015-05-07 17:20:23 +02:00
QAbstractItemModel * language_model = guiApp - > languageModel ( ) ;
language_model - > sort ( 0 ) ;
2008-06-25 13:32:27 +00:00
uiLanguageCO - > blockSignals ( true ) ;
2015-05-07 17:20:23 +02:00
uiLanguageCO - > clear ( ) ;
2008-06-25 13:32:27 +00:00
uiLanguageCO - > addItem ( qt_ ( " Default " ) , toqstr ( " auto " ) ) ;
for ( int i = 0 ; i ! = language_model - > rowCount ( ) ; + + i ) {
QModelIndex index = language_model - > index ( i , 0 ) ;
2010-12-03 17:48:06 +00:00
// Filter the list based on the available translation and add
// each language code only once
string const name = fromqstr ( index . data ( Qt : : UserRole ) . toString ( ) ) ;
Language const * lang = languages . getLanguage ( name ) ;
2012-08-23 15:08:21 +02:00
if ( ! lang )
continue ;
2010-12-03 17:48:06 +00:00
// never remove the currently selected language
2014-12-07 18:35:28 +01:00
if ( name ! = form - > rc ( ) . gui_language
2012-08-23 15:08:21 +02:00
& & name ! = lyxrc . gui_language
& & ( ! Messages : : available ( lang - > code ( ) )
2015-05-07 17:20:23 +02:00
| | ! lang - > hasGuiSupport ( ) ) )
continue ;
2008-06-25 13:32:27 +00:00
uiLanguageCO - > addItem ( index . data ( Qt : : DisplayRole ) . toString ( ) ,
2015-05-07 17:20:23 +02:00
index . data ( Qt : : UserRole ) . toString ( ) ) ;
2008-06-25 13:32:27 +00:00
}
uiLanguageCO - > blockSignals ( false ) ;
}
void PrefLanguage : : on_uiLanguageCO_currentIndexChanged ( int )
{
QMessageBox : : information ( this , qt_ ( " LyX needs to be restarted! " ) ,
qt_ ( " The change of user interface language will be fully "
" effective only after a restart. " ) ) ;
2007-04-25 07:13:54 +00:00
}
2010-11-20 13:34:14 +00:00
void PrefLanguage : : on_languagePackageCO_currentIndexChanged ( int i )
{
languagePackageED - > setEnabled ( i = = 2 ) ;
}
2014-12-19 11:35:37 +01:00
void PrefLanguage : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
2014-07-09 20:12:06 +02:00
rc . visual_cursor = visualCursorRB - > isChecked ( ) ;
2007-04-25 07:13:54 +00:00
rc . mark_foreign_language = markForeignCB - > isChecked ( ) ;
2019-07-19 17:23:20 +02:00
rc . respect_os_kbd_language = respectOSkbdCB - > isChecked ( ) ;
2019-07-21 11:37:54 +02:00
rc . language_auto_begin = ! explicitDocLangBeginCB - > isChecked ( ) ;
rc . language_auto_end = ! explicitDocLangEndCB - > isChecked ( ) ;
2010-11-20 13:34:14 +00:00
int const p = languagePackageCO - > currentIndex ( ) ;
if ( p = = 0 )
rc . language_package_selection = LyXRC : : LP_AUTO ;
else if ( p = = 1 )
rc . language_package_selection = LyXRC : : LP_BABEL ;
else if ( p = = 2 )
rc . language_package_selection = LyXRC : : LP_CUSTOM ;
else if ( p = = 3 )
rc . language_package_selection = LyXRC : : LP_NONE ;
rc . language_custom_package = fromqstr ( languagePackageED - > text ( ) ) ;
2007-04-25 07:13:54 +00:00
rc . language_global_options = globalCB - > isChecked ( ) ;
rc . language_command_begin = fromqstr ( startCommandED - > text ( ) ) ;
rc . language_command_end = fromqstr ( endCommandED - > text ( ) ) ;
2008-06-25 13:32:27 +00:00
rc . gui_language = fromqstr (
uiLanguageCO - > itemData ( uiLanguageCO - > currentIndex ( ) ) . toString ( ) ) ;
2010-06-05 07:44:44 +00:00
rc . default_decimal_point = fromqstr ( defaultDecimalPointLE - > text ( ) ) ;
2011-10-27 11:52:11 +00:00
rc . default_length_unit = ( Length : : UNIT ) defaultLengthUnitCO - > itemData ( defaultLengthUnitCO - > currentIndex ( ) ) . toInt ( ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefLanguage : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
2008-02-10 19:51:23 +00:00
if ( rc . visual_cursor )
visualCursorRB - > setChecked ( true ) ;
else
logicalCursorRB - > setChecked ( true ) ;
2007-04-25 07:13:54 +00:00
markForeignCB - > setChecked ( rc . mark_foreign_language ) ;
2019-07-19 17:23:20 +02:00
respectOSkbdCB - > setChecked ( rc . respect_os_kbd_language ) ;
2019-07-21 11:37:54 +02:00
explicitDocLangBeginCB - > setChecked ( ! rc . language_auto_begin ) ;
explicitDocLangEndCB - > setChecked ( ! rc . language_auto_end ) ;
2010-11-20 13:34:14 +00:00
languagePackageCO - > setCurrentIndex ( rc . language_package_selection ) ;
languagePackageED - > setText ( toqstr ( rc . language_custom_package ) ) ;
languagePackageED - > setEnabled ( languagePackageCO - > currentIndex ( ) = = 2 ) ;
2007-04-25 07:13:54 +00:00
globalCB - > setChecked ( rc . language_global_options ) ;
startCommandED - > setText ( toqstr ( rc . language_command_begin ) ) ;
endCommandED - > setText ( toqstr ( rc . language_command_end ) ) ;
2010-06-05 07:44:44 +00:00
defaultDecimalPointLE - > setText ( toqstr ( rc . default_decimal_point ) ) ;
2011-10-27 11:52:11 +00:00
int pos = defaultLengthUnitCO - > findData ( int ( rc . default_length_unit ) ) ;
defaultLengthUnitCO - > setCurrentIndex ( pos ) ;
2007-04-25 07:13:54 +00:00
2011-10-27 11:52:11 +00:00
pos = uiLanguageCO - > findData ( toqstr ( rc . gui_language ) ) ;
2008-06-25 13:32:27 +00:00
uiLanguageCO - > blockSignals ( true ) ;
uiLanguageCO - > setCurrentIndex ( pos ) ;
uiLanguageCO - > blockSignals ( false ) ;
2007-04-25 07:13:54 +00:00
}
/////////////////////////////////////////////////////////////////////
//
// PrefUserInterface
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefUserInterface : : PrefUserInterface ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catLookAndFeel , N_ ( " User Interface " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2013-03-02 12:24:32 +01:00
connect ( uiFilePB , SIGNAL ( clicked ( ) ) ,
this , SLOT ( selectUi ( ) ) ) ;
connect ( uiFileED , SIGNAL ( textChanged ( QString ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( iconSetCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2012-05-08 17:55:59 +02:00
connect ( useSystemThemeIconsCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2013-03-02 12:24:32 +01:00
connect ( lastfilesSB , SIGNAL ( valueChanged ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( tooltipCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
lastfilesSB - > setMaximum ( maxlastfiles ) ;
iconSetCO - > addItem ( qt_ ( " Default " ) , QString ( ) ) ;
iconSetCO - > addItem ( qt_ ( " Classic " ) , " classic " ) ;
iconSetCO - > addItem ( qt_ ( " Oxygen " ) , " oxygen " ) ;
2013-05-14 17:44:19 +02:00
2015-01-11 19:36:41 +01:00
# if (!(defined Q_WS_X11 || defined(QPA_XCB)) || QT_VERSION < 0x040600)
2013-05-14 17:44:19 +02:00
useSystemThemeIconsCB - > hide ( ) ;
# endif
2013-03-02 12:24:32 +01:00
}
2014-12-19 11:35:37 +01:00
void PrefUserInterface : : applyRC ( LyXRC & rc ) const
2013-03-02 12:24:32 +01:00
{
rc . icon_set = fromqstr ( iconSetCO - > itemData (
iconSetCO - > currentIndex ( ) ) . toString ( ) ) ;
rc . ui_file = internal_path ( fromqstr ( uiFileED - > text ( ) ) ) ;
2012-05-08 17:55:59 +02:00
rc . use_system_theme_icons = useSystemThemeIconsCB - > isChecked ( ) ;
2013-03-02 12:24:32 +01:00
rc . num_lastfiles = lastfilesSB - > value ( ) ;
rc . use_tooltip = tooltipCB - > isChecked ( ) ;
}
2014-12-19 11:35:37 +01:00
void PrefUserInterface : : updateRC ( LyXRC const & rc )
2013-03-02 12:24:32 +01:00
{
int iconset = iconSetCO - > findData ( toqstr ( rc . icon_set ) ) ;
if ( iconset < 0 )
iconset = 0 ;
iconSetCO - > setCurrentIndex ( iconset ) ;
2012-05-08 17:55:59 +02:00
useSystemThemeIconsCB - > setChecked ( rc . use_system_theme_icons ) ;
2013-03-02 12:24:32 +01:00
uiFileED - > setText ( toqstr ( external_path ( rc . ui_file ) ) ) ;
lastfilesSB - > setValue ( rc . num_lastfiles ) ;
tooltipCB - > setChecked ( rc . use_tooltip ) ;
}
void PrefUserInterface : : selectUi ( )
{
QString file = form_ - > browseUI ( internalPath ( uiFileED - > text ( ) ) ) ;
if ( ! file . isEmpty ( ) )
uiFileED - > setText ( file ) ;
}
/////////////////////////////////////////////////////////////////////
//
// PrefDocumentHandling
//
/////////////////////////////////////////////////////////////////////
PrefDocHandling : : PrefDocHandling ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catLookAndFeel , N_ ( " Document Handling " ) , form )
2013-03-02 12:24:32 +01:00
{
setupUi ( this ) ;
2007-04-25 07:13:54 +00:00
connect ( autoSaveCB , SIGNAL ( toggled ( bool ) ) ,
autoSaveSB , SLOT ( setEnabled ( bool ) ) ) ;
connect ( autoSaveCB , SIGNAL ( toggled ( bool ) ) ,
TextLabel1 , SLOT ( setEnabled ( bool ) ) ) ;
2008-03-14 23:24:45 +00:00
connect ( openDocumentsInTabsCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2010-11-13 11:55:05 +00:00
connect ( singleInstanceCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2009-10-05 23:06:29 +00:00
connect ( singleCloseTabButtonCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2012-09-15 23:37:55 +01:00
connect ( closeLastViewCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-04-25 07:13:54 +00:00
connect ( restoreCursorCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( loadSessionCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-11-15 12:58:44 +00:00
connect ( allowGeometrySessionCB , SIGNAL ( clicked ( ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
connect ( autoSaveSB , SIGNAL ( valueChanged ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( autoSaveCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2009-09-18 16:44:20 +00:00
connect ( backupCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2010-03-26 14:02:56 +00:00
connect ( saveCompressedCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2015-05-23 17:49:33 +02:00
connect ( saveOriginCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefDocHandling : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
rc . use_lastfilepos = restoreCursorCB - > isChecked ( ) ;
rc . load_session = loadSessionCB - > isChecked ( ) ;
2007-11-15 12:58:44 +00:00
rc . allow_geometry_session = allowGeometrySessionCB - > isChecked ( ) ;
2010-03-26 14:02:56 +00:00
rc . autosave = autoSaveCB - > isChecked ( ) ? autoSaveSB - > value ( ) * 60 : 0 ;
2009-09-18 16:44:20 +00:00
rc . make_backup = backupCB - > isChecked ( ) ;
2010-03-26 14:02:56 +00:00
rc . save_compressed = saveCompressedCB - > isChecked ( ) ;
2015-05-23 17:49:33 +02:00
rc . save_origin = saveOriginCB - > isChecked ( ) ;
2008-03-14 23:27:31 +00:00
rc . open_buffers_in_tabs = openDocumentsInTabsCB - > isChecked ( ) ;
2010-11-13 11:55:05 +00:00
rc . single_instance = singleInstanceCB - > isChecked ( ) ;
2009-10-05 23:06:29 +00:00
rc . single_close_tab_button = singleCloseTabButtonCB - > isChecked ( ) ;
2012-11-04 01:37:54 +01:00
2012-09-15 23:37:55 +01:00
switch ( closeLastViewCO - > currentIndex ( ) ) {
case 0 :
rc . close_buffer_with_last_view = " yes " ;
break ;
case 1 :
rc . close_buffer_with_last_view = " no " ;
break ;
case 2 :
rc . close_buffer_with_last_view = " ask " ;
break ;
default :
;
}
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefDocHandling : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
restoreCursorCB - > setChecked ( rc . use_lastfilepos ) ;
loadSessionCB - > setChecked ( rc . load_session ) ;
2007-11-15 12:58:44 +00:00
allowGeometrySessionCB - > setChecked ( rc . allow_geometry_session ) ;
2007-04-25 07:13:54 +00:00
// convert to minutes
2009-09-18 16:44:20 +00:00
bool autosave = rc . autosave > 0 ;
int mins = rc . autosave / 60 ;
if ( ! mins )
mins = 5 ;
2007-04-25 07:13:54 +00:00
autoSaveSB - > setValue ( mins ) ;
2009-09-18 16:44:20 +00:00
autoSaveCB - > setChecked ( autosave ) ;
autoSaveSB - > setEnabled ( autosave ) ;
backupCB - > setChecked ( rc . make_backup ) ;
2010-03-26 14:02:56 +00:00
saveCompressedCB - > setChecked ( rc . save_compressed ) ;
2015-05-23 17:49:33 +02:00
saveOriginCB - > setChecked ( rc . save_origin ) ;
2008-03-14 23:27:31 +00:00
openDocumentsInTabsCB - > setChecked ( rc . open_buffers_in_tabs ) ;
2010-12-11 15:21:23 +00:00
singleInstanceCB - > setChecked ( rc . single_instance & & ! rc . lyxpipes . empty ( ) ) ;
singleInstanceCB - > setEnabled ( ! rc . lyxpipes . empty ( ) ) ;
2009-10-05 23:06:29 +00:00
singleCloseTabButtonCB - > setChecked ( rc . single_close_tab_button ) ;
2012-09-15 23:37:55 +01:00
if ( rc . close_buffer_with_last_view = = " yes " )
closeLastViewCO - > setCurrentIndex ( 0 ) ;
else if ( rc . close_buffer_with_last_view = = " no " )
closeLastViewCO - > setCurrentIndex ( 1 ) ;
else if ( rc . close_buffer_with_last_view = = " ask " )
closeLastViewCO - > setCurrentIndex ( 2 ) ;
2007-04-25 07:13:54 +00:00
}
2013-03-02 12:24:32 +01:00
void PrefDocHandling : : on_clearSessionPB_clicked ( )
2008-09-22 07:14:30 +00:00
{
guiApp - > clearSession ( ) ;
}
2008-03-15 22:12:19 +00:00
/////////////////////////////////////////////////////////////////////
//
// PrefEdit
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefEdit : : PrefEdit ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( catEditing , N_ ( " Control " ) , form )
2008-03-15 22:12:19 +00:00
{
setupUi ( this ) ;
connect ( cursorFollowsCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2009-03-27 17:41:58 +00:00
connect ( scrollBelowCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2013-05-25 18:02:21 +02:00
connect ( macLikeCursorMovementCB , SIGNAL ( clicked ( ) ) ,
2010-11-29 11:26:08 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2008-03-15 22:12:19 +00:00
connect ( sortEnvironmentsCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( groupEnvironmentsCB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( macroEditStyleCO , SIGNAL ( activated ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2011-03-11 06:11:55 +00:00
connect ( cursorWidthSB , SIGNAL ( valueChanged ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2008-03-15 22:12:19 +00:00
connect ( fullscreenLimitGB , SIGNAL ( clicked ( ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( fullscreenWidthSB , SIGNAL ( valueChanged ( int ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
connect ( toggleTabbarCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2009-05-26 21:41:45 +00:00
connect ( toggleMenubarCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2008-03-15 22:12:19 +00:00
connect ( toggleScrollbarCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2014-02-25 20:48:56 -05:00
connect ( toggleStatusbarCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
2008-03-15 22:12:19 +00:00
connect ( toggleToolbarsCB , SIGNAL ( toggled ( bool ) ) ,
this , SIGNAL ( changed ( ) ) ) ;
}
2014-12-19 11:35:37 +01:00
void PrefEdit : : applyRC ( LyXRC & rc ) const
2008-03-15 22:12:19 +00:00
{
rc . cursor_follows_scrollbar = cursorFollowsCB - > isChecked ( ) ;
2009-03-27 17:41:58 +00:00
rc . scroll_below_document = scrollBelowCB - > isChecked ( ) ;
2013-05-25 18:02:21 +02:00
rc . mac_like_cursor_movement = macLikeCursorMovementCB - > isChecked ( ) ;
2008-03-15 22:12:19 +00:00
rc . sort_layouts = sortEnvironmentsCB - > isChecked ( ) ;
rc . group_layouts = groupEnvironmentsCB - > isChecked ( ) ;
switch ( macroEditStyleCO - > currentIndex ( ) ) {
case 0 : rc . macro_edit_style = LyXRC : : MACRO_EDIT_INLINE_BOX ; break ;
case 1 : rc . macro_edit_style = LyXRC : : MACRO_EDIT_INLINE ; break ;
case 2 : rc . macro_edit_style = LyXRC : : MACRO_EDIT_LIST ; break ;
}
2011-03-11 06:11:55 +00:00
rc . cursor_width = cursorWidthSB - > value ( ) ;
2008-03-15 22:12:19 +00:00
rc . full_screen_toolbars = toggleToolbarsCB - > isChecked ( ) ;
rc . full_screen_scrollbar = toggleScrollbarCB - > isChecked ( ) ;
2014-02-25 20:48:56 -05:00
rc . full_screen_statusbar = toggleStatusbarCB - > isChecked ( ) ;
2008-03-15 22:12:19 +00:00
rc . full_screen_tabbar = toggleTabbarCB - > isChecked ( ) ;
2009-05-26 21:41:45 +00:00
rc . full_screen_menubar = toggleMenubarCB - > isChecked ( ) ;
2008-03-15 22:12:19 +00:00
rc . full_screen_width = fullscreenWidthSB - > value ( ) ;
rc . full_screen_limit = fullscreenLimitGB - > isChecked ( ) ;
}
2014-12-19 11:35:37 +01:00
void PrefEdit : : updateRC ( LyXRC const & rc )
2008-03-15 22:12:19 +00:00
{
cursorFollowsCB - > setChecked ( rc . cursor_follows_scrollbar ) ;
2009-03-27 17:41:58 +00:00
scrollBelowCB - > setChecked ( rc . scroll_below_document ) ;
2013-05-25 18:02:21 +02:00
macLikeCursorMovementCB - > setChecked ( rc . mac_like_cursor_movement ) ;
2008-03-15 22:12:19 +00:00
sortEnvironmentsCB - > setChecked ( rc . sort_layouts ) ;
groupEnvironmentsCB - > setChecked ( rc . group_layouts ) ;
macroEditStyleCO - > setCurrentIndex ( rc . macro_edit_style ) ;
2011-03-11 06:11:55 +00:00
cursorWidthSB - > setValue ( rc . cursor_width ) ;
2008-03-15 22:12:19 +00:00
toggleScrollbarCB - > setChecked ( rc . full_screen_scrollbar ) ;
2015-06-25 08:21:46 -04:00
toggleStatusbarCB - > setChecked ( rc . full_screen_statusbar ) ;
2008-03-15 22:12:19 +00:00
toggleToolbarsCB - > setChecked ( rc . full_screen_toolbars ) ;
toggleTabbarCB - > setChecked ( rc . full_screen_tabbar ) ;
2009-05-26 21:41:45 +00:00
toggleMenubarCB - > setChecked ( rc . full_screen_menubar ) ;
2008-03-15 22:12:19 +00:00
fullscreenWidthSB - > setValue ( rc . full_screen_width ) ;
fullscreenLimitGB - > setChecked ( rc . full_screen_limit ) ;
}
2007-04-25 07:13:54 +00:00
2007-10-16 14:41:46 +00:00
/////////////////////////////////////////////////////////////////////
//
// PrefShortcuts
//
/////////////////////////////////////////////////////////////////////
2007-10-23 03:48:02 +00:00
GuiShortcutDialog : : GuiShortcutDialog ( QWidget * parent ) : QDialog ( parent )
{
Ui : : shortcutUi : : setupUi ( this ) ;
QDialog : : setModal ( true ) ;
}
2008-05-19 20:52:24 +00:00
PrefShortcuts : : PrefShortcuts ( GuiPreferences * form )
2015-09-12 22:39:50 +02:00
: PrefModule ( catEditing , N_ ( " Shortcuts " ) , form ) ,
editItem_ ( 0 ) , mathItem_ ( 0 ) , bufferItem_ ( 0 ) , layoutItem_ ( 0 ) ,
systemItem_ ( 0 )
2007-10-16 14:41:46 +00:00
{
setupUi ( this ) ;
2007-10-31 18:46:03 +00:00
shortcutsTW - > setColumnCount ( 2 ) ;
2007-10-17 05:13:34 +00:00
shortcutsTW - > headerItem ( ) - > setText ( 0 , qt_ ( " Function " ) ) ;
shortcutsTW - > headerItem ( ) - > setText ( 1 , qt_ ( " Shortcut " ) ) ;
shortcutsTW - > setSortingEnabled ( true ) ;
2007-10-19 16:49:04 +00:00
// Multi-selection can be annoying.
// shortcutsTW->setSelectionMode(QAbstractItemView::MultiSelection);
2007-10-16 17:48:37 +00:00
2007-10-16 14:41:46 +00:00
connect ( bindFilePB , SIGNAL ( clicked ( ) ) ,
2009-05-23 10:48:30 +00:00
this , SLOT ( selectBind ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( bindFileED , SIGNAL ( textChanged ( QString ) ) ,
2007-10-16 14:41:46 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2008-06-25 15:02:18 +00:00
2007-10-18 16:47:31 +00:00
shortcut_ = new GuiShortcutDialog ( this ) ;
2007-10-19 03:09:14 +00:00
shortcut_bc_ . setPolicy ( ButtonPolicy : : OkCancelPolicy ) ;
2018-07-10 13:04:02 +02:00
shortcut_bc_ . setOK ( shortcut_ - > buttonBox - > button ( QDialogButtonBox : : Ok ) ) ;
shortcut_bc_ . setCancel ( shortcut_ - > buttonBox - > button ( QDialogButtonBox : : Cancel ) ) ;
2007-10-19 03:09:14 +00:00
2018-07-10 13:04:02 +02:00
connect ( shortcut_ - > buttonBox , SIGNAL ( accepted ( ) ) ,
2007-10-20 20:50:56 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2018-07-10 13:04:02 +02:00
connect ( shortcut_ - > buttonBox , SIGNAL ( rejected ( ) ) ,
2007-10-19 03:09:14 +00:00
shortcut_ , SLOT ( reject ( ) ) ) ;
2007-10-23 03:48:02 +00:00
connect ( shortcut_ - > clearPB , SIGNAL ( clicked ( ) ) ,
2009-05-23 10:48:30 +00:00
this , SLOT ( shortcutClearPressed ( ) ) ) ;
2008-07-22 08:29:50 +00:00
connect ( shortcut_ - > removePB , SIGNAL ( clicked ( ) ) ,
2009-05-23 10:48:30 +00:00
this , SLOT ( shortcutRemovePressed ( ) ) ) ;
2018-07-10 13:04:02 +02:00
connect ( shortcut_ - > buttonBox , SIGNAL ( accepted ( ) ) ,
2009-05-23 10:48:30 +00:00
this , SLOT ( shortcutOkPressed ( ) ) ) ;
2018-07-10 13:04:02 +02:00
connect ( shortcut_ - > buttonBox , SIGNAL ( rejected ( ) ) ,
2009-05-23 10:48:30 +00:00
this , SLOT ( shortcutCancelPressed ( ) ) ) ;
2007-10-16 14:41:46 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefShortcuts : : applyRC ( LyXRC & rc ) const
2007-10-16 14:41:46 +00:00
{
rc . bind_file = internal_path ( fromqstr ( bindFileED - > text ( ) ) ) ;
2007-10-20 20:50:56 +00:00
// write user_bind and user_unbind to .lyx/bind/user.bind
2010-04-21 01:19:09 +00:00
FileName bind_dir ( addPath ( package ( ) . user_support ( ) . absFileName ( ) , " bind " ) ) ;
2007-12-14 22:27:47 +00:00
if ( ! bind_dir . exists ( ) & & ! bind_dir . createDirectory ( 0777 ) ) {
2007-10-20 20:50:56 +00:00
lyxerr < < " LyX could not create the user bind directory ' "
< < bind_dir < < " '. All user-defined key bindings will be lost. " < < endl ;
return ;
}
2007-12-14 22:27:47 +00:00
if ( ! bind_dir . isDirWritable ( ) ) {
2007-10-20 20:50:56 +00:00
lyxerr < < " LyX could not write to the user bind directory ' "
< < bind_dir < < " '. All user-defined key bindings will be lost. " < < endl ;
return ;
}
2010-04-21 01:19:09 +00:00
FileName user_bind_file ( bind_dir . absFileName ( ) + " /user.bind " ) ;
2008-12-22 10:41:37 +00:00
user_unbind_ . write ( user_bind_file . toFilesystemEncoding ( ) , false , true ) ;
user_bind_ . write ( user_bind_file . toFilesystemEncoding ( ) , true , false ) ;
2007-10-20 20:50:56 +00:00
// immediately apply the keybindings. Why this is not done before?
// The good thing is that the menus are updated automatically.
theTopLevelKeymap ( ) . clear ( ) ;
2007-10-29 19:45:43 +00:00
theTopLevelKeymap ( ) . read ( " site " ) ;
2009-07-16 23:12:45 +00:00
theTopLevelKeymap ( ) . read ( rc . bind_file , 0 , KeyMap : : Fallback ) ;
theTopLevelKeymap ( ) . read ( " user " , 0 , KeyMap : : MissingOK ) ;
2007-10-16 14:41:46 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefShortcuts : : updateRC ( LyXRC const & rc )
2007-10-17 05:13:34 +00:00
{
bindFileED - > setText ( toqstr ( external_path ( rc . bind_file ) ) ) ;
2007-10-20 20:50:56 +00:00
//
system_bind_ . clear ( ) ;
user_bind_ . clear ( ) ;
user_unbind_ . clear ( ) ;
2008-09-23 17:04:25 +00:00
system_bind_ . read ( " site " ) ;
2007-10-20 20:50:56 +00:00
system_bind_ . read ( rc . bind_file ) ;
// \unbind in user.bind is added to user_unbind_
2009-07-16 23:12:45 +00:00
user_bind_ . read ( " user " , & user_unbind_ , KeyMap : : MissingOK ) ;
2007-10-20 20:50:56 +00:00
updateShortcutsTW ( ) ;
}
void PrefShortcuts : : updateShortcutsTW ( )
{
2007-10-17 05:13:34 +00:00
shortcutsTW - > clear ( ) ;
2007-10-20 20:50:56 +00:00
editItem_ = new QTreeWidgetItem ( shortcutsTW ) ;
2010-08-14 15:19:05 +00:00
editItem_ - > setText ( 0 , qt_ ( " Cursor, Mouse and Editing Functions " ) ) ;
2007-10-20 20:50:56 +00:00
editItem_ - > setFlags ( editItem_ - > flags ( ) & ~ Qt : : ItemIsSelectable ) ;
2007-10-18 15:48:51 +00:00
2007-10-20 20:50:56 +00:00
mathItem_ = new QTreeWidgetItem ( shortcutsTW ) ;
2008-04-05 10:33:31 +00:00
mathItem_ - > setText ( 0 , qt_ ( " Mathematical Symbols " ) ) ;
2007-10-20 20:50:56 +00:00
mathItem_ - > setFlags ( mathItem_ - > flags ( ) & ~ Qt : : ItemIsSelectable ) ;
2008-06-25 15:02:18 +00:00
2007-10-20 20:50:56 +00:00
bufferItem_ = new QTreeWidgetItem ( shortcutsTW ) ;
2008-04-21 22:19:31 +00:00
bufferItem_ - > setText ( 0 , qt_ ( " Document and Window " ) ) ;
2007-10-20 20:50:56 +00:00
bufferItem_ - > setFlags ( bufferItem_ - > flags ( ) & ~ Qt : : ItemIsSelectable ) ;
2008-06-25 15:02:18 +00:00
2007-10-20 20:50:56 +00:00
layoutItem_ = new QTreeWidgetItem ( shortcutsTW ) ;
2008-04-05 10:33:31 +00:00
layoutItem_ - > setText ( 0 , qt_ ( " Font, Layouts and Textclasses " ) ) ;
2007-10-20 20:50:56 +00:00
layoutItem_ - > setFlags ( layoutItem_ - > flags ( ) & ~ Qt : : ItemIsSelectable ) ;
2007-10-17 05:13:34 +00:00
2007-10-20 20:50:56 +00:00
systemItem_ = new QTreeWidgetItem ( shortcutsTW ) ;
2008-04-05 10:33:31 +00:00
systemItem_ - > setText ( 0 , qt_ ( " System and Miscellaneous " ) ) ;
2007-10-20 20:50:56 +00:00
systemItem_ - > setFlags ( systemItem_ - > flags ( ) & ~ Qt : : ItemIsSelectable ) ;
2007-10-17 05:13:34 +00:00
2007-10-18 15:48:51 +00:00
// listBindings(unbound=true) lists all bound and unbound lfuns
2007-10-20 20:50:56 +00:00
// Items in this list is tagged by its source.
2008-06-25 15:02:18 +00:00
KeyMap : : BindingList bindinglist = system_bind_ . listBindings ( true ,
2008-09-23 13:53:38 +00:00
KeyMap : : System ) ;
2007-10-20 20:50:56 +00:00
KeyMap : : BindingList user_bindinglist = user_bind_ . listBindings ( false ,
2008-09-23 13:53:38 +00:00
KeyMap : : UserBind ) ;
2007-10-20 20:50:56 +00:00
KeyMap : : BindingList user_unbindinglist = user_unbind_ . listBindings ( false ,
2008-09-23 13:53:38 +00:00
KeyMap : : UserUnbind ) ;
2007-10-20 20:50:56 +00:00
bindinglist . insert ( bindinglist . end ( ) , user_bindinglist . begin ( ) ,
user_bindinglist . end ( ) ) ;
bindinglist . insert ( bindinglist . end ( ) , user_unbindinglist . begin ( ) ,
user_unbindinglist . end ( ) ) ;
2007-10-17 05:13:34 +00:00
2007-10-18 15:48:51 +00:00
KeyMap : : BindingList : : const_iterator it = bindinglist . begin ( ) ;
KeyMap : : BindingList : : const_iterator it_end = bindinglist . end ( ) ;
2007-10-20 20:50:56 +00:00
for ( ; it ! = it_end ; + + it )
2016-02-23 22:02:02 +00:00
insertShortcutItem ( it - > request , it - > sequence , it - > tag ) ;
2007-10-17 05:13:34 +00:00
shortcutsTW - > sortItems ( 0 , Qt : : AscendingOrder ) ;
2016-02-23 20:46:19 +00:00
on_shortcutsTW_itemSelectionChanged ( ) ;
on_searchLE_textEdited ( ) ;
2008-04-21 10:10:12 +00:00
shortcutsTW - > resizeColumnToContents ( 0 ) ;
2007-10-19 03:09:14 +00:00
}
2016-05-29 20:58:33 +01:00
//static
KeyMap : : ItemType PrefShortcuts : : itemType ( QTreeWidgetItem & item )
{
return static_cast < KeyMap : : ItemType > ( item . data ( 0 , Qt : : UserRole ) . toInt ( ) ) ;
}
2016-02-23 22:02:02 +00:00
//static
bool PrefShortcuts : : isAlwaysHidden ( QTreeWidgetItem & item )
{
// Hide rebound system settings that are empty
return itemType ( item ) = = KeyMap : : UserUnbind & & item . text ( 1 ) . isEmpty ( ) ;
}
2008-09-23 13:53:38 +00:00
void PrefShortcuts : : setItemType ( QTreeWidgetItem * item , KeyMap : : ItemType tag )
2007-10-20 20:50:56 +00:00
{
item - > setData ( 0 , Qt : : UserRole , QVariant ( tag ) ) ;
2007-10-31 18:46:03 +00:00
QFont font ;
2007-10-20 20:50:56 +00:00
switch ( tag ) {
2008-09-23 13:53:38 +00:00
case KeyMap : : System :
2007-10-20 20:50:56 +00:00
break ;
2008-09-23 13:53:38 +00:00
case KeyMap : : UserBind :
2007-10-31 18:46:03 +00:00
font . setBold ( true ) ;
2007-10-20 20:50:56 +00:00
break ;
2008-09-23 13:53:38 +00:00
case KeyMap : : UserUnbind :
2007-10-31 18:46:03 +00:00
font . setStrikeOut ( true ) ;
2007-10-21 05:30:43 +00:00
break ;
2007-10-31 18:46:03 +00:00
// this item is not displayed now.
2008-09-23 13:53:38 +00:00
case KeyMap : : UserExtraUnbind :
2007-10-31 18:46:03 +00:00
font . setStrikeOut ( true ) ;
2007-10-22 13:56:59 +00:00
break ;
}
2016-02-23 22:02:02 +00:00
item - > setHidden ( isAlwaysHidden ( * item ) ) ;
2007-10-31 18:46:03 +00:00
item - > setFont ( 1 , font ) ;
2007-10-20 20:50:56 +00:00
}
QTreeWidgetItem * PrefShortcuts : : insertShortcutItem ( FuncRequest const & lfun ,
2008-09-23 13:53:38 +00:00
KeySequence const & seq , KeyMap : : ItemType tag )
2007-10-20 20:50:56 +00:00
{
2010-04-09 19:00:42 +00:00
FuncCode const action = lfun . action ( ) ;
2007-10-20 20:50:56 +00:00
string const action_name = lyxaction . getActionName ( action ) ;
2008-06-25 15:02:18 +00:00
QString const lfun_name = toqstr ( from_utf8 ( action_name )
2008-04-07 20:43:02 +00:00
+ ' ' + lfun . argument ( ) ) ;
2007-10-31 17:15:10 +00:00
QString const shortcut = toqstr ( seq . print ( KeySequence : : ForGui ) ) ;
2007-10-20 20:50:56 +00:00
2008-04-07 20:43:02 +00:00
QTreeWidgetItem * newItem = 0 ;
2007-10-20 20:50:56 +00:00
// for unbind items, try to find an existing item in the system bind list
2008-09-23 13:53:38 +00:00
if ( tag = = KeyMap : : UserUnbind ) {
2008-06-25 15:02:18 +00:00
QList < QTreeWidgetItem * > const items = shortcutsTW - > findItems ( lfun_name ,
2007-10-20 20:50:56 +00:00
Qt : : MatchFlags ( Qt : : MatchExactly | Qt : : MatchRecursive ) , 0 ) ;
2007-10-21 22:12:12 +00:00
for ( int i = 0 ; i < items . size ( ) ; + + i ) {
2015-09-12 18:40:52 +02:00
if ( items [ i ] - > text ( 1 ) = = shortcut ) {
2007-10-21 05:30:43 +00:00
newItem = items [ i ] ;
break ;
}
2015-09-12 18:40:52 +02:00
}
2008-09-23 13:53:38 +00:00
// if not found, this unbind item is KeyMap::UserExtraUnbind
2008-06-25 15:02:18 +00:00
// Such an item is not displayed to avoid confusion (what is
2007-10-30 15:25:30 +00:00
// unmatched removed?).
if ( ! newItem ) {
2008-04-07 20:43:02 +00:00
return 0 ;
2007-10-30 15:25:30 +00:00
}
2007-10-20 20:50:56 +00:00
}
if ( ! newItem ) {
switch ( lyxaction . getActionType ( action ) ) {
case LyXAction : : Hidden :
2008-04-07 20:43:02 +00:00
return 0 ;
2007-10-20 20:50:56 +00:00
case LyXAction : : Edit :
newItem = new QTreeWidgetItem ( editItem_ ) ;
break ;
case LyXAction : : Math :
newItem = new QTreeWidgetItem ( mathItem_ ) ;
break ;
case LyXAction : : Buffer :
newItem = new QTreeWidgetItem ( bufferItem_ ) ;
break ;
case LyXAction : : Layout :
newItem = new QTreeWidgetItem ( layoutItem_ ) ;
break ;
case LyXAction : : System :
newItem = new QTreeWidgetItem ( systemItem_ ) ;
break ;
default :
// this should not happen
newItem = new QTreeWidgetItem ( shortcutsTW ) ;
}
}
newItem - > setText ( 0 , lfun_name ) ;
newItem - > setText ( 1 , shortcut ) ;
2007-10-31 17:15:10 +00:00
// record BindFile representation to recover KeySequence when needed.
2007-11-02 20:26:28 +00:00
newItem - > setData ( 1 , Qt : : UserRole , toqstr ( seq . print ( KeySequence : : BindFile ) ) ) ;
2015-10-09 08:08:49 +02:00
setItemType ( newItem , tag ) ;
2007-10-20 20:50:56 +00:00
return newItem ;
}
2007-10-19 03:09:14 +00:00
void PrefShortcuts : : on_shortcutsTW_itemSelectionChanged ( )
{
QList < QTreeWidgetItem * > items = shortcutsTW - > selectedItems ( ) ;
removePB - > setEnabled ( ! items . isEmpty ( ) & & ! items [ 0 ] - > text ( 1 ) . isEmpty ( ) ) ;
2008-04-21 10:10:12 +00:00
modifyPB - > setEnabled ( ! items . isEmpty ( ) ) ;
2007-10-20 20:50:56 +00:00
if ( items . isEmpty ( ) )
return ;
2008-06-25 15:02:18 +00:00
2016-05-29 20:58:33 +01:00
if ( itemType ( * items [ 0 ] ) = = KeyMap : : UserUnbind )
2008-04-05 10:46:48 +00:00
removePB - > setText ( qt_ ( " Res&tore " ) ) ;
2007-10-20 20:50:56 +00:00
else
2008-04-05 10:46:48 +00:00
removePB - > setText ( qt_ ( " Remo&ve " ) ) ;
2007-10-19 03:09:14 +00:00
}
void PrefShortcuts : : on_shortcutsTW_itemDoubleClicked ( )
2008-04-21 10:10:12 +00:00
{
modifyShortcut ( ) ;
}
void PrefShortcuts : : modifyShortcut ( )
2007-10-19 03:09:14 +00:00
{
2007-10-20 20:50:56 +00:00
QTreeWidgetItem * item = shortcutsTW - > currentItem ( ) ;
if ( item - > flags ( ) & Qt : : ItemIsSelectable ) {
shortcut_ - > lfunLE - > setText ( item - > text ( 0 ) ) ;
2010-03-11 17:34:59 +00:00
save_lfun_ = item - > text ( 0 ) . trimmed ( ) ;
2008-07-21 14:54:07 +00:00
shortcut_ - > shortcutWG - > setText ( item - > text ( 1 ) ) ;
2008-07-22 08:29:50 +00:00
KeySequence seq ;
seq . parse ( fromqstr ( item - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ) ;
shortcut_ - > shortcutWG - > setKeySequence ( seq ) ;
2008-07-21 14:54:07 +00:00
shortcut_ - > shortcutWG - > setFocus ( ) ;
2007-10-20 20:50:56 +00:00
shortcut_ - > exec ( ) ;
}
2007-10-17 05:13:34 +00:00
}
2016-02-23 22:02:02 +00:00
void PrefShortcuts : : unhideEmpty ( QString const & lfun , bool select )
{
// list of items that match lfun
QList < QTreeWidgetItem * > items = shortcutsTW - > findItems ( lfun ,
Qt : : MatchFlags ( Qt : : MatchExactly | Qt : : MatchRecursive ) , 0 ) ;
for ( int i = 0 ; i < items . size ( ) ; + + i ) {
QTreeWidgetItem * item = items [ i ] ;
if ( isAlwaysHidden ( * item ) ) {
setItemType ( item , KeyMap : : System ) ;
if ( select )
shortcutsTW - > setCurrentItem ( item ) ;
return ;
}
}
}
2008-07-22 09:35:46 +00:00
void PrefShortcuts : : removeShortcut ( )
2007-10-18 16:47:31 +00:00
{
2007-10-20 20:50:56 +00:00
// it seems that only one item can be selected, but I am
// removing all selected items anyway.
2007-10-19 03:09:14 +00:00
QList < QTreeWidgetItem * > items = shortcutsTW - > selectedItems ( ) ;
2007-10-20 20:50:56 +00:00
for ( int i = 0 ; i < items . size ( ) ; + + i ) {
2007-10-31 17:15:10 +00:00
string shortcut = fromqstr ( items [ i ] - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ;
2007-10-20 20:50:56 +00:00
string lfun = fromqstr ( items [ i ] - > text ( 0 ) ) ;
FuncRequest func = lyxaction . lookupFunc ( lfun ) ;
2008-06-25 15:02:18 +00:00
2016-05-29 20:58:33 +01:00
switch ( itemType ( * items [ i ] ) ) {
2008-09-23 13:53:38 +00:00
case KeyMap : : System : {
2007-10-20 20:50:56 +00:00
// for system bind, we do not touch the item
// but add an user unbind item
user_unbind_ . bind ( shortcut , func ) ;
2008-09-23 13:53:38 +00:00
setItemType ( items [ i ] , KeyMap : : UserUnbind ) ;
2008-04-05 10:46:48 +00:00
removePB - > setText ( qt_ ( " Res&tore " ) ) ;
2007-10-20 20:50:56 +00:00
break ;
}
2008-09-23 13:53:38 +00:00
case KeyMap : : UserBind : {
2007-10-20 20:50:56 +00:00
// for user_bind, we remove this bind
QTreeWidgetItem * parent = items [ i ] - > parent ( ) ;
2007-10-31 18:46:03 +00:00
int itemIdx = parent - > indexOfChild ( items [ i ] ) ;
parent - > takeChild ( itemIdx ) ;
if ( itemIdx > 0 )
shortcutsTW - > scrollToItem ( parent - > child ( itemIdx - 1 ) ) ;
else
shortcutsTW - > scrollToItem ( parent ) ;
2007-10-20 20:50:56 +00:00
user_bind_ . unbind ( shortcut , func ) ;
2016-02-23 22:02:02 +00:00
// If this user binding hid an empty system binding, unhide the
// latter and select it.
unhideEmpty ( items [ i ] - > text ( 0 ) , true ) ;
2007-10-20 20:50:56 +00:00
break ;
}
2008-09-23 13:53:38 +00:00
case KeyMap : : UserUnbind : {
2007-10-20 20:50:56 +00:00
// for user_unbind, we remove the unbind, and the item
2008-09-23 13:53:38 +00:00
// become KeyMap::System again.
2016-02-23 20:46:19 +00:00
KeySequence seq ;
seq . parse ( shortcut ) ;
// Ask the user to replace current binding
if ( ! validateNewShortcut ( func , seq , QString ( ) ) )
break ;
2007-10-20 20:50:56 +00:00
user_unbind_ . unbind ( shortcut , func ) ;
2008-09-23 13:53:38 +00:00
setItemType ( items [ i ] , KeyMap : : System ) ;
2008-04-05 10:46:48 +00:00
removePB - > setText ( qt_ ( " Remo&ve " ) ) ;
2007-10-20 20:50:56 +00:00
break ;
}
2008-09-23 13:53:38 +00:00
case KeyMap : : UserExtraUnbind : {
2007-10-21 05:30:43 +00:00
// for user unbind that is not in system bind file,
// remove this unbind file
QTreeWidgetItem * parent = items [ i ] - > parent ( ) ;
parent - > takeChild ( parent - > indexOfChild ( items [ i ] ) ) ;
user_unbind_ . unbind ( shortcut , func ) ;
}
2007-10-20 20:50:56 +00:00
}
}
2007-10-18 16:47:31 +00:00
}
2016-02-22 00:36:33 +00:00
void PrefShortcuts : : deactivateShortcuts ( QList < QTreeWidgetItem * > const & items )
{
for ( int i = 0 ; i < items . size ( ) ; + + i ) {
string shortcut = fromqstr ( items [ i ] - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ;
string lfun = fromqstr ( items [ i ] - > text ( 0 ) ) ;
FuncRequest func = lyxaction . lookupFunc ( lfun ) ;
2016-05-29 20:58:33 +01:00
switch ( itemType ( * items [ i ] ) ) {
2016-02-22 00:36:33 +00:00
case KeyMap : : System :
// for system bind, we do not touch the item
// but add an user unbind item
user_unbind_ . bind ( shortcut , func ) ;
setItemType ( items [ i ] , KeyMap : : UserUnbind ) ;
break ;
case KeyMap : : UserBind : {
// for user_bind, we remove this bind
QTreeWidgetItem * parent = items [ i ] - > parent ( ) ;
int itemIdx = parent - > indexOfChild ( items [ i ] ) ;
parent - > takeChild ( itemIdx ) ;
user_bind_ . unbind ( shortcut , func ) ;
2016-02-23 22:02:02 +00:00
unhideEmpty ( items [ i ] - > text ( 0 ) , false ) ;
2016-02-22 00:36:33 +00:00
break ;
}
default :
break ;
}
}
}
2009-05-23 10:48:30 +00:00
void PrefShortcuts : : selectBind ( )
2008-07-22 09:35:46 +00:00
{
QString file = form_ - > browsebind ( internalPath ( bindFileED - > text ( ) ) ) ;
if ( ! file . isEmpty ( ) ) {
bindFileED - > setText ( file ) ;
system_bind_ = KeyMap ( ) ;
system_bind_ . read ( fromqstr ( file ) ) ;
updateShortcutsTW ( ) ;
}
}
void PrefShortcuts : : on_modifyPB_pressed ( )
{
modifyShortcut ( ) ;
}
void PrefShortcuts : : on_newPB_pressed ( )
{
shortcut_ - > lfunLE - > clear ( ) ;
shortcut_ - > shortcutWG - > reset ( ) ;
save_lfun_ = QString ( ) ;
shortcut_ - > exec ( ) ;
}
void PrefShortcuts : : on_removePB_pressed ( )
{
2010-03-29 06:54:27 +00:00
changed ( ) ;
2008-07-22 09:35:46 +00:00
removeShortcut ( ) ;
}
2007-10-29 08:56:30 +00:00
void PrefShortcuts : : on_searchLE_textEdited ( )
2007-10-18 16:47:31 +00:00
{
2007-10-25 03:08:22 +00:00
if ( searchLE - > text ( ) . isEmpty ( ) ) {
// show all hidden items
QTreeWidgetItemIterator it ( shortcutsTW , QTreeWidgetItemIterator : : Hidden ) ;
2016-02-23 22:02:02 +00:00
for ( ; * it ; + + it )
shortcutsTW - > setItemHidden ( * it , isAlwaysHidden ( * * it ) ) ;
// close all categories
for ( int i = 0 ; i < shortcutsTW - > topLevelItemCount ( ) ; + + i )
shortcutsTW - > collapseItem ( shortcutsTW - > topLevelItem ( i ) ) ;
2007-10-25 03:08:22 +00:00
return ;
}
2007-10-20 20:50:56 +00:00
// search both columns
QList < QTreeWidgetItem * > matched = shortcutsTW - > findItems ( searchLE - > text ( ) ,
Qt : : MatchFlags ( Qt : : MatchContains | Qt : : MatchRecursive ) , 0 ) ;
matched + = shortcutsTW - > findItems ( searchLE - > text ( ) ,
Qt : : MatchFlags ( Qt : : MatchContains | Qt : : MatchRecursive ) , 1 ) ;
2008-06-25 15:02:18 +00:00
2007-10-19 16:49:04 +00:00
// hide everyone (to avoid searching in matched QList repeatedly
QTreeWidgetItemIterator it ( shortcutsTW , QTreeWidgetItemIterator : : Selectable ) ;
while ( * it )
shortcutsTW - > setItemHidden ( * it + + , true ) ;
// show matched items
2016-02-23 22:02:02 +00:00
for ( int i = 0 ; i < matched . size ( ) ; + + i )
if ( ! isAlwaysHidden ( * matched [ i ] ) ) {
shortcutsTW - > setItemHidden ( matched [ i ] , false ) ;
shortcutsTW - > setItemExpanded ( matched [ i ] - > parent ( ) , true ) ;
}
2007-10-19 03:09:14 +00:00
}
2008-09-24 14:56:43 +00:00
docstring makeCmdString ( FuncRequest const & f )
{
2010-04-09 19:00:42 +00:00
docstring actionStr = from_ascii ( lyxaction . getActionName ( f . action ( ) ) ) ;
2008-09-24 14:56:43 +00:00
if ( ! f . argument ( ) . empty ( ) )
actionStr + = " " + f . argument ( ) ;
return actionStr ;
}
2016-02-23 20:46:19 +00:00
FuncRequest PrefShortcuts : : currentBinding ( KeySequence const & k )
2007-10-19 03:09:14 +00:00
{
2016-02-23 20:46:19 +00:00
FuncRequest res = user_bind_ . getBinding ( k ) ;
if ( res . action ( ) ! = LFUN_UNKNOWN_ACTION )
return res ;
res = system_bind_ . getBinding ( k ) ;
// Check if it is unbound. Note: user_unbind_ can only unbind one
// FuncRequest per key sequence.
if ( user_unbind_ . getBinding ( k ) = = res )
return FuncRequest : : unknown ;
return res ;
}
2007-10-20 20:50:56 +00:00
2016-02-23 20:46:19 +00:00
bool PrefShortcuts : : validateNewShortcut ( FuncRequest const & func ,
KeySequence const & k ,
QString const & lfun_to_modify )
{
2010-04-09 19:00:42 +00:00
if ( func . action ( ) = = LFUN_UNKNOWN_ACTION ) {
2007-10-20 20:50:56 +00:00
Alert : : error ( _ ( " Failed to create shortcut " ) ,
2007-10-24 22:02:48 +00:00
_ ( " Unknown or invalid LyX function " ) ) ;
2016-02-23 20:46:19 +00:00
return false ;
2007-10-20 20:50:56 +00:00
}
2016-07-05 21:38:24 +02:00
// It is not currently possible to bind Hidden lfuns such as self-insert. In
// the future, to remove this limitation, see GuiPrefs::insertShortcutItem
// and how it is used in GuiPrefs::shortcutOkPressed.
if ( lyxaction . getActionType ( func . action ( ) ) = = LyXAction : : Hidden ) {
Alert : : error ( _ ( " Failed to create shortcut " ) ,
_ ( " This LyX function is hidden and cannot be bound. " ) ) ;
return false ;
}
2007-10-26 20:43:22 +00:00
if ( k . length ( ) = = 0 ) {
2007-10-20 20:50:56 +00:00
Alert : : error ( _ ( " Failed to create shortcut " ) ,
2007-10-26 20:43:22 +00:00
_ ( " Invalid or empty key sequence " ) ) ;
2016-02-23 20:46:19 +00:00
return false ;
2007-10-20 20:50:56 +00:00
}
2016-02-23 20:46:19 +00:00
FuncRequest oldBinding = currentBinding ( k ) ;
2010-03-29 09:13:00 +00:00
if ( oldBinding = = func )
2016-02-23 20:46:19 +00:00
// nothing to change
return false ;
2014-12-07 18:35:28 +01:00
2014-03-15 15:36:55 -04:00
// make sure this key isn't already bound---and, if so, prompt user
2016-02-23 20:46:19 +00:00
// (exclude the lfun the user already wants to modify)
2010-03-11 17:34:59 +00:00
docstring const action_string = makeCmdString ( oldBinding ) ;
2016-02-23 20:46:19 +00:00
if ( oldBinding . action ( ) ! = LFUN_UNKNOWN_ACTION
& & lfun_to_modify ! = toqstr ( action_string ) ) {
2014-03-15 15:36:55 -04:00
docstring const new_action_string = makeCmdString ( func ) ;
docstring const text = bformat ( _ ( " Shortcut `%1$s' is already bound to "
" %2$s. \n "
" Are you sure you want to unbind the "
" current shortcut and bind it to %3$s? " ) ,
k . print ( KeySequence : : ForGui ) , action_string ,
new_action_string ) ;
int ret = Alert : : prompt ( _ ( " Redefine shortcut? " ) ,
text , 0 , 1 , _ ( " &Redefine " ) , _ ( " &Cancel " ) ) ;
if ( ret ! = 0 )
2016-02-23 20:46:19 +00:00
return false ;
2014-03-15 15:36:55 -04:00
QString const sequence_text = toqstr ( k . print ( KeySequence : : ForGui ) ) ;
QList < QTreeWidgetItem * > items = shortcutsTW - > findItems ( sequence_text ,
Qt : : MatchFlags ( Qt : : MatchExactly | Qt : : MatchRecursive ) , 1 ) ;
2016-02-22 00:36:33 +00:00
deactivateShortcuts ( items ) ;
2007-10-20 20:50:56 +00:00
}
2016-02-23 20:46:19 +00:00
return true ;
}
void PrefShortcuts : : shortcutOkPressed ( )
{
QString const new_lfun = shortcut_ - > lfunLE - > text ( ) ;
FuncRequest func = lyxaction . lookupFunc ( fromqstr ( new_lfun ) ) ;
KeySequence k = shortcut_ - > shortcutWG - > getKeySequence ( ) ;
// save_lfun_ contains the text of the lfun to modify, if the user clicked
// "modify", or is empty if they clicked "new" (which I do not really like)
if ( ! validateNewShortcut ( func , k , save_lfun_ ) )
return ;
2008-06-25 15:02:18 +00:00
2016-02-22 00:36:33 +00:00
if ( ! save_lfun_ . isEmpty ( ) ) {
2008-07-22 09:35:46 +00:00
// real modification of the lfun's shortcut,
// so remove the previous one
2016-02-22 00:36:33 +00:00
QList < QTreeWidgetItem * > to_modify = shortcutsTW - > selectedItems ( ) ;
deactivateShortcuts ( to_modify ) ;
}
shortcut_ - > accept ( ) ;
2008-07-22 09:35:46 +00:00
2008-09-23 13:53:38 +00:00
QTreeWidgetItem * item = insertShortcutItem ( func , k , KeyMap : : UserBind ) ;
2007-10-20 20:50:56 +00:00
if ( item ) {
2007-10-26 20:43:22 +00:00
user_bind_ . bind ( & k , func ) ;
2007-10-20 20:50:56 +00:00
shortcutsTW - > sortItems ( 0 , Qt : : AscendingOrder ) ;
shortcutsTW - > setItemExpanded ( item - > parent ( ) , true ) ;
2016-02-22 00:36:33 +00:00
shortcutsTW - > setCurrentItem ( item ) ;
2007-10-20 20:50:56 +00:00
shortcutsTW - > scrollToItem ( item ) ;
} else {
Alert : : error ( _ ( " Failed to create shortcut " ) ,
_ ( " Can not insert shortcut to the list " ) ) ;
return ;
}
2007-10-18 16:47:31 +00:00
}
2009-05-23 10:48:30 +00:00
void PrefShortcuts : : shortcutCancelPressed ( )
2008-07-21 14:54:07 +00:00
{
shortcut_ - > shortcutWG - > reset ( ) ;
}
2009-05-23 10:48:30 +00:00
void PrefShortcuts : : shortcutClearPressed ( )
2007-10-23 03:48:02 +00:00
{
2008-07-21 14:54:07 +00:00
shortcut_ - > shortcutWG - > reset ( ) ;
2007-10-23 03:48:02 +00:00
}
2009-05-23 10:48:30 +00:00
void PrefShortcuts : : shortcutRemovePressed ( )
2008-07-22 08:29:50 +00:00
{
shortcut_ - > shortcutWG - > removeFromSequence ( ) ;
}
2007-10-19 16:49:04 +00:00
/////////////////////////////////////////////////////////////////////
//
// PrefIdentity
//
/////////////////////////////////////////////////////////////////////
2008-05-19 20:52:24 +00:00
PrefIdentity : : PrefIdentity ( GuiPreferences * form )
2013-05-12 18:30:59 +02:00
: PrefModule ( QString ( ) , N_ ( " Identity " ) , form )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2007-10-25 20:36:17 +00:00
connect ( nameED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2007-10-25 20:36:17 +00:00
connect ( emailED , SIGNAL ( textChanged ( QString ) ) ,
2007-04-25 07:13:54 +00:00
this , SIGNAL ( changed ( ) ) ) ;
2011-09-12 14:22:05 +00:00
nameED - > setValidator ( new NoNewLineValidator ( nameED ) ) ;
emailED - > setValidator ( new NoNewLineValidator ( emailED ) ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void PrefIdentity : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
rc . user_name = fromqstr ( nameED - > text ( ) ) ;
rc . user_email = fromqstr ( emailED - > text ( ) ) ;
}
2014-12-19 11:35:37 +01:00
void PrefIdentity : : updateRC ( LyXRC const & rc )
2007-04-25 07:13:54 +00:00
{
nameED - > setText ( toqstr ( rc . user_name ) ) ;
emailED - > setText ( toqstr ( rc . user_email ) ) ;
}
/////////////////////////////////////////////////////////////////////
//
2007-10-07 09:47:12 +00:00
// GuiPreferences
2007-04-25 07:13:54 +00:00
//
/////////////////////////////////////////////////////////////////////
2007-11-23 09:44:02 +00:00
GuiPreferences : : GuiPreferences ( GuiView & lv )
2019-02-26 16:37:41 +01:00
: GuiDialog ( lv , " prefs " , qt_ ( " Preferences " ) )
2007-04-25 07:13:54 +00:00
{
setupUi ( this ) ;
2007-09-05 20:33:29 +00:00
2007-04-25 07:13:54 +00:00
QDialog : : setModal ( false ) ;
2018-07-10 09:04:42 +02:00
connect ( buttonBox , SIGNAL ( clicked ( QAbstractButton * ) ) ,
this , SLOT ( slotButtonBox ( QAbstractButton * ) ) ) ;
2007-04-25 07:13:54 +00:00
2008-05-19 20:52:24 +00:00
addModule ( new PrefUserInterface ( this ) ) ;
2013-03-02 12:24:32 +01:00
addModule ( new PrefDocHandling ( this ) ) ;
2008-05-19 20:52:24 +00:00
addModule ( new PrefEdit ( this ) ) ;
addModule ( new PrefShortcuts ( this ) ) ;
2010-12-29 13:50:22 +00:00
PrefScreenFonts * screenfonts = new PrefScreenFonts ( this ) ;
connect ( this , SIGNAL ( prefsApplied ( LyXRC const & ) ) ,
screenfonts , SLOT ( updateScreenFontSizes ( LyXRC const & ) ) ) ;
addModule ( screenfonts ) ;
2008-05-19 20:52:24 +00:00
addModule ( new PrefColors ( this ) ) ;
addModule ( new PrefDisplay ( this ) ) ;
addModule ( new PrefInput ( this ) ) ;
addModule ( new PrefCompletion ( this ) ) ;
2007-04-25 07:13:54 +00:00
2008-05-19 20:52:24 +00:00
addModule ( new PrefPaths ( this ) ) ;
2007-04-25 07:13:54 +00:00
2008-05-19 20:52:24 +00:00
addModule ( new PrefIdentity ( this ) ) ;
2007-04-25 07:13:54 +00:00
2008-05-19 20:52:24 +00:00
addModule ( new PrefLanguage ( this ) ) ;
addModule ( new PrefSpellchecker ( this ) ) ;
2007-04-25 07:13:54 +00:00
2014-12-07 18:35:28 +01:00
PrefOutput * output = new PrefOutput ( this ) ;
2010-04-15 14:25:25 +00:00
addModule ( output ) ;
2008-05-19 20:52:24 +00:00
addModule ( new PrefLatex ( this ) ) ;
2007-04-25 07:13:54 +00:00
2007-09-05 20:33:29 +00:00
PrefConverters * converters = new PrefConverters ( this ) ;
PrefFileformats * formats = new PrefFileformats ( this ) ;
2007-04-25 07:13:54 +00:00
connect ( formats , SIGNAL ( formatsChanged ( ) ) ,
converters , SLOT ( updateGui ( ) ) ) ;
2008-05-19 20:52:24 +00:00
addModule ( converters ) ;
addModule ( formats ) ;
2007-04-25 07:13:54 +00:00
2013-05-12 18:30:59 +02:00
prefsPS - > setCurrentPanel ( " User Interface " ) ;
2007-04-25 07:13:54 +00:00
// FIXME: hack to work around resizing bug in Qt >= 4.2
// bug verified with Qt 4.2.{0-3} (JSpitzm)
# if QT_VERSION >= 0x040200
prefsPS - > updateGeometry ( ) ;
# endif
2007-09-05 20:33:29 +00:00
bc ( ) . setPolicy ( ButtonPolicy : : PreferencesPolicy ) ;
2018-07-10 09:04:42 +02:00
bc ( ) . setOK ( buttonBox - > button ( QDialogButtonBox : : Ok ) ) ;
bc ( ) . setApply ( buttonBox - > button ( QDialogButtonBox : : Apply ) ) ;
bc ( ) . setCancel ( buttonBox - > button ( QDialogButtonBox : : Cancel ) ) ;
bc ( ) . setRestore ( buttonBox - > button ( QDialogButtonBox : : Reset ) ) ;
2019-03-22 14:11:46 +01:00
2019-03-22 14:18:17 +01:00
guilyxfiles_ = new GuiLyXFiles ( lv ) ;
connect ( guilyxfiles_ , SIGNAL ( fileSelected ( QString ) ) ,
2019-03-22 14:11:46 +01:00
this , SLOT ( slotFileSelected ( QString ) ) ) ;
2007-09-05 20:33:29 +00:00
}
2008-05-19 20:52:24 +00:00
void GuiPreferences : : addModule ( PrefModule * module )
2007-04-25 07:13:54 +00:00
{
2008-11-16 12:22:54 +00:00
LASSERT ( module , return ) ;
2008-03-19 13:11:14 +00:00
if ( module - > category ( ) . isEmpty ( ) )
prefsPS - > addPanel ( module , module - > title ( ) ) ;
else
prefsPS - > addPanel ( module , module - > title ( ) , module - > category ( ) ) ;
2007-04-25 07:13:54 +00:00
connect ( module , SIGNAL ( changed ( ) ) , this , SLOT ( change_adaptor ( ) ) ) ;
modules_ . push_back ( module ) ;
}
2007-09-05 20:33:29 +00:00
2007-10-07 09:47:12 +00:00
void GuiPreferences : : change_adaptor ( )
2007-04-25 07:13:54 +00:00
{
2007-09-05 20:33:29 +00:00
changed ( ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void GuiPreferences : : applyRC ( LyXRC & rc ) const
2007-04-25 07:13:54 +00:00
{
size_t end = modules_ . size ( ) ;
for ( size_t i = 0 ; i ! = end ; + + i )
2014-12-19 11:35:37 +01:00
modules_ [ i ] - > applyRC ( rc ) ;
2007-04-25 07:13:54 +00:00
}
2014-12-19 11:35:37 +01:00
void GuiPreferences : : updateRC ( LyXRC const & rc )
2006-03-05 17:24:44 +00:00
{
2007-04-25 07:13:54 +00:00
size_t const end = modules_ . size ( ) ;
for ( size_t i = 0 ; i ! = end ; + + i )
2014-12-19 11:35:37 +01:00
modules_ [ i ] - > updateRC ( rc ) ;
2007-04-25 07:13:54 +00:00
}
2007-10-07 09:47:12 +00:00
void GuiPreferences : : applyView ( )
{
2014-12-19 11:35:37 +01:00
applyRC ( rc ( ) ) ;
2007-10-07 09:47:12 +00:00
}
2010-08-08 23:11:02 +00:00
2007-12-12 19:28:07 +00:00
bool GuiPreferences : : initialiseParams ( string const & )
2007-10-07 09:47:12 +00:00
{
rc_ = lyxrc ;
2017-03-13 23:33:40 -04:00
formats_ = theFormats ( ) ;
2007-10-07 09:47:12 +00:00
converters_ = theConverters ( ) ;
converters_ . update ( formats_ ) ;
movers_ = theMovers ( ) ;
colors_ . clear ( ) ;
2014-12-07 18:35:28 +01:00
2014-12-19 11:35:37 +01:00
updateRC ( rc_ ) ;
2014-12-07 18:35:28 +01:00
// Make sure that the bc is in the INITIAL state
if ( bc ( ) . policy ( ) . buttonStatus ( ButtonPolicy : : RESTORE ) )
bc ( ) . restore ( ) ;
2007-10-07 09:47:12 +00:00
return true ;
}
void GuiPreferences : : dispatchParams ( )
{
ostringstream ss ;
rc_ . write ( ss , true ) ;
2008-06-25 15:02:18 +00:00
dispatch ( FuncRequest ( LFUN_LYXRC_APPLY , ss . str ( ) ) ) ;
2010-12-29 13:50:22 +00:00
// issue prefsApplied signal. This will update the
// localized screen font sizes.
prefsApplied ( rc_ ) ;
2007-10-07 09:47:12 +00:00
// FIXME: these need lfuns
// FIXME UNICODE
2014-12-07 18:35:28 +01:00
Author const & author =
2010-10-29 19:27:55 +00:00
Author ( from_utf8 ( rc_ . user_name ) , from_utf8 ( rc_ . user_email ) ) ;
theBufferList ( ) . recordCurrentAuthor ( author ) ;
2007-10-07 09:47:12 +00:00
2017-03-13 23:33:40 -04:00
theFormats ( ) = formats_ ;
2007-10-07 09:47:12 +00:00
theConverters ( ) = converters_ ;
2017-03-13 23:33:40 -04:00
theConverters ( ) . update ( formats_ ) ;
2007-10-07 09:47:12 +00:00
theConverters ( ) . buildGraph ( ) ;
2016-10-19 17:22:58 -04:00
theBufferList ( ) . invalidateConverterCache ( ) ;
2017-07-03 13:53:14 -04:00
2007-10-07 09:47:12 +00:00
theMovers ( ) = movers_ ;
2019-02-26 16:37:41 +01:00
for ( string const & color : colors_ )
dispatch ( FuncRequest ( LFUN_SET_COLOR , color ) ) ;
2007-10-07 09:47:12 +00:00
colors_ . clear ( ) ;
2018-04-28 11:19:26 +02:00
// Save permanently
if ( ! tempSaveCB - > isChecked ( ) )
2007-10-07 09:47:12 +00:00
dispatch ( FuncRequest ( LFUN_PREFERENCES_SAVE ) ) ;
}
2008-05-19 20:52:24 +00:00
void GuiPreferences : : setColor ( ColorCode col , QString const & hex )
2007-10-07 09:47:12 +00:00
{
2008-05-19 20:52:24 +00:00
colors_ . push_back ( lcolor . getLyXName ( col ) + ' ' + fromqstr ( hex ) ) ;
2007-10-07 09:47:12 +00:00
}
2019-03-22 14:11:46 +01:00
void GuiPreferences : : slotFileSelected ( QString const file )
{
uifile_ = file ;
}
QString GuiPreferences : : browseLibFile ( QString const & dir ,
QString const & name , QString const & ext )
{
uifile_ . clear ( ) ;
2019-03-22 14:18:17 +01:00
guilyxfiles_ - > passParams ( fromqstr ( dir ) ) ;
guilyxfiles_ - > selectItem ( name ) ;
guilyxfiles_ - > exec ( ) ;
2019-03-22 14:11:46 +01:00
QString const result = uifile_ ;
// remove the extension if it is the default one
QString noextresult ;
if ( getExtension ( result ) = = ext )
noextresult = removeExtension ( result ) ;
else
noextresult = result ;
// remove the directory, if it is the default one
QString const file = onlyFileName ( noextresult ) ;
if ( toqstr ( libFileSearch ( dir , file , ext ) . absFileName ( ) ) = = result )
return file ;
else
return noextresult ;
}
QString GuiPreferences : : browsebind ( QString const & file )
2007-10-07 09:47:12 +00:00
{
2019-03-22 14:11:46 +01:00
return browseLibFile ( " bind " , file , " bind " ) ;
2007-10-07 09:47:12 +00:00
}
2019-03-22 14:11:46 +01:00
QString GuiPreferences : : browseUI ( QString const & file )
2007-10-07 09:47:12 +00:00
{
2019-03-22 14:11:46 +01:00
return browseLibFile ( " ui " , file , " ui " ) ;
2007-10-07 09:47:12 +00:00
}
2019-03-22 14:11:46 +01:00
QString GuiPreferences : : browsekbmap ( QString const & file )
2007-10-07 09:47:12 +00:00
{
2019-03-22 14:11:46 +01:00
return browseLibFile ( " kbd " , file , " kmap " ) ;
2007-10-07 09:47:12 +00:00
}
2008-03-05 23:10:53 +00:00
QString GuiPreferences : : browse ( QString const & file ,
2008-11-16 12:22:54 +00:00
QString const & title ) const
2006-03-05 17:24:44 +00:00
{
2008-04-20 19:56:01 +00:00
return browseFile ( file , title , QStringList ( ) , true ) ;
2006-03-05 17:24:44 +00:00
}
2007-09-15 15:42:22 +00:00
2007-11-23 09:44:02 +00:00
Dialog * createGuiPreferences ( GuiView & lv ) { return new GuiPreferences ( lv ) ; }
2007-10-07 09:47:12 +00:00
2006-03-05 17:24:44 +00:00
} // namespace frontend
} // namespace lyx
2007-04-25 07:13:54 +00:00
2008-11-14 14:28:50 +00:00
# include "moc_GuiPrefs.cpp"