]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBibtex.cpp
QDialogButtonBox for the remaining dialogs.
[lyx.git] / src / frontends / qt4 / GuiBibtex.cpp
index 3d958c5102ae902fbd1477a084065cb4d884eb6d..6d1c8c12a5056b4f97d0d4cc1a9210084e59f6fa 100644 (file)
@@ -39,6 +39,7 @@
 #include "support/gettext.h"
 #include "support/lstrings.h"
 
+#include <QDialogButtonBox>
 #include <QPushButton>
 #include <QListWidget>
 #include <QCheckBox>
@@ -60,10 +61,8 @@ GuiBibtex::GuiBibtex(GuiView & lv)
        QDialog::setModal(true);
        setWindowModality(Qt::WindowModal);
 
-       connect(okPB, SIGNAL(clicked()),
-               this, SLOT(slotOK()));
-       connect(closePB, SIGNAL(clicked()),
-               this, SLOT(slotClose()));
+       connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
+               this, SLOT(slotButtonBox(QAbstractButton *)));
        connect(stylePB, SIGNAL(clicked()),
                this, SLOT(browsePressed()));
        connect(deletePB, SIGNAL(clicked()),
@@ -91,16 +90,14 @@ GuiBibtex::GuiBibtex(GuiView & lv)
 
        add_ = new GuiBibtexAddDialog(this);
        add_bc_.setPolicy(ButtonPolicy::OkCancelPolicy);
-       add_bc_.setOK(add_->addPB);
-       add_bc_.setCancel(add_->closePB);
+       add_bc_.setOK(add_->buttonBox->button(QDialogButtonBox::Ok));
+       add_bc_.setCancel(add_->buttonBox->button(QDialogButtonBox::Cancel));
        add_bc_.addCheckedLineEdit(add_->bibED, 0);
 
        connect(add_->bibED, SIGNAL(textChanged(QString)),
                this, SLOT(bibEDChanged()));
-       connect(add_->addPB, SIGNAL(clicked()),
-               this, SLOT(addDatabase()));
-       connect(add_->addPB, SIGNAL(clicked()),
-               add_, SLOT(accept()));
+       connect(add_->buttonBox, SIGNAL(clicked(QAbstractButton *)),
+               this, SLOT(addBBClicked(QAbstractButton *)));
        connect(add_->rescanPB, SIGNAL(clicked()),
                this, SLOT(rescanClicked()));
        connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
@@ -111,16 +108,15 @@ GuiBibtex::GuiBibtex(GuiView & lv)
                this, SLOT(availableChanged()));
        connect(add_->browsePB, SIGNAL(clicked()),
                this, SLOT(browseBibPressed()));
-       connect(add_->closePB, SIGNAL(clicked()),
-               add_, SLOT(reject()));
 
        add_->bibLW->setToolTip(formatToolTip(qt_("This list consists of all databases that are indexed by LaTeX and thus are found without a file path. "
                                    "This is usually everything in the bib/ subdirectory of LaTeX's texmf tree. "
                                    "If you want to reuse your own database, this is the place you should store it.")));
 
        bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
-       bc().setOK(okPB);
-       bc().setCancel(closePB);
+       bc().setOK(buttonBox->button(QDialogButtonBox::Ok));
+       bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
+       bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
        bc().addReadOnly(databaseLW);
        bc().addReadOnly(stylePB);
        bc().addReadOnly(styleCB);
@@ -148,6 +144,22 @@ GuiBibtex::GuiBibtex(GuiView & lv)
 }
 
 
+void GuiBibtex::addBBClicked(QAbstractButton * button)
+{
+       switch (add_->buttonBox->standardButton(button)) {
+       case QDialogButtonBox::Ok:
+               addDatabase();
+               add_->accept();
+               break;
+       case QDialogButtonBox::Cancel:
+               add_->reject();
+               break;
+       default:
+               break;
+       }
+}
+
+
 void GuiBibtex::bibEDChanged()
 {
        // Indicate to the button controller that the contents have
@@ -378,9 +390,7 @@ void GuiBibtex::updateContents()
        biblatexOptsLE->setVisible(biblatex);
 
        // only useful for BibTeX
-       styleCB->setVisible(!biblatex);
-       styleLA->setVisible(!biblatex);
-       stylePB->setVisible(!biblatex);
+       bstGB->setVisible(!biblatex);
 
        if (!biblatex) {
                styleCB->clear();