Debian Codegraph @

src/Gui/PreferencePages/DlgSettingsPDF.cpp

raw
1
2 #include <App/Application.h>
3 #include <Base/Console.h>
4
5 #include "DlgSettingsPDF.h"
6 #include "ui_DlgSettingsPDF.h"
7
8
9 using namespace Gui::Dialog;
10
11 /* TRANSLATOR Gui::Dialog::DlgSettingsPDF */
12
13 DlgSettingsPDF::DlgSettingsPDF(QWidget* parent)
14 : PreferencePage(parent)
15 , ui(new Ui_DlgSettingsPDF)
16 {
17 ui->setupUi(this);
18 ui->warningLabel->setWordWrap(true);
19 connect(
20 ui->comboBox,
21 QOverload<int>::of(&QComboBox::currentIndexChanged),
22 this,
23 &DlgSettingsPDF::onComboBoxIndexChanged
24 );
25 }
26
27 DlgSettingsPDF::~DlgSettingsPDF() = default;
28
29 void DlgSettingsPDF::saveSettings()
30 {
31 ui->comboBox->onSave();
32 }
33
34 void DlgSettingsPDF::loadSettings()
35 {
36 ui->comboBox->onRestore();
37 int currentIndex = ui->comboBox->currentIndex();
38 #if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
39 if (currentIndex == 3) {
40 Base::Console().warning(
41 "When using another copy of FreeCAD you had set the PDF version to X4, but this build "
42 "of FreeCAD does not support it. Using 1.4 instead.\n"
43 );
44 currentIndex = 0;
45 ui->comboBox->setCurrentIndex(0);
46 }
47 ui->comboBox->removeItem(3); // PdfVersion_X4
48 #endif
49 onComboBoxIndexChanged(currentIndex);
50 }
51
52 QPagedPaintDevice::PdfVersion DlgSettingsPDF::evaluatePDFVersion()
53 {
54 auto hGrp = App::GetApplication()
55 .GetUserParameter()
56 .GetGroup("BaseApp")
57 ->GetGroup("Preferences")
58 ->GetGroup("Mod");
59
60 const int ver = hGrp->GetInt("PDFVersion");
61
62 switch (ver) {
63 case 1:
64 return QPagedPaintDevice::PdfVersion_A1b;
65 case 2:
66 return QPagedPaintDevice::PdfVersion_1_6;
67 #if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
68 case 3:
69 return QPagedPaintDevice::PdfVersion_X4;
70 #endif
71 default:
72 return QPagedPaintDevice::PdfVersion_1_4;
73 }
74 }
75
76 void DlgSettingsPDF::onComboBoxIndexChanged(int index)
77 {
78 switch (index) {
79 case 1:
80 ui->warningLabel->setText(
81 tr("This archival PDF format does not support transparency or layers. All content "
82 "must be self-contained and static.")
83 );
84 break;
85 case 2:
86 ui->warningLabel->setText(
87 tr("While this version supports more modern features, older PDF readers may not "
88 "fully handle it.")
89 );
90 break;
91 case 3:
92 ui->warningLabel->setText(
93 tr("This PDF format is intended for professional printing and requires all fonts "
94 "to be embedded; some interactive features may not be supported.")
95 );
96 break;
97 default:
98 ui->warningLabel->setText(
99 tr("This PDF version has limited support for modern features like embedded "
100 "multimedia and advanced transparency effects.")
101 );
102 break;
103 }
104 }
105
106 void DlgSettingsPDF::changeEvent(QEvent* e)
107 {
108 if (e->type() == QEvent::LanguageChange) {
109 ui->retranslateUi(this);
110 }
111
112 QWidget::changeEvent(e);
113 }
114
115 #include "moc_DlgSettingsPDF.cpp"