2 * \file LyXFileDialog.cpp
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 "LyXFileDialog.h"
15 #include "qt_helpers.h"
17 #include "support/lstrings.h"
19 #include <QApplication>
20 #include <QToolButton>
21 #include <QHBoxLayout>
24 using namespace lyx::support;
28 /// return the Qt form of the label
29 static QString getLabel(QString const & qstr)
31 // FIXME UNICODE (or "qt-ify")
32 string str = fromqstr(qstr);
34 string sc = split(str, label, '|');
37 size_t pos = label.find(sc[1]);
38 if (pos != string::npos)
39 label.insert(pos, 1, '&');
44 LyXFileDialog::LyXFileDialog(QString const & title,
46 QStringList const & filters,
47 FileDialog::Button const & b1,
48 FileDialog::Button const & b2)
49 // FIXME replace that with guiApp->currentView()
50 : QFileDialog(qApp->focusWidget(), title, path)
52 setNameFilters(filters);
53 setWindowTitle(title);
54 setOption(QFileDialog::DontUseNativeDialog);
56 QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();
58 if (!b1.first.isEmpty()) {
60 QToolButton * tb = new QToolButton(this);
61 connect(tb, SIGNAL(clicked()), this, SLOT(button1Clicked()));
62 tb->setText(getLabel(b1.first));
63 layout.at(0)->addWidget(tb);
66 if (!b2.first.isEmpty()) {
68 QToolButton * tb = new QToolButton(this);
69 connect(tb, SIGNAL(clicked()), this, SLOT(button2Clicked()));
70 tb->setText(getLabel(b2.first));
71 layout.at(0)->addWidget(tb);
76 void LyXFileDialog::button1Clicked()
78 setDirectory(b1_dir_);
82 void LyXFileDialog::button2Clicked()
84 setDirectory(b2_dir_);
89 #include "moc_LyXFileDialog.cpp"