mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
a few more docstring<->QString conversions
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23493 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
32a3ce2546
commit
88293cbcfb
@ -57,7 +57,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
FileDialog::FileDialog(docstring const & t, kb_action s)
|
||||
FileDialog::FileDialog(QString const & t, kb_action s)
|
||||
: private_(new FileDialog::Private), title_(t), success_(s)
|
||||
{}
|
||||
|
||||
@ -68,32 +68,32 @@ FileDialog::~FileDialog()
|
||||
}
|
||||
|
||||
|
||||
void FileDialog::setButton1(docstring const & label, docstring const & dir)
|
||||
void FileDialog::setButton1(QString const & label, QString const & dir)
|
||||
{
|
||||
private_->b1.first = label;
|
||||
private_->b1.second = dir;
|
||||
}
|
||||
|
||||
|
||||
void FileDialog::setButton2(docstring const & label, docstring const & dir)
|
||||
void FileDialog::setButton2(QString const & label, QString const & dir)
|
||||
{
|
||||
private_->b2.first = label;
|
||||
private_->b2.second = dir;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::save(docstring const & path,
|
||||
FileDialog::Result FileDialog::save(QString const & path,
|
||||
FileFilterList const & filters,
|
||||
docstring const & suggested)
|
||||
QString const & suggested)
|
||||
{
|
||||
LYXERR(Debug::GUI, "Select with path \"" << to_utf8(path)
|
||||
LYXERR(Debug::GUI, "Select with path \"" << fromqstr(path)
|
||||
<< "\", mask \"" << to_utf8(filters.as_string())
|
||||
<< "\", suggested \"" << to_utf8(suggested) << '"');
|
||||
<< "\", suggested \"" << fromqstr(suggested) << '"');
|
||||
FileDialog::Result result;
|
||||
result.first = FileDialog::Chosen;
|
||||
|
||||
#ifdef USE_NATIVE_FILEDIALOG
|
||||
docstring const startsWith = from_utf8(
|
||||
QString const startsWith = from_utf8(
|
||||
makeAbsPath(to_utf8(suggested), to_utf8(path)).absFilename());
|
||||
QString const name =
|
||||
QFileDialog::getSaveFileName(qApp->focusWidget(),
|
||||
@ -111,66 +111,64 @@ FileDialog::Result const FileDialog::save(docstring const & path,
|
||||
dlg.setAcceptMode(QFileDialog::AcceptSave);
|
||||
dlg.setConfirmOverwrite(false);
|
||||
|
||||
if (!suggested.empty())
|
||||
dlg.selectFile(toqstr(suggested));
|
||||
if (!suggested.isEmpty())
|
||||
dlg.selectFile(suggested);
|
||||
|
||||
LYXERR(Debug::GUI, "Synchronous FileDialog: ");
|
||||
int res = dlg.exec();
|
||||
LYXERR(Debug::GUI, "result " << res);
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = from_utf8(internal_path(
|
||||
fromqstr(dlg.selectedFiles()[0])));
|
||||
result.second = internalPath(dlg.selectedFiles()[0]);
|
||||
dlg.hide();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::open(docstring const & path,
|
||||
FileDialog::Result FileDialog::open(QString const & path,
|
||||
FileFilterList const & filters,
|
||||
docstring const & suggested)
|
||||
QString const & suggested)
|
||||
{
|
||||
LYXERR(Debug::GUI, "Select with path \"" << to_utf8(path)
|
||||
<< "\", mask \"" << to_utf8(filters.as_string())
|
||||
<< "\", suggested \"" << to_utf8(suggested) << '"');
|
||||
LYXERR(Debug::GUI, "Select with path \"" << fromqstr(path)
|
||||
<< "\", mask \"" << filters.as_string()
|
||||
<< "\", suggested \"" << fromqstr(suggested) << '"');
|
||||
FileDialog::Result result;
|
||||
result.first = FileDialog::Chosen;
|
||||
|
||||
#ifdef USE_NATIVE_FILEDIALOG
|
||||
docstring const startsWith = from_utf8(
|
||||
makeAbsPath(to_utf8(suggested), to_utf8(path)).absFilename());
|
||||
result.second = from_utf8(internal_path(fromqstr(
|
||||
QString const startsWith = toqstr(
|
||||
makeAbsPath(fromqstr(suggested), fromqstr(path)).absFilename());
|
||||
result.second = internalPath(
|
||||
QFileDialog::getOpenFileName(qApp->focusWidget(),
|
||||
toqstr(title_), toqstr(startsWith), toqstr(filters.as_string()) ))));
|
||||
toqstr(title_), toqstr(startsWith), toqstr(filters.as_string()) ));
|
||||
#else
|
||||
LyXFileDialog dlg(title_, path, filters, private_->b1, private_->b2);
|
||||
|
||||
if (!suggested.empty())
|
||||
dlg.selectFile(toqstr(suggested));
|
||||
if (!suggested.isEmpty())
|
||||
dlg.selectFile(suggested);
|
||||
|
||||
LYXERR(Debug::GUI, "Synchronous FileDialog: ");
|
||||
int res = dlg.exec();
|
||||
LYXERR(Debug::GUI, "result " << res);
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = from_utf8(internal_path(
|
||||
fromqstr(dlg.selectedFiles()[0])));
|
||||
result.second = internalPath(dlg.selectedFiles()[0]);
|
||||
dlg.hide();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::opendir(docstring const & path,
|
||||
docstring const & suggested)
|
||||
FileDialog::Result FileDialog::opendir(QString const & path,
|
||||
QString const & suggested)
|
||||
{
|
||||
LYXERR(Debug::GUI, "Select with path \"" << to_utf8(path)
|
||||
<< "\", suggested \"" << to_utf8(suggested) << '"');
|
||||
LYXERR(Debug::GUI, "Select with path \"" << fromqstr(path)
|
||||
<< "\", suggested \"" << fromqstr(suggested) << '"');
|
||||
FileDialog::Result result;
|
||||
result.first = FileDialog::Chosen;
|
||||
|
||||
#ifdef USE_NATIVE_FILEDIALOG
|
||||
docstring const startsWith = from_utf8(
|
||||
makeAbsPath(to_utf8(suggested), to_utf8(path)).absFilename());
|
||||
QString const startsWith = toqstr(
|
||||
makeAbsPath(fromqstr(suggested), fromqstr(path)).absFilename());
|
||||
result.second = from_utf8(internal_path(fromqstr(
|
||||
QFileDialog::getExistingDirectory(qApp->focusWidget(),
|
||||
toqstr(title_),toqstr(startsWith)))));
|
||||
@ -181,15 +179,14 @@ FileDialog::Result const FileDialog::opendir(docstring const & path,
|
||||
|
||||
dlg.setFileMode(QFileDialog::DirectoryOnly);
|
||||
|
||||
if (!suggested.empty())
|
||||
dlg.selectFile(toqstr(suggested));
|
||||
if (!suggested.isEmpty())
|
||||
dlg.selectFile(suggested);
|
||||
|
||||
LYXERR(Debug::GUI, "Synchronous FileDialog: ");
|
||||
int res = dlg.exec();
|
||||
LYXERR(Debug::GUI, "result " << res);
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = from_utf8(internal_path(
|
||||
fromqstr(dlg.selectedFiles()[0])));
|
||||
result.second = internalPath(dlg.selectedFiles()[0]);
|
||||
dlg.hide();
|
||||
#endif
|
||||
return result;
|
||||
|
@ -14,10 +14,10 @@
|
||||
#define FILEDIALOG_H
|
||||
|
||||
#include "lfuns.h"
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <string>
|
||||
#include <QString>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace lyx {
|
||||
|
||||
@ -32,7 +32,7 @@ class FileDialog
|
||||
{
|
||||
public:
|
||||
/// label, directory path button
|
||||
typedef std::pair<docstring, docstring> Button;
|
||||
typedef std::pair<QString, QString> Button;
|
||||
|
||||
/// result type
|
||||
enum ResultType {
|
||||
@ -41,7 +41,7 @@ public:
|
||||
};
|
||||
|
||||
/// result return
|
||||
typedef std::pair<FileDialog::ResultType, docstring> Result;
|
||||
typedef std::pair<FileDialog::ResultType, QString> Result;
|
||||
|
||||
/**
|
||||
* Constructs a file dialog with title \param title.
|
||||
@ -54,26 +54,26 @@ public:
|
||||
* additional directories in the navigation (an empty
|
||||
* directory is interpreted as FileName::getcwd())
|
||||
*/
|
||||
FileDialog(docstring const & title, kb_action a = LFUN_SELECT_FILE_SYNC);
|
||||
FileDialog(QString const & title, kb_action a = LFUN_SELECT_FILE_SYNC);
|
||||
|
||||
~FileDialog();
|
||||
|
||||
void setButton1(docstring const & label, docstring const & dir);
|
||||
void setButton2(docstring const & label, docstring const & dir);
|
||||
void setButton1(QString const & label, QString const & dir);
|
||||
void setButton2(QString const & label, QString const & dir);
|
||||
|
||||
/// Choose a file for opening, starting in directory \c path.
|
||||
Result const open(docstring const & path,
|
||||
Result open(QString const & path,
|
||||
support::FileFilterList const & filters,
|
||||
docstring const & suggested);
|
||||
QString const & suggested = QString());
|
||||
|
||||
/// Choose a directory, starting in directory \c path.
|
||||
Result const opendir(docstring const & path = docstring(),
|
||||
docstring const & suggested = docstring());
|
||||
Result opendir(QString const & path = QString(),
|
||||
QString const & suggested = QString());
|
||||
|
||||
/// Choose a file for saving, starting in directory \c path.
|
||||
Result const save(docstring const & path,
|
||||
Result save(QString const & path,
|
||||
support::FileFilterList const & filters,
|
||||
docstring const & suggested);
|
||||
QString const & suggested = QString());
|
||||
|
||||
private:
|
||||
class Private;
|
||||
@ -81,7 +81,7 @@ private:
|
||||
Private * private_;
|
||||
|
||||
/// the dialog title
|
||||
docstring title_;
|
||||
QString title_;
|
||||
|
||||
/// success action to perform if not synchronous
|
||||
kb_action success_;
|
||||
|
@ -461,9 +461,8 @@ void GuiBibtex::getBibStyles(vector<string> & data) const
|
||||
}
|
||||
vector<string>::iterator it = data.begin();
|
||||
vector<string>::iterator end = data.end();
|
||||
for (; it != end; ++it) {
|
||||
*it = onlyFilename(*it);
|
||||
}
|
||||
for (; it != end; ++it)
|
||||
*it = support::onlyFilename(*it);
|
||||
// sort on filename only (no path)
|
||||
sort(data.begin(), data.end());
|
||||
}
|
||||
@ -481,9 +480,8 @@ void GuiBibtex::getBibFiles(vector<string> & data) const
|
||||
}
|
||||
vector<string>::iterator it = data.begin();
|
||||
vector<string>::iterator end = data.end();
|
||||
for (; it != end; ++it) {
|
||||
*it = onlyFilename(*it);
|
||||
}
|
||||
for (; it != end; ++it)
|
||||
*it = support::onlyFilename(*it);
|
||||
// sort on filename only (no path)
|
||||
sort(data.begin(), data.end());
|
||||
}
|
||||
|
@ -232,15 +232,15 @@ FileName GuiClipboard::getPastedGraphicsFileName(Cursor const & cur,
|
||||
FileFilterList const filter(filterSpec);
|
||||
|
||||
// show save dialog for the graphic
|
||||
FileDialog dlg(_("Choose a filename to save the pasted graphic as"));
|
||||
FileDialog dlg(qt_("Choose a filename to save the pasted graphic as"));
|
||||
FileDialog::Result result =
|
||||
dlg.save(from_utf8(filename.onlyPath().absFilename()), filter,
|
||||
from_utf8(filename.onlyFileName()));
|
||||
dlg.save(toqstr(filename.onlyPath().absFilename()), filter,
|
||||
toqstr(filename.onlyFileName()));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return FileName();
|
||||
|
||||
string newFilename = to_utf8(result.second);
|
||||
string newFilename = fromqstr(result.second);
|
||||
if (newFilename.empty()) {
|
||||
cur.bv().message(_("Canceled."));
|
||||
return FileName();
|
||||
|
@ -321,7 +321,7 @@ docstring GuiInclude::browse(docstring const & in_name, Type in_type) const
|
||||
break;
|
||||
}
|
||||
|
||||
docstring const docpath = from_utf8(onlyPath(buffer().absFileName()));
|
||||
docstring const docpath = from_utf8(support::onlyPath(buffer().absFileName()));
|
||||
|
||||
return browseRelFile(in_name, docpath, title, filters, false,
|
||||
_("Documents|#o#O"), from_utf8(lyxrc.document_path));
|
||||
@ -336,7 +336,7 @@ void GuiInclude::edit(string const & file)
|
||||
else
|
||||
// tex file or other text file in verbatim mode
|
||||
formats.edit(buffer(),
|
||||
makeAbsPath(file, onlyPath(buffer().absFileName())),
|
||||
makeAbsPath(file, support::onlyPath(buffer().absFileName())),
|
||||
"text");
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "BufferList.h"
|
||||
#include "Color.h"
|
||||
#include "ConverterCache.h"
|
||||
#include "FileDialog.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "GuiFontExample.h"
|
||||
#include "GuiKeySymbol.h"
|
||||
@ -70,6 +71,154 @@ using namespace lyx::support::os;
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Browser Helpers
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
FileName libFileSearch(QString const & dir, QString const & name,
|
||||
QString const & ext = QString())
|
||||
{
|
||||
return support::libFileSearch(fromqstr(dir), fromqstr(name), fromqstr(ext));
|
||||
}
|
||||
|
||||
|
||||
/** Launch a file dialog and return the chosen file.
|
||||
filename: a suggested filename.
|
||||
title: the title of the dialog.
|
||||
pattern: *.ps etc.
|
||||
dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
|
||||
*/
|
||||
QString browseFile(QString const & filename,
|
||||
QString const & title,
|
||||
support::FileFilterList const & filters,
|
||||
bool save = false,
|
||||
QString const & label1 = QString(),
|
||||
QString const & dir1 = QString(),
|
||||
QString const & label2 = QString(),
|
||||
QString const & dir2 = QString())
|
||||
{
|
||||
QString lastPath = ".";
|
||||
if (!filename.isEmpty())
|
||||
lastPath = onlyPath(filename);
|
||||
|
||||
FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
|
||||
dlg.setButton2(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;
|
||||
}
|
||||
|
||||
|
||||
/** Wrapper around browseFile which tries to provide a filename
|
||||
* relative to the user or system directory. The dir, name and ext
|
||||
* parameters have the same meaning as in the
|
||||
* support::LibFileSearch function.
|
||||
*/
|
||||
QString browseLibFile(QString const & dir,
|
||||
QString const & name,
|
||||
QString const & ext,
|
||||
QString const & title,
|
||||
support::FileFilterList const & filters)
|
||||
{
|
||||
// FIXME UNICODE
|
||||
QString const label1 = qt_("System files|#S#s");
|
||||
QString const dir1 =
|
||||
toqstr(addName(package().system_support().absFilename(), fromqstr(dir)));
|
||||
|
||||
QString const label2 = qt_("User files|#U#u");
|
||||
QString const dir2 =
|
||||
toqstr(addName(package().user_support().absFilename(), fromqstr(dir)));
|
||||
|
||||
QString const result = browseFile(toqstr(
|
||||
libFileSearch(dir, name, ext).absFilename()),
|
||||
title, filters, false, dir1, dir2);
|
||||
|
||||
// remove the extension if it is the default one
|
||||
QString noextresult;
|
||||
if (toqstr(getExtension(fromqstr(result))) == ext)
|
||||
noextresult = toqstr(removeExtension(fromqstr(result)));
|
||||
else
|
||||
noextresult = result;
|
||||
|
||||
// remove the directory, if it is the default one
|
||||
QString const file = onlyFilename(noextresult);
|
||||
if (toqstr(libFileSearch(dir, file, ext).absFilename()) == result)
|
||||
return file;
|
||||
else
|
||||
return noextresult;
|
||||
}
|
||||
|
||||
|
||||
/** 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, LFUN_SELECT_FILE_SYNC);
|
||||
dlg.setButton1(label1, dir1);
|
||||
dlg.setButton2(label2, dir2);
|
||||
|
||||
FileDialog::Result const result =
|
||||
dlg.opendir(lastPath, onlyFilename(pathname));
|
||||
|
||||
return result.second;
|
||||
}
|
||||
|
||||
|
||||
QString browseRelFile(QString const & filename, QString const & refpath,
|
||||
QString const & title, FileFilterList const & filters, bool save,
|
||||
QString const & label1, QString const & dir1,
|
||||
QString const & label2, QString const & dir2)
|
||||
{
|
||||
QString const fname = toqstr(makeAbsPath(
|
||||
fromqstr(filename), fromqstr(refpath)).absFilename());
|
||||
|
||||
QString const outname =
|
||||
browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
|
||||
|
||||
QString const reloutname =
|
||||
toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(refpath)));
|
||||
|
||||
if (reloutname.startsWith("../"))
|
||||
return outname;
|
||||
else
|
||||
return reloutname;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
|
||||
docstring browseRelFile(docstring const & filename, docstring const & refpath,
|
||||
docstring const & title, FileFilterList const & filters, bool save,
|
||||
docstring const & label1, docstring const & dir1,
|
||||
docstring const & label2, docstring const & dir2)
|
||||
{
|
||||
return qstring_to_ucs4(frontend::browseRelFile(
|
||||
toqstr(filename), toqstr(refpath),
|
||||
toqstr(title), filters, save,
|
||||
toqstr(label1), toqstr(dir1),
|
||||
toqstr(label2), toqstr(dir2)));
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -77,6 +226,8 @@ namespace frontend {
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace frontend {
|
||||
|
||||
template<class A>
|
||||
static size_t findPos_helper(vector<A> const & vec, A const & val)
|
||||
{
|
||||
@ -111,7 +262,7 @@ static void setComboxFont(QComboBox * cb, string const & family,
|
||||
if (!foundry.empty())
|
||||
fontname += " [" + toqstr(foundry) + ']';
|
||||
|
||||
for (int i = 0; i < cb->count(); ++i) {
|
||||
for (int i = 0; i != cb->count(); ++i) {
|
||||
if (cb->itemText(i) == fontname) {
|
||||
cb->setCurrentIndex(i);
|
||||
return;
|
||||
@ -192,7 +343,7 @@ static void setComboxFont(QComboBox * cb, string const & family,
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefPlaintext::PrefPlaintext(QWidget * parent)
|
||||
: PrefModule(_("Plain text"), 0, parent)
|
||||
: PrefModule(qt_("Plain text"), 0, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
|
||||
@ -223,7 +374,7 @@ void PrefPlaintext::update(LyXRC const & rc)
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefDate::PrefDate(QWidget * parent)
|
||||
: PrefModule(_("Date format"), 0, parent)
|
||||
: PrefModule(qt_("Date format"), 0, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
connect(DateED, SIGNAL(textChanged(QString)),
|
||||
@ -250,7 +401,7 @@ void PrefDate::update(LyXRC const & rc)
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefInput::PrefInput(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule(_("Keyboard/Mouse"), form, parent)
|
||||
: PrefModule(qt_("Keyboard/Mouse"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -320,7 +471,7 @@ void PrefInput::update(LyXRC const & rc)
|
||||
|
||||
QString PrefInput::testKeymap(QString keymap)
|
||||
{
|
||||
return toqstr(form_->browsekbmap(from_utf8(internal_path(fromqstr(keymap)))));
|
||||
return form_->browsekbmap(toqstr(internal_path(fromqstr(keymap))));
|
||||
}
|
||||
|
||||
|
||||
@ -358,7 +509,7 @@ void PrefInput::on_keymapCB_toggled(bool keymap)
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefLatex::PrefLatex(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule(_("LaTeX"), form, parent)
|
||||
: PrefModule(qt_("LaTeX"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
connect(latexEncodingED, SIGNAL(textChanged(QString)),
|
||||
@ -425,7 +576,7 @@ void PrefLatex::update(LyXRC const & rc)
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefScreenFonts::PrefScreenFonts(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule(_("Screen fonts"), form, parent)
|
||||
: PrefModule(qt_("Screen fonts"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -599,7 +750,7 @@ struct ColorSorter
|
||||
} // namespace anon
|
||||
|
||||
PrefColors::PrefColors(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule( _("Colors"), form, parent)
|
||||
: PrefModule(qt_("Colors"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -697,7 +848,7 @@ void PrefColors::change_lyxObjects_selection()
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefDisplay::PrefDisplay(QWidget * parent)
|
||||
: PrefModule(_("Graphics"), 0, parent)
|
||||
: PrefModule(qt_("Graphics"), 0, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
connect(instantPreviewCO, SIGNAL(activated(int)),
|
||||
@ -768,7 +919,7 @@ void PrefDisplay::update(LyXRC const & rc)
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefPaths::PrefPaths(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule(_("Paths"), form, parent)
|
||||
: PrefModule(qt_("Paths"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
connect(exampleDirPB, SIGNAL(clicked()), this, SLOT(select_exampledir()));
|
||||
@ -822,61 +973,55 @@ void PrefPaths::update(LyXRC const & rc)
|
||||
|
||||
void PrefPaths::select_exampledir()
|
||||
{
|
||||
docstring file(form_->browsedir(
|
||||
from_utf8(internal_path(fromqstr(exampleDirED->text()))),
|
||||
_("Select directory for example files")));
|
||||
if (!file.empty())
|
||||
exampleDirED->setText(toqstr(file));
|
||||
QString file = form_->browsedir(internalPath(exampleDirED->text()),
|
||||
qt_("Select directory for example files"));
|
||||
if (!file.isEmpty())
|
||||
exampleDirED->setText(file);
|
||||
}
|
||||
|
||||
|
||||
void PrefPaths::select_templatedir()
|
||||
{
|
||||
docstring file(form_->browsedir(
|
||||
from_utf8(internal_path(fromqstr(templateDirED->text()))),
|
||||
_("Select a document templates directory")));
|
||||
if (!file.empty())
|
||||
templateDirED->setText(toqstr(file));
|
||||
QString file = form_->browsedir(internalPath(templateDirED->text()),
|
||||
qt_("Select a document templates directory"));
|
||||
if (!file.isEmpty())
|
||||
templateDirED->setText(file);
|
||||
}
|
||||
|
||||
|
||||
void PrefPaths::select_tempdir()
|
||||
{
|
||||
docstring file(form_->browsedir(
|
||||
from_utf8(internal_path(fromqstr(tempDirED->text()))),
|
||||
_("Select a temporary directory")));
|
||||
if (!file.empty())
|
||||
tempDirED->setText(toqstr(file));
|
||||
QString file = form_->browsedir(internalPath(tempDirED->text()),
|
||||
qt_("Select a temporary directory"));
|
||||
if (!file.isEmpty())
|
||||
tempDirED->setText(file);
|
||||
}
|
||||
|
||||
|
||||
void PrefPaths::select_backupdir()
|
||||
{
|
||||
docstring file(form_->browsedir(
|
||||
from_utf8(internal_path(fromqstr(backupDirED->text()))),
|
||||
_("Select a backups directory")));
|
||||
if (!file.empty())
|
||||
backupDirED->setText(toqstr(file));
|
||||
QString file = form_->browsedir(internalPath(backupDirED->text()),
|
||||
qt_("Select a backups directory"));
|
||||
if (!file.isEmpty())
|
||||
backupDirED->setText(file);
|
||||
}
|
||||
|
||||
|
||||
void PrefPaths::select_workingdir()
|
||||
{
|
||||
docstring file(form_->browsedir(
|
||||
from_utf8(internal_path(fromqstr(workingDirED->text()))),
|
||||
_("Select a document directory")));
|
||||
if (!file.empty())
|
||||
workingDirED->setText(toqstr(file));
|
||||
QString file = form_->browsedir(internalPath(workingDirED->text()),
|
||||
qt_("Select a document directory"));
|
||||
if (!file.isEmpty())
|
||||
workingDirED->setText(file);
|
||||
}
|
||||
|
||||
|
||||
void PrefPaths::select_lyxpipe()
|
||||
{
|
||||
docstring file(form_->browse(
|
||||
from_utf8(internal_path(fromqstr(lyxserverDirED->text()))),
|
||||
_("Give a filename for the LyX server pipe")));
|
||||
if (!file.empty())
|
||||
lyxserverDirED->setText(toqstr(file));
|
||||
QString file = form_->browse(internalPath(lyxserverDirED->text()),
|
||||
qt_("Give a filename for the LyX server pipe"));
|
||||
if (!file.isEmpty())
|
||||
lyxserverDirED->setText(file);
|
||||
}
|
||||
|
||||
|
||||
@ -887,7 +1032,7 @@ void PrefPaths::select_lyxpipe()
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefSpellchecker::PrefSpellchecker(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule(_("Spellchecker"), form, parent)
|
||||
: PrefModule(qt_("Spellchecker"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -981,10 +1126,9 @@ void PrefSpellchecker::update(LyXRC const & rc)
|
||||
|
||||
void PrefSpellchecker::select_dict()
|
||||
{
|
||||
docstring file(form_->browsedict(
|
||||
from_utf8(internal_path(fromqstr(persDictionaryED->text())))));
|
||||
if (!file.empty())
|
||||
persDictionaryED->setText(toqstr(file));
|
||||
QString file = form_->browsedict(internalPath(persDictionaryED->text()));
|
||||
if (!file.isEmpty())
|
||||
persDictionaryED->setText(file);
|
||||
}
|
||||
|
||||
|
||||
@ -997,7 +1141,7 @@ void PrefSpellchecker::select_dict()
|
||||
|
||||
|
||||
PrefConverters::PrefConverters(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule(_("Converters"), form, parent)
|
||||
: PrefModule(qt_("Converters"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -1267,7 +1411,7 @@ string FormatPrettynameValidator::str(Formats::const_iterator it) const
|
||||
|
||||
|
||||
PrefFileformats::PrefFileformats(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule(_("File formats"), form, parent)
|
||||
: PrefModule(qt_("File formats"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
formatED->setValidator(new FormatNameValidator(formatsCB, form_->formats()));
|
||||
@ -1466,7 +1610,7 @@ void PrefFileformats::on_formatRemovePB_clicked()
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefLanguage::PrefLanguage(QWidget * parent)
|
||||
: PrefModule(_("Language"), 0, parent)
|
||||
: PrefModule(qt_("Language"), 0, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -1555,7 +1699,7 @@ void PrefLanguage::update(LyXRC const & rc)
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefPrinter::PrefPrinter(QWidget * parent)
|
||||
: PrefModule(_("Printer"), 0, parent)
|
||||
: PrefModule(qt_("Printer"), 0, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -1653,7 +1797,7 @@ void PrefPrinter::update(LyXRC const & rc)
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule(_("User interface"), form, parent)
|
||||
: PrefModule(qt_("User interface"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -1752,11 +1896,9 @@ void PrefUserInterface::update(LyXRC const & rc)
|
||||
|
||||
void PrefUserInterface::select_ui()
|
||||
{
|
||||
docstring const name =
|
||||
from_utf8(internal_path(fromqstr(uiFileED->text())));
|
||||
docstring file = form_->browseUI(name);
|
||||
if (!file.empty())
|
||||
uiFileED->setText(toqstr(file));
|
||||
QString file = form_->browseUI(internalPath(uiFileED->text()));
|
||||
if (!file.isEmpty())
|
||||
uiFileED->setText(file);
|
||||
}
|
||||
|
||||
|
||||
@ -1775,7 +1917,7 @@ GuiShortcutDialog::GuiShortcutDialog(QWidget * parent) : QDialog(parent)
|
||||
|
||||
|
||||
PrefShortcuts::PrefShortcuts(GuiPreferences * form, QWidget * parent)
|
||||
: PrefModule(_("Shortcuts"), form, parent)
|
||||
: PrefModule(qt_("Shortcuts"), form, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -2018,13 +2160,11 @@ void PrefShortcuts::on_shortcutsTW_itemDoubleClicked()
|
||||
|
||||
void PrefShortcuts::select_bind()
|
||||
{
|
||||
docstring const name =
|
||||
from_utf8(internal_path(fromqstr(bindFileED->text())));
|
||||
docstring file = form_->browsebind(name);
|
||||
if (!file.empty()) {
|
||||
bindFileED->setText(toqstr(file));
|
||||
QString file = form_->browsebind(internalPath(bindFileED->text()));
|
||||
if (!file.isEmpty()) {
|
||||
bindFileED->setText(file);
|
||||
system_bind_ = KeyMap();
|
||||
system_bind_.read(to_utf8(file));
|
||||
system_bind_.read(fromqstr(file));
|
||||
updateShortcutsTW();
|
||||
}
|
||||
}
|
||||
@ -2170,7 +2310,7 @@ void PrefShortcuts::shortcut_clearPB_pressed()
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
PrefIdentity::PrefIdentity(QWidget * parent)
|
||||
: PrefModule(_("Identity"), 0, parent)
|
||||
: PrefModule(qt_("Identity"), 0, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -2258,7 +2398,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
|
||||
void GuiPreferences::add(PrefModule * module)
|
||||
{
|
||||
BOOST_ASSERT(module);
|
||||
prefsPS->addPanel(module, toqstr(module->title()));
|
||||
prefsPS->addPanel(module, module->title());
|
||||
connect(module, SIGNAL(changed()), this, SLOT(change_adaptor()));
|
||||
modules_.push_back(module);
|
||||
}
|
||||
@ -2358,52 +2498,43 @@ void GuiPreferences::updateScreenFonts()
|
||||
}
|
||||
|
||||
|
||||
docstring const GuiPreferences::browsebind(docstring const & file) const
|
||||
QString GuiPreferences::browsebind(QString const & file) const
|
||||
{
|
||||
return browseLibFile(from_ascii("bind"), file, from_ascii("bind"),
|
||||
_("Choose bind file"),
|
||||
return browseLibFile("bind", file, "bind", qt_("Choose bind file"),
|
||||
FileFilterList(_("LyX bind files (*.bind)")));
|
||||
}
|
||||
|
||||
|
||||
docstring const GuiPreferences::browseUI(docstring const & file) const
|
||||
QString GuiPreferences::browseUI(QString const & file) const
|
||||
{
|
||||
return browseLibFile(from_ascii("ui"), file, from_ascii("ui"),
|
||||
_("Choose UI file"),
|
||||
return browseLibFile("ui", file, "ui", qt_("Choose UI file"),
|
||||
FileFilterList(_("LyX UI files (*.ui)")));
|
||||
}
|
||||
|
||||
|
||||
docstring const GuiPreferences::browsekbmap(docstring const & file) const
|
||||
QString GuiPreferences::browsekbmap(QString const & file) const
|
||||
{
|
||||
return browseLibFile(from_ascii("kbd"), file, from_ascii("kmap"),
|
||||
_("Choose keyboard map"),
|
||||
return browseLibFile("kbd", file, "kmap", qt_("Choose keyboard map"),
|
||||
FileFilterList(_("LyX keyboard maps (*.kmap)")));
|
||||
}
|
||||
|
||||
|
||||
docstring const GuiPreferences::browsedict(docstring const & file) const
|
||||
QString GuiPreferences::browsedict(QString const & file) const
|
||||
{
|
||||
if (lyxrc.use_spell_lib)
|
||||
return browseFile(file,
|
||||
_("Choose personal dictionary"),
|
||||
FileFilterList(_("*.pws")));
|
||||
else
|
||||
return browseFile(file,
|
||||
_("Choose personal dictionary"),
|
||||
FileFilterList(_("*.ispell")));
|
||||
return browseFile(file, qt_("Choose personal dictionary"),
|
||||
FileFilterList(lyxrc.use_spell_lib ? _("*.pws") : _("*.ispell")));
|
||||
}
|
||||
|
||||
|
||||
docstring const GuiPreferences::browse(docstring const & file,
|
||||
docstring const & title) const
|
||||
QString GuiPreferences::browse(QString const & file,
|
||||
QString const & title) const
|
||||
{
|
||||
return browseFile(file, title, FileFilterList(), true);
|
||||
}
|
||||
|
||||
|
||||
docstring const GuiPreferences::browsedir(docstring const & path,
|
||||
docstring const & title) const
|
||||
QString GuiPreferences::browsedir(QString const & path,
|
||||
QString const & title) const
|
||||
{
|
||||
return browseDir(path, title);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class PrefModule : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PrefModule(docstring const & t,
|
||||
PrefModule(QString const & t,
|
||||
GuiPreferences * form = 0, QWidget * parent = 0)
|
||||
: QWidget(parent), title_(t), form_(form)
|
||||
{}
|
||||
@ -73,10 +73,10 @@ public:
|
||||
virtual void apply(LyXRC & rc) const = 0;
|
||||
virtual void update(LyXRC const & rc) = 0;
|
||||
|
||||
docstring const & title() const { return title_; }
|
||||
QString const & title() const { return title_; }
|
||||
|
||||
protected:
|
||||
docstring title_;
|
||||
QString title_;
|
||||
GuiPreferences * form_;
|
||||
|
||||
Q_SIGNALS:
|
||||
@ -455,18 +455,16 @@ public:
|
||||
bool isBufferDependent() const { return false; }
|
||||
|
||||
/// various file pickers
|
||||
docstring const browsebind(docstring const & file) const;
|
||||
docstring const browseUI(docstring const & file) const;
|
||||
docstring const browsekbmap(docstring const & file) const;
|
||||
docstring const browsedict(docstring const & file) const;
|
||||
QString browsebind(QString const & file) const;
|
||||
QString browseUI(QString const & file) const;
|
||||
QString browsekbmap(QString const & file) const;
|
||||
QString browsedict(QString const & file) const;
|
||||
|
||||
/// general browse
|
||||
docstring const browse(docstring const & file,
|
||||
docstring const & title) const;
|
||||
QString browse(QString const & file, QString const & title) const;
|
||||
|
||||
/// browse directory
|
||||
docstring const browsedir(docstring const & path,
|
||||
docstring const & title) const;
|
||||
QString browsedir(QString const & path, QString const & title) const;
|
||||
|
||||
/// set a color
|
||||
void setColor(ColorCode col, std::string const & hex);
|
||||
|
@ -40,7 +40,7 @@ GuiShowFile::GuiShowFile(GuiView & lv)
|
||||
|
||||
void GuiShowFile::updateContents()
|
||||
{
|
||||
setWindowTitle(toqstr(onlyFilename(filename_.absFilename())));
|
||||
setWindowTitle(onlyFilename(toqstr(filename_.absFilename())));
|
||||
|
||||
QString contents = toqstr(filename_.fileContents("UTF-8"));
|
||||
if (contents.isEmpty())
|
||||
|
@ -65,7 +65,7 @@ static string texFileFromList(string const & file, string const & type)
|
||||
string classfile = token(allClasses, '\n', entries);
|
||||
int count = 0;
|
||||
while ((!contains(classfile, file) ||
|
||||
(onlyFilename(classfile) != file)) &&
|
||||
(support::onlyFilename(classfile) != file)) &&
|
||||
(++count < 1000)) {
|
||||
classfile = token(allClasses, '\n', ++entries);
|
||||
}
|
||||
@ -167,7 +167,7 @@ void GuiTexInfo::updateStyles(TexFileType type)
|
||||
vector<string>::iterator it1 = data.begin();
|
||||
vector<string>::iterator end1 = data.end();
|
||||
for (; it1 != end1; ++it1)
|
||||
*it1 = onlyFilename(*it1);
|
||||
*it1 = support::onlyFilename(*it1);
|
||||
|
||||
// sort on filename only (no path)
|
||||
sort(data.begin(), data.end());
|
||||
|
@ -1080,20 +1080,19 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd)
|
||||
|
||||
static FileName selectTemplateFile()
|
||||
{
|
||||
FileDialog dlg(_("Select template file"));
|
||||
dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
|
||||
dlg.setButton1(_("Templates|#T#t"), from_utf8(lyxrc.template_path));
|
||||
FileDialog dlg(qt_("Select template file"));
|
||||
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
||||
dlg.setButton1(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
|
||||
|
||||
FileDialog::Result result =
|
||||
dlg.open(from_utf8(lyxrc.template_path),
|
||||
FileFilterList(_("LyX Documents (*.lyx)")),
|
||||
docstring());
|
||||
dlg.open(toqstr(lyxrc.template_path),
|
||||
FileFilterList(_("LyX Documents (*.lyx)")));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return FileName();
|
||||
if (result.second.empty())
|
||||
if (result.second.isEmpty())
|
||||
return FileName();
|
||||
return FileName(to_utf8(result.second));
|
||||
return FileName(fromqstr(result.second));
|
||||
}
|
||||
|
||||
|
||||
@ -1140,20 +1139,18 @@ void GuiView::openDocument(string const & fname)
|
||||
string filename;
|
||||
|
||||
if (fname.empty()) {
|
||||
FileDialog dlg(_("Select document to open"), LFUN_FILE_OPEN);
|
||||
dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
|
||||
dlg.setButton2(_("Examples|#E#e"),
|
||||
from_utf8(addPath(package().system_support().absFilename(), "examples")));
|
||||
FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
|
||||
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
||||
dlg.setButton2(qt_("Examples|#E#e"),
|
||||
toqstr(addPath(package().system_support().absFilename(), "examples")));
|
||||
|
||||
FileDialog::Result result =
|
||||
dlg.open(from_utf8(initpath),
|
||||
FileFilterList(_("LyX Documents (*.lyx)")),
|
||||
docstring());
|
||||
dlg.open(toqstr(initpath), FileFilterList(_("LyX Documents (*.lyx)")));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return;
|
||||
|
||||
filename = to_utf8(result.second);
|
||||
filename = fromqstr(result.second);
|
||||
|
||||
// check selected filename
|
||||
if (filename.empty()) {
|
||||
@ -1274,10 +1271,10 @@ void GuiView::importDocument(string const & argument)
|
||||
docstring const text = bformat(_("Select %1$s file to import"),
|
||||
formats.prettyName(format));
|
||||
|
||||
FileDialog dlg(text, LFUN_BUFFER_IMPORT);
|
||||
dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
|
||||
dlg.setButton2(_("Examples|#E#e"),
|
||||
from_utf8(addPath(package().system_support().absFilename(), "examples")));
|
||||
FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
|
||||
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
||||
dlg.setButton2(qt_("Examples|#E#e"),
|
||||
toqstr(addPath(package().system_support().absFilename(), "examples")));
|
||||
|
||||
docstring filter = formats.prettyName(format);
|
||||
filter += " (*.";
|
||||
@ -1286,14 +1283,12 @@ void GuiView::importDocument(string const & argument)
|
||||
filter += ')';
|
||||
|
||||
FileDialog::Result result =
|
||||
dlg.open(from_utf8(initpath),
|
||||
FileFilterList(filter),
|
||||
docstring());
|
||||
dlg.open(toqstr(initpath), FileFilterList(filter));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return;
|
||||
|
||||
filename = to_utf8(result.second);
|
||||
filename = fromqstr(result.second);
|
||||
|
||||
// check selected filename
|
||||
if (filename.empty())
|
||||
@ -1395,22 +1390,21 @@ void GuiView::insertLyXFile(docstring const & fname)
|
||||
initpath = trypath;
|
||||
|
||||
// FIXME UNICODE
|
||||
FileDialog dlg(_("Select LyX document to insert"), LFUN_FILE_INSERT);
|
||||
dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
|
||||
dlg.setButton2(_("Examples|#E#e"),
|
||||
from_utf8(addPath(package().system_support().absFilename(),
|
||||
FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
|
||||
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
||||
dlg.setButton2(qt_("Examples|#E#e"),
|
||||
toqstr(addPath(package().system_support().absFilename(),
|
||||
"examples")));
|
||||
|
||||
FileDialog::Result result =
|
||||
dlg.open(from_utf8(initpath),
|
||||
FileFilterList(_("LyX Documents (*.lyx)")),
|
||||
docstring());
|
||||
dlg.open(toqstr(initpath),
|
||||
FileFilterList(_("LyX Documents (*.lyx)")));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return;
|
||||
|
||||
// FIXME UNICODE
|
||||
filename.set(to_utf8(result.second));
|
||||
filename.set(fromqstr(result.second));
|
||||
|
||||
// check selected filename
|
||||
if (filename.empty()) {
|
||||
@ -1438,17 +1432,17 @@ void GuiView::insertPlaintextFile(docstring const & fname,
|
||||
return;
|
||||
}
|
||||
|
||||
FileDialog dlg(_("Select file to insert"), (asParagraph ?
|
||||
FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
|
||||
LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
|
||||
|
||||
FileDialog::Result result = dlg.open(from_utf8(bv->buffer().filePath()),
|
||||
FileFilterList(), docstring());
|
||||
FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
|
||||
FileFilterList());
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return;
|
||||
|
||||
// FIXME UNICODE
|
||||
filename.set(to_utf8(result.second));
|
||||
filename.set(fromqstr(result.second));
|
||||
|
||||
// check selected filename
|
||||
if (filename.empty()) {
|
||||
@ -1475,10 +1469,10 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
|
||||
|
||||
/// No argument? Ask user through dialog.
|
||||
// FIXME UNICODE
|
||||
FileDialog dlg(_("Choose a filename to save document as"),
|
||||
FileDialog dlg(qt_("Choose a filename to save document as"),
|
||||
LFUN_BUFFER_WRITE_AS);
|
||||
dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
|
||||
dlg.setButton2(_("Templates|#T#t"), from_utf8(lyxrc.template_path));
|
||||
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
||||
dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
|
||||
|
||||
if (!isLyXFilename(fname.absFilename()))
|
||||
fname.changeExtension(".lyx");
|
||||
@ -1486,14 +1480,14 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
|
||||
FileFilterList const filter(_("LyX Documents (*.lyx)"));
|
||||
|
||||
FileDialog::Result result =
|
||||
dlg.save(from_utf8(fname.onlyPath().absFilename()),
|
||||
dlg.save(toqstr(fname.onlyPath().absFilename()),
|
||||
filter,
|
||||
from_utf8(fname.onlyFileName()));
|
||||
toqstr(fname.onlyFileName()));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return false;
|
||||
|
||||
fname.set(to_utf8(result.second));
|
||||
fname.set(fromqstr(result.second));
|
||||
|
||||
if (fname.empty())
|
||||
return false;
|
||||
|
@ -27,54 +27,52 @@ using namespace lyx::support;
|
||||
namespace lyx {
|
||||
|
||||
/// return the Qt form of the label
|
||||
static docstring const getLabel(docstring const & ucs4str)
|
||||
static QString getLabel(QString const & qstr)
|
||||
{
|
||||
// FIXME UNICODE
|
||||
string str = to_utf8(ucs4str);
|
||||
// FIXME UNICODE (or "qt-ify")
|
||||
string str = fromqstr(qstr);
|
||||
string label;
|
||||
string sc = split(str, label, '|');
|
||||
if (sc.length() < 2)
|
||||
return from_utf8(label);
|
||||
return toqstr(label);
|
||||
size_t pos = label.find(sc[1]);
|
||||
if (pos != string::npos)
|
||||
label.insert(pos, 1, '&');
|
||||
return from_utf8(label);
|
||||
return toqstr(label);
|
||||
}
|
||||
|
||||
|
||||
LyXFileDialog::LyXFileDialog(docstring const & t,
|
||||
docstring const & p,
|
||||
LyXFileDialog::LyXFileDialog(QString const & title,
|
||||
QString const & path,
|
||||
support::FileFilterList const & filters,
|
||||
FileDialog::Button const & b1,
|
||||
FileDialog::Button const & b2)
|
||||
// FIXME replace that with guiApp->currentView()
|
||||
: QFileDialog(qApp->focusWidget(),
|
||||
toqstr(t), toqstr(p), toqstr(filters.as_string()))
|
||||
: QFileDialog(qApp->focusWidget(), title, path, toqstr(filters.as_string()))
|
||||
{
|
||||
QString const path = toqstr(p);
|
||||
QDir dir(path);
|
||||
// FIXME: workaround for a bug in qt which makes LyX crash
|
||||
// with hidden paths (bug 4513). Recheck with recent Qt versions.
|
||||
if (path.contains("/."))
|
||||
dir.setFilter(QDir::Hidden);
|
||||
setDirectory(dir);
|
||||
setWindowTitle(toqstr(t));
|
||||
setWindowTitle(title);
|
||||
|
||||
QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();
|
||||
|
||||
if (!b1.first.empty()) {
|
||||
if (!b1.first.isEmpty()) {
|
||||
b1_dir_ = b1.second;
|
||||
QToolButton * tb = new QToolButton(this);
|
||||
connect(tb, SIGNAL(clicked()), this, SLOT(button1Clicked()));
|
||||
tb->setText(toqstr(getLabel(b1.first)));
|
||||
tb->setText(getLabel(b1.first));
|
||||
layout.at(0)->addWidget(tb);
|
||||
}
|
||||
|
||||
if (!b2.first.empty()) {
|
||||
if (!b2.first.isEmpty()) {
|
||||
b2_dir_ = b2.second;
|
||||
QToolButton * tb = new QToolButton(this);
|
||||
connect(tb, SIGNAL(clicked()), this, SLOT(button2Clicked()));
|
||||
tb->setText(toqstr(getLabel(b2.first)));
|
||||
tb->setText(getLabel(b2.first));
|
||||
layout.at(0)->addWidget(tb);
|
||||
}
|
||||
}
|
||||
@ -82,13 +80,13 @@ LyXFileDialog::LyXFileDialog(docstring const & t,
|
||||
|
||||
void LyXFileDialog::button1Clicked()
|
||||
{
|
||||
setDirectory(toqstr(b1_dir_));
|
||||
setDirectory(b1_dir_);
|
||||
}
|
||||
|
||||
|
||||
void LyXFileDialog::button2Clicked()
|
||||
{
|
||||
setDirectory(toqstr(b2_dir_));
|
||||
setDirectory(b2_dir_);
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -27,8 +27,8 @@ class LyXFileDialog : public QFileDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LyXFileDialog(docstring const & title,
|
||||
docstring const & path,
|
||||
LyXFileDialog(QString const & title,
|
||||
QString const & path,
|
||||
support::FileFilterList const & filters,
|
||||
FileDialog::Button const & b1,
|
||||
FileDialog::Button const & b2);
|
||||
@ -38,8 +38,8 @@ public Q_SLOTS:
|
||||
void button2Clicked();
|
||||
|
||||
private:
|
||||
docstring b1_dir_;
|
||||
docstring b2_dir_;
|
||||
QString b1_dir_;
|
||||
QString b2_dir_;
|
||||
};
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -206,103 +206,6 @@ vector<LanguagePair> const getLanguageData(bool character_dlg)
|
||||
return langs;
|
||||
}
|
||||
|
||||
|
||||
docstring browseFile(docstring const & filename, docstring const & title,
|
||||
FileFilterList const & filters, bool save,
|
||||
docstring const & label1, docstring const & dir1,
|
||||
docstring const & label2, docstring const & dir2)
|
||||
{
|
||||
docstring lastPath = from_ascii(".");
|
||||
if (!filename.empty())
|
||||
lastPath = from_utf8(onlyPath(to_utf8(filename)));
|
||||
|
||||
FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
|
||||
dlg.setButton1(label1, dir1);
|
||||
dlg.setButton2(label2, dir2);
|
||||
|
||||
FileDialog::Result result;
|
||||
|
||||
if (save)
|
||||
result = dlg.save(lastPath, filters,
|
||||
from_utf8(onlyFilename(to_utf8(filename))));
|
||||
else
|
||||
result = dlg.open(lastPath, filters,
|
||||
from_utf8(onlyFilename(to_utf8(filename))));
|
||||
|
||||
return result.second;
|
||||
}
|
||||
|
||||
|
||||
docstring browseRelFile(docstring const & filename, docstring const & refpath,
|
||||
docstring const & title, FileFilterList const & filters, bool save,
|
||||
docstring const & label1, docstring const & dir1,
|
||||
docstring const & label2, docstring const & dir2)
|
||||
{
|
||||
docstring const fname = from_utf8(makeAbsPath(
|
||||
to_utf8(filename), to_utf8(refpath)).absFilename());
|
||||
|
||||
docstring const outname = browseFile(fname, title, filters, save,
|
||||
label1, dir1, label2, dir2);
|
||||
docstring const reloutname = makeRelPath(outname, refpath);
|
||||
if (prefixIs(reloutname, from_ascii("../")))
|
||||
return outname;
|
||||
else
|
||||
return reloutname;
|
||||
}
|
||||
|
||||
|
||||
docstring browseLibFile(docstring const & dir, docstring const & name,
|
||||
docstring const & ext, docstring const & title,
|
||||
FileFilterList const & filters)
|
||||
{
|
||||
// FIXME UNICODE
|
||||
docstring const label1 = _("System files|#S#s");
|
||||
docstring const dir1 =
|
||||
from_utf8(addName(package().system_support().absFilename(), to_utf8(dir)));
|
||||
|
||||
docstring const label2 = _("User files|#U#u");
|
||||
docstring const dir2 =
|
||||
from_utf8(addName(package().user_support().absFilename(), to_utf8(dir)));
|
||||
|
||||
docstring const result = browseFile(from_utf8(
|
||||
libFileSearch(to_utf8(dir), to_utf8(name), to_utf8(ext)).absFilename()),
|
||||
title, filters, false, dir1, dir2);
|
||||
|
||||
// remove the extension if it is the default one
|
||||
docstring noextresult;
|
||||
if (from_utf8(getExtension(to_utf8(result))) == ext)
|
||||
noextresult = from_utf8(removeExtension(to_utf8(result)));
|
||||
else
|
||||
noextresult = result;
|
||||
|
||||
// remove the directory, if it is the default one
|
||||
docstring const file = from_utf8(onlyFilename(to_utf8(noextresult)));
|
||||
if (from_utf8(libFileSearch(to_utf8(dir), to_utf8(file), to_utf8(ext)).absFilename()) == result)
|
||||
return file;
|
||||
else
|
||||
return noextresult;
|
||||
}
|
||||
|
||||
|
||||
docstring browseDir(docstring const & pathname, docstring const & title,
|
||||
docstring const & label1, docstring const & dir1,
|
||||
docstring const & label2, docstring const & dir2)
|
||||
{
|
||||
docstring lastPath = from_ascii(".");
|
||||
if (!pathname.empty())
|
||||
lastPath = from_utf8(onlyPath(to_utf8(pathname)));
|
||||
|
||||
FileDialog dlg(title, LFUN_SELECT_FILE_SYNC);
|
||||
dlg.setButton1(label1, dir1);
|
||||
dlg.setButton2(label2, dir2);
|
||||
|
||||
FileDialog::Result const result =
|
||||
dlg.opendir(lastPath, from_utf8(onlyFilename(to_utf8(pathname))));
|
||||
|
||||
return result.second;
|
||||
}
|
||||
|
||||
|
||||
void rescanTexStyles()
|
||||
{
|
||||
// Run rescan in user lyx directory
|
||||
@ -343,4 +246,22 @@ void getTexFileList(string const & filename, vector<string> & list)
|
||||
eliminate_duplicates(list);
|
||||
}
|
||||
|
||||
|
||||
QString internalPath(const QString & str)
|
||||
{
|
||||
return toqstr(os::internal_path(fromqstr(str)));
|
||||
}
|
||||
|
||||
|
||||
QString onlyFilename(const QString & str)
|
||||
{
|
||||
return toqstr(support::onlyFilename(fromqstr(str)));
|
||||
}
|
||||
|
||||
|
||||
QString onlyPath(const QString & str)
|
||||
{
|
||||
return toqstr(support::onlyPath(fromqstr(str)));
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -78,22 +78,6 @@ typedef std::pair<docstring, std::string> LanguagePair;
|
||||
*/
|
||||
std::vector<LanguagePair> const getLanguageData(bool character_dlg);
|
||||
|
||||
/** Launch a file dialog and return the chosen file.
|
||||
filename: a suggested filename.
|
||||
title: the title of the dialog.
|
||||
pattern: *.ps etc.
|
||||
dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
|
||||
*/
|
||||
docstring browseFile(docstring const & filename,
|
||||
docstring const & title,
|
||||
support::FileFilterList const & filters,
|
||||
bool save = false,
|
||||
docstring const & label1 = docstring(),
|
||||
docstring const & dir1 = docstring(),
|
||||
docstring const & label2 = docstring(),
|
||||
docstring const & dir2 = docstring());
|
||||
|
||||
|
||||
/** Wrapper around browseFile which tries to provide a filename
|
||||
relative to relpath. If the relative path is of the form "foo.txt"
|
||||
or "bar/foo.txt", then it is returned as relative. OTOH, if it is
|
||||
@ -111,31 +95,6 @@ docstring browseRelFile(docstring const & filename,
|
||||
docstring const & dir2 = docstring());
|
||||
|
||||
|
||||
/** Wrapper around browseFile which tries to provide a filename
|
||||
* relative to the user or system directory. The dir, name and ext
|
||||
* parameters have the same meaning as in the
|
||||
* support::LibFileSearch function.
|
||||
*/
|
||||
docstring browseLibFile(docstring const & dir,
|
||||
docstring const & name,
|
||||
docstring const & ext,
|
||||
docstring const & title,
|
||||
support::FileFilterList const & filters);
|
||||
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
docstring browseDir(docstring const & pathname,
|
||||
docstring const & title,
|
||||
docstring const & label1 = docstring(),
|
||||
docstring const & dir1 = docstring(),
|
||||
docstring const & label2 = docstring(),
|
||||
docstring const & dir2 = docstring());
|
||||
|
||||
|
||||
/** Build filelists of all availabe bst/cls/sty-files. Done through
|
||||
* kpsewhich and an external script, saved in *Files.lst.
|
||||
*/
|
||||
@ -146,6 +105,11 @@ void rescanTexStyles();
|
||||
*/
|
||||
void getTexFileList(std::string const & filename, std::vector<std::string> & contents);
|
||||
|
||||
// wrapper around the docstring versions
|
||||
QString internalPath(const QString &);
|
||||
QString onlyFilename(const QString & str);
|
||||
QString onlyPath(const QString & str);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif // QTHELPERS_H
|
||||
|
Loading…
Reference in New Issue
Block a user