Skip to content

Commit

Permalink
Working
Browse files Browse the repository at this point in the history
  • Loading branch information
alecn2002 committed May 6, 2022
1 parent a17ff0d commit f2c0bd3
Show file tree
Hide file tree
Showing 34 changed files with 671 additions and 287 deletions.
151 changes: 0 additions & 151 deletions FindPoppler.cmake

This file was deleted.

3 changes: 2 additions & 1 deletion app/app.pri
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LANGUAGE = C++
CONFIG += qt warn_on thread
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
greaterThan(QT_MAJOR_VERSION, 6): QT += core5compat pdf
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat pdf

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
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050200
Expand All @@ -15,6 +15,7 @@ DEFINES += QT_STL QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_BYTE
#QMAKE_CXXFLAGS += -Wall -Wextra -Wpedantic -Weffc++ -Wlogical-op -Wmissing-declarations -Wold-style-cast -Woverloaded-virtual -Wshadow -Wstrict-null-sentinel -Wswitch-default -Wuseless-cast -Wzero-as-null-pointer-constant -fmessage-length=0 -fdiagnostics-show-location=every-line
#QMAKE_CXXFLAGS += -Wall -Wextra -Wpedantic -Wlogical-op -Wmissing-declarations -Wold-style-cast -Woverloaded-virtual
#QMAKE_CXX = clang
QMAKE_CXXFLAGS += -Og -ggdb

DEFINES += ORGNAME=\\\"$${ORGNAME}\\\"
DEFINES += APPNAME=\\\"$${APPNAME}\\\"
Expand Down
8 changes: 6 additions & 2 deletions app/configappearancewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ void ConfigAppearanceWidget::setItemToolTip(QTableWidgetItem *item, const QFont
{
const QFontMetrics metrics(font);
ui.itemTable->setRowHeight(m_itemHighlighted, metrics.height() + m_itemMargin);
if (metrics.width(item->text()) >= ui.itemTable->contentsRect().width() - 30)
item->setToolTip(item->text());
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
if (metrics.horizontalAdvance(item->text()) >= ui.itemTable->contentsRect().width() - 30)
#else
if (metrics.width(item->text()) >= ui.itemTable->contentsRect().width() - 30)
#endif
item->setToolTip(item->text());
else
item->setToolTip(QString());
}
Expand Down
12 changes: 10 additions & 2 deletions app/configeditorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
#include "configeditorwidget.h"

#include <QtCore/QSettings>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QtCore5Compat/QTextCodec>
#else
#include <QTextCodec>
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtWidgets/QApplication>
#else
Expand Down Expand Up @@ -197,8 +201,12 @@ void ConfigEditorWidget::fillCodecComboBox(QComboBox *cb)
QVector<ComboItem> ciList; ciList.reserve(ca.length());
Q_FOREACH(const QByteArray &ba , ca)
ciList.append(ComboItem(codecNameToString(ba), ba));
qSort(ciList);
Q_FOREACH (const ComboItem& ci, ciList) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
std::sort(ciList.begin(), ciList.end());
#else
qSort(ciList);
#endif
Q_FOREACH (const ComboItem& ci, ciList) {
cb->addItem(ci.text, ci.data);
}
}
Expand Down
6 changes: 5 additions & 1 deletion app/editreplacecurrentwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ ReplaceCurrentWidget::ReplaceCurrentWidget(QWidget *parent) : QWidget(parent)
buttonsLayout->addWidget(dontReplaceButton);
buttonsLayout->addWidget(cancelButton);
buttonsLayout->addStretch();
buttonsLayout->setMargin(0);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
buttonsLayout->setContentsMargins(0, 0, 0, 0);
#else
buttonsLayout->setMargin(0);
#endif
buttonsWidget->setLayout(buttonsLayout);
mainLayout->addWidget(m_replaceLabel);
mainLayout->addWidget(buttonsWidget);
Expand Down
4 changes: 2 additions & 2 deletions app/editreplacewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void ReplaceWidget::doFind()
if (ui.comboBoxFind->findText(currentText) < 0)
ui.comboBoxFind->addItem(currentText);

QTextDocument::FindFlags flags = 0;
QTextDocument::FindFlags flags = (QTextDocument::FindFlags)0;
if (ui.checkBoxCaseSensitive->isChecked())
flags |= QTextDocument::FindCaseSensitively;
if (ui.checkBoxWholeWords->isChecked())
Expand All @@ -121,7 +121,7 @@ void ReplaceWidget::doReplace()
if (ui.comboBoxReplace->findText(replacementText) < 0)
ui.comboBoxReplace->addItem(replacementText);

