X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiGraphics.cpp;h=b48c2fd06f0c2231cc1d088a744e711538d37165;hb=ba76bf5eb85db5a10839fccee3430d906d3f7b70;hp=fa71db87a87bcfa5d903f5b9483ef01d6849b9c4;hpb=6f3cdf8da80a6b3889f2a3b8b53f44590152d600;p=lyx.git diff --git a/src/frontends/qt4/GuiGraphics.cpp b/src/frontends/qt4/GuiGraphics.cpp index fa71db87a8..b48c2fd06f 100644 --- a/src/frontends/qt4/GuiGraphics.cpp +++ b/src/frontends/qt4/GuiGraphics.cpp @@ -16,17 +16,15 @@ #include "GuiGraphics.h" -#include "GuiGraphics.h" -#include "debug.h" +#include "support/debug.h" #include "LengthCombo.h" -#include "lengthcommon.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" @@ -38,16 +36,13 @@ #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" #include -#include #include -#include #include #include #include @@ -57,34 +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; - -namespace fs = boost::filesystem; +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::isFileReadable; -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 @@ -100,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()) @@ -111,8 +84,6 @@ void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit, lengthCombo->currentLengthItem()); } - - template vector const getFirst(vector const & pr) @@ -134,12 +105,17 @@ getSecond(vector const & pr) return tmp; } -GuiGraphics::GuiGraphics(LyXView & lv) - : GuiDialog(lv, "graphics") +/// The (tranlated) GUI string and it's LaTeX equivalent. +typedef pair RotationOriginPair; +/// +vector getRotationOriginData(); + + +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())); @@ -149,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()), @@ -284,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(); } } @@ -322,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()); } @@ -471,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()) { @@ -616,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 @@ -694,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); } @@ -712,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); } @@ -765,21 +735,22 @@ docstring const GuiGraphics::browse(docstring const & in_name) const // Does user clipart directory exist? string clipdir = addName(package().user_support().absFilename(), "clipart"); - string const encoded_clipdir = FileName(clipdir).toFilesystemEncoding(); - if (!(fs::exists(encoded_clipdir) && fs::is_directory(encoded_clipdir))) - // No - bail out to system clipart directory + FileName clip(clipdir); + + // bail out to system clipart directory + if (!(clip.exists() && clip.isDirectory())) clipdir = addName(package().system_support().absFilename(), "clipart"); - pair dir1(_("Clipart|#C#c"), from_utf8(clipdir)); - pair dir2(_("Documents|#o#O"), from_utf8(lyxrc.document_path)); - // Show the file browser dialog + return browseRelFile(in_name, from_utf8(bufferFilepath()), - title, FileFilterList(), false, dir1, dir2); + title, FileFilterList(), false, + _("Clipart|#C#c"), from_utf8(clipdir), + _("Documents|#o#O"), from_utf8(lyxrc.document_path)); } string const GuiGraphics::readBB(string const & file) { - FileName const abs_file(makeAbsPath(file, bufferFilepath())); + FileName const abs_file = makeAbsPath(file, bufferFilepath()); // try to get it from the file, if possible. Zipped files are // unzipped in the readBB_from_PSFile-Function @@ -796,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(); } } @@ -808,14 +779,13 @@ string const GuiGraphics::readBB(string const & file) bool GuiGraphics::isFilenameValid(string const & fname) const { // It may be that the filename is relative. - FileName const name(makeAbsPath(fname, bufferFilepath())); - return isFileReadable(name); + return makeAbsPath(fname, bufferFilepath()).isReadableFile(); } void GuiGraphics::editGraphics() { - dialog().applyView(); + applyView(); string const lfun = InsetGraphicsMailer::params2string(params_, buffer()); dispatch(FuncRequest(LFUN_GRAPHICS_EDIT, lfun)); @@ -872,7 +842,7 @@ vector getRotationOriginData() } -Dialog * createGuiGraphics(LyXView & lv) { return new GuiGraphics(lv); } +Dialog * createGuiGraphics(GuiView & lv) { return new GuiGraphics(lv); } } // namespace frontend