Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(very WIP) KF6 port #78

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
16 changes: 16 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Qt",
"includePath": [
"/usr/include/**"
],
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++17",
"configurationProvider": "vector-of-bool.cmake-tools"
}
],
"version": 4
}
36 changes: 36 additions & 0 deletions .vscode/cmake-variants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"buildType": {
"default": "debug",
"choices": {
"debug": {
"short": "Debug",
"long": "Emit debug information without performing optimizations",
"buildType": "Debug"
},
"minsize": {
"short": "MinSizeRel",
"long": "Optimize for smallest binary size",
"buildType": "MinSizeRel"
},
"reldeb": {
"short": "RelWithDebInfo",
"long": "Perform optimizations AND include debugging information",
"buildType": "RelWithDebInfo"
}
}
},
"ktexteditor": {
"default": "yes",
"choices": {
"yes": {
"short": "Use KTextEditor",
"settings": {
"KTIKZ_USE_KTEXTEDITOR" : true
}
},
"no": {
"short": "Don’t use KTextEditor"
}
}
}
}
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "cppdbg",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/build/app/ktikz",
"args": [],
"cwd": "${workspaceFolder}",
"environment": [
{ "name": "XDG_DATA_DIRS", "value": "${workspaceFolder}/app:${env:XDG_DATA_DIRS-/usr/local/share:/usr/share}" },
],
},
],
}
31 changes: 31 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"files.associations": {
"*.desktop": "ini",
"vimrc": "viml",
"zshrc": "shellscript",
".zpreztorc": "shellscript",
"zpreztorc": "shellscript",
"asv.conf.json": "jsonc",
"*.tags": "lua",
"*.tikz": "context",
"*.lmtx": "context",
".prettierrc": "jsonc",
"*.yaml": "jinja-yaml",
"*.j2": "jinja-md",
"qdir": "cpp",
"qsyntaxhighlighter": "cpp",
"qpointer": "cpp",
"qtextcodec": "cpp",
"qdatetime": "cpp",
"qstatusbar": "cpp",
"qapplication": "cpp",
"filecopyjob": "cpp",
"statjob": "cpp",
"kmessagebox": "cpp",
"klocalizedstring": "cpp",
"readonlypart": "cpp",
"qtranslator": "cpp",
"kpluginfactory": "cpp",
"*.moc": "cpp"
}
}
21 changes: 12 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ endif()
set(KTIKZ_VERSION "0.13.2")
set(KTIKZ_USE_KTEXTEDITOR TRUE CACHE BOOL "Use KTextEditor framework")

set(QT_MIN_VERSION "6.5.0")
set(KF6_DEP_VERSION "6.0.0")
set(QT_MAJOR_VERSION "6")

