From: Kalle Dalheimer Date: Fri, 23 Mar 2001 06:31:30 +0000 (+0000) Subject: quick fix to make qt2 compile X-Git-Tag: 1.6.10~21419 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=67dc240bc9e6b2823ccbeea8da9b94666c8bf698;p=features.git quick fix to make qt2 compile git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1808 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 09e50d9fa8..0a2949b4d9 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -48,7 +48,10 @@ Dialogs::Dialogs(LyXView * lv) add( new FormCharacter(lv, this)); add( new FormCitation(lv, this)); // add(new FormCopyright(lv, this)); - add( new FormCredits(lv, this)); + + // REMOVED THIS UNTIL CHANGED TO NEW SCHEME -- Kalle, 2001-03-22 + // add( new FormCredits(lv, this)); + // add(new FormDocument(lv, this)); add(new FormError(lv, this)); add(new FormGraphics(lv, this)); diff --git a/src/frontends/qt2/FormDocument.C b/src/frontends/qt2/FormDocument.C new file mode 100644 index 0000000000..3b2a53fcc3 --- /dev/null +++ b/src/frontends/qt2/FormDocument.C @@ -0,0 +1,948 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * @author Jürgen Vigna, Kalle Dalheimer + * + *======================================================*/ + +#include + +#ifdef __GNUG_ +#pragma implementation +#endif + +#include "FormDocumentDialog.h" +#undef emit + +#include "lyx_gui_misc.h" +#include "gettext.h" +//#include FORMS_H_LOCATION +#include XPM_H_LOCATION + +#include "FormDocument.h" +//#include "xform_macros.h" +#include "Dialogs.h" +#include "layout.h" +#include "combox.h" +#include "tex-strings.h" +#include "bufferparams.h" +#include "insets/insetquotes.h" +#include "vspace.h" +#include "bmtable.h" +#include "support/filetools.h" +#include "language.h" +#include "LyXView.h" +#include "BufferView.h" +#include "buffer.h" +#include "Liason.h" +#include "CutAndPaste.h" +#include "bufferview_funcs.h" +#include "ButtonController.h" + +#ifdef SIGC_CXX_NAMESPACES +using SigC::slot; +#endif + +#ifdef CXX_WORKING_NAMESPACES +using Liason::setMinibuffer; +#endif + +#define USE_CLASS_COMBO 1 + +#include +#include +#include +#include +#include +#include +#include +#include + +// Bullet images +#include "../../../lib/images/standard.xpm" +#include "../../../lib/images/psnfss1.xpm" +#include "../../../lib/images/psnfss2.xpm" +#include "../../../lib/images/psnfss3.xpm" +#include "../../../lib/images/psnfss4.xpm" +#include "../../../lib/images/amssymb.xpm" + + +FormDocument::FormDocument(LyXView * lv, Dialogs * d) + : FormBaseBD( lv, d, _( "Document Layout" ), + new NoRepeatedApplyReadOnlyPolicy ), + dialog_(0), lv_(lv), d_(d), u_(0), h_(0), + status(POPUP_UNMODIFIED) , + currentBulletPanel(0), + currentBulletDepth(0) +{ + // let the popup be shown + // This is a permanent connection so we won't bother + // storing a copy because we won't be disconnecting. + d->showLayoutDocument.connect(slot(this, &FormDocument::show)); + + // load the images + standardpix = new QPixmap( standard ); + amssymbpix = new QPixmap( amssymb ); + psnfss1pix = new QPixmap( psnfss1 ); + psnfss2pix = new QPixmap( psnfss2 ); + psnfss3pix = new QPixmap( psnfss3 ); + psnfss4pix = new QPixmap( psnfss4 ); +} + + +FormDocument::~FormDocument() +{ + delete standardpix; + delete amssymbpix; + delete psnfss1pix; + delete psnfss2pix; + delete psnfss3pix; + delete psnfss4pix; +} + + +void FormDocument::build() +{ + int n; + + dialog_ = new FormDocumentDialog( this, 0, _( "Document Layout" ) ); + + for (LyXTextClassList::const_iterator cit = textclasslist.begin(); + cit != textclasslist.end(); ++cit) + { + dialog_->classesCO->insertItem((*cit).description().c_str()); + } + + for (n=0; tex_fonts[n][0]; ++n) { + dialog_->fontsCO->insertItem( tex_fonts[n] ); + } + + for(Languages::const_iterator cit = languages.begin(); + cit != languages.end(); ++cit) { + dialog_->languageCO->insertItem((*cit).second.lang().c_str()); + } + + for (n=0; tex_graphics[n][0]; ++n) { + dialog_->psDriverCO->insertItem( tex_graphics[n] ); + } + + dialog_->bulletDepth1PB->setOn( true ); +} + + +void FormDocument::apply() +{ + if (!lv_->view()->available() || !dialog_) + return; + + bool redo = class_apply(); + paper_apply(); + redo = language_apply() || redo; + redo = options_apply() || redo; + bullets_apply(); + + if (redo) { + lv_->view()->redoCurrentBuffer(); + } + lv_->buffer()->markDirty(); + setMinibuffer(lv_, _("Document layout set")); +} + + +bool FormDocument::class_apply() +{ + bool redo = false; + BufferParams ¶ms = lv_->buffer()->params; + + // If default skip is a "Length" but there's no text in the + // input field, reset the kind to "Medskip", which is the default. + if( ( dialog_->defaultSkipCO->currentItem() == 4 ) && + ( dialog_->defaultSkipED->text().isEmpty() ) ) + dialog_->defaultSkipCO->setCurrentItem( 1 ); + params.fonts = dialog_->fontsCO->currentText(); + params.fontsize = dialog_->fontSizeCO->currentText(); + params.pagestyle = dialog_->pagestyleCO->currentText(); + + unsigned int new_class = dialog_->classesCO->currentItem(); + if (params.textclass != new_class) { + // try to load new_class + if (textclasslist.Load(new_class)) { + // successfully loaded + redo = true; + setMinibuffer(lv_, _("Converting document to new document class...")); + CutAndPaste cap; + int ret = cap.SwitchLayoutsBetweenClasses( + params.textclass, new_class, + lv_->buffer()->paragraph); + if (ret) { + string s; + if (ret==1) { + s = _("One paragraph couldn't be converted"); + } else { + s += tostr(ret); + s += _(" paragraphs couldn't be converted"); + } + WriteAlert(_("Conversion Errors!"),s, + _("into chosen document class")); + } + + params.textclass = new_class; + } else { + // problem changing class -- warn user and retain old style + WriteAlert(_("Conversion Errors!"), + _("Errors loading new document class."), + _("Reverting to original document class.")); + dialog_->classesCO->setCurrentItem( params.textclass ); + } + } + char tmpsep = params.paragraph_separation; + if( dialog_->indentRB->isChecked() ) + params.paragraph_separation = BufferParams::PARSEP_INDENT; + else + params.paragraph_separation = BufferParams::PARSEP_SKIP; + if (tmpsep != params.paragraph_separation) + redo = true; + + VSpace tmpdefskip = params.getDefSkip(); + switch( dialog_->defaultSkipCO->currentItem() ) { + 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: + params.setDefSkip + (VSpace(LyXGlueLength(dialog_->defaultSkipED->text().latin1()))); + break; + // DocumentDefskipCB assures that this never happens + default: + params.setDefSkip(VSpace(VSpace::MEDSKIP)); + break; + } + if (!(tmpdefskip == params.getDefSkip())) + redo = true; + + if( dialog_->twoColumnsRB->isChecked() ) + params.columns = 2; + else + params.columns = 1; + if( dialog_->twoSidesRB->isChecked() ) + params.sides = LyXTextClass::TwoSides; + else + params.sides = LyXTextClass::OneSide; + + Spacing tmpSpacing = params.spacing; + switch( dialog_->spacingCO->currentItem() ) { + case 0: + lyxerr[Debug::INFO] << "Spacing: SINGLE\n"; + params.spacing.set(Spacing::Single); + break; + case 1: + lyxerr[Debug::INFO] << "Spacing: ONEHALF\n"; + params.spacing.set(Spacing::Onehalf); + break; + case 2: + lyxerr[Debug::INFO] << "Spacing: DOUBLE\n"; + params.spacing.set(Spacing::Double); + break; + case 3: + lyxerr[Debug::INFO] << "Spacing: OTHER\n"; + params.spacing.set(Spacing::Other, + dialog_->defaultSkipED->text().latin1() ); + break; + } + if (tmpSpacing != params.spacing) + redo = true; + + params.options = dialog_->extraOptionsED->text(); + + return redo; +} + + +void FormDocument::paper_apply() +{ + BufferParams & params = lv_->buffer()->params; + + params.papersize2 = dialog_->papersizeCO->currentItem(); + params.paperpackage = dialog_->specialCO->currentItem(); + params.use_geometry = dialog_->CheckBox1->isChecked(); + if( dialog_->landscapeRB->isChecked() ) + params.orientation = BufferParams::ORIENTATION_LANDSCAPE; + else + params.orientation = BufferParams::ORIENTATION_PORTRAIT; + params.paperwidth = dialog_->customWidthED->text(); + params.paperheight = dialog_->customHeightED->text(); + params.leftmargin = dialog_->marginLeftED->text(); + params.topmargin = dialog_->marginTopED->text(); + params.rightmargin = dialog_->marginRightED->text(); + params.bottommargin = dialog_->marginBottomED->text(); + params.headheight = dialog_->headheightED->text(); + params.headsep = dialog_->headsepED->text(); + params.footskip = dialog_->footskipED->text(); + lv_->buffer()->setPaperStuff(); +} + + +bool FormDocument::language_apply() +{ + BufferParams & params = lv_->buffer()->params; + InsetQuotes::quote_language lga = InsetQuotes::EnglishQ; + bool redo = false; + + switch( dialog_->quoteStyleTypeCO->currentItem() ) { + 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; + if( dialog_->quoteStyleSingleRB->isChecked() ) + params.quotes_times = InsetQuotes::SingleQ; + else + params.quotes_times = InsetQuotes::DoubleQ; + + Language const * old_language = params.language; + Language const * new_language = + languages.getLanguage( dialog_->languageCO->currentText().latin1() ); + if( !new_language ) + new_language = default_language; + + if (old_language != new_language + && old_language->RightToLeft() == new_language->RightToLeft() + && !lv_->buffer()->isMultiLingual()) + lv_->buffer()->ChangeLanguage(old_language, new_language); + if (old_language != new_language) { + redo = true; + } + params.language = new_language; + params.inputenc = dialog_->encodingCO->currentText(); + + return redo; +} + + +bool FormDocument::options_apply() +{ + BufferParams & params = lv_->buffer()->params; + bool redo = false; + + params.graphicsDriver = + dialog_->psDriverCO->currentText(); + params.use_amsmath = dialog_->amsMathCB->isChecked(); + + int tmpchar = dialog_->sectionNumberDepthSB->value(); + if (params.secnumdepth != tmpchar) + redo = true; + params.secnumdepth = tmpchar; + + params.tocdepth = dialog_->tocDepthSB->value(); + + params.float_placement = + dialog_->floatPlacementED->text(); + + return redo; +} + + +void FormDocument::bullets_apply() +{ + /* update the bullet settings */ + BufferParams & param = lv_->buffer()->params; + + // a little bit of loop unrolling + param.user_defined_bullets[0] = param.temp_bullets[0]; + param.user_defined_bullets[1] = param.temp_bullets[1]; + param.user_defined_bullets[2] = param.temp_bullets[2]; + param.user_defined_bullets[3] = param.temp_bullets[3]; +} + + +void FormDocument::cancel() +{ + // this avoids confusion when reopening + BufferParams & param = lv_->buffer()->params; + param.temp_bullets[0] = param.user_defined_bullets[0]; + param.temp_bullets[1] = param.user_defined_bullets[1]; + param.temp_bullets[2] = param.user_defined_bullets[2]; + param.temp_bullets[3] = param.user_defined_bullets[3]; +} + + +void FormDocument::update() +{ + if (!dialog_) + return; + + checkReadOnly(); + + BufferParams const & params = lv_->buffer()->params; + + class_update(params); + paper_update(params); + language_update(params); + options_update(params); + bullets_update(params); +} + + +void FormDocument::class_update(BufferParams const & params) +{ + LyXTextClass const & tclass = textclasslist.TextClass(params.textclass); + + for( int i = 0; i < dialog_->classesCO->count(); i++ ) + if( dialog_->classesCO->text( i ) == textclasslist.DescOfClass( params.textclass ).c_str() ) + dialog_->classesCO->setCurrentItem( i ); + + for( int i = 0; i < dialog_->fontsCO->count(); i++ ) + if( dialog_->fontsCO->text( i ) == params.fonts.c_str() ) + dialog_->fontsCO->setCurrentItem( i ); + + dialog_->fontSizeCO->clear(); + dialog_->fontSizeCO->insertItem( _("default") ); + dialog_->fontSizeCO->insertStringList( QStringList::split( "|", tclass.opt_fontsize().c_str() ) ); + for( int i = 0; i < dialog_->fontSizeCO->count(); i++ ) + if( dialog_->fontSizeCO->text( i ) == + tokenPos(tclass.opt_fontsize(), '|', params.fontsize)+2) + dialog_->fontSizeCO->setCurrentItem( i ); + + dialog_->pagestyleCO->clear(); + dialog_->pagestyleCO->insertItem( _("default") ); + dialog_->pagestyleCO->insertStringList( QStringList::split( "|", tclass.opt_pagestyle().c_str() ) ); + for( int i = 0; i < dialog_->pagestyleCO->count(); i++ ) + if( dialog_->pagestyleCO->text( i ) == + tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle)+2) + dialog_->pagestyleCO->setCurrentItem( i ); + + if (params.paragraph_separation == BufferParams::PARSEP_INDENT) { + dialog_->indentRB->setChecked( true ); + dialog_->skipRB->setChecked( false ); + } else { + dialog_->skipRB->setChecked( true ); + dialog_->indentRB->setChecked( false ); + } + switch (params.getDefSkip().kind()) { + case VSpace::SMALLSKIP: + dialog_->defaultSkipCO->setCurrentItem( 0 ); + break; + case VSpace::MEDSKIP: + dialog_->defaultSkipCO->setCurrentItem( 1 ); + break; + case VSpace::BIGSKIP: + dialog_->defaultSkipCO->setCurrentItem( 2 ); + break; + case VSpace::LENGTH: + dialog_->defaultSkipCO->setCurrentItem( 3 ); + dialog_->defaultSkipED->setText( params.getDefSkip().asLyXCommand().c_str() ); + break; + default: + dialog_->defaultSkipCO->setCurrentItem( 1 ); + break; + } + + if( params.sides == 2 ) { + dialog_->twoSidesRB->setChecked( true ); + dialog_->oneSideRB->setChecked( false ); + } else { + dialog_->twoSidesRB->setChecked( false ); + dialog_->oneSideRB->setChecked( true ); + } + + if( params.columns == 2 ) { + dialog_->twoColumnsRB->setChecked( true ); + dialog_->oneColumnRB->setChecked( false ); + } else { + dialog_->twoColumnsRB->setChecked( false ); + dialog_->oneColumnRB->setChecked( true ); + } + + dialog_->spacingED->setText( "" ); + switch (params.spacing.getSpace()) { + case Spacing::Default: // nothing bad should happen with this + case Spacing::Single: + // \singlespacing + dialog_->spacingCO->setCurrentItem( 0 ); + break; + case Spacing::Onehalf: + // \onehalfspacing + dialog_->spacingCO->setCurrentItem( 1 ); + break; + case Spacing::Double: + // \doublespacing + dialog_->spacingCO->setCurrentItem( 2 ); + break; + case Spacing::Other: + { + dialog_->spacingCO->setCurrentItem( 3 ); + QString sval; + sval.sprintf("%g",params.spacing.getValue()); + dialog_->spacingED->setText( sval ); + break; + } + } + if (!params.options.empty()) + dialog_->extraOptionsED->setText( params.options.c_str()); + else + dialog_->extraOptionsED->setText( "" ); +} + + +void FormDocument::language_update(BufferParams const & params) +{ + for( int i = 0; i < dialog_->languageCO->count(); i++ ) + if( dialog_->languageCO->text( i ) == params.language->lang().c_str() ) + dialog_->languageCO->setCurrentItem( i ); + + + for( int i = 0; i < dialog_->encodingCO->count(); i++ ) + if( dialog_->encodingCO->text( i ) == params.inputenc.c_str() ) + dialog_->encodingCO->setCurrentItem( i ); + + dialog_->quoteStyleTypeCO->setCurrentItem( params.quotes_language ); + + if( params.quotes_times == InsetQuotes::SingleQ ) { + dialog_->quoteStyleSingleRB->setChecked( true ); + dialog_->quoteStyleDoubleRB->setChecked( false ); + } else { + dialog_->quoteStyleSingleRB->setChecked( false ); + dialog_->quoteStyleDoubleRB->setChecked( true ); + } +} + + +void FormDocument::options_update(BufferParams const & params) +{ + for( int i = 0; i < dialog_->psDriverCO->count(); i++ ) + if( dialog_->psDriverCO->text( i ) == params.graphicsDriver.c_str() ) + dialog_->psDriverCO->setCurrentItem( i ); + + dialog_->amsMathCB->setChecked( params.use_amsmath ); + dialog_->sectionNumberDepthSB->setValue( params.secnumdepth ); + dialog_->tocDepthSB->setValue( params.tocdepth ); + + if (!params.float_placement.empty()) + dialog_->floatPlacementED->setText( params.float_placement.c_str()); + else + dialog_->floatPlacementED->setText( "" ); +} + + +void FormDocument::paper_update(BufferParams const & params) +{ + dialog_->papersizeCO->setCurrentItem( params.papersize2 ); + dialog_->specialCO->setCurrentItem( params.paperpackage ); + dialog_->CheckBox1->setChecked( params.use_geometry ); + + if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE) { + dialog_->landscapeRB->setChecked( true ); + dialog_->portraitRB->setChecked( false ); + } else { + dialog_->landscapeRB->setChecked( false ); + dialog_->portraitRB->setChecked( true ); + } + + dialog_->customWidthED->setText( params.paperwidth.c_str()); + dialog_->customHeightED->setText( params.paperheight.c_str()); + dialog_->marginLeftED->setText( params.leftmargin.c_str()); + dialog_->marginTopED->setText( params.topmargin.c_str()); + dialog_->marginRightED->setText( params.rightmargin.c_str()); + dialog_->marginBottomED->setText( params.bottommargin.c_str()); + dialog_->headheightED->setText( params.headheight.c_str()); + dialog_->headsepED->setText( params.headsep.c_str()); + dialog_->footskipED->setText( params.footskip.c_str()); + dialog_->papersizeCO->setFocus(); +} + + +void FormDocument::bullets_update(BufferParams const & params) +{ + if (lv_->buffer()->isLinuxDoc()) { + dialog_->bulletTypeBG->setEnabled( false ); + dialog_->bulletDepth1PB->setEnabled( false ); + dialog_->bulletDepth2PB->setEnabled( false ); + dialog_->bulletDepth3PB->setEnabled( false ); + dialog_->bulletDepth4PB->setEnabled( false ); + dialog_->bulletSizeCO->setEnabled( false ); + dialog_->latexED->setEnabled( false ); + return; + } else { + dialog_->bulletTypeBG->setEnabled( true ); + dialog_->bulletDepth1PB->setEnabled( true ); + dialog_->bulletDepth2PB->setEnabled( true ); + dialog_->bulletDepth3PB->setEnabled( true ); + dialog_->bulletDepth4PB->setEnabled( true ); + dialog_->bulletSizeCO->setEnabled( true ); + dialog_->latexED->setEnabled( true ); + } + if (lv_->buffer()->isReadonly()) { + dialog_->bulletTypeBG->setEnabled( false ); + dialog_->bulletSizeCO->setEnabled( false ); + dialog_->latexED->setEnabled( false ); + } else { + dialog_->bulletTypeBG->setEnabled( true ); + dialog_->bulletSizeCO->setEnabled( true ); + dialog_->latexED->setEnabled( true ); + } + + dialog_->bulletDepth1PB->setOn( true ); + dialog_->latexED->setText( params.user_defined_bullets[0].getText().c_str()); + dialog_->bulletSizeCO->setCurrentItem( params.user_defined_bullets[0].getSize() + 1); + dialog_->bulletStandardPB->setOn( false ); + dialog_->bulletMathsPB->setOn( false ); + dialog_->bulletDing1PB->setOn( false ); + dialog_->bulletDing2PB->setOn( false ); + dialog_->bulletDing3PB->setOn( false ); + dialog_->bulletDing4PB->setOn( false ); + switch( params.user_defined_bullets[0].getFont() ) { + case 0: + dialog_->bulletStandardPB->setOn( true ); + break; + case 1: + dialog_->bulletMathsPB->setOn( true ); + break; + case 2: + dialog_->bulletDing1PB->setOn( true ); + break; + case 3: + dialog_->bulletDing2PB->setOn( true ); + break; + case 4: + dialog_->bulletDing3PB->setOn( true ); + break; + case 5: + dialog_->bulletDing4PB->setOn( true ); + break; + default: + // should not happen + dialog_->bulletStandardPB->setOn( true ); + } +} + + +void FormDocument::free() +{ + if (dialog_) { + hide(); + delete dialog_; + dialog_ = 0; + } +} + + +void FormDocument::checkReadOnly() +{ + if (bc_.readOnly(lv_->buffer()->isReadonly())) { + dialog_->classesCO->setEnabled( false ); + dialog_->languageCO->setEnabled( false ); + dialog_->warningLA->setText( _("Document is read-only." + " No changes to layout permitted.")); + dialog_->warningLA->show(); + } else { + dialog_->classesCO->setEnabled( true ); + dialog_->languageCO->setEnabled( true ); + dialog_->warningLA->hide(); + } +} + + +void FormDocument::checkMarginValues() +{ + const int allEmpty = + dialog_->marginTopED->text().isEmpty() && + dialog_->marginBottomED->text().isEmpty() && + dialog_->marginLeftED->text().isEmpty() && + dialog_->marginRightED->text().isEmpty() && + dialog_->headheightED->text().isEmpty() && + dialog_->headsepED->text().isEmpty() && + dialog_->footskipED->text().isEmpty() && + dialog_->customWidthED->text().isEmpty() && + dialog_->customHeightED->text().isEmpty(); + if (!allEmpty) + dialog_->CheckBox1->setChecked( true ); +} + +bool FormDocument::checkDocumentInput(QWidget* w) +{ + string str; + char val; + bool ok = true; + QString input; + + checkMarginValues(); + if (w == dialog_->papersizeCO) { + val = dialog_->papersizeCO->currentItem(); + + if (val == BufferParams::VM_PAPER_DEFAULT) { + dialog_->CheckBox1->setChecked( false ); + checkMarginValues(); + } else { + if ((val != BufferParams::VM_PAPER_USLETTER) && + (val != BufferParams::VM_PAPER_USLEGAL) && + (val != BufferParams::VM_PAPER_USEXECUTIVE) && + (val != BufferParams::VM_PAPER_A4) && + (val != BufferParams::VM_PAPER_A5) && + (val != BufferParams::VM_PAPER_B5)) { + dialog_->CheckBox1->setChecked( true ); + } + dialog_->specialCO->setCurrentItem( BufferParams::PACKAGE_NONE ); + } + } else if (w == dialog_->specialCO ) { + val = dialog_->specialCO->currentItem(); + if (val != BufferParams::PACKAGE_NONE) { + dialog_->papersizeCO->setCurrentItem( BufferParams::VM_PAPER_DEFAULT ); + dialog_->CheckBox1->setChecked( false ); + } + } else if (w == dialog_->spacingED) { + input = dialog_->spacingED->text(); + if (input.isEmpty()) { + dialog_->spacingCO->setCurrentItem( 0 ); + } else { + dialog_->spacingCO->setCurrentItem( 3 ); + } + } + // this has to be all out of if/elseif because it has to deactivate + // the document buttons and so the whole stuff has to be tested again. + str = dialog_->customWidthED->text(); + ok = ok && (str.empty() || isValidLength(str)); + str = dialog_->customHeightED->text(); + ok = ok && (str.empty() || isValidLength(str)); + str = dialog_->marginLeftED->text(); + ok = ok && (str.empty() || isValidLength(str)); + str = dialog_->marginRightED->text(); + ok = ok && (str.empty() || isValidLength(str)); + str = dialog_->marginTopED->text(); + ok = ok && (str.empty() || isValidLength(str)); + str = dialog_->marginBottomED->text(); + ok = ok && (str.empty() || isValidLength(str)); + str = dialog_->headheightED->text(); + ok = ok && (str.empty() || isValidLength(str)); + str = dialog_->headsepED->text(); + ok = ok && (str.empty() || isValidLength(str)); + str = dialog_->footskipED->text(); + ok = ok && (str.empty() || isValidLength(str)); + // "Synchronize" the choice and the input field, so that it + // is impossible to commit senseless data. + input = dialog_->defaultSkipED->text(); + if (w == dialog_->defaultSkipED) { + if (input.isEmpty()) { + dialog_->defaultSkipCO->setCurrentItem( 1 ); + } else if (isValidGlueLength (input.latin1())) { + dialog_->defaultSkipCO->setCurrentItem( 3 ); + } else { + dialog_->defaultSkipCO->setCurrentItem( 3 ); + ok = false; + } + } else { + if (!input.isEmpty() && !isValidGlueLength(input.latin1())) + ok = false; + } + if(( dialog_->defaultSkipCO->currentItem() == 3 ) && input.isEmpty() ) + ok = false; + else if( dialog_->defaultSkipCO->currentItem() != 3 ) + dialog_->defaultSkipED->setText( "" ); + + input = dialog_->spacingED->text(); + if( ( dialog_->spacingCO->currentItem() == 3 ) && input.isEmpty() ) + ok = false; + else if( dialog_->spacingCO->currentItem() != 3 ) + dialog_->spacingED->setText( "" ); + return ok; +} + + +void FormDocument::choiceBulletSize() +{ + BufferParams & param = lv_->buffer()->params; + + // convert from 0-5 range to -1-4 + param.temp_bullets[currentBulletDepth].setSize(dialog_->bulletSizeCO->currentItem() - 1); + dialog_->latexED->setText( param.temp_bullets[currentBulletDepth].getText().c_str()); +} + + +void FormDocument::inputBulletLaTeX() +{ + BufferParams & param = lv_->buffer()->params; + + param.temp_bullets[currentBulletDepth]. + setText(dialog_->latexED->text().latin1() ); +} + + +void FormDocument::bulletDepth(int depth) +{ + /* Should I do the following: */ + /* 1. change to the panel that the current bullet belongs in */ + /* 2. show that bullet as selected */ + /* 3. change the size setting to the size of the bullet in Q.*/ + /* 4. display the latex equivalent in the latex box */ + /* */ + /* I'm inclined to just go with 3 and 4 at the moment and */ + /* maybe try to support the others later */ + BufferParams & param = lv_->buffer()->params; + + // reset on right mouse button not supported in KLyX + // right mouse button resets to default + param.temp_bullets[depth] = ITEMIZE_DEFAULTS[depth]; + dialog_->latexED->setText( param.temp_bullets[depth].getText().c_str()); + dialog_->bulletSizeCO->setCurrentItem( param.temp_bullets[depth].getSize() + 1 ); + + currentBulletDepth = depth; +} + + +// PENDING(kalle) Call this. +void FormDocument::setBulletPics() +{ + QPixmap* currentpix = 0; + if( dialog_->bulletStandardPB->isOn() ) { + currentpix = standardpix; + currentBulletPanel = 0; + } else if( dialog_->bulletMathsPB->isOn() ) { + currentpix = amssymbpix; + currentBulletPanel = 1; + } else if( dialog_->bulletDing1PB->isOn() ) { + currentpix = psnfss1pix; + currentBulletPanel = 2; + } else if( dialog_->bulletDing2PB->isOn() ) { + currentpix = psnfss2pix; + currentBulletPanel = 3; + } else if( dialog_->bulletDing3PB->isOn() ) { + currentpix = psnfss3pix; + currentBulletPanel = 4; + } else if( dialog_->bulletDing4PB->isOn() ) { + currentpix = psnfss4pix; + currentBulletPanel = 5; + } + + for( int x = 0; x < 6; x++ ) + for( int y = 0; y < 6; y++ ) { + bulletpics[x*6+y].resize( 44, 29 ); + bitBlt( &bulletpics[x*6+y], 0, 0, currentpix, x*44, y*29, 44, 29 ); + } + + // This is disgusting, but the only way since the designer does not + // support widget arrays. + dialog_->bullet00PB->setPixmap( bulletpics[0] ); + dialog_->bullet01PB->setPixmap( bulletpics[1] ); + dialog_->bullet02PB->setPixmap( bulletpics[2] ); + dialog_->bullet03PB->setPixmap( bulletpics[3] ); + dialog_->bullet04PB->setPixmap( bulletpics[4] ); + dialog_->bullet05PB->setPixmap( bulletpics[5] ); + dialog_->bullet10PB->setPixmap( bulletpics[6] ); + dialog_->bullet11PB->setPixmap( bulletpics[7] ); + dialog_->bullet12PB->setPixmap( bulletpics[8] ); + dialog_->bullet13PB->setPixmap( bulletpics[9] ); + dialog_->bullet14PB->setPixmap( bulletpics[10] ); + dialog_->bullet15PB->setPixmap( bulletpics[11] ); + dialog_->bullet20PB->setPixmap( bulletpics[12] ); + dialog_->bullet21PB->setPixmap( bulletpics[13] ); + dialog_->bullet22PB->setPixmap( bulletpics[14] ); + dialog_->bullet23PB->setPixmap( bulletpics[15] ); + dialog_->bullet24PB->setPixmap( bulletpics[16] ); + dialog_->bullet25PB->setPixmap( bulletpics[17] ); + dialog_->bullet30PB->setPixmap( bulletpics[18] ); + dialog_->bullet31PB->setPixmap( bulletpics[19] ); + dialog_->bullet32PB->setPixmap( bulletpics[20] ); + dialog_->bullet33PB->setPixmap( bulletpics[21] ); + dialog_->bullet34PB->setPixmap( bulletpics[22] ); + dialog_->bullet35PB->setPixmap( bulletpics[23] ); + dialog_->bullet40PB->setPixmap( bulletpics[24] ); + dialog_->bullet41PB->setPixmap( bulletpics[25] ); + dialog_->bullet42PB->setPixmap( bulletpics[26] ); + dialog_->bullet43PB->setPixmap( bulletpics[27] ); + dialog_->bullet44PB->setPixmap( bulletpics[28] ); + dialog_->bullet45PB->setPixmap( bulletpics[29] ); + dialog_->bullet50PB->setPixmap( bulletpics[30] ); + dialog_->bullet51PB->setPixmap( bulletpics[31] ); + dialog_->bullet52PB->setPixmap( bulletpics[32] ); + dialog_->bullet53PB->setPixmap( bulletpics[33] ); + dialog_->bullet54PB->setPixmap( bulletpics[34] ); + dialog_->bullet55PB->setPixmap( bulletpics[35] ); +} + + +void FormDocument::bulletBMTable(int button) +{ + /* handle the user input by setting the current bullet depth's pixmap */ + /* to that extracted from the current chosen position of the BMTable */ + /* Don't forget to free the button's old pixmap first. */ + + BufferParams & param = lv_->buffer()->params; + + /* try to keep the button held down till another is pushed */ + /* fl_set_bmtable(ob, 1, bmtable_button); */ + param.temp_bullets[currentBulletDepth].setFont(currentBulletPanel); + param.temp_bullets[currentBulletDepth].setCharacter(button); + dialog_->latexED->setText( param.temp_bullets[currentBulletDepth].getText().c_str()); +} + + +void FormDocument::checkChoiceClass(QComboBox* cb) +{ + if (!cb) + cb = dialog_->classesCO; + + ProhibitInput(lv_->view()); + int tc; + string tct; + + tc = cb->currentItem(); + tct = cb->currentText(); + + if (textclasslist.Load(tc)) { + if (AskQuestion(_("Should I set some parameters to"), tct, + _("the defaults of this document class?"))) { + BufferParams & params = lv_->buffer()->params; + + params.textclass = tc; + params.useClassDefaults(); + UpdateLayoutDocument(params); + } + } else { + // unable to load new style + WriteAlert(_("Conversion Errors!"), + _("Unable to switch to new document class."), + _("Reverting to original document class.")); + + dialog_->classesCO->setCurrentItem( + lv_->buffer()->params.textclass ); + } + AllowInput(lv_->view()); +} + + +void FormDocument::UpdateLayoutDocument(BufferParams const & params) +{ + if (!dialog_) + return; + + checkReadOnly(); + class_update(params); + paper_update(params); + language_update(params); + options_update(params); + bullets_update(params); +} diff --git a/src/frontends/qt2/FormDocument.h b/src/frontends/qt2/FormDocument.h new file mode 100644 index 0000000000..6317f595af --- /dev/null +++ b/src/frontends/qt2/FormDocument.h @@ -0,0 +1,165 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright (C) 2000 The LyX Team. + * + * @author Jürgen Vigna, Kalle Dalheimer + * + *======================================================*/ + +#ifndef FORM_DOCUMENT_H +#define FORM_DOCUMENT_H + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "FormBase.h" +#include + +#ifdef __GNUG_ +#pragma interface +#endif + +class LyXView; +class Dialogs; +class Combox; +class BufferParams; + +class QWidget; +class FormDocumentDialog; + +#ifdef SIGC_CXX_NAMESPACES +using SigC::Connection; +#endif + +class QComboBox; + +#include + +/** This class provides an Qt2 implementation of the FormDocument Popup. + The table-layout-form here changes values for latex-tabulars + */ +class FormDocument : public DialogBase { +public: + /// #FormDocument x(Communicator ..., Popups ...);# + FormDocument(LyXView *, Dialogs *); + /// + ~FormDocument(); + /// + enum EnumPopupStatus { + /// + POPUP_UNMODIFIED, + /// + POPUP_MODIFIED, + /// + POPUP_READONLY + }; + +private: + /// Show the dialog. + void show(); + /// Hide the dialog. + void hide(); + + void checkMarginValues(); + /// + void checkReadOnly(); + /// + void UpdateLayoutDocument(BufferParams const & params); + +public: + /// + void checkChoiceClass(QComboBox* cb); +// /// + bool checkDocumentInput(QWidget* w); +// /// + void bulletDepth( int ); + /// + void choiceBulletSize(); +// /// + void inputBulletLaTeX(); +// /// + void setBulletPics(); +// /// + void bulletBMTable( int ); + + /// Update the popup. + void update(); + /// + void paper_update(BufferParams const &); + /// + void class_update(BufferParams const &); + /// + void language_update(BufferParams const &); + /// + void options_update(BufferParams const &); + /// + void bullets_update(BufferParams const &); + /// Apply from popup + void apply(); + /// + void paper_apply(); + /// + bool class_apply(); + /// + bool language_apply(); + /// + bool options_apply(); + /// + void bullets_apply(); + /// Cancel from popup + void cancel(); + /// Build the popup + void build(); + /// Explicitly free the popup. + void free(); + +// /// Typedefinitions from the fdesign produced Header file +// FD_form_tabbed_document * build_tabbed_document(); +// /// +// FD_form_doc_paper * build_doc_paper(); +// /// +// FD_form_doc_class * build_doc_class(); +// /// +// FD_form_doc_language * build_doc_language(); +// /// +// FD_form_doc_options * build_doc_options(); +// /// +// FD_form_doc_bullet * build_doc_bullet(); + +// /// Real GUI implementation. + FormDocumentDialog* dialog_; + + /// Which LyXView do we belong to? + LyXView * lv_; + /// + Dialogs * d_; + /// Update connection. + Connection u_; + /// Hide connection. + Connection h_; + /// has form contents changed? Used to control OK/Apply + EnumPopupStatus status; + /// + int ActCell; + /// + int Confirmed; + /// + int currentBulletPanel; + /// + int currentBulletDepth; + /// + + QPixmap* standardpix; + QPixmap* amssymbpix; + QPixmap* psnfss1pix; + QPixmap* psnfss2pix; + QPixmap* psnfss3pix; + QPixmap* psnfss4pix; + QPixmap bulletpics[36]; +}; + +#endif diff --git a/src/frontends/qt2/FormDocumentDialog.C b/src/frontends/qt2/FormDocumentDialog.C new file mode 100644 index 0000000000..d6d7754cde --- /dev/null +++ b/src/frontends/qt2/FormDocumentDialog.C @@ -0,0 +1,502 @@ +#include "FormDocumentDialog.h" +#include "Dialogs.h" +#include "FormDocument.h" + +#include +#include +#include +#include +#include +#include + +/* + * Constructs a FormDocumentDialog which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +FormDocumentDialog::FormDocumentDialog( FormDocument* _form, QWidget* parent, const char* name, bool modal, WFlags fl ) + : FormDocumentDialogBase( parent, name, modal, fl ), + form( _form ) +{ + // Copy the pointers to the bullet buttons into an array so that + // they can all be manipulated together. + bulletbuttons[0] = bullet00PB; + bulletbuttons[1] = bullet01PB; + bulletbuttons[2] = bullet02PB; + bulletbuttons[3] = bullet03PB; + bulletbuttons[4] = bullet04PB; + bulletbuttons[5] = bullet05PB; + bulletbuttons[6] = bullet10PB; + bulletbuttons[7] = bullet11PB; + bulletbuttons[8] = bullet12PB; + bulletbuttons[9] = bullet13PB; + bulletbuttons[10] = bullet14PB; + bulletbuttons[11] = bullet15PB; + bulletbuttons[12] = bullet20PB; + bulletbuttons[13] = bullet21PB; + bulletbuttons[14] = bullet22PB; + bulletbuttons[15] = bullet23PB; + bulletbuttons[16] = bullet24PB; + bulletbuttons[17] = bullet25PB; + bulletbuttons[18] = bullet30PB; + bulletbuttons[19] = bullet31PB; + bulletbuttons[20] = bullet32PB; + bulletbuttons[21] = bullet33PB; + bulletbuttons[22] = bullet34PB; + bulletbuttons[23] = bullet35PB; + bulletbuttons[24] = bullet40PB; + bulletbuttons[25] = bullet41PB; + bulletbuttons[26] = bullet42PB; + bulletbuttons[27] = bullet43PB; + bulletbuttons[28] = bullet44PB; + bulletbuttons[29] = bullet45PB; + bulletbuttons[30] = bullet50PB; + bulletbuttons[31] = bullet51PB; + bulletbuttons[32] = bullet52PB; + bulletbuttons[33] = bullet53PB; + bulletbuttons[34] = bullet54PB; + bulletbuttons[35] = bullet55PB; +} + +/* + * Destroys the object and frees any allocated resources + */ +FormDocumentDialog::~FormDocumentDialog() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * public slot + */ +void FormDocumentDialog::slotApply() +{ + form->apply(); + // PENDING(kalle) Check whether we need this + // form->bc_->apply(); +} +/* + * public slot + */ +void FormDocumentDialog::slotAMSMath(bool) +{ + form->checkDocumentInput( amsMathCB ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletDepth1() +{ + form->bulletDepth( 0 ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletDepth2() +{ + form->bulletDepth( 1 ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletDepth3() +{ + form->bulletDepth( 2 ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletDepth4() +{ + form->bulletDepth( 3 ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletDing1() +{ + qDebug( "FormDocumentDialog::slotBulletDing1()" ); + form->checkDocumentInput( bulletDing1PB ); + form->setBulletPics(); + bulletStandardPB->setOn( false ); + bulletMathsPB->setOn( false ); + bulletDing2PB->setOn( false ); + bulletDing3PB->setOn( false ); + bulletDing4PB->setOn( false ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletDing2() +{ + form->checkDocumentInput( bulletDing2PB ); + form->setBulletPics(); + bulletStandardPB->setOn( false ); + bulletMathsPB->setOn( false ); + bulletDing1PB->setOn( false ); + bulletDing3PB->setOn( false ); + bulletDing4PB->setOn( false ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletDing3() +{ + form->checkDocumentInput( bulletDing3PB ); + form->setBulletPics(); + bulletStandardPB->setOn( false ); + bulletMathsPB->setOn( false ); + bulletDing2PB->setOn( false ); + bulletDing1PB->setOn( false ); + bulletDing4PB->setOn( false ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletDing4() +{ + form->checkDocumentInput( bulletDing4PB ); + form->setBulletPics(); + bulletStandardPB->setOn( false ); + bulletMathsPB->setOn( false ); + bulletDing2PB->setOn( false ); + bulletDing3PB->setOn( false ); + bulletDing1PB->setOn( false ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletMaths() +{ + form->checkDocumentInput( bulletMathsPB ); + form->setBulletPics(); + bulletStandardPB->setOn( false ); + bulletDing1PB->setOn( false ); + bulletDing2PB->setOn( false ); + bulletDing3PB->setOn( false ); + bulletDing4PB->setOn( false ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletSize(int) +{ + form->choiceBulletSize(); + form->checkDocumentInput( bulletSizeCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletStandard() +{ + form->checkDocumentInput( bulletStandardPB ); + form->setBulletPics(); + bulletDing1PB->setOn( false ); + bulletMathsPB->setOn( false ); + bulletDing2PB->setOn( false ); + bulletDing3PB->setOn( false ); + bulletDing4PB->setOn( false ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletSymbol(int n) +{ + qDebug( "FormDocumentDialog::slotBulletSymbol( %d )", n ); + for( int i = 0; i < 36; i++ ) + bulletbuttons[i]->setOn( false ); + bulletbuttons[n]->setOn( true ); + form->bulletBMTable( n ); + form->checkDocumentInput( bulletTypeBG ); +} +/* + * public slot + */ +void FormDocumentDialog::slotClass(int) +{ + form->checkChoiceClass( 0 ); + form->checkDocumentInput( classesCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotClose() +{ + form->cancel(); + form->hide(); + // PENDING(kalle) do something with this + // form->bc_->cancel(); +} +/* + * public slot + */ +void FormDocumentDialog::slotColumns(int) +{ + form->checkDocumentInput( columnsBG ); +} +/* + * public slot + */ +void FormDocumentDialog::slotDefaultSkip(const QString&) +{ + form->checkDocumentInput( defaultSkipED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotDefaultSkip(int) +{ + form->checkChoiceClass( defaultSkipCO ); + form->checkDocumentInput( defaultSkipCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotEncoding(int) +{ + form->checkChoiceClass( encodingCO ); + form->checkDocumentInput( encodingCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotExtraOptions(const QString&) +{ + form->checkDocumentInput( extraOptionsED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotFloatPlacement(const QString&) +{ + form->checkDocumentInput( floatPlacementED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotFont(int) +{ + form->checkChoiceClass( fontsCO ); + form->checkDocumentInput( fontsCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotFontSize(int) +{ + form->checkChoiceClass( fontSizeCO ); + form->checkDocumentInput( fontSizeCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotFootskip(const QString&) +{ + form->checkDocumentInput( footskipED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotHeadheight(const QString&) +{ + form->checkDocumentInput( headheightED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotHeadsep(const QString&) +{ + form->checkDocumentInput( headsepED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotHeight(const QString&) +{ + form->checkDocumentInput( customHeightED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotLanguage(int) +{ + form->checkChoiceClass( languageCO ); + form->checkDocumentInput( languageCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotBulletLaTeX(const QString&) +{ + form->inputBulletLaTeX(); + form->checkDocumentInput( latexED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotMarginBottom(const QString&) +{ + form->checkDocumentInput( marginBottomED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotMarginLeft(const QString&) +{ + form->checkDocumentInput( marginLeftED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotMarginRight(const QString&) +{ + form->checkDocumentInput( marginRightED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotMarginTop(const QString&) +{ + form->checkDocumentInput( marginTopED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotOK() +{ + form->apply(); + form->hide(); + // PENDING(kalle) Do something about this. + // form->bc_->ok(); +} +/* + * public slot + */ +void FormDocumentDialog::slotOrientation(int) +{ + form->checkDocumentInput( orientationBG ); +} +/* + * public slot + */ +void FormDocumentDialog::slotPSDriver(int) +{ + form->checkChoiceClass( psDriverCO ); + form->checkDocumentInput( psDriverCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotPageStyle(int) +{ + form->checkChoiceClass( pagestyleCO ); + form->checkDocumentInput( pagestyleCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotPapersize(int) +{ + form->checkChoiceClass( pagestyleCO ); + form->checkDocumentInput( papersizeCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotQuoteStyle(int) +{ + form->checkChoiceClass( quoteStyleTypeCO ); + form->checkDocumentInput( quoteStyleTypeCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotQuoteType(int) +{ + // Intentionally left blank +} +/* + * public slot + */ +void FormDocumentDialog::slotRestore() +{ + form->update(); + // PENDING(kalle) Do something about this. + // form->bc_->updateAll(); +} +/* + * public slot + */ +void FormDocumentDialog::slotSectionNumberDepth(int) +{ + form->checkDocumentInput( sectionNumberDepthSB ); +} +/* + * public slot + */ +void FormDocumentDialog::slotSeparation(int) +{ + form->checkDocumentInput( separationBG ); +} +/* + * public slot + */ +void FormDocumentDialog::slotSides(int) +{ + form->checkDocumentInput( sidesBG ); +} +/* + * public slot + */ +void FormDocumentDialog::slotSpacing(const QString&) +{ + form->checkDocumentInput( spacingED ); +} +/* + * public slot + */ +void FormDocumentDialog::slotSpacing(int) +{ + form->checkDocumentInput( spacingCO ); + form->checkDocumentInput( spacingCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotSpecialPaperPackage(int) +{ + form->checkChoiceClass( specialCO ); + form->checkDocumentInput( specialCO ); +} +/* + * public slot + */ +void FormDocumentDialog::slotTOCDepth(int) +{ + form->checkDocumentInput( tocDepthSB ); +} +/* + * public slot + */ +void FormDocumentDialog::slotUseGeometryPackage(bool) +{ + form->checkDocumentInput( CheckBox1 ); +} +/* + * public slot + */ +void FormDocumentDialog::slotWidth(const QString&) +{ + form->checkDocumentInput( customWidthED ); +} + + +void FormDocumentDialog::closeEvent( QCloseEvent* e ) +{ + form->hide(); + //PENDING(kalle) Do something about this. + // form->bc_->hide(); + e->accept(); +} diff --git a/src/frontends/qt2/FormDocumentDialog.h b/src/frontends/qt2/FormDocumentDialog.h new file mode 100644 index 0000000000..ff9d24372d --- /dev/null +++ b/src/frontends/qt2/FormDocumentDialog.h @@ -0,0 +1,76 @@ +#ifndef FORMDOCUMENTDIALOG_H +#define FORMDOCUMENTDIALOG_H +#include "FormDocumentDialogBase.h" + +class FormDocument; + +class FormDocumentDialog : public FormDocumentDialogBase +{ + Q_OBJECT + +public: + FormDocumentDialog( FormDocument* form, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~FormDocumentDialog(); + +public slots: + void slotApply(); + void slotBulletLaTeX(const QString&); + void slotAMSMath(bool); + void slotBulletDepth1(); + void slotBulletDepth2(); + void slotBulletDepth3(); + void slotBulletDepth4(); + void slotBulletDing1(); + void slotBulletDing2(); + void slotBulletDing3(); + void slotBulletDing4(); + void slotBulletMaths(); + void slotBulletSize(int); + void slotBulletStandard(); + void slotBulletSymbol(int); + void slotClass(int); + void slotClose(); + void slotColumns(int); + void slotDefaultSkip(const QString&); + void slotDefaultSkip(int); + void slotEncoding(int); + void slotExtraOptions(const QString&); + void slotFloatPlacement(const QString&); + void slotFont(int); + void slotFontSize(int); + void slotFootskip(const QString&); + void slotHeadheight(const QString&); + void slotHeadsep(const QString&); + void slotHeight(const QString&); + void slotLanguage(int); + void slotMarginBottom(const QString&); + void slotMarginLeft(const QString&); + void slotMarginRight(const QString&); + void slotMarginTop(const QString&); + void slotOK(); + void slotOrientation(int); + void slotPSDriver(int); + void slotPageStyle(int); + void slotPapersize(int); + void slotQuoteStyle(int); + void slotQuoteType(int); + void slotRestore(); + void slotSectionNumberDepth(int); + void slotSeparation(int); + void slotSides(int); + void slotSpacing(const QString&); + void slotSpacing(int); + void slotSpecialPaperPackage(int); + void slotTOCDepth(int); + void slotUseGeometryPackage(bool); + void slotWidth(const QString&); + +protected: + void closeEvent( QCloseEvent* ); + +private: + FormDocument* form; + QToolButton* bulletbuttons[36]; +}; + +#endif // FORMDOCUMENTDIALOG_H diff --git a/src/frontends/qt2/FormDocumentDialogBase.ui b/src/frontends/qt2/FormDocumentDialogBase.ui new file mode 100644 index 0000000000..a617fc5ac3 --- /dev/null +++ b/src/frontends/qt2/FormDocumentDialogBase.ui @@ -0,0 +1,4952 @@ + +FormDocumentDialogBase + + QDialog + + name + FormDocumentDialogBase + + + geometry + + 0 + 0 + 538 + 437 + + + + caption + Document Layout + + + + margin + 11 + + + spacing + 6 + + + QTabWidget + + name + TabWidget2 + + + layoutMargin + + + QWidget + + name + Widget2 + + + title + Document + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout33 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout32 + + + + margin + 0 + + + spacing + 6 + + + QLineEdit + + name + extraOptionsED + + + + QLabel + + name + fontsLA + + + text + &Fonts: + + + buddy + fontsCO + + + + QLabel + + name + pagestyleLA + + + text + &Pagestyle: + + + buddy + pagestyleCO + + + + QLabel + + name + defaultSkipLA + + + text + Defa&ult Skip: + + + buddy + defaultSkipCO + + + + QLabel + + name + fontSizeLA + + + text + F&ont Size: + + + buddy + fontSizeCO + + + + QComboBox + + + text + default + + + + + text + empty + + + + + text + plain + + + + + text + headings + + + + + text + fancy + + + + name + pagestyleCO + + + + QLabel + + name + spacingLA + + + text + Spacin&g: + + + buddy + spacingCO + + + + QLabel + + name + extraOptionsLA + + + text + E&xtra Options: + + + buddy + extraOptionsED + + + + QLabel + + name + classesLA + + + text + &Class: + + + buddy + classesCO + + + + QLayoutWidget + + name + Layout13 + + + + margin + 0 + + + spacing + 6 + + + QComboBox + + + text + smallskip + + + + + text + medskip + + + + + text + bigskip + + + + + text + length + + + + name + defaultSkipCO + + + + QLineEdit + + name + defaultSkipED + + + + + + QLayoutWidget + + name + Layout31 + + + + margin + 0 + + + spacing + 6 + + + QComboBox + + + text + Single + + + + + text + OneHalf + + + + + text + Double + + + + + text + Other + + + + name + spacingCO + + + + QLineEdit + + name + spacingED + + + + + + QComboBox + + name + fontsCO + + + + QComboBox + + name + classesCO + + + + QComboBox + + + text + default + + + + + text + 10 + + + + + text + 11 + + + + + text + 12 + + + + name + fontSizeCO + + + + + + + name + Spacer2_2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + QLayoutWidget + + name + Layout52 + + + + margin + 0 + + + spacing + 6 + + + QButtonGroup + + name + sidesBG + + + title + Sides + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + oneSideRB + + + text + O&ne + + + + QRadioButton + + name + twoSidesRB + + + text + &Two + + + + + + QButtonGroup + + name + columnsBG + + + title + Columns + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + oneColumnRB + + + text + On&e + + + + QRadioButton + + name + twoColumnsRB + + + text + T&wo + + + + + + QButtonGroup + + name + separationBG + + + title + Separation + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + indentRB + + + text + &Indent + + + + QRadioButton + + name + skipRB + + + text + S&kip + + + + + + + name + Spacer33 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + + + QWidget + + name + Widget3 + + + title + Paper + + + + margin + 11 + + + spacing + 6 + + + + name + Spacer34 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout19 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + papersizeLA + + + text + &Papersize: + + + buddy + papersizeCO + + + + QComboBox + + + text + Default + + + + + text + Custom + + + + + text + USletter + + + + + text + USlegal + + + + + text + USexecutive + + + + + text + A3 + + + + + text + A5 + + + + + text + B3 + + + + + text + B4 + + + + + text + B5 + + + + name + papersizeCO + + + + + name + Spacer5 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLabel + + name + specialLA + + + text + &Special: + + + buddy + specialCO + + + + QComboBox + + + text + None + + + + + text + A4 small Margins (only portrait) + + + + + text + A4 very small Margins (only portrait) + + + + + text + A4 very wide margins (only portrait) + + + + name + specialCO + + + + + + + name + Spacer35 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout23 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer6 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QCheckBox + + name + CheckBox1 + + + text + &Use Geometry Package + + + + + name + Spacer7 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer36 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout22 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout20 + + + + margin + 0 + + + spacing + 6 + + + QButtonGroup + + name + orientationBG + + + title + Orientation + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + portraitRB + + + text + P&ortrait + + + + QRadioButton + + name + landscapeRB + + + text + &Landscape + + + + + + QGroupBox + + name + marginsGB + + + title + Margins + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + marginRightLA + + + text + &Right: + + + buddy + marginRightED + + + + QLineEdit + + name + marginLeftED + + + + QLineEdit + + name + marginBottomED + + + + QLineEdit + + name + marginRightED + + + + QLabel + + name + marginBottomLA + + + text + &Bottom: + + + buddy + marginBottomED + + + + QLineEdit + + name + marginTopED + + + + QLabel + + name + marginLeftL + + + text + L&eft: + + + buddy + marginLeftED + + + + QLabel + + name + marginTopLA + + + text + &Top: + + + buddy + marginTopED + + + + + + + + QLayoutWidget + + name + Layout21 + + + + margin + 0 + + + spacing + 6 + + + QGroupBox + + name + customPapersizeGB + + + title + Custom Papersize + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + customWidthLA + + + text + &Width: + + + buddy + customWidthED + + + + QLineEdit + + name + customWidthED + + + + QLineEdit + + name + customHeightED + + + + QLabel + + name + customHeightLA + + + text + &Height: + + + buddy + customHeightED + + + + + + QGroupBox + + name + headsepBG + + + title + Foot/Head Margins + + + + margin + 11 + + + spacing + 6 + + + QLineEdit + + name + headheightED + + + + QLineEdit + + name + headsepED + + + + QLineEdit + + name + footskipED + + + + QLabel + + name + footskipLA + + + text + &Footskip: + + + buddy + footskipED + + + + QLabel + + name + headsepLA + + + text + Hea&dsep: + + + buddy + headsepED + + + + QLabel + + name + headheightLA + + + text + Headhe&ight: + + + buddy + headheightED + + + + + + + + + + + name + Spacer37 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + QWidget + + name + Widget4 + + + title + Language + + + + margin + 11 + + + spacing + 6 + + + + name + Spacer10 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout53 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer12 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout26 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + languageLA + + + text + &Language: + + + buddy + languageCO + + + + QComboBox + + name + languageCO + + + + + + + name + Spacer38 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout27 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + encodingLA + + + text + Enco&ding: + + + buddy + encodingCO + + + + QComboBox + + + text + default + + + + + text + auto + + + + + text + latin1 + + + + + text + latin2 + + + + + text + latin5 + + + + + text + koi8-r + + + + + text + koi8-u + + + + + text + cp866 + + + + + text + cp1251 + + + + + text + iso88595 + + + + name + encodingCO + + + + + + + name + Spacer9 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QButtonGroup + + name + quoteStyleBG + + + title + Quote Style + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout28 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + quoteStyleTypeLA + + + text + &Type: + + + buddy + quoteStyleTypeCO + + + + QComboBox + + + text + ``text'' + + + + + text + ''text'' + + + + + text + ,,text`` + + + + + text + ,,text'' + + + + + text + «text» + + + + + text + »text« + + + + name + quoteStyleTypeCO + + + + + + QLayoutWidget + + name + Layout29 + + + + margin + 0 + + + spacing + 6 + + + QRadioButton + + name + quoteStyleSingleRB + + + text + &Single + + + + QRadioButton + + name + quoteStyleDoubleRB + + + text + &Double + + + + + + + + + name + Spacer13 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer11 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + QWidget + + name + Widget5 + + + title + Extra + + + + margin + 11 + + + spacing + 6 + + + + name + Spacer24 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout39 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer18 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout33 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel28 + + + text + F&loat Placement: + + + buddy + floatPlacementED + + + + QLineEdit + + name + floatPlacementED + + + + + + + name + Spacer14 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout34 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + sectionNumberDepthLA + + + text + S&ection number depth: + + + buddy + sectionNumberDepthSB + + + + QSpinBox + + name + sectionNumberDepthSB + + + minValue + -2 + + + maxValue + 5 + + + + + + + name + Spacer15 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout35 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + tocDepthLA + + + text + &Table of contents depth: + + + buddy + tocDepthSB + + + + QSpinBox + + name + tocDepthSB + + + minValue + -1 + + + maxValue + 5 + + + + + + + name + Spacer16 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout36 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + psDriverLA + + + text + P&S Driver: + + + buddy + psDriverCO + + + + QComboBox + + name + psDriverCO + + + + + + + name + Spacer17 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout38 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer23 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QCheckBox + + name + amsMathCB + + + text + Use A&MS Math + + + + + name + Spacer22 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer19 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer25 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + QWidget + + name + Widget6 + + + title + Bullets + + + + margin + 6 + + + spacing + -1 + + + QLayoutWidget + + name + Layout51 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout48 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer31 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLabel + + name + bulletSizeLA + + + text + Si&ze + + + buddy + bulletSizeCO + + + + QComboBox + + + text + default + + + + + text + tiny + + + + + text + script + + + + + text + footnote + + + + + text + small + + + + + text + normal + + + + + text + large + + + + + text + Large + + + + + text + LARGE + + + + + text + huge + + + + + text + Huge + + + + name + bulletSizeCO + + + + + + QLayoutWidget + + name + Layout50 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer32 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QButtonGroup + + name + bulletDepthBG + + + title + Bullet Depth + + + exclusive + true + + + + margin + 11 + + + spacing + 6 + + + QToolButton + + name + bulletDepth1PB + + + text + &1 + + + toggleButton + true + + + + QToolButton + + name + bulletDepth2PB + + + text + &2 + + + toggleButton + true + + + + QToolButton + + name + bulletDepth3PB + + + text + &3 + + + toggleButton + true + + + + QToolButton + + name + bulletDepth4PB + + + text + &4 + + + toggleButton + true + + + + + + + + + + + name + Spacer1 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout47 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer27 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QButtonGroup + + name + bulletTypeBG + + + title + + + + frameShape + NoFrame + + + radioButtonExclusive + false + + + layoutSpacing + + + + name + Spacer26 + + + geometry + + 77 + 12 + 20 + 20 + + + + orientation + Horizontal + + + sizeType + Fixed + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QToolButton + + name + bullet01PB + + + geometry + + 121 + 11 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet02PB + + + geometry + + 144 + 11 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet03PB + + + geometry + + 167 + 11 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet04PB + + + geometry + + 190 + 11 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet10PB + + + geometry + + 98 + 33 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet11PB + + + geometry + + 121 + 33 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet12PB + + + geometry + + 144 + 33 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet13PB + + + geometry + + 167 + 33 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet14PB + + + geometry + + 190 + 33 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet15PB + + + geometry + + 213 + 33 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet21PB + + + geometry + + 121 + 55 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet20PB + + + geometry + + 98 + 55 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet22PB + + + geometry + + 144 + 55 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet23PB + + + geometry + + 167 + 55 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet24PB + + + geometry + + 190 + 55 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet25PB + + + geometry + + 213 + 55 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet30PB + + + geometry + + 98 + 77 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet31PB + + + geometry + + 121 + 77 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet32PB + + + geometry + + 144 + 77 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet33PB + + + geometry + + 167 + 77 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet34PB + + + geometry + + 190 + 77 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet35PB + + + geometry + + 213 + 77 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet42PB + + + geometry + + 144 + 99 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet43PB + + + geometry + + 167 + 99 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet44PB + + + geometry + + 190 + 99 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet45PB + + + geometry + + 213 + 99 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet50PB + + + geometry + + 98 + 121 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet51PB + + + geometry + + 121 + 121 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet52PB + + + geometry + + 144 + 121 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet53PB + + + geometry + + 167 + 121 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet54PB + + + geometry + + 190 + 121 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet55PB + + + geometry + + 213 + 121 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet05PB + + + geometry + + 213 + 11 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet00PB + + + geometry + + 98 + 11 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bulletDing3PB + + + geometry + + 11 + 99 + 66 + 22 + + + + text + Di&ng 3 + + + toggleButton + true + + + + QToolButton + + name + bulletDing4PB + + + geometry + + 11 + 121 + 66 + 22 + + + + text + Din&g 4 + + + + QToolButton + + name + bullet40PB + + + geometry + + 98 + 99 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bullet41PB + + + geometry + + 121 + 99 + 23 + 22 + + + + text + + + + sizePolicy + + 0 + 0 + + + + toggleButton + true + + + + QToolButton + + name + bulletStandardPB + + + geometry + + 11 + 11 + 66 + 22 + + + + text + &Standard + + + toggleButton + true + + + + QToolButton + + name + bulletMathsPB + + + geometry + + 11 + 33 + 66 + 22 + + + + text + &Maths + + + toggleButton + true + + + + QToolButton + + name + bulletDing1PB + + + geometry + + 11 + 55 + 66 + 22 + + + + text + &Ding 1 + + + toggleButton + true + + + + QToolButton + + name + bulletDing2PB + + + geometry + + 11 + 77 + 66 + 22 + + + + text + D&ing 2 + + + toggleButton + true + + + + + + name + Spacer28 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout45 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer29 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout42 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + latexLA + + + text + &LaTeX + + + buddy + latexED + + + + QLineEdit + + name + latexED + + + maxLength + 80 + + + + + + + name + Spacer30 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + + + + + + QLabel + + name + warningLA + + + text + + + + font + + 1 + + + + palette + + + + 0 + 0 + 0 + + + 220 + 220 + 220 + + + 255 + 255 + 255 + + + 237 + 237 + 237 + + + 110 + 110 + 110 + + + 146 + 146 + 146 + + + 255 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 0 + 128 + 128 + + + 255 + 255 + 255 + + + + + 128 + 128 + 128 + + + 220 + 220 + 220 + + + 255 + 255 + 255 + + + 253 + 253 + 253 + + + 110 + 110 + 110 + + + 146 + 146 + 146 + + + 255 + 0 + 0 + + + 255 + 255 + 255 + + + 128 + 128 + 128 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 0 + 128 + 128 + + + 255 + 255 + 255 + + + + + 0 + 0 + 0 + + + 220 + 220 + 220 + + + 255 + 255 + 255 + + + 253 + 253 + 253 + + + 110 + 110 + 110 + + + 146 + 146 + 146 + + + 255 + 0 + 0 + + + 255 + 255 + 255 + + + 0 + 0 + 0 + + + 255 + 255 + 255 + + + 220 + 220 + 220 + + + 0 + 0 + 0 + + + 0 + 128 + 128 + + + 255 + 255 + 255 + + + + + + alignment + AlignCenter + + + hAlign + + + + QLayoutWidget + + name + Layout54 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer39 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + restorePB + + + text + &Restore + + + + QPushButton + + name + okPB + + + text + OK + + + default + true + + + + QPushButton + + name + applyPB + + + text + &Apply + + + + QPushButton + + name + cancelPB + + + text + Close + + + + + + + + + okPB + clicked() + FormDocumentDialogBase + slotOK() + + + restorePB + clicked() + FormDocumentDialogBase + slotRestore() + + + specialCO + activated(int) + FormDocumentDialogBase + slotSpecialPaperPackage(int) + + + orientationBG + clicked(int) + FormDocumentDialogBase + slotOrientation(int) + + + papersizeCO + activated(int) + FormDocumentDialogBase + slotPapersize(int) + + + CheckBox1 + toggled(bool) + FormDocumentDialogBase + slotUseGeometryPackage(bool) + + + customWidthED + textChanged(const QString&) + FormDocumentDialogBase + slotWidth(const QString&) + + + customHeightED + textChanged(const QString&) + FormDocumentDialogBase + slotHeight(const QString&) + + + marginTopED + textChanged(const QString&) + FormDocumentDialogBase + slotMarginTop(const QString&) + + + marginBottomED + textChanged(const QString&) + FormDocumentDialogBase + slotMarginBottom(const QString&) + + + marginLeftED + textChanged(const QString&) + FormDocumentDialogBase + slotMarginLeft(const QString&) + + + marginRightED + textChanged(const QString&) + FormDocumentDialogBase + slotMarginRight(const QString&) + + + headheightED + textChanged(const QString&) + FormDocumentDialogBase + slotHeadheight(const QString&) + + + headsepED + textChanged(const QString&) + FormDocumentDialogBase + slotHeadsep(const QString&) + + + footskipED + textChanged(const QString&) + FormDocumentDialogBase + slotFootskip(const QString&) + + + classesCO + activated(int) + FormDocumentDialogBase + slotClass(int) + + + pagestyleCO + activated(int) + FormDocumentDialogBase + slotPageStyle(int) + + + fontsCO + activated(int) + FormDocumentDialogBase + slotFont(int) + + + fontSizeCO + activated(int) + FormDocumentDialogBase + slotFontSize(int) + + + extraOptionsED + textChanged(const QString&) + FormDocumentDialogBase + slotExtraOptions(const QString&) + + + defaultSkipCO + activated(int) + FormDocumentDialogBase + slotDefaultSkip(int) + + + defaultSkipED + textChanged(const QString&) + FormDocumentDialogBase + slotDefaultSkip(const QString&) + + + spacingCO + activated(int) + FormDocumentDialogBase + slotSpacing(int) + + + spacingED + textChanged(const QString&) + FormDocumentDialogBase + slotSpacing(const QString&) + + + sidesBG + clicked(int) + FormDocumentDialogBase + slotSides(int) + + + columnsBG + clicked(int) + FormDocumentDialogBase + slotColumns(int) + + + separationBG + clicked(int) + FormDocumentDialogBase + slotSeparation(int) + + + languageCO + activated(int) + FormDocumentDialogBase + slotLanguage(int) + + + encodingCO + activated(int) + FormDocumentDialogBase + slotEncoding(int) + + + quoteStyleTypeCO + activated(int) + FormDocumentDialogBase + slotQuoteStyle(int) + + + quoteStyleBG + clicked(int) + FormDocumentDialogBase + slotQuoteStyle(int) + + + floatPlacementED + textChanged(const QString&) + FormDocumentDialogBase + slotFloatPlacement(const QString&) + + + sectionNumberDepthSB + valueChanged(int) + FormDocumentDialogBase + slotSectionNumberDepth(int) + + + tocDepthSB + valueChanged(int) + FormDocumentDialogBase + slotTOCDepth(int) + + + psDriverCO + activated(int) + FormDocumentDialogBase + slotPSDriver(int) + + + amsMathCB + toggled(bool) + FormDocumentDialogBase + slotAMSMath(bool) + + + applyPB + clicked() + FormDocumentDialogBase + slotApply() + + + cancelPB + clicked() + FormDocumentDialogBase + slotClose() + + + latexED + textChanged(const QString&) + FormDocumentDialogBase + slotBulletLaTeX(const QString&) + + + bulletStandardPB + clicked() + FormDocumentDialogBase + slotBulletStandard() + + + bulletMathsPB + clicked() + FormDocumentDialogBase + slotBulletMaths() + + + bulletDing1PB + clicked() + FormDocumentDialogBase + slotBulletDing1() + + + bulletDing2PB + clicked() + FormDocumentDialogBase + slotBulletDing2() + + + bulletDing3PB + clicked() + FormDocumentDialogBase + slotBulletDing3() + + + bulletDing4PB + clicked() + FormDocumentDialogBase + slotBulletDing4() + + + bulletTypeBG + clicked(int) + FormDocumentDialogBase + slotBulletSymbol(int) + + + bulletSizeCO + activated(int) + FormDocumentDialogBase + slotBulletSize(int) + + + bulletDepth1PB + clicked() + FormDocumentDialogBase + slotBulletDepth1() + + + bulletDepth2PB + clicked() + FormDocumentDialogBase + slotBulletDepth2() + + + bulletDepth3PB + clicked() + FormDocumentDialogBase + slotBulletDing3() + + + bulletDepth4PB + clicked() + FormDocumentDialogBase + slotBulletDepth4() + + slotAMSMath(bool) + slotApply() + slotBulletDepth1() + slotBulletDepth2() + slotBulletDepth3() + slotBulletDepth4() + slotBulletDing1() + slotBulletDing2() + slotBulletDing3() + slotBulletDing4() + slotBulletLaTeX(const QString&) + slotBulletMaths() + slotBulletSize(int) + slotBulletStandard() + slotBulletSymbol(int) + slotClass(int) + slotClose() + slotColumns(int) + slotDefaultSkip(const QString&) + slotDefaultSkip(int) + slotEncoding(int) + slotExtraOptions(const QString&) + slotFloatPlacement(const QString&) + slotFont(int) + slotFontSize(int) + slotFootskip(const QString&) + slotHeadheight(const QString&) + slotHeadsep(const QString&) + slotHeight(const QString&) + slotLanguage(int) + slotMarginBottom(const QString&) + slotMarginLeft(const QString&) + slotMarginRight(const QString&) + slotMarginTop(const QString&) + slotOK() + slotOrientation(int) + slotPSDriver(int) + slotPageStyle(int) + slotPapersize(int) + slotQuoteStyle(int) + slotQuoteType(int) + slotRestore() + slotSectionNumberDepth(int) + slotSeparation(int) + slotSides(int) + slotSpacing(const QString&) + slotSpacing(int) + slotSpecialPaperPackage(int) + slotTOCDepth(int) + slotUseGeometryPackage(bool) + slotWidth(const QString&) + + + classesCO + pagestyleCO + fontsCO + fontSizeCO + extraOptionsED + defaultSkipCO + defaultSkipED + spacingCO + spacingED + oneSideRB + twoSidesRB + oneColumnRB + twoColumnsRB + indentRB + skipRB + papersizeCO + specialCO + CheckBox1 + portraitRB + landscapeRB + marginTopED + marginBottomED + marginLeftED + marginRightED + customWidthED + customHeightED + headheightED + headsepED + footskipED + languageCO + encodingCO + quoteStyleTypeCO + quoteStyleSingleRB + quoteStyleDoubleRB + floatPlacementED + sectionNumberDepthSB + tocDepthSB + psDriverCO + amsMathCB + bulletSizeCO + latexED + restorePB + okPB + applyPB + cancelPB + TabWidget2 + + diff --git a/src/frontends/qt2/FormIndex.C b/src/frontends/qt2/FormIndex.C new file mode 100644 index 0000000000..a6bfc5cde6 --- /dev/null +++ b/src/frontends/qt2/FormIndex.C @@ -0,0 +1,132 @@ +/* + * FormIndex.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include + +#include "FormIndexDialog.h" +#undef emit + +#include "Dialogs.h" +#include "FormIndex.h" +#include "gettext.h" +#include "buffer.h" +#include "LyXView.h" +#include "lyxfunc.h" + +#include +#include + +FormIndex::FormIndex(LyXView *v, Dialogs *d) + : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0) +{ + // let the dialog be shown + // This is a permanent connection so we won't bother + // storing a copy because we won't be disconnecting. + d->showIndex.connect(slot(this, &FormIndex::showIndex)); + d->createIndex.connect(slot(this, &FormIndex::createIndex)); +} + +FormIndex::~FormIndex() +{ + delete dialog_; +} + +void FormIndex::showIndex(InsetCommand * const inset) +{ + // FIXME: when could inset be 0 here ? + if (inset==0) + return; + + inset_ = inset; + readonly = lv_->buffer()->isReadonly(); + ih_ = inset_->hide.connect(slot(this,&FormIndex::hide)); + params = inset->params(); + + show(); +} + +void FormIndex::createIndex(string const & arg) +{ + // we could already be showing a URL, clear it out + if (inset_) + close(); + + readonly = lv_->buffer()->isReadonly(); + params.setFromString(arg); + show(); +} + +void FormIndex::update() +{ + dialog_->keywordED->setText(params.getContents().c_str()); + + if (readonly) { + dialog_->keywordED->setFocusPolicy(QWidget::NoFocus); + dialog_->okPB->setEnabled(false); + dialog_->cancelPB->setText(_("Close")); + } else { + dialog_->keywordED->setFocusPolicy(QWidget::StrongFocus); + dialog_->keywordED->setFocus(); + dialog_->okPB->setEnabled(true); + dialog_->cancelPB->setText(_("Cancel")); + } +} + +void FormIndex::apply() +{ + if (readonly) + return; + + params.setContents(dialog_->keywordED->text().latin1()); + + if (inset_ != 0) { + if (params != inset_->params()) { + inset_->setParams(params); + lv_->view()->updateInset(inset_, true); + } + } else + lv_->getLyXFunc()->Dispatch(LFUN_INDEX_INSERT, params.getAsString().c_str()); +} + +void FormIndex::show() +{ + if (!dialog_) + dialog_ = new FormIndexDialog(this, 0, _("LyX: Index"), false); + + if (!dialog_->isVisible()) { + h_ = d_->hideBufferDependent.connect(slot(this, &FormIndex::hide)); + u_ = d_->updateBufferDependent.connect(slot(this, &FormIndex::update)); + } + + dialog_->raise(); + dialog_->setActiveWindow(); + + update(); + dialog_->show(); +} + +void FormIndex::close() +{ + h_.disconnect(); + u_.disconnect(); + ih_.disconnect(); + inset_ = 0; +} + +void FormIndex::hide() +{ + dialog_->hide(); + close(); +} diff --git a/src/frontends/qt2/FormIndex.h b/src/frontends/qt2/FormIndex.h new file mode 100644 index 0000000000..f451a44901 --- /dev/null +++ b/src/frontends/qt2/FormIndex.h @@ -0,0 +1,82 @@ +/* FormIndex.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + * Adapted for Qt2 frontend by Kalle Dalheimer, + * kalle@klaralvdalens-datakonsult.se + */ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FORMINDEX_H +#define FORMINDEX_H + +#include "DialogBase.h" +#include "LString.h" +#include "boost/utility.hpp" +#include "insets/insetindex.h" + +class Dialogs; +class LyXView; +class FormIndexDialog; + +class FormIndex : public DialogBase { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormIndex(LyXView *, Dialogs *); + /// + ~FormIndex(); + //@} + + /// Apply changes + void apply(); + /// close the connections + void close(); + +private: + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + /// Update the dialog. + void update(); + + /// create an Index inset + void createIndex(string const &); + /// edit an Index inset + void showIndex(InsetCommand * const); + + /// Real GUI implementation. + FormIndexDialog * dialog_; + + /// the LyXView we belong to + LyXView * lv_; + + /** Which Dialogs do we belong to? + Used so we can get at the signals we have to connect to. + */ + Dialogs * d_; + /// pointer to the inset if any + InsetCommand * inset_; + /// insets params + InsetCommandParams params; + /// is the inset we are reading from a readonly buffer ? + bool readonly; + + /// Hide connection. + Connection h_; + /// Update connection. + Connection u_; + /// Inset hide connection. + Connection ih_; +}; + +#endif diff --git a/src/frontends/qt2/FormIndexDialog.C b/src/frontends/qt2/FormIndexDialog.C new file mode 100644 index 0000000000..4d0d8c2b6f --- /dev/null +++ b/src/frontends/qt2/FormIndexDialog.C @@ -0,0 +1,46 @@ +#include "FormIndexDialog.h" +#include "Dialogs.h" +#include "FormIndex.h" + +/* + * Constructs a FormIndexDialog which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +FormIndexDialog::FormIndexDialog( FormIndex* form_, QWidget* parent, const char* name, bool modal, WFlags fl ) + : FormIndexDialogBase( parent, name, modal, fl ), + form( form_ ) +{ +} + +/* + * Destroys the object and frees any allocated resources + */ +FormIndexDialog::~FormIndexDialog() +{ + // no need to delete child widgets, Qt does it all for us +} + + +void FormIndexDialog::apply_adaptor() +{ + form->apply(); + form->close(); + hide(); +} + + +void FormIndexDialog::close_adaptor() +{ + form->close(); + hide(); +} + + +void FormIndexDialog::closeEvent(QCloseEvent *e) +{ + form->close(); + e->accept(); +} diff --git a/src/frontends/qt2/FormIndexDialog.h b/src/frontends/qt2/FormIndexDialog.h new file mode 100644 index 0000000000..9ee2b40e88 --- /dev/null +++ b/src/frontends/qt2/FormIndexDialog.h @@ -0,0 +1,26 @@ +#ifndef FORMINDEXDIALOG_H +#define FORMINDEXDIALOG_H +#include "FormIndexDialogBase.h" + +class FormIndex; + +class FormIndexDialog : public FormIndexDialogBase +{ + Q_OBJECT + +public: + FormIndexDialog( FormIndex* form, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~FormIndexDialog(); + +public slots: + void apply_adaptor(); + void close_adaptor(); + +protected: + void closeEvent(QCloseEvent *e); + +private: + FormIndex* form; +}; + +#endif // FORMINDEXDIALOG_H diff --git a/src/frontends/qt2/FormIndexDialogBase.ui b/src/frontends/qt2/FormIndexDialogBase.ui new file mode 100644 index 0000000000..408cd1e008 --- /dev/null +++ b/src/frontends/qt2/FormIndexDialogBase.ui @@ -0,0 +1,160 @@ + +FormIndexDialogBase + + QDialog + + name + FormIndexDialogBase + + + geometry + + 0 + 0 + 216 + 82 + + + + caption + Index + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout28 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + keywordLA + + + text + &Keyword + + + buddy + keywordED + + + toolTip + Index entry + + + + QLineEdit + + name + keywordED + + + toolTip + Index entry + + + + + + QLayoutWidget + + name + Layout27 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer3 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + okPB + + + text + OK + + + default + true + + + + QPushButton + + name + cancelPB + + + text + Cancel + + + + + + + + + okPB + clicked() + FormIndexDialogBase + apply_adaptor() + + + cancelPB + clicked() + FormIndexDialogBase + close_adaptor() + + apply_adaptor() + close_adaptor() + + diff --git a/src/frontends/qt2/FormParagraph.C b/src/frontends/qt2/FormParagraph.C index bf5a2c51f0..2af1642633 100644 --- a/src/frontends/qt2/FormParagraph.C +++ b/src/frontends/qt2/FormParagraph.C @@ -47,7 +47,7 @@ void FormParagraph::update(bool switched) return; Buffer *buf = lv_->view()->buffer(); - + if (readonly!=buf->isReadonly()) { readonly = buf->isReadonly(); dialog_->setReadOnly(readonly); @@ -64,7 +64,7 @@ void FormParagraph::update(bool switched) LyXParagraph *par = text->cursor.par(); int align = par->GetAlign(); - + if (align==LYX_ALIGN_LAYOUT) align = textclasslist.Style(buf->params.textclass, par->GetLayout()).align; @@ -73,7 +73,7 @@ void FormParagraph::update(bool switched) #else ParagraphParameters *params = &(par->params); #endif - + if (params->spaceTop().kind() == VSpace::LENGTH) { LyXGlueLength above = params->spaceTop().length(); lyxerr[Debug::GUI] << "Reading above space : \"" << params->spaceTop().length().asString() << "\"" << endl; @@ -148,7 +148,6 @@ void FormParagraph::apply() spaceabove, spacebelow, dialog_->getAlign(), dialog_->getLabelWidth(), dialog_->getNoIndent()); -#ifndef NO_PEXTRA // extra stuff string width(""); @@ -163,6 +162,7 @@ void FormParagraph::apply() lyxerr[Debug::GUI] << "Setting extrawidth \"" << width << "\"" << endl; lyxerr[Debug::GUI] << "Setting percent extrawidth \"" << widthp << "\"" << endl; +#ifndef NO_PEXTRA lv_->view()->text->SetParagraphExtraOpt(lv_->view(), dialog_->getExtraType(), width, widthp, dialog_->getExtraAlign(), @@ -173,7 +173,7 @@ void FormParagraph::apply() BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE); - + lv_->buffer()->markDirty(); setMinibuffer(lv_, _("Paragraph layout set")); } @@ -186,11 +186,11 @@ void FormParagraph::show() if (!dialog_->isVisible()) h_ = d_->hideBufferDependent.connect(slot(this, &FormParagraph::hide)); - + dialog_->raise(); dialog_->setActiveWindow(); update(); - + dialog_->show(); } diff --git a/src/frontends/qt2/FormRef.C b/src/frontends/qt2/FormRef.C new file mode 100644 index 0000000000..433d660444 --- /dev/null +++ b/src/frontends/qt2/FormRef.C @@ -0,0 +1,278 @@ +/* + * FormRef.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include + +#include "FormRefDialog.h" +#undef emit + +#include "Dialogs.h" +#include "FormRef.h" +#include "gettext.h" +#include "buffer.h" +#include "LyXView.h" +#include "lyxfunc.h" +#include "debug.h" + +#include +#include +#include +#include +#include + +using std::endl; + +FormRef::FormRef(LyXView *v, Dialogs *d) + : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0), + sort(0), gotowhere(GOTOREF), type(REF), refs(0) +{ + // let the dialog be shown + // This is a permanent connection so we won't bother + // storing a copy because we won't be disconnecting. + d->showRef.connect(slot(this, &FormRef::showRef)); + d->createRef.connect(slot(this, &FormRef::createRef)); +} + +FormRef::~FormRef() +{ + delete dialog_; +} + +void FormRef::showRef(InsetCommand * const inset) +{ + // FIXME: when could inset be 0 here ? + if (inset==0) + return; + + inset_ = inset; + readonly = lv_->buffer()->isReadonly(); + ih_ = inset_->hide.connect(slot(this,&FormRef::hide)); + params = inset->params(); + + show(); +} + +void FormRef::createRef(string const & arg) +{ + if (inset_) + close(); + + readonly = lv_->buffer()->isReadonly(); + params.setFromString(arg); + show(); +} + +void FormRef::select(const char *text) +{ + highlight(text); + goto_ref(); +} + +void FormRef::highlight(const char *text) +{ + if (gotowhere==GOTOBACK) + goto_ref(); + + dialog_->gotoPB->setEnabled(true); + if (!readonly) { + dialog_->typeCO->setEnabled(true); + dialog_->referenceED->setText(text); + dialog_->okPB->setEnabled(true); + } +} + +void FormRef::set_sort(bool on) +{ + if (on!=sort) { + sort=on; + dialog_->refsLB->clear(); + updateRefs(); + } +} + +void FormRef::goto_ref() +{ + switch (gotowhere) { + case GOTOREF: + lv_->getLyXFunc()->Dispatch(LFUN_REF_GOTO, dialog_->referenceED->text().latin1()); + gotowhere=GOTOBACK; + dialog_->gotoPB->setText(_("&Go back")); + break; + case GOTOBACK: + lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK); + gotowhere=GOTOREF; + dialog_->gotoPB->setText(_("&Goto reference")); + break; + } +} + +void FormRef::updateRefs() +{ + // list will be re-done, should go back if necessary + if (gotowhere==GOTOBACK) { + lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK); + gotowhere = GOTOREF; + dialog_->gotoPB->setText(_("&Goto reference")); + } + + dialog_->refsLB->setAutoUpdate(false); + + // need this because Qt will send a highlight() here for + // the first item inserted + string tmp(dialog_->referenceED->text()); + + for (vector< string >::const_iterator iter = refs.begin(); + iter != refs.end(); ++iter) { + if (sort) + dialog_->refsLB->inSort(iter->c_str()); + else + dialog_->refsLB->insertItem(iter->c_str()); + } + + dialog_->referenceED->setText(tmp.c_str()); + + for (unsigned int i = 0; i < dialog_->refsLB->count(); ++i) { + if (!strcmp(dialog_->referenceED->text(),dialog_->refsLB->text(i))) + dialog_->refsLB->setCurrentItem(i); + } + + dialog_->refsLB->setAutoUpdate(true); + dialog_->refsLB->update(); +} + +void FormRef::do_ref_update() +{ + refs.clear(); + dialog_->refsLB->clear(); + refs = lv_->buffer()->getLabelList(); + if (!refs.empty()) + dialog_->sortCB->setEnabled(true); + updateRefs(); +} + +void FormRef::update() +{ + dialog_->referenceED->setText(params.getContents().c_str()); + dialog_->nameED->setText(params.getOptions().c_str()); + + if (params.getCmdName()=="pageref") { + type = PAGEREF; + dialog_->typeCO->setCurrentItem(1); + } else if (params.getCmdName()=="vref") { + type = VREF; + dialog_->typeCO->setCurrentItem(2); + } else if (params.getCmdName()=="vpageref") { + type = VPAGEREF; + dialog_->typeCO->setCurrentItem(3); + } else if (params.getCmdName()=="prettyref") { + type = PRETTYREF; + dialog_->typeCO->setCurrentItem(4); + } else { + type = REF; + dialog_->typeCO->setCurrentItem(0); + } + + dialog_->gotoPB->setText(_("&Goto reference")); + + gotowhere = GOTOREF; + + dialog_->sortCB->setChecked(sort); + + do_ref_update(); + + dialog_->gotoPB->setEnabled(params.getContents()!=""); + dialog_->okPB->setEnabled(params.getContents()!=""); + + dialog_->typeCO->setEnabled(!readonly); + dialog_->sortCB->setEnabled(!readonly); + dialog_->refsLB->setEnabled(!readonly); + dialog_->okPB->setEnabled(!readonly); + dialog_->updatePB->setEnabled(!readonly); + if (readonly) + dialog_->cancelPB->setText(_("&Close")); + else + dialog_->cancelPB->setText(_("&Cancel")); +} + +void FormRef::apply() +{ + if (readonly) + return; + + if (!lv_->view()->available()) + return; + + switch (dialog_->typeCO->currentItem()) { + case 0: + params.setCmdName("ref"); + break; + case 1: + params.setCmdName("pageref"); + break; + case 2: + params.setCmdName("vref"); + break; + case 3: + params.setCmdName("vpageref"); + break; + case 4: + params.setCmdName("prettyref"); + break; + default: + lyxerr[Debug::GUI] << "Unknown Ref Type" << endl; + } + + params.setContents(dialog_->referenceED->text().latin1()); + params.setOptions(dialog_->nameED->text().latin1()); + + if (inset_ != 0) { + if (params != inset_->params()) { + inset_->setParams(params); + lv_->view()->updateInset(inset_, true); + } + } else + lv_->getLyXFunc()->Dispatch(LFUN_REF_INSERT, params.getAsString().c_str()); +} + +void FormRef::show() +{ + if (!dialog_) + dialog_ = new FormRefDialog(this, 0, _("LyX: Cross Reference"), false); + + if (!dialog_->isVisible()) { + h_ = d_->hideBufferDependent.connect(slot(this, &FormRef::hide)); + u_ = d_->updateBufferDependent.connect(slot(this, &FormRef::update)); + } + + dialog_->raise(); + dialog_->setActiveWindow(); + + update(); + dialog_->show(); +} + +void FormRef::close() +{ + h_.disconnect(); + u_.disconnect(); + ih_.disconnect(); + inset_ = 0; +} + +void FormRef::hide() +{ + dialog_->hide(); + close(); +} diff --git a/src/frontends/qt2/FormRef.h b/src/frontends/qt2/FormRef.h new file mode 100644 index 0000000000..df4475feb8 --- /dev/null +++ b/src/frontends/qt2/FormRef.h @@ -0,0 +1,115 @@ +/* FormRef.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + * Adapted for Qt2 frontend by Kalle Dalheimer, + * kalle@klaralvdalens-datakonsult.se + */ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FORMREF_H +#define FORMREF_H + +#include "DialogBase.h" +#include "LString.h" +#include "boost/utility.hpp" +#include "insets/insetcommand.h" + +class Dialogs; +class LyXView; +class FormRefDialog; + +class FormRef : public DialogBase { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormRef(LyXView *, Dialogs *); + /// + ~FormRef(); + //@} + + /// double-click a ref + void select(const char *); + /// highlight a ref + void highlight(const char *); + /// set sort + void set_sort(bool); + /// goto a ref (or back) + void goto_ref(); + /// update dialog + void update(); + /// update just the refs + void do_ref_update(); + /// Apply changes + void apply(); + /// close the connections + void close(); + +private: + enum Type { + REF, PAGEREF, VREF, VPAGEREF, PRETTYREF + }; + + enum GotoType { + GOTOREF, GOTOBACK + }; + + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + + /// create a Reference inset + void createRef(string const &); + /// edit a Reference inset + void showRef(InsetCommand * const); + + /// update the keys list + void updateRefs(void); + + /// Real GUI implementation. + FormRefDialog * dialog_; + + /// the LyXView we belong to + LyXView * lv_; + + /** Which Dialogs do we belong to? + Used so we can get at the signals we have to connect to. + */ + Dialogs * d_; + /// pointer to the inset if any + InsetCommand * inset_; + /// insets params + InsetCommandParams params; + /// is the inset we are reading from a readonly buffer ? + bool readonly; + + /// Hide connection. + Connection h_; + /// Update connection. + Connection u_; + /// Inset hide connection. + Connection ih_; + + /// to sort or not to sort + bool sort; + + /// where to go + GotoType gotowhere; + + /// current type + Type type; + + /// available references + std::vector< string > refs; +}; + +#endif diff --git a/src/frontends/qt2/FormRefDialog.C b/src/frontends/qt2/FormRefDialog.C new file mode 100644 index 0000000000..49a7a5bf53 --- /dev/null +++ b/src/frontends/qt2/FormRefDialog.C @@ -0,0 +1,83 @@ +#include "FormRefDialog.h" +#include "Dialogs.h" +#include "FormRef.h" + +/* + * Constructs a FormRefDialog which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +FormRefDialog::FormRefDialog( FormRef* _form, QWidget* parent, const char* name, bool modal, WFlags fl ) + : FormReferenceDialogBase( parent, name, modal, fl ), + form( _form ) +{ +} + +/* + * Destroys the object and frees any allocated resources + */ +FormRefDialog::~FormRefDialog() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * public slot + */ +void FormRefDialog::apply_adaptor() +{ + form->apply(); + form->close(); + hide(); +} +/* + * public slot + */ +void FormRefDialog::goto_adaptor() +{ + form->goto_ref(); +} +/* + * public slot + */ +void FormRefDialog::highlight_adaptor(const QString& sel) +{ + form->highlight(sel); +} +/* + * public slot + */ +void FormRefDialog::close_adaptor() +{ + form->close(); + hide(); +} +/* + * public slot + */ +void FormRefDialog::select_adaptor(const QString& sel) +{ + form->select(sel); +} +/* + * public slot + */ +void FormRefDialog::sort_adaptor(bool sort) +{ + form->set_sort(sort); +} +/* + * public slot + */ +void FormRefDialog::update_adaptor() +{ + form->do_ref_update(); +} + +void FormRefDialog::closeEvent(QCloseEvent *e) +{ + form->close(); + e->accept(); +} diff --git a/src/frontends/qt2/FormRefDialog.h b/src/frontends/qt2/FormRefDialog.h new file mode 100644 index 0000000000..c26630b68b --- /dev/null +++ b/src/frontends/qt2/FormRefDialog.h @@ -0,0 +1,31 @@ +#ifndef FORMREFDIALOG_H +#define FORMREFDIALOG_H +#include "FormRefDialogBase.h" + +class FormRef; + +class FormRefDialog : public FormReferenceDialogBase +{ + Q_OBJECT + +public: + FormRefDialog( FormRef* form, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~FormRefDialog(); + +public slots: + void apply_adaptor(); + void goto_adaptor(); + void highlight_adaptor(const QString&); + void close_adaptor(); + void select_adaptor(const QString&); + void sort_adaptor(bool); + void update_adaptor(); + +protected: + void closeEvent(QCloseEvent *e); + +private: + FormRef* form; +}; + +#endif // FORMREFDIALOG_H diff --git a/src/frontends/qt2/FormRefDialogBase.ui b/src/frontends/qt2/FormRefDialogBase.ui new file mode 100644 index 0000000000..f1fb2f2479 --- /dev/null +++ b/src/frontends/qt2/FormRefDialogBase.ui @@ -0,0 +1,506 @@ + +FormReferenceDialogBase + + QDialog + + name + FormReferenceDialogBase + + + geometry + + 0 + 0 + 421 + 277 + + + + caption + Reference + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout30 + + + + margin + 0 + + + spacing + 6 + + + QListBox + + name + refsLB + + + + QLayoutWidget + + name + Layout29 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer4 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + updatePB + + + text + &Update + + + + + name + Spacer5 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QCheckBox + + name + sortCB + + + text + Sort + + + toolTip + Sort references in alphabetical order ? + + + + + name + Spacer6 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + + QLayoutWidget + + name + Layout35 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout31 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + nameL + + + text + &Name: + + + buddy + nameED + + + + QLineEdit + + name + nameED + + + + + + QLayoutWidget + + name + Layout32 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + referenceL + + + text + &Reference: + + + buddy + referenceED + + + + QLineEdit + + name + referenceED + + + + + + + name + Spacer7 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout33 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + typeLA + + + text + Reference &type + + + buddy + typeLA + + + alignment + AlignCenter + + + hAlign + + + + QComboBox + + + text + Reference + + + + + text + Page number + + + + + text + Ref on page xxx + + + + + text + On page xxx + + + + + text + Pretty reference + + + + name + typeCO + + + toolTip + Reference as it appears in output + + + + + + + name + Spacer8 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + gotoPB + + + text + &Goto reference + + + + + name + Spacer9 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout34 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + okPB + + + text + &OK + + + default + true + + + + QPushButton + + name + cancelPB + + + text + &Cancel + + + + + + + + + + + refsLB + highlighted(const QString&) + FormReferenceDialogBase + highlight_adaptor(const QString&) + + + refsLB + selected(const QString&) + FormReferenceDialogBase + select_adaptor(const QString&) + + + sortCB + toggled(bool) + FormReferenceDialogBase + sort_adaptor(bool) + + + updatePB + clicked() + FormReferenceDialogBase + update_adaptor() + + + okPB + clicked() + FormReferenceDialogBase + apply_adaptor() + + + cancelPB + clicked() + FormReferenceDialogBase + close_adaptor() + + + gotoPB + clicked() + FormReferenceDialogBase + goto_adaptor() + + apply_adaptor() + goto_adaptor() + highlight_adaptor(const QString&) + close_adaptor() + select_adaptor(const QString&) + sort_adaptor(bool) + update_adaptor() + + diff --git a/src/frontends/qt2/FormToc.C b/src/frontends/qt2/FormToc.C new file mode 100644 index 0000000000..8fdfb22377 --- /dev/null +++ b/src/frontends/qt2/FormToc.C @@ -0,0 +1,274 @@ +/* + * FormToc.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include + +#include + +#include +#include "FormTocDialog.h" +#undef emit + +#include "Dialogs.h" +#include "FormToc.h" +#include "gettext.h" +#include "buffer.h" +#include "support/lstrings.h" +#include "QtLyXView.h" +#include "lyxfunc.h" +#include "debug.h" + +using std::vector; +using std::pair; +using std::stack; +using std::endl; + +#include +#include + +FormToc::FormToc(LyXView *v, Dialogs *d) + : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0), + toclist(0), type(Buffer::TOC_TOC), depth(1) +{ + // let the dialog be shown + // This is a permanent connection so we won't bother + // storing a copy because we won't be disconnecting. + d->showTOC.connect(slot(this, &FormToc::showTOC)); + d->createTOC.connect(slot(this, &FormToc::createTOC)); +} + +FormToc::~FormToc() +{ + delete dialog_; +} + +void FormToc::showTOC(InsetCommand * const inset) +{ + // FIXME: when could inset be 0 here ? + if (inset==0) + return; + + inset_ = inset; + ih_ = inset_->hide.connect(slot(this,&FormToc::hide)); + params = inset->params(); + + show(); +} + +void FormToc::createTOC(string const & arg) +{ + if (inset_) + close(); + + params.setFromString(arg); + show(); +} + +void FormToc::updateToc(int newdepth) +{ + if (!lv_->view()->available()) { + toclist.clear(); + dialog_->tocLV->clear(); + return; + } + + vector< vector > tmp = + lv_->view()->buffer()->getTocList(); + + // Check if all elements are the same. + if (newdepth==depth && toclist.size() == tmp[type].size()) { + unsigned int i = 0; + for (; i < toclist.size(); ++i) { + if (toclist[i] != tmp[type][i]) + break; + } + if (i >= toclist.size()) + return; + } + + depth=newdepth; + + toclist = tmp[type]; + + dialog_->tocLV->clear(); + if (toclist.empty()) + return; + + dialog_->tocLV->setUpdatesEnabled(false); + + int curdepth = 0; + stack< pair< QListViewItem *, QListViewItem *> > istack; + QListViewItem *last = 0; + QListViewItem *parent = 0; + QListViewItem *item; + + // Yes, it is this ugly. Two reasons - root items must have a QListView parent, + // rather than QListViewItem; and the TOC can move in and out an arbitrary number + // of levels + + for (vector< Buffer::TocItem >::const_iterator iter = toclist.begin(); + iter != toclist.end(); ++iter) { + if (iter->depth == curdepth) { + // insert it after the last one we processed + if (!parent) + item = (last) ? (new QListViewItem(dialog_->tocLV,last)) : (new QListViewItem(dialog_->tocLV)); + else + item = (last) ? (new QListViewItem(parent,last)) : (new QListViewItem(parent)); + } else if (iter->depth > curdepth) { + int diff = iter->depth - curdepth; + // first save old parent and last + while (diff--) + istack.push(pair< QListViewItem *, QListViewItem * >(parent,last)); + item = (last) ? (new QListViewItem(last)) : (new QListViewItem(dialog_->tocLV)); + parent = last; + } else { + int diff = curdepth - iter->depth; + pair< QListViewItem *, QListViewItem * > top; + // restore context + while (diff--) { + top = istack.top(); + istack.pop(); + } + parent = top.first; + last = top.second; + // insert it after the last one we processed + if (!parent) + item = (last) ? (new QListViewItem(dialog_->tocLV,last)) : (new QListViewItem(dialog_->tocLV)); + else + item = (last) ? (new QListViewItem(parent,last)) : (new QListViewItem(parent)); + } + lyxerr[Debug::GUI] << "Table of contents" << endl << "Added item " << iter->str.c_str() + << " at depth " << iter->depth << ", previous sibling \"" << (last ? last->text(0).latin1() : "0") + << "\", parent \"" << (parent ? parent->text(0).latin1() : "0") << "\"" << endl; + item->setText(0,iter->str.c_str()); + item->setOpen(iter->depth < depth); + curdepth = iter->depth; + last = item; + } + + dialog_->tocLV->setUpdatesEnabled(true); + dialog_->tocLV->update(); +} + +void FormToc::setType(Buffer::TocType toctype) +{ + type = toctype; + switch (type) { + case Buffer::TOC_TOC: + dialog_->setCaption(_("Table of Contents")); + dialog_->tocLV->setColumnText(0,_("Table of Contents")); + dialog_->depthSL->setEnabled(true); + break; + case Buffer::TOC_LOF: + dialog_->setCaption(_("List of Figures")); + dialog_->tocLV->setColumnText(0,_("List of Figures")); + dialog_->depthSL->setEnabled(false); + break; + case Buffer::TOC_LOT: + dialog_->setCaption(_("List of Tables")); + dialog_->tocLV->setColumnText(0,_("List of Tables")); + dialog_->depthSL->setEnabled(false); + break; + case Buffer::TOC_LOA: + dialog_->setCaption(_("List of Algorithms")); + dialog_->tocLV->setColumnText(0,_("List of Algorithms")); + dialog_->depthSL->setEnabled(false); + break; + } +} + +void FormToc::set_depth(int newdepth) +{ + if (newdepth!=depth) + updateToc(newdepth); +} + +void FormToc::update() +{ + if (params.getCmdName()=="tableofcontents") { + setType(Buffer::TOC_TOC); + dialog_->typeCO->setCurrentItem(0); + } else if (params.getCmdName()=="listoffigures") { + setType(Buffer::TOC_LOF); + dialog_->typeCO->setCurrentItem(1); + } else if (params.getCmdName()=="listoftables") { + setType(Buffer::TOC_LOT); + dialog_->typeCO->setCurrentItem(2); + } else { + setType(Buffer::TOC_LOA); + dialog_->typeCO->setCurrentItem(3); + } + + updateToc(depth); +} + +void FormToc::select(const char *text) +{ + if (!lv_->view()->available()) + return; + + vector ::const_iterator iter = toclist.begin(); + for (; iter != toclist.end(); ++iter) { + if (iter->str==text) + break; + } + + if (iter==toclist.end()) { + lyxerr[Debug::GUI] << "Couldn't find highlighted TOC entry : " << text << endl; + return; + } + + lv_->getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tostr(iter->par->id()).c_str()); +} + +void FormToc::set_type(Buffer::TocType toctype) +{ + if (toctype==type) + return; + + setType(toctype); + updateToc(depth); +} + +void FormToc::show() +{ + if (!dialog_) + dialog_ = new FormTocDialog(this, 0, _("LyX: Table of Contents"), false); + + if (!dialog_->isVisible()) { + h_ = d_->hideBufferDependent.connect(slot(this, &FormToc::hide)); + u_ = d_->updateBufferDependent.connect(slot(this, &FormToc::update)); + } + + dialog_->raise(); + dialog_->setActiveWindow(); + + update(); + dialog_->show(); +} + +void FormToc::close() +{ + h_.disconnect(); + u_.disconnect(); + ih_.disconnect(); + inset_ = 0; +} + +void FormToc::hide() +{ + dialog_->hide(); + close(); +} diff --git a/src/frontends/qt2/FormToc.h b/src/frontends/qt2/FormToc.h new file mode 100644 index 0000000000..5bf424e544 --- /dev/null +++ b/src/frontends/qt2/FormToc.h @@ -0,0 +1,89 @@ +/* FormToc.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + * Adapted for Qt2 frontend by Kalle Dalheimer, + * kalle@klaralvdalens-datakonsult.se + */ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FORMTOC_H +#define FORMTOC_H + +#include "DialogBase.h" +#include "LString.h" +#include "boost/utility.hpp" +#include "insets/insetcommand.h" +#include "buffer.h" + +class Dialogs; +class FormTocDialog; + +class FormToc : public DialogBase { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormToc(LyXView *, Dialogs *); + /// + ~FormToc(); + //@} + + // Build the dialog + virtual void build(); + /// Update the dialog before showing it. + virtual void update(); + /// close the connections + virtual void close(); + +private: + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + + /// create a Toc inset + void createTOC(string const &); + /// view a Toc inset + void showTOC(InsetCommand * const); + + /// update the Toc + void updateToc(int); + + /// Real GUI implementation. + FormTocDialog * dialog_; + + /// the LyXView we belong to + LyXView * lv_; + + /** Which Dialogs do we belong to? + Used so we can get at the signals we have to connect to. + */ + Dialogs * d_; + /// pointer to the inset if any + InsetCommand * inset_; + /// insets params + InsetCommandParams params; + + /// Hide connection. + Connection h_; + /// Update connection. + Connection u_; + /// Inset hide connection. + Connection ih_; + + /// the toc list + std::vector toclist; + + /// depth of list shown + int depth; +}; + +#endif diff --git a/src/frontends/qt2/FormTocDialog.C b/src/frontends/qt2/FormTocDialog.C new file mode 100644 index 0000000000..ebc33ef5f4 --- /dev/null +++ b/src/frontends/qt2/FormTocDialog.C @@ -0,0 +1,87 @@ +#include +#include +#include "FormTocDialog.h" +#include "Dialogs.h" +#include "FormToc.h" + +#include + +/* + * Constructs a FormTocDialog which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +FormTocDialog::FormTocDialog( FormToc* form_, QWidget* parent, const char* name, bool modal, WFlags fl ) + : FormTocDialogBase( parent, name, modal, fl ), + form( form_ ) +{ +} + +/* + * Destroys the object and frees any allocated resources + */ +FormTocDialog::~FormTocDialog() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * public slot + */ +void FormTocDialog::activate_adaptor(int index) +{ + switch (index) { + case 0: + form->set_type(Buffer::TOC_TOC); + break; + case 1: + form->set_type(Buffer::TOC_LOF); + break; + case 2: + form->set_type(Buffer::TOC_LOT); + break; + case 3: + form->set_type(Buffer::TOC_LOA); + break; + default: + lyxerr[Debug::GUI] << "Unknown TOC combo selection." << std::endl; + break; + } +} +/* + * public slot + */ +void FormTocDialog::close_adaptor() +{ + form->close(); + hide(); +} +/* + * public slot + */ +void FormTocDialog::depth_adaptor(int depth) +{ + form->set_depth(depth); +} +/* + * public slot + */ +void FormTocDialog::select_adaptor(QListViewItem* item) +{ + form->select(item->text(0)); +} +/* + * public slot + */ +void FormTocDialog::update_adaptor() +{ + form->update(); +} + +void FormTocDialog::closeEvent(QCloseEvent *e) +{ + form->close(); + e->accept(); +} diff --git a/src/frontends/qt2/FormTocDialog.h b/src/frontends/qt2/FormTocDialog.h new file mode 100644 index 0000000000..dbb8721151 --- /dev/null +++ b/src/frontends/qt2/FormTocDialog.h @@ -0,0 +1,29 @@ +#ifndef FORMTOCDIALOG_H +#define FORMTOCDIALOG_H +#include "FormTocDialogBase.h" + +class FormToc; + +class FormTocDialog : public FormTocDialogBase +{ + Q_OBJECT + +public: + FormTocDialog( FormToc* form, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~FormTocDialog(); + +public slots: + void activate_adaptor(int); + void close_adaptor(); + void depth_adaptor(int); + void select_adaptor(QListViewItem*); + void update_adaptor(); + +protected: + void closeEvent(QCloseEvent *e); + +private: + FormToc* form; +}; + +#endif // FORMTOCDIALOG_H diff --git a/src/frontends/qt2/FormTocDialogBase.ui b/src/frontends/qt2/FormTocDialogBase.ui new file mode 100644 index 0000000000..24dd5628f3 --- /dev/null +++ b/src/frontends/qt2/FormTocDialogBase.ui @@ -0,0 +1,227 @@ + +FormTocDialogBase + + QDialog + + name + FormTocDialogBase + + + geometry + + 0 + 0 + 358 + 313 + + + + caption + Table Of Contents + + + + margin + 11 + + + spacing + 6 + + + QListView + + + text + Table Of Contents + + + clickable + true + + + resizeable + true + + + + name + tocLV + + + + QSlider + + name + depthSL + + + orientation + Horizontal + + + maxValue + 5 + + + pageStep + 1 + + + + QLayoutWidget + + name + Layout39 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer11 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + sizeHint + + 20 + 20 + + + + + QLabel + + name + typeLA + + + text + &Type + + + buddy + typeCO + + + + QComboBox + + + text + Table of Contents + + + + + text + List of Figures + + + + + text + List of Tables + + + + + text + List of Algorithms + + + + name + typeCO + + + + QPushButton + + name + updatePB + + + text + &Update + + + + QPushButton + + name + closePB + + + text + &Close + + + default + true + + + + + + + + + tocLV + selectionChanged(QListViewItem*) + FormTocDialogBase + select_adaptor(QListViewItem*) + + + typeCO + activated(int) + FormTocDialogBase + activate_adaptor(int) + + + updatePB + clicked() + FormTocDialogBase + update_adaptor() + + + closePB + clicked() + FormTocDialogBase + close_adaptor() + + + depthSL + valueChanged(int) + FormTocDialogBase + depth_adaptor(int) + + activate_adaptor(int) + close_adaptor() + depth_adaptor(int) + select_adaptor(QListViewItem*) + update_adaptor() + + diff --git a/src/frontends/qt2/FormUrl.C b/src/frontends/qt2/FormUrl.C new file mode 100644 index 0000000000..d8f596572c --- /dev/null +++ b/src/frontends/qt2/FormUrl.C @@ -0,0 +1,149 @@ +/* + * FormUrl.C + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + */ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include + +#include "FormUrlDialog.h" +#undef emit + +#include "Dialogs.h" +#include "FormUrl.h" +#include "gettext.h" +#include "buffer.h" +#include "LyXView.h" +#include "lyxfunc.h" + +#include +#include +#include + +FormUrl::FormUrl(LyXView *v, Dialogs *d) + : dialog_(0), lv_(v), d_(d), inset_(0), h_(0), u_(0), ih_(0) +{ + // let the dialog be shown + // This is a permanent connection so we won't bother + // storing a copy because we won't be disconnecting. + d->showUrl.connect(slot(this, &FormUrl::showUrl)); + d->createUrl.connect(slot(this, &FormUrl::createUrl)); +} + +FormUrl::~FormUrl() +{ + delete dialog_; +} + +void FormUrl::showUrl(InsetCommand * const inset) +{ + // FIXME: when could inset be 0 here ? + if (inset==0) + return; + + inset_ = inset; + readonly = lv_->buffer()->isReadonly(); + ih_ = inset_->hide.connect(slot(this,&FormUrl::hide)); + params = inset->params(); + + show(); +} + +void FormUrl::createUrl(string const & arg) +{ + // we could already be showing a URL, clear it out + if (inset_) + close(); + + readonly = lv_->buffer()->isReadonly(); + params.setFromString(arg); + show(); +} + +void FormUrl::update() +{ + dialog_->urlED->setText(params.getContents().c_str()); + dialog_->nameED->setText(params.getOptions().c_str()); + + if (params.getCmdName()=="url") + dialog_->hyperlinkCB->setChecked(false); + else + dialog_->hyperlinkCB->setChecked(true); + + if (readonly) { + dialog_->nameED->setFocusPolicy(QWidget::NoFocus); + dialog_->urlED->setFocusPolicy(QWidget::NoFocus); + dialog_->okPB->setEnabled(false); + dialog_->cancelPB->setText(_("Close")); + dialog_->hyperlinkCB->setEnabled(false); + } else { + dialog_->nameED->setFocusPolicy(QWidget::StrongFocus); + dialog_->urlED->setFocusPolicy(QWidget::StrongFocus); + dialog_->urlED->setFocus(); + dialog_->okPB->setEnabled(true); + dialog_->cancelPB->setText(_("Cancel")); + dialog_->hyperlinkCB->setEnabled(true); + } +} + +void FormUrl::apply() +{ + if (readonly) + return; + + params.setContents(dialog_->urlED->text().latin1()); + params.setOptions(dialog_->nameED->text().latin1()); + + if (dialog_->hyperlinkCB->isChecked()) + params.setCmdName("htmlurl"); + else + params.setCmdName("url"); + + if (inset_ != 0) { + if (params != inset_->params()) { + inset_->setParams(params); + lv_->view()->updateInset(inset_, true); + } + } else + lv_->getLyXFunc()->Dispatch(LFUN_INSERT_URL, params.getAsString().c_str()); +} + +void FormUrl::show() +{ + if (!dialog_) + dialog_ = new FormUrlDialog(this, 0, _("LyX: Url"), false); + + if (!dialog_->isVisible()) { + h_ = d_->hideBufferDependent.connect(slot(this, &FormUrl::hide)); + u_ = d_->updateBufferDependent.connect(slot(this, &FormUrl::update)); + } + + dialog_->raise(); + dialog_->setActiveWindow(); + + update(); + dialog_->show(); +} + +void FormUrl::close() +{ + h_.disconnect(); + u_.disconnect(); + ih_.disconnect(); + inset_ = 0; +} + +void FormUrl::hide() +{ + dialog_->hide(); + close(); +} diff --git a/src/frontends/qt2/FormUrl.h b/src/frontends/qt2/FormUrl.h new file mode 100644 index 0000000000..268edea539 --- /dev/null +++ b/src/frontends/qt2/FormUrl.h @@ -0,0 +1,82 @@ +/* FormUrl.h + * (C) 2000 LyX Team + * John Levon, moz@compsoc.man.ac.uk + * Adapted for Qt2 frontend by Kalle Dalheimer, + * kalle@klaralvdalens-datakonsult.se + */ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef FORMURL_H +#define FORMURL_H + +#include "DialogBase.h" +#include "LString.h" +#include "boost/utility.hpp" +#include "insets/inseturl.h" + +class Dialogs; +class LyXView; +class FormUrlDialog; + +class FormUrl : public DialogBase { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormUrl(LyXView *, Dialogs *); + /// + ~FormUrl(); + //@} + + /// Apply changes + void apply(); + /// close the connections + void close(); + +private: + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + /// Update the dialog. + void update(); + + /// create a URL inset + void createUrl(string const &); + /// edit a URL inset + void showUrl(InsetCommand * const); + + /// Real GUI implementation. + FormUrlDialog * dialog_; + + /// the LyXView we belong to + LyXView * lv_; + + /** Which Dialogs do we belong to? + Used so we can get at the signals we have to connect to. + */ + Dialogs * d_; + /// pointer to the inset if any + InsetCommand * inset_; + /// insets params + InsetCommandParams params; + /// is the inset we are reading from a readonly buffer + bool readonly; + + /// Hide connection. + Connection h_; + /// Update connection. + Connection u_; + /// Inset hide connection. + Connection ih_; +}; + +#endif diff --git a/src/frontends/qt2/FormUrlDialog.C b/src/frontends/qt2/FormUrlDialog.C new file mode 100644 index 0000000000..488fec8166 --- /dev/null +++ b/src/frontends/qt2/FormUrlDialog.C @@ -0,0 +1,48 @@ +#include "FormUrlDialog.h" +#include "Dialogs.h" +#include "FormUrl.h" + +/* + * Constructs a FormUrlDialog which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +FormUrlDialog::FormUrlDialog( FormUrl* _form, QWidget* parent, const char* name, bool modal, WFlags fl ) + : FormUrlDialogBase( parent, name, modal, fl ), + form( _form ) +{ +} + +/* + * Destroys the object and frees any allocated resources + */ +FormUrlDialog::~FormUrlDialog() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * public slot + */ +void FormUrlDialog::apply_adaptor() +{ + form->apply(); + form->close(); + hide(); +} +/* + * public slot + */ +void FormUrlDialog::close_adaptor() +{ + form->close(); + hide(); +} + +void FormUrlDialog::closeEvent(QCloseEvent *e) +{ + form->close(); + e->accept(); +} diff --git a/src/frontends/qt2/FormUrlDialog.h b/src/frontends/qt2/FormUrlDialog.h new file mode 100644 index 0000000000..f3c4eb53e8 --- /dev/null +++ b/src/frontends/qt2/FormUrlDialog.h @@ -0,0 +1,26 @@ +#ifndef FORMURLDIALOG_H +#define FORMURLDIALOG_H +#include "FormUrlDialogBase.h" + +class FormUrl; + +class FormUrlDialog : public FormUrlDialogBase +{ + Q_OBJECT + +public: + FormUrlDialog( FormUrl* form, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~FormUrlDialog(); + +public slots: + void apply_adaptor(); + void close_adaptor(); + +protected: + void closeEvent( QCloseEvent* ); + +private: + FormUrl* form; +}; + +#endif // FORMURLDIALOG_H diff --git a/src/frontends/qt2/FormUrlDialogBase.ui b/src/frontends/qt2/FormUrlDialogBase.ui new file mode 100644 index 0000000000..ccbae13fb6 --- /dev/null +++ b/src/frontends/qt2/FormUrlDialogBase.ui @@ -0,0 +1,201 @@ + +FormUrlDialogBase + + QDialog + + name + FormUrlDialogBase + + + geometry + + 0 + 0 + 325 + 112 + + + + caption + Url + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout2 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + urlLA + + + text + &Url + + + buddy + urlED + + + toolTip + URL + + + + QLineEdit + + name + urlED + + + toolTip + URL + + + + + + QLayoutWidget + + name + Layout3 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + nameLA + + + text + &Name + + + buddy + nameED + + + toolTip + Name associated with the URL + + + + QLineEdit + + name + nameED + + + toolTip + Name associated with the URL + + + + + + QLayoutWidget + + name + Layout4 + + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + hyperlinkCB + + + text + &Generate hyperlink + + + toolTip + Output as a hyperlink ? + + + + QPushButton + + name + okPB + + + text + &OK + + + default + true + + + + QPushButton + + name + cancelPB + + + text + &Cancel + + + + + + + + + okPB + clicked() + FormUrlDialogBase + apply_adaptor() + + + cancelPB + clicked() + FormUrlDialogBase + close_adaptor() + + apply_adaptor() + close_adaptor() + + diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index 4e3b55ecfa..e574942e8c 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -49,7 +49,6 @@ libqt2_la_OBJADD = \ ../xforms/FormInset.lo \ ../xforms/FormLog.lo \ ../xforms/FormMinipage.lo \ - ../xforms/FormMaths.lo \ ../xforms/FormPreamble.lo \ ../xforms/FormPreferences.lo \ ../xforms/FormRef.lo \ @@ -74,7 +73,6 @@ libqt2_la_OBJADD = \ ../xforms/form_graphics.lo \ ../xforms/form_include.lo \ ../xforms/form_index.lo \ - ../xforms/form_maths.lo \ ../xforms/form_minipage.lo \ ../xforms/form_preamble.lo \ ../xforms/form_preferences.lo \