2001-03-12 12:47:07 +00:00
|
|
|
/**
|
|
|
|
* \file FileDialog_private.C
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "LString.h"
|
2002-08-25 20:53:39 +00:00
|
|
|
#include "support/lstrings.h"
|
2001-03-26 19:34:45 +00:00
|
|
|
|
|
|
|
#include <qapplication.h>
|
2001-03-12 12:47:07 +00:00
|
|
|
#include <qfiledialog.h>
|
2002-08-25 20:53:39 +00:00
|
|
|
#include <qtoolbutton.h>
|
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"
|
2001-03-26 19:34:45 +00:00
|
|
|
|
2001-03-12 12:47:07 +00:00
|
|
|
#include "FileDialog_private.h"
|
|
|
|
|
2002-08-25 20:53:39 +00:00
|
|
|
namespace {
|
|
|
|
/// return the Qt form of the label
|
|
|
|
string const getLabel(string const & str) {
|
|
|
|
string label;
|
|
|
|
string sc(split(str, label, '|'));
|
|
|
|
if (sc.length() < 2)
|
|
|
|
return label;
|
|
|
|
string::size_type pos = label.find(sc[1]);
|
|
|
|
if (pos == string::npos)
|
|
|
|
return label;
|
|
|
|
label.insert(pos, "&");
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LyXFileDialog::LyXFileDialog(string const & p, string const & m, string const & t,
|
|
|
|
FileDialog::Button const & b1, FileDialog::Button const & b2)
|
|
|
|
: QFileDialog(p.c_str(), m.c_str(), qApp->mainWidget(), t.c_str(), true),
|
|
|
|
b1_(0), b2_(0)
|
2001-03-12 12:47:07 +00:00
|
|
|
{
|
|
|
|
setCaption(t.c_str());
|
|
|
|
|
2002-08-25 20:53:39 +00:00
|
|
|
if (!b1.first.empty()) {
|
|
|
|
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
|
|
|
}
|