Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 948747
Collapse All | Expand All

(-)a/app/app.pri (+1 lines)
Lines 5-10 VERSION = $${APPVERSION} Link Here
5
LANGUAGE = C++
5
LANGUAGE = C++
6
CONFIG += qt warn_on thread
6
CONFIG += qt warn_on thread
7
QT += core gui widgets
7
QT += core gui widgets
8
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat
8
9
9
DEFINES += QT_STL QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_BYTEARRAY QT_STRICT_ITERATORS QT_NO_URL_CAST_FROM_STRING QT_NO_KEYWORDS
10
DEFINES += QT_STL QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_BYTEARRAY QT_STRICT_ITERATORS QT_NO_URL_CAST_FROM_STRING QT_NO_KEYWORDS
10
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050200
11
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050200
(-)a/app/configeditorwidget.cpp (-1 / +1 lines)
Lines 22-28 Link Here
22
#include "configeditorwidget.h"
22
#include "configeditorwidget.h"
23
23
24
#include <QtCore/QSettings>
24
#include <QtCore/QSettings>
25
#include <QTextCodec>
25
#include <QtCore5Compat/QTextCodec>
26
#include <QtWidgets/QApplication>
26
#include <QtWidgets/QApplication>
27
27
28
#include "../common/utils/fontdialog.h"
28
#include "../common/utils/fontdialog.h"
(-)a/app/editreplacecurrentwidget.cpp (-1 / +1 lines)
Lines 43-49 ReplaceCurrentWidget::ReplaceCurrentWidget(QWidget *parent) : QWidget(parent) Link Here
43
    buttonsLayout->addWidget(dontReplaceButton);
43
    buttonsLayout->addWidget(dontReplaceButton);
44
    buttonsLayout->addWidget(cancelButton);
44
    buttonsLayout->addWidget(cancelButton);
45
    buttonsLayout->addStretch();
45
    buttonsLayout->addStretch();
46
    buttonsLayout->setMargin(0);
46
    buttonsLayout->setContentsMargins(0, 0, 0, 0);
47
    buttonsWidget->setLayout(buttonsLayout);
47
    buttonsWidget->setLayout(buttonsLayout);
48
    mainLayout->addWidget(m_replaceLabel);
48
    mainLayout->addWidget(m_replaceLabel);
49
    mainLayout->addWidget(buttonsWidget);
49
    mainLayout->addWidget(buttonsWidget);
