X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fcontrollers%2FDialog.C;h=6c0aee8d2cbad378cd92b2d35ab03d8b7caf9515;hb=98ebb778411f39db1d144234b5b8bb944c3c05b2;hp=977379089a5faca6b6123ddde786c8b73f4ec857;hpb=2a31934f38d624bef25c0b177852233eee9768f0;p=lyx.git diff --git a/src/frontends/controllers/Dialog.C b/src/frontends/controllers/Dialog.C index 977379089a..6c0aee8d2c 100644 --- a/src/frontends/controllers/Dialog.C +++ b/src/frontends/controllers/Dialog.C @@ -1,5 +1,5 @@ /** - * \file Dialog.C + * \file Dialog.cpp * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -15,6 +15,13 @@ #include "ButtonController.h" #include "BCView.h" +#include "frontends/LyXView.h" + +#include "funcrequest.h" +#include "FuncStatus.h" +#include "lyxfunc.h" + +using lyx::docstring; using std::string; @@ -167,11 +174,45 @@ void Dialog::setView(View * v) } +void Dialog::checkStatus() +{ + // buffer independant dialogs are always active. + // This check allows us leave canApply unimplemented for some dialogs. + if (!controller().isBufferDependent()) + return; + + // deactivate the dialog if we have no buffer + if (!kernel().isBufferAvailable()) { + bc().readOnly(true); + return; + } + + // check whether this dialog may be active + if (controller().canApply()) { + bool const readonly = kernel().isBufferReadonly(); + bc().readOnly(readonly); + // refreshReadOnly() is too generous in _enabling_ widgets + // update dialog to disable disabled widgets again + if (!readonly) + view().update(); + } else + bc().readOnly(true); +} + + Dialog::Controller::Controller(Dialog & parent) : parent_(parent) {} +bool Dialog::Controller::canApply() const +{ + FuncRequest const fr(getLfun(), dialog().name()); + FuncStatus const fs(lyx::getStatus(fr)); + return fs.enabled(); +} + + Dialog::Controller & Dialog::controller() const { BOOST_ASSERT(controller_ptr_.get()); @@ -179,7 +220,7 @@ Dialog::Controller & Dialog::controller() const } -Dialog::View::View(Dialog & parent, string title) : +Dialog::View::View(Dialog & parent, docstring title) : p_(parent), title_(title) {} @@ -191,13 +232,13 @@ Dialog::View & Dialog::view() const } -void Dialog::View::setTitle(string const & newtitle) +void Dialog::View::setTitle(docstring const & newtitle) { title_ = newtitle; } -string const & Dialog::View::getTitle() const +docstring const & Dialog::View::getTitle() const { return title_; }