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 20:52:20 +02:00
|
|
|
#include "support/debug.h"
|
|
|
|
|
2007-09-28 09:45:50 +00:00
|
|
|
#include <QCloseEvent>
|
2018-07-08 16:35:38 +02:00
|
|
|
#include <QDialogButtonBox>
|
2007-09-28 09:45:50 +00:00
|
|
|
|
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)
|
2020-08-09 13:00:41 -04:00
|
|
|
: QDialog(&lv), Dialog(lv, name, title), updating_(false),
|
2009-07-14 16:01:55 +00:00
|
|
|
is_closing_(false)
|
2016-10-03 20:20:16 +02:00
|
|
|
{
|
2016-09-28 21:33:44 +02:00
|
|
|
connect(&lv, SIGNAL(bufferViewChanged()),
|
2016-11-09 23:37:35 +01:00
|
|
|
this, SLOT(onBufferViewChanged()));
|
2016-09-28 21:33:44 +02:00
|
|
|
|
2016-10-03 20:20:16 +02:00
|
|
|
// remove question marks from Windows dialogs
|
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
}
|
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
|
|
|
|
2018-07-08 16:35:38 +02:00
|
|
|
void GuiDialog::slotButtonBox(QAbstractButton * button)
|
|
|
|
{
|
|
|
|
QDialogButtonBox * bbox = qobject_cast<QDialogButtonBox*>(sender());
|
|
|
|
switch (bbox->standardButton(button)) {
|
|
|
|
case QDialogButtonBox::Ok:
|
|
|
|
slotOK();
|
|
|
|
break;
|
|
|
|
case QDialogButtonBox::Apply:
|
|
|
|
slotApply();
|
|
|
|
break;
|
|
|
|
case QDialogButtonBox::Cancel:
|
2018-07-10 09:04:42 +02:00
|
|
|
case QDialogButtonBox::Close:
|
2018-07-08 16:35:38 +02:00
|
|
|
slotClose();
|
|
|
|
break;
|
|
|
|
case QDialogButtonBox::Reset:
|
|
|
|
slotRestore();
|
|
|
|
break;
|
2018-12-17 12:59:40 +01:00
|
|
|
case QDialogButtonBox::RestoreDefaults:
|
|
|
|
slotRestoreDefaults();
|
|
|
|
break;
|
2018-07-08 16:35:38 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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"
|