}
-QString GuiBibtex::browseBib(QString const & in_name) const
+QString GuiBibtex::browseBib(QString const & in_name)
{
QString const label1 = qt_("D&ocuments");
QString const dir1 = toqstr(lyxrc.document_path);
}
-QString GuiBibtex::browseBst(QString const & in_name) const
+QString GuiBibtex::browseBst(QString const & in_name)
{
QString const label1 = qt_("D&ocuments");
QString const dir1 = toqstr(lyxrc.document_path);
void updateContents() override;
/// Browse for a .bib file
- QString browseBib(QString const & in_name) const;
+ QString browseBib(QString const & in_name);
/// Browse for a .bst file
- QString browseBst(QString const & in_name) const;
+ QString browseBst(QString const & in_name);
/// get the list of bst files
QStringList bibStyles() const;
/// get the list of bib files
}
-QString GuiCompare::browse(QString const & in_name) const
+QString GuiCompare::browse(QString const & in_name)
{
QString const title = qt_("Select document");
void enableControls(bool enable);
/// browse for a file
- QString browse(QString const & in_name) const;
+ QString browse(QString const & in_name);
/// retrieve the buffer from the specified filename
Buffer const * bufferFromFileName(std::string const & file) const;
#include <config.h>
+#include "FileDialog.h"
+#include "GuiApplication.h"
#include "GuiDialog.h"
-
#include "GuiView.h"
#include "qt_helpers.h"
#include "support/debug.h"
+#include "support/filetools.h"
#include <QCloseEvent>
#include <QDialogButtonBox>
setUpdatesEnabled(true);
}
+QString GuiDialog::browseFile(QString const & filename,
+ QString const & title,
+ QStringList const & filters,
+ bool save,
+ QString const & label1,
+ QString const & dir1,
+ QString const & label2,
+ QString const & dir2,
+ QString const & fallback_dir)
+{
+ QString lastPath = ".";
+ if (!filename.isEmpty())
+ lastPath = onlyPath(filename);
+ else if(!fallback_dir.isEmpty())
+ lastPath = fallback_dir;
+
+ FileDialog dlg(title);
+ dlg.setButton1(label1, dir1);
+ dlg.setButton2(label2, dir2);
+
+ FileDialog::Result result;
+
+ if (save)
+ result = dlg.save(lastPath, filters, onlyFileName(filename));
+ else
+ result = dlg.open(lastPath, filters, onlyFileName(filename));
+
+ if (guiApp->platformName() == "cocoa") {
+ QWidget * dialog = asQWidget();
+ dialog->raise();
+ dialog->activateWindow();
+ }
+
+ return result.second;
+}
+
+
+/** Launch a file dialog and return the chosen directory.
+ pathname: a suggested pathname.
+ title: the title of the dialog.
+ dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+*/
+QString GuiDialog::browseDir(QString const & pathname,
+ QString const & title,
+ QString const & label1,
+ QString const & dir1,
+ QString const & label2,
+ QString const & dir2)
+{
+ QString lastPath = ".";
+ if (!pathname.isEmpty())
+ lastPath = onlyPath(pathname);
+
+ FileDialog dlg(title);
+ dlg.setButton1(label1, dir1);
+ dlg.setButton2(label2, dir2);
+
+ FileDialog::Result const result =
+ dlg.opendir(lastPath, onlyFileName(pathname));
+
+ if (guiApp->platformName() == "cocoa") {
+ QWidget * dialog = asQWidget();
+ dialog->raise();
+ dialog->activateWindow();
+ }
+
+ return result.second;
+}
+
+QString GuiDialog::browseRelToParent(
+ QString const & filename,
+ QString const & relpath,
+ QString const & title,
+ QStringList const & filters,
+ bool save,
+ QString const & label1,
+ QString const & dir1,
+ QString const & label2,
+ QString const & dir2)
+{
+ QString const fname = makeAbsPath(filename, relpath);
+
+ QString const outname =
+ browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
+
+ QString const reloutname =
+ toqstr(support::makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
+
+ if (reloutname.startsWith("../"))
+ return outname;
+ else
+ return reloutname;
+}
+
+
+QString GuiDialog::browseRelToSub(
+ QString const & filename,
+ QString const & relpath,
+ QString const & title,
+ QStringList const & filters,
+ bool save,
+ QString const & label1,
+ QString const & dir1,
+ QString const & label2,
+ QString const & dir2)
+{
+ QString const fname = makeAbsPath(filename, relpath);
+
+ QString const outname =
+ browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
+
+ QString const reloutname =
+ toqstr(support::makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
+
+ QString testname = reloutname;
+ testname.remove(QRegularExpression("^(\\.\\./)+"));
+
+ if (testname.contains("/"))
+ return outname;
+ else
+ return reloutname;
+}
+
+
} // namespace frontend
} // namespace lyx
/// Update the display of the dialog whilst it is still visible.
void updateView() override;
+
+ /** Launch a file dialog and return the chosen file.
+ filename: a suggested filename.
+ title: the title of the dialog.
+ filters: *.ps etc.
+ dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+ */
+ QString browseFile(QString const & filename,
+ QString const & title,
+ QStringList const & filters,
+ bool save = false,
+ QString const & label1 = QString(),
+ QString const & dir1 = QString(),
+ QString const & label2 = QString(),
+ QString const & dir2 = QString(),
+ QString const & fallback_dir = QString());
+ /** Launch a file dialog and return the chosen directory.
+ pathname: a suggested pathname.
+ title: the title of the dialog.
+ dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+ */
+ QString browseDir(QString const & pathname,
+ QString const & title,
+ QString const & label1 = QString(),
+ QString const & dir1 = QString(),
+ QString const & label2 = QString(),
+ QString const & dir2 = QString());
+ /** Wrappers around browseFile which try to provide a filename relative to relpath.
+
+ \param title: title for dialog
+
+ \param filters: *.ps, etc
+
+ \param save: whether to save dialog info (current path, etc) for next use.
+
+ The \param labelN and \param dirN arguments provide for extra buttons
+ in the dialog (e.g., "Templates" and a path to that directory).
+
+ The difference between the functions concerns when we think we have a
+ relative path.
+
+ In \c browseRelToParent, we return a relative path only if it IS NOT of
+ the form "../../foo.txt".
+
+ In \c browseRelToSub, we return a relative path only if it IS of the
+ form "../../foo.txt".
+ */
+ QString browseRelToParent(QString const & filename,
+ QString const & relpath,
+ QString const & title,
+ QStringList const & filters,
+ bool save = false,
+ QString const & label1 = QString(),
+ QString const & dir1 = QString(),
+ QString const & label2 = QString(),
+ QString const & dir2 = QString());
+ QString browseRelToSub(QString const & filename,
+ QString const & relpath,
+ QString const & title,
+ QStringList const & filters,
+ bool save = false,
+ QString const & label1 = QString(),
+ QString const & dir1 = QString(),
+ QString const & label2 = QString(),
+ QString const & dir2 = QString());
+
private:
ButtonController bc_;
/// are we updating ?
QString GuiExternal::browse(QString const & input,
- QString const & template_name) const
+ QString const & template_name)
{
QString const title = qt_("Select external file");
QString const bufpath = bufferFilePath();
///
QString browse(QString const & input_file,
- QString const & template_name) const;
+ QString const & template_name);
///
MapType extra_;
}
-QString GuiGraphics::browse(QString const & in_name) const
+QString GuiGraphics::browse(QString const & in_name)
{
QString const title = qt_("Select graphics file");
/// does the bounding box differ from the file?
bool isChangedBB();
/// Browse for a file
- QString browse(QString const &) const;
+ QString browse(QString const &);
/// Read the Bounding Box from a eps or ps-file
std::string readBoundingBox(std::string const & file);
/// test if file exist
}
-QString GuiInclude::browse(QString const & in_name, Type in_type) const
+QString GuiInclude::browse(QString const & in_name, Type in_type)
{
QString const title = qt_("Select document to include");
/// update
void updateContents() override {}
/// Browse for a file
- QString browse(QString const &, Type) const;
+ QString browse(QString const &, Type);
private:
///
using namespace lyx::support::os;
namespace lyx {
-namespace frontend {
-
-/////////////////////////////////////////////////////////////////////
-//
-// Browser Helpers
-//
-/////////////////////////////////////////////////////////////////////
-
-/** Launch a file dialog and return the chosen file.
- filename: a suggested filename.
- title: the title of the dialog.
- filters: *.ps etc.
- dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
-*/
-QString browseFile(QString const & filename,
- QString const & title,
- QStringList const & filters,
- bool save = false,
- QString const & label1 = QString(),
- QString const & dir1 = QString(),
- QString const & label2 = QString(),
- QString const & dir2 = QString(),
- QString const & fallback_dir = QString())
-{
- QString lastPath = ".";
- if (!filename.isEmpty())
- lastPath = onlyPath(filename);
- else if(!fallback_dir.isEmpty())
- lastPath = fallback_dir;
-
- FileDialog dlg(title);
- dlg.setButton1(label1, dir1);
- dlg.setButton2(label2, dir2);
-
- FileDialog::Result result;
-
- if (save)
- result = dlg.save(lastPath, filters, onlyFileName(filename));
- else
- result = dlg.open(lastPath, filters, onlyFileName(filename));
-
- return result.second;
-}
-
-
-/** Launch a file dialog and return the chosen directory.
- pathname: a suggested pathname.
- title: the title of the dialog.
- dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
-*/
-QString browseDir(QString const & pathname,
- QString const & title,
- QString const & label1 = QString(),
- QString const & dir1 = QString(),
- QString const & label2 = QString(),
- QString const & dir2 = QString())
-{
- QString lastPath = ".";
- if (!pathname.isEmpty())
- lastPath = onlyPath(pathname);
-
- FileDialog dlg(title);
- dlg.setButton1(label1, dir1);
- dlg.setButton2(label2, dir2);
-
- FileDialog::Result const result =
- dlg.opendir(lastPath, onlyFileName(pathname));
-
- return result.second;
-}
-
-
-} // namespace frontend
-
-
-QString browseRelToParent(QString const & filename, QString const & relpath,
- QString const & title, QStringList const & filters, bool save,
- QString const & label1, QString const & dir1,
- QString const & label2, QString const & dir2)
-{
- QString const fname = makeAbsPath(filename, relpath);
-
- QString const outname =
- frontend::browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
-
- QString const reloutname =
- toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
-
- if (reloutname.startsWith("../"))
- return outname;
- else
- return reloutname;
-}
-
-
-QString browseRelToSub(QString const & filename, QString const & relpath,
- QString const & title, QStringList const & filters, bool save,
- QString const & label1, QString const & dir1,
- QString const & label2, QString const & dir2)
-{
- QString const fname = makeAbsPath(filename, relpath);
-
- QString const outname =
- frontend::browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
-
- QString const reloutname =
- toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
-
- QString testname = reloutname;
- testname.remove(QRegularExpression("^(\\.\\./)+"));
-
- if (testname.contains("/"))
- return outname;
- else
- return reloutname;
-}
-
-
/////////////////////////////////////////////////////////////////////
//
void PrefPaths::selectExampledir()
{
- QString file = browseDir(internalPath(exampleDirED->text()),
+ QString file = form_->browseDir(internalPath(exampleDirED->text()),
qt_("Select directory for example files"));
if (!file.isEmpty())
exampleDirED->setText(file);
void PrefPaths::selectTemplatedir()
{
- QString file = browseDir(internalPath(templateDirED->text()),
+ QString file = form_->browseDir(internalPath(templateDirED->text()),
qt_("Select a document templates directory"));
if (!file.isEmpty())
templateDirED->setText(file);
void PrefPaths::selectTempdir()
{
- QString file = browseDir(internalPath(tempDirED->text()),
+ QString file = form_->browseDir(internalPath(tempDirED->text()),
qt_("Select a temporary directory"));
if (!file.isEmpty())
tempDirED->setText(file);
void PrefPaths::selectBackupdir()
{
- QString file = browseDir(internalPath(backupDirED->text()),
+ QString file = form_->browseDir(internalPath(backupDirED->text()),
qt_("Select a backups directory"));
if (!file.isEmpty())
backupDirED->setText(file);
void PrefPaths::selectWorkingdir()
{
- QString file = browseDir(internalPath(workingDirED->text()),
+ QString file = form_->browseDir(internalPath(workingDirED->text()),
qt_("Select a document directory"));
if (!file.isEmpty())
workingDirED->setText(file);
void PrefPaths::selectThesaurusdir()
{
- QString file = browseDir(internalPath(thesaurusDirED->text()),
+ QString file = form_->browseDir(internalPath(thesaurusDirED->text()),
qt_("Set the path to the thesaurus dictionaries"));
if (!file.isEmpty())
thesaurusDirED->setText(file);
void PrefPaths::selectHunspelldir()
{
- QString file = browseDir(internalPath(hunspellDirED->text()),
+ QString file = form_->browseDir(internalPath(hunspellDirED->text()),
qt_("Set the path to the Hunspell dictionaries"));
if (!file.isEmpty())
hunspellDirED->setText(file);
guilyxfiles_->passParams(fromqstr(dir));
guilyxfiles_->selectItem(name);
guilyxfiles_->exec();
+
+ if (frontend::guiApp->platformName() == "cocoa") {
+ QWidget * dialog_ = asQWidget();
+ dialog_->raise();
+ dialog_->activateWindow();
+ }
QString const result = uifile_;
QString GuiPreferences::browse(QString const & file,
- QString const & title) const
+ QString const & title)
{
return browseFile(file, title, QStringList(), true);
}
QString browsekbmap(QString const & file);
/// general browse
- QString browse(QString const & file, QString const & title) const;
+ QString browse(QString const & file, QString const & title);
/// set a color
void setColor(ColorCode col, QString const & hex);
QString const & ext = QString(),
support::search_mode mode = support::must_exist);
-/** Wrappers around browseFile which try to provide a filename
- relative to relpath.
-
-\param title: title for dialog
-
-\param filters: *.ps, etc
-
-\param save: whether to save dialog info (current path, etc) for next use.
-
-The \param labelN and \param dirN arguments provide for extra buttons
-in the dialog (e.g., "Templates" and a path to that directory).
-
-The difference between the functions concerns when we think we have a
-relative path.
-
-In \c browseRelToParent, we return a relative path only if it IS NOT of
- the form "../../foo.txt".
-
-In \c browseRelToSub, we return a relative path only if it IS of the
- form "../../foo.txt".
-*/
-QString browseRelToParent(QString const & filename,
- QString const & relpath,
- QString const & title,
- QStringList const & filters,
- bool save = false,
- QString const & label1 = QString(),
- QString const & dir1 = QString(),
- QString const & label2 = QString(),
- QString const & dir2 = QString());
-
-QString browseRelToSub(QString const & filename,
- QString const & relpath,
- QString const & title,
- QStringList const & filters,
- bool save = false,
- QString const & label1 = QString(),
- QString const & dir1 = QString(),
- QString const & label2 = QString(),
- QString const & dir2 = QString());
-
/** Build filelists of all available bst/cls/sty-files. Done through
* kpsewhich and an external script, saved in *Files.lst.
* \param arg: cls, sty, bst, or bib, as required by TeXFiles.py.