Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
1428 fschmid 1
#include "fontreplacedialog.h"
2
 
3
#include "fontreplacedialog.moc"
4
#include <qvariant.h>
5
#include <qlabel.h>
6
#include <qtable.h>
7
#include <qcheckbox.h>
8
#include <qpushbutton.h>
9
#include <qlayout.h>
10
#include <qtooltip.h>
11
#include <qwhatsthis.h>
12
#include <qcombobox.h>
13
#include "fontcombo.h"
14
extern QPixmap loadIcon(QString nam);
15
 
16
FontReplaceDialog::FontReplaceDialog( QWidget* parent, ApplicationPrefs *Prefs, QMap<QString, QString> *RList) : QDialog( parent, "FontReplaceDialog", true, 0 )
17
{
18
        setCaption( tr( "Font Substitution" ) );
19
        setIcon(loadIcon("AppIcon.png"));
20
        ReplaceList = RList;
21
        FontReplaceDialogLayout = new QVBoxLayout( this, 10, 5, "FontReplaceDialogLayout");
22
 
23
        textLabel1 = new QLabel( this, "textLabel1" );
24
        textLabel1->setAlignment( int( QLabel::AlignVCenter ) );
2217 cbradney 25
        textLabel1->setText( tr( "This document contains some fonts that are not installed on your system,\nplease choose a suitable replacement for them." ) );
1428 fschmid 26
        FontReplaceDialogLayout->addWidget( textLabel1 );
27
 
28
        replacementTable = new QTable( this, "replacementTable" );
29
        replacementTable->setNumCols( 2 );
30
        replacementTable->horizontalHeader()->setLabel( 0, tr( "Original Font" ) );
31
        replacementTable->horizontalHeader()->setLabel( 1, tr( "Substitution Font" ) );
32
        replacementTable->setSorting(false);
33
        replacementTable->setSelectionMode(QTable::NoSelection);
34
        replacementTable->setLeftMargin(0);
35
        replacementTable->verticalHeader()->hide();
36
        replacementTable->setNumRows(RList->count());
37
        int a = 0;
38
        QMap<QString,QString>::Iterator itfsu;
39
        for (itfsu = RList->begin(); itfsu != RList->end(); ++itfsu)
40
        {
41
                replacementTable->setText(a, 0, itfsu.key());
42
                FontCombo* item = new FontCombo(this, Prefs);
43
                item->setCurrentText(itfsu.data());
44
                replacementTable->setCellWidget(a, 1, item);
45
                a++;
46
        }
47
        replacementTable->setColumnStretchable(0, true);
48
        replacementTable->setColumnStretchable(1, true);
49
        FontReplaceDialogLayout->addWidget( replacementTable );
50
 
51
        layout1 = new QHBoxLayout( 0, 0, 5, "layout1");
52
        stickyReplacements = new QCheckBox( this, "stickyReplacements" );
53
        stickyReplacements->setText( tr( "Make these substitutions permanent" ) );
54
        layout1->addWidget( stickyReplacements );
55
        spacer1 = new QSpacerItem( 71, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
56
        layout1->addItem( spacer1 );
57
        okButton = new QPushButton( this, "okButton" );
2217 cbradney 58
        okButton->setText( tr( "&OK" ) );
1428 fschmid 59
        layout1->addWidget( okButton );
60
        FontReplaceDialogLayout->addLayout( layout1 );
61
        resize( QSize(474, 247).expandedTo(minimumSizeHint()) );
62
        clearWState( WState_Polished );
63
        connect(okButton, SIGNAL(clicked()), this, SLOT(close()));
64
}
65
 
66
void FontReplaceDialog::closeEvent(QCloseEvent *closeEvent)
67
{
68
        for (int a = 0; a < replacementTable->numRows(); ++a)
69
        {
70
                FontCombo* item = (FontCombo*)replacementTable->cellWidget(a, 1);
71
                ReplaceList->replace(replacementTable->text(a, 0), item->currentText());
72
        }
73
        closeEvent->accept();
74
}
75