mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 13:48:59 +00:00
Fix problem with edit button.
The previous implementation relied upon the cursor being immediately
in front of the inset. A bad idea.
(cherry picked from commit cf7e32ee8f
)
This commit is contained in:
parent
3a7560dcb0
commit
7f69fb3b3c
@ -15,12 +15,12 @@
|
|||||||
#include "GuiInclude.h"
|
#include "GuiInclude.h"
|
||||||
|
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
#include "BufferList.h"
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LyXRC.h"
|
#include "LyXRC.h"
|
||||||
|
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
#include "LyXRC.h"
|
|
||||||
|
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
@ -28,6 +28,8 @@
|
|||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
|
|
||||||
|
#include "frontends/alert.h"
|
||||||
|
|
||||||
#include "insets/InsetListingsParams.h"
|
#include "insets/InsetListingsParams.h"
|
||||||
#include "insets/InsetInclude.h"
|
#include "insets/InsetInclude.h"
|
||||||
|
|
||||||
@ -291,15 +293,20 @@ void GuiInclude::edit()
|
|||||||
applyView();
|
applyView();
|
||||||
} else
|
} else
|
||||||
hideView();
|
hideView();
|
||||||
dispatch(FuncRequest(LFUN_INSET_EDIT));
|
QString const fname = filenameED->text();
|
||||||
|
string const bpath = buffer().filePath();
|
||||||
|
string const absfname = support::makeAbsPath(fromqstr(fname), bpath).absFileName();
|
||||||
|
// The button is enabled only if the document is already open.
|
||||||
|
// If something goes wrong and it is not, we'll get an error
|
||||||
|
// message from the dispatch. So no need for one here.
|
||||||
|
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, absfname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GuiInclude::isValid()
|
bool GuiInclude::isValid()
|
||||||
{
|
{
|
||||||
QString fname = filenameED->text();
|
QString fname = filenameED->text();
|
||||||
bool fempty = fname.isEmpty();
|
if (fname.isEmpty() || !validate_listings_params().empty()) {
|
||||||
if (fempty || !validate_listings_params().empty()) {
|
|
||||||
editPB->setEnabled(false);
|
editPB->setEnabled(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -311,15 +318,17 @@ bool GuiInclude::isValid()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Do we have a LyX filename?
|
// Do we have a LyX filename?
|
||||||
if (!support::isLyXFileName(fromqstr(fname))) {
|
if (!isLyXFileName(fromqstr(fname))) {
|
||||||
okPB->setText("OK");
|
okPB->setText("OK");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string const bpath = buffer().filePath();
|
string const bpath = buffer().filePath();
|
||||||
QString absfname = makeAbsPath(fname, toqstr(bpath));
|
// Path might be relative to current Buffer, so make absolute
|
||||||
bool const fexists = QFile::exists(absfname);
|
FileName const absfname = support::makeAbsPath(fromqstr(fname), bpath);
|
||||||
okPB->setText(fexists ? "OK" : "Create");
|
// Set OK button text according to whether file already exists
|
||||||
editPB->setEnabled(fexists);
|
okPB->setText(absfname.exists() ? "OK" : "Create");
|
||||||
|
// enable edit button iff file is open in some Buffer
|
||||||
|
editPB->setEnabled(theBufferList().getBuffer(absfname));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,8 @@ What's new
|
|||||||
- Prevent permanent disabling of widgets in Vertical/Horizontal Space dialogs
|
- Prevent permanent disabling of widgets in Vertical/Horizontal Space dialogs
|
||||||
(bug 11952).
|
(bug 11952).
|
||||||
|
|
||||||
|
- Fix behavior of Edit button in Include dialog.
|
||||||
|
|
||||||
|
|
||||||
* INTERNALS
|
* INTERNALS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user