Lines 27-44
Link Here
|
27 |
#include <QComboBox> |
27 |
#include <QComboBox> |
28 |
#include <QDir> |
28 |
#include <QDir> |
29 |
#include <QDockWidget> |
29 |
#include <QDockWidget> |
|
|
30 |
#include <QElapsedTimer> |
30 |
#include <QEvent> |
31 |
#include <QEvent> |
31 |
#include <QFileDialog> |
32 |
#include <QFileDialog> |
32 |
#include <QGroupBox> |
33 |
#include <QGroupBox> |
33 |
#include <QLabel> |
34 |
#include <QLabel> |
34 |
#include <QLineEdit> |
35 |
#include <QLineEdit> |
35 |
#include <QMessageBox> |
36 |
#include <QMessageBox> |
|
|
37 |
#include <QPageLayout> |
36 |
#include <QPainter> |
38 |
#include <QPainter> |
37 |
#include <QPixmapCache> |
39 |
#include <QPixmapCache> |
38 |
#include <QPlainTextEdit> |
40 |
#include <QPlainTextEdit> |
39 |
#include <QPrinter> |
41 |
#include <QPrinter> |
40 |
#include <QPushButton> |
42 |
#include <QPushButton> |
41 |
#include <QRadioButton> |
43 |
#include <QRadioButton> |
|
|
44 |
#include <QRegularExpression> |
42 |
#include <QScrollArea> |
45 |
#include <QScrollArea> |
43 |
#include <QScrollBar> |
46 |
#include <QScrollBar> |
44 |
#include <QSettings> |
47 |
#include <QSettings> |
Lines 1249-1259
PdfDocument MainWindow::getPdf(const QString &filename)
Link Here
|
1249 |
else if (pdf->isLocked()) { |
1252 |
else if (pdf->isLocked()) { |
1250 |
QMessageBox::warning(this, tr("DiffPDF — Error"), |
1253 |
QMessageBox::warning(this, tr("DiffPDF — Error"), |
1251 |
tr("Cannot read a locked PDF ('%1').").arg(filename)); |
1254 |
tr("Cannot read a locked PDF ('%1').").arg(filename)); |
1252 |
#if QT_VERSION >= 0x040600 |
1255 |
return {}; |
1253 |
pdf.clear(); |
|
|
1254 |
#else |
1255 |
pdf.reset(); |
1256 |
#endif |
1257 |
} |
1256 |
} |
1258 |
return pdf; |
1257 |
return pdf; |
1259 |
} |
1258 |
} |
Lines 1319-1325
QList<int> MainWindow::getPageList(int which, PdfDocument pdf)
Link Here
|
1319 |
bool error = false; |
1318 |
bool error = false; |
1320 |
QList<int> pages; |
1319 |
QList<int> pages; |
1321 |
QString page_string = pagesEdit->text(); |
1320 |
QString page_string = pagesEdit->text(); |
1322 |
page_string = page_string.replace(QRegExp("\\s+"), ""); |
1321 |
static QRegularExpression spaces("\\s+"); |
|
|
1322 |
page_string = page_string.replace(spaces, ""); |
1323 |
QStringList page_list = page_string.split(","); |
1323 |
QStringList page_list = page_string.split(","); |
1324 |
bool ok; |
1324 |
bool ok; |
1325 |
foreach (const QString &page, page_list) { |
1325 |
foreach (const QString &page, page_list) { |
Lines 1387-1393
void MainWindow::compare()
Link Here
|
1387 |
} |
1387 |
} |
1388 |
|
1388 |
|
1389 |
comparePrepareUi(); |
1389 |
comparePrepareUi(); |
1390 |
QTime time; |
1390 |
QElapsedTimer time; |
1391 |
time.start(); |
1391 |
time.start(); |
1392 |
const QPair<int, int> pair = comparePages(filename1, pdf1, filename2, |
1392 |
const QPair<int, int> pair = comparePages(filename1, pdf1, filename2, |
1393 |
pdf2); |
1393 |
pdf2); |
Lines 1685-1692
void MainWindow::saveAsPdf(const int start, const int end,
Link Here
|
1685 |
printer.setOutputFormat(QPrinter::PdfFormat); |
1685 |
printer.setOutputFormat(QPrinter::PdfFormat); |
1686 |
printer.setColorMode(QPrinter::Color); |
1686 |
printer.setColorMode(QPrinter::Color); |
1687 |
printer.setCreator(tr("DiffPDF")); |
1687 |
printer.setCreator(tr("DiffPDF")); |
1688 |
printer.setOrientation(savePages == SaveBothPages |
1688 |
printer.setPageOrientation(savePages == SaveBothPages |
1689 |
? QPrinter::Landscape : QPrinter::Portrait); |
1689 |
? QPageLayout::Landscape : QPageLayout::Portrait); |
1690 |
QPainter painter(&printer); |
1690 |
QPainter painter(&printer); |
1691 |
painter.setRenderHints(QPainter::Antialiasing| |
1691 |
painter.setRenderHints(QPainter::Antialiasing| |
1692 |
QPainter::TextAntialiasing|QPainter::SmoothPixmapTransform); |
1692 |
QPainter::TextAntialiasing|QPainter::SmoothPixmapTransform); |
Lines 1802-1808
void MainWindow::showZones()
Link Here
|
1802 |
void MainWindow::showZones(const int Width, const TextBoxList &list, |
1802 |
void MainWindow::showZones(const int Width, const TextBoxList &list, |
1803 |
QLabel *label) |
1803 |
QLabel *label) |
1804 |
{ |
1804 |
{ |
1805 |
if (!label || !label->pixmap() || label->pixmap()->isNull()) |
1805 |
if (!label || label->pixmap().isNull()) |
1806 |
return; |
1806 |
return; |
1807 |
const bool ComparingWords = compareComboBox->currentIndex() == |
1807 |
const bool ComparingWords = compareComboBox->currentIndex() == |
1808 |
CompareWords; |
1808 |
CompareWords; |
Lines 1815-1821
void MainWindow::showZones(const int Width, const TextBoxList &list,
Link Here
|
1815 |
columnsSpinBox->value()); |
1815 |
columnsSpinBox->value()); |
1816 |
const int DPI = static_cast<int>(POINTS_PER_INCH * |
1816 |
const int DPI = static_cast<int>(POINTS_PER_INCH * |
1817 |
(zoomSpinBox->value() / 100.0)); |
1817 |
(zoomSpinBox->value() / 100.0)); |
1818 |
QPixmap pixmap = label->pixmap()->copy(); |
1818 |
QPixmap pixmap = label->pixmap().copy(); |
1819 |
QPainter painter(&pixmap); |
1819 |
QPainter painter(&pixmap); |
1820 |
painter.setPen(Qt::green); |
1820 |
painter.setPen(Qt::green); |
1821 |
for (int i = 0; i < paths.count(); ++i) { |
1821 |
for (int i = 0; i < paths.count(); ++i) { |
Lines 1844-1854
void MainWindow::showMargins()
Link Here
|
1844 |
|
1844 |
|
1845 |
void MainWindow::showMargins(QLabel *label) |
1845 |
void MainWindow::showMargins(QLabel *label) |
1846 |
{ |
1846 |
{ |
1847 |
if (!label || !label->pixmap() || label->pixmap()->isNull()) |
1847 |
if (!label || label->pixmap().isNull()) |
1848 |
return; |
1848 |
return; |
1849 |
const int DPI = static_cast<int>(POINTS_PER_INCH * |
1849 |
const int DPI = static_cast<int>(POINTS_PER_INCH * |
1850 |
(zoomSpinBox->value() / 100.0)); |
1850 |
(zoomSpinBox->value() / 100.0)); |
1851 |
QPixmap pixmap = label->pixmap()->copy(); |
1851 |
QPixmap pixmap = label->pixmap().copy(); |
1852 |
QPainter painter(&pixmap); |
1852 |
QPainter painter(&pixmap); |
1853 |
painter.setPen(Qt::cyan); |
1853 |
painter.setPen(Qt::cyan); |
1854 |
int left = leftMarginSpinBox->value(); |
1854 |
int left = leftMarginSpinBox->value(); |
Lines 1880-1891
void MainWindow::showMargins(QLabel *label)
Link Here
|
1880 |
|
1880 |
|
1881 |
void MainWindow::setAMargin(const QPoint &pos) |
1881 |
void MainWindow::setAMargin(const QPoint &pos) |
1882 |
{ |
1882 |
{ |
1883 |
if (!marginsGroupBox->isChecked() || !page1Label->pixmap() || |
1883 |
if (!marginsGroupBox->isChecked() || page1Label->pixmap().isNull()) |
1884 |
page1Label->pixmap()->isNull()) |
|
|
1885 |
return; |
1884 |
return; |
1886 |
const int DPI = static_cast<int>(POINTS_PER_INCH * |
1885 |
const int DPI = static_cast<int>(POINTS_PER_INCH * |
1887 |
(zoomSpinBox->value() / 100.0)); |
1886 |
(zoomSpinBox->value() / 100.0)); |
1888 |
const QSize &size = page1Label->pixmap()->size(); |
1887 |
const QSize &size = page1Label->pixmap().size(); |
1889 |
int x = pos.x(); |
1888 |
int x = pos.x(); |
1890 |
int y = pos.y(); |
1889 |
int y = pos.y(); |
1891 |
const int HorizontalMiddle = size.width() / 2; |
1890 |
const int HorizontalMiddle = size.width() / 2; |