#include <config.h>
#include "GuiDialog.h"
+
#include "GuiView.h"
#include "qt_helpers.h"
#include "support/debug.h"
#include <QCloseEvent>
-#include <QMainWindow>
-#include <QSettings>
-#include <QShowEvent>
using namespace std;
namespace lyx {
namespace frontend {
-GuiDialog::GuiDialog(GuiView & lv, std::string const & name)
- : DialogView(lv, name), is_closing_(false)
+GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
+ : QDialog(&lv), Dialog(lv, name, "LyX: " + title), updating_(false),
+ is_closing_(false)
{}
+void GuiDialog::closeEvent(QCloseEvent * ev)
+{
+ slotClose();
+ ev->accept();
+}
+
+
void GuiDialog::setButtonsValid(bool valid)
{
bc().setValid(valid);
}
+void GuiDialog::slotAutoApply()
+{
+ apply();
+ bc().autoApply();
+}
+
+
void GuiDialog::slotOK()
{
is_closing_ = true;
apply();
is_closing_ = false;
- QDialog::hide();
+ hideView();
bc().ok();
}
void GuiDialog::slotClose()
{
- QDialog::hide();
+ hideView();
bc().cancel();
}
void GuiDialog::enableView(bool enable)
{
- bc().setReadOnly(!enable);
- bc().setValid(enable);
- DialogView::enableView(enable);
+ if (!enable) {
+ bc().setReadOnly(true);
+ bc().setValid(false);
+ }
+ Dialog::enableView(enable);
}
} // namespace frontend
} // namespace lyx
-
-/////////////////////////////////////////////////////////////////////
-//
-// Command based dialogs
-//
-/////////////////////////////////////////////////////////////////////
-
-#include "FuncRequest.h"
-#include "insets/InsetCommand.h"
-
-using namespace std;
-
-namespace lyx {
-namespace frontend {
-
-GuiCommand::GuiCommand(GuiView & lv, string const & name)
- : GuiDialog(lv, name), params_(insetCode(name)), lfun_name_(name)
-{
-}
-
-
-bool GuiCommand::initialiseParams(string const & data)
-{
- // The name passed with LFUN_INSET_APPLY is also the name
- // used to identify the mailer.
- InsetCommandMailer::string2params(lfun_name_, data, params_);
- return true;
-}
-
-
-void GuiCommand::dispatchParams()
-{
- if (lfun_name_.empty())
- return;
-
- string const lfun =
- InsetCommandMailer::params2string(lfun_name_, params_);
- dispatch(FuncRequest(getLfun(), lfun));
-}
-
-} // namespace frontend
-} // namespace lyx
-
-#include "GuiDialog_moc.cpp"
+#include "moc_GuiDialog.cpp"