X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiShowFile.cpp;h=c2a4360b2fca7ff0b4f42ce9cb553ebaad23b297;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=ab89573a434738cf32c65ddeccb51b76c3d5d7a4;hpb=212386be8a1573fb52b5da718961835816a3c8e2;p=lyx.git diff --git a/src/frontends/qt4/GuiShowFile.cpp b/src/frontends/qt4/GuiShowFile.cpp index ab89573a43..c2a4360b2f 100644 --- a/src/frontends/qt4/GuiShowFile.cpp +++ b/src/frontends/qt4/GuiShowFile.cpp @@ -4,6 +4,7 @@ * Licence details can be found in the file COPYING. * * \author John Levon + * \author Herbert Voß * * Full author contact details are available in file CREDITS. */ @@ -11,70 +12,61 @@ #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 { -///////////////////////////////////////////////////////////////////// -// -// GuiShowFileDialog -// -///////////////////////////////////////////////////////////////////// -GuiShowFileDialog::GuiShowFileDialog(GuiShowFile * form) - : form_(form) +GuiShowFile::GuiShowFile(GuiView & lv) + : GuiDialog(lv, "file", qt_("Show File")) { setupUi(this); - connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose())); -} + connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); -void GuiShowFileDialog::closeEvent(QCloseEvent * e) -{ - form_->slotWMHide(); - e->accept(); + bc().setPolicy(ButtonPolicy::OkCancelPolicy); + bc().setCancel(closePB); } -///////////////////////////////////////////////////////////////////// -// -// GuiShowFile -// -///////////////////////////////////////////////////////////////////// +void GuiShowFile::updateContents() +{ + setWindowTitle(onlyFilename(toqstr(filename_.absFilename()))); + QString contents = toqstr(filename_.fileContents("UTF-8")); + if (contents.isEmpty()) + contents = qt_("Error -> Cannot load file!"); -GuiShowFile::GuiShowFile(GuiDialog & parent) - : GuiView(parent, _("Show File")) -{ + textTB->setPlainText(contents); } -void GuiShowFile::build_dialog() +bool GuiShowFile::initialiseParams(string const & data) { - dialog_.reset(new GuiShowFileDialog(this)); - - bc().setCancel(dialog_->closePB); + filename_ = FileName(data); + return true; } -void GuiShowFile::update_contents() +void GuiShowFile::clearParams() { - dialog_->setWindowTitle(toqstr(controller().getFileName())); + filename_.erase(); +} - std::string contents = controller().getFileContents(); - if (contents.empty()) { - contents = "Error -> Cannot load file!"; - } - dialog_->textTB->setPlainText(toqstr(contents)); -} +Dialog * createGuiShowFile(GuiView & lv) { return new GuiShowFile(lv); } + } // namespace frontend } // namespace lyx -#include "GuiShowFile_moc.cpp" +#include "moc_GuiShowFile.cpp"