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 "QtLyXView.h"
16 #include "funcrequest.h"
18 #include "FileDialog_private.h"
19 #include "qt_helpers.h"
21 #include "support/lstrings.h"
23 #include <qapplication.h>
24 #include <qfiledialog.h>
25 #include <qtoolbutton.h>
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, string const & m,
48 FileDialog::Button const & b1, FileDialog::Button const & b2)
49 : QFileDialog(toqstr(p), toqstr(m),
50 qApp->focusWidget() ? qApp->focusWidget() : qApp->mainWidget(), toqstr(t), true),
53 setCaption(toqstr(t));
55 if (!b1.first.empty()) {
57 b1_ = new QToolButton(this);
58 connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
59 b1_->setText(toqstr(getLabel(b1.first)));
60 addToolButton(b1_, true);
63 if (!b2.first.empty()) {
65 b2_ = new QToolButton(this);
66 connect(b2_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
67 b2_->setText(toqstr(getLabel(b2.first)));
73 void LyXFileDialog::buttonClicked()
76 setDir(toqstr(b1_dir_));
77 else if (sender() == b2_)
78 setDir(toqstr(b2_dir_));