2 * \file FileDialog_private.C
3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
12 #include "support/lstrings.h"
14 #include <qapplication.h>
15 #include <qfiledialog.h>
16 #include <qtoolbutton.h>
18 #include "QtLyXView.h"
20 #include "funcrequest.h"
22 #include "FileDialog_private.h"
25 /// return the Qt form of the label
26 string const getLabel(string const & str) {
28 string sc(split(str, label, '|'));
31 string::size_type pos = label.find(sc[1]);
32 if (pos == string::npos)
34 label.insert(pos, "&");
39 LyXFileDialog::LyXFileDialog(string const & p, string const & m, string const & t,
40 FileDialog::Button const & b1, FileDialog::Button const & b2)
41 : QFileDialog(p.c_str(), m.c_str(), qApp->mainWidget(), t.c_str(), true),
44 setCaption(t.c_str());
46 if (!b1.first.empty()) {
48 b1_ = new QToolButton(this);
49 connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
50 b1_->setText(getLabel(b1.first).c_str());
51 addToolButton(b1_, true);
54 if (!b2.first.empty()) {
56 b2_ = new QToolButton(this);
57 connect(b2_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
58 b2_->setText(getLabel(b2.first).c_str());
64 void LyXFileDialog::buttonClicked()
67 setDir(b1_dir_.c_str());
68 else if (sender() == b2_)
69 setDir(b2_dir_.c_str());