Subversion Repositories Scribus

Rev

Rev 2262 | Rev 2272 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 paul 1
#include "edit1format.h"
2
#include "edit1format.moc"
280 Franz 3
#include "tabruler.h"
806 cbradney 4
#include "units.h"
1047 subik 5
 
3 paul 6
#include <qmessagebox.h>
249 Franz 7
#include <qtooltip.h>
838 cbradney 8
#include "scribusdoc.h"
710 cbradney 9
#include "styleselect.h"
1879 subik 10
#include "pageitem.h"
11
#include "scribusdoc.h"
12
#include "scribusstructs.h"
13
#include "scpaths.h"
3 paul 14
 
1047 subik 15
extern QPixmap loadIcon(QString nam);
1879 subik 16
extern bool loadText(QString nam, QString *Buffer);
1047 subik 17
 
18
 
1065 cbradney 19
EditStyle::EditStyle( QWidget* parent, struct ParagraphStyle *vor, QValueList<ParagraphStyle> v, bool neu, ApplicationPrefs *Prefs, double au, int dEin, ScribusDoc *doc)
249 Franz 20
                : QDialog( parent, "EditST", true, 0)
3 paul 21
{
1047 subik 22
        parentDoc = doc;
249 Franz 23
        setCaption( tr( "Edit Style" ) );
161 Franz 24
        setIcon(loadIcon("AppIcon.png"));
25
        AutoVal = au;
26
        DocsEin = dEin;
2263 fschmid 27
        PrefsData = Prefs;
249 Franz 28
        EditStyleLayout = new QGridLayout( this );
29
        EditStyleLayout->setSpacing( 6 );
30
        EditStyleLayout->setMargin( 10 );
3 paul 31
 
348 Franz 32
        TextLabel1 = new QLabel( tr( "&Name:" ), this, "TextLabel1" );
249 Franz 33
        EditStyleLayout->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
3 paul 34
 
249 Franz 35
        Name = new QLineEdit( this, "Name" );
36
        Name->setMinimumSize( QSize( 200, 22 ) );
37
        Name->setText( vor->Vname );
38
        OldName = vor->Vname;
39
        IsNew = neu;
348 Franz 40
        TextLabel1->setBuddy(Name);
249 Franz 41
        EditStyleLayout->addMultiCellWidget( Name, 1, 1, 0, 1 );
3 paul 42
 
348 Franz 43
        GroupFont = new QGroupBox( tr( "Character" ), this, "GroupFont" );
249 Franz 44
        GroupFont->setColumnLayout(0, Qt::Vertical );
45
        GroupFont->layout()->setSpacing( 5 );
46
        GroupFont->layout()->setMargin( 10 );
47
        GroupFontLayout = new QGridLayout( GroupFont->layout() );
48
        GroupFontLayout->setAlignment( Qt::AlignTop );
348 Franz 49
        TextF1 = new QLabel( tr( "&Font:"),  GroupFont, "TextF1" );
249 Franz 50
        TextF1->setMinimumSize( QSize( 50, 22 ) );
51
        GroupFontLayout->addWidget( TextF1, 0, 0 );
52
        FontC = new FontCombo(GroupFont, Prefs);
53
        for (int fc=0; fc<FontC->count(); ++fc)
54
        {
55
                if (FontC->text(fc) == vor->Font)
56
                {
57
                        FontC->setCurrentItem(fc);
58
                        break;
59
                }
60
        }
348 Franz 61
        TextF1->setBuddy(FontC);
280 Franz 62
        GroupFontLayout->addMultiCellWidget( FontC, 0, 0, 1, 4 );
2247 fschmid 63
        SizeC = new MSpinBox( 1, 2048, GroupFont, 1 );
249 Franz 64
        SizeC->setMinimumSize( QSize( 70, 22 ) );
65
        SizeC->setSuffix( tr( " pt" ) );
161 Franz 66
        SizeC->setValue(vor->FontSize / 10.0);
348 Franz 67
        TextF2 = new QLabel( SizeC, tr("Si&ze:") ,GroupFont, "TextF2" );
68
        TextF2->setMinimumSize( QSize( 50, 22 ) );
69
        GroupFontLayout->addWidget( TextF2, 1, 0 );
249 Franz 70
        GroupFontLayout->addWidget( SizeC, 1, 1 );
348 Franz 71
 
173 Franz 72
        EffeS = new StyleSelect(GroupFont);
73
        EffeS->setStyle(vor->FontEffect);
348 Franz 74
        EffeLabel = new QLabel( tr("Effect:"), GroupFont, "EffeLabel" );
75
        GroupFontLayout->addWidget( EffeLabel, 1, 2 );
280 Franz 76
        GroupFontLayout->addMultiCellWidget( EffeS, 1, 1, 3, 4, Qt::AlignLeft );
348 Franz 77
 
173 Franz 78
        AligS = new AlignSelect(GroupFont);
1065 cbradney 79
        AligS->setStyle(vor->textAlignment);
348 Franz 80
        AligLabel = new QLabel( AligS, tr("&Alignment:"), GroupFont, "AligLabel" );
81
        GroupFontLayout->addWidget( AligLabel, 2, 0 );
280 Franz 82
        GroupFontLayout->addWidget( AligS, 2, 1, Qt::AlignLeft );
3 paul 83
 
348 Franz 84
        DropCaps = new QCheckBox( tr("&Drop Caps"), GroupFont, "DropCaps" );
280 Franz 85
        DropCaps->setChecked(vor->Drop);
86
        GroupFontLayout->addWidget( DropCaps, 2, 2 );
87
        DropLines = new QSpinBox( GroupFont, "DropLines" );
88
        DropLines->setMinValue( 2 );
89
        DropLines->setMaxValue( 20 );
90
        DropLines->setValue(vor->DropLin);
348 Franz 91
        CapLabel = new QLabel( DropLines, tr("&Lines:"), GroupFont, "CapLabel" );
92
        GroupFontLayout->addWidget( CapLabel, 2, 3, Qt::AlignRight );
280 Franz 93
        GroupFontLayout->addWidget( DropLines, 2, 4 );
94
        bool enable = vor->Drop ? true : false;
95
        DropLines->setEnabled(enable);
96
        CapLabel->setEnabled(enable);
2219 fschmid 97
 
98
        tabFillCombo = new QComboBox( true, GroupFont, "tabFillCombo" );
99
        tabFillCombo->setEditable(false);
100
        tabFillCombo->insertItem( tr("None"));
101
        tabFillCombo->insertItem( "...");
102
        tabFillCombo->insertItem( "---");
103
        tabFillCombo->insertItem( "___");
104
        if (vor->tabFillChar == "")
105
                tabFillCombo->setCurrentItem(0);
106
        if (vor->tabFillChar == ".")
107
                tabFillCombo->setCurrentItem(1);
108
        if (vor->tabFillChar == "-")
109
                tabFillCombo->setCurrentItem(2);
110
        if (vor->tabFillChar == "_")
111
                tabFillCombo->setCurrentItem(3);
112
        GroupFontLayout->addWidget( tabFillCombo, 3, 4 );
113
        tabFillComboT = new QLabel(tabFillCombo, tr( "Tab Fill Char:" ), GroupFont, "textLabel3b2t" );
114
        GroupFontLayout->addWidget( tabFillComboT, 3, 3 );
280 Franz 115
 
249 Franz 116
        TxFill = new QComboBox( true, GroupFont, "TxFill" );
173 Franz 117
        TxFill->setEditable(false);
348 Franz 118
        FillIcon = new QLabel( TxFill, tr( "F&ill Color:" ), GroupFont, "FillIcon" );
119
        GroupFontLayout->addWidget( FillIcon, 3, 0 );
280 Franz 120
        GroupFontLayout->addWidget( TxFill, 3, 1 );
173 Franz 121
        PM2 = new ShadeButton(GroupFont);
280 Franz 122
        GroupFontLayout->addWidget( PM2, 3, 2, Qt::AlignLeft );
173 Franz 123
 
249 Franz 124
        TxStroke = new QComboBox( true, GroupFont, "TxStroke" );
173 Franz 125
        TxStroke->setEditable(false);
348 Franz 126
        StrokeIcon = new QLabel( TxStroke, tr("St&roke Color:"), GroupFont, "StrokeIcon" );
127
        GroupFontLayout->addWidget( StrokeIcon, 4, 0 );
280 Franz 128
        GroupFontLayout->addWidget( TxStroke, 4, 1 );
173 Franz 129
        PM1 = new ShadeButton(GroupFont);
280 Franz 130
        GroupFontLayout->addWidget( PM1, 4, 2, Qt::AlignLeft );
173 Franz 131
 
132
        TxFill->clear();
133
        TxStroke->clear();
1065 cbradney 134
        ColorList::Iterator it;
173 Franz 135
        QPixmap pm = QPixmap(15, 15);
136
        TxFill->insertItem( tr("None"));
137
        TxStroke->insertItem( tr("None"));
138
        for (it = doc->PageColors.begin(); it != doc->PageColors.end(); ++it)
223 Franz 139
        {
173 Franz 140
                pm.fill(doc->PageColors[it.key()].getRGBColor());
141
                TxFill->insertItem(pm, it.key());
142
                TxStroke->insertItem(pm, it.key());
223 Franz 143
        }
173 Franz 144
        StrokeIcon->setEnabled(false);
414 Franz 145
        PM1->setEnabled(false);
173 Franz 146
        TxStroke->setEnabled(false);
147
        TxFill->setCurrentText(vor->FColor);
148
        TxStroke->setCurrentText(vor->SColor);
149
        PM2->setValue(vor->FShade);
150
        PM1->setValue(vor->SShade);
151
 
280 Franz 152
        EditStyleLayout->addWidget( GroupFont, 2, 0 );
1047 subik 153
 
348 Franz 154
        AbstandV = new QGroupBox( tr("Vertical Spaces"), this, "AbstandV" );
249 Franz 155
        AbstandV->setColumnLayout(0, Qt::Vertical );
156
        AbstandV->layout()->setSpacing( 0 );
157
        AbstandV->layout()->setMargin( 0 );
158
        AbstandVLayout = new QGridLayout( AbstandV->layout() );
159
        AbstandVLayout->setAlignment( Qt::AlignTop );
160
        AbstandVLayout->setSpacing( 5 );
161
        AbstandVLayout->setMargin( 10 );
3 paul 162
 
2026 cbradney 163
        BaseGrid = new QCheckBox( tr("Align to Baseline &Grid"), AbstandV, "BaseGrid" );
241 Franz 164
        BaseGrid->setChecked(vor->BaseAdj);
165
        AbstandVLayout->addMultiCellWidget( BaseGrid, 0, 0, 0, 1 );
333 Franz 166
        AboveV = new MSpinBox( 0, 300, AbstandV, 1 );
249 Franz 167
        AboveV->setMinimumSize( QSize( 70, 22 ) );
168
        AbstandVLayout->addWidget( AboveV, 1, 1 );
3 paul 169
 
333 Franz 170
        BelowV = new MSpinBox( 0, 300, AbstandV, 1 );
249 Franz 171
        BelowV->setMinimumSize( QSize( 70, 22 ) );
241 Franz 172
        AbstandVLayout->addWidget( BelowV, 2, 1 );
3 paul 173
 
333 Franz 174
        LineSpVal = new MSpinBox( 1, 300, AbstandV, 1 );
249 Franz 175
        LineSpVal->setMinimumSize( QSize( 70, 22 ) );
176
        LineSpVal->setSuffix( tr( " pt" ) );
177
        LineSpVal->setValue(vor->LineSpa);
178
        AbstandVLayout->addWidget( LineSpVal, 3, 1 );
80 Franz 179
 
348 Franz 180
        TextLabel3 = new QLabel( LineSpVal, tr("Line &Spacing:"), AbstandV, "TextLabel3" );
249 Franz 181
        TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)1,
