2001-03-12 12:47:07 +00:00
|
|
|
/**
|
|
|
|
* \file FileDialog_private.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-12 12:47:07 +00:00
|
|
|
*
|
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-12 12:47:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
2001-03-26 19:34:45 +00:00
|
|
|
|
2001-03-12 12:47:07 +00:00
|
|
|
#include "QtLyXView.h"
|
|
|
|
#include "debug.h"
|
2002-08-07 08:11:41 +00:00
|
|
|
#include "funcrequest.h"
|
2002-09-24 13:57:09 +00:00
|
|
|
#include "lyxfunc.h"
|
2002-10-19 10:32:57 +00:00
|
|
|
#include "FileDialog_private.h"
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
#include "support/lstrings.h"
|
2001-03-12 12:47:07 +00:00
|
|
|
|
2002-10-19 10:32:57 +00:00
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qfiledialog.h>
|
|
|
|
#include <qtoolbutton.h>
|
|
|
|
|
|
|
|
|
2002-08-25 20:53:39 +00:00
|
|
|
namespace {
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
/// return the Qt form of the label
|
|
|
|
string const getLabel(string const & str) {
|
|
|
|
string label;
|
|
|
|
string sc(split(str, label, '|'));
|
|
|
|
if (sc.length() < 2)
|
2002-08-25 20:53:39 +00:00
|
|
|
return label;
|
2002-10-20 01:48:28 +00:00
|
|
|
string::size_type pos = label.find(sc[1]);
|
|
|
|
if (pos == string::npos)
|
|
|
|
return label;
|
2002-11-27 10:30:28 +00:00
|
|
|
label.insert(pos, 1, '&');
|
2002-10-20 01:48:28 +00:00
|
|
|
return label;
|
2002-08-25 20:53:39 +00:00
|
|
|
}
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
} // namespace anon
|
|
|
|
|
2002-10-19 10:32:57 +00:00
|
|
|
|
|
|
|
LyXFileDialog::LyXFileDialog(string const & p, string const & m,
|
|
|
|
string const & t,
|
2002-08-25 20:53:39 +00:00
|
|
|
FileDialog::Button const & b1, FileDialog::Button const & b2)
|
2002-10-19 10:32:57 +00:00
|
|
|
: QFileDialog(p.c_str(), m.c_str(),
|
2002-12-12 17:24:24 +00:00
|
|
|
qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget(), t.c_str(), true),
|
2002-08-25 20:53:39 +00:00
|
|
|
b1_(0), b2_(0)
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
|
|
|
setCaption(t.c_str());
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
if (!b1.first.empty()) {
|
2002-08-25 20:53:39 +00:00
|
|
|
b1_dir_ = b1.second;
|
|
|
|
b1_ = new QToolButton(this);
|
|
|
|
connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
|
|
|
|
b1_->setText(getLabel(b1.first).c_str());
|
|
|
|
addToolButton(b1_, true);
|
|
|
|
}
|
2001-03-26 19:34:45 +00:00
|
|
|
|
2002-08-25 20:53:39 +00:00
|
|
|
if (!b2.first.empty()) {
|
|
|
|
b2_dir_ = b2.second;
|
|
|
|
b2_ = new QToolButton(this);
|
|
|
|
connect(b2_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
|
|
|
|
b2_->setText(getLabel(b2.first).c_str());
|
|
|
|
addToolButton(b2_);
|
2002-01-16 23:56:25 +00:00
|
|
|
}
|
2002-08-25 20:53:39 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-08-07 08:11:41 +00:00
|
|
|
|
2002-08-25 20:53:39 +00:00
|
|
|
void LyXFileDialog::buttonClicked()
|
|
|
|
{
|
|
|
|
if (sender() == b1_)
|
|
|
|
setDir(b1_dir_.c_str());
|
|
|
|
else if (sender() == b2_)
|
|
|
|
setDir(b2_dir_.c_str());
|
2001-03-12 12:47:07 +00:00
|
|
|
}
|