diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index e4d69e964e..b0fef11452 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -49,7 +49,6 @@ libqt4_la_SOURCES = \ QChanges.C QChanges.h \ QCharacter.C QCharacter.h \ QCitation.C QCitation.h \ - QDocument.C QDocument.h \ QDialogView.C QDialogView.h \ QErrorList.C QErrorList.h \ QExternal.C QExternal.h \ @@ -58,18 +57,15 @@ libqt4_la_SOURCES = \ QInclude.C QInclude.h \ QIndex.C QIndex.h \ QLImage.C QLImage.h \ - QLog.C QLog.h \ QViewSource.C QViewSource.h \ QLPainter.C QLPainter.h \ QLyXKeySym.C QLyXKeySym.h \ QNomencl.C QNomencl.h \ QNote.C QNote.h \ - QParagraph.C QParagraph.h \ QPrefs.C QPrefs.h \ QPrint.C QPrint.h \ QRef.C QRef.h \ QSendto.C QSendto.h \ - QShowFile.C QShowFile.h \ Qt2BC.C Qt2BC.h \ checkedwidgets.C checkedwidgets.h \ panelstack.h panelstack.C \ diff --git a/src/frontends/qt4/Makefile.dialogs b/src/frontends/qt4/Makefile.dialogs index 28e66f21d6..6ba0107039 100644 --- a/src/frontends/qt4/Makefile.dialogs +++ b/src/frontends/qt4/Makefile.dialogs @@ -98,7 +98,7 @@ MOCFILES = \ QCommandBuffer.C QCommandBuffer.h \ QCommandEdit.C QCommandEdit.h \ QDelimiterDialog.C QDelimiterDialog.h \ - QDocumentDialog.C QDocumentDialog.h \ + QDocument.C QDocument.h \ QErrorListDialog.C QErrorListDialog.h \ QERT.C QERT.h \ QExternalDialog.C QExternalDialog.h \ @@ -107,7 +107,6 @@ MOCFILES = \ QIncludeDialog.C QIncludeDialog.h \ QIndexDialog.C QIndexDialog.h \ QLog.C QLog.h \ - QLogDialog.C QLogDialog.h \ QViewSource.C QViewSource.h \ QLMenubar.C QLMenubar.h \ QLPopupMenu.C QLPopupMenu.h \ @@ -115,13 +114,13 @@ MOCFILES = \ QMathMatrixDialog.C QMathMatrixDialog.h \ QNomenclDialog.C QNomenclDialog.h \ QNoteDialog.C QNoteDialog.h \ - QParagraphDialog.C QParagraphDialog.h \ + QParagraph.C QParagraph.h \ QPrefsDialog.C QPrefsDialog.h \ QRefDialog.C QRefDialog.h \ QSearch.C QSearch.h \ QSendtoDialog.C QSendtoDialog.h \ qsetborder.C qsetborder.h \ - QShowFileDialog.C QShowFileDialog.h \ + QShowFile.C QShowFile.h \ QSpellchecker.C QSpellchecker.h \ QDialogView.C QDialogView.h \ QTabularCreate.C QTabularCreate.h \ diff --git a/src/frontends/qt4/QDocument.C b/src/frontends/qt4/QDocument.C index ef5de14e23..26ad575c1d 100644 --- a/src/frontends/qt4/QDocument.C +++ b/src/frontends/qt4/QDocument.C @@ -11,41 +11,1173 @@ #include #include "QDocument.h" -#include "QDocumentDialog.h" #include "Qt2BC.h" #include "qt_helpers.h" +#include "QBranches.h" + +#include + +#include "FloatPlacement.h" +#include "lengthcombo.h" +#include "validators.h" +#include "panelstack.h" +#include "Qt2BC.h" +#include "checkedwidgets.h" +#include "qt_helpers.h" + +// For latexHighlighter use in the preamble. +#include "QViewSource.h" #include "bufferparams.h" -#include "FloatPlacement.h" +#include "encoding.h" #include "gettext.h" #include "helper_funcs.h" // getSecond() #include "language.h" #include "lyxrc.h" // defaultUnit #include "lyxtextclasslist.h" +#include "tex-strings.h" // tex_graphics +#include "Spacing.h" + +#include "frontends/controllers/biblio.h" +#include "controllers/ControlDocument.h" +#include "controllers/frnt_lang.h" #include "support/lstrings.h" #include "controllers/ControlDocument.h" #include "controllers/frnt_lang.h" -#include "lengthcombo.h" - +using lyx::support::token; using lyx::support::bformat; +using lyx::support::findToken; using lyx::support::getVectorFromString; using std::distance; using std::vector; using std::string; + +///////////////////////////////////////////////////////////////////// +// +// DocumentDialog +// +///////////////////////////////////////////////////////////////////// + namespace lyx { namespace frontend { -typedef QController > document_base_class; + +QDocumentDialog::QDocumentDialog(QDocument * form) + : form_(form), + lang_(getSecond(getLanguageData(false))) +{ + setupUi(this); + + connect(okPB, SIGNAL(clicked()), + form, SLOT(slotOK())); + connect(applyPB, SIGNAL(clicked()), + form, SLOT(slotApply())); + connect(closePB, SIGNAL(clicked()), + form, SLOT(slotClose())); + connect(restorePB, SIGNAL(clicked()), + form, SLOT(slotRestore())); + + + connect(savePB, SIGNAL( clicked() ), + this, SLOT( saveDefaultClicked() ) ); + connect(defaultPB, SIGNAL( clicked() ), + this, SLOT( useDefaultsClicked() ) ); + + // Manage the restore, ok, apply, restore and cancel/close buttons + form_->bcview().setOK(okPB); + form_->bcview().setApply(applyPB); + form_->bcview().setCancel(closePB); + form_->bcview().setRestore(restorePB); + + + textLayoutModule = new UiWidget; + // text layout + connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(setLSpacing(int))); + connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(textLayoutModule->skipRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(textLayoutModule->indentRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(setSkip(int))); + connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(enableSkip(bool))); + connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + textLayoutModule->lspacingLE->setValidator(new QDoubleValidator( + textLayoutModule->lspacingLE)); + textLayoutModule->skipLE->setValidator(unsignedLengthValidator( + textLayoutModule->skipLE)); + + textLayoutModule->skipCO->addItem(qt_("SmallSkip")); + textLayoutModule->skipCO->addItem(qt_("MedSkip")); + textLayoutModule->skipCO->addItem(qt_("BigSkip")); + textLayoutModule->skipCO->addItem(qt_("Length")); + // remove the %-items from the unit choice + textLayoutModule->skipLengthCO->noPercents(); + textLayoutModule->lspacingCO->insertItem( + Spacing::Single, qt_("Single")); + textLayoutModule->lspacingCO->insertItem( + Spacing::Onehalf, qt_("OneHalf")); + textLayoutModule->lspacingCO->insertItem( + Spacing::Double, qt_("Double")); + textLayoutModule->lspacingCO->insertItem( + Spacing::Other, qt_("Custom")); + + // initialize the length validator + addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE); + + + + + fontModule = new UiWidget; + // fonts + connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(romanChanged(int))); + connect(fontModule->fontsSansCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(fontModule->fontsSansCO, SIGNAL(activated(int)), this, SLOT(sansChanged(int))); + connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)), this, SLOT(ttChanged(int))); + connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(fontModule->fontsizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); + connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); + connect(fontModule->fontScCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(fontModule->fontOsfCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + + for (int n = 0; tex_fonts_roman[n][0]; ++n) { + QString font = toqstr(tex_fonts_roman_gui[n]); + if (!form_->controller().isFontAvailable(tex_fonts_roman[n])) + font += qt_(" (not installed)"); + fontModule->fontsRomanCO->addItem(font); + } + for (int n = 0; tex_fonts_sans[n][0]; ++n) { + QString font = toqstr(tex_fonts_sans_gui[n]); + if (!form_->controller().isFontAvailable(tex_fonts_sans[n])) + font += qt_(" (not installed)"); + fontModule->fontsSansCO->addItem(font); + } + for (int n = 0; tex_fonts_monospaced[n][0]; ++n) { + QString font = toqstr(tex_fonts_monospaced_gui[n]); + if (!form_->controller().isFontAvailable(tex_fonts_monospaced[n])) + font += qt_(" (not installed)"); + fontModule->fontsTypewriterCO->addItem(font); + } + + fontModule->fontsizeCO->addItem(qt_("default")); + fontModule->fontsizeCO->addItem(qt_("10")); + fontModule->fontsizeCO->addItem(qt_("11")); + fontModule->fontsizeCO->addItem(qt_("12")); + + for (int n = 0; ControlDocument::fontfamilies_gui[n][0]; ++n) + fontModule->fontsDefaultCO->addItem( + qt_(ControlDocument::fontfamilies_gui[n])); + + + + + pageLayoutModule = new UiWidget; + // page layout + connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int))); + connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int))); + connect(pageLayoutModule->portraitRB, SIGNAL(clicked()), this, SLOT(portraitChanged())); + connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(pageLayoutModule->portraitRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + pageLayoutModule->pagestyleCO->addItem(qt_("default")); + pageLayoutModule->pagestyleCO->addItem(qt_("empty")); + pageLayoutModule->pagestyleCO->addItem(qt_("plain")); + pageLayoutModule->pagestyleCO->addItem(qt_("headings")); + pageLayoutModule->pagestyleCO->addItem(qt_("fancy")); + addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperheightLE, + pageLayoutModule->paperheightL); + addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperwidthLE, + pageLayoutModule->paperwidthL); + + // paper + QComboBox * cb = pageLayoutModule->papersizeCO; + cb->addItem(qt_("Default")); + cb->addItem(qt_("Custom")); + cb->addItem(qt_("US letter")); + cb->addItem(qt_("US legal")); + cb->addItem(qt_("US executive")); + cb->addItem(qt_("A3")); + cb->addItem(qt_("A4")); + cb->addItem(qt_("A5")); + cb->addItem(qt_("B3")); + cb->addItem(qt_("B4")); + cb->addItem(qt_("B5")); + // remove the %-items from the unit choice + pageLayoutModule->paperwidthUnitCO->noPercents(); + pageLayoutModule->paperheightUnitCO->noPercents(); + pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator( + pageLayoutModule->paperheightLE)); + pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator( + pageLayoutModule->paperwidthLE)); + + + + + marginsModule = new UiWidget; + // margins + connect(marginsModule->marginCB, SIGNAL(toggled(bool)), this, SLOT(setCustomMargins(bool))); + connect(marginsModule->marginCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(marginsModule->topLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(marginsModule->topUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(marginsModule->bottomUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(marginsModule->innerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(marginsModule->innerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(marginsModule->outerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(marginsModule->outerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(marginsModule->headheightUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(marginsModule->headsepUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(marginsModule->footskipUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + marginsModule->topLE->setValidator(unsignedLengthValidator( + marginsModule->topLE)); + marginsModule->bottomLE->setValidator(unsignedLengthValidator( + marginsModule->bottomLE)); + marginsModule->innerLE->setValidator(unsignedLengthValidator( + marginsModule->innerLE)); + marginsModule->outerLE->setValidator(unsignedLengthValidator( + marginsModule->outerLE)); + marginsModule->headsepLE->setValidator(unsignedLengthValidator( + marginsModule->headsepLE)); + marginsModule->headheightLE->setValidator(unsignedLengthValidator( + marginsModule->headheightLE)); + marginsModule->footskipLE->setValidator(unsignedLengthValidator( + marginsModule->footskipLE)); + + addCheckedLineEdit(form_->bcview(), marginsModule->topLE, + marginsModule->topL); + addCheckedLineEdit(form_->bcview(), marginsModule->bottomLE, + marginsModule->bottomL); + addCheckedLineEdit(form_->bcview(), marginsModule->innerLE, + marginsModule->innerL); + addCheckedLineEdit(form_->bcview(), marginsModule->outerLE, + marginsModule->outerL); + addCheckedLineEdit(form_->bcview(), marginsModule->headsepLE, + marginsModule->headsepL); + addCheckedLineEdit(form_->bcview(), marginsModule->headheightLE, + marginsModule->headheightL); + addCheckedLineEdit(form_->bcview(), marginsModule->footskipLE, + marginsModule->footskipL); + + + + + + langModule = new UiWidget; + connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), langModule->encodingL, SLOT(setDisabled(bool))); + connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), langModule->encodingCO, SLOT(setDisabled(bool))); + // language & quote + connect(langModule->languageCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(langModule->defaultencodingCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(langModule->encodingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(langModule->quoteStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + // language & quotes + vector const langs = getLanguageData(false); + vector::const_iterator lit = langs.begin(); + vector::const_iterator lend = langs.end(); + for (; lit != lend; ++lit) { + langModule->languageCO->addItem( + toqstr(lit->first)); + } + + // Always put the default encoding in the first position. + // It is special because the displayed text is translated. + langModule->encodingCO->addItem(qt_("LaTeX default")); + Encodings::const_iterator it = encodings.begin(); + Encodings::const_iterator const end = encodings.end(); + for (; it != end; ++it) + langModule->encodingCO->addItem(toqstr(it->latexName())); + + langModule->quoteStyleCO->addItem(qt_("``text''")); + langModule->quoteStyleCO->addItem(qt_("''text''")); + langModule->quoteStyleCO->addItem(qt_(",,text``")); + langModule->quoteStyleCO->addItem(qt_(",,text''")); + langModule->quoteStyleCO->addItem(qt_("<>")); + langModule->quoteStyleCO->addItem(qt_(">>text<<")); + + + + numberingModule = new UiWidget; + // numbering + connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); + connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); + connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering())); + connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering())); + numberingModule->tocTW->setColumnCount(3); + numberingModule->tocTW->headerItem()->setText(0, qt_("Example")); + numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered")); + numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC")); + + + biblioModule = new UiWidget; + connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citationStyleL, SLOT( setEnabled(bool) ) ); + connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citeStyleCO, SLOT( setEnabled(bool) ) ); + // biblio + connect(biblioModule->citeDefaultRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(biblioModule->citeNatbibRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(biblioModule->citeStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(biblioModule->citeJurabibRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(biblioModule->bibtopicCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + // biblio + biblioModule->citeStyleCO->addItem(qt_("Author-year")); + biblioModule->citeStyleCO->addItem(qt_("Numerical")); + biblioModule->citeStyleCO->setCurrentIndex(0); + + + + mathsModule = new UiWidget; + connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)), mathsModule->amsCB, SLOT(setDisabled(bool))); + connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)), mathsModule->esintCB, SLOT(setDisabled(bool))); + // maths + connect(mathsModule->amsCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(mathsModule->amsautoCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(mathsModule->esintCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(mathsModule->esintautoCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + + latexModule = new UiWidget; + // latex class + connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(latexModule->optionsLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); + connect(latexModule->psdriverCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(classChanged())); + // packages + for (int n = 0; tex_graphics[n][0]; ++n) { + QString enc = tex_graphics[n]; + latexModule->psdriverCO->addItem(enc); + } + // latex + for (LyXTextClassList::const_iterator cit = textclasslist.begin(); + cit != textclasslist.end(); ++cit) { + if (cit->isTeXClassAvailable()) { + latexModule->classCO->addItem(toqstr(cit->description())); + } else { + docstring item = + bformat(_("Unavailable: %1$s"), lyx::from_utf8(cit->description())); + latexModule->classCO->addItem(toqstr(item)); + } + } + + // branches + branchesModule = new QBranches; + connect(branchesModule, SIGNAL(changed()), this, SLOT(change_adaptor())); + + // preamble + preambleModule = new UiWidget; + connect(preambleModule->preambleTE, SIGNAL(textChanged()), + this, SLOT(change_adaptor())); + // This is not a memory leak. The object will be destroyed + // with preambleModule. + (void) new LaTeXHighlighter(preambleModule->preambleTE->document()); + + + // bullets + bulletsModule = new BulletsModule; + connect(bulletsModule, SIGNAL(changed()), this, SLOT(change_adaptor())); + + + // float + floatModule = new FloatPlacement; + connect(floatModule, SIGNAL(changed()), this, SLOT(change_adaptor())); + + docPS->addPanel(latexModule, _("Document Class")); + docPS->addPanel(fontModule, _("Fonts")); + docPS->addPanel(textLayoutModule, _("Text Layout")); + docPS->addPanel(pageLayoutModule, _("Page Layout")); + docPS->addPanel(marginsModule, _("Page Margins")); + docPS->addPanel(langModule, _("Language")); + docPS->addPanel(numberingModule, _("Numbering & TOC")); + docPS->addPanel(biblioModule, _("Bibliography")); + docPS->addPanel(mathsModule, _("Math Options")); + docPS->addPanel(floatModule, _("Float Placement")); + docPS->addPanel(bulletsModule, _("Bullets")); + docPS->addPanel(branchesModule, _("Branches")); + docPS->addPanel(preambleModule, _("LaTeX Preamble")); + docPS->setCurrentPanel(_("Document Class")); +// FIXME: hack to work around resizing bug in Qt >= 4.2 +// bug verified with Qt 4.2.{0-3} (JSpitzm) +#if QT_VERSION >= 0x040200 + docPS->updateGeometry(); +#endif +} + + +QDocumentDialog::~QDocumentDialog() +{ +} + + +void QDocumentDialog::showPreamble() +{ + docPS->setCurrentPanel(_("LaTeX Preamble")); +} + + +void QDocumentDialog::saveDefaultClicked() +{ + form_->saveDocDefault(); +} + + +void QDocumentDialog::useDefaultsClicked() +{ + form_->useClassDefaults(); +} + + +void QDocumentDialog::change_adaptor() +{ + form_->changed(); +} + + +void QDocumentDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + + +void QDocumentDialog::setLSpacing(int item) +{ + textLayoutModule->lspacingLE->setEnabled(item == 3); +} + + +void QDocumentDialog::setSkip(int item) +{ + bool const enable = (item == 3); + textLayoutModule->skipLE->setEnabled(enable); + textLayoutModule->skipLengthCO->setEnabled(enable); +} + + +void QDocumentDialog::enableSkip(bool skip) +{ + textLayoutModule->skipCO->setEnabled(skip); + textLayoutModule->skipLE->setEnabled(skip); + textLayoutModule->skipLengthCO->setEnabled(skip); + if (skip) + setSkip(textLayoutModule->skipCO->currentIndex()); +} + +void QDocumentDialog::portraitChanged() +{ + setMargins(pageLayoutModule->papersizeCO->currentIndex()); +} + +void QDocumentDialog::setMargins(bool custom) +{ + marginsModule->marginCB->setChecked(custom); + setCustomMargins(custom); +} + + +void QDocumentDialog::setCustomPapersize(int papersize) +{ + bool const custom = (papersize == 1); + + pageLayoutModule->paperwidthL->setEnabled(custom); + pageLayoutModule->paperwidthLE->setEnabled(custom); + pageLayoutModule->paperwidthUnitCO->setEnabled(custom); + pageLayoutModule->paperheightL->setEnabled(custom); + pageLayoutModule->paperheightLE->setEnabled(custom); + pageLayoutModule->paperheightLE->setFocus(); + pageLayoutModule->paperheightUnitCO->setEnabled(custom); +} + + +void QDocumentDialog::setCustomMargins(bool custom) +{ + marginsModule->topL->setEnabled(!custom); + marginsModule->topLE->setEnabled(!custom); + marginsModule->topUnit->setEnabled(!custom); + + marginsModule->bottomL->setEnabled(!custom); + marginsModule->bottomLE->setEnabled(!custom); + marginsModule->bottomUnit->setEnabled(!custom); + + marginsModule->innerL->setEnabled(!custom); + marginsModule->innerLE->setEnabled(!custom); + marginsModule->innerUnit->setEnabled(!custom); + + marginsModule->outerL->setEnabled(!custom); + marginsModule->outerLE->setEnabled(!custom); + marginsModule->outerUnit->setEnabled(!custom); + + marginsModule->headheightL->setEnabled(!custom); + marginsModule->headheightLE->setEnabled(!custom); + marginsModule->headheightUnit->setEnabled(!custom); + + marginsModule->headsepL->setEnabled(!custom); + marginsModule->headsepLE->setEnabled(!custom); + marginsModule->headsepUnit->setEnabled(!custom); + + marginsModule->footskipL->setEnabled(!custom); + marginsModule->footskipLE->setEnabled(!custom); + marginsModule->footskipUnit->setEnabled(!custom); +} + + +void QDocumentDialog::updateFontsize(string const & items, string const & sel) +{ + fontModule->fontsizeCO->clear(); + fontModule->fontsizeCO->addItem(qt_("default")); + + for (int n = 0; !token(items,'|',n).empty(); ++n) + fontModule->fontsizeCO-> + addItem(toqstr(token(items,'|',n))); + + for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) { + if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) { + fontModule->fontsizeCO->setCurrentIndex(n); + break; + } + } +} + + +void QDocumentDialog::romanChanged(int item) +{ + string const font = tex_fonts_roman[item]; + + fontModule->fontScCB->setEnabled( + form_->controller().providesSC(font)); + fontModule->fontOsfCB->setEnabled( + form_->controller().providesOSF(font)); +} + + +void QDocumentDialog::sansChanged(int item) +{ + string const font = tex_fonts_sans[item]; + bool scaleable = form_->controller().providesScale(font); + fontModule->scaleSansSB->setEnabled(scaleable); + fontModule->scaleSansLA->setEnabled(scaleable); +} + + +void QDocumentDialog::ttChanged(int item) +{ + string const font = tex_fonts_monospaced[item]; + bool scaleable = form_->controller().providesScale(font); + fontModule->scaleTypewriterSB->setEnabled(scaleable); + fontModule->scaleTypewriterLA->setEnabled(scaleable); +} + + +void QDocumentDialog::updatePagestyle(string const & items, string const & sel) +{ + pageLayoutModule->pagestyleCO->clear(); + pageLayoutModule->pagestyleCO->addItem("default"); + + for (int n=0; !token(items,'|',n).empty(); ++n) + pageLayoutModule->pagestyleCO-> + addItem(toqstr(token(items,'|',n))); + + for (int n = 0; npagestyleCO->count(); ++n) { + if (fromqstr(pageLayoutModule->pagestyleCO->itemText(n))==sel) { + pageLayoutModule->pagestyleCO->setCurrentIndex(n); + break; + } + } +} + + +void QDocumentDialog::classChanged() +{ + ControlDocument & cntrl = form_->controller(); + BufferParams & params = cntrl.params(); + + lyx::textclass_type const tc = latexModule->classCO->currentIndex(); + + if (form_->controller().loadTextclass(tc)) { + params.textclass = tc; + if (lyxrc.auto_reset_options) + params.useClassDefaults(); + form_->update_contents(); + } else { + latexModule->classCO->setCurrentIndex(params.textclass); + } +} + + +void QDocumentDialog::updateNumbering() +{ + LyXTextClass const & tclass = + form_->controller().params().getLyXTextClass(); + + numberingModule->tocTW->setUpdatesEnabled(false); + numberingModule->tocTW->clear(); + + int const depth = numberingModule->depthSL->value(); + int const toc = numberingModule->tocSL->value(); + QString const no = qt_("No"); + QString const yes = qt_("Yes"); + LyXTextClass::const_iterator end = tclass.end(); + LyXTextClass::const_iterator cit = tclass.begin(); + QTreeWidgetItem * item = 0; + for ( ; cit != end ; ++cit) { + int const toclevel = (*cit)->toclevel; + if (toclevel != LyXLayout::NOT_IN_TOC + && (*cit)->labeltype == LABEL_COUNTER) { + item = new QTreeWidgetItem(numberingModule->tocTW); + item->setText(0, qt_((*cit)->name())); + item->setText(1, (toclevel <= depth) ? yes : no); + item->setText(2, (toclevel <= toc) ? yes : no); + } + } + + numberingModule->tocTW->setUpdatesEnabled(true); + numberingModule->tocTW->update(); +} + +void QDocumentDialog::apply(BufferParams & params) +{ + // preamble + params.preamble = + fromqstr(preambleModule->preambleTE->document()->toPlainText()); + + // biblio + params.setCiteEngine(biblio::ENGINE_BASIC); + + if (biblioModule->citeNatbibRB->isChecked()) { + bool const use_numerical_citations = + biblioModule->citeStyleCO->currentIndex(); + if (use_numerical_citations) + params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL); + else + params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR); + + } else if (biblioModule->citeJurabibRB->isChecked()) + params.setCiteEngine(biblio::ENGINE_JURABIB); + + params.use_bibtopic = + biblioModule->bibtopicCB->isChecked(); + + // language & quotes + if (langModule->defaultencodingCB->isChecked()) { + params.inputenc = "auto"; + } else { + int i = langModule->encodingCO->currentIndex(); + if (i == 0) + params.inputenc = "default"; + else + params.inputenc = + fromqstr(langModule->encodingCO->currentText()); + } + + InsetQuotes::quote_language lga = InsetQuotes::EnglishQ; + switch (langModule->quoteStyleCO->currentIndex()) { + case 0: + lga = InsetQuotes::EnglishQ; + break; + case 1: + lga = InsetQuotes::SwedishQ; + break; + case 2: + lga = InsetQuotes::GermanQ; + break; + case 3: + lga = InsetQuotes::PolishQ; + break; + case 4: + lga = InsetQuotes::FrenchQ; + break; + case 5: + lga = InsetQuotes::DanishQ; + break; + } + params.quotes_language = lga; + + int const pos = langModule->languageCO->currentIndex(); + params.language = languages.getLanguage(lang_[pos]); + + // numbering + if (params.getLyXTextClass().hasTocLevels()) { + params.tocdepth = numberingModule->tocSL->value(); + params.secnumdepth = numberingModule->depthSL->value(); + } + + // bullets + params.user_defined_bullet(0) = bulletsModule->getBullet(0); + params.user_defined_bullet(1) = bulletsModule->getBullet(1); + params.user_defined_bullet(2) = bulletsModule->getBullet(2); + params.user_defined_bullet(3) = bulletsModule->getBullet(3); + + // packages + params.graphicsDriver = + fromqstr(latexModule->psdriverCO->currentText()); + + if (mathsModule->amsautoCB->isChecked()) { + params.use_amsmath = BufferParams::package_auto; + } else { + if (mathsModule->amsCB->isChecked()) + params.use_amsmath = BufferParams::package_on; + else + params.use_amsmath = BufferParams::package_off; + } + + if (mathsModule->esintautoCB->isChecked()) + params.use_esint = BufferParams::package_auto; + else { + if (mathsModule->esintCB->isChecked()) + params.use_esint = BufferParams::package_on; + else + params.use_esint = BufferParams::package_off; + } + + // text layout + params.textclass = + latexModule->classCO->currentIndex(); + + params.pagestyle = + fromqstr(pageLayoutModule->pagestyleCO->currentText()); + + switch (textLayoutModule->lspacingCO->currentIndex()) { + case 0: + params.spacing().set(Spacing::Single); + break; + case 1: + params.spacing().set(Spacing::Onehalf); + break; + case 2: + params.spacing().set(Spacing::Double); + break; + case 3: + params.spacing().set(Spacing::Other, + fromqstr(textLayoutModule->lspacingLE->text())); + break; + } + + if (textLayoutModule->twoColumnCB->isChecked()) + params.columns = 2; + else + params.columns = 1; + + if (textLayoutModule->indentRB->isChecked()) + params.paragraph_separation = BufferParams::PARSEP_INDENT; + else + params.paragraph_separation = BufferParams::PARSEP_SKIP; + + switch (textLayoutModule->skipCO->currentIndex()) { + case 0: + params.setDefSkip(VSpace(VSpace::SMALLSKIP)); + break; + case 1: + params.setDefSkip(VSpace(VSpace::MEDSKIP)); + break; + case 2: + params.setDefSkip(VSpace(VSpace::BIGSKIP)); + break; + case 3: + { + VSpace vs = VSpace( + widgetsToLength(textLayoutModule->skipLE, + textLayoutModule->skipLengthCO) + ); + params.setDefSkip(vs); + break; + } + default: + // DocumentDefskipCB assures that this never happens + // so Assert then !!! - jbl + params.setDefSkip(VSpace(VSpace::MEDSKIP)); + break; + } + + params.options = + fromqstr(latexModule->optionsLE->text()); + + params.float_placement = floatModule->get(); + + // fonts + params.fontsRoman = + tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()]; + + params.fontsSans = + tex_fonts_sans[fontModule->fontsSansCO->currentIndex()]; + + params.fontsTypewriter = + tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()]; + + params.fontsSansScale = fontModule->scaleSansSB->value(); + + params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value(); + + params.fontsSC = fontModule->fontScCB->isChecked(); + + params.fontsOSF = fontModule->fontOsfCB->isChecked(); + + params.fontsDefaultFamily = ControlDocument::fontfamilies[ + fontModule->fontsDefaultCO->currentIndex()]; + + if (fontModule->fontsizeCO->currentIndex() == 0) + params.fontsize = "default"; + else + params.fontsize = + fromqstr(fontModule->fontsizeCO->currentText()); + + // paper + params.papersize = PAPER_SIZE( + pageLayoutModule->papersizeCO->currentIndex()); + + // custom, A3, B3 and B4 paper sizes need geometry + int psize = pageLayoutModule->papersizeCO->currentIndex(); + bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9); + + params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE, + pageLayoutModule->paperwidthUnitCO); + + params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE, + pageLayoutModule->paperheightUnitCO); + + if (pageLayoutModule->facingPagesCB->isChecked()) + params.sides = LyXTextClass::TwoSides; + else + params.sides = LyXTextClass::OneSide; + + if (pageLayoutModule->landscapeRB->isChecked()) + params.orientation = ORIENTATION_LANDSCAPE; + else + params.orientation = ORIENTATION_PORTRAIT; + + // margins + params.use_geometry = + (!marginsModule->marginCB->isChecked() + || geom_papersize); + + Ui::MarginsUi const * m(marginsModule); + + params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit); + + params.topmargin = widgetsToLength(m->topLE, m->topUnit); + + params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit); + + params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit); + + params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit); + + params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit); + + params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit); + + branchesModule->apply(params); +} + +namespace { + +/** Return the position of val in the vector if found. + If not found, return 0. + */ +template +typename std::vector::size_type +findPos(std::vector const & vec, A const & val) +{ + typename std::vector::const_iterator it = + std::find(vec.begin(), vec.end(), val); + if (it == vec.end()) + return 0; + return distance(vec.begin(), it); +} + +} // namespace anom + + +void QDocumentDialog::updateParams(BufferParams const & params) +{ + // set the default unit + // FIXME: move to controller + LyXLength::UNIT defaultUnit = LyXLength::CM; + switch (lyxrc.default_papersize) { + case PAPER_DEFAULT: break; + + case PAPER_USLETTER: + case PAPER_USLEGAL: + case PAPER_USEXECUTIVE: + defaultUnit = LyXLength::IN; + break; + + case PAPER_A3: + case PAPER_A4: + case PAPER_A5: + case PAPER_B3: + case PAPER_B4: + case PAPER_B5: + defaultUnit = LyXLength::CM; + break; + case PAPER_CUSTOM: + break; + } + + // preamble + QString preamble = toqstr(params.preamble); + preambleModule->preambleTE->document()->setPlainText(preamble); + + // biblio + biblioModule->citeDefaultRB->setChecked( + params.getEngine() == biblio::ENGINE_BASIC); + + biblioModule->citeNatbibRB->setChecked( + params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL || + params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR); + + biblioModule->citeStyleCO->setCurrentIndex( + params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL); + + biblioModule->citeJurabibRB->setChecked( + params.getEngine() == biblio::ENGINE_JURABIB); + + biblioModule->bibtopicCB->setChecked( + params.use_bibtopic); + + // language & quotes + int const pos = int(findPos(lang_, + params.language->lang())); + langModule->languageCO->setCurrentIndex(pos); + + langModule->quoteStyleCO->setCurrentIndex( + params.quotes_language); + + langModule->defaultencodingCB->setChecked(true); + + if (params.inputenc != "auto") { + langModule->defaultencodingCB->setChecked(false); + if (params.inputenc == "default") { + langModule->encodingCO->setCurrentIndex(0); + } else { + int const i = langModule->encodingCO->findText( + toqstr(params.inputenc)); + if (i >= 0) + langModule->encodingCO->setCurrentIndex(i); + else + // unknown encoding. Set to default. + langModule->defaultencodingCB->setChecked(true); + } + } + + // numbering + int const min_toclevel = form_->controller().textClass().min_toclevel(); + int const max_toclevel = form_->controller().textClass().max_toclevel(); + if (form_->controller().textClass().hasTocLevels()) { + numberingModule->setEnabled(true); + numberingModule->depthSL->setMinimum(min_toclevel - 1); + numberingModule->depthSL->setMaximum(max_toclevel); + numberingModule->depthSL->setValue(params.secnumdepth); + numberingModule->tocSL->setMaximum(min_toclevel - 1); + numberingModule->tocSL->setMaximum(max_toclevel); + numberingModule->tocSL->setValue(params.tocdepth); + updateNumbering(); + } else { + numberingModule->setEnabled(false); + numberingModule->tocTW->clear(); + } + + // bullets + bulletsModule->setBullet(0, params.user_defined_bullet(0)); + bulletsModule->setBullet(1, params.user_defined_bullet(1)); + bulletsModule->setBullet(2, params.user_defined_bullet(2)); + bulletsModule->setBullet(3, params.user_defined_bullet(3)); + bulletsModule->init(); + + // packages + QString text = toqstr(params.graphicsDriver); + int nitem = latexModule->psdriverCO->count(); + for (int n = 0; n < nitem ; ++n) { + QString enc = tex_graphics[n]; + if (enc == text) { + latexModule->psdriverCO->setCurrentIndex(n); + } + } + + + mathsModule->amsCB->setChecked( + params.use_amsmath == BufferParams::package_on); + mathsModule->amsautoCB->setChecked( + params.use_amsmath == BufferParams::package_auto); + + mathsModule->esintCB->setChecked( + params.use_esint == BufferParams::package_on); + mathsModule->esintautoCB->setChecked( + params.use_esint == BufferParams::package_auto); + + switch (params.spacing().getSpace()) { + case Spacing::Other: nitem = 3; break; + case Spacing::Double: nitem = 2; break; + case Spacing::Onehalf: nitem = 1; break; + case Spacing::Default: case Spacing::Single: nitem = 0; break; + } + + // text layout + latexModule->classCO->setCurrentIndex(params.textclass); + + updatePagestyle(form_->controller().textClass().opt_pagestyle(), + params.pagestyle); + + textLayoutModule->lspacingCO->setCurrentIndex(nitem); + if (params.spacing().getSpace() == Spacing::Other) { + textLayoutModule->lspacingLE->setText( + toqstr(params.spacing().getValueAsString())); + } + setLSpacing(nitem); + + if (params.paragraph_separation + == BufferParams::PARSEP_INDENT) { + textLayoutModule->indentRB->setChecked(true); + } else { + textLayoutModule->skipRB->setChecked(true); + } + + int skip = 0; + switch (params.getDefSkip().kind()) { + case VSpace::SMALLSKIP: + skip = 0; + break; + case VSpace::MEDSKIP: + skip = 1; + break; + case VSpace::BIGSKIP: + skip = 2; + break; + case VSpace::LENGTH: + { + skip = 3; + string const length = params.getDefSkip().asLyXCommand(); + lengthToWidgets(textLayoutModule->skipLE, + textLayoutModule->skipLengthCO, + length, defaultUnit); + break; + } + default: + skip = 0; + break; + } + textLayoutModule->skipCO->setCurrentIndex(skip); + setSkip(skip); + + textLayoutModule->twoColumnCB->setChecked( + params.columns == 2); + + if (!params.options.empty()) { + latexModule->optionsLE->setText( + toqstr(params.options)); + } else { + latexModule->optionsLE->setText(""); + } + + floatModule->set(params.float_placement); + + //fonts + updateFontsize(form_->controller().textClass().opt_fontsize(), + params.fontsize); + + int n = findToken(tex_fonts_roman, params.fontsRoman); + if (n >= 0) { + fontModule->fontsRomanCO->setCurrentIndex(n); + romanChanged(n); + } + + n = findToken(tex_fonts_sans, params.fontsSans); + if (n >= 0) { + fontModule->fontsSansCO->setCurrentIndex(n); + sansChanged(n); + } + + n = findToken(tex_fonts_monospaced, params.fontsTypewriter); + if (n >= 0) { + fontModule->fontsTypewriterCO->setCurrentIndex(n); + ttChanged(n); + } + + fontModule->fontScCB->setChecked(params.fontsSC); + fontModule->fontOsfCB->setChecked(params.fontsOSF); + fontModule->scaleSansSB->setValue(params.fontsSansScale); + fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale); + n = findToken(ControlDocument::fontfamilies, params.fontsDefaultFamily); + if (n >= 0) + fontModule->fontsDefaultCO->setCurrentIndex(n); + + // paper + int const psize = params.papersize; + pageLayoutModule->papersizeCO->setCurrentIndex(psize); + setCustomPapersize(psize); + + bool const landscape = + params.orientation == ORIENTATION_LANDSCAPE; + pageLayoutModule->landscapeRB->setChecked(landscape); + pageLayoutModule->portraitRB->setChecked(!landscape); + + pageLayoutModule->facingPagesCB->setChecked( + params.sides == LyXTextClass::TwoSides); + + + lengthToWidgets(pageLayoutModule->paperwidthLE, + pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit); + + lengthToWidgets(pageLayoutModule->paperheightLE, + pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit); + + // margins + Ui::MarginsUi * m = marginsModule; + + setMargins(!params.use_geometry); + + lengthToWidgets(m->topLE, m->topUnit, + params.topmargin, defaultUnit); + + lengthToWidgets(m->bottomLE, m->bottomUnit, + params.bottommargin, defaultUnit); + + lengthToWidgets(m->innerLE, m->innerUnit, + params.leftmargin, defaultUnit); + + lengthToWidgets(m->outerLE, m->outerUnit, + params.rightmargin, defaultUnit); + + lengthToWidgets(m->headheightLE, m->headheightUnit, + params.headheight, defaultUnit); + + lengthToWidgets(m->headsepLE, m->headsepUnit, + params.headsep, defaultUnit); + + lengthToWidgets(m->footskipLE, m->footskipUnit, + params.footskip, defaultUnit); + + branchesModule->update(params); +} + + + +///////////////////////////////////////////////////////////////////// +// +// Document +// +///////////////////////////////////////////////////////////////////// + +typedef QController > + DocumentBase; QDocument::QDocument(Dialog & parent) - : document_base_class(parent, _("Document Settings")) + : DocumentBase(parent, _("Document Settings")) {} @@ -99,3 +1231,5 @@ void QDocument::useClassDefaults() } // namespace frontend } // namespace lyx + +#include "QDocument_moc.cpp" diff --git a/src/frontends/qt4/QDocument.h b/src/frontends/qt4/QDocument.h index 8a50e6a6ae..1468d48032 100644 --- a/src/frontends/qt4/QDocument.h +++ b/src/frontends/qt4/QDocument.h @@ -13,19 +13,107 @@ #define QDOCUMENT_H #include "QDialogView.h" -#include "QDocumentDialog.h" +#include "BulletsModule.h" -#include "BranchList.h" -#include -#include +#include "ui/DocumentUi.h" +#include "ui/FontUi.h" +#include "ui/TextLayoutUi.h" +#include "ui/MathsUi.h" +#include "ui/LaTeXUi.h" +#include "ui/PageLayoutUi.h" +#include "ui/LanguageUi.h" +#include "ui/BiblioUi.h" +#include "ui/NumberingUi.h" +#include "ui/MarginsUi.h" +#include "ui/PreambleUi.h" + +#include +#include #include +#include -class LengthCombo; -class QLineEdit; +class FloatPlacement; + +template +class UiWidget: public QWidget, public UI +{ +public: + UiWidget(QWidget * parent = 0) : QWidget(parent) + { + UI::setupUi(this); + } +}; namespace lyx { namespace frontend { +class QBranches; +class QDocument; + +class QDocumentDialog : public QDialog, public Ui::QDocumentUi { + Q_OBJECT +public: + friend class QDocument; + + QDocumentDialog(QDocument *); + ~QDocumentDialog(); + + void updateParams(BufferParams const & params); + void apply(BufferParams & params); + + void updateFontsize(std::string const &, std::string const &); + void updatePagestyle(std::string const &, std::string const &); + + void showPreamble(); + +public Q_SLOTS: + void updateNumbering(); + void change_adaptor(); + void saveDefaultClicked(); + void useDefaultsClicked(); + +protected Q_SLOTS: + void setLSpacing(int); + void setMargins(bool); + void setCustomPapersize(int); + void setCustomMargins(bool); + void romanChanged(int); + void sansChanged(int); + void ttChanged(int); + void setSkip(int); + void enableSkip(bool); + void portraitChanged(); + void classChanged(); + +protected: + void closeEvent(QCloseEvent * e); + +private: + + UiWidget *textLayoutModule; + UiWidget *fontModule; + UiWidget *pageLayoutModule; + UiWidget *marginsModule; + UiWidget *langModule; + UiWidget *numberingModule; + UiWidget *biblioModule; + UiWidget *mathsModule; + UiWidget *latexModule; + UiWidget *preambleModule; + + QBranches *branchesModule; + + BulletsModule * bulletsModule; + FloatPlacement * floatModule; + + QDocument * form_; + + /// FIXME + std::vector lang_; +}; + + + class ControlDocument; class QDocument diff --git a/src/frontends/qt4/QDocumentDialog.C b/src/frontends/qt4/QDocumentDialog.C deleted file mode 100644 index a547664496..0000000000 --- a/src/frontends/qt4/QDocumentDialog.C +++ /dev/null @@ -1,1166 +0,0 @@ -/** - * \file QDocumentDialog.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Edwin Leuven - * \author Abdelrazak Younes - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "QBranches.h" -#include "QDocument.h" -#include "QDocumentDialog.h" - -#include - -#include "FloatPlacement.h" -#include "lengthcombo.h" -#include "validators.h" -#include "panelstack.h" -#include "Qt2BC.h" -#include "checkedwidgets.h" -#include "qt_helpers.h" -// For latexHighlighter use in the preamble. -#include "QViewSource.h" - -#include "bufferparams.h" -#include "encoding.h" -#include "gettext.h" -#include "helper_funcs.h" // getSecond() -#include "language.h" -#include "lyxrc.h" // defaultUnit -#include "lyxtextclasslist.h" -#include "tex-strings.h" // tex_graphics -#include "Spacing.h" - -#include "frontends/controllers/biblio.h" -#include "controllers/ControlDocument.h" -#include "controllers/frnt_lang.h" - -#include "support/lstrings.h" - -#include "controllers/ControlDocument.h" -#include "controllers/frnt_lang.h" - - -using lyx::support::token; -using lyx::support::bformat; -using lyx::support::findToken; -using lyx::support::getVectorFromString; - -using std::distance; -using std::vector; -using std::string; - - -namespace lyx { -namespace frontend { - - -QDocumentDialog::QDocumentDialog(QDocument * form) - : form_(form), - lang_(getSecond(getLanguageData(false))) -{ - setupUi(this); - - connect(okPB, SIGNAL(clicked()), - form, SLOT(slotOK())); - connect(applyPB, SIGNAL(clicked()), - form, SLOT(slotApply())); - connect(closePB, SIGNAL(clicked()), - form, SLOT(slotClose())); - connect(restorePB, SIGNAL(clicked()), - form, SLOT(slotRestore())); - - - connect(savePB, SIGNAL( clicked() ), - this, SLOT( saveDefaultClicked() ) ); - connect(defaultPB, SIGNAL( clicked() ), - this, SLOT( useDefaultsClicked() ) ); - - // Manage the restore, ok, apply, restore and cancel/close buttons - form_->bcview().setOK(okPB); - form_->bcview().setApply(applyPB); - form_->bcview().setCancel(closePB); - form_->bcview().setRestore(restorePB); - - - textLayoutModule = new UiWidget; - // text layout - connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), this, SLOT(setLSpacing(int))); - connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(textLayoutModule->skipRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(textLayoutModule->indentRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(textLayoutModule->skipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(textLayoutModule->skipLengthCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(textLayoutModule->skipCO, SIGNAL(activated(int)), this, SLOT(setSkip(int))); - connect(textLayoutModule->skipRB, SIGNAL(toggled(bool)), this, SLOT(enableSkip(bool))); - connect(textLayoutModule->twoColumnCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - textLayoutModule->lspacingLE->setValidator(new QDoubleValidator( - textLayoutModule->lspacingLE)); - textLayoutModule->skipLE->setValidator(unsignedLengthValidator( - textLayoutModule->skipLE)); - - textLayoutModule->skipCO->addItem(qt_("SmallSkip")); - textLayoutModule->skipCO->addItem(qt_("MedSkip")); - textLayoutModule->skipCO->addItem(qt_("BigSkip")); - textLayoutModule->skipCO->addItem(qt_("Length")); - // remove the %-items from the unit choice - textLayoutModule->skipLengthCO->noPercents(); - textLayoutModule->lspacingCO->insertItem( - Spacing::Single, qt_("Single")); - textLayoutModule->lspacingCO->insertItem( - Spacing::Onehalf, qt_("OneHalf")); - textLayoutModule->lspacingCO->insertItem( - Spacing::Double, qt_("Double")); - textLayoutModule->lspacingCO->insertItem( - Spacing::Other, qt_("Custom")); - - // initialize the length validator - addCheckedLineEdit(form_->bcview(), textLayoutModule->skipLE); - - - - - fontModule = new UiWidget; - // fonts - connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(fontModule->fontsRomanCO, SIGNAL(activated(int)), this, SLOT(romanChanged(int))); - connect(fontModule->fontsSansCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(fontModule->fontsSansCO, SIGNAL(activated(int)), this, SLOT(sansChanged(int))); - connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)), this, SLOT(ttChanged(int))); - connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(fontModule->fontsizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); - connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); - connect(fontModule->fontScCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(fontModule->fontOsfCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - - for (int n = 0; tex_fonts_roman[n][0]; ++n) { - QString font = toqstr(tex_fonts_roman_gui[n]); - if (!form_->controller().isFontAvailable(tex_fonts_roman[n])) - font += qt_(" (not installed)"); - fontModule->fontsRomanCO->addItem(font); - } - for (int n = 0; tex_fonts_sans[n][0]; ++n) { - QString font = toqstr(tex_fonts_sans_gui[n]); - if (!form_->controller().isFontAvailable(tex_fonts_sans[n])) - font += qt_(" (not installed)"); - fontModule->fontsSansCO->addItem(font); - } - for (int n = 0; tex_fonts_monospaced[n][0]; ++n) { - QString font = toqstr(tex_fonts_monospaced_gui[n]); - if (!form_->controller().isFontAvailable(tex_fonts_monospaced[n])) - font += qt_(" (not installed)"); - fontModule->fontsTypewriterCO->addItem(font); - } - - fontModule->fontsizeCO->addItem(qt_("default")); - fontModule->fontsizeCO->addItem(qt_("10")); - fontModule->fontsizeCO->addItem(qt_("11")); - fontModule->fontsizeCO->addItem(qt_("12")); - - for (int n = 0; ControlDocument::fontfamilies_gui[n][0]; ++n) - fontModule->fontsDefaultCO->addItem( - qt_(ControlDocument::fontfamilies_gui[n])); - - - - - pageLayoutModule = new UiWidget; - // page layout - connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int))); - connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(setCustomPapersize(int))); - connect(pageLayoutModule->portraitRB, SIGNAL(clicked()), this, SLOT(portraitChanged())); - connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(pageLayoutModule->paperheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(pageLayoutModule->paperwidthLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(pageLayoutModule->paperwidthUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(pageLayoutModule->paperheightUnitCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(pageLayoutModule->portraitRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(pageLayoutModule->landscapeRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(pageLayoutModule->facingPagesCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - pageLayoutModule->pagestyleCO->addItem(qt_("default")); - pageLayoutModule->pagestyleCO->addItem(qt_("empty")); - pageLayoutModule->pagestyleCO->addItem(qt_("plain")); - pageLayoutModule->pagestyleCO->addItem(qt_("headings")); - pageLayoutModule->pagestyleCO->addItem(qt_("fancy")); - addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperheightLE, - pageLayoutModule->paperheightL); - addCheckedLineEdit(form_->bcview(), pageLayoutModule->paperwidthLE, - pageLayoutModule->paperwidthL); - - // paper - QComboBox * cb = pageLayoutModule->papersizeCO; - cb->addItem(qt_("Default")); - cb->addItem(qt_("Custom")); - cb->addItem(qt_("US letter")); - cb->addItem(qt_("US legal")); - cb->addItem(qt_("US executive")); - cb->addItem(qt_("A3")); - cb->addItem(qt_("A4")); - cb->addItem(qt_("A5")); - cb->addItem(qt_("B3")); - cb->addItem(qt_("B4")); - cb->addItem(qt_("B5")); - // remove the %-items from the unit choice - pageLayoutModule->paperwidthUnitCO->noPercents(); - pageLayoutModule->paperheightUnitCO->noPercents(); - pageLayoutModule->paperheightLE->setValidator(unsignedLengthValidator( - pageLayoutModule->paperheightLE)); - pageLayoutModule->paperwidthLE->setValidator(unsignedLengthValidator( - pageLayoutModule->paperwidthLE)); - - - - - marginsModule = new UiWidget; - // margins - connect(marginsModule->marginCB, SIGNAL(toggled(bool)), this, SLOT(setCustomMargins(bool))); - connect(marginsModule->marginCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(marginsModule->topLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(marginsModule->topUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(marginsModule->bottomLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(marginsModule->bottomUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(marginsModule->innerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(marginsModule->innerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(marginsModule->outerLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(marginsModule->outerUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(marginsModule->headheightLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(marginsModule->headheightUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(marginsModule->headsepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(marginsModule->headsepUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(marginsModule->footskipLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(marginsModule->footskipUnit, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - marginsModule->topLE->setValidator(unsignedLengthValidator( - marginsModule->topLE)); - marginsModule->bottomLE->setValidator(unsignedLengthValidator( - marginsModule->bottomLE)); - marginsModule->innerLE->setValidator(unsignedLengthValidator( - marginsModule->innerLE)); - marginsModule->outerLE->setValidator(unsignedLengthValidator( - marginsModule->outerLE)); - marginsModule->headsepLE->setValidator(unsignedLengthValidator( - marginsModule->headsepLE)); - marginsModule->headheightLE->setValidator(unsignedLengthValidator( - marginsModule->headheightLE)); - marginsModule->footskipLE->setValidator(unsignedLengthValidator( - marginsModule->footskipLE)); - - addCheckedLineEdit(form_->bcview(), marginsModule->topLE, - marginsModule->topL); - addCheckedLineEdit(form_->bcview(), marginsModule->bottomLE, - marginsModule->bottomL); - addCheckedLineEdit(form_->bcview(), marginsModule->innerLE, - marginsModule->innerL); - addCheckedLineEdit(form_->bcview(), marginsModule->outerLE, - marginsModule->outerL); - addCheckedLineEdit(form_->bcview(), marginsModule->headsepLE, - marginsModule->headsepL); - addCheckedLineEdit(form_->bcview(), marginsModule->headheightLE, - marginsModule->headheightL); - addCheckedLineEdit(form_->bcview(), marginsModule->footskipLE, - marginsModule->footskipL); - - - - - - langModule = new UiWidget; - connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), langModule->encodingL, SLOT(setDisabled(bool))); - connect(langModule->defaultencodingCB, SIGNAL(toggled(bool)), langModule->encodingCO, SLOT(setDisabled(bool))); - // language & quote - connect(langModule->languageCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(langModule->defaultencodingCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(langModule->encodingCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(langModule->quoteStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - // language & quotes - vector const langs = getLanguageData(false); - vector::const_iterator lit = langs.begin(); - vector::const_iterator lend = langs.end(); - for (; lit != lend; ++lit) { - langModule->languageCO->addItem( - toqstr(lit->first)); - } - - // Always put the default encoding in the first position. - // It is special because the displayed text is translated. - langModule->encodingCO->addItem(qt_("LaTeX default")); - Encodings::const_iterator it = encodings.begin(); - Encodings::const_iterator const end = encodings.end(); - for (; it != end; ++it) - langModule->encodingCO->addItem(toqstr(it->latexName())); - - langModule->quoteStyleCO->addItem(qt_("``text''")); - langModule->quoteStyleCO->addItem(qt_("''text''")); - langModule->quoteStyleCO->addItem(qt_(",,text``")); - langModule->quoteStyleCO->addItem(qt_(",,text''")); - langModule->quoteStyleCO->addItem(qt_("<>")); - langModule->quoteStyleCO->addItem(qt_(">>text<<")); - - - - numberingModule = new UiWidget; - // numbering - connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); - connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(change_adaptor())); - connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering())); - connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), this, SLOT(updateNumbering())); - numberingModule->tocTW->setColumnCount(3); - numberingModule->tocTW->headerItem()->setText(0, qt_("Example")); - numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered")); - numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC")); - - - biblioModule = new UiWidget; - connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citationStyleL, SLOT( setEnabled(bool) ) ); - connect( biblioModule->citeNatbibRB, SIGNAL( toggled(bool) ), biblioModule->citeStyleCO, SLOT( setEnabled(bool) ) ); - // biblio - connect(biblioModule->citeDefaultRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(biblioModule->citeNatbibRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(biblioModule->citeStyleCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(biblioModule->citeJurabibRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(biblioModule->bibtopicCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - // biblio - biblioModule->citeStyleCO->addItem(qt_("Author-year")); - biblioModule->citeStyleCO->addItem(qt_("Numerical")); - biblioModule->citeStyleCO->setCurrentIndex(0); - - - - mathsModule = new UiWidget; - connect(mathsModule->amsautoCB, SIGNAL(toggled(bool)), mathsModule->amsCB, SLOT(setDisabled(bool))); - connect(mathsModule->esintautoCB, SIGNAL(toggled(bool)), mathsModule->esintCB, SLOT(setDisabled(bool))); - // maths - connect(mathsModule->amsCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(mathsModule->amsautoCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(mathsModule->esintCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - connect(mathsModule->esintautoCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); - - latexModule = new UiWidget; - // latex class - connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(latexModule->optionsLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(latexModule->psdriverCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(latexModule->classCO, SIGNAL(activated(int)), this, SLOT(classChanged())); - // packages - for (int n = 0; tex_graphics[n][0]; ++n) { - QString enc = tex_graphics[n]; - latexModule->psdriverCO->addItem(enc); - } - // latex - for (LyXTextClassList::const_iterator cit = textclasslist.begin(); - cit != textclasslist.end(); ++cit) { - if (cit->isTeXClassAvailable()) { - latexModule->classCO->addItem(toqstr(cit->description())); - } else { - docstring item = - bformat(_("Unavailable: %1$s"), lyx::from_utf8(cit->description())); - latexModule->classCO->addItem(toqstr(item)); - } - } - - // branches - branchesModule = new QBranches; - connect(branchesModule, SIGNAL(changed()), this, SLOT(change_adaptor())); - - // preamble - preambleModule = new UiWidget; - connect(preambleModule->preambleTE, SIGNAL(textChanged()), - this, SLOT(change_adaptor())); - // This is not a memory leak. The object will be destroyed - // with preambleModule. - (void) new LaTeXHighlighter(preambleModule->preambleTE->document()); - - - // bullets - bulletsModule = new BulletsModule; - connect(bulletsModule, SIGNAL(changed()), this, SLOT(change_adaptor())); - - - // float - floatModule = new FloatPlacement; - connect(floatModule, SIGNAL(changed()), this, SLOT(change_adaptor())); - - docPS->addPanel(latexModule, _("Document Class")); - docPS->addPanel(fontModule, _("Fonts")); - docPS->addPanel(textLayoutModule, _("Text Layout")); - docPS->addPanel(pageLayoutModule, _("Page Layout")); - docPS->addPanel(marginsModule, _("Page Margins")); - docPS->addPanel(langModule, _("Language")); - docPS->addPanel(numberingModule, _("Numbering & TOC")); - docPS->addPanel(biblioModule, _("Bibliography")); - docPS->addPanel(mathsModule, _("Math Options")); - docPS->addPanel(floatModule, _("Float Placement")); - docPS->addPanel(bulletsModule, _("Bullets")); - docPS->addPanel(branchesModule, _("Branches")); - docPS->addPanel(preambleModule, _("LaTeX Preamble")); - docPS->setCurrentPanel(_("Document Class")); -// FIXME: hack to work around resizing bug in Qt >= 4.2 -// bug verified with Qt 4.2.{0-3} (JSpitzm) -#if QT_VERSION >= 0x040200 - docPS->updateGeometry(); -#endif -} - - -QDocumentDialog::~QDocumentDialog() -{ -} - - -void QDocumentDialog::showPreamble() -{ - docPS->setCurrentPanel(_("LaTeX Preamble")); -} - - -void QDocumentDialog::saveDefaultClicked() -{ - form_->saveDocDefault(); -} - - -void QDocumentDialog::useDefaultsClicked() -{ - form_->useClassDefaults(); -} - - -void QDocumentDialog::change_adaptor() -{ - form_->changed(); -} - - -void QDocumentDialog::closeEvent(QCloseEvent * e) -{ - form_->slotWMHide(); - e->accept(); -} - - -void QDocumentDialog::setLSpacing(int item) -{ - textLayoutModule->lspacingLE->setEnabled(item == 3); -} - - -void QDocumentDialog::setSkip(int item) -{ - bool const enable = (item == 3); - textLayoutModule->skipLE->setEnabled(enable); - textLayoutModule->skipLengthCO->setEnabled(enable); -} - - -void QDocumentDialog::enableSkip(bool skip) -{ - textLayoutModule->skipCO->setEnabled(skip); - textLayoutModule->skipLE->setEnabled(skip); - textLayoutModule->skipLengthCO->setEnabled(skip); - if (skip) - setSkip(textLayoutModule->skipCO->currentIndex()); -} - -void QDocumentDialog::portraitChanged() -{ - setMargins(pageLayoutModule->papersizeCO->currentIndex()); -} - -void QDocumentDialog::setMargins(bool custom) -{ - marginsModule->marginCB->setChecked(custom); - setCustomMargins(custom); -} - - -void QDocumentDialog::setCustomPapersize(int papersize) -{ - bool const custom = (papersize == 1); - - pageLayoutModule->paperwidthL->setEnabled(custom); - pageLayoutModule->paperwidthLE->setEnabled(custom); - pageLayoutModule->paperwidthUnitCO->setEnabled(custom); - pageLayoutModule->paperheightL->setEnabled(custom); - pageLayoutModule->paperheightLE->setEnabled(custom); - pageLayoutModule->paperheightLE->setFocus(); - pageLayoutModule->paperheightUnitCO->setEnabled(custom); -} - - -void QDocumentDialog::setCustomMargins(bool custom) -{ - marginsModule->topL->setEnabled(!custom); - marginsModule->topLE->setEnabled(!custom); - marginsModule->topUnit->setEnabled(!custom); - - marginsModule->bottomL->setEnabled(!custom); - marginsModule->bottomLE->setEnabled(!custom); - marginsModule->bottomUnit->setEnabled(!custom); - - marginsModule->innerL->setEnabled(!custom); - marginsModule->innerLE->setEnabled(!custom); - marginsModule->innerUnit->setEnabled(!custom); - - marginsModule->outerL->setEnabled(!custom); - marginsModule->outerLE->setEnabled(!custom); - marginsModule->outerUnit->setEnabled(!custom); - - marginsModule->headheightL->setEnabled(!custom); - marginsModule->headheightLE->setEnabled(!custom); - marginsModule->headheightUnit->setEnabled(!custom); - - marginsModule->headsepL->setEnabled(!custom); - marginsModule->headsepLE->setEnabled(!custom); - marginsModule->headsepUnit->setEnabled(!custom); - - marginsModule->footskipL->setEnabled(!custom); - marginsModule->footskipLE->setEnabled(!custom); - marginsModule->footskipUnit->setEnabled(!custom); -} - - -void QDocumentDialog::updateFontsize(string const & items, string const & sel) -{ - fontModule->fontsizeCO->clear(); - fontModule->fontsizeCO->addItem(qt_("default")); - - for (int n = 0; !token(items,'|',n).empty(); ++n) - fontModule->fontsizeCO-> - addItem(toqstr(token(items,'|',n))); - - for (int n = 0; n < fontModule->fontsizeCO->count(); ++n) { - if (fromqstr(fontModule->fontsizeCO->itemText(n)) == sel) { - fontModule->fontsizeCO->setCurrentIndex(n); - break; - } - } -} - - -void QDocumentDialog::romanChanged(int item) -{ - string const font = tex_fonts_roman[item]; - - fontModule->fontScCB->setEnabled( - form_->controller().providesSC(font)); - fontModule->fontOsfCB->setEnabled( - form_->controller().providesOSF(font)); -} - - -void QDocumentDialog::sansChanged(int item) -{ - string const font = tex_fonts_sans[item]; - bool scaleable = form_->controller().providesScale(font); - fontModule->scaleSansSB->setEnabled(scaleable); - fontModule->scaleSansLA->setEnabled(scaleable); -} - - -void QDocumentDialog::ttChanged(int item) -{ - string const font = tex_fonts_monospaced[item]; - bool scaleable = form_->controller().providesScale(font); - fontModule->scaleTypewriterSB->setEnabled(scaleable); - fontModule->scaleTypewriterLA->setEnabled(scaleable); -} - - -void QDocumentDialog::updatePagestyle(string const & items, string const & sel) -{ - pageLayoutModule->pagestyleCO->clear(); - pageLayoutModule->pagestyleCO->addItem("default"); - - for (int n=0; !token(items,'|',n).empty(); ++n) - pageLayoutModule->pagestyleCO-> - addItem(toqstr(token(items,'|',n))); - - for (int n = 0; npagestyleCO->count(); ++n) { - if (fromqstr(pageLayoutModule->pagestyleCO->itemText(n))==sel) { - pageLayoutModule->pagestyleCO->setCurrentIndex(n); - break; - } - } -} - - -void QDocumentDialog::classChanged() -{ - ControlDocument & cntrl = form_->controller(); - BufferParams & params = cntrl.params(); - - lyx::textclass_type const tc = latexModule->classCO->currentIndex(); - - if (form_->controller().loadTextclass(tc)) { - params.textclass = tc; - if (lyxrc.auto_reset_options) - params.useClassDefaults(); - form_->update_contents(); - } else { - latexModule->classCO->setCurrentIndex(params.textclass); - } -} - - -void QDocumentDialog::updateNumbering() -{ - LyXTextClass const & tclass = - form_->controller().params().getLyXTextClass(); - - numberingModule->tocTW->setUpdatesEnabled(false); - numberingModule->tocTW->clear(); - - int const depth = numberingModule->depthSL->value(); - int const toc = numberingModule->tocSL->value(); - QString const no = qt_("No"); - QString const yes = qt_("Yes"); - LyXTextClass::const_iterator end = tclass.end(); - LyXTextClass::const_iterator cit = tclass.begin(); - QTreeWidgetItem * item = 0; - for ( ; cit != end ; ++cit) { - int const toclevel = (*cit)->toclevel; - if (toclevel != LyXLayout::NOT_IN_TOC - && (*cit)->labeltype == LABEL_COUNTER) { - item = new QTreeWidgetItem(numberingModule->tocTW); - item->setText(0, qt_((*cit)->name())); - item->setText(1, (toclevel <= depth) ? yes : no); - item->setText(2, (toclevel <= toc) ? yes : no); - } - } - - numberingModule->tocTW->setUpdatesEnabled(true); - numberingModule->tocTW->update(); -} - -void QDocumentDialog::apply(BufferParams & params) -{ - // preamble - params.preamble = - fromqstr(preambleModule->preambleTE->document()->toPlainText()); - - // biblio - params.setCiteEngine(biblio::ENGINE_BASIC); - - if (biblioModule->citeNatbibRB->isChecked()) { - bool const use_numerical_citations = - biblioModule->citeStyleCO->currentIndex(); - if (use_numerical_citations) - params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL); - else - params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR); - - } else if (biblioModule->citeJurabibRB->isChecked()) - params.setCiteEngine(biblio::ENGINE_JURABIB); - - params.use_bibtopic = - biblioModule->bibtopicCB->isChecked(); - - // language & quotes - if (langModule->defaultencodingCB->isChecked()) { - params.inputenc = "auto"; - } else { - int i = langModule->encodingCO->currentIndex(); - if (i == 0) - params.inputenc = "default"; - else - params.inputenc = - fromqstr(langModule->encodingCO->currentText()); - } - - InsetQuotes::quote_language lga = InsetQuotes::EnglishQ; - switch (langModule->quoteStyleCO->currentIndex()) { - case 0: - lga = InsetQuotes::EnglishQ; - break; - case 1: - lga = InsetQuotes::SwedishQ; - break; - case 2: - lga = InsetQuotes::GermanQ; - break; - case 3: - lga = InsetQuotes::PolishQ; - break; - case 4: - lga = InsetQuotes::FrenchQ; - break; - case 5: - lga = InsetQuotes::DanishQ; - break; - } - params.quotes_language = lga; - - int const pos = langModule->languageCO->currentIndex(); - params.language = languages.getLanguage(lang_[pos]); - - // numbering - if (params.getLyXTextClass().hasTocLevels()) { - params.tocdepth = numberingModule->tocSL->value(); - params.secnumdepth = numberingModule->depthSL->value(); - } - - // bullets - params.user_defined_bullet(0) = bulletsModule->getBullet(0); - params.user_defined_bullet(1) = bulletsModule->getBullet(1); - params.user_defined_bullet(2) = bulletsModule->getBullet(2); - params.user_defined_bullet(3) = bulletsModule->getBullet(3); - - // packages - params.graphicsDriver = - fromqstr(latexModule->psdriverCO->currentText()); - - if (mathsModule->amsautoCB->isChecked()) { - params.use_amsmath = BufferParams::package_auto; - } else { - if (mathsModule->amsCB->isChecked()) - params.use_amsmath = BufferParams::package_on; - else - params.use_amsmath = BufferParams::package_off; - } - - if (mathsModule->esintautoCB->isChecked()) - params.use_esint = BufferParams::package_auto; - else { - if (mathsModule->esintCB->isChecked()) - params.use_esint = BufferParams::package_on; - else - params.use_esint = BufferParams::package_off; - } - - // text layout - params.textclass = - latexModule->classCO->currentIndex(); - - params.pagestyle = - fromqstr(pageLayoutModule->pagestyleCO->currentText()); - - switch (textLayoutModule->lspacingCO->currentIndex()) { - case 0: - params.spacing().set(Spacing::Single); - break; - case 1: - params.spacing().set(Spacing::Onehalf); - break; - case 2: - params.spacing().set(Spacing::Double); - break; - case 3: - params.spacing().set(Spacing::Other, - fromqstr(textLayoutModule->lspacingLE->text())); - break; - } - - if (textLayoutModule->twoColumnCB->isChecked()) - params.columns = 2; - else - params.columns = 1; - - if (textLayoutModule->indentRB->isChecked()) - params.paragraph_separation = BufferParams::PARSEP_INDENT; - else - params.paragraph_separation = BufferParams::PARSEP_SKIP; - - switch (textLayoutModule->skipCO->currentIndex()) { - case 0: - params.setDefSkip(VSpace(VSpace::SMALLSKIP)); - break; - case 1: - params.setDefSkip(VSpace(VSpace::MEDSKIP)); - break; - case 2: - params.setDefSkip(VSpace(VSpace::BIGSKIP)); - break; - case 3: - { - VSpace vs = VSpace( - widgetsToLength(textLayoutModule->skipLE, - textLayoutModule->skipLengthCO) - ); - params.setDefSkip(vs); - break; - } - default: - // DocumentDefskipCB assures that this never happens - // so Assert then !!! - jbl - params.setDefSkip(VSpace(VSpace::MEDSKIP)); - break; - } - - params.options = - fromqstr(latexModule->optionsLE->text()); - - params.float_placement = floatModule->get(); - - // fonts - params.fontsRoman = - tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()]; - - params.fontsSans = - tex_fonts_sans[fontModule->fontsSansCO->currentIndex()]; - - params.fontsTypewriter = - tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()]; - - params.fontsSansScale = fontModule->scaleSansSB->value(); - - params.fontsTypewriterScale = fontModule->scaleTypewriterSB->value(); - - params.fontsSC = fontModule->fontScCB->isChecked(); - - params.fontsOSF = fontModule->fontOsfCB->isChecked(); - - params.fontsDefaultFamily = ControlDocument::fontfamilies[ - fontModule->fontsDefaultCO->currentIndex()]; - - if (fontModule->fontsizeCO->currentIndex() == 0) - params.fontsize = "default"; - else - params.fontsize = - fromqstr(fontModule->fontsizeCO->currentText()); - - // paper - params.papersize = PAPER_SIZE( - pageLayoutModule->papersizeCO->currentIndex()); - - // custom, A3, B3 and B4 paper sizes need geometry - int psize = pageLayoutModule->papersizeCO->currentIndex(); - bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9); - - params.paperwidth = widgetsToLength(pageLayoutModule->paperwidthLE, - pageLayoutModule->paperwidthUnitCO); - - params.paperheight = widgetsToLength(pageLayoutModule->paperheightLE, - pageLayoutModule->paperheightUnitCO); - - if (pageLayoutModule->facingPagesCB->isChecked()) - params.sides = LyXTextClass::TwoSides; - else - params.sides = LyXTextClass::OneSide; - - if (pageLayoutModule->landscapeRB->isChecked()) - params.orientation = ORIENTATION_LANDSCAPE; - else - params.orientation = ORIENTATION_PORTRAIT; - - // margins - params.use_geometry = - (!marginsModule->marginCB->isChecked() - || geom_papersize); - - Ui::MarginsUi const * m(marginsModule); - - params.leftmargin = widgetsToLength(m->innerLE, m->innerUnit); - - params.topmargin = widgetsToLength(m->topLE, m->topUnit); - - params.rightmargin = widgetsToLength(m->outerLE, m->outerUnit); - - params.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit); - - params.headheight = widgetsToLength(m->headheightLE, m->headheightUnit); - - params.headsep = widgetsToLength(m->headsepLE, m->headsepUnit); - - params.footskip = widgetsToLength(m->footskipLE, m->footskipUnit); - - branchesModule->apply(params); -} - -namespace { - -/** Return the position of val in the vector if found. - If not found, return 0. - */ -template -typename std::vector::size_type -findPos(std::vector const & vec, A const & val) -{ - typename std::vector::const_iterator it = - std::find(vec.begin(), vec.end(), val); - if (it == vec.end()) - return 0; - return distance(vec.begin(), it); -} - -} // namespace anom - - -void QDocumentDialog::updateParams(BufferParams const & params) -{ - // set the default unit - // FIXME: move to controller - LyXLength::UNIT defaultUnit = LyXLength::CM; - switch (lyxrc.default_papersize) { - case PAPER_DEFAULT: break; - - case PAPER_USLETTER: - case PAPER_USLEGAL: - case PAPER_USEXECUTIVE: - defaultUnit = LyXLength::IN; - break; - - case PAPER_A3: - case PAPER_A4: - case PAPER_A5: - case PAPER_B3: - case PAPER_B4: - case PAPER_B5: - defaultUnit = LyXLength::CM; - break; - case PAPER_CUSTOM: - break; - } - - // preamble - QString preamble = toqstr(params.preamble); - preambleModule->preambleTE->document()->setPlainText(preamble); - - // biblio - biblioModule->citeDefaultRB->setChecked( - params.getEngine() == biblio::ENGINE_BASIC); - - biblioModule->citeNatbibRB->setChecked( - params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL || - params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR); - - biblioModule->citeStyleCO->setCurrentIndex( - params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL); - - biblioModule->citeJurabibRB->setChecked( - params.getEngine() == biblio::ENGINE_JURABIB); - - biblioModule->bibtopicCB->setChecked( - params.use_bibtopic); - - // language & quotes - int const pos = int(findPos(lang_, - params.language->lang())); - langModule->languageCO->setCurrentIndex(pos); - - langModule->quoteStyleCO->setCurrentIndex( - params.quotes_language); - - langModule->defaultencodingCB->setChecked(true); - - if (params.inputenc != "auto") { - langModule->defaultencodingCB->setChecked(false); - if (params.inputenc == "default") { - langModule->encodingCO->setCurrentIndex(0); - } else { - int const i = langModule->encodingCO->findText( - toqstr(params.inputenc)); - if (i >= 0) - langModule->encodingCO->setCurrentIndex(i); - else - // unknown encoding. Set to default. - langModule->defaultencodingCB->setChecked(true); - } - } - - // numbering - int const min_toclevel = form_->controller().textClass().min_toclevel(); - int const max_toclevel = form_->controller().textClass().max_toclevel(); - if (form_->controller().textClass().hasTocLevels()) { - numberingModule->setEnabled(true); - numberingModule->depthSL->setMinimum(min_toclevel - 1); - numberingModule->depthSL->setMaximum(max_toclevel); - numberingModule->depthSL->setValue(params.secnumdepth); - numberingModule->tocSL->setMaximum(min_toclevel - 1); - numberingModule->tocSL->setMaximum(max_toclevel); - numberingModule->tocSL->setValue(params.tocdepth); - updateNumbering(); - } else { - numberingModule->setEnabled(false); - numberingModule->tocTW->clear(); - } - - // bullets - bulletsModule->setBullet(0, params.user_defined_bullet(0)); - bulletsModule->setBullet(1, params.user_defined_bullet(1)); - bulletsModule->setBullet(2, params.user_defined_bullet(2)); - bulletsModule->setBullet(3, params.user_defined_bullet(3)); - bulletsModule->init(); - - // packages - QString text = toqstr(params.graphicsDriver); - int nitem = latexModule->psdriverCO->count(); - for (int n = 0; n < nitem ; ++n) { - QString enc = tex_graphics[n]; - if (enc == text) { - latexModule->psdriverCO->setCurrentIndex(n); - } - } - - - mathsModule->amsCB->setChecked( - params.use_amsmath == BufferParams::package_on); - mathsModule->amsautoCB->setChecked( - params.use_amsmath == BufferParams::package_auto); - - mathsModule->esintCB->setChecked( - params.use_esint == BufferParams::package_on); - mathsModule->esintautoCB->setChecked( - params.use_esint == BufferParams::package_auto); - - switch (params.spacing().getSpace()) { - case Spacing::Other: nitem = 3; break; - case Spacing::Double: nitem = 2; break; - case Spacing::Onehalf: nitem = 1; break; - case Spacing::Default: case Spacing::Single: nitem = 0; break; - } - - // text layout - latexModule->classCO->setCurrentIndex(params.textclass); - - updatePagestyle(form_->controller().textClass().opt_pagestyle(), - params.pagestyle); - - textLayoutModule->lspacingCO->setCurrentIndex(nitem); - if (params.spacing().getSpace() == Spacing::Other) { - textLayoutModule->lspacingLE->setText( - toqstr(params.spacing().getValueAsString())); - } - setLSpacing(nitem); - - if (params.paragraph_separation - == BufferParams::PARSEP_INDENT) { - textLayoutModule->indentRB->setChecked(true); - } else { - textLayoutModule->skipRB->setChecked(true); - } - - int skip = 0; - switch (params.getDefSkip().kind()) { - case VSpace::SMALLSKIP: - skip = 0; - break; - case VSpace::MEDSKIP: - skip = 1; - break; - case VSpace::BIGSKIP: - skip = 2; - break; - case VSpace::LENGTH: - { - skip = 3; - string const length = params.getDefSkip().asLyXCommand(); - lengthToWidgets(textLayoutModule->skipLE, - textLayoutModule->skipLengthCO, - length, defaultUnit); - break; - } - default: - skip = 0; - break; - } - textLayoutModule->skipCO->setCurrentIndex(skip); - setSkip(skip); - - textLayoutModule->twoColumnCB->setChecked( - params.columns == 2); - - if (!params.options.empty()) { - latexModule->optionsLE->setText( - toqstr(params.options)); - } else { - latexModule->optionsLE->setText(""); - } - - floatModule->set(params.float_placement); - - //fonts - updateFontsize(form_->controller().textClass().opt_fontsize(), - params.fontsize); - - int n = findToken(tex_fonts_roman, params.fontsRoman); - if (n >= 0) { - fontModule->fontsRomanCO->setCurrentIndex(n); - romanChanged(n); - } - - n = findToken(tex_fonts_sans, params.fontsSans); - if (n >= 0) { - fontModule->fontsSansCO->setCurrentIndex(n); - sansChanged(n); - } - - n = findToken(tex_fonts_monospaced, params.fontsTypewriter); - if (n >= 0) { - fontModule->fontsTypewriterCO->setCurrentIndex(n); - ttChanged(n); - } - - fontModule->fontScCB->setChecked(params.fontsSC); - fontModule->fontOsfCB->setChecked(params.fontsOSF); - fontModule->scaleSansSB->setValue(params.fontsSansScale); - fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale); - n = findToken(ControlDocument::fontfamilies, params.fontsDefaultFamily); - if (n >= 0) - fontModule->fontsDefaultCO->setCurrentIndex(n); - - // paper - int const psize = params.papersize; - pageLayoutModule->papersizeCO->setCurrentIndex(psize); - setCustomPapersize(psize); - - bool const landscape = - params.orientation == ORIENTATION_LANDSCAPE; - pageLayoutModule->landscapeRB->setChecked(landscape); - pageLayoutModule->portraitRB->setChecked(!landscape); - - pageLayoutModule->facingPagesCB->setChecked( - params.sides == LyXTextClass::TwoSides); - - - lengthToWidgets(pageLayoutModule->paperwidthLE, - pageLayoutModule->paperwidthUnitCO, params.paperwidth, defaultUnit); - - lengthToWidgets(pageLayoutModule->paperheightLE, - pageLayoutModule->paperheightUnitCO, params.paperheight, defaultUnit); - - // margins - Ui::MarginsUi * m = marginsModule; - - setMargins(!params.use_geometry); - - lengthToWidgets(m->topLE, m->topUnit, - params.topmargin, defaultUnit); - - lengthToWidgets(m->bottomLE, m->bottomUnit, - params.bottommargin, defaultUnit); - - lengthToWidgets(m->innerLE, m->innerUnit, - params.leftmargin, defaultUnit); - - lengthToWidgets(m->outerLE, m->outerUnit, - params.rightmargin, defaultUnit); - - lengthToWidgets(m->headheightLE, m->headheightUnit, - params.headheight, defaultUnit); - - lengthToWidgets(m->headsepLE, m->headsepUnit, - params.headsep, defaultUnit); - - lengthToWidgets(m->footskipLE, m->footskipUnit, - params.footskip, defaultUnit); - - branchesModule->update(params); -} - - - - -} // namespace frontend -} // namespace lyx - -#include "QDocumentDialog_moc.cpp" diff --git a/src/frontends/qt4/QDocumentDialog.h b/src/frontends/qt4/QDocumentDialog.h deleted file mode 100644 index 02474639b5..0000000000 --- a/src/frontends/qt4/QDocumentDialog.h +++ /dev/null @@ -1,118 +0,0 @@ -// -*- C++ -*- -/** - * \file QDocumentDialog.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Edwin Leuven - * \author Abdelrazak Younes - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef QDOCUMENTDIALOG_H -#define QDOCUMENTDIALOG_H - -#include "ui/DocumentUi.h" -#include "ui/FontUi.h" -#include "ui/TextLayoutUi.h" -#include "ui/MathsUi.h" -#include "ui/LaTeXUi.h" -#include "ui/PageLayoutUi.h" -#include "ui/LanguageUi.h" -#include "ui/BiblioUi.h" -#include "ui/NumberingUi.h" -#include "ui/MarginsUi.h" -#include "ui/PreambleUi.h" - -#include "BulletsModule.h" - -#include -#include -#include -#include - -class FloatPlacement; - -template - class UiWidget: public QWidget, public UI - { - public: - UiWidget(QWidget * Parent=0): QWidget(Parent) - { - UI::setupUi(this); - } - }; - -namespace lyx { -namespace frontend { - -class QBranches; -class QDocument; - -class QDocumentDialog : public QDialog, public Ui::QDocumentUi { - Q_OBJECT -public: - friend class QDocument; - - QDocumentDialog(QDocument *); - ~QDocumentDialog(); - - void updateParams(BufferParams const & params); - void apply(BufferParams & params); - - void updateFontsize(std::string const &, std::string const &); - void updatePagestyle(std::string const &, std::string const &); - - void showPreamble(); - -public Q_SLOTS: - void updateNumbering(); - void change_adaptor(); - void saveDefaultClicked(); - void useDefaultsClicked(); - -protected Q_SLOTS: - void setLSpacing(int); - void setMargins(bool); - void setCustomPapersize(int); - void setCustomMargins(bool); - void romanChanged(int); - void sansChanged(int); - void ttChanged(int); - void setSkip(int); - void enableSkip(bool); - void portraitChanged(); - void classChanged(); - -protected: - void closeEvent(QCloseEvent * e); - -private: - - UiWidget *textLayoutModule; - UiWidget *fontModule; - UiWidget *pageLayoutModule; - UiWidget *marginsModule; - UiWidget *langModule; - UiWidget *numberingModule; - UiWidget *biblioModule; - UiWidget *mathsModule; - UiWidget *latexModule; - UiWidget *preambleModule; - - QBranches *branchesModule; - - BulletsModule * bulletsModule; - FloatPlacement * floatModule; - - QDocument * form_; - - /// FIXME - std::vector lang_; -}; - -} // namespace frontend -} // namespace lyx - -#endif // DOCUMENTDIALOG_H diff --git a/src/frontends/qt4/QLog.C b/src/frontends/qt4/QLog.C index 565f1c3756..11b51ba7eb 100644 --- a/src/frontends/qt4/QLog.C +++ b/src/frontends/qt4/QLog.C @@ -11,7 +11,6 @@ #include #include "QLog.h" -#include "QLogDialog.h" #include "qt_helpers.h" #include "frontends/Application.h" @@ -26,15 +25,46 @@ namespace lyx { namespace frontend { -typedef QController > log_base_class; - -QLog::QLog(Dialog & parent) - : log_base_class(parent, lyx::docstring()) -{} +///////////////////////////////////////////////////////////////////// +// +// QLogDialog +// +///////////////////////////////////////////////////////////////////// -logHighlighter::logHighlighter(QTextDocument * parent) : - QSyntaxHighlighter(parent) +QLogDialog::QLogDialog(QLog * form) + : form_(form) +{ + setupUi(this); + + connect(closePB, SIGNAL(clicked()), + form, SLOT(slotClose())); + connect( updatePB, SIGNAL( clicked() ), + this, SLOT( updateClicked() ) ); +} + + +void QLogDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + + +void QLogDialog::updateClicked() +{ + form_->update_contents(); +} + + +///////////////////////////////////////////////////////////////////// +// +// LogHighlighter +// +///////////////////////////////////////////////////////////////////// + +LogHighlighter::LogHighlighter(QTextDocument * parent) + : QSyntaxHighlighter(parent) { infoFormat.setForeground(Qt::darkGray); warningFormat.setForeground(Qt::darkBlue); @@ -42,7 +72,7 @@ logHighlighter::logHighlighter(QTextDocument * parent) : } -void logHighlighter::highlightBlock(QString const & text) +void LogHighlighter::highlightBlock(QString const & text) { // Info QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|Underfull|Overfull|\\(|\\\\).*$"); @@ -71,11 +101,24 @@ void logHighlighter::highlightBlock(QString const & text) } +///////////////////////////////////////////////////////////////////// +// +// QLog +// +///////////////////////////////////////////////////////////////////// + +typedef QController > LogBase; + +QLog::QLog(Dialog & parent) + : LogBase(parent, lyx::docstring()) +{} + + void QLog::build_dialog() { dialog_.reset(new QLogDialog(this)); // set syntax highlighting - highlighter = new logHighlighter(dialog_->logTB->document()); + highlighter = new LogHighlighter(dialog_->logTB->document()); // dialog_->logTB->setReadOnly(true); QFont font(toqstr(theApp()->typewriterFontName())); diff --git a/src/frontends/qt4/QLog.h b/src/frontends/qt4/QLog.h index 0ed6170a0a..5ce6ecb4cf 100644 --- a/src/frontends/qt4/QLog.h +++ b/src/frontends/qt4/QLog.h @@ -13,15 +13,34 @@ #define QLOG_H #include "QDialogView.h" -#include "QLogDialog.h" + +#include "ui/LogUi.h" + +#include +#include #include namespace lyx { namespace frontend { +class QLog; + +class QLogDialog : public QDialog, public Ui::QLogUi { + Q_OBJECT +public: + QLogDialog(QLog * form); +protected Q_SLOTS: + virtual void updateClicked(); +protected: + virtual void closeEvent(QCloseEvent * e); +private: + QLog * form_; +}; + + class ControlLog; -class logHighlighter; +class LogHighlighter; /// class QLog @@ -40,18 +59,15 @@ private: /// build the dialog virtual void build_dialog(); /// log syntax highlighter - logHighlighter * highlighter; - + LogHighlighter * highlighter; }; /// -class logHighlighter : public QSyntaxHighlighter +class LogHighlighter : public QSyntaxHighlighter { - Q_OBJECT - public: - logHighlighter(QTextDocument * parent); + LogHighlighter(QTextDocument * parent); protected: void highlightBlock(QString const & text); diff --git a/src/frontends/qt4/QParagraph.C b/src/frontends/qt4/QParagraph.C index 8abffd1577..dd78aaa529 100644 --- a/src/frontends/qt4/QParagraph.C +++ b/src/frontends/qt4/QParagraph.C @@ -12,7 +12,6 @@ #include #include "QParagraph.h" -#include "QParagraphDialog.h" #include "Qt2BC.h" #include "qt_helpers.h" @@ -28,18 +27,154 @@ #include #include - using std::string; using std::endl; +///////////////////////////////////////////////////////////////////// +// +// QParagraphDialog +// +///////////////////////////////////////////////////////////////////// + + +#include + namespace lyx { namespace frontend { -typedef QController > paragraph_base_class; +QParagraphDialog::QParagraphDialog(QParagraph * form) + : form_(form) +{ + setupUi(this); + + connect(okPB, SIGNAL(clicked()), form_, SLOT(slotOK())); + connect(applyPB, SIGNAL(clicked()), form_, SLOT(slotApply())); + connect(closePB, SIGNAL(clicked()), form_, SLOT(slotClose())); + connect(restorePB, SIGNAL(clicked()), form_, SLOT(slotRestore())); + connect(alignDefaultCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(alignJustRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(alignLeftRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(alignRightRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(alignCenterRB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(linespacing, SIGNAL(activated(int)), this, SLOT(change_adaptor())); + connect(linespacing, SIGNAL(activated(int)), + this, SLOT(enableLinespacingValue(int))); + connect(linespacingValue, SIGNAL(textChanged(const QString &)), + this, SLOT(change_adaptor())); + connect(indentCB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(labelWidth, SIGNAL(textChanged(const QString &)), + this, SLOT(change_adaptor())); + + linespacingValue->setValidator(new QDoubleValidator(linespacingValue)); + + labelWidth->setWhatsThis( qt_( + "As described in the User Guide, the length of" + " this text will determine how wide the label part" + " of each item is in environments like List and" + " Description.\n" + "\n" + " Normally you won't need to set this," + " since the largest label width of all the" + " items is used. But if you need to, you can" + " change it here." + )); + + radioMap[LYX_ALIGN_BLOCK] = alignJustRB; + radioMap[LYX_ALIGN_LEFT] = alignLeftRB; + radioMap[LYX_ALIGN_RIGHT] = alignRightRB; + radioMap[LYX_ALIGN_CENTER] = alignCenterRB; +} + + +void QParagraphDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + + +void QParagraphDialog::change_adaptor() +{ + form_->changed(); +} + + +void QParagraphDialog::enableLinespacingValue(int) +{ + bool const enable = linespacing->currentIndex() == 4; + linespacingValue->setEnabled(enable); +} + + +void QParagraphDialog::checkAlignmentRadioButtons() { + if (alignDefaultCB->isChecked()) { + QPRadioMap::const_iterator it = radioMap.begin(); + for (; it != radioMap.end(); ++it) + it->second->setDisabled(true); + } else { + LyXAlignment alignPossible = form_->controller().alignPossible(); + QPRadioMap::const_iterator it = radioMap.begin(); + for (; it != radioMap.end(); ++it) + it->second->setEnabled(it->first & alignPossible); + } +} + + +void QParagraphDialog::on_alignDefaultCB_toggled(bool) +{ + checkAlignmentRadioButtons(); + alignmentToRadioButtons(); +} + + +void QParagraphDialog::alignmentToRadioButtons(LyXAlignment align) +{ + if (align == LYX_ALIGN_LAYOUT) + align = form_->controller().alignDefault(); + + QPRadioMap::const_iterator it = radioMap.begin(); + for (;it != radioMap.end(); ++it) { + if (align == it->first) { + it->second->setChecked(true); + return; + } + } + + lyxerr << BOOST_CURRENT_FUNCTION << "Unknown alignment " + << align << std::endl; +} + + +LyXAlignment QParagraphDialog::getAlignmentFromDialog() +{ + if (alignDefaultCB->isChecked()) + return LYX_ALIGN_LAYOUT; + LyXAlignment alignment = LYX_ALIGN_NONE; + QPRadioMap::const_iterator it = radioMap.begin(); + for (; it != radioMap.end(); ++it) { + if (it->second->isChecked()) { + alignment = it->first; + break; + } + } + if (alignment == form_->controller().alignDefault()) + return LYX_ALIGN_LAYOUT; + return alignment; +} + + +///////////////////////////////////////////////////////////////////// +// +// QParagraph +// +///////////////////////////////////////////////////////////////////// + +typedef QController > + ParagraphBase; QParagraph::QParagraph(Dialog & parent) - : paragraph_base_class(parent, _("Paragraph Settings")) + : ParagraphBase(parent, _("Paragraph Settings")) {} @@ -155,3 +290,5 @@ void QParagraph::update_contents() } // namespace frontend } // namespace lyx + +#include "QParagraph_moc.cpp" diff --git a/src/frontends/qt4/QParagraph.h b/src/frontends/qt4/QParagraph.h index 2ad010eef0..17941db89c 100644 --- a/src/frontends/qt4/QParagraph.h +++ b/src/frontends/qt4/QParagraph.h @@ -14,10 +14,43 @@ #define QPARAGRAPH_H #include "QDialogView.h" -#include "QParagraphDialog.h" + +#include +#include +#include +#include "layout.h" +#include "ui/ParagraphUi.h" namespace lyx { namespace frontend { + +class QParagraph; + +class QParagraphDialog : public QDialog, public Ui::QParagraphUi { + Q_OBJECT +public: + QParagraphDialog(QParagraph * form); + /// + void checkAlignmentRadioButtons(); + /// + void alignmentToRadioButtons(LyXAlignment align = LYX_ALIGN_LAYOUT); + /// + LyXAlignment getAlignmentFromDialog(); +protected: + void closeEvent (QCloseEvent * e); +private: + QParagraph * form_; + typedef std::map QPRadioMap; + QPRadioMap radioMap; +protected Q_SLOTS: + /// + void change_adaptor(); + /// + void enableLinespacingValue(int); + /// + void on_alignDefaultCB_toggled(bool); +}; + class ControlParagraph; diff --git a/src/frontends/qt4/QParagraphDialog.C b/src/frontends/qt4/QParagraphDialog.C deleted file mode 100644 index b519b914f7..0000000000 --- a/src/frontends/qt4/QParagraphDialog.C +++ /dev/null @@ -1,170 +0,0 @@ -/** - * \file QParagraphDialog.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author John Levon - * \author Edwin Leuven - * \author Richard Heck - * - * Full author contact details are available in file CREDITS. - */ - -#include -#include - -#include "QParagraphDialog.h" -#include "QParagraph.h" - -#include -#include -#include -#include -#include - -#include "qt_helpers.h" -#include "frontends/controllers/ControlParagraph.h" - -#include "debug.h" - -#include - -namespace lyx { -namespace frontend { - -QParagraphDialog::QParagraphDialog(QParagraph * form) - : form_(form) -{ - setupUi(this); - - connect(okPB, SIGNAL(clicked()), - form_, SLOT(slotOK())); - connect(applyPB, SIGNAL(clicked()), - form_, SLOT(slotApply())); - connect(closePB, SIGNAL(clicked()), - form_, SLOT(slotClose())); - connect(restorePB, SIGNAL(clicked()), - form_, SLOT(slotRestore())); - connect(alignDefaultCB, SIGNAL( clicked() ), - this, SLOT( change_adaptor() ) ); - connect(alignJustRB, SIGNAL( clicked() ), - this, SLOT( change_adaptor() ) ); - connect(alignLeftRB, SIGNAL( clicked() ), - this, SLOT( change_adaptor() ) ); - connect(alignRightRB, SIGNAL( clicked() ), - this, SLOT( change_adaptor() ) ); - connect(alignCenterRB, SIGNAL( clicked() ), - this, SLOT( change_adaptor() ) ); - connect(linespacing, SIGNAL( activated(int) ), - this, SLOT( change_adaptor() ) ); - connect(linespacing, SIGNAL( activated(int) ), - this, SLOT( enableLinespacingValue(int) ) ); - connect(linespacingValue, SIGNAL( textChanged(const QString&) ), - this, SLOT( change_adaptor() ) ); - connect(indentCB, SIGNAL( clicked() ), - this, SLOT( change_adaptor() ) ); - connect(labelWidth, SIGNAL( textChanged(const QString&) ), - this, SLOT( change_adaptor() ) ); - - linespacingValue->setValidator(new QDoubleValidator(linespacingValue)); - - labelWidth->setWhatsThis( qt_( - "As described in the User Guide, the length of" - " this text will determine how wide the label part" - " of each item is in environments like List and" - " Description.\n" - "\n" - " Normally you won't need to set this," - " since the largest label width of all the" - " items is used. But if you need to, you can" - " change it here." - )); - - radioMap[LYX_ALIGN_BLOCK] = alignJustRB; - radioMap[LYX_ALIGN_LEFT] = alignLeftRB; - radioMap[LYX_ALIGN_RIGHT] = alignRightRB; - radioMap[LYX_ALIGN_CENTER] = alignCenterRB; -} - - -void QParagraphDialog::closeEvent(QCloseEvent * e) -{ - form_->slotWMHide(); - e->accept(); -} - - -void QParagraphDialog::change_adaptor() -{ - form_->changed(); -} - - -void QParagraphDialog::enableLinespacingValue(int) -{ - bool const enable = linespacing->currentIndex() == 4; - linespacingValue->setEnabled(enable); -} - - -void QParagraphDialog::checkAlignmentRadioButtons() { - if (alignDefaultCB->isChecked()) { - QPRadioMap::const_iterator it = radioMap.begin(); - for (; it != radioMap.end(); ++it) - it->second->setDisabled(true); - } else { - LyXAlignment alignPossible = form_->controller().alignPossible(); - QPRadioMap::const_iterator it = radioMap.begin(); - for (; it != radioMap.end(); ++it) - it->second->setEnabled(it->first & alignPossible); - } -} - - -void QParagraphDialog::on_alignDefaultCB_toggled(bool) -{ - checkAlignmentRadioButtons(); - alignmentToRadioButtons(); -} - - -void QParagraphDialog::alignmentToRadioButtons(LyXAlignment align) -{ - if (align == LYX_ALIGN_LAYOUT) - align = form_->controller().alignDefault(); - - QPRadioMap::const_iterator it = radioMap.begin(); - for (;it != radioMap.end(); ++it) { - if (align == it->first) { - it->second->setChecked(true); - return; - } - } - - lyxerr << BOOST_CURRENT_FUNCTION << "Unknown alignment " - << align << std::endl; -} - - -LyXAlignment QParagraphDialog::getAlignmentFromDialog() -{ - if (alignDefaultCB->isChecked()) - return LYX_ALIGN_LAYOUT; - LyXAlignment alignment = LYX_ALIGN_NONE; - QPRadioMap::const_iterator it = radioMap.begin(); - for (; it != radioMap.end(); ++it) { - if (it->second->isChecked()) { - alignment = it->first; - break; - } - } - if (alignment == form_->controller().alignDefault()) - return LYX_ALIGN_LAYOUT; - else return alignment; -} - - -} // namespace frontend -} // namespace lyx - -#include "QParagraphDialog_moc.cpp" diff --git a/src/frontends/qt4/QParagraphDialog.h b/src/frontends/qt4/QParagraphDialog.h deleted file mode 100644 index 1fce7e3aef..0000000000 --- a/src/frontends/qt4/QParagraphDialog.h +++ /dev/null @@ -1,57 +0,0 @@ -// -*- C++ -*- -/** - * \file QParagraphDialog.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author John Levon - * \author Edwin Leuven - * \author Richard Heck - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef QPARAGRAPHDIALOG_H -#define QPARAGRAPHDIALOG_H - -#include "ui/ParagraphUi.h" - -#include -#include -#include -#include "layout.h" - -namespace lyx { -namespace frontend { - -class QParagraph; - -class QParagraphDialog : public QDialog, public Ui::QParagraphUi { - Q_OBJECT -public: - QParagraphDialog(QParagraph * form); - /// - void checkAlignmentRadioButtons(); - /// - void alignmentToRadioButtons(LyXAlignment align = LYX_ALIGN_LAYOUT); - /// - LyXAlignment getAlignmentFromDialog(); -protected: - void closeEvent (QCloseEvent * e); -private: - QParagraph * form_; - typedef std::map QPRadioMap; - QPRadioMap radioMap; -protected Q_SLOTS: - /// - void change_adaptor(); - /// - void enableLinespacingValue(int); - /// - void on_alignDefaultCB_toggled(bool); -}; - -} // namespace frontend -} // namespace lyx - -#endif // QPARAGRAPHDIALOG_H diff --git a/src/frontends/qt4/QShowFile.C b/src/frontends/qt4/QShowFile.C index f34e154843..6701a48a52 100644 --- a/src/frontends/qt4/QShowFile.C +++ b/src/frontends/qt4/QShowFile.C @@ -11,7 +11,6 @@ #include #include "QShowFile.h" -#include "QShowFileDialog.h" #include "Qt2BC.h" #include "qt_helpers.h" @@ -20,16 +19,42 @@ #include #include -using std::string; - namespace lyx { namespace frontend { -typedef QController > showfile_base_class; +///////////////////////////////////////////////////////////////////// +// +// QShowFileDialog +// +///////////////////////////////////////////////////////////////////// + +QShowFileDialog::QShowFileDialog(QShowFile * form) + : form_(form) +{ + setupUi(this); + connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose())); +} + + +void QShowFileDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + + +///////////////////////////////////////////////////////////////////// +// +// QShowFile +// +///////////////////////////////////////////////////////////////////// + +typedef QController > + ShowFileBase; QShowFile::QShowFile(Dialog & parent) - : showfile_base_class(parent, _("Show File")) + : ShowFileBase(parent, _("Show File")) { } @@ -46,7 +71,7 @@ void QShowFile::update_contents() { dialog_->setWindowTitle(toqstr(controller().getFileName())); - string contents = controller().getFileContents(); + std::string contents = controller().getFileContents(); if (contents.empty()) { contents = "Error -> Cannot load file!"; } @@ -56,3 +81,5 @@ void QShowFile::update_contents() } // namespace frontend } // namespace lyx + +#include "QShowFile_moc.cpp" diff --git a/src/frontends/qt4/QShowFile.h b/src/frontends/qt4/QShowFile.h index 363645f30e..72b344b61a 100644 --- a/src/frontends/qt4/QShowFile.h +++ b/src/frontends/qt4/QShowFile.h @@ -13,11 +13,28 @@ #define QSHOWFILE_H #include "QDialogView.h" -#include "QShowFileDialog.h" + +#include "ui/ShowFileUi.h" + +#include +#include namespace lyx { namespace frontend { +class QShowFile; + +class QShowFileDialog : public QDialog, public Ui::QShowFileUi { + Q_OBJECT +public: + QShowFileDialog(QShowFile * form); +protected: + virtual void closeEvent(QCloseEvent * e); +private: + QShowFile * form_; +}; + + class ControlShowFile; class QShowFile diff --git a/src/frontends/qt4/QShowFileDialog.C b/src/frontends/qt4/QShowFileDialog.C deleted file mode 100644 index 89e600c45b..0000000000 --- a/src/frontends/qt4/QShowFileDialog.C +++ /dev/null @@ -1,41 +0,0 @@ -/** - * \file QShowFileDialog.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author John Levon - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "QShowFileDialog.h" -#include "QShowFile.h" - -#include -#include - -namespace lyx { -namespace frontend { - -QShowFileDialog::QShowFileDialog(QShowFile * form) - : form_(form) -{ - setupUi(this); - - connect(closePB, SIGNAL(clicked()), - form, SLOT(slotClose())); -} - - -void QShowFileDialog::closeEvent(QCloseEvent * e) -{ - form_->slotWMHide(); - e->accept(); -} - -} // namespace frontend -} // namespace lyx - -#include "QShowFileDialog_moc.cpp" diff --git a/src/frontends/qt4/QShowFileDialog.h b/src/frontends/qt4/QShowFileDialog.h deleted file mode 100644 index 9b620b1328..0000000000 --- a/src/frontends/qt4/QShowFileDialog.h +++ /dev/null @@ -1,38 +0,0 @@ -// -*- C++ -*- -/** - * \file QShowFileDialog.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author John Levon - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef QSHOWFILEDIALOG_H -#define QSHOWFILEDIALOG_H - -#include "ui/ShowFileUi.h" - -#include -#include - -namespace lyx { -namespace frontend { - -class QShowFile; - -class QShowFileDialog : public QDialog, public Ui::QShowFileUi { - Q_OBJECT -public: - QShowFileDialog(QShowFile * form); -protected: - virtual void closeEvent(QCloseEvent * e); -private: - QShowFile * form_; -}; - -} // namespace frontend -} // namespace lyx - -#endif // QSHOWFILEDIALOG_H