mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
qt filedialog fix
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5652 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0c89888e25
commit
0d5b17b058
@ -857,7 +857,7 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
|
||||
string(AddPath(system_lyxdir, "examples"))));
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.Select(initpath,
|
||||
fileDlg.open(initpath,
|
||||
_("*.lyx| LyX Documents (*.lyx)"));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
|
@ -1,3 +1,9 @@
|
||||
2002-11-17 John Levon <levon@movementarian.org>
|
||||
|
||||
* BufferView_pimpl.C:
|
||||
* lyx_cb.C:
|
||||
* lyxfunc.C: split filedialog into open/save
|
||||
|
||||
2002-11-08 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* undo_funcs.C (textHandleUndo): fixed problems with undo introduced
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-11-17 John Levon <levon@movementarian.org>
|
||||
|
||||
* FileDialog.h: split Select() into open()/save() for
|
||||
benefit of Qt
|
||||
|
||||
2002-11-01 Herbert Voss <voss@perce.de>
|
||||
|
||||
* ControlGraphics.C: "Default" is now a part of the rotate-list
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
/**
|
||||
* Constructs a file dialog attached to LyXView \param lv, with
|
||||
* title \param title. If \param a is \const LFUN_SELECT_FILE_SYNC
|
||||
* then a value will be returned immediately upon performing a Select(),
|
||||
* then a value will be returned immediately upon performing a open(),
|
||||
* otherwise a callback Dispatch() will be invoked with the filename as
|
||||
* argument, of action \param a.
|
||||
*
|
||||
@ -64,7 +64,7 @@ public:
|
||||
~FileDialog();
|
||||
|
||||
/**
|
||||
* Choose a file for selection, starting in directory \param
|
||||
* Choose a file for opening, starting in directory \param
|
||||
* path, with the file selection \param mask. The \param mask
|
||||
* string is of the form :
|
||||
*
|
||||
@ -74,7 +74,20 @@ public:
|
||||
*
|
||||
* FIXME: should support multiple lines of these for different file types.
|
||||
*/
|
||||
Result const Select(string const & path = string(),
|
||||
Result const open(string const & path = string(),
|
||||
string const & mask = string(),
|
||||
string const & suggested = string());
|
||||
|
||||
/**
|
||||
* Choose a file for saving, starting in directory \param
|
||||
* path, with the file selection \param mask. The \param mask
|
||||
* string is of the form :
|
||||
*
|
||||
* <glob to match> | <description>
|
||||
*
|
||||
* for example, "*.ps | PostScript files (*.ps)".
|
||||
*/
|
||||
Result const save(string const & path = string(),
|
||||
string const & mask = string(),
|
||||
string const & suggested = string());
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
2002-11-17 John Levon <levon@movementarian.org>
|
||||
|
||||
* helper_funcs.C and users: specify save/open in file dialog
|
||||
|
||||
2002-11-15 John Levon <levon@movementarian.org>
|
||||
|
||||
* ControlPrefs.h:
|
||||
|
@ -63,7 +63,7 @@ string const ControlBibtex::Browse(string const & in_name,
|
||||
pair<string, string> dir1(_("Documents|#o#O"),
|
||||
string(lyxrc.document_path));
|
||||
return browseRelFile(&lv_, in_name, buffer()->filePath(),
|
||||
title, pattern, dir1);
|
||||
title, pattern, false, dir1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,5 +154,5 @@ string const ControlExternal::Browse(string const & input) const
|
||||
std::pair<string, string> dir1(N_("Documents|#o#O"),
|
||||
string(lyxrc.document_path));
|
||||
|
||||
return browseRelFile(&lv_, input, bufpath, title, pattern, dir1);
|
||||
return browseRelFile(&lv_, input, bufpath, title, pattern, false, dir1);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ string const ControlGraphics::Browse(string const & in_name)
|
||||
pair<string, string> dir2(_("Documents|#o#O"), string(lyxrc.document_path));
|
||||
// Show the file browser dialog
|
||||
return browseRelFile(&lv_, in_name, buffer()->filePath(),
|
||||
title, "*.*", dir1, dir2);
|
||||
title, "*.*", false, dir1, dir2);
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ string const ControlInclude::Browse(string const & in_name, Type in_type)
|
||||
|
||||
string const docpath = OnlyPath(params().masterFilename_);
|
||||
|
||||
return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
|
||||
return browseRelFile(&lv_, in_name, docpath, title, pattern, false, dir1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ string const ControlPrefs::browsebind(string const & file)
|
||||
name = _("User Bind|#U#u");
|
||||
pair<string,string> dir2(name, dir);
|
||||
|
||||
return browseFile(&lv_, file, _("Choose bind file"), "*.bind", dir1, dir2);
|
||||
return browseFile(&lv_, file, _("Choose bind file"), "*.bind", false, dir1, dir2);
|
||||
}
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ string const ControlPrefs::browseUI(string const & file)
|
||||
name = _("User UI|#U#u");
|
||||
pair<string,string> dir2(name, dir);
|
||||
|
||||
return browseFile(&lv_, file, _("Choose UI file"), "*.ui", dir1, dir2);
|
||||
return browseFile(&lv_, file, _("Choose UI file"), "*.ui", false, dir1, dir2);
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ string const ControlPrefs::browsekbmap(string const & file)
|
||||
string const name = _("Key maps|#K#k");
|
||||
pair<string, string> dir1(name, dir);
|
||||
|
||||
return browseFile(&lv_, file, _("Choose keyboard map"), "*.kmap", dir1);
|
||||
return browseFile(&lv_, file, _("Choose keyboard map"), "*.kmap", false, dir1);
|
||||
}
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ string const ControlPrefs::browsedict(string const & file)
|
||||
|
||||
string const ControlPrefs::browse(string const & file, string const & title)
|
||||
{
|
||||
return browseFile(&lv_, file, title, "*");
|
||||
return browseFile(&lv_, file, title, "*", true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,7 +80,7 @@ string const ControlPrint::Browse(string const & in_name)
|
||||
|
||||
// Show the file browser dialog
|
||||
return browseRelFile(&lv_, in_name, buffer()->filePath(),
|
||||
title, pattern);
|
||||
title, pattern, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,6 +32,7 @@ using std::make_pair;
|
||||
string const browseFile(LyXView * lv, string const & filename,
|
||||
string const & title,
|
||||
string const & pattern,
|
||||
bool save,
|
||||
pair<string,string> const & dir1,
|
||||
pair<string,string> const & dir2)
|
||||
{
|
||||
@ -44,8 +45,12 @@ string const browseFile(LyXView * lv, string const & filename,
|
||||
FileDialog::Result result;
|
||||
|
||||
while (true) {
|
||||
result = fileDlg.Select(lastPath, pattern,
|
||||
OnlyFilename(filename));
|
||||
if (save)
|
||||
result = fileDlg.save(lastPath, pattern,
|
||||
OnlyFilename(filename));
|
||||
else
|
||||
result = fileDlg.open(lastPath, pattern,
|
||||
OnlyFilename(filename));
|
||||
|
||||
if (result.second.empty())
|
||||
return result.second;
|
||||
@ -68,12 +73,13 @@ string const browseRelFile(LyXView * lv, string const & filename,
|
||||
string const & refpath,
|
||||
string const & title,
|
||||
string const & pattern,
|
||||
bool save = false,
|
||||
pair<string,string> const & dir1,
|
||||
pair<string,string> const & dir2)
|
||||
{
|
||||
string const fname = MakeAbsPath(filename, refpath);
|
||||
|
||||
string const outname = browseFile(lv, fname, title, pattern,
|
||||
string const outname = browseFile(lv, fname, title, pattern, save,
|
||||
dir1, dir2);
|
||||
string const reloutname = MakeRelPath(outname, refpath);
|
||||
if (prefixIs(reloutname, "../"))
|
||||
|
@ -30,9 +30,10 @@ class LyXView;
|
||||
dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
|
||||
*/
|
||||
string const
|
||||
browseFile(LyXView *lv, string const & filename,
|
||||
browseFile(LyXView * lv, string const & filename,
|
||||
string const & title,
|
||||
string const & pattern,
|
||||
bool save = false,
|
||||
std::pair<string,string> const & dir1 =
|
||||
std::make_pair(string(), string()),
|
||||
std::pair<string,string> const & dir2 =
|
||||
@ -46,10 +47,11 @@ browseFile(LyXView *lv, string const & filename,
|
||||
intended to be useful for insets which encapsulate files/
|
||||
*/
|
||||
string const
|
||||
browseRelFile(LyXView *lv, string const & filename,
|
||||
browseRelFile(LyXView * lv, string const & filename,
|
||||
string const & refpath,
|
||||
string const & title,
|
||||
string const & pattern,
|
||||
bool save = false,
|
||||
std::pair<string,string> const & dir1 =
|
||||
std::make_pair(string(), string()),
|
||||
std::pair<string,string> const & dir2 =
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-11-17 John Levon <levon@movementarian.org>
|
||||
|
||||
* FileDialog.C: split into open/save so open
|
||||
no longer says "Save" !
|
||||
|
||||
2002-11-17 John Levon <levon@movementarian.org>
|
||||
|
||||
* QPrefsDialog.h:
|
||||
|
@ -51,7 +51,7 @@ FileDialog::~FileDialog()
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::Select(string const & path,
|
||||
FileDialog::Result const FileDialog::save(string const & path,
|
||||
string const & mask,
|
||||
string const & suggested)
|
||||
{
|
||||
@ -69,9 +69,33 @@ FileDialog::Result const FileDialog::Select(string const & path,
|
||||
if (!suggested.empty())
|
||||
dlg.setSelection(suggested.c_str());
|
||||
|
||||
// This code relies on DestructiveClose which is broken
|
||||
// in Qt < 3.0.5. So we just don't allow it for now.
|
||||
//if (success_ == LFUN_SELECT_FILE_SYNC) {
|
||||
FileDialog::Result result;
|
||||
lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
|
||||
result.first = FileDialog::Chosen;
|
||||
int res = dlg.exec();
|
||||
lyxerr[Debug::GUI] << "result " << res << endl;
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = string(dlg.selectedFile().data());
|
||||
dlg.hide();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::open(string const & path,
|
||||
string const & mask,
|
||||
string const & suggested)
|
||||
{
|
||||
string filter(mask);
|
||||
if (mask.empty())
|
||||
filter = _("*|All files");
|
||||
|
||||
LyXFileDialog dlg(path, filter, title_, private_->b1, private_->b2);
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << path
|
||||
<< "\", mask \"" << filter
|
||||
<< "\", suggested \"" << suggested << endl;
|
||||
|
||||
if (!suggested.empty())
|
||||
dlg.setSelection(suggested.c_str());
|
||||
|
||||
FileDialog::Result result;
|
||||
lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
|
||||
@ -82,8 +106,4 @@ FileDialog::Result const FileDialog::Select(string const & path,
|
||||
result.second = string(dlg.selectedFile().data());
|
||||
dlg.hide();
|
||||
return result;
|
||||
#if 0
|
||||
dlg->show();
|
||||
return make_pair(FileDialog::Later, string());
|
||||
#endif
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ void QPrefsDialog::switch_converter(int nr)
|
||||
}
|
||||
|
||||
|
||||
// FIXME: we would like to highlight the new entry ... also user must
|
||||
// FIXME: user must
|
||||
// specify unique from/to or it doesn't appear. This is really bad UI
|
||||
void QPrefsDialog::new_converter()
|
||||
{
|
||||
@ -325,6 +325,7 @@ void QPrefsDialog::new_converter()
|
||||
form_->converters_.updateLast(form_->formats_);
|
||||
}
|
||||
updateConverters();
|
||||
convertersModule->convertersLB->setCurrentItem(convertersModule->convertersLB->count() - 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>305</width>
|
||||
<width>301</width>
|
||||
<height>259</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -21,7 +21,7 @@
|
||||
<name>caption</name>
|
||||
<string>Colors</string>
|
||||
</property>
|
||||
<grid>
|
||||
<hbox>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>11</number>
|
||||
@ -30,53 +30,108 @@
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget row="1" column="0" rowspan="2" colspan="1" >
|
||||
<class>QListBox</class>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>New Item</string>
|
||||
<widget>
|
||||
<class>QLayoutWidget</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>Layout2</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>0</number>
|
||||
</property>
|
||||
</item>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>lyxObjectsLB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget>
|
||||
<class>QLabel</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>lyxObjectsLA</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>&Colors</string>
|
||||
</property>
|
||||
<property>
|
||||
<name>buddy</name>
|
||||
<cstring>lyxObjectsLB</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QListBox</class>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>New Item</string>
|
||||
</property>
|
||||
</item>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>lyxObjectsLB</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QLayoutWidget</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>Layout1</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget>
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>colorChangePB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>&Alter ...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property>
|
||||
<name>name</name>
|
||||
<cstring>Spacer3</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>orientation</name>
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>sizeType</name>
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property>
|
||||
<name>sizeHint</name>
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</hbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget row="0" column="0" >
|
||||
<class>QLabel</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>lyxObjectsLA</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>LyX &Objects:</string>
|
||||
</property>
|
||||
<property>
|
||||
<name>buddy</name>
|
||||
<cstring>lyxObjectsLB</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="1" column="1" >
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>colorChangePB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Chan&ge Color...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer row="2" column="1" >
|
||||
<spacer>
|
||||
<property>
|
||||
<name>name</name>
|
||||
<cstring>Spacer6</cstring>
|
||||
<cstring>Spacer2</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>orientation</name>
|
||||
<enum>Vertical</enum>
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>sizeType</name>
|
||||
@ -90,6 +145,6 @@
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</grid>
|
||||
</hbox>
|
||||
</widget>
|
||||
</UI>
|
||||
|
@ -1,3 +1,7 @@
|
||||
2002-11-17 John Levon <levon@movementarian.org>
|
||||
|
||||
* FileDialog.C: open/save name change
|
||||
|
||||
2002-11-15 John Levon <levon@movementarian.org>
|
||||
|
||||
* Dialogs2.C:
|
||||
|
@ -48,7 +48,13 @@ FileDialog::~FileDialog()
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
|
||||
FileDialog::Result const FileDialog::save(string const & path, string const & mask, string const & suggested)
|
||||
{
|
||||
open(path, mask, suggested);
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::open(string const & path, string const & mask, string const & suggested)
|
||||
{
|
||||
string filter = mask;
|
||||
|
||||
@ -60,7 +66,8 @@ FileDialog::Result const FileDialog::Select(string const & path, string const &
|
||||
filter = mask;
|
||||
}
|
||||
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << "\"" << endl;
|
||||
lyxerr[Debug::GUI] << "filedialog open with path \"" << path << "\", mask \""
|
||||
<< filter << "\", suggested \"" << suggested << "\"" << endl;
|
||||
|
||||
// no support for asynchronous selection yet
|
||||
|
||||
|
@ -115,7 +115,7 @@ bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename)
|
||||
fname += ".lyx";
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.Select(OnlyPath(fname),
|
||||
fileDlg.save(OnlyPath(fname),
|
||||
_("*.lyx|LyX Documents (*.lyx)"),
|
||||
OnlyFilename(fname));
|
||||
|
||||
@ -419,7 +419,7 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
|
||||
FileDialog fileDlg(bv->owner(), _("Select file to insert"),
|
||||
(asParagraph) ? LFUN_FILE_INSERT_ASCII_PARA : LFUN_FILE_INSERT_ASCII);
|
||||
|
||||
FileDialog::Result result = fileDlg.Select(bv->owner()->buffer()->filePath());
|
||||
FileDialog::Result result = fileDlg.open(bv->owner()->buffer()->filePath());
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return string();
|
||||
|
@ -1594,7 +1594,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
|
||||
string(lyxrc.template_path)));
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.Select(lyxrc.template_path,
|
||||
fileDlg.open(lyxrc.template_path,
|
||||
_("*.lyx|LyX Documents (*.lyx)"));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
@ -1633,7 +1633,7 @@ void LyXFunc::open(string const & fname)
|
||||
string(AddPath(system_lyxdir, "examples"))));
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.Select(initpath,
|
||||
fileDlg.open(initpath,
|
||||
"*.lyx|LyX Documents (*.lyx)");
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
@ -1722,7 +1722,7 @@ void LyXFunc::doImport(string const & argument)
|
||||
+ "| " + formats.prettyName(format)
|
||||
+ " (*." + formats.extension(format) + ")";
|
||||
|
||||
FileDialog::Result result = fileDlg.Select(initpath,
|
||||
FileDialog::Result result = fileDlg.open(initpath,
|
||||
extension);
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
|
Loading…
Reference in New Issue
Block a user