2 * \file GuiShowFile.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #include "GuiShowFile.h"
16 #include "qt_helpers.h"
17 #include "support/filetools.h"
19 #include <QTextBrowser>
20 #include <QPushButton>
21 #include <QCloseEvent>
27 using support::FileName;
28 using support::onlyFilename;
30 GuiShowFile::GuiShowFile(LyXView & lv)
31 : GuiDialog(lv, "file"), Controller(this)
34 setViewTitle(_("Show File"));
35 setController(this, false);
37 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
39 bc().setPolicy(ButtonPolicy::OkCancelPolicy);
40 bc().setCancel(closePB);
44 void GuiShowFile::closeEvent(QCloseEvent * e)
51 void GuiShowFile::updateContents()
53 setWindowTitle(toqstr(onlyFilename(filename_.absFilename())));
55 std::string contents = support::getFileContents(filename_);
57 contents = "Error -> Cannot load file!";
59 textTB->setPlainText(toqstr(contents));
63 bool GuiShowFile::initialiseParams(std::string const & data)
65 filename_ = FileName(data);
70 void GuiShowFile::clearParams()
76 Dialog * createGuiShowFile(LyXView & lv) { return new GuiShowFile(lv); }
79 } // namespace frontend
82 #include "GuiShowFile_moc.cpp"