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 "fontembeddingcombo.h" 8 #include "fontembeddingmodel.h" 9 // #include "qdebug.h" 10 FontEmbeddingCombo(QWidget * parent)11FontEmbeddingCombo::FontEmbeddingCombo(QWidget* parent) : QComboBox(parent) 12 { 13 #ifdef Q_OS_MAC 14 // setStyle( new FontEmbeddingCombo::ScMacStyle() ); 15 #endif 16 m_allowNoFontEmbedding = true; 17 m_fontEmbeddingModel = new FontEmbeddingModel(this); 18 19 setEditable(false); 20 setModel(m_fontEmbeddingModel); 21 } 22 ~FontEmbeddingCombo()23FontEmbeddingCombo::~FontEmbeddingCombo() 24 { 25 if (m_fontEmbeddingModel) 26 { 27 delete m_fontEmbeddingModel; 28 m_fontEmbeddingModel = nullptr; 29 } 30 } 31 embeddingMode() const32PDFOptions::PDFFontEmbedding FontEmbeddingCombo::embeddingMode() const 33 { 34 int curIndex = currentIndex(); 35 if (curIndex == 0) 36 return PDFOptions::EmbedFonts; 37 if (curIndex == 1) 38 return PDFOptions::OutlineFonts; 39 if (curIndex == 2) 40 return PDFOptions::DontEmbed; 41 return PDFOptions::EmbedFonts; 42 } 43 setEmbeddingMode(PDFOptions::PDFFontEmbedding mode)44void FontEmbeddingCombo::setEmbeddingMode(PDFOptions::PDFFontEmbedding mode) 45 { 46 if ((mode == PDFOptions::DontEmbed) && !m_allowNoFontEmbedding) 47 return; 48 49 if (mode == PDFOptions::EmbedFonts) 50 setCurrentIndex(0); 51 else if (mode == PDFOptions::OutlineFonts) 52 setCurrentIndex(1); 53 else if (mode == PDFOptions::DontEmbed) 54 setCurrentIndex(2); 55 } 56 setNoEmbeddingEnabled(bool enabled)57void FontEmbeddingCombo::setNoEmbeddingEnabled(bool enabled) 58 { 59 if (m_allowNoFontEmbedding == enabled) 60 return; 61 m_allowNoFontEmbedding = enabled; 62 63 PDFOptions::PDFFontEmbedding oldMode = embeddingMode(); 64 if ((oldMode == PDFOptions::DontEmbed) && !enabled) 65 setCurrentIndex(0); 66 m_fontEmbeddingModel->setNoFontEmbeddingEnabled(enabled); 67 } 68