182
                                                TextLabel3->sizePolicy().hasHeightForWidth() ) );
183
        TextLabel3->setMinimumSize( QSize( 90, 22 ) );
184
        AbstandVLayout->addWidget( TextLabel3, 3, 0 );
348 Franz 185
        TextLabel1_2_2 = new QLabel( AboveV, tr("Abo&ve:"), AbstandV, "TextLabel1_2_2" );
249 Franz 186
        TextLabel1_2_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)1,
187
                                       TextLabel1_2_2->sizePolicy().hasHeightForWidth() ) );
188
        TextLabel1_2_2->setMinimumSize( QSize( 90, 22 ) );
189
        AbstandVLayout->addWidget( TextLabel1_2_2, 1, 0 );
348 Franz 190
        TextLabel1_2_3 = new QLabel( BelowV, tr("&Below:"), AbstandV, "TextLabel1_2_3" );
249 Franz 191
        TextLabel1_2_3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)1,
192
                                       TextLabel1_2_3->sizePolicy().hasHeightForWidth() ) );
193
        TextLabel1_2_3->setMinimumSize( QSize( 90, 22 ) );
194
        AbstandVLayout->addWidget( TextLabel1_2_3, 2, 0 );
195
        EditStyleLayout->addWidget( AbstandV, 2, 1 );
