3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "QListings.h"
15 #include "qt_helpers.h"
16 #include "controllers/ControlListings.h"
17 #include "insets/InsetListingsParams.h"
20 #include "support/convert.h"
21 #include "support/lstrings.h"
24 #include <QCloseEvent>
25 #include <QPushButton>
33 /////////////////////////////////////////////////////////////////////
37 /////////////////////////////////////////////////////////////////////
40 QListingsDialog::QListingsDialog(QListings * form)
45 connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
46 connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
47 connect(inlineCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
48 connect(listingsED, SIGNAL(textChanged()), this, SLOT(change_adaptor()));
49 connect(listingsED, SIGNAL(textChanged()), this, SLOT(validate_listings_params()));
53 void QListingsDialog::closeEvent(QCloseEvent * e)
60 void QListingsDialog::change_adaptor()
66 void QListingsDialog::validate_listings_params()
68 static bool isOK = true;
70 InsetListingsParams par(fromqstr(listingsED->toPlainText()));
73 // listingsTB->setTextColor("black");
74 listingsTB->setPlainText("Input listings parameters below. Enter ? for a list of parameters.");
75 okPB->setEnabled(true);
77 } catch (invalidParam & e) {
79 // listingsTB->setTextColor("red");
80 listingsTB->setPlainText(e.what());
81 okPB->setEnabled(false);
85 /////////////////////////////////////////////////////////////////////
89 /////////////////////////////////////////////////////////////////////
91 typedef QController<ControlListings, QView<QListingsDialog> > listings_wrap_base_class;
93 QListings::QListings(Dialog & parent)
94 : listings_wrap_base_class(parent, _("Program Listings Settings"))
99 void QListings::build_dialog()
101 dialog_.reset(new QListingsDialog(this));
103 bcview().setOK(dialog_->okPB);
104 bcview().setCancel(dialog_->closePB);
105 dialog_->listingsTB->setPlainText("Input listings parameters below. Enter ? for a list of parameters.");
111 /// not used right now.
112 void QListings::apply()
114 InsetListingsParams & params = controller().params();
115 params.setInline(dialog_->inlineCB->isChecked());
116 params.setParams(fromqstr(dialog_->listingsED->toPlainText()));
117 controller().setParams(params);
121 void QListings::update_contents()
123 InsetListingsParams & params = controller().params();
124 dialog_->listingsED->setPlainText(toqstr(params.separatedParams()));
126 if (params.isInline())
127 dialog_->inlineCB->setChecked(true);
129 dialog_->inlineCB->setChecked(false);
133 } // namespace frontend
137 #include "QListings_moc.cpp"