2 * \file FileDialog_private.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
17 #include "QtLyXView.h"
19 #include "funcrequest.h"
21 #include "FileDialog_private.h"
23 #include "support/lstrings.h"
25 #include <qapplication.h>
26 #include <qfiledialog.h>
27 #include <qtoolbutton.h>
31 /// return the Qt form of the label
32 string const getLabel(string const & str) {
34 string sc(split(str, label, '|'));
37 string::size_type pos = label.find(sc[1]);
38 if (pos == string::npos)
40 label.insert(pos, "&");
46 LyXFileDialog::LyXFileDialog(string const & p, string const & m,
48 FileDialog::Button const & b1, FileDialog::Button const & b2)
49 : QFileDialog(p.c_str(), m.c_str(),
50 qApp->mainWidget(), t.c_str(), true),
53 setCaption(t.c_str());
55 if (!b1.first.empty()) {
57 b1_ = new QToolButton(this);
58 connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
59 b1_->setText(getLabel(b1.first).c_str());
60 addToolButton(b1_, true);
63 if (!b2.first.empty()) {
65 b2_ = new QToolButton(this);
66 connect(b2_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
67 b2_->setText(getLabel(b2.first).c_str());
73 void LyXFileDialog::buttonClicked()
76 setDir(b1_dir_.c_str());
77 else if (sender() == b2_)
78 setDir(b2_dir_.c_str());