3 paul 196
 
348 Franz 197
        GroupBox10 = new QGroupBox( tr("Tabulators and Indentation"), this, "GroupBox10" );
280 Franz 198
        GroupBox10->setColumnLayout(0, Qt::Vertical );
199
        GroupBox10->layout()->setSpacing( 0 );
200
        GroupBox10->layout()->setMargin( 0 );
201
        GroupBox10Layout = new QVBoxLayout(GroupBox10->layout());
202
        GroupBox10Layout->setAlignment( Qt::AlignTop );
203
        GroupBox10Layout->setSpacing( 5 );
204
        GroupBox10Layout->setMargin( 10 );
205
        TabList = new Tabruler(GroupBox10, true, DocsEin, vor->TabValues, -1);
820 cbradney 206
        TabList->setLeftIndentData(vor->Indent);
207
        TabList->setLeftIndent();
208
        TabList->setFirstLineData(vor->First);
209
        TabList->setFirstLine();
280 Franz 210
        GroupBox10Layout->addWidget( TabList );
211
 
212
        EditStyleLayout->addMultiCellWidget( GroupBox10, 3, 3, 0, 1 );
213
 
1047 subik 214
        // Label for holding "style preview" bitmap 12/30/2004 petr vanek
1613 subik 215
        layoutPreview = new QVBoxLayout;
