this, SLOT(change_adaptor()));
connect(draftCB, SIGNAL(stateChanged(int)),
this, SLOT(change_adaptor()));
- // FIXME: we should connect to clicked() when we move to Qt 4.2 because
- // the toggled(bool) signal is also triggered when we update the widgets
- // (rgh-4/07) this isn't as much or a problem as it was, because we're now
- // using blockSignals() to keep from triggering that signal when we call
- // 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(displayGB, SIGNAL(clicked(bool)), this, SLOT(change_adaptor()));
+ connect(darkModeCB, SIGNAL(clicked(bool)), this, SLOT(change_adaptor()));
connect(displayscale, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
connect(groupCO, SIGNAL(currentIndexChanged(int)),
this, SLOT(changeGroup(int)));
- displayscale->setValidator(new QIntValidator(displayscale));
+ displayscale->setValidator(new QIntValidator(1, 1000, displayscale));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
bc().addReadOnly(draftCB);
bc().addReadOnly(clip);
bc().addReadOnly(displayGB);
+ bc().addReadOnly(darkModeCB);
bc().addReadOnly(sizeGB);
bc().addReadOnly(rotationGB);
bc().addReadOnly(latexoptions);
bc().addReadOnly(getPB);
bc().addReadOnly(rotateOrderCB);
- // initialize the length validator
+ // Add validated widgets to those that will be
+ // visually marked if invalid
bc().addCheckedLineEdit(Scale, scaleCB);
bc().addCheckedLineEdit(Width, WidthCB);
bc().addCheckedLineEdit(Height, HeightCB);
- bc().addCheckedLineEdit(displayscale, scaleLA);
bc().addCheckedLineEdit(angle, angleL);
+ bc().addCheckedLineEdit(filename, filenameL);
+ bc().addCheckedLineEdit(displayscale, scaleLA);
bc().addCheckedLineEdit(lbX, xL);
bc().addCheckedLineEdit(lbY, yL);
bc().addCheckedLineEdit(rtX, xL_2);
bc().addCheckedLineEdit(rtY, yL_2);
- bc().addCheckedLineEdit(filename, filenameL);
+
+ // We also mark the tabs the widgets are in
+ int tabindex = tabWidget->indexOf(Graphics);
+ bc().addCheckedLineEdit(Scale, tabWidget, tabindex);
+ bc().addCheckedLineEdit(Width, tabWidget, tabindex);
+ bc().addCheckedLineEdit(Height, tabWidget, tabindex);
+ bc().addCheckedLineEdit(angle, tabWidget, tabindex);
+ bc().addCheckedLineEdit(filename, tabWidget, tabindex);
+ bc().addCheckedLineEdit(displayscale, tabWidget, tabWidget->indexOf(ExtraOptions));
+ tabindex = tabWidget->indexOf(Clipping);
+ bc().addCheckedLineEdit(lbX, tabWidget, tabindex);
+ bc().addCheckedLineEdit(lbY, tabWidget, tabindex);
+ bc().addCheckedLineEdit(rtX, tabWidget, tabindex);
+ bc().addCheckedLineEdit(rtY, tabWidget, tabindex);
}
void GuiGraphics::changeBB()
{
- bbChanged = true;
- LYXERR(Debug::GRAPHICS, "[bb_Changed set to true]");
+ bbChanged = isChangedBB();
+ getPB->setEnabled(bbChanged);
+ LYXERR(Debug::GRAPHICS, "[bb_Changed set to " << bbChanged << "]");
changed();
}
QString const str = browse(filename->text());
if (!str.isEmpty()) {
filename->setText(str);
+ // read in the bb values of the new file
+ // if there was no explicit custom viewport
+ if (!bbChanged)
+ getBB();
changed();
}
}
void GuiGraphics::on_getPB_clicked()
{
getBB();
+ bbChanged = false;
}
if (scaleCB->isChecked())
return;
if (!Scale->isEnabled() && Scale->text() != "100")
- Scale->setText(qt_(autostr));
+ Scale->setText("100");
setAutoTextCB(WidthCB, Width, widthUnit);
setAutoTextCB(HeightCB, Height, heightUnit);
// Update the draft and clip mode
draftCB->setChecked(params.draft);
clip->setChecked(params.clip);
+ darkModeCB->setChecked(params.darkModeSensitive);
displayGB->setChecked(params.display);
displayscale->setText(toqstr(convert<string>(params.lyxscale)));
igp.draft = draftCB->isChecked();
igp.clip = clip->isChecked();
igp.display = displayGB->isChecked();
+ igp.darkModeSensitive = darkModeCB->isChecked();
//the graphics section
if (scaleCB->isChecked() && !Scale->text().isEmpty()) {
}
+bool GuiGraphics::isChangedBB()
+{
+ string const fn = fromqstr(filename->text());
+ if (fn.empty())
+ return false;
+
+ string const bb = readBoundingBox(fn);
+ if (bb.empty())
+ return false;
+
+ // Compare orig bb values with the set ones
+ if (Length(token(bb, ' ', 0) + "bp") !=
+ Length(widgetToDoubleStr(lbX) + fromqstr(lbXunit->currentText())))
+ return true;
+
+ if (Length(token(bb, ' ', 1) + "bp") !=
+ Length(widgetToDoubleStr(lbY) + fromqstr(lbYunit->currentText())))
+ return true;
+
+ if (Length(token(bb, ' ', 2) + "bp") !=
+ Length(widgetToDoubleStr(rtX) + fromqstr(rtXunit->currentText())))
+ return true;
+
+ if (Length(token(bb, ' ', 3) + "bp") !=
+ Length(widgetToDoubleStr(rtY) + fromqstr(rtYunit->currentText())))
+ return true;
+
+ return false;
+}
+
+
bool GuiGraphics::isValid()
{
return !filename->text().isEmpty();
{
FileName const abs_file = support::makeAbsPath(file, fromqstr(bufferFilePath()));
- // try to get it from the file, if possible. Zipped files are
- // unzipped in the readBB_from_PSFile-Function
+ // With (E)PS files, try to get it from the file, if possible.
+ // Zipped files are unzipped in the readBB_from_PSFile-Function
string const bb = graphics::readBB_from_PSFile(abs_file);
if (!bb.empty())
return bb;
- // we don't, so ask the Graphics Cache if it has loaded the file
+ // With other formats, we try to read the file dimensions
int width = 0;
int height = 0;
+ // First ask the Graphics Cache if it has loaded the file
graphics::Cache & gc = graphics::Cache::get();
if (gc.inCache(abs_file)) {
graphics::Image const * image = gc.item(abs_file)->image();
width = image->width();
height = image->height();
}
+ } else {
+ // If not, construct a QImage and get the values from that
+ QImage image(toqstr(abs_file.absoluteFilePath()));
+ if (!image.isNull()) {
+ width = image.width();
+ height = image.height();
+ }
}
return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));