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 <qapplication.h>
18 #include <qtoolbutton.h>
20 #include "FileDialog_private.h"
22 #include "QtLyXView.h"
24 #include "funcrequest.h"
26 #include "support/lstrings.h"
29 /// return the Qt form of the label
30 string const getLabel(string const & str) {
32 string sc(split(str, label, '|'));
35 string::size_type pos = label.find(sc[1]);
36 if (pos == string::npos)
38 label.insert(pos, "&");
43 LyXFileDialog::LyXFileDialog(string const & p, string const & m, string const & t,
44 FileDialog::Button const & b1, FileDialog::Button const & b2)
45 : QFileDialog(p.c_str(), m.c_str(), qApp->mainWidget(), t.c_str(), true),
48 setCaption(t.c_str());
50 if (!b1.first.empty()) {
52 b1_ = new QToolButton(this);
53 connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
54 b1_->setText(getLabel(b1.first).c_str());
55 addToolButton(b1_, true);
58 if (!b2.first.empty()) {
60 b2_ = new QToolButton(this);
61 connect(b2_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
62 b2_->setText(getLabel(b2.first).c_str());
68 void LyXFileDialog::buttonClicked()
71 setDir(b1_dir_.c_str());
72 else if (sender() == b2_)
73 setDir(b2_dir_.c_str());