2 * \file GuiGraphics.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
10 * \author Richard Heck
12 * Full author contact details are available in file CREDITS.
17 #include "GuiGraphics.h"
19 #include "LengthCombo.h"
22 #include "qt_helpers.h"
23 #include "Validator.h"
25 #include "FuncRequest.h"
27 #include "graphics/GraphicsCache.h"
28 #include "graphics/GraphicsCacheItem.h"
29 #include "graphics/GraphicsImage.h"
31 #include "insets/InsetGraphics.h"
33 #include "support/convert.h"
34 #include "support/debug.h"
35 #include "support/filetools.h"
36 #include "support/gettext.h"
37 #include "support/lstrings.h"
38 #include "support/os.h"
39 #include "support/Package.h"
40 #include "support/types.h"
45 #include <QPushButton>
52 using namespace lyx::support;
56 // These are the strings that are stored in the LyX file and which
57 // correspond to the LaTeX identifiers shown in the comments at the
59 char const * const rorigin_lyx_strs[] = {
60 // the LaTeX default is leftBaseline
62 "leftTop", "leftBottom", "leftBaseline", // lt lb lB
63 "center", "centerTop", "centerBottom", "centerBaseline", // c ct cb cB
64 "rightTop", "rightBottom", "rightBaseline" }; // rt rb rB
66 // These are the strings, corresponding to the above, that the GUI should
67 // use. Note that they can/should be translated.
68 char const * const rorigin_gui_strs[] = {
70 N_("Top left"), N_("Bottom left"), N_("Baseline left"),
71 N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
72 N_("Top right"), N_("Bottom right"), N_("Baseline right") };
74 size_t const rorigin_size = sizeof(rorigin_lyx_strs) / sizeof(char *);
82 //FIXME setAutoTextCB should really take an argument, as indicated, that
83 //determines what text is to be written for "auto". But making
84 //that work involves more extensive revisions than we now want
85 //to make, since "auto" also appears in paramsToDialog().
86 //The right way to do this, I think, would be to define a class
87 //checkedLengthSet (and a partnering labeledLengthSete) that encapsulated
88 //the checkbox, line edit, and length combo together, and then made e.g.
89 //lengthToWidgets, widgetsToLength, etc, all public methods of that class.
90 //Perhaps even the validator could be exposed through it.
92 * sets a checkbox-line edit-length combo group, using "text" if the
93 * checkbox is unchecked and clearing the line edit if it previously
96 static void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit,
97 LengthCombo * lengthCombo/*, string text = "auto"*/)
99 if (!checkBox->isChecked())
100 lengthToWidgets(lineEdit, lengthCombo,
101 "auto", lengthCombo->currentLengthItem());
102 else if (lineEdit->text() == "auto")
103 lengthToWidgets(lineEdit, lengthCombo, string(),
104 lengthCombo->currentLengthItem());
109 vector<typename Pair::first_type> getFirst(vector<Pair> const & pr)
111 size_t const n = pr.size();
112 vector<typename Pair::first_type> tmp(n);
113 for (size_t i = 0; i != n; ++i)
114 tmp[i] = pr[i].first;
121 vector<typename Pair::second_type> getSecond(vector<Pair> const & pr)
123 size_t const n = pr.size();
124 vector<typename Pair::second_type> tmp(n);
125 for (size_t i = 0; i != n; ++i)
126 tmp[i] = pr[i].second;
131 /// The (tranlated) GUI string and it's LaTeX equivalent.
132 typedef pair<docstring, string> RotationOriginPair;
134 vector<RotationOriginPair> getRotationOriginData()
136 static vector<RotationOriginPair> data;
140 data.resize(rorigin_size);
141 for (size_type i = 0; i < rorigin_size; ++i) {
142 data[i] = make_pair(_(rorigin_gui_strs[i]),
143 rorigin_lyx_strs[i]);
151 GuiGraphics::GuiGraphics(GuiView & lv)
152 : GuiDialog(lv, "graphics", qt_("Graphics"))
157 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
158 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
159 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
160 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
163 connect(filename, SIGNAL(textChanged(const QString &)),
164 this, SLOT(change_adaptor()));
165 connect(WidthCB, SIGNAL( clicked()),
166 this, SLOT(change_adaptor()));
167 connect(HeightCB, SIGNAL( clicked()),
168 this, SLOT(change_adaptor()));
169 connect(Width, SIGNAL(textChanged(const QString &)),
170 this, SLOT(change_adaptor()));
171 connect(Height, SIGNAL(textChanged(const QString &)),
172 this, SLOT(change_adaptor()));
173 connect(heightUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
174 this, SLOT(change_adaptor()));
175 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
176 this, SLOT(change_adaptor()));
177 connect(aspectratio, SIGNAL(stateChanged(int)),
178 this, SLOT(change_adaptor()));
179 connect(angle, SIGNAL(textChanged(const QString &)),
180 this, SLOT(change_adaptor()));
181 connect(origin, SIGNAL(activated(int)),
182 this, SLOT(change_adaptor()));
183 connect(scaleCB, SIGNAL(clicked()),
184 this, SLOT(change_adaptor()));
185 connect(Scale, SIGNAL(textChanged(const QString &)),
186 this, SLOT(change_adaptor()));
187 connect(rotateOrderCB, SIGNAL(clicked()),
188 this, SLOT(change_adaptor()));
190 filename->setValidator(new PathValidator(true, filename));
191 setFocusProxy(filename);
193 QDoubleValidator * scaleValidator = new DoubleAutoValidator(Scale);
194 scaleValidator->setBottom(0);
195 scaleValidator->setDecimals(256); //I guess that will do
196 Scale->setValidator(scaleValidator);
197 Height->setValidator(unsignedLengthAutoValidator(Height));
198 Width->setValidator(unsignedLengthAutoValidator(Width));
199 angle->setValidator(new QDoubleValidator(-360, 360, 2, angle));
202 connect(clip, SIGNAL(stateChanged(int)),
203 this, SLOT(change_adaptor()));
204 connect(lbY, SIGNAL(textChanged(const QString&)),
205 this, SLOT(change_bb()));
206 connect(lbYunit, SIGNAL(activated(int)),
207 this, SLOT(change_bb()));
208 connect(rtY, SIGNAL(textChanged(const QString&)),
209 this, SLOT(change_bb()));
210 connect(rtYunit, SIGNAL(activated(int)),
211 this, SLOT(change_bb()));
212 connect(lbX, SIGNAL(textChanged(const QString&)),
213 this, SLOT(change_bb()));
214 connect(lbXunit, SIGNAL(activated(int)),
215 this, SLOT(change_bb()));
216 connect(rtX, SIGNAL(textChanged(const QString&)),
217 this, SLOT(change_bb()));
218 connect(rtXunit, SIGNAL(activated(int)),
219 this, SLOT(change_bb()));
220 connect(getPB, SIGNAL(clicked()),
221 this, SLOT(change_adaptor()));
223 lbX->setValidator(new QDoubleValidator(lbX));
224 lbY->setValidator(new QDoubleValidator(lbY));
225 rtX->setValidator(new QDoubleValidator(rtX));
226 rtY->setValidator(new QDoubleValidator(rtY));
229 connect(latexoptions, SIGNAL(textChanged(const QString&)),
230 this, SLOT(change_adaptor()));
231 connect(draftCB, SIGNAL(stateChanged(int)),
232 this, SLOT(change_adaptor()));
233 connect(unzipCB, SIGNAL(stateChanged(int)),
234 this, SLOT(change_adaptor()));
235 // FIXME: we should connect to clicked() when we move to Qt 4.2 because
236 // the toggled(bool) signal is also trigged when we update the widgets
237 // (rgh-4/07) this isn't as much or a problem as it was, because we're now
238 // using blockSignals() to keep from triggering that signal when we call
239 // setChecked(). Note, too, that clicked() would get called whenever it
240 // is clicked, even right clicked (I think), not just whenever it is
242 connect(displayGB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
243 connect(displayscale, SIGNAL(textChanged(const QString&)),
244 this, SLOT(change_adaptor()));
245 connect(groupId, SIGNAL(textChanged(const QString&)),
246 this, SLOT(change_adaptor()));
247 displayscale->setValidator(new QIntValidator(displayscale));
249 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
251 bc().setApply(applyPB);
252 bc().setRestore(restorePB);
253 bc().setCancel(closePB);
255 bc().addReadOnly(latexoptions);
256 bc().addReadOnly(filenameL);
257 bc().addReadOnly(filename);
258 bc().addReadOnly(browsePB);
259 bc().addReadOnly(unzipCB);
260 bc().addReadOnly(bbFrame);
261 bc().addReadOnly(draftCB);
262 bc().addReadOnly(clip);
263 bc().addReadOnly(unzipCB);
264 bc().addReadOnly(displayGB);
265 bc().addReadOnly(sizeGB);
266 bc().addReadOnly(rotationGB);
267 bc().addReadOnly(latexoptions);
268 bc().addReadOnly(getPB);
269 bc().addReadOnly(rotateOrderCB);
271 // initialize the length validator
272 bc().addCheckedLineEdit(Scale, scaleCB);
273 bc().addCheckedLineEdit(Width, WidthCB);
274 bc().addCheckedLineEdit(Height, HeightCB);
275 bc().addCheckedLineEdit(displayscale, scaleLA);
276 bc().addCheckedLineEdit(angle, angleL);
277 bc().addCheckedLineEdit(lbX, xL);
278 bc().addCheckedLineEdit(lbY, yL);
279 bc().addCheckedLineEdit(rtX, xL_2);
280 bc().addCheckedLineEdit(rtY, yL_2);
281 bc().addCheckedLineEdit(filename, filenameL);
285 void GuiGraphics::change_adaptor()
291 void GuiGraphics::change_bb()
294 LYXERR(Debug::GRAPHICS, "[bb_Changed set to true]");
299 void GuiGraphics::on_browsePB_clicked()
301 QString const str = browse(filename->text());
302 if (!str.isEmpty()) {
303 filename->setText(str);
309 void GuiGraphics::on_getPB_clicked()
315 void GuiGraphics::setAutoText()
317 if (scaleCB->isChecked())
319 if (!Scale->isEnabled() && Scale->text() != "100")
320 Scale->setText(QString("auto"));
322 setAutoTextCB(WidthCB, Width, widthUnit);
323 setAutoTextCB(HeightCB, Height, heightUnit);
327 void GuiGraphics::on_scaleCB_toggled(bool setScale)
329 Scale->setEnabled(setScale);
331 Scale->setText("100");
332 Scale->setFocus(Qt::OtherFocusReason);
335 WidthCB->setDisabled(setScale);
336 WidthCB->blockSignals(true);
337 WidthCB->setChecked(false);
338 WidthCB->blockSignals(false);
339 Width->setEnabled(false);
340 widthUnit->setEnabled(false);
342 HeightCB->setDisabled(setScale);
343 HeightCB->blockSignals(true);
344 HeightCB->setChecked(false);
345 HeightCB->blockSignals(false);
346 Height->setEnabled(false);
347 heightUnit->setEnabled(false);
349 aspectratio->setDisabled(true);
350 aspectratio->setChecked(true);
352 rotateOrderCB->setEnabled((WidthCB->isChecked() ||
353 HeightCB->isChecked() ||
354 scaleCB->isChecked()) &&
355 (angle->text() != "0"));
361 void GuiGraphics::on_WidthCB_toggled(bool setWidth)
363 Width->setEnabled(setWidth);
364 widthUnit->setEnabled(setWidth);
366 Width->setFocus(Qt::OtherFocusReason);
368 bool const setHeight = HeightCB->isChecked();
369 aspectratio->setEnabled(setWidth && setHeight);
370 aspectratio->blockSignals(true);
371 aspectratio->setChecked(!(setWidth && setHeight));
372 aspectratio->blockSignals(false);
374 scaleCB->setEnabled(!setWidth && !setHeight);
375 //already will be unchecked, so don't need to do that
376 Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
377 && scaleCB->isChecked()); //should be false, but let's check
378 rotateOrderCB->setEnabled((setWidth || setHeight ||
379 scaleCB->isChecked()) &&
380 (angle->text() != "0"));
386 void GuiGraphics::on_HeightCB_toggled(bool setHeight)
388 Height->setEnabled(setHeight);
389 heightUnit->setEnabled(setHeight);
391 Height->setFocus(Qt::OtherFocusReason);
393 bool const setWidth = WidthCB->isChecked();
394 aspectratio->setEnabled(setWidth && setHeight);
395 aspectratio->blockSignals(true);
396 aspectratio->setChecked(!(setWidth && setHeight));
397 aspectratio->blockSignals(false);
399 scaleCB->setEnabled(!setWidth && !setHeight);
401 Scale->setEnabled((!setWidth && !setHeight) //=scaleCB->isEnabled()
402 && scaleCB->isChecked()); //should be false
403 rotateOrderCB->setEnabled((setWidth || setHeight ||
404 scaleCB->isChecked()) &&
405 (angle->text() != "0"));
411 void GuiGraphics::on_angle_textChanged(const QString & filename)
413 rotateOrderCB->setEnabled((WidthCB->isChecked() ||
414 HeightCB->isChecked() ||
415 scaleCB->isChecked()) &&
419 // returns the number of the string s in the vector v
420 static int itemNumber(const vector<string> & v, string const & s)
422 vector<string>::const_iterator cit =
423 find(v.begin(), v.end(), s);
424 return (cit != v.end()) ? int(cit - v.begin()) : 0;
428 void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
430 static char const * const bb_units[] = { "bp", "cm", "mm", "in" };
431 size_t const bb_size = sizeof(bb_units) / sizeof(bb_units[0]);
433 vector<string> const units = vector<string>(bb_units, bb_units + bb_size);
438 for (vector<string>::const_iterator it = units.begin();
439 it != units.end(); ++it) {
440 lbXunit->addItem(toqstr(*it));
441 lbYunit->addItem(toqstr(*it));
442 rtXunit->addItem(toqstr(*it));
443 rtYunit->addItem(toqstr(*it));
446 // set the right default unit
447 Length::UNIT unitDefault = Length::CM;
448 switch (lyxrc.default_papersize) {
451 case PAPER_USEXECUTIVE:
452 unitDefault = Length::IN;
458 //lyxerr << bufferFilepath();
460 igp.filename.outputFilename(fromqstr(bufferFilepath()));
461 filename->setText(toqstr(name));
463 // set the bounding box values
464 if (igp.bb.empty()) {
465 string const bb = readBoundingBox(igp.filename.absFilename());
466 // the values from the file always have the bigpoint-unit bp
467 lbX->setText(toqstr(token(bb, ' ', 0)));
468 lbY->setText(toqstr(token(bb, ' ', 1)));
469 rtX->setText(toqstr(token(bb, ' ', 2)));
470 rtY->setText(toqstr(token(bb, ' ', 3)));
471 lbXunit->setCurrentIndex(0);
472 lbYunit->setCurrentIndex(0);
473 rtXunit->setCurrentIndex(0);
474 rtYunit->setCurrentIndex(0);
477 // get the values from the inset
479 string const xl = token(igp.bb, ' ', 0);
480 string const yl = token(igp.bb, ' ', 1);
481 string const xr = token(igp.bb, ' ', 2);
482 string const yr = token(igp.bb, ' ', 3);
483 if (isValidLength(xl, &anyLength)) {
484 lbX->setText(toqstr(convert<string>(anyLength.value())));
485 string const unit = unit_name[anyLength.unit()];
486 lbXunit->setCurrentIndex(itemNumber(units, unit));
488 lbX->setText(toqstr(xl));
490 if (isValidLength(yl, &anyLength)) {
491 lbY->setText(toqstr(convert<string>(anyLength.value())));
492 string const unit = unit_name[anyLength.unit()];
493 lbYunit->setCurrentIndex(itemNumber(units, unit));
495 lbY->setText(toqstr(xl));
497 if (isValidLength(xr, &anyLength)) {
498 rtX->setText(toqstr(convert<string>(anyLength.value())));
499 string const unit = unit_name[anyLength.unit()];
500 rtXunit->setCurrentIndex(itemNumber(units, unit));
502 rtX->setText(toqstr(xl));
504 if (isValidLength(yr, &anyLength)) {
505 rtY->setText(toqstr(convert<string>(anyLength.value())));
506 string const unit = unit_name[anyLength.unit()];
507 rtYunit->setCurrentIndex(itemNumber(units, unit));
509 rtY->setText(toqstr(xl));
514 // Update the draft and clip mode
515 draftCB->setChecked(igp.draft);
516 clip->setChecked(igp.clip);
517 unzipCB->setChecked(igp.noUnzip);
518 displayGB->setChecked(igp.display);
519 displayscale->setText(toqstr(convert<string>(igp.lyxscale)));
521 // the output section (width/height)
523 Scale->setText(toqstr(igp.scale));
524 //igp.scale defaults to 100, so we treat it as empty
525 bool const scaleChecked = !igp.scale.empty() && igp.scale != "100";
526 scaleCB->blockSignals(true);
527 scaleCB->setChecked(scaleChecked);
528 scaleCB->blockSignals(false);
529 Scale->setEnabled(scaleChecked);
530 displayGB->setEnabled(lyxrc.display_graphics);
532 groupId->setText(toqstr(igp.groupId));
534 lengthAutoToWidgets(Width, widthUnit, igp.width,
536 bool const widthChecked = !Width->text().isEmpty() &&
537 Width->text() != "auto";
538 WidthCB->blockSignals(true);
539 WidthCB->setChecked(widthChecked);
540 WidthCB->blockSignals(false);
541 Width->setEnabled(widthChecked);
542 widthUnit->setEnabled(widthChecked);
544 lengthAutoToWidgets(Height, heightUnit, igp.height,
546 bool const heightChecked = !Height->text().isEmpty()
547 && Height->text() != "auto";
548 HeightCB->blockSignals(true);
549 HeightCB->setChecked(heightChecked);
550 HeightCB->blockSignals(false);
551 Height->setEnabled(heightChecked);
552 heightUnit->setEnabled(heightChecked);
554 scaleCB->setEnabled(!widthChecked && !heightChecked);
555 WidthCB->setEnabled(!scaleChecked);
556 HeightCB->setEnabled(!scaleChecked);
557 aspectratio->setEnabled(widthChecked && heightChecked);
561 angle->setText(toqstr(igp.rotateAngle));
562 rotateOrderCB->setChecked(igp.scaleBeforeRotation);
564 rotateOrderCB->setEnabled( (widthChecked || heightChecked || scaleChecked)
565 && igp.rotateAngle != "0");
569 vector<RotationOriginPair> origindata = getRotationOriginData();
570 vector<docstring> const origin_lang = getFirst(origindata);
571 origin_ltx = getSecond(origindata);
573 for (vector<docstring>::const_iterator it = origin_lang.begin();
574 it != origin_lang.end(); ++it)
575 origin->addItem(toqstr(*it));
577 if (!igp.rotateOrigin.empty())
578 origin->setCurrentIndex(itemNumber(origin_ltx, igp.rotateOrigin));
580 origin->setCurrentIndex(0);
583 latexoptions->setText(toqstr(igp.special));
587 void GuiGraphics::applyView()
589 InsetGraphicsParams & igp = params_;
591 igp.filename.set(fromqstr(filename->text()), fromqstr(bufferFilepath()));
597 string lbXs = fromqstr(lbX->text());
598 string lbYs = fromqstr(lbY->text());
599 string rtXs = fromqstr(rtX->text());
600 string rtYs = fromqstr(rtY->text());
602 convert<int>(lbXs) + convert<int>(lbYs) +
603 convert<int>(rtXs) + convert<int>(rtXs);
608 bb = lbXs + fromqstr(lbXunit->currentText()) + ' ';
612 bb += (lbYs + fromqstr(lbYunit->currentText()) + ' ');
616 bb += (rtXs + fromqstr(rtXunit->currentText()) + ' ');
620 bb += (rtYs + fromqstr(rtYunit->currentText()));
625 igp.draft = draftCB->isChecked();
626 igp.clip = clip->isChecked();
627 igp.display = displayGB->isChecked();
629 //the graphics section
630 if (scaleCB->isChecked() && !Scale->text().isEmpty()) {
631 igp.scale = fromqstr(Scale->text());
632 igp.width = Length("0pt");
633 igp.height = Length("0pt");
634 igp.keepAspectRatio = false;
636 igp.scale = string();
637 igp.width = WidthCB->isChecked() ?
638 //Note that this works even if Width is "auto", since in
639 //that case we get "0pt".
640 Length(widgetsToLength(Width, widthUnit)):
642 igp.height = HeightCB->isChecked() ?
643 Length(widgetsToLength(Height, heightUnit)) :
645 igp.keepAspectRatio = aspectratio->isEnabled() &&
646 aspectratio->isChecked() &&
647 igp.width.value() > 0 && igp.height.value() > 0;
650 igp.noUnzip = unzipCB->isChecked();
651 igp.lyxscale = displayscale->text().toInt();
652 igp.rotateAngle = fromqstr(angle->text());
654 double rotAngle = convert<double>(igp.rotateAngle);
655 if (abs(rotAngle) > 360.0) {
656 rotAngle -= 360.0 * floor(rotAngle / 360.0);
657 igp.rotateAngle = convert<string>(rotAngle);
660 // save the latex name for the origin. If it is the default
661 // then origin_ltx returns ""
662 igp.rotateOrigin = origin_ltx[origin->currentIndex()];
663 igp.scaleBeforeRotation = rotateOrderCB->isChecked();
665 // more latex options
666 igp.special = fromqstr(latexoptions->text());
668 igp.groupId = fromqstr(groupId->text());
672 void GuiGraphics::getBB()
674 string const fn = fromqstr(filename->text());
677 string const bb = readBoundingBox(fn);
681 lbX->setText(toqstr(token(bb, ' ', 0)));
682 lbY->setText(toqstr(token(bb, ' ', 1)));
683 rtX->setText(toqstr(token(bb, ' ', 2)));
684 rtY->setText(toqstr(token(bb, ' ', 3)));
685 // the default units for the bb values when reading
687 lbXunit->setCurrentIndex(0);
688 lbYunit->setCurrentIndex(0);
689 rtXunit->setCurrentIndex(0);
690 rtYunit->setCurrentIndex(0);
694 bool GuiGraphics::isValid()
696 return !filename->text().isEmpty();
700 bool GuiGraphics::initialiseParams(string const & data)
702 InsetGraphics::string2params(data, buffer(), params_);
703 paramsToDialog(params_);
708 void GuiGraphics::clearParams()
710 params_ = InsetGraphicsParams();
714 void GuiGraphics::dispatchParams()
716 InsetGraphicsParams tmp_params(params_);
717 string const lfun = InsetGraphics::params2string(tmp_params, buffer());
718 dispatch(FuncRequest(getLfun(), lfun));
719 if (!params_.groupId.empty())
720 dispatch(FuncRequest(LFUN_GRAPHICS_GROUPS_UNIFY,
721 InsetGraphics::params2string(params_, buffer())));
725 QString GuiGraphics::browse(QString const & in_name) const
727 QString const title = qt_("Select graphics file");
729 // Does user clipart directory exist?
730 string clipdir = addName(package().user_support().absFilename(), "clipart");
731 FileName clip(clipdir);
733 // bail out to system clipart directory
734 if (!clip.isDirectory())
735 clipdir = addName(package().system_support().absFilename(), "clipart");
737 return browseRelFile(in_name, bufferFilepath(),
738 title, fileFilters(QString()), false,
739 qt_("Clipart|#C#c"), toqstr(clipdir),
740 qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
744 string GuiGraphics::readBoundingBox(string const & file)
746 FileName const abs_file = support::makeAbsPath(file, fromqstr(bufferFilepath()));
748 // try to get it from the file, if possible. Zipped files are
749 // unzipped in the readBB_from_PSFile-Function
750 string const bb = readBB_from_PSFile(abs_file);
754 // we don't, so ask the Graphics Cache if it has loaded the file
758 graphics::Cache & gc = graphics::Cache::get();
759 if (gc.inCache(abs_file)) {
760 graphics::Image const * image = gc.item(abs_file)->image();
763 width = image->width();
764 height = image->height();
768 return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
772 bool GuiGraphics::isFileNameValid(string const & fname) const
774 // It may be that the filename is relative.
775 return support::makeAbsPath(fname, fromqstr(bufferFilepath())).isReadableFile();
779 Dialog * createGuiGraphics(GuiView & lv) { return new GuiGraphics(lv); }
782 } // namespace frontend
785 #include "GuiGraphics_moc.cpp"