#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"
#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 <boost/bind.hpp>
-#include <boost/filesystem/operations.hpp>
#include <QCheckBox>
-#include <QCloseEvent>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <cmath>
#include <utility>
-#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
* 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())
lengthCombo->currentLengthItem());
}
-
-
template<class Pair>
vector<typename Pair::first_type> const
getFirst(vector<Pair> const & pr)
return tmp;
}
-GuiGraphics::GuiGraphics(LyXView & lv)
- : GuiDialog(lv, "graphics")
+/// The (tranlated) GUI string and it's LaTeX equivalent.
+typedef pair<docstring, string> RotationOriginPair;
+///
+vector<RotationOriginPair> 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()));
//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()),
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();
}
}
void GuiGraphics::on_filename_textChanged(const QString & filename)
{
editPB->setDisabled(filename.isEmpty());
+ EmbeddedFile file = EmbeddedFile(fromqstr(filename), bufferFilepath());
}
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()) {
{
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
igp.rotateAngle = fromqstr(angle->text());
double rotAngle = convert<double>(igp.rotateAngle);
- if (std::abs(rotAngle) > 360.0) {
+ if (abs(rotAngle) > 360.0) {
rotAngle -= 360.0 * floor(rotAngle / 360.0);
igp.rotateAngle = convert<string>(rotAngle);
}
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);
}
// 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<docstring, docstring> dir1(_("Clipart|#C#c"), from_utf8(clipdir));
- pair<docstring, docstring> 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
graphics::Image const * image = gc.item(abs_file)->image();
if (image) {
- width = image->getWidth();
- height = image->getHeight();
+ width = image->width();
+ height = image->height();
}
}
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));
}
-Dialog * createGuiGraphics(LyXView & lv) { return new GuiGraphics(lv); }
+Dialog * createGuiGraphics(GuiView & lv) { return new GuiGraphics(lv); }
} // namespace frontend