/** * \file GuiShowFile.cpp * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author John Levon * \author Herbert Voß * * Full author contact details are available in file CREDITS. */ #include #include "GuiShowFile.h" #include "qt_helpers.h" #include "support/filetools.h" #include #include #include using namespace std; using namespace lyx::support; namespace lyx { namespace frontend { GuiShowFile::GuiShowFile(GuiView & lv) : GuiDialog(lv, "file") { setupUi(this); setViewTitle(_("Show File")); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); bc().setPolicy(ButtonPolicy::OkCancelPolicy); bc().setCancel(closePB); } void GuiShowFile::closeEvent(QCloseEvent * e) { slotClose(); e->accept(); } void GuiShowFile::updateContents() { setWindowTitle(toqstr(onlyFilename(filename_.absFilename()))); docstring contents = filename_.fileContents("UTF-8"); if (contents.empty()) contents = _("Error -> Cannot load file!"); textTB->setPlainText(toqstr(contents)); } bool GuiShowFile::initialiseParams(string const & data) { filename_ = FileName(data); return true; } void GuiShowFile::clearParams() { filename_.erase(); } Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); } } // namespace frontend } // namespace lyx #include "GuiShowFile_moc.cpp"