Back to index

scribus-ng  1.3.4.dfsg+svn20071115
edit1format.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "edit1format.h"
00008 #include "edit1format.moc"
00009 #include "tabruler.h"
00010 #include "units.h"
00011 
00012 #include <qmessagebox.h>
00013 #include <qtooltip.h>
00014 #include <qcolordialog.h>
00015 #include <qcursor.h>
00016 
00017 #include "colorcombo.h"
00018 #include "commonstrings.h"
00019 #include "prefsmanager.h"
00020 #include "prefscontext.h"
00021 #include "prefsfile.h"
00022 #include "scribusdoc.h"
00023 #include "styleselect.h"
00024 #include "scribusstructs.h"
00025 #include "sctextstruct.h"
00026 #include "scpaths.h"
00027 #include "scribus.h"
00028 #include "util.h"
00029 #include "loremipsum.h"
00030 #include "prefsmanager.h"
00031 #include "sampleitem.h"
00032 
00033 
00034 EditStyle::EditStyle( QWidget* parent, ParagraphStyle *vor, const StyleSet<ParagraphStyle>& v, bool neu, double au, int dEin, ScribusDoc *doc)
00035               : QDialog( parent, "EditST", true, 0), allV(v)
00036 {
00037        qApp->setOverrideCursor(QCursor(waitCursor));
00038        parentDoc = doc;
00039        setCaption( tr( "Edit Style" ) );
00040        setIcon(loadIcon("AppIcon.png"));
00041        AutoVal = au;
00042        DocsEin = dEin;
00043 
00044        sampleItem = new SampleItem(doc);
00045        sampleItem->setLoremIpsum(2);
00046        sampleItem->cleanupTemporary();
00047 
00048        prefs = PrefsManager::instance()->prefsFile->getContext("edit_style");
00049        QString prevBg = prefs->get("PreviewBg", "");
00050        if( !prevBg.isEmpty() )
00051        {
00052               QColor bg(prevBg);
00053               sampleItem->setBgColorMngt(false);
00054               sampleItem->setBgColor(bg);
00055        }
00056 
00057        EditStyleLayout = new QVBoxLayout( this, 10, 5, "EditStyleLayout");
00058 
00059        TextLabel1 = new QLabel( tr( "&Name:" ), this, "TextLabel1" );
00060        EditStyleLayout->addWidget( TextLabel1 );
00061 
00062        Name = new QLineEdit( this, "Name" );
00063        Name->setMinimumSize( QSize( 200, 22 ) );
00064        Name->setText( vor->name() );
00065        OldName = vor->name();
00066        IsNew = neu;
00067        TextLabel1->setBuddy(Name);
00068        EditStyleLayout->addWidget( Name );
00069 
00070        layout9 = new QHBoxLayout( 0, 0, 5, "layout9");
00071 
00072        GroupFont = new QGroupBox( tr( "Character" ), this, "GroupFont" );
00073        GroupFont->setColumnLayout(0, Qt::Vertical );
00074        GroupFont->layout()->setSpacing( 5 );
00075        GroupFont->layout()->setMargin( 10 );
00076        GroupFontLayout = new QVBoxLayout( GroupFont->layout() );
00077        GroupFontLayout->setAlignment( Qt::AlignLeft );
00078        FontC = new FontComboH(GroupFont);
00079        FontC->setCurrentFont(vor->charStyle().font().scName());
00080        GroupFontLayout->addWidget( FontC );
00081        layout7 = new QHBoxLayout( 0, 0, 5, "layout7");
00082        SizeC = new MSpinBox( 1, 2048, GroupFont, 1 );
00083        SizeC->setMinimumSize( QSize( 70, 22 ) );
00084        SizeC->setSuffix( tr( " pt" ) );
00085        SizeC->setValue(vor->charStyle().fontSize() / 10.0);
00086        TextF2 = new QLabel( "" ,GroupFont, "TextF2" );
00087        TextF2->setPixmap(loadIcon("Zeichen.xpm"));
00088        TextF2->setMinimumSize( QSize( 22, 22 ) );
00089        TextF2->setMaximumSize( QSize( 22, 22 ) );
00090        layout7->addWidget( TextF2 );
00091        layout7->addWidget( SizeC );
00092        pixmapLabel3 = new QLabel( "", GroupFont, "pixmapLabel3" );
00093        pixmapLabel3->setMinimumSize( QSize( 22, 22 ) );
00094        pixmapLabel3->setMaximumSize( QSize( 22, 22 ) );
00095        pixmapLabel3->setPixmap( loadIcon("textscaleh.png") );
00096        layout7->addWidget( pixmapLabel3 );
00097        fontHScale = new MSpinBox( 10, 400, GroupFont, 1 );
00098        fontHScale->setValue( vor->charStyle().scaleH() / 10.0 );
00099        fontHScale->setSuffix( tr( " %" ) );
00100        layout7->addWidget( fontHScale );
00101        pixmapLabel3_2 = new QLabel( "", GroupFont, "pixmapLabel3_2" );
00102        pixmapLabel3_2->setMinimumSize( QSize( 22, 22 ) );
00103        pixmapLabel3_2->setMaximumSize( QSize( 22, 22 ) );
00104        pixmapLabel3_2->setPixmap( loadIcon("textscalev.png") );
00105        layout7->addWidget( pixmapLabel3_2 );
00106 
00107        fontVScale = new MSpinBox( 10, 400, GroupFont, 1 );
00108        fontVScale->setValue( vor->charStyle().scaleV() / 10.0 );
00109        fontVScale->setSuffix( tr( " %" ) );
00110        layout7->addWidget( fontVScale );
00111        GroupFontLayout->addLayout( layout7 );
00112 
00113        layout9a = new QHBoxLayout( 0, 0, 0, "layout9");
00114        EffeS = new StyleSelect(GroupFont);
00115        EffeS->setStyle(vor->charStyle().effects());
00116        EffeS->ShadowVal->Xoffset->setValue(vor->charStyle().shadowXOffset() / 10.0);
00117        EffeS->ShadowVal->Yoffset->setValue(vor->charStyle().shadowYOffset() / 10.0);
00118        EffeS->OutlineVal->LWidth->setValue(vor->charStyle().outlineWidth() / 10.0);
00119        EffeS->UnderlineVal->LPos->setValue(vor->charStyle().underlineOffset() / 10.0);
00120        EffeS->UnderlineVal->LWidth->setValue(vor->charStyle().underlineWidth() / 10.0);
00121        EffeS->StrikeVal->LPos->setValue(vor->charStyle().strikethruOffset() / 10.0);
00122        EffeS->StrikeVal->LWidth->setValue(vor->charStyle().strikethruWidth() / 10.0);
00123        layout9a->addWidget( EffeS );
00124        QSpacerItem* spacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00125        layout9a->addItem( spacer1 );
00126        GroupFontLayout->addLayout( layout9a, Qt::AlignLeft );
00127 
00128        layout9b = new QHBoxLayout( 0, 0, 0, "layout9");
00129        AligS = new AlignSelect(GroupFont);
00130        AligS->setStyle(vor->alignment());
00131        layout9b->addWidget( AligS );
00132        QSpacerItem* spacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00133        layout9a->addItem( spacer2 );
00134        GroupFontLayout->addLayout( layout9b, Qt::AlignLeft );
00135 
00136        layout5 = new QHBoxLayout( 0, 0, 5, "layout5");
00137        FillIcon = new QLabel( "", GroupFont, "FillIcon" );
00138        FillIcon->setPixmap(loadIcon("16/color-fill.png"));
00139        layout5->addWidget( FillIcon );
00140        TxFill = new ColorCombo( false, GroupFont, "TxFill" );
00141        layout5->addWidget( TxFill );
00142        pixmapLabel3_20 = new QLabel( GroupFont, "pixmapLabel3_20" );
00143        pixmapLabel3_20->setMinimumSize( QSize( 22, 22 ) );
00144        pixmapLabel3_20->setMaximumSize( QSize( 22, 22 ) );
00145        pixmapLabel3_20->setPixmap( loadIcon("shade.png") );
00146        layout5->addWidget( pixmapLabel3_20 );
00147        PM2 = new ShadeButton(GroupFont);
00148        layout5->addWidget( PM2 );
00149        QSpacerItem* spacer3 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00150        layout5->addItem( spacer3 );
00151        GroupFontLayout->addLayout( layout5 );
00152 
00153        layout6 = new QHBoxLayout( 0, 0, 5, "layout6");
00154        StrokeIcon = new QLabel( "", GroupFont, "StrokeIcon" );
00155        StrokeIcon->setPixmap(loadIcon("16/color-stroke.png"));
00156        layout6->addWidget( StrokeIcon );
00157        TxStroke = new ColorCombo( false, GroupFont, "TxStroke" );
00158        layout6->addWidget( TxStroke );
00159        pixmapLabel3_19 = new QLabel( "", GroupFont, "pixmapLabel3_19" );
00160        pixmapLabel3_19->setMinimumSize( QSize( 22, 22 ) );
00161        pixmapLabel3_19->setMaximumSize( QSize( 22, 22 ) );
00162        pixmapLabel3_19->setPixmap( loadIcon("shade.png") );
00163        layout6->addWidget( pixmapLabel3_19 );
00164        PM1 = new ShadeButton(GroupFont);
00165        layout6->addWidget( PM1 );
00166        QSpacerItem* spacer4 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00167        layout6->addItem( spacer4 );
00168        GroupFontLayout->addLayout( layout6 );
00169 
00170        TxFill->clear();
00171        TxStroke->clear();
00172        ColorList::Iterator it;
00173        QPixmap pm = QPixmap(15, 15);
00174        TxFill->insertItem(CommonStrings::tr_NoneColor);
00175        TxStroke->insertItem(CommonStrings::tr_NoneColor);
00176        for (it = doc->PageColors.begin(); it != doc->PageColors.end(); ++it)
00177        {
00178               TxFill->insertSmallItem(it.data(), parentDoc, it.key());
00179               TxStroke->insertSmallItem(it.data(), parentDoc, it.key());
00180        }
00181        StrokeIcon->setEnabled(false);
00182        PM1->setEnabled(false);
00183        TxStroke->setEnabled(false);
00184        TxFill->setCurrentText(vor->charStyle().fillColor());
00185        TxStroke->setCurrentText(vor->charStyle().strokeColor());
00186        PM2->setValue(vor->charStyle().fillShade());
00187        PM1->setValue(vor->charStyle().strokeShade());
00188 
00189        layout9->addWidget( GroupFont );
00190 
00191        layout8 = new QVBoxLayout( 0, 0, 5, "layout8");
00192        AbstandV = new QGroupBox( tr("Distances"), this, "AbstandV" );
00193        AbstandV->setColumnLayout(0, Qt::Vertical );
00194        AbstandV->layout()->setSpacing( 0 );
00195        AbstandV->layout()->setMargin( 0 );
00196        AbstandVLayout = new QGridLayout( AbstandV->layout() );
00197        AbstandVLayout->setAlignment( Qt::AlignTop );
00198        AbstandVLayout->setSpacing( 5 );
00199        AbstandVLayout->setMargin( 10 );
00200        lineSpacingPop = new QPopupMenu();
00201        lineSpacingPop->insertItem( tr("Fixed Linespacing"));
00202        lineSpacingPop->insertItem( tr("Automatic Linespacing"));
00203        lineSpacingPop->insertItem( tr("Align to Baseline Grid"));
00204        linespacingButton = new QToolButton(AbstandV, "linespacingButton" );
00205        linespacingButton->setText("");
00206        linespacingButton->setPixmap( loadIcon("linespacing.png") );
00207        linespacingButton->setPopup(lineSpacingPop);
00208        linespacingButton->setPopupDelay(400);
00209        linespacingButton->setAutoRaise(true);
00210        AbstandVLayout->addWidget( linespacingButton, 0, 0 );
00211        LineSpVal = new MSpinBox( 1, 300, AbstandV, 1 );
00212        LineSpVal->setSuffix( tr( " pt" ) );
00213        LineSpVal->setValue(vor->lineSpacing());
00214        AbstandVLayout->addWidget( LineSpVal, 0, 1 );
00215        pixmapLabel2 = new QLabel( AbstandV, "pixmapLabel2" );
00216        pixmapLabel2->setMinimumSize( QSize( 22, 22 ) );
00217        pixmapLabel2->setMaximumSize( QSize( 22, 22 ) );
00218        pixmapLabel2->setPixmap( loadIcon("textbase.png") );
00219        AbstandVLayout->addWidget( pixmapLabel2, 0, 2 );
00220        fontBase = new MSpinBox( -100, 100, AbstandV, 1 );
00221        fontBase->setValue( vor->charStyle().baselineOffset() / 10.0 );
00222        fontBase->setSuffix( tr( " %" ) );
00223        AbstandVLayout->addWidget( fontBase, 0, 3 );
00224        pixmapLabel3_3 = new QLabel( AbstandV, "pixmapLabel3_3" );
00225        pixmapLabel3_3->setMinimumSize( QSize( 22, 22 ) );
00226        pixmapLabel3_3->setMaximumSize( QSize( 22, 22 ) );
00227        pixmapLabel3_3->setPixmap( loadIcon("textkern.png") );
00228        AbstandVLayout->addWidget( pixmapLabel3_3, 0, 4 );
00229        fontKern = new MSpinBox( -300, 300, AbstandV, 1 );
00230        fontKern->setValue( vor->charStyle().tracking() / 10.0 );
00231        fontKern->setSuffix( tr( " %" ) );
00232        AbstandVLayout->addWidget( fontKern, 0, 5 );
00233 
00234        TextLabel1_2_2 = new QLabel( "", AbstandV, "TextLabel1_2_2" );
00235        TextLabel1_2_2->setPixmap( loadIcon("above.png") );
00236        AbstandVLayout->addWidget( TextLabel1_2_2, 1, 0 );
00237        AboveV = new MSpinBox( 0, 300, AbstandV, 1 );
00238        AboveV->setSuffix( tr( " pt" ) );
00239        AbstandVLayout->addWidget( AboveV, 1, 1 );
00240 
00241        TextLabel1_2_3 = new QLabel( "", AbstandV, "TextLabel1_2_3" );
00242        TextLabel1_2_3->setPixmap( loadIcon("below.png") );
00243        AbstandVLayout->addWidget( TextLabel1_2_3, 1, 2 );
00244        BelowV = new MSpinBox( 0, 300, AbstandV, 1 );
00245        BelowV->setSuffix( tr( " pt" ) );
00246        AbstandVLayout->addWidget( BelowV, 1, 3 );
00247        layout8->addWidget( AbstandV );
00248 
00249        DropCaps = new QGroupBox( tr("Drop Caps"),  this, "groupCaps" );
00250        DropCaps->setCheckable( true );
00251        DropCaps->setColumnLayout(0, Qt::Vertical );
00252        DropCaps->layout()->setSpacing( 5 );
00253        DropCaps->layout()->setMargin( 10 );
00254        DropCapsLayout = new QGridLayout( DropCaps->layout() );
00255        DropCapsLayout->setAlignment( Qt::AlignTop );
00256        DropLines = new QSpinBox( DropCaps, "DropLines" );
00257        DropLines->setMinValue( 2 );
00258        DropLines->setMaxValue( 20 );
00259        DropLines->setValue(vor->dropCapLines());
00260        CapLabel = new QLabel( DropLines, tr("&Lines:"), DropCaps, "CapLabel" );
00261        DropCapsLayout->addWidget( CapLabel, 0, 0 );
00262        DropCapsLayout->addWidget( DropLines, 0, 1 );
00263        DropDist = new MSpinBox( -3000, 3000, DropCaps, 1);
00264        DropDist->setSuffix( tr( " pt" ) );
00265        DropDist->setValue(vor->dropCapOffset());
00266        CapLabel2 = new QLabel( DropLines, tr("Distance from Text:"), DropCaps, "CapLabel2" );
00267        DropCapsLayout->addWidget( CapLabel2, 1, 0 );
00268        DropCapsLayout->addWidget( DropDist, 1, 1 );
00269        DropCaps->setChecked(vor->hasDropCap());
00270        layout8->addWidget( DropCaps );
00271        layout9->addLayout( layout8 );
00272        EditStyleLayout->addLayout( layout9 );
00273 
00274        for (uint al = 0; al < lineSpacingPop->count(); ++al)
00275        {
00276               lineSpacingPop->setItemChecked(lineSpacingPop->idAt(al), false);
00277        }
00278        if (vor->useBaselineGrid())
00279        {
00280               LineSpVal->setEnabled(false);
00281               lineSpacingPop->setItemChecked(lineSpacingPop->idAt(2), true);
00282        }
00283        else
00284        {
00285               lineSpacingPop->setItemChecked(lineSpacingPop->idAt(vor->lineSpacingMode()), true);
00286               if (vor->lineSpacingMode() > 0)
00287                      LineSpVal->setEnabled(false);
00288               else
00289                      LineSpVal->setEnabled(true);
00290        }
00291 
00292        GroupBox10 = new QGroupBox( tr("Tabulators and Indentation"), this, "GroupBox10" );
00293        GroupBox10->setColumnLayout(0, Qt::Vertical );
00294        GroupBox10->layout()->setSpacing( 0 );
00295        GroupBox10->layout()->setMargin( 0 );
00296        GroupBox10Layout = new QVBoxLayout(GroupBox10->layout());
00297        GroupBox10Layout->setAlignment( Qt::AlignTop );
00298        GroupBox10Layout->setSpacing( 5 );
00299        GroupBox10Layout->setMargin( 10 );
00300        TabList = new Tabruler(GroupBox10, true, DocsEin, vor->tabValues(), -1);
00301        TabList->setLeftIndentData(vor->leftMargin());
00302        TabList->setLeftIndent();
00303        TabList->setFirstLineData(vor->firstIndent());
00304        TabList->setFirstLine();
00305        GroupBox10Layout->addWidget( TabList );
00306        EditStyleLayout->addWidget( GroupBox10 );
00307 
00308        // Label for holding "style preview" bitmap 12/30/2004 petr vanek
00309        layoutPreview = new QVBoxLayout; // paragraphs and check
00310        layoutPreview->setSpacing(6);
00311        layoutPreview->setMargin(0);
00312        layoutPrevSet = new QHBoxLayout; // all preview items
00313        layoutPrevSet->setSpacing(6);
00314        layoutPrevSet->setMargin(0);
00315 
00316        previewCaption = new QCheckBox( tr("Preview of the Paragraph Style"), this, "previewCaption" );
00317        previewCaption->setChecked(PrefsManager::instance()->appPrefs.haveStylePreview);
00318        QSpacerItem* spacerBg = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
00319        previewBgColor = new QPushButton(this, "previewBgColor");
00320        previewBgColor->setText( tr("Background"));
00321        layoutPrevSet->addWidget(previewCaption);
00322        layoutPrevSet->addItem(spacerBg);
00323        layoutPrevSet->addWidget(previewBgColor);
00324 
00325        layoutPreview->addLayout(layoutPrevSet);
00326 
00327        previewText = new QLabel(this, "previewText");
00328        previewText->setMinimumSize(640, 200);
00329        previewText->setMaximumSize(640, 200);
00330        previewText->setAlignment( static_cast<int>( QLabel::AlignVCenter | QLabel::AlignLeft ) );
00331        previewText->setFrameShape(QFrame::Box);
00332        previewText->setPaletteBackgroundColor(paletteBackgroundColor());
00333        layoutPreview->addWidget(previewText);
00334 
00335        EditStyleLayout->addLayout(layoutPreview);
00336 
00337        Layout17 = new QHBoxLayout;
00338        Layout17->setSpacing( 6 );
00339        Layout17->setMargin( 0 );
00340        QSpacerItem* spacer2a = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00341        Layout17->addItem( spacer2a );
00342        OkButton = new QPushButton( CommonStrings::tr_OK, this, "OkButton" );
00343        Layout17->addWidget( OkButton );
00344        Cancel = new QPushButton( CommonStrings::tr_Cancel, this, "Cancel" );
00345        OkButton->setDefault( true );
00346        Layout17->addWidget( Cancel );
00347        EditStyleLayout->addLayout(Layout17);
00348 
00349        werte = vor;
00350        // tooltips
00351        QToolTip::add(previewBgColor, "<qt>" + tr("Select for easier reading of light colored text styles") + "</qt>");
00352        QToolTip::add( Name, "<qt>" + tr( "Name of your paragraph style" ) + "</qt>" );
00353        QToolTip::add( FontC, "<qt>" + tr( "Font of selected text or object" ) + "</qt>" );
00354        QToolTip::add( SizeC, "<qt>" + tr( "Font Size" ) + "</qt>" );
00355        QToolTip::add( TxFill, "<qt>" + tr( "Color of text fill" ) + "</qt>" );
00356        QToolTip::add( TxStroke, "<qt>" + tr( "Color of text stroke" ) + "</qt>" );
00357        //     QToolTip::add( DropCaps, "<qt>" + tr( "Provides an oversized first letter for a paragraph. Used for stylistic effect" ) + "</qt>" );
00358        QToolTip::add( DropLines, "<qt>" + tr( "Determines the overall height, in line numbers, of the Drop Caps" ) );
00359        QToolTip::add( DropDist, "<qt>" + tr( "Determines the gap between the DropCaps and the Text" ) );
00360        //     QToolTip::add( BaseGrid, "<qt>" + tr( "Align text to baseline grid" ) + "</qt>" );
00361        QToolTip::add( AboveV, "<qt>" + tr( "Spacing above the paragraph" ) + "</qt>" );
00362        QToolTip::add( BelowV, "<qt>" + tr( "Spacing below the paragraph" ) + "</qt>" );
00363        QToolTip::add( fontKern, tr("Manual Tracking"));
00364        QToolTip::add( fontBase, tr("Offset to baseline of characters"));
00365        QToolTip::add( LineSpVal, "<qt>" + tr( "Line Spacing" ) + "</qt>" );
00366        QToolTip::add( linespacingButton, tr("Click to select the line spacing mode"));
00367        QToolTip::add( previewText, "<qt>" + tr( "Toggles sample text of this paragraph style" ) + "</qt>");
00368 
00369        // signals and slots connections
00370        connect( Cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
00371        connect( OkButton, SIGNAL( clicked() ), this, SLOT( Verlassen() ) );
00372        connect( DropCaps, SIGNAL( toggled(bool) ), this, SLOT( updatePreview() ) );
00373        connect(SizeC, SIGNAL(valueChanged(int)), this, SLOT(FontChange()));
00374        connect(fontVScale, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00375        connect(fontHScale, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00376        connect(EffeS, SIGNAL(State(int)), this, SLOT(ColorChange()));
00377        connect(EffeS->ShadowVal->Xoffset, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00378        connect(EffeS->ShadowVal->Yoffset, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00379        connect(EffeS->OutlineVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00380        connect(EffeS->UnderlineVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00381        connect(EffeS->UnderlineVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00382        connect(EffeS->StrikeVal->LPos, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00383        connect(EffeS->StrikeVal->LWidth, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00384        // preview generators
00385 //     connect(FontC, SIGNAL(activated(const QString &)), this, SLOT(updatePreview()));
00386        connect(FontC, SIGNAL(fontSelected(QString )), this, SLOT(updatePreview()));
00387        connect(LineSpVal, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00388        connect(fontBase, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00389        connect(fontKern, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00390        connect(TabList, SIGNAL(tabrulerChanged()), this, SLOT(updatePreview()));
00391        connect(AboveV, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00392        connect(BelowV, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00393        connect(AligS, SIGNAL(State(int)), this, SLOT(updatePreview()));
00394        connect(TxStroke, SIGNAL(activated(const QString &)), this, SLOT(updatePreview()));
00395        connect(PM1, SIGNAL(clicked()), this, SLOT(updatePreview()));
00396        connect(TxFill, SIGNAL(activated(const QString &)), this, SLOT(updatePreview()));
00397        connect(PM2, SIGNAL(clicked()), this, SLOT(updatePreview()));
00398        connect(DropLines, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00399        connect(DropDist, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00400        connect(previewCaption, SIGNAL( clicked() ), this, SLOT( togglePreview() ) );
00401        connect(previewBgColor, SIGNAL(clicked()), this, SLOT(setPreviewBackground()));
00402        connect(lineSpacingPop, SIGNAL(activated(int)), this, SLOT(toggleLsp(int )));
00403        connect(fontKern, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
00404 
00405        AboveV->setDecimals(10);
00406        BelowV->setDecimals(10);
00407        /* PFJ - 29.02.04 - Altered switch so only case 2 is tested */
00408        QString ein = unitGetSuffixFromIndex(dEin);
00409        if (dEin == 2)
00410        {
00411               AboveV->setDecimals(10000);
00412               BelowV->setDecimals(10000);
00413               DropDist->setDecimals(10000);
00414        }
00415        AboveV->setSuffix(ein);
00416        BelowV->setSuffix(ein);
00417        DropDist->setSuffix(ein);
00418        BelowV->setValue(vor->gapAfter() * parentDoc->unitRatio());
00419        AboveV->setValue(vor->gapBefore() * parentDoc->unitRatio());
00420        DropDist->setValue(vor->dropCapOffset() * parentDoc->unitRatio());
00421        ColorChange();
00422        togglePreview();
00423        qApp->restoreOverrideCursor();
00424 }
00425 
00426 EditStyle::~EditStyle()
00427 {
00428        delete sampleItem;
00429 }
00430 
00431 void EditStyle::toggleLsp(int id)
00432 {
00433        for (uint al = 0; al < lineSpacingPop->count(); ++al)
00434        {
00435               lineSpacingPop->setItemChecked(lineSpacingPop->idAt(al), false);
00436        }
00437        lineSpacingPop->setItemChecked(id, true);
00438        if (lineSpacingPop->indexOf(id) > 0)
00439        {
00440               LineSpVal->setSpecialValueText( tr( "Auto" ) );
00441               LineSpVal->setMinValue(0);
00442               LineSpVal->setValue(0);
00443               LineSpVal->setEnabled(false);
00444        }
00445        else
00446        {
00447               LineSpVal->setEnabled(true);
00448               LineSpVal->setSpecialValueText("");
00449               LineSpVal->setMinValue(1);
00450               double val = SizeC->value();
00451               LineSpVal->setValue((val  * AutoVal / 100) + val);
00452        }
00453        updatePreview();
00454 }
00455 
00456 void EditStyle::togglePreview()
00457 {
00458        if (previewCaption->isChecked())
00459        {
00460               previewText->show();
00461               previewText->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
00462               previewBgColor->show();
00463               updatePreview();
00464        }
00465        else
00466        {
00467               previewText->hide();
00468               previewBgColor->hide();
00469               previewText->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
00470        }
00471        PrefsManager::instance()->appPrefs.haveStylePreview = previewCaption->isChecked();
00472        layout()->activate();
00473        resize(minimumSizeHint());
00474 }
00475 
00476 void EditStyle::ColorChange()
00477 {
00478        int s = EffeS->getStyle();
00479        bool enabled;
00480        if ((s & 4) || (s & 256))
00481               enabled = true;
00482        else
00483               enabled = false;
00484        StrokeIcon->setEnabled(enabled);
00485        PM1->setEnabled(enabled);
00486        TxStroke->setEnabled(enabled);
00487        updatePreview();
00488 }
00489 
00490 void EditStyle::FontChange()
00491 {
00492        double val = SizeC->value();
00493        if (LineSpVal->isEnabled())
00494               LineSpVal->setValue((val  * AutoVal / 100) + val);
00495        updatePreview();
00496 }
00497 
00498 void EditStyle::Verlassen()
00499 {
00500        QString mess=tr("Name of the style is not unique");
00501        if (IsNew)
00502        {
00503               for (uint x=0; x<allV.count()-1; ++x)
00504               {
00505                      if (Name->text() == allV[x].name())
00506                      {
00507                             QMessageBox::information(this, CommonStrings::trWarning, mess, CommonStrings::tr_OK,0, 0, 0, QMessageBox::Ok);
00508                             Name->selectAll();
00509                             Name->setFocus();
00510                             return;
00511                      }
00512               }
00513        }
00514        else
00515        {
00516               if (OldName != Name->text())
00517               {
00518                      for (uint x=0; x<allV.count(); ++x)
00519                      {
00520                             if (Name->text() == allV[x].name())
00521                             {
00522                                    QMessageBox::information(this, CommonStrings::trWarning, mess, CommonStrings::tr_OK,0, 0, 0, QMessageBox::Ok);
00523                                    Name->selectAll();
00524                                    Name->setFocus();
00525                                    return;
00526                             }
00527                      }
00528               }
00529        }
00530        copyStyleSettings(*werte);
00531        accept();
00532 }
00533 
00534 void EditStyle::copyStyleSettings(ParagraphStyle& parstyle)
00535 {
00536        CharStyle charstyle;
00537        charstyle.setFeatures(static_cast<StyleFlag>(EffeS->getStyle()).featureList());
00538        parstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(AligS->getStyle()));
00539        for (uint al = 0; al < lineSpacingPop->count(); ++al)
00540        {
00541               if (lineSpacingPop->isItemChecked(lineSpacingPop->idAt(al)))
00542               {
00543                      parstyle.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(al));
00544                      parstyle.setUseBaselineGrid(al == 2);
00545                      break;
00546               }
00547        }
00548        parstyle.setLineSpacing(LineSpVal->value());
00549        parstyle.setLeftMargin(QMAX(TabList->getLeftIndent(), 0.0));
00550        parstyle.setFirstIndent(TabList->getFirstLine());
00551        parstyle.setGapBefore(AboveV->value() / parentDoc->unitRatio());
00552        parstyle.setGapAfter(BelowV->value() / parentDoc->unitRatio());
00553        parstyle.setName(Name->text());
00554        charstyle.setFont(PrefsManager::instance()->appPrefs.AvailFonts[FontC->currentFont()]);
00555        charstyle.setFontSize(qRound(SizeC->value() * 10.0));
00556        parstyle.setHasDropCap(DropCaps->isChecked());
00557        parstyle.setDropCapLines(DropLines->value());
00558        parstyle.setDropCapOffset(DropDist->value() / parentDoc->unitRatio());
00559        charstyle.setFillColor(TxFill->currentText());
00560        charstyle.setFillShade(PM2->getValue());
00561        charstyle.setStrokeColor(TxStroke->currentText());
00562        charstyle.setStrokeShade(PM1->getValue());
00563        parstyle.setTabValues(TabList->getTabVals());
00564        charstyle.setShadowXOffset(qRound(EffeS->ShadowVal->Xoffset->value() * 10.0));
00565        charstyle.setShadowYOffset(qRound(EffeS->ShadowVal->Yoffset->value() * 10.0));
00566        charstyle.setOutlineWidth(qRound(EffeS->OutlineVal->LWidth->value() * 10.0));
00567        charstyle.setStrikethruOffset(qRound(EffeS->StrikeVal->LPos->value() * 10.0));
00568        charstyle.setStrikethruWidth(qRound(EffeS->StrikeVal->LWidth->value() * 10.0));
00569        charstyle.setUnderlineOffset(qRound(EffeS->UnderlineVal->LPos->value() * 10.0));
00570        charstyle.setUnderlineWidth(qRound(EffeS->UnderlineVal->LWidth->value() * 10.0));
00571        charstyle.setScaleH(qRound(fontHScale->value() * 10.0));
00572        charstyle.setScaleV(qRound(fontVScale->value() * 10.0));
00573        charstyle.setBaselineOffset(qRound(fontBase->value() * 10.0));
00574        charstyle.setTracking(qRound(fontKern->value() * 10.0));
00575        parstyle.charStyle().applyCharStyle(charstyle);
00576 }
00577 
00578 
00579 void EditStyle::updatePreview()
00580 {
00581        if (!previewCaption->isChecked())
00582               return;
00583        qApp->setOverrideCursor(QCursor(waitCursor));
00584 
00585        ParagraphStyle tmpStyle;
00586        copyStyleSettings(tmpStyle);
00587        tmpStyle.setName(Name->text() + " (preview temporary)");
00588        sampleItem->setStyle(tmpStyle);
00589        QPixmap pm = sampleItem->getSample(previewText->width(), previewText->height());
00590        previewText->setPixmap(pm);
00591        qApp->restoreOverrideCursor();
00592 }
00593 
00594 void EditStyle::setPreviewBackground()
00595 {
00596        QColor bg;
00597        bg = QColorDialog::getColor(previewText->paletteBackgroundColor(), this);
00598        if (bg.isValid())
00599        {
00600               prefs->set("PreviewBg", bg.name());
00601               previewText->setPaletteBackgroundColor(bg);
00602               sampleItem->setBgColorMngt(false);
00603               sampleItem->setBgColor(bg);
00604               updatePreview();
00605        }
00606 }