1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #include "missing.h"
8 
9 #include <QGridLayout>
10 #include <QHBoxLayout>
11 #include <QLabel>
12 #include <QPushButton>
13 #include <QImage>
14 #include <QPixmap>
15 
16 #include "commonstrings.h"
17 #include "fontcombo.h"
18 #include "iconmanager.h"
19 #include "prefsmanager.h"
20 #include "scpage.h"
21 #include "scribusdoc.h"
22 #include "util.h"
23 
MissingFont(QWidget * parent,const QString & fon,ScribusDoc * doc)24 MissingFont::MissingFont( QWidget* parent, const QString& fon, ScribusDoc* doc ) : QDialog( parent )
25 {
26 	setModal(true);
27 	setWindowTitle( tr("Missing Font"));
28 	setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
29 	missingFontLayout = new QHBoxLayout( this );
30 	missingFontLayout->setContentsMargins(9, 9, 9, 9);
31 	missingFontLayout->setSpacing(6);
32 	missingFontGridLayout = new QGridLayout;
33 	missingFontGridLayout->setSpacing(6);
34 	missingFontGridLayout->setContentsMargins(0, 0, 0, 0);
35 	notInstalledLabel = new QLabel( tr("The Font %1 is not installed.").arg(fon), this );
36 	missingFontGridLayout->addWidget( notInstalledLabel, 0, 0, 1, 4 );
37 	pixmapLabel = new QLabel( this );
38 	pixmapLabel->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(32, 32));
39 	missingFontGridLayout->addWidget( pixmapLabel, 1, 0 );
40 	useLabel = new QLabel( tr( "Use" ), this );
41 	missingFontGridLayout->addWidget( useLabel, 1, 1 );
42 	replaceFontCombo = new FontComboH(this);
43 	replaceFontCombo->setCurrentFont(doc == nullptr ? PrefsManager::instance().appPrefs.itemToolPrefs.textFont : doc->itemToolPrefs().textFont);
44 	replacementFont = replaceFontCombo->currentFont();
45 	missingFontGridLayout->addWidget( replaceFontCombo, 1, 2 );
46 	insteadLabel = new QLabel( tr( "instead" ), this );
47 	missingFontGridLayout->addWidget( insteadLabel, 1, 3 );
48 	okButton = new QPushButton( CommonStrings::tr_OK, this );
49 	missingFontGridLayout->addWidget( okButton, 2, 2 );
50 	missingFontLayout->addLayout( missingFontGridLayout );
51 
52 	// signals and slots connections
53 	connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
54 	connect( replaceFontCombo, SIGNAL(fontSelected(QString)), this, SLOT( newFont(const QString&) ) );
55 }
56 
newFont(const QString & replacement)57 void MissingFont::newFont(const QString& replacement)
58 {
59 	replacementFont = replacement;
60 }
61 
getReplacementFont()62 const QString& MissingFont::getReplacementFont()
63 {
64 	return replacementFont;
65 }
66 
67