QTextDocument::FindFlags flags = 0;
QTextDocument::FindFlags flags = (QTextDocument::FindFlags)0;
if (ui.checkBoxCaseSensitive->isChecked())
flags |= QTextDocument::FindCaseSensitively;
if (ui.checkBoxWholeWords->isChecked())
Expand Down
14 changes: 11 additions & 3 deletions app/linenumberwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ void LineNumberWidget::paintEvent(QPaintEvent *event)
{
if (userBookmarks.at(i) == lineNumber)
{
painter.fillRect(2, top, fm.width(QLatin1Char('B')) + 4, lineHeight, m_highlightBrush);
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
painter.fillRect(2, top, fm.horizontalAdvance(QLatin1Char('B')) + 4, lineHeight, m_highlightBrush);
#else
painter.fillRect(2, top, fm.width(QLatin1Char('B')) + 4, lineHeight, m_highlightBrush);
#endif
painter.setPen(m_highlightedTextPen);
painter.drawText(4, top, width() - 4, lineHeight, Qt::AlignLeft | Qt::AlignTop, QLatin1String("B"));
painter.setPen(m_highlightPen);
Expand All @@ -97,8 +101,12 @@ void LineNumberWidget::paintEvent(QPaintEvent *event)
void LineNumberWidget::mousePressEvent(QMouseEvent *event)
{
event->accept();
const QPoint p = m_editor->viewport()->mapFromGlobal(event->globalPos());
const int lineNumber = m_editor->cursorForPosition(p).blockNumber() + 1;
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
const QPointF p = m_editor->viewport()->mapFromGlobal(event->globalPosition());
#else
const QPoint p = m_editor->viewport()->mapFromGlobal(event->globalPos());
#endif
const int lineNumber = m_editor->cursorForPosition(p.toPoint()).blockNumber() + 1;
if (lineNumber <= 0)
return;

Expand Down
30 changes: 25 additions & 5 deletions app/loghighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,23 @@ LogHighlighter::LogHighlighter(QTextDocument *parent)
<< tr("This program will not work!");
Q_FOREACH (const QString &pattern, keywordPatterns)
{
rule.pattern = QRegExp(pattern);
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
rule.pattern = QRegularExpression(pattern);
#else
rule.pattern = QRegExp(pattern);
#endif
rule.format = keywordFormat;
m_highlightingRules.append(rule);
}

QTextCharFormat commandFormat;
commandFormat.setForeground(Qt::darkBlue);
commandFormat.setFontWeight(QFont::Bold);
rule.pattern = QRegExp(QLatin1String("^\\[[^\\]\\d][^\\]]*\\]"));
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
rule.pattern = QRegularExpression(QLatin1String("^\\[[^\\]\\d][^\\]]*\\]"));
#else
rule.pattern = QRegExp(QLatin1String("^\\[[^\\]\\d][^\\]]*\\]"));
#endif
rule.format = commandFormat;
m_highlightingRules.append(rule);

Expand All @@ -65,16 +73,28 @@ void LogHighlighter::highlightBlock(const QString &text)
{
// const QRegExp expression(rule.pattern);
// int index = text.indexOf(expression);
QRegExp expression(rule.pattern);
int index = expression.indexIn(text);
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
QRegularExpression expression(rule.pattern);
QRegularExpressionMatch match = expression.match(text);
while (match.hasMatch())
{
const int length = match.capturedLength();
setFormat(match.capturedStart(), length, rule.format);
// index = text.indexOf(expression, index + length);
match = expression.match(text, match.capturedEnd() + 1);
}
#else
QRegExp expression(rule.pattern);
int index = text.indexOf(expression);
while (index >= 0)
{
const int length = expression.matchedLength();
setFormat(index, length, rule.format);
// index = text.indexOf(expression, index + length);
index = expression.indexIn(text, index + length);
}
}
#endif
}

// Highlight statistics (at the end of the log)
setCurrentBlockState(0); // The current block state tracks multiline formatting
Expand Down
7 changes: 6 additions & 1 deletion app/loghighlighter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <QtGui/QSyntaxHighlighter>
#include <QtGui/QTextCharFormat>
#include <QRegularExpression>

/** A simple, incomplete highlighter for LaTeX .log files
* @author Florian Hackenberger <[email protected]>
Expand All @@ -44,7 +45,11 @@ class LogHighlighter : public QSyntaxHighlighter
private:
struct LogHighlightingRule
{
QRegExp pattern; /// The pattern to match for formatting
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
QRegularExpression pattern; /// The pattern to match for formatting
#else
QRegExp pattern; /// The pattern to match for formatting
#endif
QTextCharFormat format; /// The style of the formatting
};
/// All highlighting rules with their formatting for easy iteration
Expand Down
6 changes: 5 additions & 1 deletion app/logtextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ void LogTextEdit::setLogPalette(bool runFailed)
if (runFailed)
{
QPalette failedPalette(QApplication::palette());
failedPalette.setColor(QPalette::Background, QColor(255, 102, 102));
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
failedPalette.setColor(QPalette::Window, QColor(255, 102, 102));
#else
failedPalette.setColor(QPalette::Background, QColor(255, 102, 102));
#endif
setAutoFillBackground(true);
setPalette(failedPalette);
}
Expand Down
Loading

0 comments on commit f2c0bd3

Please sign in to comment.