216
        layoutPreview->setSpacing(6);
217
        layoutPreview->setMargin(0);
2258 fschmid 218
        previewCaption = new QCheckBox( tr("Preview of the Paragraph Style"), this, "previewCaption" );
2263 fschmid 219
        previewCaption->setChecked(Prefs->haveStylePreview);
1879 subik 220
        layoutPreview->addWidget(previewCaption);
1047 subik 221
        previewText = new QLabel(this, "previewText");
1879 subik 222
        previewText->setMinimumSize(640, 200);
223
        previewText->setMaximumSize(640, 200);
1047 subik 224
        previewText->setAlignment( static_cast<int>( QLabel::AlignVCenter | QLabel::AlignLeft ) );
225
        previewText->setFrameShape(QFrame::Box);
226
        previewText->setPaletteBackgroundColor(paletteBackgroundColor());
1613 subik 227
        layoutPreview->addWidget(previewText);
1879 subik 228
        // preview setting - reading first paragraphs from LoremIpsum.txt etc.
229
        previewItem = new PageItem(parentDoc, PageItem::TextFrame, 0, 0, previewText->width(), previewText->height(), 0, "None", parentDoc->toolSettings.dPenText);
230
        previewItem->FrameType = PageItem::TextFrame;
1882 subik 231
        if (!loadText(ScPaths::instance().sampleScriptDir() + "LoremIpsum-short.txt", &lorem))
232
        {
1879 subik 233
                qDebug("edit1format.cpp: Error reading sample text");
1882 subik 234
                lorem = QString("Lorem ipsum");
235
        }
1879 subik 236
        lorem = QString::fromUtf8(lorem);
237
        lorem = lorem.section('\n', 0, 2);
1047 subik 238
 
249 Franz 239
        Layout17 = new QHBoxLayout;
240
        Layout17->setSpacing( 6 );
241
        Layout17->setMargin( 0 );
242
        QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
243
        Layout17->addItem( spacer2 );
348 Franz 244
        OkButton = new QPushButton( tr( "&OK" ), this, "OkButton" );
249 Franz 245
        Layout17->addWidget( OkButton );
348 Franz 246
        Cancel = new QPushButton( tr( "&Cancel" ), this, "Cancel" );
249 Franz 247
        OkButton->setDefault( true );
248
        Layout17->addWidget( Cancel );
1613 subik 249
        layoutPreview->addLayout(Layout17);
250
        EditStyleLayout->addMultiCellLayout( layoutPreview, 4, 4, 0, 1 );
249 Franz 251
        werte = vor;
252
        allV = v;
253
        // tooltips
1879 subik 254
        QToolTip::add( Name, "<qt>" + tr( "Name of your paragraph style" ) + "</qt>" );
255
        QToolTip::add( FontC, "<qt>" + tr( "Font of selected text or object" ) + "</qt>" );
