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"
|
2007-11-26 23:42:51 +00:00
|
|
|
#include "GuiView.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-09-10 22:32:59 +00:00
|
|
|
|
2007-12-09 22:35:04 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
|
2007-09-28 09:45:50 +00:00
|
|
|
#include <QCloseEvent>
|
2007-11-26 23:42:51 +00:00
|
|
|
#include <QMainWindow>
|
2007-09-28 09:45:50 +00:00
|
|
|
#include <QSettings>
|
|
|
|
#include <QShowEvent>
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
using std::string;
|
2007-09-03 05:59:32 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiDialog::GuiDialog(GuiView & lv, std::string const & name)
|
2007-12-09 22:35:04 +00:00
|
|
|
: DialogView(lv, name), is_closing_(false)
|
2007-10-09 19:34:27 +00:00
|
|
|
{}
|
2007-09-10 22:32:59 +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 22:35:04 +00:00
|
|
|
applyView();
|
2007-09-03 05:59:32 +00:00
|
|
|
bc().apply();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 22:35:04 +00:00
|
|
|
applyView();
|
2007-09-03 05:59:32 +00:00
|
|
|
is_closing_ = false;
|
2007-09-05 20:33:29 +00:00
|
|
|
QDialog::hide();
|
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
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
QDialog::hide();
|
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
|
|
|
{
|
2007-12-09 22:35:04 +00:00
|
|
|
bc().setReadOnly(!enable);
|
|
|
|
bc().setValid(enable);
|
|
|
|
DialogView::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-09-03 05:59:32 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Command based dialogs
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "FuncRequest.h"
|
|
|
|
#include "insets/InsetCommand.h"
|
|
|
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiCommand::GuiCommand(GuiView & lv, string const & name)
|
2007-10-19 17:22:55 +00:00
|
|
|
: GuiDialog(lv, name), params_(insetCode(name)), lfun_name_(name)
|
2007-10-07 14:41:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
#include "GuiDialog_moc.cpp"
|