2007-09-03 05:59:32 +00:00
|
|
|
/**
|
|
|
|
* \file Dialog.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GuiDialog.h"
|
2008-04-20 08:19:26 +00:00
|
|
|
|
2007-11-26 23:42:51 +00:00
|
|
|
#include "GuiView.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
#include "qt_helpers.h"
|
2008-03-05 20:11:47 +00:00
|
|
|
|
2012-06-28 18:52:20 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
|
2007-09-28 09:45:50 +00:00
|
|
|
#include <QCloseEvent>
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-09-03 05:59:32 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2008-03-05 20:11:47 +00:00
|
|
|
GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
|
2009-07-14 16:01:55 +00:00
|
|
|
: QDialog(&lv), Dialog(lv, name, "LyX: " + title), updating_(false),
|
|
|
|
is_closing_(false)
|
2007-10-09 19:34:27 +00:00
|
|
|
{}
|
2007-09-10 22:32:59 +00:00
|
|
|
|
|
|
|
|
2008-03-05 20:11:47 +00:00
|
|
|
void GuiDialog::closeEvent(QCloseEvent * ev)
|
2008-02-17 20:16:14 +00:00
|
|
|
{
|
|
|
|
slotClose();
|
2008-03-05 20:11:47 +00:00
|
|
|
ev->accept();
|
2008-02-17 20:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
void GuiDialog::setButtonsValid(bool valid)
|
|
|
|
{
|
|
|
|
bc().setValid(valid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-11 17:06:15 +00:00
|
|
|
void GuiDialog::slotApply()
|
2007-09-03 05:59:32 +00:00
|
|
|
{
|
2007-12-09 23:16:07 +00:00
|
|
|
apply();
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().apply();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-18 14:33:51 +00:00
|
|
|
void GuiDialog::slotAutoApply()
|
|
|
|
{
|
|
|
|
apply();
|
|
|
|
bc().autoApply();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-11 17:06:15 +00:00
|
|
|
void GuiDialog::slotOK()
|
2007-09-03 05:59:32 +00:00
|
|
|
{
|
|
|
|
is_closing_ = true;
|
2007-12-09 23:16:07 +00:00
|
|
|
apply();
|
2007-09-03 05:59:32 +00:00
|
|
|
is_closing_ = false;
|
2008-03-02 15:19:03 +00:00
|
|
|
hideView();
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().ok();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-11 17:06:15 +00:00
|
|
|
void GuiDialog::slotClose()
|
2007-09-03 05:59:32 +00:00
|
|
|
{
|
2008-03-02 15:06:55 +00:00
|
|
|
hideView();
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().cancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-11 17:06:15 +00:00
|
|
|
void GuiDialog::slotRestore()
|
2007-09-03 05:59:32 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
// Tell the controller that a request to refresh the dialog's contents
|
|
|
|
// has been received. It's up to the controller to supply the necessary
|
2007-09-03 20:28:26 +00:00
|
|
|
// info by calling GuiDialog::updateView().
|
2007-11-23 10:45:14 +00:00
|
|
|
updateDialog();
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().restore();
|
|
|
|
}
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2007-12-09 22:35:04 +00:00
|
|
|
void GuiDialog::changed()
|
2007-09-05 20:33:29 +00:00
|
|
|
{
|
2007-12-09 22:35:04 +00:00
|
|
|
if (updating_)
|
2007-09-05 20:33:29 +00:00
|
|
|
return;
|
2007-12-09 22:35:04 +00:00
|
|
|
bc().setValid(isValid());
|
2007-09-05 20:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-09 22:35:04 +00:00
|
|
|
void GuiDialog::enableView(bool enable)
|
2007-09-05 20:33:29 +00:00
|
|
|
{
|
2008-05-15 08:06:32 +00:00
|
|
|
if (!enable) {
|
|
|
|
bc().setReadOnly(true);
|
|
|
|
bc().setValid(false);
|
|
|
|
}
|
2008-02-05 10:53:31 +00:00
|
|
|
Dialog::enableView(enable);
|
2007-09-05 20:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiDialog::updateView()
|
|
|
|
{
|
|
|
|
setUpdatesEnabled(false);
|
|
|
|
|
2007-12-09 22:35:04 +00:00
|
|
|
bc().setReadOnly(isBufferReadonly());
|
2007-09-05 20:33:29 +00:00
|
|
|
// protect the BC from unwarranted state transitions
|
|
|
|
updating_ = true;
|
2007-09-11 18:33:42 +00:00
|
|
|
updateContents();
|
2007-09-05 20:33:29 +00:00
|
|
|
updating_ = false;
|
2007-09-10 22:32:59 +00:00
|
|
|
// The widgets may not be valid, so refresh the button controller
|
|
|
|
bc().refresh();
|
|
|
|
|
2007-12-09 22:35:04 +00:00
|
|
|
setUpdatesEnabled(true);
|
2007-09-28 09:45:50 +00:00
|
|
|
}
|
2007-09-27 14:35:12 +00:00
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiDialog.cpp"
|