256
        QToolTip::add( SizeC, "<qt>" + tr( "Font Size" ) + "</qt>" );
257
        QToolTip::add( TxFill, "<qt>" + tr( "Color of text fill" ) + "</qt>" );
258
        QToolTip::add( TxStroke, "<qt>" + tr( "Color of text stroke" ) + "</qt>" );
259
        QToolTip::add( DropCaps, "<qt>" + tr( "Provides an oversized first letter for a paragraph. Used for stylistic effect" ) + "</qt>" );
260
        QToolTip::add( DropLines, "<qt>" + tr( "Determines the overall height, in line numbers, of the Drop Caps" ) );
261
        QToolTip::add( BaseGrid, "<qt>" + tr( "Align text to baseline grid" ) + "</qt>" );
262
        QToolTip::add( AboveV, "<qt>" + tr( "Spacing above the paragraph" ) + "</qt>" );
263
        QToolTip::add( BelowV, "<qt>" + tr( "Spacing below the paragraph" ) + "</qt>" );
264
        QToolTip::add( LineSpVal, "<qt>" + tr( "Line Spacing" ) + "</qt>" );
2258 fschmid 265
        QToolTip::add( previewText, "<qt>" + tr( "Toggles sample text of this paragraph style" ) + "</qt>");
249 Franz 266
 
267
        // signals and slots connections