add_definitions(-DORGNAME=\"Florian_Hackenberger\")
add_definitions(-DAPPNAME=\"ktikz\")
add_definitions(-DAPPVERSION=\"${KTIKZ_VERSION}\")
Expand All @@ -32,16 +36,15 @@ include(KDECMakeSettings)
include(FeatureSummary)

find_package(
Qt5
5.15
CONFIG
REQUIRED Core Gui Widgets Xml PrintSupport LinguistTools
Qt6
REQUIRED
COMPONENTS Core Gui Widgets Xml PrintSupport LinguistTools Core5Compat
)

find_package(
KF5
5.92
REQUIRED DocTools XmlGui TextEditor Parts IconThemes
KF6
REQUIRED
COMPONENTS DocTools XmlGui TextEditor Parts IconThemes KIO WidgetsAddons I18n
)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
Expand All @@ -58,9 +61,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif()
endif()

find_package(Poppler "22.02" REQUIRED Qt5 Core)
find_package(Poppler "24.06" REQUIRED Qt6 Core)
set_package_properties(
"Poppler-Qt5"
"Poppler-Qt6"
PROPERTIES
DESCRIPTION "A PDF rendering library"
URL "http://poppler.freedesktop.org"
Expand Down
29 changes: 17 additions & 12 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ ki18n_wrap_ui(ktikz_UI_FILES
../common/templatewidget.ui
)
kconfig_add_kcfg_files(ktikz_SRCS ../common/settings.kcfgc)
qt5_add_resources(ktikz_SRCS ktikz.qrc)
qt5_add_resources(ktikz_SRCS qtikz.qrc)
qt_add_resources(ktikz_SRCS ktikz.qrc)
qt_add_resources(ktikz_SRCS qtikz.qrc)

file(GLOB icons_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/icons/*-apps-ktikz.png")
# add icons for win32 and mac; this command assumes that the first arg is of the
Expand All @@ -86,23 +86,28 @@ ecm_add_app_icon(ktikz_SRCS ICONS ${icons_SRCS})
add_executable(ktikz ${ktikz_SRCS} ${ktikz_UI_FILES})
target_link_libraries(
ktikz
KF5::XmlGui
KF5::TextEditor
KF5::IconThemes
Qt5::PrintSupport
Poppler::Qt5
KF6::XmlGui
KF6::TextEditor
KF6::IconThemes
KF6::KIOWidgets
KF6::KIOFileWidgets
KF6::WidgetsAddons
KF6::I18n
Qt6::Core5Compat # QTextCodec
Qt6::PrintSupport
Poppler::Qt6
)

if(KTIKZ_USE_KTEXTEDITOR)
target_link_libraries(ktikz KF5::TextEditor)
target_link_libraries(ktikz KF6::TextEditor)
endif()

install(TARGETS ktikz DESTINATION ${KDE_INSTALL_BINDIR})
if(KTIKZ_USE_KTEXTEDITOR)
install(FILES ktikzui_frameworks.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/ktikz)
install(FILES kxmlgui5/ktikz/ktikzui_frameworks.rc DESTINATION ${KDE_INSTALL_KXMLGUIDIR}/ktikz)
endif()

install(FILES ktikzui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/ktikz)
install(FILES kxmlgui5/ktikz/ktikzui.rc DESTINATION ${KDE_INSTALL_KXMLGUIDIR}/ktikz)
install(FILES ../common/ktikz.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})

add_subdirectory(icons)
Expand All @@ -114,8 +119,8 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E remove_directory ${KTIKZ_TRANSLATIONS_INSTALL_DIR}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${KTIKZ_TEMPLATES_INSTALL_DIR}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${KTIKZ_DATA_INSTALL_DIR}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${KXMLGUI_INSTALL_DIR}/ktikz
COMMAND ${CMAKE_COMMAND} -E remove_directory ${KDE_INSTALL_KXMLGUIDIR}/ktikz
COMMENT
"Removing directories ${KTIKZ_TRANSLATIONS_INSTALL_DIR} ${KTIKZ_TEMPLATES_INSTALL_DIR} ${KTIKZ_DATA_INSTALL_DIR} ${KXMLGUI_INSTALL_DIR}/ktikz"
"Removing directories ${KTIKZ_TRANSLATIONS_INSTALL_DIR} ${KTIKZ_TEMPLATES_INSTALL_DIR} ${KTIKZ_DATA_INSTALL_DIR} ${KDE_INSTALL_KXMLGUIDIR}/ktikz"
VERBATIM
)
2 changes: 1 addition & 1 deletion app/configeditorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "configeditorwidget.h"

#include <QtCore/QSettings>
#include <QTextCodec>
#include <QtCore5Compat/QTextCodec>
#include <QtWidgets/QApplication>

#include "../common/utils/fontdialog.h"
Expand Down
2 changes: 1 addition & 1 deletion app/editreplacecurrentwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ReplaceCurrentWidget::ReplaceCurrentWidget(QWidget *parent) : QWidget(parent)
buttonsLayout->addWidget(dontReplaceButton);
buttonsLayout->addWidget(cancelButton);
buttonsLayout->addStretch();
buttonsLayout->setMargin(0);
buttonsLayout->setContentsMargins(0, 0, 0, 0);
buttonsWidget->setLayout(buttonsLayout);
mainLayout->addWidget(m_replaceLabel);
mainLayout->addWidget(buttonsWidget);
Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 7 additions & 10 deletions app/loghighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ LogHighlighter::LogHighlighter(QTextDocument *parent) : QSyntaxHighlighter(paren
// TikzPreviewGenerator::getParsedLogText()
<< tr("This program will not work!");
for (const auto &pattern : keywordPatterns) {
rule.pattern = QRegExp(pattern);
rule.pattern = QRegularExpression(pattern);
rule.format = keywordFormat;
m_highlightingRules.append(rule);
}

QTextCharFormat commandFormat;
commandFormat.setForeground(Qt::darkBlue);
commandFormat.setFontWeight(QFont::Bold);
rule.pattern = QRegExp(QLatin1String("^\\[[^\\]\\d][^\\]]*\\]"));
rule.pattern = QRegularExpression("^\\[[^\\]\\d][^\\]]*\\]");
rule.format = commandFormat;
m_highlightingRules.append(rule);

Expand All @@ -61,15 +61,12 @@ void LogHighlighter::highlightBlock(const QString &text)
{
// Try each highlighting pattern and apply formatting if it matches
for (const auto &rule : m_highlightingRules) {
// const QRegExp expression(rule.pattern);
// int index = text.indexOf(expression);
QRegExp expression(rule.pattern);
int index = expression.indexIn(text);
while (index >= 0) {
const int length = expression.matchedLength();
auto m = rule.pattern.match(text);
while (m.hasMatch()) {
int index = m.capturedStart();
const int length = m.capturedLength();
setFormat(index, length, rule.format);
// index = text.indexOf(expression, index + length);
index = expression.indexIn(text, index + length);
m = rule.pattern.match(text, m.capturedEnd());
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/loghighlighter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef LOGHIGHLIGHTER_H
#define LOGHIGHLIGHTER_H

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

Expand All @@ -44,7 +45,7 @@ class LogHighlighter : public QSyntaxHighlighter
private:
struct LogHighlightingRule
{
QRegExp pattern; /// The pattern to match for formatting
QRegularExpression pattern; /// The pattern to match for formatting
QTextCharFormat format; /// The style of the formatting
};
/// All highlighting rules with their formatting for easy iteration
Expand Down
10 changes: 5 additions & 5 deletions app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <QMenuBar>
#include <QScreen>
#include <QStatusBar>
#include <QtCore/QTextCodec>
#include <QtCore5Compat/QTextCodec>
#include <QtCore/QProcess>
#include <QtCore/QSettings>
#include <QtCore/QTextStream>
Expand Down Expand Up @@ -140,7 +140,7 @@ MainWindow::MainWindow()
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
mainLayout->setSpacing(0);
mainLayout->setMargin(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(m_tikzPreviewController->templateWidget());
mainLayout->addWidget(m_tikzEditorView);

Expand Down Expand Up @@ -1069,7 +1069,7 @@ void MainWindow::loadUrl(const QUrl &url)
QApplication::setOverrideCursor(Qt::WaitCursor);
this->configureStreamDecoding(in);
m_tikzQtEditorView->editor()->setPlainText(in.readAll());
setCurrentEncoding(in.codec());
//setCurrentEncoding(in.codec());
}

QApplication::restoreOverrideCursor();
Expand Down Expand Up @@ -1169,7 +1169,7 @@ void MainWindow::configureStreamEncoding(QTextStream &textStream)
{
QTextCodec *encoder = this->getEncoder();
if (Q_LIKELY(encoder)) // should be true
textStream.setCodec(encoder);
{}//textStream.setCodec(encoder);
else
qWarning("The encoder variable should not be null.");

Expand All @@ -1179,7 +1179,7 @@ void MainWindow::configureStreamEncoding(QTextStream &textStream)
void MainWindow::configureStreamDecoding(QTextStream &textStream)
{
if (m_overrideDecoder) {
textStream.setCodec(m_overrideDecoder);
//textStream.setCodec(m_overrideDecoder);
}
textStream.setAutoDetectUnicode(true);
}
Expand Down
1 change: 1 addition & 0 deletions app/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AssistantController;

#include <QtCore/QDateTime>
#include <QtCore/QPointer>
#include <QtCore5Compat/QTextCodec>
#include "../common/mainwidget.h"

class QAction;
Expand Down
Loading
Loading