mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
- Simplify prefs, graphics and external display options which are now true or false.
- the display combo in the prefs, external and graphics dialogs are gone - the lyxrc display_graphics option now overrides any local inset display option - The external template format has a new tag: Preview - format incremented to 337 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25245 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2c44c3d031
commit
4a1be58591
@ -1,6 +1,9 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2008-06-13 Abdelrazak Younes <younes@lyx.org>
|
||||
* Format incremented to 337: convert/revert graphics display param.
|
||||
|
||||
2008-06-04 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||
* Format incremented to 336: new param \font_cjk.
|
||||
|
||||
|
@ -58,6 +58,13 @@ Template RasterImage
|
||||
Transform Resize
|
||||
Transform Clip
|
||||
Transform Extra
|
||||
# LyX preview options:
|
||||
# Off: LyX will not attempt to show this material on screen.
|
||||
# Graphics: LyX will attempt to show this material as-is or via a
|
||||
# conversion to a showable format.
|
||||
# InstantPreview: LyX will attempt to use the 'instant preview'
|
||||
# mechanism in order to show this material.
|
||||
Preview Graphics
|
||||
Format LaTeX
|
||||
TransformOption Rotate RotationLatexOption
|
||||
TransformOption Resize ResizeLatexOption
|
||||
@ -109,6 +116,7 @@ Template XFig
|
||||
AutomaticProduction true
|
||||
Transform Rotate
|
||||
Transform Resize
|
||||
Preview InstantPreview
|
||||
Format LaTeX
|
||||
TransformCommand Rotate RotationLatexCommand
|
||||
TransformCommand Resize ResizeLatexCommand
|
||||
@ -175,6 +183,7 @@ Template ChessDiagram
|
||||
InputFormat fen
|
||||
FileFilter "*.fen"
|
||||
AutomaticProduction true
|
||||
Preview InstantPreview
|
||||
Format LaTeX
|
||||
Product "\\loadgame{$$AbsOrRelPathMaster$$Basename}\\showboard"
|
||||
Requirement "chess"
|
||||
@ -211,6 +220,7 @@ Template LilyPond
|
||||
Transform Resize
|
||||
Transform Clip
|
||||
Transform Extra
|
||||
Preview InstantPreview
|
||||
Format LaTeX
|
||||
TransformOption Rotate RotationLatexOption
|
||||
TransformOption Resize ResizeLatexOption
|
||||
@ -293,6 +303,7 @@ Template Date
|
||||
InputFormat date
|
||||
FileFilter "*"
|
||||
AutomaticProduction true
|
||||
Preview Off
|
||||
Format LaTeX
|
||||
Product "$$Contents(\"$$Tempname\")"
|
||||
UpdateFormat dateout
|
||||
|
@ -2500,6 +2500,40 @@ def revert_InsetSpace(document):
|
||||
document.body[i] = document.body[i].replace('\\begin_inset space', '\\begin_inset Space')
|
||||
|
||||
|
||||
def convert_display_enum(document):
|
||||
" Convert 'display foo' to 'display false/true'"
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "display", i)
|
||||
if i == -1:
|
||||
return
|
||||
if check_token(i, "none"):
|
||||
document.body[i] = document.body[i].replace('none', 'false')
|
||||
if check_token(i, "default"):
|
||||
document.body[i] = document.body[i].replace('default', 'true')
|
||||
if check_token(i, "monochrome"):
|
||||
document.body[i] = document.body[i].replace('monochrome', 'true')
|
||||
if check_token(i, "grayscale"):
|
||||
document.body[i] = document.body[i].replace('grayscale', 'true')
|
||||
if check_token(i, "color"):
|
||||
document.body[i] = document.body[i].replace('color', 'true')
|
||||
if check_token(i, "preview"):
|
||||
document.body[i] = document.body[i].replace('preview', 'true')
|
||||
|
||||
|
||||
def revert_display_enum(document):
|
||||
" Revert 'display false/true' to 'display none/color'"
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "display", i)
|
||||
if i == -1:
|
||||
return
|
||||
if check_token(i, "false"):
|
||||
document.body[i] = document.body[i].replace('false', 'none')
|
||||
if check_token(i, "true"):
|
||||
document.body[i] = document.body[i].replace('true', 'default')
|
||||
|
||||
|
||||
def remove_fontsCJK(document):
|
||||
' Remove font_cjk param '
|
||||
i = find_token(document.header, "\\font_cjk", 0)
|
||||
@ -2610,9 +2644,11 @@ convert = [[277, [fix_wrong_tables]],
|
||||
[334, [convert_paper_sizes]],
|
||||
[335, [convert_InsetSpace]],
|
||||
[336, []],
|
||||
[337, [convert_display_enum]],
|
||||
]
|
||||
|
||||
revert = [[335, [remove_fontsCJK]],
|
||||
revert = [[336, [revert_display_enum]],
|
||||
[335, [remove_fontsCJK]],
|
||||
[334, [revert_InsetSpace]],
|
||||
[333, [revert_paper_sizes]],
|
||||
[332, []],
|
||||
|
@ -115,7 +115,7 @@ namespace os = support::os;
|
||||
|
||||
namespace {
|
||||
|
||||
int const LYX_FORMAT = 336;
|
||||
int const LYX_FORMAT = 337;
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -254,7 +254,7 @@ void LyXRC::setDefaults()
|
||||
load_session = false;
|
||||
make_backup = true;
|
||||
backupdir_path.erase();
|
||||
display_graphics = graphics::ColorDisplay;
|
||||
display_graphics = true;
|
||||
// Spellchecker settings:
|
||||
use_spell_lib = true;
|
||||
isp_command = "ispell";
|
||||
@ -420,7 +420,7 @@ int LyXRC::read(Lexer & lexrc)
|
||||
|
||||
case RC_DISPLAY_GRAPHICS:
|
||||
if (lexrc.next())
|
||||
display_graphics = graphics::displayTranslator().find(lexrc.getString());
|
||||
display_graphics = lexrc.getString() == "true";
|
||||
break;
|
||||
|
||||
case RC_TEX_EXPECTS_WINDOWS_PATHS:
|
||||
@ -1224,10 +1224,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
if (ignore_system_lyxrc ||
|
||||
display_graphics != system_lyxrc.display_graphics) {
|
||||
os << "# Display graphics within LyX\n"
|
||||
<< "# monochrome|grayscale|color|none\n"
|
||||
<< "# true|false\n"
|
||||
<< "\\display_graphics "
|
||||
<< graphics::displayTranslator().find(
|
||||
graphics::DisplayType(display_graphics))
|
||||
<< (display_graphics ? "true" : "false")
|
||||
<< '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
|
@ -376,8 +376,7 @@ public:
|
||||
///
|
||||
int label_init_length;
|
||||
///
|
||||
///graphics::DisplayType
|
||||
int display_graphics;
|
||||
bool display_graphics;
|
||||
///
|
||||
bool show_banner;
|
||||
///
|
||||
|
@ -98,12 +98,10 @@ GuiExternal::GuiExternal(GuiView & lv)
|
||||
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
||||
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
||||
|
||||
connect(displayGB, SIGNAL(toggled(bool)),
|
||||
showCO, SLOT(setEnabled(bool)));
|
||||
/*
|
||||
connect(displayGB, SIGNAL(toggled(bool)),
|
||||
displayscaleED, SLOT(setEnabled(bool)));
|
||||
connect(showCO, SIGNAL(activated(QString)),
|
||||
this, SLOT(change_adaptor()));
|
||||
*/
|
||||
connect(originCO, SIGNAL(activated(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(aspectratioCB, SIGNAL(stateChanged(int)),
|
||||
@ -168,7 +166,6 @@ GuiExternal::GuiExternal(GuiView & lv)
|
||||
bc().addReadOnly(externalCO);
|
||||
bc().addReadOnly(draftCB);
|
||||
bc().addReadOnly(displayscaleED);
|
||||
bc().addReadOnly(showCO);
|
||||
bc().addReadOnly(displayGB);
|
||||
bc().addReadOnly(angleED);
|
||||
bc().addReadOnly(originCO);
|
||||
@ -365,62 +362,6 @@ static Length::UNIT defaultUnit()
|
||||
}
|
||||
|
||||
|
||||
static void setDisplay(
|
||||
QGroupBox & displayGB, QComboBox & showCO, QLineEdit & scaleED,
|
||||
external::DisplayType display, unsigned int scale, bool read_only)
|
||||
{
|
||||
int item = 0;
|
||||
switch (display) {
|
||||
case external::DefaultDisplay:
|
||||
item = 0;
|
||||
break;
|
||||
case external::MonochromeDisplay:
|
||||
item = 1;
|
||||
break;
|
||||
case external::GrayscaleDisplay:
|
||||
item = 2;
|
||||
break;
|
||||
case external::ColorDisplay:
|
||||
item = 3;
|
||||
break;
|
||||
case external::PreviewDisplay:
|
||||
item = 4;
|
||||
break;
|
||||
case external::NoDisplay:
|
||||
item = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
showCO.setCurrentIndex(item);
|
||||
bool const no_display = display == external::NoDisplay;
|
||||
showCO.setEnabled(!no_display && !read_only);
|
||||
displayGB.setChecked(!no_display);
|
||||
scaleED.setEnabled(!no_display && !read_only);
|
||||
scaleED.setText(QString::number(scale));
|
||||
}
|
||||
|
||||
|
||||
static external::DisplayType display(QGroupBox const & displayGB,
|
||||
QComboBox const & showCO)
|
||||
{
|
||||
if (!displayGB.isChecked())
|
||||
return external::NoDisplay;
|
||||
switch (showCO.currentIndex()) {
|
||||
default:
|
||||
case 0:
|
||||
return external::DefaultDisplay;
|
||||
case 1:
|
||||
return external::MonochromeDisplay;
|
||||
case 2:
|
||||
return external::GrayscaleDisplay;
|
||||
case 3:
|
||||
return external::ColorDisplay;
|
||||
case 4:
|
||||
return external::PreviewDisplay;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void setRotation(QLineEdit & angleED, QComboBox & originCO,
|
||||
external::RotationData const & data)
|
||||
{
|
||||
@ -569,8 +510,10 @@ void GuiExternal::updateContents()
|
||||
|
||||
draftCB->setChecked(params_.draft);
|
||||
|
||||
setDisplay(*displayGB, *showCO, *displayscaleED,
|
||||
params_.display, params_.lyxscale, isBufferReadonly());
|
||||
displayGB->setChecked(params_.display);
|
||||
displayscaleED->setEnabled(params_.display && !isBufferReadonly());
|
||||
displayscaleED->setText(QString::number(params_.lyxscale));
|
||||
displayGB->setEnabled(lyxrc.display_graphics);
|
||||
|
||||
setRotation(*angleED, *originCO, params_.rotationdata);
|
||||
|
||||
@ -654,7 +597,7 @@ void GuiExternal::applyView()
|
||||
|
||||
params_.draft = draftCB->isChecked();
|
||||
params_.lyxscale = displayscaleED->text().toInt();
|
||||
params_.display = display(*displayGB, *showCO);
|
||||
params_.display = displayGB->isChecked();
|
||||
|
||||
if (rotationGB->isEnabled())
|
||||
getRotation(params_.rotationdata, *angleED, *originCO);
|
||||
|
@ -239,10 +239,7 @@ GuiGraphics::GuiGraphics(GuiView & lv)
|
||||
// setChecked(). Note, too, that clicked() would get called whenever it
|
||||
// is clicked, even right clicked (I think), not just whenever it is
|
||||
// toggled.
|
||||
connect(displayGB, SIGNAL(toggled(bool)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(showCB, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(displayGB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
|
||||
connect(displayscale, SIGNAL(textChanged(const QString&)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(groupId, SIGNAL(textChanged(const QString&)),
|
||||
@ -518,18 +515,8 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
|
||||
draftCB->setChecked(igp.draft);
|
||||
clip->setChecked(igp.clip);
|
||||
unzipCB->setChecked(igp.noUnzip);
|
||||
|
||||
int item = 0;
|
||||
switch (igp.display) {
|
||||
case graphics::DefaultDisplay: item = 0; break;
|
||||
case graphics::MonochromeDisplay: item = 1; break;
|
||||
case graphics::GrayscaleDisplay: item = 2; break;
|
||||
case graphics::ColorDisplay: item = 3; break;
|
||||
case graphics::NoDisplay: item = 0; break;
|
||||
}
|
||||
showCB->setCurrentIndex(item);
|
||||
displayGB->setChecked(igp.display);
|
||||
displayscale->setText(toqstr(convert<string>(igp.lyxscale)));
|
||||
displayGB->setChecked(igp.display != graphics::NoDisplay);
|
||||
|
||||
// the output section (width/height)
|
||||
|
||||
@ -540,6 +527,7 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
|
||||
scaleCB->setChecked(scaleChecked);
|
||||
scaleCB->blockSignals(false);
|
||||
Scale->setEnabled(scaleChecked);
|
||||
displayGB->setEnabled(lyxrc.display_graphics);
|
||||
|
||||
groupId->setText(toqstr(igp.groupId));
|
||||
|
||||
@ -636,17 +624,7 @@ void GuiGraphics::applyView()
|
||||
|
||||
igp.draft = draftCB->isChecked();
|
||||
igp.clip = clip->isChecked();
|
||||
|
||||
switch (showCB->currentIndex()) {
|
||||
case 0: igp.display = graphics::DefaultDisplay; break;
|
||||
case 1: igp.display = graphics::MonochromeDisplay; break;
|
||||
case 2: igp.display = graphics::GrayscaleDisplay; break;
|
||||
case 3: igp.display = graphics::ColorDisplay; break;
|
||||
default:;
|
||||
}
|
||||
|
||||
if (!displayGB->isChecked())
|
||||
igp.display = graphics::NoDisplay;
|
||||
igp.display = displayGB->isChecked();
|
||||
|
||||
//the graphics section
|
||||
if (scaleCB->isChecked() && !Scale->text().isEmpty()) {
|
||||
|
@ -78,58 +78,15 @@ bool GuiImage::load(FileName const & filename)
|
||||
}
|
||||
|
||||
|
||||
// This code is taken from KImageEffect::toGray
|
||||
static QPixmap toGray(QPixmap const & pix)
|
||||
{
|
||||
if (pix.width() == 0 || pix.height() == 0)
|
||||
return pix;
|
||||
|
||||
QImage img = pix.toImage();
|
||||
int const pixels = img.depth() > 8 ?
|
||||
img.width() * img.height() : img.numColors();
|
||||
|
||||
unsigned int *data = img.depth() > 8 ?
|
||||
reinterpret_cast<unsigned int *>(img.bits()) :
|
||||
reinterpret_cast<unsigned int *>(&img.colorTable()[0]);
|
||||
|
||||
for(int i = 0; i < pixels; ++i){
|
||||
int const val = qGray(data[i]);
|
||||
data[i] = qRgba(val, val, val, qAlpha(data[i]));
|
||||
}
|
||||
return QPixmap::fromImage(img);
|
||||
}
|
||||
|
||||
|
||||
bool GuiImage::setPixmap(Params const & params)
|
||||
{
|
||||
if (original_.isNull() || params.display == NoDisplay)
|
||||
if (original_.isNull() || !params.display)
|
||||
return false;
|
||||
|
||||
is_transformed_ = clip(params);
|
||||
is_transformed_ |= rotate(params);
|
||||
is_transformed_ |= scale(params);
|
||||
|
||||
switch (params.display) {
|
||||
case GrayscaleDisplay: {
|
||||
transformed_ = is_transformed_
|
||||
? toGray(transformed_) : toGray(original_);
|
||||
is_transformed_ = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case MonochromeDisplay: {
|
||||
QImage img = is_transformed_
|
||||
? transformed_.toImage() : original_.toImage();
|
||||
img.convertToFormat(img.format(), Qt::MonoOnly);
|
||||
transformed_ = QPixmap::fromImage(img);
|
||||
is_transformed_ = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!is_transformed_)
|
||||
// Clear it out to save some memory.
|
||||
transformed_ = QPixmap();
|
||||
|
@ -864,10 +864,8 @@ PrefDisplay::PrefDisplay(GuiPreferences * form)
|
||||
: PrefModule(qt_(catLookAndFeel), qt_("Graphics"), form)
|
||||
{
|
||||
setupUi(this);
|
||||
connect(instantPreviewCO, SIGNAL(activated(int)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(displayGraphicsCO, SIGNAL(activated(int)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(displayGraphicsCB, SIGNAL(toggled(int)), this, SIGNAL(changed()));
|
||||
connect(instantPreviewCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
|
||||
@ -879,15 +877,7 @@ void PrefDisplay::apply(LyXRC & rc) const
|
||||
case 2: rc.preview = LyXRC::PREVIEW_ON; break;
|
||||
}
|
||||
|
||||
graphics::DisplayType dtype;
|
||||
switch (displayGraphicsCO->currentIndex()) {
|
||||
case 3: dtype = graphics::NoDisplay; break;
|
||||
case 2: dtype = graphics::ColorDisplay; break;
|
||||
case 1: dtype = graphics::GrayscaleDisplay; break;
|
||||
case 0: dtype = graphics::MonochromeDisplay; break;
|
||||
default: dtype = graphics::GrayscaleDisplay;
|
||||
}
|
||||
rc.display_graphics = dtype;
|
||||
rc.display_graphics = displayGraphicsCB->isChecked();
|
||||
|
||||
// FIXME!! The graphics cache no longer has a changeDisplay method.
|
||||
#if 0
|
||||
@ -913,15 +903,8 @@ void PrefDisplay::update(LyXRC const & rc)
|
||||
break;
|
||||
}
|
||||
|
||||
int item = 2;
|
||||
switch (rc.display_graphics) {
|
||||
case graphics::NoDisplay: item = 3; break;
|
||||
case graphics::ColorDisplay: item = 2; break;
|
||||
case graphics::GrayscaleDisplay: item = 1; break;
|
||||
case graphics::MonochromeDisplay: item = 0; break;
|
||||
default: break;
|
||||
}
|
||||
displayGraphicsCO->setCurrentIndex(item);
|
||||
displayGraphicsCB->setChecked(rc.display_graphics);
|
||||
instantPreviewCO->setEnabled(rc.display_graphics);
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,10 +24,21 @@
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QTabWidget" name="tab" >
|
||||
<property name="toolTip" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentIndex" >
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="filetab" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>362</width>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title" >
|
||||
<string>F&ile</string>
|
||||
</attribute>
|
||||
@ -98,7 +109,7 @@
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
@ -109,9 +120,7 @@
|
||||
<item row="0" column="0" >
|
||||
<widget class="QComboBox" name="externalCO" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -127,17 +136,19 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="lyxviewtab" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>362</width>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title" >
|
||||
<string>LaTe&X and LyX options</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="QGroupBox" name="optionsGB" >
|
||||
<property name="title" >
|
||||
<string>LaTeX Options</string>
|
||||
@ -184,10 +195,15 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<item>
|
||||
<widget class="QGroupBox" name="displayGB" >
|
||||
<property name="toolTip" >
|
||||
<string>Display image in LyX</string>
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Enable LyX to preview this material; only if graphics previewing is not disabled at application level (see Preference dialog).</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html></string>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>&Show in LyX</string>
|
||||
@ -198,134 +214,58 @@
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>87</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QComboBox" name="showCO" >
|
||||
<property name="toolTip" >
|
||||
<string>Screen display</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Monochrome</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Grayscale</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="displayscaleED" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Percentage to scale by in LyX</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="displayscaleLA" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="focusPolicy" >
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>%</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="showLA" >
|
||||
<property name="toolTip" >
|
||||
<string>Screen display</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Display:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>showCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLabel" name="scaleLA" >
|
||||
<property name="toolTip" >
|
||||
<string>Percentage to scale by in LyX</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Sca&le:</string>
|
||||
<string>Sca&le on Screen (%):</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>displayscaleED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="displayscaleED" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Percentage to scale by in LyX</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<spacer name="horizontalSpacer" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>81</width>
|
||||
<height>196</height>
|
||||
@ -336,6 +276,14 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="sizetab" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>362</width>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title" >
|
||||
<string>Si&ze and Rotation</string>
|
||||
</attribute>
|
||||
@ -369,7 +317,7 @@
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
@ -388,9 +336,7 @@
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="angleED" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -457,7 +403,7 @@
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="2" >
|
||||
<widget class="LengthCombo" native="1" name="heightUnitCO" />
|
||||
<widget class="LengthCombo" name="heightUnitCO" />
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QComboBox" name="widthUnitCO" />
|
||||
@ -601,7 +547,7 @@
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>43</width>
|
||||
<height>18</height>
|
||||
@ -631,12 +577,12 @@
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
@ -645,7 +591,7 @@
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
@ -689,11 +635,13 @@
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>tab</zorder>
|
||||
<zorder>displayscaleLA</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LengthCombo</class>
|
||||
<extends>QWidget</extends>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LengthCombo.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
@ -704,8 +652,6 @@
|
||||
<tabstop>externalCO</tabstop>
|
||||
<tabstop>externalTB</tabstop>
|
||||
<tabstop>draftCB</tabstop>
|
||||
<tabstop>showCO</tabstop>
|
||||
<tabstop>displayscaleED</tabstop>
|
||||
<tabstop>angleED</tabstop>
|
||||
<tabstop>originCO</tabstop>
|
||||
<tabstop>okPB</tabstop>
|
||||
|
@ -121,15 +121,15 @@
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentIndex" >
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Graphics" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>562</width>
|
||||
<height>293</height>
|
||||
<width>593</width>
|
||||
<height>295</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title" >
|
||||
@ -371,8 +371,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>593</width>
|
||||
<height>295</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title" >
|
||||
@ -541,8 +541,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>595</width>
|
||||
<height>293</height>
|
||||
<width>593</width>
|
||||
<height>295</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title" >
|
||||
@ -600,6 +600,9 @@
|
||||
<property name="focusPolicy" >
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Enable LyX to preview this graphics, only if graphics previewing is not disabled at application level (see Preference dialog).</string>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>Sho&w in LyX</string>
|
||||
</property>
|
||||
@ -629,75 +632,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3" >
|
||||
<widget class="QLineEdit" name="displayscale" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Percentage to scale by in LyX</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QLabel" name="scaleLA" >
|
||||
<property name="toolTip" >
|
||||
<string>Percentage to scale by in LyX</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Sca&le on Screen (%):</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>displayscale</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="showCB" >
|
||||
<property name="toolTip" >
|
||||
<string>Screen display</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Monochrome</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Grayscale</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="showL" >
|
||||
<property name="toolTip" >
|
||||
<string>Screen display</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Scr&een Display:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>showCB</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="sizePolicy" >
|
||||
@ -727,6 +661,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="displayscale" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Percentage to scale by in LyX</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="scaleLA" >
|
||||
<property name="toolTip" >
|
||||
<string>Percentage to scale by in LyX</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Sca&le on Screen (%):</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>displayscale</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -790,8 +753,6 @@
|
||||
<tabstop>draftCB</tabstop>
|
||||
<tabstop>unzipCB</tabstop>
|
||||
<tabstop>displayGB</tabstop>
|
||||
<tabstop>showCB</tabstop>
|
||||
<tabstop>displayscale</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
|
@ -12,19 +12,20 @@
|
||||
<property name="windowTitle" >
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<widget class="QCheckBox" name="displayGraphicsCB" >
|
||||
<property name="text" >
|
||||
<string>Display &Graphics</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item rowspan="2" row="0" column="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
@ -32,6 +33,16 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="instantPreviewLA" >
|
||||
<property name="text" >
|
||||
<string>Instant &Preview:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>instantPreviewCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QComboBox" name="instantPreviewCO" >
|
||||
<item>
|
||||
@ -51,50 +62,6 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="displayGraphicsCO" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Monochrome</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Grayscale</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Do not display</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="displayGraphicsLA" >
|
||||
<property name="text" >
|
||||
<string>Display &Graphics:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>displayGraphicsCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="instantPreviewLA" >
|
||||
<property name="text" >
|
||||
<string>Instant &Preview:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>instantPreviewCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
@ -103,7 +70,7 @@
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
@ -114,7 +81,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>displayGraphicsCO</tabstop>
|
||||
<tabstop>instantPreviewCO</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
|
@ -207,10 +207,10 @@ Loader::Loader()
|
||||
{}
|
||||
|
||||
|
||||
Loader::Loader(FileName const & file, DisplayType type)
|
||||
Loader::Loader(FileName const & file, bool display)
|
||||
: pimpl_(new Impl)
|
||||
{
|
||||
reset(file, type);
|
||||
reset(file, display);
|
||||
}
|
||||
|
||||
|
||||
@ -245,10 +245,10 @@ Loader & Loader::operator=(Loader const & other)
|
||||
}
|
||||
|
||||
|
||||
void Loader::reset(FileName const & file, DisplayType type) const
|
||||
void Loader::reset(FileName const & file, bool display) const
|
||||
{
|
||||
Params params;
|
||||
params.display = type;
|
||||
params.display = display;
|
||||
pimpl_->resetParams(params);
|
||||
|
||||
pimpl_->resetFile(file);
|
||||
@ -407,8 +407,7 @@ void Loader::Impl::statusChanged()
|
||||
|
||||
void Loader::Impl::createPixmap()
|
||||
{
|
||||
if (!cached_item_.get() ||
|
||||
params_.display == NoDisplay || status_ != Loaded)
|
||||
if (!cached_item_.get() || !params_.display || status_ != Loaded)
|
||||
return;
|
||||
|
||||
image_.reset(cached_item_->image()->clone());
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
/// Must use the reset methods to make this instance usable.
|
||||
Loader();
|
||||
/// The image is not transformed, just displayed as-is.
|
||||
Loader(support::FileName const & file_with_path, DisplayType = ColorDisplay);
|
||||
Loader(support::FileName const & file_with_path, bool display = true);
|
||||
/// The image is transformed before display.
|
||||
Loader(support::FileName const & file_with_path, Params const &);
|
||||
///
|
||||
@ -53,8 +53,7 @@ public:
|
||||
Loader & operator=(Loader const &);
|
||||
|
||||
/// The file can be changed, or the display params, or both.
|
||||
void reset(support::FileName const & file_with_path,
|
||||
DisplayType = ColorDisplay) const;
|
||||
void reset(support::FileName const & file_with_path, bool display = true) const;
|
||||
///
|
||||
void reset(support::FileName const & file_with_path, Params const &) const;
|
||||
///
|
||||
|
@ -23,7 +23,7 @@ namespace lyx {
|
||||
namespace graphics {
|
||||
|
||||
Params::Params()
|
||||
: display(ColorDisplay),
|
||||
: display(true),
|
||||
scale(100),
|
||||
angle(0)
|
||||
{}
|
||||
|
@ -55,7 +55,7 @@ class Params
|
||||
public:
|
||||
Params();
|
||||
|
||||
DisplayType display;
|
||||
bool display;
|
||||
unsigned int scale;
|
||||
|
||||
/// The image filename.
|
||||
|
@ -19,30 +19,5 @@ using namespace std;
|
||||
namespace lyx {
|
||||
namespace graphics {
|
||||
|
||||
namespace {
|
||||
|
||||
/// The translator between the Display enum and corresponding lyx string.
|
||||
Translator<DisplayType, string> const initTranslator()
|
||||
{
|
||||
Translator<DisplayType, string> translator(DefaultDisplay, "default");
|
||||
|
||||
// Fill the display translator
|
||||
translator.addPair(MonochromeDisplay, "monochrome");
|
||||
translator.addPair(GrayscaleDisplay, "grayscale");
|
||||
translator.addPair(ColorDisplay, "color");
|
||||
translator.addPair(NoDisplay, "none");
|
||||
|
||||
return translator;
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
Translator<DisplayType, string> const & displayTranslator()
|
||||
{
|
||||
static Translator<DisplayType, string> const translator =
|
||||
initTranslator();
|
||||
return translator;
|
||||
}
|
||||
|
||||
} // namespace graphics
|
||||
} // namespace lyx
|
||||
|
@ -50,24 +50,6 @@ enum ImageStatus {
|
||||
ErrorUnknown
|
||||
};
|
||||
|
||||
/// How is the image to be displayed on the LyX screen?
|
||||
enum DisplayType {
|
||||
///
|
||||
DefaultDisplay,
|
||||
///
|
||||
MonochromeDisplay,
|
||||
///
|
||||
GrayscaleDisplay,
|
||||
///
|
||||
ColorDisplay,
|
||||
///
|
||||
NoDisplay
|
||||
};
|
||||
|
||||
|
||||
/// The translator between the Display enum and corresponding lyx string.
|
||||
Translator<DisplayType, std::string> const & displayTranslator();
|
||||
|
||||
} // namespace graphics
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -102,8 +102,19 @@ public:
|
||||
<< "\tHelpTextEnd\n"
|
||||
<< "\tInputFormat " << et.inputFormat << '\n'
|
||||
<< "\tFileFilter " << et.fileRegExp << '\n'
|
||||
<< "\tAutomaticProduction " << et.automaticProduction << '\n';
|
||||
|
||||
<< "\tAutomaticProduction " << et.automaticProduction << '\n'
|
||||
<< "\tPreview ";
|
||||
switch (et.preview_mode) {
|
||||
case PREVIEW_OFF:
|
||||
os_ << "Off\n";
|
||||
break;
|
||||
case PREVIEW_GRAPHICS:
|
||||
os_ << "Graphics\n";
|
||||
break;
|
||||
case PREVIEW_INSTANT:
|
||||
os_ << "InstantPreview\n";
|
||||
break;
|
||||
}
|
||||
typedef vector<TransformID> IDs;
|
||||
IDs::const_iterator it = et.transformIds.begin();
|
||||
IDs::const_iterator end = et.transformIds.end();
|
||||
@ -299,6 +310,7 @@ void Template::readTemplate(Lexer & lex)
|
||||
TO_INPUTFORMAT,
|
||||
TO_FILTER,
|
||||
TO_AUTOMATIC,
|
||||
TO_PREVIEW,
|
||||
TO_TRANSFORM,
|
||||
TO_FORMAT,
|
||||
TO_END
|
||||
@ -306,6 +318,7 @@ void Template::readTemplate(Lexer & lex)
|
||||
|
||||
LexerKeyword templateoptiontags[] = {
|
||||
{ "automaticproduction", TO_AUTOMATIC },
|
||||
{ "preview", TO_PREVIEW },
|
||||
{ "filefilter", TO_FILTER },
|
||||
{ "format", TO_FORMAT },
|
||||
{ "guiname", TO_GUINAME },
|
||||
@ -345,6 +358,16 @@ void Template::readTemplate(Lexer & lex)
|
||||
automaticProduction = lex.getBool();
|
||||
break;
|
||||
|
||||
case TO_PREVIEW:
|
||||
lex >> token;
|
||||
if (token == "InstantPreview")
|
||||
preview_mode = PREVIEW_INSTANT;
|
||||
else if (token == "Graphics")
|
||||
preview_mode = PREVIEW_GRAPHICS;
|
||||
else
|
||||
preview_mode = PREVIEW_OFF;
|
||||
break;
|
||||
|
||||
case TO_TRANSFORM: {
|
||||
lex >> token;
|
||||
TransformID id = transformIDTranslator().find(token);
|
||||
|
@ -23,6 +23,12 @@ namespace support { class FileName; }
|
||||
|
||||
class Lexer;
|
||||
|
||||
enum PreviewMode {
|
||||
PREVIEW_OFF = 0,
|
||||
PREVIEW_GRAPHICS,
|
||||
PREVIEW_INSTANT
|
||||
};
|
||||
|
||||
namespace external {
|
||||
|
||||
class Template {
|
||||
@ -56,6 +62,8 @@ public:
|
||||
std::string fileRegExp;
|
||||
/// Should we do automatic production of the output?
|
||||
bool automaticProduction;
|
||||
/// How should we preview the data in LyX?
|
||||
PreviewMode preview_mode;
|
||||
/// A collection of transforms that we can use to transform the data.
|
||||
std::vector<TransformID> transformIds;
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include "InsetExternal.h"
|
||||
#include "insets/ExternalSupport.h"
|
||||
#include "insets/ExternalTemplate.h"
|
||||
#include "insets/RenderButton.h"
|
||||
#include "insets/RenderGraphic.h"
|
||||
#include "insets/RenderPreview.h"
|
||||
@ -54,8 +53,6 @@ using namespace lyx::support;
|
||||
|
||||
namespace {
|
||||
|
||||
lyx::external::DisplayType const defaultDisplayType = lyx::external::NoDisplay;
|
||||
|
||||
unsigned int const defaultLyxScale = 100;
|
||||
|
||||
string defaultTemplateName;
|
||||
@ -98,39 +95,11 @@ TempName & TempName::operator=(TempName const & other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
/// The translator between the Display enum and corresponding lyx string.
|
||||
Translator<DisplayType, string> const initTranslator()
|
||||
{
|
||||
Translator<DisplayType, string> translator(DefaultDisplay, "default");
|
||||
|
||||
// Fill the display translator
|
||||
translator.addPair(MonochromeDisplay, "monochrome");
|
||||
translator.addPair(GrayscaleDisplay, "grayscale");
|
||||
translator.addPair(ColorDisplay, "color");
|
||||
translator.addPair(PreviewDisplay, "preview");
|
||||
translator.addPair(NoDisplay, "none");
|
||||
|
||||
return translator;
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
Translator<DisplayType, string> const & displayTranslator()
|
||||
{
|
||||
static Translator<DisplayType, string> const translator =
|
||||
initTranslator();
|
||||
return translator;
|
||||
}
|
||||
|
||||
} // namespace external
|
||||
|
||||
|
||||
InsetExternalParams::InsetExternalParams()
|
||||
: display(defaultDisplayType),
|
||||
: display(true),
|
||||
lyxscale(defaultLyxScale),
|
||||
draft(false)
|
||||
{
|
||||
@ -180,6 +149,9 @@ void InsetExternalParams::settemplate(string const & name)
|
||||
clearIfNotFound(extradata, external::Extra, ids);
|
||||
clearIfNotFound(resizedata, external::Resize, ids);
|
||||
clearIfNotFound(rotationdata, external::Rotate, ids);
|
||||
|
||||
//
|
||||
preview_mode = et->preview_mode;
|
||||
}
|
||||
|
||||
|
||||
@ -191,10 +163,8 @@ void InsetExternalParams::write(Buffer const & buf, ostream & os) const
|
||||
if (!filename.empty())
|
||||
os << "\tfilename " << filename.outputFilename(buf.filePath()) << '\n';
|
||||
|
||||
if (display != defaultDisplayType)
|
||||
os << "\tdisplay "
|
||||
<< external::displayTranslator().find(display)
|
||||
<< '\n';
|
||||
if (!display)
|
||||
os << "\tdisplay false\n";
|
||||
|
||||
if (lyxscale != defaultLyxScale)
|
||||
os << "\tlyxscale " << convert<string>(lyxscale) << '\n';
|
||||
@ -301,8 +271,7 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
|
||||
|
||||
case EX_DISPLAY: {
|
||||
lex.next();
|
||||
string const name = lex.getString();
|
||||
display = external::displayTranslator().find(name);
|
||||
display = lex.getString() != "false";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -499,33 +468,6 @@ void InsetExternal::draw(PainterInfo & pi, int x, int y) const
|
||||
|
||||
namespace {
|
||||
|
||||
enum RenderType {
|
||||
RENDERBUTTON,
|
||||
RENDERGRAPHIC,
|
||||
RENDERPREVIEW
|
||||
};
|
||||
|
||||
|
||||
RenderType getRenderType(InsetExternalParams const & p)
|
||||
{
|
||||
if (!external::getTemplatePtr(p) ||
|
||||
p.filename.empty() ||
|
||||
p.display == external::NoDisplay)
|
||||
return RENDERBUTTON;
|
||||
|
||||
if (p.display == external::PreviewDisplay) {
|
||||
if (RenderPreview::status() != LyXRC::PREVIEW_OFF)
|
||||
return RENDERPREVIEW;
|
||||
return RENDERBUTTON;
|
||||
}
|
||||
|
||||
if (p.display == external::DefaultDisplay &&
|
||||
lyxrc.display_graphics == graphics::NoDisplay)
|
||||
return RENDERBUTTON;
|
||||
return RENDERGRAPHIC;
|
||||
}
|
||||
|
||||
|
||||
graphics::Params get_grfx_params(InsetExternalParams const & eparams)
|
||||
{
|
||||
graphics::Params gparams;
|
||||
@ -535,31 +477,7 @@ graphics::Params get_grfx_params(InsetExternalParams const & eparams)
|
||||
if (eparams.clipdata.clip)
|
||||
gparams.bb = eparams.clipdata.bbox;
|
||||
gparams.angle = convert<double>(eparams.rotationdata.adjAngle());
|
||||
|
||||
switch (eparams.display) {
|
||||
case external::DefaultDisplay:
|
||||
gparams.display = graphics::DefaultDisplay;
|
||||
break;
|
||||
case external::MonochromeDisplay:
|
||||
gparams.display = graphics::MonochromeDisplay;
|
||||
break;
|
||||
case external::GrayscaleDisplay:
|
||||
gparams.display = graphics::GrayscaleDisplay;
|
||||
break;
|
||||
case external::ColorDisplay:
|
||||
gparams.display = graphics::ColorDisplay;
|
||||
break;
|
||||
case external::NoDisplay:
|
||||
gparams.display = graphics::NoDisplay;
|
||||
break;
|
||||
default:
|
||||
LASSERT(false, /**/);
|
||||
}
|
||||
if (gparams.display == graphics::DefaultDisplay)
|
||||
gparams.display = graphics::DisplayType(lyxrc.display_graphics);
|
||||
// Override the above if we're not using a gui
|
||||
if (!use_gui)
|
||||
gparams.display = graphics::NoDisplay;
|
||||
gparams.display = eparams.display;
|
||||
|
||||
return gparams;
|
||||
}
|
||||
@ -585,8 +503,7 @@ docstring screenLabel(InsetExternalParams const & params,
|
||||
|
||||
static bool isPreviewWanted(InsetExternalParams const & params)
|
||||
{
|
||||
return params.display == external::PreviewDisplay &&
|
||||
params.filename.isReadableFile();
|
||||
return params.display && params.filename.isReadableFile();
|
||||
}
|
||||
|
||||
|
||||
@ -632,44 +549,43 @@ void InsetExternal::setParams(InsetExternalParams const & p)
|
||||
// will use this.
|
||||
defaultTemplateName = params_.templatename();
|
||||
|
||||
switch (getRenderType(params_)) {
|
||||
case RENDERBUTTON: {
|
||||
if (!external::getTemplatePtr(params_) || params_.filename.empty()
|
||||
|| !params_.display
|
||||
|| !lyxrc.display_graphics
|
||||
|| params_.preview_mode == PREVIEW_OFF
|
||||
|| (params_.preview_mode == PREVIEW_INSTANT
|
||||
&& RenderPreview::status() == LyXRC::PREVIEW_OFF)) {
|
||||
RenderButton * button_ptr = renderer_->asButton();
|
||||
if (!button_ptr) {
|
||||
renderer_.reset(new RenderButton);
|
||||
button_ptr = renderer_->asButton();
|
||||
}
|
||||
|
||||
button_ptr->update(screenLabel(params_, buffer()), true);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
case RENDERGRAPHIC: {
|
||||
switch (params_.preview_mode) {
|
||||
case PREVIEW_OFF:
|
||||
// Already taken care of above.
|
||||
LASSERT(false, return);
|
||||
break;
|
||||
case PREVIEW_INSTANT: {
|
||||
RenderMonitoredPreview * preview_ptr = renderer_->asMonitoredPreview();
|
||||
renderer_.reset(new RenderMonitoredPreview(this));
|
||||
preview_ptr = renderer_->asMonitoredPreview();
|
||||
preview_ptr->fileChanged(boost::bind(&InsetExternal::fileChanged, this));
|
||||
if (preview_ptr->monitoring())
|
||||
preview_ptr->stopMonitoring();
|
||||
add_preview_and_start_loading(*preview_ptr, *this, buffer());
|
||||
break;
|
||||
}
|
||||
case PREVIEW_GRAPHICS: {
|
||||
RenderGraphic * graphic_ptr = renderer_->asGraphic();
|
||||
if (!graphic_ptr) {
|
||||
renderer_.reset(new RenderGraphic(this));
|
||||
graphic_ptr = renderer_->asGraphic();
|
||||
}
|
||||
|
||||
graphic_ptr->update(get_grfx_params(params_));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case RENDERPREVIEW: {
|
||||
RenderMonitoredPreview * preview_ptr =
|
||||
renderer_->asMonitoredPreview();
|
||||
if (!preview_ptr) {
|
||||
renderer_.reset(new RenderMonitoredPreview(this));
|
||||
preview_ptr = renderer_->asMonitoredPreview();
|
||||
preview_ptr->fileChanged(
|
||||
boost::bind(&InsetExternal::fileChanged, this));
|
||||
}
|
||||
|
||||
if (preview_ptr->monitoring())
|
||||
preview_ptr->stopMonitoring();
|
||||
add_preview_and_start_loading(*preview_ptr, *this, buffer());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define INSET_EXTERNAL_H
|
||||
|
||||
#include "Inset.h"
|
||||
#include "ExternalTemplate.h"
|
||||
#include "ExternalTransforms.h"
|
||||
|
||||
#include "support/FileName.h"
|
||||
@ -44,20 +45,6 @@ private:
|
||||
support::FileName tempname_;
|
||||
};
|
||||
|
||||
/// How is the image to be displayed on the LyX screen?
|
||||
enum DisplayType {
|
||||
DefaultDisplay,
|
||||
MonochromeDisplay,
|
||||
GrayscaleDisplay,
|
||||
ColorDisplay,
|
||||
PreviewDisplay,
|
||||
NoDisplay
|
||||
};
|
||||
|
||||
|
||||
/// The translator between the Display enum and corresponding lyx string.
|
||||
Translator<DisplayType, std::string> const & displayTranslator();
|
||||
|
||||
} // namespace external
|
||||
|
||||
|
||||
@ -78,8 +65,10 @@ public:
|
||||
|
||||
/// The external file.
|
||||
support::DocFileName filename;
|
||||
/// How the inset is to be displayed by LyX.
|
||||
external::DisplayType display;
|
||||
/// If the inset is to be displayed by LyX.
|
||||
bool display;
|
||||
/// If the inset is to use the preview mechanism.
|
||||
PreviewMode preview_mode;
|
||||
/// The scale of the displayed graphic (if shown).
|
||||
unsigned int lyxscale;
|
||||
|
||||
|
@ -64,7 +64,7 @@ void InsetGraphicsParams::init()
|
||||
{
|
||||
filename.erase();
|
||||
lyxscale = 100; // lyx scaling in percentage
|
||||
display = graphics::DefaultDisplay; // display mode; see preferences
|
||||
display = true; // may be overriden by display mode in preferences
|
||||
scale = string("100"); // output scaling in percentage
|
||||
width = Length();
|
||||
height = Length();
|
||||
@ -144,8 +144,8 @@ void InsetGraphicsParams::Write(ostream & os, Buffer const & buffer) const
|
||||
os << "\tfilename " << filename.outputFilename(buffer.filePath()) << '\n';
|
||||
if (lyxscale != 100)
|
||||
os << "\tlyxscale " << lyxscale << '\n';
|
||||
if (display != graphics::DefaultDisplay)
|
||||
os << "\tdisplay " << graphics::displayTranslator().find(display) << '\n';
|
||||
if (!display)
|
||||
os << "\tdisplay false\n";
|
||||
if (!scale.empty() && !float_equal(convert<double>(scale), 0.0, 0.05)) {
|
||||
if (!float_equal(convert<double>(scale), 100.0, 0.05))
|
||||
os << "\tscale " << scale << '\n';
|
||||
@ -193,7 +193,7 @@ bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const &
|
||||
} else if (token == "display") {
|
||||
lex.next();
|
||||
string const type = lex.getString();
|
||||
display = graphics::displayTranslator().find(type);
|
||||
display = lex.getString() != "false";
|
||||
} else if (token == "scale") {
|
||||
lex.next();
|
||||
scale = lex.getString();
|
||||
@ -303,15 +303,11 @@ graphics::Params InsetGraphicsParams::as_grfxParams() const
|
||||
}
|
||||
}
|
||||
|
||||
if (display == graphics::DefaultDisplay) {
|
||||
pars.display = graphics::DisplayType(lyxrc.display_graphics);
|
||||
} else {
|
||||
pars.display = display;
|
||||
}
|
||||
pars.display = display;
|
||||
|
||||
// Override the above if we're not using a gui
|
||||
if (!use_gui)
|
||||
pars.display = graphics::NoDisplay;
|
||||
pars.display = false;
|
||||
|
||||
return pars;
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ public:
|
||||
support::DocFileName filename;
|
||||
/// Scaling the Screen inside Lyx
|
||||
unsigned int lyxscale;
|
||||
/// How to display the image inside LyX
|
||||
graphics::DisplayType display;
|
||||
/// If to display the image inside LyX
|
||||
bool display;
|
||||
/// Scaling for output (LaTeX)
|
||||
std::string scale;
|
||||
/// sizes for output (LaTeX)
|
||||
|
@ -67,8 +67,7 @@ namespace {
|
||||
|
||||
bool displayGraphic(graphics::Params const & params)
|
||||
{
|
||||
return params.display != graphics::NoDisplay &&
|
||||
lyxrc.display_graphics != graphics::NoDisplay;
|
||||
return params.display && lyxrc.display_graphics;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user