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"
|
|
|
|
#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 "paper.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-03-08 07:59:47 +00:00
|
|
|
#include "support/foreach.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"
|
|
|
|
#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-10-09 14:10:55 +00:00
|
|
|
#include <QPixmapCache>
|
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>
|
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
|
|
|
|
|
|
|
FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
|
|
|
|
dlg.setButton2(label1, dir1);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Wrapper around browseFile which tries to provide a filename
|
|
|
|
* relative to the user or system directory. The dir, name and ext
|
|
|
|
* parameters have the same meaning as in the
|
|
|
|
* support::LibFileSearch function.
|
|
|
|
*/
|
|
|
|
QString browseLibFile(QString const & dir,
|
|
|
|
QString const & name,
|
|
|
|
QString const & ext,
|
|
|
|
QString const & title,
|
2008-04-20 19:56:01 +00:00
|
|
|
QStringList const & filters)
|
2008-03-05 23:10:53 +00:00
|
|
|
{
|
|
|
|
// FIXME UNICODE
|
|
|
|
QString const label1 = qt_("System files|#S#s");
|
|
|
|
QString const dir1 =
|
2010-04-21 01:19:09 +00:00
|
|
|
toqstr(addName(package().system_support().absFileName(), fromqstr(dir)));
|
2008-03-05 23:10:53 +00:00
|
|
|
|
|
|
|
QString const label2 = qt_("User files|#U#u");
|
|
|
|
QString const dir2 =
|
2010-04-21 01:19:09 +00:00
|
|
|
toqstr(addName(package().user_support().absFileName(), fromqstr(dir)));
|
2008-03-05 23:10:53 +00:00
|
|
|
|
|
|
|
QString const result = browseFile(toqstr(
|
2010-04-21 01:19:09 +00:00
|
|
|
libFileSearch(dir, name, ext).absFileName()),
|
2008-10-05 14:11:04 +00:00
|
|
|
title, filters, false, dir1, dir2, QString(), QString(), dir1);
|
2008-03-05 23:10:53 +00:00
|
|
|
|
|
|
|
// remove the extension if it is the default one
|
|
|
|
QString noextresult;
|
2008-03-08 07:59:47 +00:00
|
|
|
if (getExtension(result) == ext)
|
|
|
|
noextresult = removeExtension(result);
|
2008-03-05 23:10:53 +00:00
|
|
|
else
|
|
|
|
noextresult = result;
|
|
|
|
|
|
|
|
// remove the directory, if it is the default one
|
2010-04-21 01:19:28 +00:00
|
|
|
QString const file = onlyFileName(noextresult);
|
2010-04-21 01:19:09 +00:00
|
|
|
if (toqstr(libFileSearch(dir, file, ext).absFileName()) == result)
|
2008-03-05 23:10:53 +00:00
|
|
|
return file;
|
|
|
|
else
|
|
|
|
return noextresult;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 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);
|
|
|
|
|
|
|
|
FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
|
|
|
|
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("^(\\.\\./)+"));
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
2008-03-19 13:11:14 +00:00
|
|
|
string const catLookAndFeel = N_("Look & Feel");
|
2008-03-19 14:32:40 +00:00
|
|
|
string const catEditing = N_("Editing");
|
2008-03-19 13:11:14 +00:00
|
|
|
string const catLanguage = N_("Language Settings");
|
2008-03-19 14:32:40 +00:00
|
|
|
string const catOutput = N_("Output");
|
2008-03-19 13:11:14 +00:00
|
|
|
string const catFiles = N_("File Handling");
|
|
|
|
|
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;) {
|
2007-11-24 22:15:52 +00:00
|
|
|
string name, foundry;
|
|
|
|
parseFontName(cb->itemText(i), name, foundry);
|
|
|
|
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; ) {
|
2007-11-24 22:15:52 +00:00
|
|
|
string name, foundry;
|
|
|
|
parseFontName(cb->itemText(i), name, foundry);
|
|
|
|
if (compare_ascii_no_case(name, 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;
|
|
|
|
font.setKerning(false);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-27 11:22:54 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// StrftimeValidator
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class StrftimeValidator : public QValidator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StrftimeValidator(QWidget *);
|
|
|
|
QValidator::State validate(QString & input, int & pos) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
StrftimeValidator::StrftimeValidator(QWidget * parent)
|
|
|
|
: QValidator(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QValidator::State StrftimeValidator::validate(QString & input, int & /*pos*/) const
|
|
|
|
{
|
|
|
|
if (is_valid_strftime(fromqstr(input)))
|
|
|
|
return QValidator::Acceptable;
|
|
|
|
else
|
|
|
|
return QValidator::Intermediate;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
: PrefModule(qt_(catOutput), qt_("General"), form)
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2011-09-12 14:22:05 +00:00
|
|
|
|
2009-03-27 11:22:54 +00:00
|
|
|
DateED->setValidator(new StrftimeValidator(DateED));
|
2011-09-12 14:22:05 +00:00
|
|
|
dviCB->setValidator(new NoNewLineValidator(dviCB));
|
|
|
|
pdfCB->setValidator(new NoNewLineValidator(pdfCB));
|
|
|
|
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(DateED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
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()));
|
|
|
|
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");
|
2011-03-01 12:42:14 +00:00
|
|
|
dviCB->addItem("okular --unique \"file:$$o#src:$$n $$t\"");
|
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)]");
|
2012-03-02 02:35:30 +00: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}\"");
|
2011-03-01 12:42:14 +00:00
|
|
|
pdfCB->addItem("okular --unique \"file:$$o#src:$$n $$t\"");
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-15 14:25:25 +00:00
|
|
|
void PrefOutput::on_DateED_textChanged(const QString &)
|
2009-03-27 11:22:54 +00:00
|
|
|
{
|
|
|
|
QString t = DateED->text();
|
|
|
|
int p = 0;
|
|
|
|
bool valid = DateED->validator()->validate(t, p)
|
|
|
|
== QValidator::Acceptable;
|
|
|
|
setValid(DateLA, valid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-15 14:25:25 +00:00
|
|
|
void PrefOutput::apply(LyXRC & rc) const
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
|
|
|
rc.date_insert_format = fromqstr(DateED->text());
|
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;
|
|
|
|
}
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-15 14:25:25 +00:00
|
|
|
void PrefOutput::update(LyXRC const & rc)
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
|
|
|
DateED->setText(toqstr(rc.date_insert_format));
|
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;
|
|
|
|
}
|
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)
|
|
|
|
: PrefModule(qt_(catEditing), qt_("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()));
|
|
|
|
|
|
|
|
// reveal checkbox for switching Ctrl and Meta on Mac:
|
|
|
|
bool swapcb = false;
|
|
|
|
#ifdef Q_WS_MACX
|
|
|
|
#if QT_VERSION > 0x040600
|
|
|
|
swapcb = true;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
dontswapCB->setVisible(swapcb);
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-30 21:20:56 +00:00
|
|
|
void PrefInput::apply(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();
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-30 21:20:56 +00:00
|
|
|
void PrefInput::update(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);
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-18 17:31:17 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// PrefCompletion
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-05-19 20:52:24 +00:00
|
|
|
PrefCompletion::PrefCompletion(GuiPreferences * form)
|
|
|
|
: PrefModule(qt_(catEditing), qt_("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());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-18 17:31:17 +00:00
|
|
|
void PrefCompletion::apply(LyXRC & rc) const
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefCompletion::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
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);
|
2009-05-22 21:35:18 +00: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)
|
|
|
|
: PrefModule(qt_(catOutput), qt_("LaTeX"), form)
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2011-09-12 14:22:05 +00:00
|
|
|
|
|
|
|
latexEncodingED->setValidator(new NoNewLineValidator(latexEncodingED));
|
|
|
|
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));
|
|
|
|
|
2009-11-29 13:29:36 +00:00
|
|
|
connect(latexEncodingCB, SIGNAL(clicked()),
|
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(latexEncodingED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
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()));
|
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-11-29 13:29:36 +00:00
|
|
|
void PrefLatex::on_latexEncodingCB_stateChanged(int state)
|
|
|
|
{
|
|
|
|
latexEncodingED->setEnabled(state == Qt::Checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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();
|
2009-06-07 16:19:40 +00:00
|
|
|
latexBibtexOptionsLA->setText(qt_("Co&mmand:"));
|
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:"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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:"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-25 07:13:54 +00:00
|
|
|
void PrefLatex::apply(LyXRC & rc) const
|
|
|
|
{
|
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
|
|
|
|
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
|
|
|
|
2009-11-29 13:29:36 +00:00
|
|
|
if (latexEncodingCB->isChecked())
|
|
|
|
rc.fontenc = fromqstr(latexEncodingED->text());
|
|
|
|
else
|
|
|
|
rc.fontenc = "default";
|
2007-04-25 07:13:54 +00:00
|
|
|
rc.chktex_command = fromqstr(latexChecktexED->text());
|
2009-04-13 09:53:40 +00:00
|
|
|
rc.jbibtex_command = fromqstr(latexJBibtexED->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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefLatex::update(LyXRC const & rc)
|
|
|
|
{
|
2009-05-08 10:07:32 +00:00
|
|
|
latexBibtexCO->clear();
|
|
|
|
|
|
|
|
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);
|
2009-06-07 16:19:40 +00:00
|
|
|
latexBibtexOptionsLA->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:"));
|
|
|
|
}
|
|
|
|
|
2009-11-29 13:29:36 +00:00
|
|
|
if (rc.fontenc == "default") {
|
|
|
|
latexEncodingCB->setChecked(false);
|
|
|
|
latexEncodingED->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
latexEncodingCB->setChecked(true);
|
|
|
|
latexEncodingED->setEnabled(true);
|
|
|
|
latexEncodingED->setText(toqstr(rc.fontenc));
|
|
|
|
}
|
2007-04-25 07:13:54 +00:00
|
|
|
latexChecktexED->setText(toqstr(rc.chktex_command));
|
2009-04-13 09:53:40 +00:00
|
|
|
latexJBibtexED->setText(toqstr(rc.jbibtex_command));
|
|
|
|
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)
|
2010-08-14 15:19:05 +00:00
|
|
|
: PrefModule(qt_(catLookAndFeel), qt_("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()));
|
2008-01-26 01:14:37 +00:00
|
|
|
connect(pixmapCacheCB, SIGNAL(toggled(bool)),
|
|
|
|
this, SIGNAL(changed()));
|
2007-04-25 07:13:54 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefScreenFonts::apply(LyXRC & rc) const
|
|
|
|
{
|
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
|
|
|
|
|
|
|
rc.zoom = screenZoomSB->value();
|
2009-07-12 15:44:26 +00:00
|
|
|
rc.font_sizes[FONT_SIZE_TINY] = widgetToDoubleStr(screenTinyED);
|
|
|
|
rc.font_sizes[FONT_SIZE_SCRIPT] = widgetToDoubleStr(screenSmallestED);
|
|
|
|
rc.font_sizes[FONT_SIZE_FOOTNOTE] = widgetToDoubleStr(screenSmallerED);
|
|
|
|
rc.font_sizes[FONT_SIZE_SMALL] = widgetToDoubleStr(screenSmallED);
|
|
|
|
rc.font_sizes[FONT_SIZE_NORMAL] = widgetToDoubleStr(screenNormalED);
|
|
|
|
rc.font_sizes[FONT_SIZE_LARGE] = widgetToDoubleStr(screenLargeED);
|
|
|
|
rc.font_sizes[FONT_SIZE_LARGER] = widgetToDoubleStr(screenLargerED);
|
|
|
|
rc.font_sizes[FONT_SIZE_LARGEST] = widgetToDoubleStr(screenLargestED);
|
|
|
|
rc.font_sizes[FONT_SIZE_HUGE] = widgetToDoubleStr(screenHugeED);
|
|
|
|
rc.font_sizes[FONT_SIZE_HUGER] = widgetToDoubleStr(screenHugerED);
|
2008-01-26 01:14:37 +00:00
|
|
|
rc.use_pixmap_cache = pixmapCacheCB->isChecked();
|
2007-04-25 07:13:54 +00:00
|
|
|
|
|
|
|
if (rc.font_sizes != oldrc.font_sizes
|
|
|
|
|| rc.roman_font_name != oldrc.roman_font_name
|
|
|
|
|| rc.sans_font_name != oldrc.sans_font_name
|
|
|
|
|| rc.typewriter_font_name != oldrc.typewriter_font_name
|
2010-08-08 20:32:26 +00:00
|
|
|
|| rc.zoom != oldrc.zoom) {
|
2007-10-09 14:10:55 +00:00
|
|
|
// The global QPixmapCache is used in GuiPainter to cache text
|
|
|
|
// painting so we must reset it in case any of the above
|
|
|
|
// parameter is changed.
|
|
|
|
QPixmapCache::clear();
|
|
|
|
guiApp->fontLoader().update();
|
2007-10-07 09:47:12 +00:00
|
|
|
form_->updateScreenFonts();
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefScreenFonts::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
screenZoomSB->setValue(rc.zoom);
|
2010-12-29 13:50:22 +00:00
|
|
|
updateScreenFontSizes(rc);
|
|
|
|
|
|
|
|
pixmapCacheCB->setChecked(rc.use_pixmap_cache);
|
|
|
|
#if defined(Q_WS_X11)
|
|
|
|
pixmapCacheCB->setEnabled(false);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefScreenFonts::updateScreenFontSizes(LyXRC const & rc)
|
|
|
|
{
|
2009-07-12 15:44:26 +00:00
|
|
|
doubleToWidget(screenTinyED, rc.font_sizes[FONT_SIZE_TINY]);
|
|
|
|
doubleToWidget(screenSmallestED, rc.font_sizes[FONT_SIZE_SCRIPT]);
|
|
|
|
doubleToWidget(screenSmallerED, rc.font_sizes[FONT_SIZE_FOOTNOTE]);
|
|
|
|
doubleToWidget(screenSmallED, rc.font_sizes[FONT_SIZE_SMALL]);
|
|
|
|
doubleToWidget(screenNormalED, rc.font_sizes[FONT_SIZE_NORMAL]);
|
|
|
|
doubleToWidget(screenLargeED, rc.font_sizes[FONT_SIZE_LARGE]);
|
|
|
|
doubleToWidget(screenLargerED, rc.font_sizes[FONT_SIZE_LARGER]);
|
|
|
|
doubleToWidget(screenLargestED, rc.font_sizes[FONT_SIZE_LARGEST]);
|
|
|
|
doubleToWidget(screenHugeED, rc.font_sizes[FONT_SIZE_HUGE]);
|
|
|
|
doubleToWidget(screenHugerED, rc.font_sizes[FONT_SIZE_HUGER]);
|
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
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct ColorSorter
|
|
|
|
{
|
2007-10-25 12:41:02 +00:00
|
|
|
bool operator()(ColorCode lhs, ColorCode rhs) const {
|
2009-01-05 13:37:46 +00:00
|
|
|
return
|
|
|
|
compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0;
|
2007-09-11 21:27:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
2008-05-19 20:52:24 +00:00
|
|
|
PrefColors::PrefColors(GuiPreferences * form)
|
|
|
|
: PrefModule(qt_(catLookAndFeel), qt_("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_red
|
|
|
|
|| lc == Color_green
|
|
|
|
|| lc == Color_blue
|
|
|
|
|| lc == Color_cyan
|
|
|
|
|| lc == Color_magenta
|
|
|
|
|| 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
|
|
|
}
|
2007-12-12 19:28:07 +00:00
|
|
|
sort(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()));
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-08 23:11:02 +00:00
|
|
|
void PrefColors::apply(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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-08 23:11:02 +00:00
|
|
|
void PrefColors::update(LyXRC const & rc)
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
2007-05-09 20:16:31 +00:00
|
|
|
for (unsigned int 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);
|
|
|
|
lyxObjectsLW->item(i)->setIcon(QIcon(coloritem));
|
|
|
|
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();
|
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
|
|
|
|
|
|
|
QString const color = newcolors_[row];
|
2007-09-15 15:42:22 +00:00
|
|
|
QColor c = QColorDialog::getColor(QColor(color), qApp->focusWidget());
|
2007-04-25 07:13:54 +00:00
|
|
|
|
2007-05-09 19:52:24 +00:00
|
|
|
if (c.isValid() && c.name() != color) {
|
2007-04-25 07:13:54 +00:00
|
|
|
newcolors_[row] = c.name();
|
|
|
|
QPixmap coloritem(32, 32);
|
|
|
|
coloritem.fill(c);
|
|
|
|
lyxObjectsLW->currentItem()->setIcon(QIcon(coloritem));
|
|
|
|
// emit signal
|
|
|
|
changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
bool const hide = syscolorsCB->isChecked()
|
|
|
|
&& guiApp->colorCache().isSystem(lcolors_[row]);
|
|
|
|
|
|
|
|
lyxObjectsLW->item(row)->setHidden(hide);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-05-23 10:15:24 +00:00
|
|
|
void PrefColors::changeLyxObjectsSelection()
|
2007-05-09 20:09:03 +00:00
|
|
|
{
|
|
|
|
colorChangePB->setDisabled(lyxObjectsLW->currentRow() < 0);
|
|
|
|
}
|
|
|
|
|
2007-04-25 07:13:54 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// PrefDisplay
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-05-19 20:52:24 +00:00
|
|
|
PrefDisplay::PrefDisplay(GuiPreferences * form)
|
2009-08-19 22:46:43 +00:00
|
|
|
: PrefModule(qt_(catLookAndFeel), qt_("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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefDisplay::on_displayGraphicsCB_toggled(bool on)
|
|
|
|
{
|
|
|
|
instantPreviewCO->setEnabled(on);
|
|
|
|
previewSizeSB->setEnabled(on && instantPreviewCO->currentIndex() > 0);
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefDisplay::apply(LyXRC & rc) const
|
|
|
|
{
|
|
|
|
switch (instantPreviewCO->currentIndex()) {
|
2011-01-03 17:21:22 +00:00
|
|
|
case 0:
|
|
|
|
rc.preview = LyXRC::PREVIEW_OFF;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
rc.preview = LyXRC::PREVIEW_NO_MATH;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
rc.preview = LyXRC::PREVIEW_ON;
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefDisplay::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
instantPreviewCO->setEnabled(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)
|
|
|
|
: PrefModule(QString(), qt_("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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefPaths::apply(LyXRC & rc) const
|
|
|
|
{
|
|
|
|
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()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefPaths::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
: PrefModule(qt_(catLanguage), qt_("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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefSpellchecker::apply(LyXRC & rc) const
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefSpellchecker::update(LyXRC const & rc)
|
|
|
|
{
|
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();
|
|
|
|
|
2011-07-21 15:33:56 +00:00
|
|
|
compoundWordCB->setEnabled(spellchecker == QString("aspell"));
|
2010-09-29 19:05:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-04-25 07:13:54 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// PrefConverters
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2008-05-19 20:52:24 +00:00
|
|
|
PrefConverters::PrefConverters(GuiPreferences * form)
|
|
|
|
: PrefModule(qt_(catFiles), qt_("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()));
|
|
|
|
|
2011-09-12 14:22:05 +00:00
|
|
|
converterED->setValidator(new NoNewLineValidator(converterED));
|
|
|
|
converterFlagED->setValidator(new NoNewLineValidator(converterFlagED));
|
2007-04-25 07:13:54 +00:00
|
|
|
maxAgeLE->setValidator(new QDoubleValidator(maxAgeLE));
|
2007-09-02 20:17:36 +00:00
|
|
|
//converterDefGB->setFocusProxy(convertersLW);
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefConverters::apply(LyXRC & rc) const
|
|
|
|
{
|
|
|
|
rc.use_converter_cache = cacheCB->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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefConverters::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
cacheCB->setChecked(rc.use_converter_cache);
|
|
|
|
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()
|
|
|
|
{
|
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
|
|
|
|
QString current = converterFromCO->currentText()
|
|
|
|
+ " -> " + converterToCO->currentText();
|
|
|
|
|
|
|
|
converterFromCO->clear();
|
|
|
|
converterToCO->clear();
|
|
|
|
|
|
|
|
Formats::const_iterator cit = form_->formats().begin();
|
|
|
|
Formats::const_iterator end = form_->formats().end();
|
|
|
|
for (; cit != end; ++cit) {
|
2008-05-25 09:42:41 +00:00
|
|
|
converterFromCO->addItem(qt_(cit->prettyname()));
|
|
|
|
converterToCO->addItem(qt_(cit->prettyname()));
|
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();
|
|
|
|
|
|
|
|
Converters::const_iterator ccit = form_->converters().begin();
|
|
|
|
Converters::const_iterator cend = form_->converters().end();
|
|
|
|
for (; ccit != cend; ++ccit) {
|
2008-05-25 09:42:41 +00:00
|
|
|
QString const name =
|
|
|
|
qt_(ccit->From->prettyname()) + " -> " + qt_(ccit->To->prettyname());
|
2007-04-25 07:13:54 +00:00
|
|
|
int type = form_->converters().getNumber(ccit->From->name(), ccit->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
|
|
|
|
if (!current.isEmpty()) {
|
|
|
|
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));
|
|
|
|
converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from));
|
|
|
|
converterToCO->setCurrentIndex(form_->formats().getNumber(c.to));
|
|
|
|
converterED->setText(toqstr(c.command));
|
|
|
|
converterFlagED->setText(toqstr(c.flags));
|
|
|
|
|
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-23 12:52:23 +00:00
|
|
|
void PrefConverters::changeConverter()
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefConverters::updateButtons()
|
|
|
|
{
|
2010-05-10 21:30:57 +00:00
|
|
|
if (form_->formats().size() == 0)
|
|
|
|
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 12:21:29 +00:00
|
|
|
string old_command;
|
|
|
|
string old_flag;
|
|
|
|
|
|
|
|
if (convertersLW->count() > 0) {
|
|
|
|
int const cnr = convertersLW->currentItem()->type();
|
|
|
|
Converter const & c = form_->converters().get(cnr);
|
|
|
|
old_command = c.command;
|
|
|
|
old_flag = c.flags;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
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
|
|
|
|
{
|
2008-05-25 09:42:41 +00:00
|
|
|
return qt_(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)
|
2010-08-14 15:19:05 +00:00
|
|
|
: PrefModule(qt_(catFiles), qt_("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()));
|
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 {
|
|
|
|
|
|
|
|
string const l10n_shortcut(string const prettyname, string const shortcut)
|
|
|
|
{
|
|
|
|
if (shortcut.empty())
|
|
|
|
return string();
|
|
|
|
|
|
|
|
string l10n_format =
|
|
|
|
to_utf8(_(prettyname + '|' + shortcut));
|
|
|
|
return split(l10n_format, '|');
|
|
|
|
}
|
|
|
|
|
2010-12-16 08:06:00 +00:00
|
|
|
} // namespace anon
|
2008-05-25 09:42:41 +00:00
|
|
|
|
|
|
|
|
2009-04-07 05:01:08 +00:00
|
|
|
void PrefFileformats::apply(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);
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-07 05:01:08 +00:00
|
|
|
void PrefFileformats::update(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) {
|
2009-11-22 00:19:50 +00:00
|
|
|
int const pos =
|
|
|
|
defaultFormatCB->findData(toqstr(rc.default_view_format));
|
2009-04-07 05:01:08 +00:00
|
|
|
defaultFormatCB->setCurrentIndex(pos);
|
|
|
|
}
|
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();
|
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);
|
2007-09-15 17:09:57 +00:00
|
|
|
formatsCB->clear();
|
2009-04-07 10:59:03 +00:00
|
|
|
defaultFormatCB->clear();
|
2007-09-15 17:09:57 +00:00
|
|
|
form_->formats().sort();
|
2007-04-25 07:13:54 +00:00
|
|
|
Formats::const_iterator cit = form_->formats().begin();
|
|
|
|
Formats::const_iterator end = form_->formats().end();
|
2009-04-07 05:01:08 +00:00
|
|
|
for (; cit != end; ++cit) {
|
2008-05-25 09:42:41 +00:00
|
|
|
formatsCB->addItem(qt_(cit->prettyname()),
|
2009-04-07 05:01:08 +00:00
|
|
|
QVariant(form_->formats().getNumber(cit->name())));
|
|
|
|
if (form_->converters().isReachable("latex", cit->name())
|
2011-08-10 02:23:44 +00:00
|
|
|
|| form_->converters().isReachable("dviluatex", cit->name())
|
2011-05-24 01:26:41 +00:00
|
|
|
|| form_->converters().isReachable("pdflatex", cit->name())
|
|
|
|
|| form_->converters().isReachable("luatex", cit->name())
|
|
|
|
|| form_->converters().isReachable("xetex", cit->name()))
|
2009-04-07 05:01:08 +00:00
|
|
|
defaultFormatCB->addItem(qt_(cit->prettyname()),
|
|
|
|
QVariant(toqstr(cit->name())));
|
|
|
|
}
|
2007-04-25 07:13:54 +00:00
|
|
|
|
|
|
|
// restore selection
|
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);
|
2007-09-15 17:09:57 +00:00
|
|
|
formatsCB->blockSignals(false);
|
2009-04-07 05:01:08 +00:00
|
|
|
defaultFormatCB->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
|
|
|
{
|
2010-05-10 21:30:57 +00:00
|
|
|
if (form_->formats().size() == 0)
|
|
|
|
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();
|
|
|
|
if (newname == qt_(currentFormat().prettyname()))
|
2007-09-15 17:09:57 +00:00
|
|
|
return;
|
|
|
|
|
2008-05-25 09:42:41 +00:00
|
|
|
currentFormat().setPrettyname(fromqstr(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)
|
|
|
|
{
|
|
|
|
LyXRC::Alternatives::const_iterator it =
|
|
|
|
alts.find(fmt);
|
|
|
|
if (it != alts.end()) {
|
|
|
|
LyXRC::CommandSet const & cmds = it->second;
|
|
|
|
LyXRC::CommandSet::const_iterator sit =
|
|
|
|
cmds.begin();
|
|
|
|
LyXRC::CommandSet::const_iterator const sen =
|
|
|
|
cmds.end();
|
|
|
|
for (; sit != sen; ++sit) {
|
|
|
|
QString const qcmd = toqstr(*sit);
|
|
|
|
combo->addItem(qcmd, qcmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2012-02-21 20:29:44 +00:00
|
|
|
form_->formats().add("", "", "", "", "", "", "", 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)
|
|
|
|
: PrefModule(qt_(catLanguage), qt_("Language"), form)
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
2008-02-10 19:51:23 +00:00
|
|
|
connect(rtlGB, SIGNAL(clicked()),
|
|
|
|
this, SIGNAL(changed()));
|
|
|
|
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()));
|
|
|
|
connect(autoBeginCB, SIGNAL(clicked()),
|
|
|
|
this, SIGNAL(changed()));
|
|
|
|
connect(autoEndCB, SIGNAL(clicked()),
|
|
|
|
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));
|
|
|
|
|
2008-06-25 13:32:27 +00:00
|
|
|
uiLanguageCO->clear();
|
2007-04-25 07:13:54 +00:00
|
|
|
|
2008-05-14 10:34:19 +00:00
|
|
|
QAbstractItemModel * language_model = guiApp->languageModel();
|
|
|
|
// FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
|
|
|
|
language_model->sort(0);
|
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);
|
|
|
|
|
2010-12-03 17:48:06 +00:00
|
|
|
set<string> added;
|
2008-06-25 13:32:27 +00:00
|
|
|
uiLanguageCO->blockSignals(true);
|
|
|
|
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);
|
|
|
|
// never remove the currently selected language
|
|
|
|
if (lang && name != form->rc().gui_language && name != lyxrc.gui_language)
|
|
|
|
if (!lang->translated() || added.find(lang->code()) != added.end())
|
|
|
|
continue;
|
|
|
|
added.insert(lang->code());
|
2008-06-25 13:32:27 +00:00
|
|
|
uiLanguageCO->addItem(index.data(Qt::DisplayRole).toString(),
|
|
|
|
index.data(Qt::UserRole).toString());
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-25 07:13:54 +00:00
|
|
|
void PrefLanguage::apply(LyXRC & rc) const
|
|
|
|
{
|
|
|
|
// FIXME: remove rtl_support bool
|
2008-02-10 19:51:23 +00:00
|
|
|
rc.rtl_support = rtlGB->isChecked();
|
|
|
|
rc.visual_cursor = rtlGB->isChecked() && visualCursorRB->isChecked();
|
2007-04-25 07:13:54 +00:00
|
|
|
rc.mark_foreign_language = markForeignCB->isChecked();
|
|
|
|
rc.language_auto_begin = autoBeginCB->isChecked();
|
|
|
|
rc.language_auto_end = autoEndCB->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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefLanguage::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
// FIXME: remove rtl_support bool
|
2008-02-10 19:51:23 +00:00
|
|
|
rtlGB->setChecked(rc.rtl_support);
|
|
|
|
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);
|
|
|
|
autoBeginCB->setChecked(rc.language_auto_begin);
|
|
|
|
autoEndCB->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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// PrefPrinter
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-05-19 20:52:24 +00:00
|
|
|
PrefPrinter::PrefPrinter(GuiPreferences * form)
|
|
|
|
: PrefModule(qt_(catOutput), qt_("Printer"), form)
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(printerAdaptCB, SIGNAL(clicked()),
|
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerCommandED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerNameED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerPageRangeED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerCopiesED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerReverseED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerToPrinterED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerExtensionED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerSpoolCommandED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerPaperTypeED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerEvenED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerOddED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerCollatedED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerLandscapeED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerToFileED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerExtraED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerSpoolPrefixED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(printerPaperSizeED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2011-09-12 14:22:05 +00:00
|
|
|
|
|
|
|
printerNameED->setValidator(new NoNewLineValidator(printerNameED));
|
|
|
|
printerCommandED->setValidator(new NoNewLineValidator(printerCommandED));
|
|
|
|
printerEvenED->setValidator(new NoNewLineValidator(printerEvenED));
|
|
|
|
printerPageRangeED->setValidator(new NoNewLineValidator(printerPageRangeED));
|
|
|
|
printerCopiesED->setValidator(new NoNewLineValidator(printerCopiesED));
|
|
|
|
printerReverseED->setValidator(new NoNewLineValidator(printerReverseED));
|
|
|
|
printerToFileED->setValidator(new NoNewLineValidator(printerToFileED));
|
|
|
|
printerPaperTypeED->setValidator(new NoNewLineValidator(printerPaperTypeED));
|
|
|
|
printerExtraED->setValidator(new NoNewLineValidator(printerExtraED));
|
|
|
|
printerOddED->setValidator(new NoNewLineValidator(printerOddED));
|
|
|
|
printerCollatedED->setValidator(new NoNewLineValidator(printerCollatedED));
|
|
|
|
printerLandscapeED->setValidator(new NoNewLineValidator(printerLandscapeED));
|
|
|
|
printerToPrinterED->setValidator(new NoNewLineValidator(printerToPrinterED));
|
|
|
|
printerExtensionED->setValidator(new NoNewLineValidator(printerExtensionED));
|
|
|
|
printerPaperSizeED->setValidator(new NoNewLineValidator(printerPaperSizeED));
|
|
|
|
printerSpoolCommandED->setValidator(new NoNewLineValidator(printerSpoolCommandED));
|
|
|
|
printerSpoolPrefixED->setValidator(new NoNewLineValidator(printerSpoolPrefixED));
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefPrinter::apply(LyXRC & rc) const
|
|
|
|
{
|
|
|
|
rc.print_adapt_output = printerAdaptCB->isChecked();
|
|
|
|
rc.print_command = fromqstr(printerCommandED->text());
|
|
|
|
rc.printer = fromqstr(printerNameED->text());
|
|
|
|
|
|
|
|
rc.print_pagerange_flag = fromqstr(printerPageRangeED->text());
|
|
|
|
rc.print_copies_flag = fromqstr(printerCopiesED->text());
|
|
|
|
rc.print_reverse_flag = fromqstr(printerReverseED->text());
|
|
|
|
rc.print_to_printer = fromqstr(printerToPrinterED->text());
|
|
|
|
rc.print_file_extension = fromqstr(printerExtensionED->text());
|
|
|
|
rc.print_spool_command = fromqstr(printerSpoolCommandED->text());
|
|
|
|
rc.print_paper_flag = fromqstr(printerPaperTypeED->text());
|
|
|
|
rc.print_evenpage_flag = fromqstr(printerEvenED->text());
|
|
|
|
rc.print_oddpage_flag = fromqstr(printerOddED->text());
|
|
|
|
rc.print_collcopies_flag = fromqstr(printerCollatedED->text());
|
|
|
|
rc.print_landscape_flag = fromqstr(printerLandscapeED->text());
|
|
|
|
rc.print_to_file = internal_path(fromqstr(printerToFileED->text()));
|
|
|
|
rc.print_extra_options = fromqstr(printerExtraED->text());
|
|
|
|
rc.print_spool_printerprefix = fromqstr(printerSpoolPrefixED->text());
|
|
|
|
rc.print_paper_dimension_flag = fromqstr(printerPaperSizeED->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefPrinter::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
printerAdaptCB->setChecked(rc.print_adapt_output);
|
|
|
|
printerCommandED->setText(toqstr(rc.print_command));
|
|
|
|
printerNameED->setText(toqstr(rc.printer));
|
|
|
|
|
|
|
|
printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
|
|
|
|
printerCopiesED->setText(toqstr(rc.print_copies_flag));
|
|
|
|
printerReverseED->setText(toqstr(rc.print_reverse_flag));
|
|
|
|
printerToPrinterED->setText(toqstr(rc.print_to_printer));
|
|
|
|
printerExtensionED->setText(toqstr(rc.print_file_extension));
|
|
|
|
printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
|
|
|
|
printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
|
|
|
|
printerEvenED->setText(toqstr(rc.print_evenpage_flag));
|
|
|
|
printerOddED->setText(toqstr(rc.print_oddpage_flag));
|
|
|
|
printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
|
|
|
|
printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
|
|
|
|
printerToFileED->setText(toqstr(external_path(rc.print_to_file)));
|
|
|
|
printerExtraED->setText(toqstr(rc.print_extra_options));
|
|
|
|
printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
|
|
|
|
printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// PrefUserInterface
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-05-19 20:52:24 +00:00
|
|
|
PrefUserInterface::PrefUserInterface(GuiPreferences * form)
|
2010-08-14 15:19:05 +00:00
|
|
|
: PrefModule(qt_(catLookAndFeel), qt_("User Interface"), form)
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
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
|
|
|
#if QT_VERSION < 0x040500
|
2009-10-06 10:15:14 +00:00
|
|
|
singleCloseTabButtonCB->setEnabled(false);
|
2009-10-05 23:06:29 +00:00
|
|
|
#endif
|
|
|
|
connect(singleCloseTabButtonCB, SIGNAL(clicked()),
|
|
|
|
this, SIGNAL(changed()));
|
2007-04-25 07:13:54 +00:00
|
|
|
connect(uiFilePB, SIGNAL(clicked()),
|
2009-05-23 10:48:22 +00:00
|
|
|
this, SLOT(selectUi()));
|
2007-10-25 20:36:17 +00:00
|
|
|
connect(uiFileED, SIGNAL(textChanged(QString)),
|
2007-04-25 07:13:54 +00:00
|
|
|
this, SIGNAL(changed()));
|
2011-03-25 14:21:28 +00:00
|
|
|
connect(iconSetCO, 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()));
|
2007-04-25 07:13:54 +00:00
|
|
|
connect(lastfilesSB, SIGNAL(valueChanged(int)),
|
|
|
|
this, SIGNAL(changed()));
|
2007-12-26 13:52:56 +00:00
|
|
|
connect(tooltipCB, SIGNAL(toggled(bool)),
|
|
|
|
this, SIGNAL(changed()));
|
2007-04-25 07:13:54 +00:00
|
|
|
lastfilesSB->setMaximum(maxlastfiles);
|
2011-03-25 14:21:28 +00:00
|
|
|
|
2011-03-25 15:21:35 +00:00
|
|
|
iconSetCO->addItem(qt_("Default"), QString());
|
2011-04-01 17:51:12 +00:00
|
|
|
iconSetCO->addItem(qt_("Classic"), "classic");
|
2011-03-25 15:14:52 +00:00
|
|
|
iconSetCO->addItem(qt_("Oxygen"), "oxygen");
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefUserInterface::apply(LyXRC & rc) const
|
|
|
|
{
|
2011-03-25 15:14:52 +00:00
|
|
|
rc.icon_set = fromqstr(iconSetCO->itemData(
|
|
|
|
iconSetCO->currentIndex()).toString());
|
2011-03-25 14:21:28 +00:00
|
|
|
|
2007-04-25 07:13:54 +00:00
|
|
|
rc.ui_file = internal_path(fromqstr(uiFileED->text()));
|
|
|
|
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();
|
2007-04-25 07:13:54 +00:00
|
|
|
rc.num_lastfiles = lastfilesSB->value();
|
2007-12-26 13:52:56 +00:00
|
|
|
rc.use_tooltip = tooltipCB->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();
|
|
|
|
#if QT_VERSION < 0x040500
|
|
|
|
rc.single_close_tab_button = true;
|
|
|
|
#endif
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefUserInterface::update(LyXRC const & rc)
|
|
|
|
{
|
2011-03-25 15:14:52 +00:00
|
|
|
int iconset = iconSetCO->findData(toqstr(rc.icon_set));
|
2011-03-25 14:21:28 +00:00
|
|
|
if (iconset < 0)
|
|
|
|
iconset = 0;
|
|
|
|
iconSetCO->setCurrentIndex(iconset);
|
2007-04-25 07:13:54 +00:00
|
|
|
uiFileED->setText(toqstr(external_path(rc.ui_file)));
|
|
|
|
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);
|
2007-04-25 07:13:54 +00:00
|
|
|
lastfilesSB->setValue(rc.num_lastfiles);
|
2007-12-26 13:52:56 +00:00
|
|
|
tooltipCB->setChecked(rc.use_tooltip);
|
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);
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-23 10:48:22 +00:00
|
|
|
void PrefUserInterface::selectUi()
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
2008-03-05 23:10:53 +00:00
|
|
|
QString file = form_->browseUI(internalPath(uiFileED->text()));
|
|
|
|
if (!file.isEmpty())
|
|
|
|
uiFileED->setText(file);
|
2007-04-25 07:13:54 +00:00
|
|
|
}
|
|
|
|
|
2008-05-19 20:52:24 +00:00
|
|
|
|
2008-09-22 07:14:30 +00:00
|
|
|
void PrefUserInterface::on_clearSessionPB_clicked()
|
|
|
|
{
|
|
|
|
guiApp->clearSession();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-15 22:12:19 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// PrefEdit
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-05-19 20:52:24 +00:00
|
|
|
PrefEdit::PrefEdit(GuiPreferences * form)
|
|
|
|
: PrefModule(qt_(catEditing), qt_("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()));
|
2010-11-29 11:26:08 +00:00
|
|
|
connect(macLikeWordMovementCB, SIGNAL(clicked()),
|
|
|
|
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()));
|
|
|
|
connect(toggleToolbarsCB, SIGNAL(toggled(bool)),
|
|
|
|
this, SIGNAL(changed()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefEdit::apply(LyXRC & rc) const
|
|
|
|
{
|
|
|
|
rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
|
2009-03-27 17:41:58 +00:00
|
|
|
rc.scroll_below_document = scrollBelowCB->isChecked();
|
2010-11-29 11:26:08 +00:00
|
|
|
rc.mac_like_word_movement = macLikeWordMovementCB->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();
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefEdit::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
|
2009-03-27 17:41:58 +00:00
|
|
|
scrollBelowCB->setChecked(rc.scroll_below_document);
|
2010-11-29 11:26:08 +00:00
|
|
|
macLikeWordMovementCB->setChecked(rc.mac_like_word_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);
|
|
|
|
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)
|
|
|
|
: PrefModule(qt_(catEditing), qt_("Shortcuts"), form)
|
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);
|
|
|
|
shortcut_bc_.setOK(shortcut_->okPB);
|
|
|
|
shortcut_bc_.setCancel(shortcut_->cancelPB);
|
|
|
|
|
2007-10-20 20:50:56 +00:00
|
|
|
connect(shortcut_->okPB, SIGNAL(clicked()),
|
2007-10-19 03:09:14 +00:00
|
|
|
shortcut_, SLOT(accept()));
|
2008-06-25 15:02:18 +00:00
|
|
|
connect(shortcut_->okPB, SIGNAL(clicked()),
|
2007-10-20 20:50:56 +00:00
|
|
|
this, SIGNAL(changed()));
|
2008-06-25 15:02:18 +00:00
|
|
|
connect(shortcut_->cancelPB, SIGNAL(clicked()),
|
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()));
|
2008-06-25 15:02:18 +00:00
|
|
|
connect(shortcut_->okPB, SIGNAL(clicked()),
|
2009-05-23 10:48:30 +00:00
|
|
|
this, SLOT(shortcutOkPressed()));
|
2008-07-21 14:54:07 +00:00
|
|
|
connect(shortcut_->cancelPB, SIGNAL(clicked()),
|
2009-05-23 10:48:30 +00:00
|
|
|
this, SLOT(shortcutCancelPressed()));
|
2007-10-16 14:41:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefShortcuts::apply(LyXRC & rc) const
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-17 05:13:34 +00:00
|
|
|
void PrefShortcuts::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
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)
|
2008-09-23 13:53:38 +00:00
|
|
|
insertShortcutItem(it->request, it->sequence, KeyMap::ItemType(it->tag));
|
2007-10-17 05:13:34 +00:00
|
|
|
|
|
|
|
shortcutsTW->sortItems(0, Qt::AscendingOrder);
|
2007-10-19 03:09:14 +00:00
|
|
|
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());
|
|
|
|
|
|
|
|
shortcutsTW->resizeColumnToContents(0);
|
2007-10-19 03:09:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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));
|
2008-09-23 13:53:38 +00:00
|
|
|
KeyMap::ItemType item_tag = tag;
|
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) {
|
2007-10-21 05:30:43 +00:00
|
|
|
if (items[i]->text(1) == shortcut)
|
|
|
|
newItem = items[i];
|
|
|
|
break;
|
|
|
|
}
|
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-09-23 13:53:38 +00:00
|
|
|
item_tag = KeyMap::UserExtraUnbind;
|
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)));
|
2007-10-21 05:30:43 +00:00
|
|
|
setItemType(newItem, item_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
|
|
|
|
2008-09-23 13:53:38 +00:00
|
|
|
KeyMap::ItemType tag =
|
|
|
|
static_cast<KeyMap::ItemType>(items[0]->data(0, Qt::UserRole).toInt());
|
|
|
|
if (tag == 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
|
|
|
}
|
|
|
|
|
|
|
|
|
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-09-23 13:53:38 +00:00
|
|
|
KeyMap::ItemType tag =
|
|
|
|
static_cast<KeyMap::ItemType>(items[i]->data(0, Qt::UserRole).toInt());
|
2008-06-25 15:02:18 +00:00
|
|
|
|
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
|
|
|
// 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);
|
|
|
|
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.
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
while (*it)
|
|
|
|
shortcutsTW->setItemHidden(*it++, false);
|
|
|
|
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
|
2007-10-19 09:38:28 +00:00
|
|
|
for (int i = 0; i < matched.size(); ++i) {
|
2007-10-19 16:49:04 +00:00
|
|
|
shortcutsTW->setItemHidden(matched[i], false);
|
2007-10-20 20:50:56 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-23 10:48:30 +00:00
|
|
|
void PrefShortcuts::shortcutOkPressed()
|
2007-10-19 03:09:14 +00:00
|
|
|
{
|
2008-07-22 09:35:46 +00:00
|
|
|
QString const new_lfun = shortcut_->lfunLE->text();
|
|
|
|
FuncRequest func = lyxaction.lookupFunc(fromqstr(new_lfun));
|
2007-10-20 20:50:56 +00:00
|
|
|
|
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"));
|
2007-10-20 20:50:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-21 14:54:07 +00:00
|
|
|
KeySequence k = shortcut_->shortcutWG->getKeySequence();
|
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"));
|
2007-10-20 20:50:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-24 14:56:43 +00:00
|
|
|
// check to see if there's been any change
|
|
|
|
FuncRequest oldBinding = system_bind_.getBinding(k);
|
2010-04-09 19:00:42 +00:00
|
|
|
if (oldBinding.action() == LFUN_UNKNOWN_ACTION)
|
2008-09-24 14:56:43 +00:00
|
|
|
oldBinding = user_bind_.getBinding(k);
|
2010-03-29 09:13:00 +00:00
|
|
|
if (oldBinding == func)
|
|
|
|
// nothing has changed
|
2008-09-24 14:56:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// make sure this key isn't already bound---and, if so, not unbound
|
2010-04-09 19:00:42 +00:00
|
|
|
FuncCode const unbind = user_unbind_.getBinding(k).action();
|
2010-03-11 17:34:59 +00:00
|
|
|
docstring const action_string = makeCmdString(oldBinding);
|
2010-04-09 19:00:42 +00:00
|
|
|
if (oldBinding.action() > LFUN_NOACTION && unbind == LFUN_UNKNOWN_ACTION
|
2010-03-11 17:34:59 +00:00
|
|
|
&& save_lfun_ != toqstr(action_string)) {
|
2008-09-24 14:56:43 +00:00
|
|
|
// FIXME Perhaps we should offer to over-write the old shortcut?
|
|
|
|
// If so, we'll need to remove it from our list, etc.
|
2007-10-20 20:50:56 +00:00
|
|
|
Alert::error(_("Failed to create shortcut"),
|
2008-09-24 14:56:43 +00:00
|
|
|
bformat(_("Shortcut `%1$s' is already bound to:\n%2$s\n"
|
|
|
|
"You need to remove that binding before creating a new one."),
|
2010-03-11 17:34:59 +00:00
|
|
|
k.print(KeySequence::ForGui), action_string));
|
2007-10-20 20:50:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-06-25 15:02:18 +00:00
|
|
|
|
2010-03-11 17:34:59 +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
|
|
|
|
removeShortcut();
|
|
|
|
|
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);
|
|
|
|
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)
|
|
|
|
: PrefModule(QString(), qt_("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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefIdentity::apply(LyXRC & rc) const
|
|
|
|
{
|
|
|
|
rc.user_name = fromqstr(nameED->text());
|
|
|
|
rc.user_email = fromqstr(emailED->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PrefIdentity::update(LyXRC const & rc)
|
|
|
|
{
|
|
|
|
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)
|
2008-02-05 12:43:19 +00:00
|
|
|
: GuiDialog(lv, "prefs", qt_("Preferences")), update_screen_font_(false)
|
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);
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
connect(savePB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
|
|
|
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
|
2007-04-25 07:13:54 +00:00
|
|
|
|
2008-05-19 20:52:24 +00:00
|
|
|
addModule(new PrefUserInterface(this));
|
|
|
|
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
|
|
|
|
2010-04-15 14:25:25 +00:00
|
|
|
//for strftime validator
|
|
|
|
PrefOutput * output = new PrefOutput(this);
|
|
|
|
addModule(output);
|
2008-05-19 20:52:24 +00:00
|
|
|
addModule(new PrefPrinter(this));
|
|
|
|
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
|
|
|
|
2010-08-14 15:19:05 +00:00
|
|
|
prefsPS->setCurrentPanel(qt_("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);
|
|
|
|
bc().setOK(savePB);
|
|
|
|
bc().setApply(applyPB);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
bc().setRestore(restorePB);
|
2009-03-27 11:22:54 +00:00
|
|
|
|
|
|
|
// initialize the strftime validator
|
2010-04-15 14:25:25 +00:00
|
|
|
bc().addCheckedLineEdit(output->DateED);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 09:47:12 +00:00
|
|
|
void GuiPreferences::apply(LyXRC & rc) const
|
2007-04-25 07:13:54 +00:00
|
|
|
{
|
|
|
|
size_t end = modules_.size();
|
|
|
|
for (size_t i = 0; i != end; ++i)
|
|
|
|
modules_[i]->apply(rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 09:47:12 +00: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)
|
|
|
|
modules_[i]->update(rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 09:47:12 +00:00
|
|
|
void GuiPreferences::applyView()
|
|
|
|
{
|
|
|
|
apply(rc());
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
formats_ = lyx::formats;
|
|
|
|
converters_ = theConverters();
|
|
|
|
converters_.update(formats_);
|
|
|
|
movers_ = theMovers();
|
|
|
|
colors_.clear();
|
|
|
|
update_screen_font_ = false;
|
2008-11-23 14:12:39 +00:00
|
|
|
|
2008-07-11 09:35:05 +00:00
|
|
|
updateRc(rc_);
|
2009-02-26 20:52:47 +00: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
|
2010-10-29 19:27:55 +00:00
|
|
|
Author const & author =
|
|
|
|
Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
|
|
|
|
theBufferList().recordCurrentAuthor(author);
|
2007-10-07 09:47:12 +00:00
|
|
|
|
|
|
|
lyx::formats = formats_;
|
|
|
|
|
|
|
|
theConverters() = converters_;
|
|
|
|
theConverters().update(lyx::formats);
|
|
|
|
theConverters().buildGraph();
|
|
|
|
|
|
|
|
theMovers() = movers_;
|
|
|
|
|
|
|
|
vector<string>::const_iterator it = colors_.begin();
|
|
|
|
vector<string>::const_iterator const end = colors_.end();
|
|
|
|
for (; it != end; ++it)
|
|
|
|
dispatch(FuncRequest(LFUN_SET_COLOR, *it));
|
|
|
|
colors_.clear();
|
|
|
|
|
|
|
|
if (update_screen_font_) {
|
|
|
|
dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
|
|
|
|
update_screen_font_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The Save button has been pressed
|
2007-10-09 21:21:01 +00:00
|
|
|
if (isClosing())
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiPreferences::updateScreenFonts()
|
|
|
|
{
|
|
|
|
update_screen_font_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
QString GuiPreferences::browsebind(QString const & file) const
|
2007-10-07 09:47:12 +00:00
|
|
|
{
|
2008-03-05 23:10:53 +00:00
|
|
|
return browseLibFile("bind", file, "bind", qt_("Choose bind file"),
|
2008-04-20 19:56:01 +00:00
|
|
|
QStringList(qt_("LyX bind files (*.bind)")));
|
2007-10-07 09:47:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
QString GuiPreferences::browseUI(QString const & file) const
|
2007-10-07 09:47:12 +00:00
|
|
|
{
|
2008-03-05 23:10:53 +00:00
|
|
|
return browseLibFile("ui", file, "ui", qt_("Choose UI file"),
|
2008-04-20 19:56:01 +00:00
|
|
|
QStringList(qt_("LyX UI files (*.ui)")));
|
2007-10-07 09:47:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
QString GuiPreferences::browsekbmap(QString const & file) const
|
2007-10-07 09:47:12 +00:00
|
|
|
{
|
2008-03-05 23:10:53 +00:00
|
|
|
return browseLibFile("kbd", file, "kmap", qt_("Choose keyboard map"),
|
2008-04-20 19:56:01 +00:00
|
|
|
QStringList(qt_("LyX keyboard maps (*.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"
|