GuiDelimiter::GuiDelimiter(GuiView & lv) : GuiDialog(lv, "mathdelimiter", qt_("Math Delimiter")) { setupUi(this); connect(closePB, SIGNAL(clicked()), this, SLOT(accept())); setFocusProxy(leftLW); leftLW->setViewMode(QListView::IconMode); rightLW->setViewMode(QListView::IconMode); leftLW->setDragDropMode(QAbstractItemView::NoDragDrop); rightLW->setDragDropMode(QAbstractItemView::NoDragDrop); initMathSymbols(); typedef map<char_type, QListWidgetItem *> ListItems; ListItems list_items; // The last element is the empty one. int const end = nr_latex_delimiters - 1; for (int i = 0; i < end; ++i) { string const delim = latex_delimiters[i]; MathSymbol const & ms = mathSymbol(delim); QString symbol(ms.fontcode? QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode))); QListWidgetItem * lwi = new QListWidgetItem(symbol); lwi->setToolTip(toqstr(delim)); FontInfo lyxfont; lyxfont.setFamily(ms.fontfamily); lwi->setFont(frontend::getFont(lyxfont)); list_items[ms.unicode] = lwi; leftLW->addItem(lwi); } for (int i = 0; i != leftLW->count(); ++i) { MathSymbol const & ms = mathSymbol( fromqstr(leftLW->item(i)->toolTip())); rightLW->addItem(list_items[doMatch(ms.unicode)]->clone()); } // The last element is the empty one. leftLW->addItem(qt_("(None)")); rightLW->addItem(qt_("(None)")); sizeCO->addItem(qt_("Variable")); for (int i = 0; *biggui[i]; ++i) sizeCO->addItem(qt_(biggui[i])); on_leftLW_currentRowChanged(0); bc().setPolicy(ButtonPolicy::IgnorantPolicy); }
void GuiShowFile::updateContents() { setWindowTitle(onlyFileName(toqstr(filename_.absFileName()))); QString contents = toqstr(filename_.fileContents("UTF-8")); if (contents.isEmpty()) contents = qt_("Error -> Cannot load file!"); textTB->setPlainText(contents); }
GuiShowFile::GuiShowFile(GuiView & lv) : GuiDialog(lv, "file", qt_("Show File")) { setupUi(this); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); bc().setPolicy(ButtonPolicy::OkCancelPolicy); bc().setCancel(closePB); }
void GuiBibitem::paramsToDialog(Inset const * inset) { InsetCommand const * ic = static_cast<InsetCommand const *>(inset); InsetCommandParams const & params = ic->params(); keyED->setText(toqstr(params["key"])); literalCB->setChecked(params["literal"] == "true"); QString const label = toqstr(params["label"]); if (inset->buffer().masterParams().citeEngine() == "natbib") { yearED->setHidden(false); yearLA->setHidden(false); allAuthorsED->setHidden(false); allAuthorsLA->setHidden(false); labelLA->setText(qt_("Author &Names:")); labelLA->setMaximumWidth(labelLA->sizeHint().width()); labelED->setToolTip(qt_("Insert the author name(s) for the author-year reference here. " "If you use an abbreviated list (with `et al.'), the full list can go below.")); allAuthorsLA->setText(qt_("A&ll Author Names:")); allAuthorsLA->setMaximumWidth(allAuthorsLA->sizeHint().width()); literalCB->setToolTip(qt_("Pass content of the `Author', `Year' and `All Authors' fields literally to LaTeX. " "Check this if you want to enter LaTeX code.")); int const i = label.lastIndexOf("("); int const j = label.lastIndexOf(")"); if (i != -1 && j != -1 && i < j) { // Split Author(s) and Year // Natbib syntax is "Jones et al.(1990)Jones, Baker, and Williams" // (full list is optional) QString const year = label.left(j).mid(i + 1); QString const author = label.left(i); QString const allauthors = label.mid(j + 1); labelED->setText(author); yearED->setText(year); allAuthorsED->setText(allauthors); } else labelED->setText(label); } else { yearED->setHidden(true); yearLA->setHidden(true); allAuthorsED->setHidden(true); allAuthorsLA->setHidden(true); allAuthorsLA->setText(qt_("&Label:")); allAuthorsLA->setMaximumWidth(allAuthorsLA->sizeHint().width()); labelLA->setText(qt_("&Label:")); labelLA->setMaximumWidth(labelLA->sizeHint().width()); labelED->setToolTip(qt_("The label as it appears in the document")); labelED->setText(label); literalCB->setToolTip(qt_("Pass content of the `Label' field literally to LaTeX. " "Check this if you want to enter LaTeX code.")); } }
GuiCompareHistory::GuiCompareHistory(GuiView & lv) : GuiDialog(lv, "comparehistory", qt_("Compare different revisions")) { setupUi(this); setModal(Qt::WindowModal); connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotCancel())); connect(revbackRB, SIGNAL(clicked()), this, SLOT(selectRevback())); connect(betweenrevRB, SIGNAL(clicked()), this, SLOT(selectBetweenrev())); }
GuiPrintNomencl::GuiPrintNomencl(GuiView & lv) : GuiDialog(lv, "nomencl_print", qt_("Nomenclature settings")), params_(insetCode("nomencl_print")) { setupUi(this); connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply())); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); connect(valueLE, SIGNAL(textChanged(QString)), this, SLOT(change_adaptor())); connect(unitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(change_adaptor())); valueLE->setValidator(unsignedLengthValidator(valueLE)); // Manage the ok, apply, restore and cancel/close buttons bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy); bc().setOK(okPB); bc().setApply(applyPB); bc().setCancel(closePB); // disable for read-only documents bc().addReadOnly(valueLE); bc().addReadOnly(unitLC); // initialize the length validator bc().addCheckedLineEdit(valueLE, valueLA); setWidthCO->addItem(qt_("Default"), QVariant(toqstr("none"))); setWidthCO->addItem(qt_("Longest label width"), QVariant(toqstr("auto"))); setWidthCO->addItem(qt_("Custom"), QVariant(toqstr("custom"))); }
QVariant data(QModelIndex const & index, int role) const { static QString const strCharacter = qt_("Character: "); static QString const strCodePoint = qt_("Code Point: "); static char codeName[10]; char_type c = symbols_.at(index.row()); if (role == Qt::TextAlignmentRole) return QVariant(Qt::AlignCenter); if (role == Qt::DisplayRole) return toqstr(c); if (role == Qt::ToolTipRole) { sprintf(codeName, "0x%04x", c); return strCharacter + toqstr(c) + '\n' + strCodePoint + QLatin1String(codeName); } //LYXERR0("role: " << role << " row: " << index.row()); return QVariant(); }
GuiPhantom::GuiPhantom(GuiView & lv) : GuiDialog(lv, "phantom", qt_("Phantom Settings")) { setupUi(this); connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); connect(phantomRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(hphantomRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(vphantomRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); bc().setOK(okPB); bc().setCancel(closePB); }
Length widgetsToLength(QLineEdit const * input, QComboBox const * combo) { QString const length = input->text(); if (length.isEmpty()) return Length(); // don't return unit-from-choice if the input(field) contains a unit if (isValidGlueLength(fromqstr(length))) return Length(fromqstr(length)); Length::UNIT unit = Length::UNIT_NONE; QString const item = combo->currentText(); for (int i = 0; i < num_units; i++) { if (qt_(lyx::unit_name_gui[i]) == item) { unit = unitFromString(unit_name[i]); break; } } return Length(locstringToDouble(length.trimmed()), unit); }
GuiNomenclature::GuiNomenclature(GuiView & lv) : GuiDialog(lv, "nomenclature", qt_("Nomenclature")), params_(insetCode("nomenclature")) { setupUi(this); connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); connect(symbolED, SIGNAL(textChanged(QString)), this, SLOT(change_adaptor())); connect(descriptionTE, SIGNAL(textChanged()), this, SLOT(change_adaptor())); setFocusProxy(descriptionTE); bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); bc().setOK(okPB); bc().setCancel(closePB); bc().addReadOnly(symbolED); bc().addReadOnly(descriptionTE); bc().addReadOnly(prefixED); }
GuiSymbols::GuiSymbols(GuiView & lv) : DialogView(lv, "symbols", qt_("Symbols")), encoding_("ascii"), model_(new Model(this)) { setupUi(this); setFocusProxy(symbolsLW); symbolsLW->setViewMode(QListView::IconMode); // increase the display size of the symbols a bit QFont font = symbolsLW->font(); const int size = font.pointSize() + 3; font.setPointSize(size); symbolsLW->setFont(font); QFontMetrics fm(font); const int cellHeight = fm.height() + 2; // FIXME: using at least cellHeight because of // QFontMetrics::maxWidth() is returning 0 with Qt/Cocoa on Mac OS const int cellWidth = max(cellHeight, fm.maxWidth() + 2); symbolsLW->setGridSize(QSize(cellWidth, cellHeight)); symbolsLW->setModel(model_); }
GuiSearch::GuiSearch(GuiView & lv) : GuiDialog(lv, "findreplace", qt_("Find and Replace")) { setupUi(this); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); connect(findPB, SIGNAL(clicked()), this, SLOT(findClicked())); connect(replacePB, SIGNAL(clicked()), this, SLOT(replaceClicked())); connect(replaceallPB, SIGNAL(clicked()), this, SLOT(replaceallClicked())); connect(findCO, SIGNAL(editTextChanged(QString)), this, SLOT(findChanged())); setFocusProxy(findCO); bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); bc().setCancel(closePB); bc().addReadOnly(replaceCO); bc().addReadOnly(replacePB); bc().addReadOnly(replaceallPB); replacePB->setEnabled(false); replaceallPB->setEnabled(false); }
void GuiDelimiter::updateTeXCode(int size) { bool const bigsize = size != 0; QString left_str = fix_name(leftLW->currentItem()->toolTip(), bigsize); QString right_str = fix_name(rightLW->currentItem()->toolTip(), bigsize); if (!bigsize) tex_code_ = left_str + ' ' + right_str; else { tex_code_ = bigleft[size] + ' ' + left_str + ' ' + bigright[size] + ' ' + right_str; } // Generate TeX-code for GUI display. // FIXME: Instead of reconstructing the TeX code it would be nice to // FIXME: retrieve the LateX code directly from mathed. // In all cases, we want the '\' prefix if needed, so we pass 'true' // to fix_name. left_str = fix_name(leftLW->currentItem()->toolTip(), true); right_str = fix_name(rightLW->currentItem()->toolTip(), true); QString code_str; if (!bigsize) code_str = "\\left" + left_str + " \\right" + right_str; else { // There should be nothing in the TeX-code when the delimiter is "None". if (left_str != ".") code_str = "\\" + bigleft[size] + left_str + ' '; if (right_str != ".") code_str += "\\" + bigright[size] + right_str; } texCodeL->setText(qt_("TeX Code: ") + code_str); }
void GuiSymbols::updateSymbolList(bool update_combo) { QString category = categoryCO->currentText(); bool const nocategory = category.isEmpty(); char_type range_start = 0x0000; char_type range_end = 0x110000; QList<char_type> s; if (update_combo) { used_blocks.clear(); categoryCO->clear(); } bool const show_all = categoryFilterCB->isChecked(); if (symbols_.empty() || update_combo) symbols_ = encodings.fromLyXName(encoding_)->symbolsList(); if (!show_all) { for (int i = 0 ; i < no_blocks; ++i) if (qt_(unicode_blocks[i].name) == category) { range_start = unicode_blocks[i].start; range_end = unicode_blocks[i].end; break; } } SymbolsList::const_iterator const end = symbols_.end(); int numItem = 0; for (SymbolsList::const_iterator it = symbols_.begin(); it != end; ++it) { char_type c = *it; if (!update_combo && !show_all && (c <= range_start || c >= range_end)) continue; QChar::Category const cat = QChar::category(uint(c)); // we do not want control or space characters if (cat == QChar::Other_Control || cat == QChar::Separator_Space) continue; ++numItem; if (show_all || (c >= range_start && c <= range_end)) s.append(c); if (update_combo) { QString block = getBlock(c); if (category.isEmpty()) category = block; if (used_blocks.find(block) == used_blocks.end()) used_blocks[block] = numItem; } } model_->setSymbols(s); if (update_combo) { // update category combo for (UsedBlocks::iterator it = used_blocks.begin(); it != used_blocks.end(); ++it) { categoryCO->addItem(it->first); } } int old = categoryCO->findText(category); if (old != -1) categoryCO->setCurrentIndex(old); // update again in case the combo has not yet been filled // on first cycle (at dialog initialization) if (nocategory && !category.isEmpty()) updateSymbolList(); }
QString guiName(string const & type, BufferParams const & bp) { if (type == "tableofcontents") return qt_("Table of Contents"); if (type == "child") return qt_("Child Documents"); if (type == "graphics") return qt_("Graphics"); if (type == "equation") return qt_("Equations"); if (type == "footnote") return qt_("Footnotes"); if (type == "listing") return qt_("Listings"); if (type == "index") return qt_("Index Entries"); if (type == "marginalnote") return qt_("Marginal notes"); if (type == "nomencl") return qt_("Nomenclature Entries"); if (type == "note") return qt_("Notes"); if (type == "citation") return qt_("Citations"); if (type == "label") return qt_("Labels and References"); if (type == "branch") return qt_("Branches"); if (type == "change") return qt_("Changes"); FloatList const & floats = bp.documentClass().floats(); if (floats.typeExist(type)) return qt_(floats.getType(type).listName()); return qt_(type); }
QString guiName(string const & type, BufferParams const & bp) { if (type == "tableofcontents") return qt_("Table of Contents"); if (type == "child") return qt_("Child Documents"); if (type == "graphics") return qt_("Graphics"); if (type == "equation") return qt_("Equations"); if (type == "footnote") return qt_("Footnotes"); if (type == "listing") return qt_("Listings"); if (type == "index") return qt_("Index Entries"); if (type == "marginalnote") return qt_("Marginal notes"); if (type == "nomencl") return qt_("Nomenclature Entries"); if (type == "note") return qt_("Notes"); if (type == "citation") return qt_("Citations"); if (type == "label") return qt_("Labels and References"); if (type == "branch") return qt_("Branches"); if (type == "change") return qt_("Changes"); if (prefixIs(type, "index:")) { string const itype = split(type, ':'); IndicesList const & indiceslist = bp.indiceslist(); Index const * index = indiceslist.findShortcut(from_utf8(itype)); docstring indextype = _("unknown type!"); if (index) indextype = index->index(); return toqstr(bformat(_("Index Entries (%1$s)"), indextype)); } FloatList const & floats = bp.documentClass().floats(); if (floats.typeExist(type)) return qt_(floats.getType(type).listName()); return qt_(type); }