]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/LyXFileDialog.cpp
QDialogButtonBox for the remaining dialogs.
[lyx.git] / src / frontends / qt4 / LyXFileDialog.cpp
1 /**
2  * \file LyXFileDialog.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "LyXFileDialog.h"
14
15 #include "qt_helpers.h"
16
17 #include "support/lstrings.h"
18
19 #include <QApplication>
20 #include <QToolButton>
21 #include <QHBoxLayout>
22
23 using namespace std;
24 using namespace lyx::support;
25
26 namespace lyx {
27
28
29 LyXFileDialog::LyXFileDialog(QString const & title,
30                              QString const & path,
31                              QStringList const & filters,
32                              FileDialog::Button const & b1,
33                              FileDialog::Button const & b2)
34                                  // FIXME replace that with guiApp->currentView()
35         : QFileDialog(qApp->focusWidget(), title, path)
36 {
37         setNameFilters(filters);
38         setWindowTitle(title);
39         setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
40         setOption(QFileDialog::DontUseNativeDialog);
41
42         QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();
43
44         if (!b1.first.isEmpty()) {
45                 b1_dir_ = b1.second;
46                 QToolButton * tb = new QToolButton(this);
47                 connect(tb, SIGNAL(clicked()), this, SLOT(button1Clicked()));
48                 tb->setText(b1.first);
49                 layout.at(0)->addWidget(tb);
50         }
51
52         if (!b2.first.isEmpty()) {
53                 b2_dir_ = b2.second;
54                 QToolButton * tb = new QToolButton(this);
55                 connect(tb, SIGNAL(clicked()), this, SLOT(button2Clicked()));
56                 tb->setText(b2.first);
57                 layout.at(0)->addWidget(tb);
58         }
59 }
60
61
62 void LyXFileDialog::button1Clicked()
63 {
64         setDirectory(b1_dir_);
65 }
66
67
68 void LyXFileDialog::button2Clicked()
69 {
70         setDirectory(b2_dir_);
71 }
72
73 } // namespace lyx
74
75 #include "moc_LyXFileDialog.cpp"