Commit fb239391 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

KWrite compiles with Qt6

parent 1c5f0578
Pipeline #153617 passed with stage
in 2 minutes and 26 seconds
......@@ -25,6 +25,7 @@
#include <QCommandLineParser>
#include <QDir>
#include <QFileInfo>
#include <QRegularExpression>
#include <QTextCodec>
#include <QUrlQuery>
......@@ -251,21 +252,13 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv)
if (parser.positionalArguments().count() == 0) {
KWrite *t = kapp.newWindow();
if (parser.isSet(QStringLiteral("stdin"))) {
QTextStream input(stdin, QIODevice::ReadOnly);
if (parser.isSet(QStringLiteral("stdin"))) { // get full stdin content with right encoding
QFile input;
input.open(stdin, QIODevice::ReadOnly);
QString text = codec ? codec->toUnicode(input.readAll()) : QString::fromLocal8Bit(input.readAll());
// set chosen codec
if (codec) {
input.setCodec(codec);
}
QString line;
QString text;
do {
line = input.readLine();
text.append(line + QLatin1Char('\n'));
} while (!line.isNull());
// normalize line endings, to e.g. catch issues with \r\n on Windows
text.replace(QRegularExpression(QStringLiteral("\r\n?")), QStringLiteral("\n"));
KTextEditor::Document *doc = t->activeView()->document();
if (doc) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment