]> git.lyx.org Git - features.git/blob - src/frontends/qt/GuiShowFile.cpp
Fix broken Apple speller interface
[features.git] / src / frontends / qt / GuiShowFile.cpp
1 /**
2  * \file GuiShowFile.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  * \author Herbert Voß
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiShowFile.h"
15
16 #include "qt_helpers.h"
17 #include "support/filetools.h"
18
19 #include <QTextBrowser>
20 #include <QPushButton>
21
22 using namespace std;
23 using namespace lyx::support;
24
25 namespace lyx {
26 namespace frontend {
27
28
29 GuiShowFile::GuiShowFile(GuiView & lv)
30         : GuiDialog(lv, "file", qt_("Show File"))
31 {
32         setupUi(this);
33
34         connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
35                 this, SLOT(slotButtonBox(QAbstractButton *)));
36
37         bc().setPolicy(ButtonPolicy::OkCancelPolicy);
38         bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
39 }
40
41
42 void GuiShowFile::updateContents()
43 {
44         setWindowTitle(onlyFileName(toqstr(filename_.absFileName())));
45
46         QString contents = toqstr(filename_.fileContents("UTF-8"));
47         if (contents.isEmpty())
48                 contents = qt_("Error -> Cannot load file!");
49
50         textTB->setPlainText(contents);
51 }
52
53
54 bool GuiShowFile::initialiseParams(string const & sdata)
55 {
56         filename_ = FileName(sdata);
57         return true;
58 }
59
60
61 void GuiShowFile::clearParams()
62 {
63         filename_.erase();
64 }
65
66
67 } // namespace frontend
68 } // namespace lyx
69
70 #include "moc_GuiShowFile.cpp"