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"
14 #include "qt_helpers.h"
16 #include "support/filefilterlist.h"
17 #include "support/lstrings.h"
19 #include <qapplication.h>
20 #include <qtoolbutton.h>
22 using lyx::support::split;
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, 1, '&');
45 LyXFileDialog::LyXFileDialog(string const & p,
46 lyx::support::FileFilterList const & filters,
48 FileDialog::Button const & b1,
49 FileDialog::Button const & b2)
50 : QFileDialog(toqstr(p), toqstr(filters.as_string()),
51 qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget(), toqstr(t), true),
54 setCaption(toqstr(t));
56 if (!b1.first.empty()) {
58 b1_ = new QToolButton(this);
59 connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
60 b1_->setText(toqstr(getLabel(b1.first)));
61 addToolButton(b1_, true);
64 if (!b2.first.empty()) {
66 b2_ = new QToolButton(this);
67 connect(b2_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
68 b2_->setText(toqstr(getLabel(b2.first)));
74 void LyXFileDialog::buttonClicked()
77 setDir(toqstr(b1_dir_));
78 else if (sender() == b2_)
79 setDir(toqstr(b2_dir_));