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>
23 using namespace lyx::support;
29 GuiShowFile::GuiShowFile(GuiView & lv)
30 : GuiDialog(lv, "file", qt_("Show File"))
34 connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
35 this, SLOT(slotButtonBox(QAbstractButton *)));
37 bc().setPolicy(ButtonPolicy::OkCancelPolicy);
38 bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
42 void GuiShowFile::updateContents()
44 setWindowTitle(onlyFileName(toqstr(filename_.absFileName())));
46 QString contents = toqstr(filename_.fileContents("UTF-8"));
47 if (contents.isEmpty())
48 contents = qt_("Error -> Cannot load file!");
50 textTB->setPlainText(contents);
54 bool GuiShowFile::initialiseParams(string const & sdata)
56 filename_ = FileName(sdata);
61 void GuiShowFile::clearParams()
67 Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); }
70 } // namespace frontend
73 #include "moc_GuiShowFile.cpp"