commit 0fc8bd0c5fa1f7c61e3be37fc80235c5d0118ad8
Author: Tommaso Cucinotta <[email protected]>
Date: Sat May 6 09:21:50 2017 +0200
Revert "Create new graphics from within LyX choosing a sample file to copy
from."
This reverts commit 7b6e26ad911db7de329169fcaebe24f19d3b3b17.
---
src/frontends/qt4/GuiGraphics.cpp | 94 ------------------------------------
src/frontends/qt4/GuiGraphics.h | 5 --
src/frontends/qt4/ui/GraphicsUi.ui | 24 +--------
3 files changed, 2 insertions(+), 121 deletions(-)
diff --git a/src/frontends/qt4/GuiGraphics.cpp
b/src/frontends/qt4/GuiGraphics.cpp
index 404df3c..7e4f9ef 100644
--- a/src/frontends/qt4/GuiGraphics.cpp
+++ b/src/frontends/qt4/GuiGraphics.cpp
@@ -24,7 +24,6 @@
#include "LengthCombo.h"
#include "Length.h"
#include "LyXRC.h"
-#include "Format.h"
#include "graphics/epstools.h"
#include "graphics/GraphicsCache.h"
@@ -43,7 +42,6 @@
#include "support/types.h"
#include <QCheckBox>
-#include <QFileDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
@@ -250,13 +248,6 @@ GuiGraphics::GuiGraphics(GuiView & lv)
void GuiGraphics::change_adaptor()
{
changed();
- string const fname = fromqstr(filename->text());
- FileName dest_fname(FileName(fromqstr(bufferFilePath())), fname);
- Format const * fmt =
theFormats().getFormat(theFormats().getFormatFromFile(dest_fname));
- LYXERR(Debug::GRAPHICS, "fmt: " << fmt
- << ", fmt_name: " <<
theFormats().getFormatFromFile(dest_fname));
- editPB->setEnabled(!fname.empty() && !dest_fname.isDirectory() &&
dest_fname.exists());
- chooseSamplePB->setEnabled(!fname.empty() && !dest_fname.isDirectory());
}
@@ -368,91 +359,6 @@ void GuiGraphics::on_browsePB_clicked()
}
-bool GuiGraphics::checkFileExists()
-{
- string const fname = fromqstr(filename->text());
- FileName dest_fname(FileName(fromqstr(bufferFilePath())), fname);
- if (fname.empty() || !dest_fname.exists()) {
- return frontend::Alert::prompt(
- _("Continue?"), bformat(_("File '%1$s' does not exist.
Continue?"), from_utf8(dest_fname.absFileName())),
- 0, 1, _("&Yes"), _("&No")) == 0;
- }
- return true;
-}
-
-
-void GuiGraphics::on_chooseSamplePB_clicked()
-{
- string fname = fromqstr(filename->text());
- FileName dest_fname(FileName(fromqstr(bufferFilePath())), fname);
- string fmt_name = theFormats().getFormatFromFile(FileName(fname));
- string filter("Any file (*.*)");
- if (!fmt_name.empty()) {
- Format const *fmt = theFormats().getFormat(fmt_name);
- filter = to_utf8(fmt->prettyname()) + " Files (*." +
dest_fname.extension() + ")";
- }
- if (fname.empty() || dest_fname.isDirectory()) {
- frontend::Alert::warning(_("Invalid destination file name!"),
_("Invalid destination file name!"));
- return;
- }
-
- QString const samplesDir =
toqstr(addPath(package().user_support().absFileName(), "samples"));
- string sample_name = fromqstr(QFileDialog::getOpenFileName(this,
toqstr("Please, select sample template"), samplesDir, toqstr(filter)));
- if (sample_name.empty())
- // User pressed Cancel
- return;
- FileName sample_fname = FileName(sample_name);
-
- //FileName sample_fname = libFileSearch(toqstr("samples"),
toqstr(sample_name));
- if (sample_fname.isDirectory() || !sample_fname.exists()) {
- frontend::Alert::warning(_("Invalid sample file name"),
_("Invalid sample file name"));
- return;
- }
-
- string sample_fmt_name = theFormats().getFormatFromFile(sample_fname);
- if (fmt_name.empty() && !sample_fmt_name.empty()) {
- fmt_name = sample_fmt_name;
- string ext = theFormats().getFormat(fmt_name)->extension();
- if (!ext.empty()) {
- fname = fname + "." + ext;
- dest_fname.set(FileName(fromqstr(bufferFilePath())),
fname);
- filename->setText(toqstr(fname));
- }
- }
-
- if (fname.empty() || dest_fname.isDirectory()) {
- frontend::Alert::warning(_("Invalid destination file name!"),
_("Cannot copy sample file on an invalid destination file!"));
- return;
- }
-
- if (!dest_fname.exists() || (dest_fname.exists() &&
- frontend::Alert::prompt(
- _("Overwrite?"), bformat(_("File '%1$s' already exists.
Overwrite with sample from template?"), from_utf8(dest_fname.absFileName())),
- 0, 1, _("&Yes"), _("&No")) == 0)) {
- sample_fname.copyTo(dest_fname);
- dest_fname.refresh();
- change_adaptor();
- }
-}
-
-
-void GuiGraphics::on_editPB_clicked()
-{
- string const fname = fromqstr(filename->text());
- FileName dest_fname(FileName(fromqstr(bufferFilePath())), fname);
- string fmt_name = theFormats().getFormatFromFile(FileName(fname));
- if (checkFileExists())
- theFormats().edit(buffer(), dest_fname, fmt_name);
-}
-
-
-void GuiGraphics::on_okPB_clicked()
-{
- if (checkFileExists())
- applyView();
-}
-
-
void GuiGraphics::on_getPB_clicked()
{
getBB();
diff --git a/src/frontends/qt4/GuiGraphics.h b/src/frontends/qt4/GuiGraphics.h
index aeca7e9..6446949 100644
--- a/src/frontends/qt4/GuiGraphics.h
+++ b/src/frontends/qt4/GuiGraphics.h
@@ -43,9 +43,6 @@ private Q_SLOTS:
void on_newGroupPB_clicked();
void on_browsePB_clicked();
void on_getPB_clicked();
- void on_editPB_clicked();
- void on_chooseSamplePB_clicked();
- void on_okPB_clicked();
void on_scaleCB_toggled(bool);
void on_WidthCB_toggled(bool);
void on_HeightCB_toggled(bool);
@@ -77,8 +74,6 @@ private:
std::string readBoundingBox(std::string const & file);
/// test if file exist
bool isFileNameValid(std::string const & fname) const;
- /// Check if file exists, if not, ask whether ok to continue
- bool checkFileExists();
/// Control the bb
bool bbChanged;
diff --git a/src/frontends/qt4/ui/GraphicsUi.ui
b/src/frontends/qt4/ui/GraphicsUi.ui
index a878eca..3942651 100644
--- a/src/frontends/qt4/ui/GraphicsUi.ui
+++ b/src/frontends/qt4/ui/GraphicsUi.ui
@@ -59,7 +59,7 @@
</property>
</widget>
</item>
- <item row="2" column="0" colspan="5" >
+ <item row="1" column="0" colspan="5" >
<widget class="QGroupBox" name="sizeGB" >
<property name="title" >
<string>Output Size</string>
@@ -181,7 +181,7 @@
</layout>
</widget>
</item>
- <item row="3" column="0" colspan="5" >
+ <item row="2" column="0" colspan="5" >
<widget class="QGroupBox" name="rotationGB" >
<property name="title" >
<string>Rotate Graphics</string>
@@ -277,26 +277,6 @@
</property>
</widget>
</item>
- <item row="0" column="4" >
- <widget class="QPushButton" name="editPB" >
- <property name="text" >
- <string>&Edit</string>
- </property>
- <property name="toolTip" >
- <string>Edit in external editor (specify an existing filename
first)</string>
- </property>
- </widget>
- </item>
- <item row="1" column="4" >
- <widget class="QPushButton" name="chooseSamplePB" >
- <property name="text" >
- <string>&New...</string>
- </property>
- <property name="toolTip" >
- <string>Create copying from sample file in <HOME>/.lyx/samples
(specify a valid destination filename first)</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
<widget class="QWidget" name="Clipping" >