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 #pragma implementation
17 #include "QtLyXView.h"
19 #include "funcrequest.h"
21 #include "FileDialog_private.h"
23 #include "support/lstrings.h"
25 #include <qapplication.h>
26 #include <qfiledialog.h>
27 #include <qtoolbutton.h>
32 /// return the Qt form of the label
33 string const getLabel(string const & str) {
35 string sc(split(str, label, '|'));
38 string::size_type pos = label.find(sc[1]);
39 if (pos == string::npos)
41 label.insert(pos, 1, '&');
48 LyXFileDialog::LyXFileDialog(string const & p, string const & m,
50 FileDialog::Button const & b1, FileDialog::Button const & b2)
51 : QFileDialog(p.c_str(), m.c_str(),
52 qApp->mainWidget(), t.c_str(), true),
55 setCaption(t.c_str());
57 if (!b1.first.empty()) {
59 b1_ = new QToolButton(this);
60 connect(b1_, SIGNAL(clicked()), this, SLOT(buttonClicked()));
61 b1_->setText(getLabel(b1.first).c_str());
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(getLabel(b2.first).c_str());
75 void LyXFileDialog::buttonClicked()
78 setDir(b1_dir_.c_str());
79 else if (sender() == b2_)
80 setDir(b2_dir_.c_str());