(-)a/app/linenumberwidget.cpp (-2 / +2 lines)
Lines 99-106 void LineNumberWidget::paintEvent(QPaintEvent *event) Link Here
99
void LineNumberWidget::mousePressEvent(QMouseEvent *event)
99
void LineNumberWidget::mousePressEvent(QMouseEvent *event)
100
{
100
{
101
    event->accept();
101
    event->accept();
102
    const QPoint p = m_editor->viewport()->mapFromGlobal(event->globalPos());
102
    const QPointF p = m_editor->viewport()->mapFromGlobal(event->globalPosition());
103
    const int lineNumber = m_editor->cursorForPosition(p).blockNumber() + 1;
103
    const int lineNumber = m_editor->cursorForPosition(p.toPoint()).blockNumber() + 1;
104
    if (lineNumber <= 0)
104
    if (lineNumber <= 0)
105
        return;
105
        return;
106
106
(-)a/app/loghighlighter.cpp (-11 / +9 lines)
Lines 38-44 LogHighlighter::LogHighlighter(QTextDocument *parent) : QSyntaxHighlighter(paren Link Here
38
                                                        // TikzPreviewGenerator::getParsedLogText()
38
                                                        // TikzPreviewGenerator::getParsedLogText()
39
            << tr("This program will not work!");
39
            << tr("This program will not work!");
40
    for (const auto &pattern : keywordPatterns) {
40
    for (const auto &pattern : keywordPatterns) {
41
        rule.pattern = QRegExp(pattern);
41
        rule.pattern = QRegularExpression(pattern);
42
        rule.format = keywordFormat;
42
        rule.format = keywordFormat;
43
        m_highlightingRules.append(rule);
43
        m_highlightingRules.append(rule);
44
    }
44
    }
Lines 46-52 LogHighlighter::LogHighlighter(QTextDocument *parent) : QSyntaxHighlighter(paren Link Here
46
    QTextCharFormat commandFormat;
46
    QTextCharFormat commandFormat;
47
    commandFormat.setForeground(Qt::darkBlue);
47
    commandFormat.setForeground(Qt::darkBlue);
48
    commandFormat.setFontWeight(QFont::Bold);
48
    commandFormat.setFontWeight(QFont::Bold);
49
    rule.pattern = QRegExp(QLatin1String("^\\[[^\\]\\d][^\\]]*\\]"));
49
    rule.pattern = QRegularExpression(QLatin1String("^\\[[^\\]\\d][^\\]]*\\]"));
50
    rule.format = commandFormat;
50
    rule.format = commandFormat;
51
    m_highlightingRules.append(rule);
51
    m_highlightingRules.append(rule);
52
52
Lines 61-75 void LogHighlighter::highlightBlock(const QString &text) Link Here
61
{
61
{
62
    // Try each highlighting pattern and apply formatting if it matches
62
    // Try each highlighting pattern and apply formatting if it matches
63
    for (const auto &rule : m_highlightingRules) {
63
    for (const auto &rule : m_highlightingRules) {
64
        // const QRegExp expression(rule.pattern);
64
        QRegularExpression expression(rule.pattern);
65
        // int index = text.indexOf(expression);
65
        QRegularExpressionMatch match = expression.match(text);
66
        QRegExp expression(rule.pattern);
66
        while (match.hasMatch())
67
        int index = expression.indexIn(text);
67
        {
68
        while (index >= 0) {
68
            const int length = match.capturedLength();
69
            const int length = expression.matchedLength();
69
            setFormat(match.capturedStart(), length, rule.format);
70
            setFormat(index, length, rule.format);
70
            match = expression.match(text, match.capturedEnd() + 1);
71
            // index = text.indexOf(expression, index + length);
72
            index = expression.indexIn(text, index + length);
73
        }
71
        }
74
    }
72
    }
75
73
(-)a/app/loghighlighter.h (-1 / +2 lines)
Lines 23-28 Link Here
23
23
24
#include <QtGui/QSyntaxHighlighter>
24
#include <QtGui/QSyntaxHighlighter>
25
#include <QtGui/QTextCharFormat>
25
#include <QtGui/QTextCharFormat>
26
#include <QRegularExpression>
26
27
27
/** A simple, incomplete highlighter for LaTeX .log files
28
/** A simple, incomplete highlighter for LaTeX .log files
28
 * @author Florian Hackenberger <florian@hackenberger.at>
29
 * @author Florian Hackenberger <florian@hackenberger.at>
Lines 44-50 protected: Link Here
44
private:
45
private:
45
    struct LogHighlightingRule
46
    struct LogHighlightingRule
46
    {
47
    {
47
        QRegExp pattern; /// The pattern to match for formatting
48
        QRegularExpression pattern; /// The pattern to match for formatting
48
        QTextCharFormat format; /// The style of the formatting
49
        QTextCharFormat format; /// The style of the formatting
49
    };
50
    };
50
    /// All highlighting rules with their formatting for easy iteration
51
    /// All highlighting rules with their formatting for easy iteration
(-)a/app/mainwindow.cpp (-19 / +34 lines)
Lines 38-44 Link Here
38
#include <QMenuBar>
38
#include <QMenuBar>
39
#include <QScreen>
39
#include <QScreen>
40
#include <QStatusBar>
40
#include <QStatusBar>
41
#include <QtCore/QTextCodec>
41
#include <QtCore5Compat/QTextCodec>
42
#include <QtCore/QProcess>
42
#include <QtCore/QProcess>
43
#include <QtCore/QSettings>
43
#include <QtCore/QSettings>
44
#include <QtCore/QTextStream>
44
#include <QtCore/QTextStream>
Lines 82-88 Link Here
82
82
83
QList<MainWindow *> MainWindow::s_mainWindowList;
83
QList<MainWindow *> MainWindow::s_mainWindowList;
84
84
85
MainWindow::MainWindow()
85
MainWindow::MainWindow() : m_doOverrideEncoder(false), m_doOverrideDecoder(false)
86
{
86
{
87
// QTime t = QTime::currentTime();
87
// QTime t = QTime::currentTime();
88
#ifndef KTIKZ_USE_KDE
88
#ifndef KTIKZ_USE_KDE
Lines 140-146 MainWindow::MainWindow() Link Here
140
    QWidget *mainWidget = new QWidget(this);
140
    QWidget *mainWidget = new QWidget(this);
141
    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
141
    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
142
    mainLayout->setSpacing(0);
142
    mainLayout->setSpacing(0);
143
    mainLayout->setMargin(0);
143
    mainLayout->setContentsMargins(0, 0, 0, 0);
144
    mainLayout->addWidget(m_tikzPreviewController->templateWidget());
144
    mainLayout->addWidget(m_tikzPreviewController->templateWidget());
145
    mainLayout->addWidget(m_tikzEditorView);
145
    mainLayout->addWidget(m_tikzEditorView);
146
146
Lines 933-944 void MainWindow::applySettings() Link Here
933
    updateCompleter();
933
    updateCompleter();
934
    settings.beginGroup(QLatin1String("encoding"));
934
    settings.beginGroup(QLatin1String("encoding"));
935
    QVariant qv = settings.value(QLatin1String("default"));
935
    QVariant qv = settings.value(QLatin1String("default"));
936
    setCurrentEncoding(qv.isNull() ? QTextCodec::codecForLocale()
936
    if (qv.isNull())
937
                                   : QTextCodec::codecForName(qv.toByteArray()));
937
    {
938
        setCurrentEncoding( QStringConverter::System ) ;
939
    } else {
940
        std::optional<QStringConverter::Encoding> currentEncoding = QStringConverter::encodingForName(qv.toString().toStdString().c_str());
941
        setCurrentEncoding( currentEncoding.value_or( QStringConverter::System ) ) ;
942
    }
943
938
    qv = settings.value(QLatin1String("encoder"));
944
    qv = settings.value(QLatin1String("encoder"));
939
    m_overrideEncoder = qv.isNull() ? NULL : QTextCodec::codecForName(qv.toByteArray());
945
    if (qv.isNull())
946
    {
947
        m_doOverrideEncoder = false;
948
    } else {
949
        std::optional<QStringConverter::Encoding> overrideEncoding = QStringConverter::encodingForName(qv.toString().toStdString().c_str());
950
        m_doOverrideEncoder = overrideEncoding.has_value();
951
        m_overrideEncoder = overrideEncoding.value_or( QStringConverter::System ) ;
952
    }
940
    qv = settings.value(QLatin1String("decoder"));
953
    qv = settings.value(QLatin1String("decoder"));
941
    m_overrideDecoder = qv.isNull() ? NULL : QTextCodec::codecForName(qv.toByteArray());
954
    if (qv.isNull())
955
    {
956
        m_doOverrideDecoder = false;
957
    } else {
958
        std::optional<QStringConverter::Encoding> overrideDecoding = QStringConverter::encodingForName(qv.toString().toStdString().c_str());
959
        m_doOverrideDecoder = overrideDecoding.has_value();
960
        m_overrideDecoder = overrideDecoding.value_or( QStringConverter::System ) ;
961
    }
942
    m_encoderBom = settings.value(QLatin1String("bom"), true).toBool();
962
    m_encoderBom = settings.value(QLatin1String("bom"), true).toBool();
943
    settings.endGroup();
963
    settings.endGroup();
944
964
Lines 1069-1075 void MainWindow::loadUrl(const QUrl &url) Link Here
1069
        QApplication::setOverrideCursor(Qt::WaitCursor);
1089
        QApplication::setOverrideCursor(Qt::WaitCursor);
1070
        this->configureStreamDecoding(in);
1090
        this->configureStreamDecoding(in);
1071
        m_tikzQtEditorView->editor()->setPlainText(in.readAll());
1091
        m_tikzQtEditorView->editor()->setPlainText(in.readAll());
1072
        setCurrentEncoding(in.codec());
1092
        setCurrentEncoding(in.encoding());
1073
    }
1093
    }
1074
1094
1075
    QApplication::restoreOverrideCursor();
1095
    QApplication::restoreOverrideCursor();
Lines 1131-1137 bool MainWindow::saveUrl(const QUrl &url) Link Here
1131
    return true;
1151
    return true;
1132
}
1152
}
1133
1153
1134
void MainWindow::setCurrentEncoding(QTextCodec *codec)
1154
void MainWindow::setCurrentEncoding(QStringConverter::Encoding codec )
1135
{
1155
{
1136
    m_currentEncoding = codec;
1156
    m_currentEncoding = codec;
1137
    // TODO: implement user warning and suggestion to reload the file.
1157
    // TODO: implement user warning and suggestion to reload the file.
Lines 1160-1186 QString MainWindow::strippedName(const QUrl &url) const Link Here
1160
    return (fileName.isEmpty()) ? QLatin1String("untitled.txt") : fileName;
1180
    return (fileName.isEmpty()) ? QLatin1String("untitled.txt") : fileName;
1161
}
1181
}
1162
1182
1163
QTextCodec *MainWindow::getEncoder() const
1183
QStringConverter::Encoding MainWindow::getEncoder() const
1164
{
1184
{
1165
    return this->m_overrideEncoder ? this->m_overrideEncoder : this->m_currentEncoding;
1185
    return this->m_doOverrideEncoder ? this->m_overrideEncoder : this->m_currentEncoding;
1166
}
1186
}
1167
1187
1168
void MainWindow::configureStreamEncoding(QTextStream &textStream)
1188
void MainWindow::configureStreamEncoding(QTextStream &textStream)
1169
{
1189
{
1170
    QTextCodec *encoder = this->getEncoder();
1190
    textStream.setEncoding(this->getEncoder());
1171
    if (Q_LIKELY(encoder)) // should be true
1172
        textStream.setCodec(encoder);
1173
    else
1174
        qWarning("The encoder variable should not be null.");
1175
1191
1176
    textStream.setGenerateByteOrderMark(this->m_encoderBom);
1192
    textStream.setGenerateByteOrderMark(this->m_encoderBom);
1177
}
1193
}
1178
1194
1179
void MainWindow::configureStreamDecoding(QTextStream &textStream)
1195
void MainWindow::configureStreamDecoding(QTextStream &textStream)
1180
{
1196
{
1181
    if (m_overrideDecoder) {
1197
    if(m_doOverrideDecoder)
1182
        textStream.setCodec(m_overrideDecoder);
1198
        textStream.setEncoding(m_overrideDecoder);
1183
    }
1184
    textStream.setAutoDetectUnicode(true);
1199
    textStream.setAutoDetectUnicode(true);
1185
}
1200
}
1186
1201
(-)a/app/mainwindow.h (-7 / +10 lines)
Lines 43-48 class QDockWidget; Link Here
43
class QLabel;
43
class QLabel;
44
class QMenu;
44
class QMenu;
45
class QToolButton;
45
class QToolButton;
46
class QTextCodec;
46
47
47
class Action;
48
class Action;
48
class ConfigDialog;
49
class ConfigDialog;
Lines 134-140 private Q_SLOTS: Link Here
134
    /// Change the codec for the current document
135
    /// Change the codec for the current document
135
    /// @param isUserRequest set to true if the user requested the changement (in this case, the
136
    /// @param isUserRequest set to true if the user requested the changement (in this case, the
136
    /// application should warn the user -- not implemented yet.).
137
    /// application should warn the user -- not implemented yet.).
137
    void setCurrentEncoding(QTextCodec *codec /*, bool isUserRequest = false */);
138
    void setCurrentEncoding(QStringConverter::Encoding codec );
138
139
139
private:
140
private:
140
    void createActions();
141
    void createActions();
Lines 225-239 private: Link Here
225
    QPointer<ConfigDialog> m_configDialog;
226
    QPointer<ConfigDialog> m_configDialog;
226
227
227
    QUrl m_currentUrl;
228
    QUrl m_currentUrl;
228
    QTextCodec *m_currentEncoding;
229
    QStringConverter::Encoding m_currentEncoding;
229
    /// If not null, override the encoder (rather than @ref m_currentEncoding)
230
    /// If true, override the encoder (rather than @ref m_currentEncoding)
230
    QTextCodec *m_overrideEncoder;
231
    bool m_doOverrideEncoder;
231
    /// If not null, override the decoder
232
    QStringConverter::Encoding m_overrideEncoder;
232
    QTextCodec *m_overrideDecoder;
233
    /// If true, override the decoder
234
    bool m_doOverrideDecoder;
235
    QStringConverter::Encoding m_overrideDecoder;
233
    /// True if a BOM must be added to the PGF-file
236
    /// True if a BOM must be added to the PGF-file
234
    bool m_encoderBom;
237
    bool m_encoderBom;
235
    /// Return the current encoder (m_currentEncoding or another if encoder is overriden).
238
    /// Return the current encoder (m_currentEncoding or another if encoder is overriden).
236
    /*virtual*/ QTextCodec *getEncoder() const;
239
    /*virtual*/ QStringConverter::Encoding getEncoder() const;
237
240
238
    QUrl m_lastUrl;
241
    QUrl m_lastUrl;
239
    QDateTime m_lastInternalModifiedDateTime;
242
    QDateTime m_lastInternalModifiedDateTime;
(-)a/app/tikzcommandinserter.cpp (-5 / +5 lines)
Lines 46-52 Link Here
46
#include "tikzcommandwidget.h"
46
#include "tikzcommandwidget.h"
47
#include "../common/utils/combobox.h"
47
#include "../common/utils/combobox.h"
48
48
49
static const QString s_completionPlaceHolder(0x2022);
49
static const QString s_completionPlaceHolder(QChar(0x2022));
50
50
51
TikzCommandList TikzCommandInserter::m_tikzSections;
51
TikzCommandList TikzCommandInserter::m_tikzSections;
52
QList<TikzCommand> TikzCommandInserter::m_tikzCommandsList;
52
QList<TikzCommand> TikzCommandInserter::m_tikzCommandsList;
Lines 90-99 static TikzCommand newCommand(const QString &name, const QString &description, Link Here
90
static QString translateOptions(const QString &text)
90
static QString translateOptions(const QString &text)
91
{
91
{
92
    QString translatedText;
92
    QString translatedText;
93
    for (int pos = 0, oldPos = 0; pos >= 0;) {
93
    for (qsizetype pos = 0, oldPos = 0; pos >= 0;) {
94
        oldPos = pos;
94
        oldPos = pos;
95
        pos = text.indexOf(QLatin1Char('<'), pos); // option is between < and >
95
        pos = text.indexOf(QLatin1Char('<'), pos); // option is between < and >
96
        translatedText += text.midRef(
96
        translatedText += text.mid(
97
                oldPos, pos - oldPos + 1); // add text between the current option and the previous
97
                oldPos, pos - oldPos + 1); // add text between the current option and the previous
98
                                           // option; this also adds the end of the original string,
98
                                           // option; this also adds the end of the original string,
99
                                           // except when there are no options
99
                                           // except when there are no options
Lines 574-580 QDockWidget *TikzCommandInserter::getDockWidget(QWidget *parent) Link Here
574
    tikzLayout->addWidget(commandsComboLabel, 0, 0);
574
    tikzLayout->addWidget(commandsComboLabel, 0, 0);
575
    tikzLayout->addWidget(m_commandsCombo, 0, 1);
575
    tikzLayout->addWidget(m_commandsCombo, 0, 1);
576
    tikzLayout->addWidget(m_commandsStack, 1, 0, 1, 2);
576
    tikzLayout->addWidget(m_commandsStack, 1, 0, 1, 2);
577
    tikzLayout->setMargin(5);
577
    tikzLayout->setContentsMargins(5, 5, 5, 5);
578
578
579
    TikzCommandWidget *tikzWidget = new TikzCommandWidget;
579
    TikzCommandWidget *tikzWidget = new TikzCommandWidget;
580
    tikzWidget->setLayout(tikzLayout);
580
    tikzWidget->setLayout(tikzLayout);
Lines 801-807 void TikzCommandInserter::insertTag(const QString &tag, int dx, int dy) Link Here
801
801
802
        // replace all options (between <...>) by a place holder
802
        // replace all options (between <...>) by a place holder
803
        QString insertWord = tag;
803
        QString insertWord = tag;
804
        const QRegExp rx(QLatin1String("<[^<>]*>"));
804
        const QRegularExpression rx(QLatin1String("<[^<>]*>"));
805
        insertWord.replace(rx, s_completionPlaceHolder);
805
        insertWord.replace(rx, s_completionPlaceHolder);
806
806
807
        QTextCursor cur = m_mainEdit->textCursor();
807
        QTextCursor cur = m_mainEdit->textCursor();
(-)a/app/tikzeditor.cpp (-3 / +3 lines)
Lines 50-56 Link Here
50
50
51
#include "linenumberwidget.h"
51
#include "linenumberwidget.h"
52
52
53
static const QString s_completionPlaceHolder(0x2022);
53
static const QString s_completionPlaceHolder(QChar(0x2022));
54
54
55
TikzEditor::TikzEditor(QWidget *parent)
55
TikzEditor::TikzEditor(QWidget *parent)
56
    : QPlainTextEdit(parent),
56
    : QPlainTextEdit(parent),
Lines 619-626 void TikzEditor::insertCompletion(const QString &completion) Link Here
619
619
620
    // remove all options (between <...>) and put cursor at the first option
620
    // remove all options (between <...>) and put cursor at the first option
621
    QString insertWord = completion.right(extra);
621
    QString insertWord = completion.right(extra);
622
    const QRegExp rx(QLatin1String("<[^<>]*>"));
622
    const QRegularExpression rx(QLatin1String("<[^<>]*>"));
623
    const int offset = rx.indexIn(insertWord) - 1; // put cursor at the first option
623
    const int offset = insertWord.indexOf(rx) - 1; // put cursor at the first option
624
    insertWord.replace(rx, s_completionPlaceHolder);
624
    insertWord.replace(rx, s_completionPlaceHolder);
625
625
626
    cursor.insertText(insertWord);
626
    cursor.insertText(insertWord);
(-)a/app/tikzeditorhighlighter.h (+1 lines)
Lines 22-27 Link Here
22
#define TIKZEDITORHIGHLIGHTER_H
22
#define TIKZEDITORHIGHLIGHTER_H
23
23
24
#include <QtGui/QSyntaxHighlighter>
24
#include <QtGui/QSyntaxHighlighter>
25
#include <QtCore5Compat/QRegExp>
25
26
26
struct HighlightingRule
27
struct HighlightingRule
27
{
28
{
(-)a/app/tikzeditorview.cpp (-1 / +1 lines)
Lines 59-65 TikzEditorView::TikzEditorView(QWidget *parent) Link Here
59
59
60
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
60
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
61
    mainLayout->setSpacing(0);
61
    mainLayout->setSpacing(0);
62
    mainLayout->setMargin(0);
62
    mainLayout->setContentsMargins(0, 0, 0, 0);
63
    mainLayout->addWidget(m_tikzEditor);
63
    mainLayout->addWidget(m_tikzEditor);
64
64
65
    createActions();
65
    createActions();
(-)a/app/usercommandeditdialog.cpp (-1 / +1 lines)
Lines 20-26 Link Here
20
20
21
#include <QtCore/QSettings>
21
#include <QtCore/QSettings>
22
22
23
static const QString s_completionPlaceHolder(0x2022);
23
static const QString s_completionPlaceHolder(QChar(0x2022));
24
24
25
UserCommandEditDialog::UserCommandEditDialog(QWidget *parent) : QDialog(parent), m_oldIndex(-1)
25
UserCommandEditDialog::UserCommandEditDialog(QWidget *parent) : QDialog(parent), m_oldIndex(-1)
26
{
26
{
(-)a/app/usercommandinserter.cpp (-1 / +1 lines)
Lines 25-31 Link Here
25
#include "tikzcommandinserter.h"
25
#include "tikzcommandinserter.h"
26
#include "usercommandeditdialog.h"
26
#include "usercommandeditdialog.h"
27
27
28
static const QString s_completionPlaceHolder(0x2022);
28
static const QString s_completionPlaceHolder(QChar(0x2022));
29
29
30
UserCommandInserter::UserCommandInserter(QWidget *parent) : QObject(parent), m_userMenu(0)
30
UserCommandInserter::UserCommandInserter(QWidget *parent) : QObject(parent), m_userMenu(0)
31
{
31
{
(-)a/common/common.pri (+1 lines)
Lines 1-4 Link Here
1
QT *= widgets printsupport
1
QT *= widgets printsupport
2
greaterThan(QT_MAJOR_VERSION, 6): QT *= core5compat
2
3
3
include($${_PRO_FILE_PWD_}/qmake/findpoppler.pri)
4
include($${_PRO_FILE_PWD_}/qmake/findpoppler.pri)
4
5
(-)a/common/tikzpreview.cpp (-4 / +2 lines)
Lines 18-28 Link Here
18
18
19
#include "tikzpreview.h"
19
#include "tikzpreview.h"
20
20
21
#include <poppler-qt5.h>
21
#include <poppler-qt6.h>
22
22
23
#include <QSettings>
23
#include <QSettings>
24
#include <QApplication>
24
#include <QApplication>
25
#include <QDesktopWidget>
26
#include <QGraphicsProxyWidget>
25
#include <QGraphicsProxyWidget>
27
#include <QMenu>
26
#include <QMenu>
28
#include <QScreen>
27
#include <QScreen>
Lines 316-328 void TikzPreview::pixmapUpdated(Poppler::Document *tikzPdfDoc, const QList<qreal Link Here
316
315
317
QImage TikzPreview::renderToImage(double xres, double yres, int pageNumber)
316
QImage TikzPreview::renderToImage(double xres, double yres, int pageNumber)
318
{
317
{
319
    Poppler::Page *page = m_tikzPdfDoc->page(pageNumber);
318
    auto page = m_tikzPdfDoc->page(pageNumber);
320
    //	const QSizeF pageSize = page->pageSizeF();
319
    //	const QSizeF pageSize = page->pageSizeF();
321
    //	const QImage image = pageSize.height() >= pageSize.width()
320
    //	const QImage image = pageSize.height() >= pageSize.width()
322
    //		? page->renderToImage(xres, yres)
321
    //		? page->renderToImage(xres, yres)
323
    //		: page->renderToImage(xres, yres, -1, -1, -1, -1, Poppler::Page::Rotate270); // slow
322
    //		: page->renderToImage(xres, yres, -1, -1, -1, -1, Poppler::Page::Rotate270); // slow
324
    const QImage image = page->renderToImage(xres, yres); // slow
323
    const QImage image = page->renderToImage(xres, yres); // slow
325
    delete page;
326
    return image;
324
    return image;
327
}
325
}
328
326
(-)a/common/tikzpreviewcontroller.cpp (-1 / +1 lines)
Lines 33-39 Link Here
33
#include <QtWidgets/QMenu>
33
#include <QtWidgets/QMenu>
34
#include <QtWidgets/QPushButton>
34
#include <QtWidgets/QPushButton>
35
35
36
#include <poppler-qt5.h>
36
#include <poppler-qt6.h>
37
37
38
#include "templatewidget.h"
38
#include "templatewidget.h"
39
#include "tikzpreview.h"
39
#include "tikzpreview.h"
(-)a/common/tikzpreviewgenerator.cpp (-2 / +3 lines)
Lines 32-38 Link Here
32
#include <QtGui/QPixmap>
32
#include <QtGui/QPixmap>
33
#include <QtCore/QStandardPaths>
33
#include <QtCore/QStandardPaths>
34
#include <QtWidgets/QPlainTextEdit>
34
#include <QtWidgets/QPlainTextEdit>
35
#include <poppler-qt5.h>
35
#include <QtCore5Compat/QRegExp>
36
#include <poppler-qt6.h>
36
37
37
#include "tikzpreviewcontroller.h"
38
#include "tikzpreviewcontroller.h"
38
#include "mainwidget.h"
39
#include "mainwidget.h"
Lines 306-312 void TikzPreviewGenerator::createPreview() Link Here
306
            // Update widget
307
            // Update widget
307
            if (m_tikzPdfDoc)
308
            if (m_tikzPdfDoc)
308
                delete m_tikzPdfDoc;
309
                delete m_tikzPdfDoc;
309
            m_tikzPdfDoc = Poppler::Document::load(tikzPdfFileInfo.absoluteFilePath());
310
            m_tikzPdfDoc = Poppler::Document::load(tikzPdfFileInfo.absoluteFilePath()).release();
310
            if (m_tikzPdfDoc) {
311
            if (m_tikzPdfDoc) {
311
                m_shortLogText = QLatin1String("[LaTeX] ")
312
                m_shortLogText = QLatin1String("[LaTeX] ")
312
                        + tr("Process finished successfully.", "info process");
313
                        + tr("Process finished successfully.", "info process");
(-)a/common/tikzpreviewmessagewidget.cpp (-1 / +1 lines)
Lines 55-61 TikzPreviewMessageWidget::TikzPreviewMessageWidget(QWidget *parent) : QFrame(par Link Here
55
                                        "}")));
55
                                        "}")));
56
56
57
    QHBoxLayout *infoLayout = new QHBoxLayout(this);
57
    QHBoxLayout *infoLayout = new QHBoxLayout(this);
58
    infoLayout->setMargin(10);
58
    infoLayout->setContentsMargins(10, 10 ,10, 10);
59
    infoLayout->addWidget(m_infoPixmapLabel);
59
    infoLayout->addWidget(m_infoPixmapLabel);
60
    infoLayout->addWidget(m_infoLabel);
60
    infoLayout->addWidget(m_infoLabel);
61
61
(-)a/common/tikzpreviewrenderer.cpp (-3 / +2 lines)
Lines 19-25 Link Here
19
#include "tikzpreviewrenderer.h"
19
#include "tikzpreviewrenderer.h"
20
20
21
#include <QtGui/QImage>
21
#include <QtGui/QImage>
22
#include <poppler-qt5.h>
22
#include <poppler-qt6.h>
23
23
24
TikzPreviewRenderer::TikzPreviewRenderer()
24
TikzPreviewRenderer::TikzPreviewRenderer()
25
{
25
{
Lines 38-46 TikzPreviewRenderer::~TikzPreviewRenderer() Link Here
38
void TikzPreviewRenderer::generatePreview(Poppler::Document *tikzPdfDoc, qreal zoomFactor,
38
void TikzPreviewRenderer::generatePreview(Poppler::Document *tikzPdfDoc, qreal zoomFactor,
39
                                          int currentPage)
39
                                          int currentPage)
40
{
40
{
41
    Poppler::Page *pdfPage = tikzPdfDoc->page(currentPage);
41
    auto pdfPage = tikzPdfDoc->page(currentPage);
42
    const QImage tikzImage = pdfPage->renderToImage(zoomFactor * 72, zoomFactor * 72);
42
    const QImage tikzImage = pdfPage->renderToImage(zoomFactor * 72, zoomFactor * 72);
43
    delete pdfPage;
44
43
45
    Q_EMIT showPreview(tikzImage, zoomFactor);
44
    Q_EMIT showPreview(tikzImage, zoomFactor);
46
}
45
}
(-)a/common/utils/pagedialog.cpp (-1 / +1 lines)
Lines 101-107 QWidget *PageDialog::centerWidget() Link Here
101
    m_pagesTitleLabel->setStyleSheet(QLatin1String("QLabel { font-weight: bold; }"));
101
    m_pagesTitleLabel->setStyleSheet(QLatin1String("QLabel { font-weight: bold; }"));
102
    QGridLayout *titleLayout = new QGridLayout(titleFrame);
102
    QGridLayout *titleLayout = new QGridLayout(titleFrame);
103
    titleLayout->setColumnStretch(0, 1);
103
    titleLayout->setColumnStretch(0, 1);
104
    titleLayout->setMargin(6);
104
    titleLayout->setContentsMargins(6, 6, 6, 6);
105
    titleLayout->addWidget(m_pagesTitleLabel);
105
    titleLayout->addWidget(m_pagesTitleLabel);
106
106
107
    // add pages
107
    // add pages
(-)a/common/utils/recentfilesaction.cpp (-1 / +1 lines)
Lines 102-108 void RecentFilesAction::openRecentFile() Link Here
102
#  ifdef Q_OS_WIN32
102
#  ifdef Q_OS_WIN32
103
        Q_EMIT urlSelected(Url(action->data().toString()));
103
        Q_EMIT urlSelected(Url(action->data().toString()));
104
#  else
104
#  else
105
        Q_EMIT urlSelected(Url(QLatin1String("file://") + action->data().toString()));
105
        Q_EMIT urlSelected(QUrl(QLatin1String("file://") + action->data().toString()));
106
#  endif
106
#  endif
107
}
107
}
108
108
(-)a/common/utils/recentfilesaction.h (-1 / +1 lines)
Lines 60-66 public: Link Here
60
    void removeUrl(const QUrl &url);
60
    void removeUrl(const QUrl &url);
61
61
62
Q_SIGNALS:
62
Q_SIGNALS:
63
    void urlSelected(const Url &url);
63
    void urlSelected(const QUrl &url);
64
64
65
private Q_SLOTS:
65
private Q_SLOTS:
66
    void openRecentFile();
66
    void openRecentFile();
(-)a/common/utils/standardaction.cpp (-1 / +1 lines)
Lines 308-314 RecentFilesAction *openRecent(const QObject *recvr, const char *slot, QObject *p Link Here
308
    RecentFilesAction *action = new RecentFilesAction(
308
    RecentFilesAction *action = new RecentFilesAction(
309
            Icon(QLatin1String("document-open-recent")),
309
            Icon(QLatin1String("document-open-recent")),
310
            QCoreApplication::translate("StandardAction", "&Open Recent"), parent);
310
            QCoreApplication::translate("StandardAction", "&Open Recent"), parent);
311
    QObject::connect(action, SIGNAL(urlSelected(Url)), recvr, slot);
311
    QObject::connect(action, SIGNAL(urlSelected(QUrl)), recvr, slot);
312
    return action;
312
    return action;
313
}
313
}
314
Action *save(const QObject *recvr, const char *slot, QObject *parent)
314
Action *save(const QObject *recvr, const char *slot, QObject *parent)
(-)a/common/utils/toggleaction.h (-1 / +1 lines)
Lines 36-42 public: Link Here
36
};
36
};
37
#else
37
#else
38
#  include <QtCore/QtGlobal>
38
#  include <QtCore/QtGlobal>
39
#  include <QtWidgets/QAction>
39
#  include <QAction>
40
40
41
class ToggleAction : public QAction
41
class ToggleAction : public QAction
42
{
42
{
(-)a/common/utils/urlcompletion.h (-1 / +1 lines)
Lines 29-35 public: Link Here
29
};
29
};
30
#else
30
#else
31
#  include <QtWidgets/QCompleter>
31
#  include <QtWidgets/QCompleter>
32
#  include <QtWidgets/QFileSystemModel>
32
#  include <QFileSystemModel>
33
33
34
class UrlCompletion : public QCompleter
34
class UrlCompletion : public QCompleter
35
{
35
{
(-)a/common/utils/zoomaction.cpp (-1 / +2 lines)
Lines 18-23 Link Here
18
18
19
#include "zoomaction.h"
19
#include "zoomaction.h"
20
20
21
#include <QRegularExpression>
21
#include "globallocale.h"
22
#include "globallocale.h"
22
#include "icon.h"
23
#include "icon.h"
23
24
Lines 136-142 void ZoomAction::setZoomFactor(const QString &zoomFactorText) Link Here
136
{
137
{
137
    setZoomFactor(GlobalLocale::readNumber(
138
    setZoomFactor(GlobalLocale::readNumber(
138
                          QString(zoomFactorText)
139
                          QString(zoomFactorText)
139
                                  .remove(QRegExp(QString(QLatin1String("[^\\d\\%1]*"))
140
                                  .remove(QRegularExpression(QString(QLatin1String("[^\\d\\%1]*"))
140
                                                          .arg(GlobalLocale::decimalSymbol()))))
141
                                                          .arg(GlobalLocale::decimalSymbol()))))
141
                  / 100.0);
142
                  / 100.0);
142
}
143
}
(-)a/qmake/findpoppler.pri (-3 / +3 lines)
Lines 1-7 Link Here
1
unix: {
1
unix: {
2
	PKG_CONFIG = $$pkgConfigExecutable()
2
	PKG_CONFIG = $$pkgConfigExecutable()
3
    POPPLERINCLUDES = $$system($$PKG_CONFIG --cflags poppler-qt5)
3
    POPPLERINCLUDES = $$system($$PKG_CONFIG --cflags poppler-qt6)
4
    POPPLERLIBS = $$system($$PKG_CONFIG --libs poppler-qt5)
4
    POPPLERLIBS = $$system($$PKG_CONFIG --libs poppler-qt6)
5
	QMAKE_CXXFLAGS += $$POPPLERINCLUDES
5
	QMAKE_CXXFLAGS += $$POPPLERINCLUDES
6
	QMAKE_LFLAGS += $$POPPLERLIBS
6
	QMAKE_LFLAGS += $$POPPLERLIBS
7
}
7
}
Lines 11-14 win32 { Link Here
11
	LIBS += -L$${_PRO_FILE_PWD_}/win32/poppler/
11
	LIBS += -L$${_PRO_FILE_PWD_}/win32/poppler/
12
}
12
}
13
13
14
LIBS += -lpoppler-qt5
14
LIBS += -lpoppler-qt6

Return to bug 948747