268
        connect( Cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
269
        connect( OkButton, SIGNAL( clicked() ), this, SLOT( Verlassen() ) );
270
        connect( DropCaps, SIGNAL( clicked() ), this, SLOT( ManageDrops() ) );
271
        connect(SizeC, SIGNAL(valueChanged(int)), this, SLOT(FontChange()));
272
        connect(EffeS, SIGNAL(State(int)), this, SLOT(ColorChange()));
1879 subik 273
        // preview generators
274
        connect(FontC, SIGNAL(activated(const QString &)), this, SLOT(updatePreview()));
275
        connect(LineSpVal, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
276
        connect(TabList, SIGNAL(tabrulerChanged()), this, SLOT(updatePreview()));
277
        connect(AboveV, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
278
        connect(BelowV, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
279
        connect(AligS, SIGNAL(State(int)), this, SLOT(updatePreview()));
280
        connect(TxStroke, SIGNAL(activated(const QString &)), this, SLOT(updatePreview()));
281
        connect(PM1, SIGNAL(clicked()), this, SLOT(updatePreview()));
282
        connect(TxFill, SIGNAL(activated(const QString &)), this, SLOT(updatePreview()));
283
        connect(PM2, SIGNAL(clicked()), this, SLOT(updatePreview()));
284
        connect(BaseGrid, SIGNAL(stateChanged(int)), this, SLOT(updatePreview()));
285
        connect(DropLines, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));
2258 fschmid 286
        connect(previewCaption, SIGNAL( clicked() ), this, SLOT( togglePreview() ) );
1879 subik 287
 
161 Franz 288
        AboveV->setDecimals(10);
289
        BelowV->setDecimals(10);
223 Franz 290
        /* PFJ - 29.02.04 - Altered switch so only case 2 is tested */
806 cbradney 291
        QString ein = unitGetSuffixFromIndex(dEin);
223 Franz 292
        if (dEin == 2)
161 Franz 293
        {
249 Franz 294
                AboveV->setDecimals(10000);
295
                BelowV->setDecimals(10000);
161 Franz 296
        }
249 Franz 297
        AboveV->setSuffix(ein);
298
        BelowV->setSuffix(ein);
1843 cbradney 299
        BelowV->setValue(vor->gapAfter * parentDoc->unitRatio);
300
        AboveV->setValue(vor->gapBefore * parentDoc->unitRatio);
174 Franz 301
        ColorChange();
2263 fschmid 302
        togglePreview();
3 paul 303
}
304
 
2258 fschmid 305
void EditStyle::togglePreview()
306
{
307
        if (previewCaption->isChecked())
308
        {
309
                previewText->show();
310
                previewText->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
311
                updatePreview();
312
        }
313
        else
314
        {
315
                previewText->hide();
316
                previewText->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
317
        }
2263 fschmid 318
        PrefsData->haveStylePreview = previewCaption->isChecked();
2258 fschmid 319
        layout()->activate();
320
        resize(minimumSizeHint());
321
}
322
 
173 Franz 323
void EditStyle::ColorChange()
324
{
325
        int s = EffeS->getStyle();
2229 fschmid 326
        bool enabled;
327
        if ((s & 4) || (s & 256))
328
                enabled = true;
329
        else
330
                enabled = false;
173 Franz 331
        StrokeIcon->setEnabled(enabled);
414 Franz 332
        PM1->setEnabled(enabled);
173 Franz 333
        TxStroke->setEnabled(enabled);
1047 subik 334
        updatePreview();
173 Franz 335
}
336
 
153 Franz 337
void EditStyle::ManageDrops()
338
{
161 Franz 339
        bool enabled = DropCaps->isChecked() ? true : false;
340
        DropLines->setEnabled(enabled);
341
        CapLabel->setEnabled(enabled);
1047 subik 342
        updatePreview();
153 Franz 343
}
344
 
345
void EditStyle::FontChange()
3 paul 346
{
153 Franz 347
        double val = SizeC->value();
348
        LineSpVal->setValue((val  * AutoVal / 100) + val);
1047 subik 349
        updatePreview();
3 paul 350
}
351
 
352
void EditStyle::Verlassen()
353
{
354
        if (IsNew)
161 Franz 355
        {
356
                for (uint x=0; x<allV.count()-1; ++x)
3 paul 357
                {
161 Franz 358
                        if (Name->text() == allV[x].Vname)
3 paul 359
                        {
2150 cbradney 360
                                QMessageBox::information(this, tr("Warning"), tr("Name of the Style is not unique"), tr("&OK"),
249 Franz 361
                                                         0, 0, 0, QMessageBox::Ok);
362
                                Name->selectAll();
112 Franz 363
                                Name->setFocus();
3 paul 364
                                return;
365
                        }
366
                }
161 Franz 367
        }
3 paul 368
        else
161 Franz 369
        {
370
                if (OldName != Name->text())
3 paul 371
                {
161 Franz 372
                        for (uint x=0; x<allV.count(); ++x)
3 paul 373
                        {
161 Franz 374
                                if (Name->text() == allV[x].Vname)
3 paul 375
                                {
249 Franz 376
                                        QMessageBox::information(this, tr("Warning"), tr("Name of the Style is not unique"),
2150 cbradney 377
                                                                 tr("&OK"),0, 0, 0, QMessageBox::Ok);
249 Franz 378
                                        Name->selectAll();
112 Franz 379
                                        Name->setFocus();
3 paul 380
                                        return;
381
                                }
382
                        }
383
                }
161 Franz 384
        }
173 Franz 385
        werte->FontEffect = EffeS->getStyle();
1065 cbradney 386
        werte->textAlignment = AligS->getStyle();
146 Franz 387
        werte->LineSpa = LineSpVal->value();
2254 fschmid 388
        werte->Indent = QMAX(TabList->getLeftIndent(), 0.0);
820 cbradney 389
        werte->First = TabList->getFirstLine();
1843 cbradney 390
        werte->gapBefore = AboveV->value() / parentDoc->unitRatio;
391
        werte->gapAfter = BelowV->value() / parentDoc->unitRatio;
3 paul 392
        werte->Vname = Name->text();
393
        werte->Font = FontC->currentText();
146 Franz 394
        werte->FontSize = qRound(SizeC->value() * 10.0);
153 Franz 395
        werte->Drop = DropCaps->isChecked();
396
        werte->DropLin = DropLines->value();
173 Franz 397
        werte->FColor = TxFill->currentText();
398
        werte->FShade = PM2->getValue();
399
        werte->SColor = TxStroke->currentText();
400
        werte->SShade = PM1->getValue();
241 Franz 401
        werte->BaseAdj = BaseGrid->isChecked();
280 Franz 402
        werte->TabValues = TabList->getTabVals();
2219 fschmid 403
        switch (tabFillCombo->currentItem())
404
        {
405
                case 0:
406
                        werte->tabFillChar = "";
407
                        break;
408
                case 1:
409
                        werte->tabFillChar = ".";
410
                        break;
411
                case 2:
412
                        werte->tabFillChar = "-";
413
                        break;
414
                case 3:
415
                        werte->tabFillChar = "_";
416
                        break;
417
        }
3 paul 418
        accept();
419
}
1047 subik 420
 
421
void EditStyle::updatePreview()
422
{
2258 fschmid 423
        if (!previewCaption->isChecked())
424
                return;
1879 subik 425
        int x = previewText->width();
426
        int y = previewText->height();
427
        QPixmap pm(x, y);
428
        ScPainter *painter = new ScPainter(&pm, x, y, 0, 0);
429
        painter->clear(white);
430
        pm.fill(white);
431
        previewText->clear();
1047 subik 432
 
1879 subik 433
        ParagraphStyle tmpStyle;
434
        tmpStyle.Vname = Name->text() + " (preview temporary)";
435
        tmpStyle.FontEffect = EffeS->getStyle();
436
        tmpStyle.textAlignment = AligS->getStyle();
437
        tmpStyle.LineSpa = LineSpVal->value();
438
        tmpStyle.Indent = TabList->getLeftIndent();
439
        tmpStyle.First = TabList->getFirstLine();
440
        tmpStyle.gapBefore = AboveV->value() / parentDoc->unitRatio;
441
        tmpStyle.gapAfter = BelowV->value() / parentDoc->unitRatio;
442
        tmpStyle.Font = FontC->currentText();
443
        tmpStyle.FontSize = qRound(SizeC->value() * 10.0);
444
        tmpStyle.Drop = DropCaps->isChecked();
445
        tmpStyle.DropLin = DropLines->value();
446
        tmpStyle.FColor = TxFill->currentText();
447
        tmpStyle.FShade = PM2->getValue();
448
        tmpStyle.SColor = TxStroke->currentText();
449
        tmpStyle.SShade = PM1->getValue();
450
        tmpStyle.BaseAdj = BaseGrid->isChecked();
451
        tmpStyle.TabValues = TabList->getTabVals();
2219 fschmid 452
        switch (tabFillCombo->currentItem())
453
        {
454
                case 0:
455
                        tmpStyle.tabFillChar = "";
456
                        break;
457
                case 1:
458
                        tmpStyle.tabFillChar = ".";
459
                        break;
460
                case 2:
461
                        tmpStyle.tabFillChar = "-";
462
                        break;
463
                case 3:
464
                        tmpStyle.tabFillChar = "_";
465
                        break;
466
        }
1879 subik 467
 
468
        QFont fo = QFont(FontC->currentText());
469
        fo.setPointSize(qRound(parentDoc->toolSettings.defSize / 10.0));
470
        parentDoc->AddFont(FontC->currentText(), fo);
471
        parentDoc->docParagraphStyles.append(tmpStyle);
472
        int tmpIndex = parentDoc->docParagraphStyles.count() - 1;
473
        previewItem->itemText.clear();
474
        previewItem->IFont = FontC->currentText();
2219 fschmid 475
        previewItem->Cols = 1;
1879 subik 476
        for (uint i = 0; i < lorem.length(); ++i)
477
        {
478
                ScText *hg = new ScText;
479
                hg->ch = lorem.at(i);
480
                if ((hg->ch == QChar(10)) || (hg->ch == QChar(5)))
481
                        hg->ch = QChar(13);
482
                hg->cfont = (*parentDoc->AllFonts)[FontC->currentText()];
483
                hg->csize = tmpStyle.FontSize;
484
                hg->ccolor = tmpStyle.FColor;
485
                hg->cshade = tmpStyle.FShade;
486
                hg->cstroke = tmpStyle.SColor;
487
                hg->cshade2 = tmpStyle.SShade;
2242 fschmid 488
                hg->cscale = 1000;
489
                hg->cscalev = 1000;
2234 fschmid 490
                hg->cbase = 0;
2247 fschmid 491
                hg->cshadowx = 50;
492
                hg->cshadowy = -50;
2257 fschmid 493
                hg->coutline = 10;
2262 fschmid 494
                hg->cunderpos = -1;
495
                hg->cunderwidth = -1;
1879 subik 496
                hg->cselect = false;
497
                hg->cstyle = tmpStyle.FontEffect;
498
                hg->cab = tmpIndex;
499
                hg->cextra = 0;
500
                hg->xp = 0;
501
                hg->yp = 0;
502
                hg->PRot = 0;
503
                hg->PtransX = 0;
504
                hg->PtransY = 0;
505
                previewItem->itemText.append(hg);
506
        }
507
 
508
        previewItem->DrawObj(painter, QRect(0, 0, x, y));
509
        painter->end();
510
        previewText->setPixmap(pm);
511
        delete(painter);
512
        parentDoc->docParagraphStyles.remove(parentDoc->docParagraphStyles.fromLast());
1047 subik 513
}