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.
13 #include "FileDialog_private.h"
15 #include "qt_helpers.h"
17 #include "support/filefilterlist.h"
18 #include "support/lstrings.h"
20 #include <QApplication>
21 #include <QToolButton>
22 #include <QHBoxLayout>
24 using lyx::support::split;
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, 1, '&');
47 LyXFileDialog::LyXFileDialog(string const & t,
49 lyx::support::FileFilterList const & filters,
50 FileDialog::Button const & b1,
51 FileDialog::Button const & b2)
52 // FIXME replace that with theApp->gui()->currentView()
53 : QFileDialog(qApp->focusWidget(),
54 toqstr(t), toqstr(p), toqstr(filters.as_string())),
57 setWindowTitle(toqstr(t));
59 QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();
61 if (!b1.first.empty()) {
63 b1_ = new QToolButton(this);
64 connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
65 b1_->setText(toqstr(getLabel(b1.first)));
66 layout.at(0)->addWidget(b1_);
69 if (!b2.first.empty()) {
71 b2_ = new QToolButton(this);
72 connect(b2_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
73 b2_->setText(toqstr(getLabel(b2.first)));
74 layout.at(0)->addWidget(b2_);
79 void LyXFileDialog::buttonClicked()
82 setDirectory(toqstr(b1_dir_));
83 else if (sender() == b2_)
84 setDirectory(toqstr(b2_dir_));
87 #include "FileDialog_private_moc.cpp"