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 #include "FileDialog_private.h"
15 #include "qt_helpers.h"
17 #include "support/globbing.h"
18 #include "support/lstrings.h"
20 #include <qapplication.h>
21 #include <qtoolbutton.h>
23 using lyx::support::split;
30 /// return the Qt form of the label
31 string const getLabel(string const & str) {
33 string sc(split(str, label, '|'));
36 string::size_type pos = label.find(sc[1]);
37 if (pos == string::npos)
39 label.insert(pos, 1, '&');
46 LyXFileDialog::LyXFileDialog(string const & p,
47 lyx::support::FileFilterList const & filters,
49 FileDialog::Button const & b1,
50 FileDialog::Button const & b2)
51 : QFileDialog(toqstr(p), toqstr(filters.str(true)),
52 qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget(), toqstr(t), true),
55 setCaption(toqstr(t));
57 if (!b1.first.empty()) {
59 b1_ = new QToolButton(this);
60 connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
61 b1_->setText(toqstr(getLabel(b1.first)));
62 addToolButton(b1_, true);
65 if (!b2.first.empty()) {
67 b2_ = new QToolButton(this);
68 connect(b2_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
69 b2_->setText(toqstr(getLabel(b2.first)));
75 void LyXFileDialog::buttonClicked()
78 setDir(toqstr(b1_dir_));
79 else if (sender() == b2_)
80 setDir(toqstr(b2_dir_));