File size: 3,199 Bytes
985c397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

#include <App/Application.h>
#include <Base/Console.h>

#include "DlgSettingsPDF.h"
#include "ui_DlgSettingsPDF.h"


using namespace Gui::Dialog;

/* TRANSLATOR Gui::Dialog::DlgSettingsPDF */

DlgSettingsPDF::DlgSettingsPDF(QWidget* parent)
    : PreferencePage(parent)
    , ui(new Ui_DlgSettingsPDF)
{
    ui->setupUi(this);
    ui->warningLabel->setWordWrap(true);
    connect(
        ui->comboBox,
        QOverload<int>::of(&QComboBox::currentIndexChanged),
        this,
        &DlgSettingsPDF::onComboBoxIndexChanged
    );
}

DlgSettingsPDF::~DlgSettingsPDF() = default;

void DlgSettingsPDF::saveSettings()
{
    ui->comboBox->onSave();
}

void DlgSettingsPDF::loadSettings()
{
    ui->comboBox->onRestore();
    int currentIndex = ui->comboBox->currentIndex();
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
    if (currentIndex == 3) {
        Base::Console().warning(
            "When using another copy of FreeCAD you had set the PDF version to X4, but this build "
            "of FreeCAD does not support it. Using 1.4 instead.\n"
        );
        currentIndex = 0;
        ui->comboBox->setCurrentIndex(0);
    }
    ui->comboBox->removeItem(3);  // PdfVersion_X4
#endif
    onComboBoxIndexChanged(currentIndex);
}

QPagedPaintDevice::PdfVersion DlgSettingsPDF::evaluatePDFVersion()
{
    auto hGrp = App::GetApplication()
                    .GetUserParameter()
                    .GetGroup("BaseApp")
                    ->GetGroup("Preferences")
                    ->GetGroup("Mod");

    const int ver = hGrp->GetInt("PDFVersion");

    switch (ver) {
        case 1:
            return QPagedPaintDevice::PdfVersion_A1b;
        case 2:
            return QPagedPaintDevice::PdfVersion_1_6;
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
        case 3:
            return QPagedPaintDevice::PdfVersion_X4;
#endif
        default:
            return QPagedPaintDevice::PdfVersion_1_4;
    }
}

void DlgSettingsPDF::onComboBoxIndexChanged(int index)
{
    switch (index) {
        case 1:
            ui->warningLabel->setText(
                tr("This archival PDF format does not support transparency or layers. All content "
                   "must be self-contained and static.")
            );
            break;
        case 2:
            ui->warningLabel->setText(
                tr("While this version supports more modern features, older PDF readers may not "
                   "fully handle it.")
            );
            break;
        case 3:
            ui->warningLabel->setText(
                tr("This PDF format is intended for professional printing and requires all fonts "
                   "to be embedded; some interactive features may not be supported.")
            );
            break;
        default:
            ui->warningLabel->setText(
                tr("This PDF version has limited support for modern features like embedded "
                   "multimedia and advanced transparency effects.")
            );
            break;
    }
}

void DlgSettingsPDF::changeEvent(QEvent* e)
{
    if (e->type() == QEvent::LanguageChange) {
        ui->retranslateUi(this);
    }

    QWidget::changeEvent(e);
}

#include "moc_DlgSettingsPDF.cpp"