X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiGraphics.cpp;h=b48c2fd06f0c2231cc1d088a744e711538d37165;hb=ba76bf5eb85db5a10839fccee3430d906d3f7b70;hp=30d876ca008f2c04142aefcb40763423eec2fb46;hpb=053e705779cefd93fe5c8048369d65b60d6e5957;p=lyx.git diff --git a/src/frontends/qt4/GuiGraphics.cpp b/src/frontends/qt4/GuiGraphics.cpp index 30d876ca00..b48c2fd06f 100644 --- a/src/frontends/qt4/GuiGraphics.cpp +++ b/src/frontends/qt4/GuiGraphics.cpp @@ -16,16 +16,15 @@ #include "GuiGraphics.h" -#include "debug.h" +#include "support/debug.h" #include "LengthCombo.h" #include "Length.h" #include "LyXRC.h" #include "qt_helpers.h" #include "Validator.h" -#include "frontend_helpers.h" #include "FuncRequest.h" -#include "gettext.h" +#include "support/gettext.h" #include "graphics/GraphicsCache.h" #include "graphics/GraphicsCacheItem.h" @@ -37,7 +36,6 @@ #include "support/FileFilterList.h" #include "support/filetools.h" #include "support/lstrings.h" -#include "support/lyxlib.h" #include "support/os.h" #include "support/Package.h" #include "support/types.h" @@ -45,7 +43,6 @@ #include #include -#include #include #include #include @@ -55,31 +52,12 @@ #include #include -#ifndef CXX_GLOBAL_CSTD -using std::floor; -#endif -using std::find; -using std::vector; -using std::string; -using std::transform; -using std::make_pair; -using std::pair; -using std::vector; +using namespace std; +using namespace lyx::support; namespace lyx { namespace frontend { -using support::addName; -using support::FileFilterList; -using support::FileName; -using support::float_equal; -using support::makeAbsPath; -using support::os::internal_path; -using support::package; -using support::readBB_from_PSFile; -using support::token; - - //FIXME setAutoTextCB should really take an argument, as indicated, that //determines what text is to be written for "auto". But making //that work involves more extensive revisions than we now want @@ -95,7 +73,7 @@ using support::token; * checkbox is unchecked and clearing the line edit if it previously * said "text". */ -void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit, +static void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit, LengthCombo * lengthCombo/*, string text = "auto"*/) { if (!checkBox->isChecked()) @@ -106,8 +84,6 @@ void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit, lengthCombo->currentLengthItem()); } - - template vector const getFirst(vector const & pr) @@ -129,18 +105,17 @@ getSecond(vector const & pr) return tmp; } -/// The (tranlated) GUI std::string and it's LaTeX equivalent. -typedef std::pair RotationOriginPair; +/// The (tranlated) GUI string and it's LaTeX equivalent. +typedef pair RotationOriginPair; /// -std::vector getRotationOriginData(); +vector getRotationOriginData(); -GuiGraphics::GuiGraphics(LyXView & lv) - : GuiDialog(lv, "graphics") +GuiGraphics::GuiGraphics(GuiView & lv) + : GuiDialog(lv, "graphics", qt_("Graphics")) { setupUi(this); - setViewTitle(_("Graphics")); - + //main buttons connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply())); @@ -150,6 +125,8 @@ GuiGraphics::GuiGraphics(LyXView & lv) //graphics pane connect(filename, SIGNAL(textChanged(const QString &)), this, SLOT(change_adaptor())); + connect(embedCB, SIGNAL(toggled(bool)), + this, SLOT(change_adaptor())); connect(WidthCB, SIGNAL( clicked()), this, SLOT(change_adaptor())); connect(HeightCB, SIGNAL( clicked()), @@ -285,24 +262,16 @@ void GuiGraphics::change_adaptor() void GuiGraphics::change_bb() { bbChanged = true; - LYXERR(Debug::GRAPHICS) << "[bb_Changed set to true]\n"; + LYXERR(Debug::GRAPHICS, "[bb_Changed set to true]"); changed(); } -void GuiGraphics::closeEvent(QCloseEvent * e) -{ - slotClose(); - GuiDialog::closeEvent(e); -} - - void GuiGraphics::on_browsePB_clicked() { docstring const str = browse(qstring_to_ucs4(filename->text())); if (!str.empty()) { filename->setText(toqstr(str)); - embedCB->setCheckState(Qt::Unchecked); changed(); } } @@ -323,6 +292,7 @@ void GuiGraphics::on_editPB_clicked() void GuiGraphics::on_filename_textChanged(const QString & filename) { editPB->setDisabled(filename.isEmpty()); + EmbeddedFile file = EmbeddedFile(fromqstr(filename), bufferFilepath()); } @@ -472,7 +442,7 @@ void GuiGraphics::updateContents() string const name = igp.filename.outputFilename(bufferFilepath()); filename->setText(toqstr(name)); - embedCB->setCheckState(igp.filename.embedded() ? Qt::Checked : Qt::Unchecked); + embedCB->setCheckState(igp.filename.embedded() ? Qt::Checked : Qt::Unchecked); // set the bounding box values if (igp.bb.empty()) { @@ -617,8 +587,7 @@ void GuiGraphics::applyView() { InsetGraphicsParams & igp = params_; - igp.filename.set(internal_path(fromqstr(filename->text())), - bufferFilepath()); + igp.filename.set(fromqstr(filename->text()), bufferFilepath()); igp.filename.setEmbed(embedCB->checkState() == Qt::Checked); // the bb section @@ -695,7 +664,7 @@ void GuiGraphics::applyView() igp.rotateAngle = fromqstr(angle->text()); double rotAngle = convert(igp.rotateAngle); - if (std::abs(rotAngle) > 360.0) { + if (abs(rotAngle) > 360.0) { rotAngle -= 360.0 * floor(rotAngle / 360.0); igp.rotateAngle = convert(rotAngle); } @@ -713,22 +682,22 @@ void GuiGraphics::applyView() void GuiGraphics::getBB() { string const fn = fromqstr(filename->text()); - if (!fn.empty()) { - string const bb = readBB(fn); - if (!bb.empty()) { - lbX->setText(toqstr(token(bb, ' ', 0))); - lbY->setText(toqstr(token(bb, ' ', 1))); - rtX->setText(toqstr(token(bb, ' ', 2))); - rtY->setText(toqstr(token(bb, ' ', 3))); - // the default units for the bb values when reading - // it from the file - lbXunit->setCurrentIndex(0); - lbYunit->setCurrentIndex(0); - rtXunit->setCurrentIndex(0); - rtYunit->setCurrentIndex(0); - } - bbChanged = false; - } + if (fn.empty()) + return; + string const bb = readBB(fn); + bbChanged = false; + if (bb.empty()) + return; + lbX->setText(toqstr(token(bb, ' ', 0))); + lbY->setText(toqstr(token(bb, ' ', 1))); + rtX->setText(toqstr(token(bb, ' ', 2))); + rtY->setText(toqstr(token(bb, ' ', 3))); + // the default units for the bb values when reading + // it from the file + lbXunit->setCurrentIndex(0); + lbYunit->setCurrentIndex(0); + rtXunit->setCurrentIndex(0); + rtYunit->setCurrentIndex(0); } @@ -769,7 +738,7 @@ docstring const GuiGraphics::browse(docstring const & in_name) const FileName clip(clipdir); // bail out to system clipart directory - if (!clip.exists() && clip.isDirectory()) + if (!(clip.exists() && clip.isDirectory())) clipdir = addName(package().system_support().absFilename(), "clipart"); return browseRelFile(in_name, from_utf8(bufferFilepath()), @@ -798,8 +767,8 @@ string const GuiGraphics::readBB(string const & file) graphics::Image const * image = gc.item(abs_file)->image(); if (image) { - width = image->getWidth(); - height = image->getHeight(); + width = image->width(); + height = image->height(); } } @@ -810,7 +779,7 @@ string const GuiGraphics::readBB(string const & file) bool GuiGraphics::isFilenameValid(string const & fname) const { // It may be that the filename is relative. - return makeAbsPath(fname, bufferFilepath()).isReadable(); + return makeAbsPath(fname, bufferFilepath()).isReadableFile(); } @@ -873,7 +842,7 @@ vector getRotationOriginData() } -Dialog * createGuiGraphics(LyXView & lv) { return new GuiGraphics(lv); } +Dialog * createGuiGraphics(GuiView & lv) { return new GuiGraphics(lv); } } // namespace frontend