X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt%2FGuiGraphics.cpp;h=6801f4c5d009fbb88c3687f435f575bae2f4c1ee;hb=5cb80b867f4a59c3253487652ba74a29ad5b3f0f;hp=aefe3d057ce120d226ef444328ad79b2569f2c3f;hpb=ec722f3a48ee7f1c774ef504862dcea8276373df;p=lyx.git diff --git a/src/frontends/qt/GuiGraphics.cpp b/src/frontends/qt/GuiGraphics.cpp index aefe3d057c..6801f4c5d0 100644 --- a/src/frontends/qt/GuiGraphics.cpp +++ b/src/frontends/qt/GuiGraphics.cpp @@ -201,7 +201,7 @@ GuiGraphics::GuiGraphics(GuiView & lv) 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)); @@ -224,17 +224,32 @@ GuiGraphics::GuiGraphics(GuiView & lv) 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); } @@ -336,8 +351,9 @@ void GuiGraphics::on_newGroupPB_clicked() 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(); } @@ -347,6 +363,10 @@ void GuiGraphics::on_browsePB_clicked() 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(); } } @@ -355,6 +375,7 @@ void GuiGraphics::on_browsePB_clicked() void GuiGraphics::on_getPB_clicked() { getBB(); + bbChanged = false; } @@ -741,6 +762,37 @@ void GuiGraphics::getBB() } +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();