]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiDialog.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiDialog.cpp
index 7b08bef7b49420f45580fdc3384c654e63743504..8778886e34138ebc75550e3f3e8f845ab69048af 100644 (file)
 
 #include "GuiView.h"
 #include "qt_helpers.h"
-#include "FuncRequest.h"
 
 #include "support/debug.h"
 
 #include <QCloseEvent>
+#include <QDialogButtonBox>
 
 using namespace std;
 
@@ -26,8 +26,15 @@ namespace lyx {
 namespace frontend {
 
 GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
-       : QDialog(&lv), Dialog(lv, name, "LyX: " + title), is_closing_(false)
-{}
+       : QDialog(&lv), Dialog(lv, name, "LyX: " + title), updating_(false),
+         is_closing_(false)
+{
+       connect(&lv, SIGNAL(bufferViewChanged()),
+               this, SLOT(onBufferViewChanged()));
+
+       // remove question marks from Windows dialogs
+       setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
+}
 
 
 void GuiDialog::closeEvent(QCloseEvent * ev)
@@ -50,6 +57,13 @@ void GuiDialog::slotApply()
 }
 
 
+void GuiDialog::slotAutoApply()
+{
+       apply();
+       bc().autoApply();
+}
+
+
 void GuiDialog::slotOK()
 {
        is_closing_ = true;
@@ -77,6 +91,32 @@ void GuiDialog::slotRestore()
 }
 
 
+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:
+       case QDialogButtonBox::Close:
+               slotClose();
+               break;
+       case QDialogButtonBox::Reset:
+               slotRestore();
+               break;
+       case QDialogButtonBox::RestoreDefaults:
+               slotRestoreDefaults();
+               break;
+       default:
+               break;
+       }
+}
+
+
 void GuiDialog::changed()
 {
        if (updating_)
@@ -87,7 +127,10 @@ void GuiDialog::changed()
 
 void GuiDialog::enableView(bool enable)
 {
-       bc().setReadOnly(!enable);
+       if (!enable) {
+               bc().setReadOnly(true);
+               bc().setValid(false);
+       }
        Dialog::enableView(enable);
 }
 
@@ -110,4 +153,4 @@ void GuiDialog::updateView()
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiDialog_moc.cpp"
+#include "moc_GuiDialog.cpp"