* Licence details can be found in the file COPYING.
*
* \author Bo Peng
- * \author Jürgen Spitzmüller
+ * \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#include "GuiListings.h"
#include "qt_helpers.h"
+
#include "FuncRequest.h"
+
#include "insets/InsetListings.h"
#include "insets/InsetListingsParams.h"
-#include "support/debug.h"
+#include "support/convert.h"
+#include "support/debug.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
#include <QLineEdit>
-#include <QCloseEvent>
#include <QPushButton>
#include <QValidator>
#include <QRegExpValidator>
GuiListings::GuiListings(GuiView & lv)
- : GuiDialog(lv, "listings")
+ : GuiDialog(lv, "listings", qt_("Program Listing Settings"))
{
setupUi(this);
- setViewTitle(_("Program Listing Settings"));
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
this, SLOT(change_adaptor()));
connect(spaceInStringCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ connect(tabsizeSB, SIGNAL(valueChanged(int)),
+ this, SLOT(change_adaptor()));
connect(extendedcharsCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(listingsED, SIGNAL(textChanged()),
this, SLOT(change_adaptor()));
connect(listingsED, SIGNAL(textChanged()),
- this, SLOT(set_listings_msg()));
+ this, SLOT(setListingsMsg()));
connect(bypassCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(bypassCB, SIGNAL(clicked()),
- this, SLOT(set_listings_msg()));
+ this, SLOT(setListingsMsg()));
for (int n = 0; languages[n][0]; ++n)
languageCO->addItem(qt_(languages_gui[n]));
lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
+ bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setApply(applyPB);
bc().setCancel(closePB);
}
-void GuiListings::closeEvent(QCloseEvent * e)
-{
- slotClose();
- e->accept();
-}
-
-
void GuiListings::change_adaptor()
{
changed();
string GuiListings::construct_params()
{
- string language = languages[languageCO->currentIndex()];
+ string language = languages[qMax(0, languageCO->currentIndex())];
string dialect;
string const dialect_gui = fromqstr(dialectCO->currentText());
if (dialectCO->currentIndex() > 0) {
placement = fromqstr(placementLE->text());
string numberSide;
- switch (numberSideCO->currentIndex()) {
+ switch (qMax(0, numberSideCO->currentIndex())) {
case 0:
numberSide = "none";
break;
break;
}
string stepnumber = fromqstr(numberStepLE->text());
- string numberfontsize = font_sizes[numberFontSizeCO->currentIndex()];
+ string numberfontsize = font_sizes[qMax(0, numberFontSizeCO->currentIndex())];
string firstline = fromqstr(firstlineLE->text());
string lastline = fromqstr(lastlineLE->text());
- string fontsize = font_sizes[fontsizeCO->currentIndex()];
- string fontstyle = font_styles[fontstyleCO->currentIndex()];
+ string fontsize = font_sizes[qMax(0, fontsizeCO->currentIndex())];
+ string fontstyle = font_styles[qMax(0, fontstyleCO->currentIndex())];
string basicstyle;
if (fontsize != "default")
basicstyle = "\\" + fontsize;
basicstyle += "\\" + fontstyle;
bool breakline = breaklinesCB->isChecked();
bool space = spaceCB->isChecked();
+ int tabsize = tabsizeSB->value();
bool spaceInString = spaceInStringCB->isChecked();
bool extendedchars = extendedcharsCB->isChecked();
string extra = fromqstr(listingsED->toPlainText());
par.addParam("showspaces", "true");
if (!spaceInString)
par.addParam("showstringspaces", "false");
+ if (tabsize != 8)
+ par.addParam("tabsize", convert<string>(tabsize));
if (extendedchars)
par.addParam("extendedchars", "true");
par.addParams(extra);
}
-void GuiListings::set_listings_msg()
+void GuiListings::setListingsMsg()
{
static bool isOK = true;
docstring msg = validate_listings_params();
breaklinesCB->setChecked(false);
spaceCB->setChecked(false);
spaceInStringCB->setChecked(true);
+ tabsizeSB->setValue(8);
extendedcharsCB->setChecked(false);
// set values from param string
} else if (prefixIs(*it, "showstringspaces=")) {
spaceInStringCB->setChecked(contains(*it, "true"));
*it = "";
+ } else if (prefixIs(*it, "tabsize=")) {
+ tabsizeSB->setValue(convert<int>(plainParam(it->substr(8))));
+ *it = "";
} else if (prefixIs(*it, "extendedchars=")) {
extendedcharsCB->setChecked(contains(*it, "true"));
*it = "";
bool GuiListings::initialiseParams(string const & data)
{
- InsetListingsMailer::string2params(data, params_);
+ InsetListings::string2params(data, params_);
return true;
}
void GuiListings::dispatchParams()
{
- string const lfun = InsetListingsMailer::params2string(params_);
+ string const lfun = InsetListings::params2string(params_);
dispatch(FuncRequest(getLfun(), lfun));
}
} // namespace lyx
-#include "GuiListings_moc.cpp"
+#include "moc_GuiListings.cpp"