Advance Wayland and KDE package bring-up

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-04-14 10:51:06 +01:00
parent 51f3c21121
commit cf12defd28
15214 changed files with 20594243 additions and 269 deletions
@@ -0,0 +1,14 @@
find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG QUIET OPTIONAL_COMPONENTS Widgets)
if(NOT TARGET Qt6::Widgets)
message(STATUS "Qt6Widgets not found, examples will not be built.")
return()
endif()
add_executable(kdirwatchtest_gui kdirwatchtest_gui.cpp)
target_link_libraries(kdirwatchtest_gui Qt6::Widgets KF6::CoreAddons)
add_executable(faceicontest faceicontest.cpp)
target_link_libraries(faceicontest Qt6::Widgets KF6::CoreAddons)
add_executable(texttohtmltest ktexttohtmltest.cpp)
target_link_libraries(texttohtmltest Qt6::Widgets KF6::CoreAddons)
@@ -0,0 +1,43 @@
/*
SPDX-FileCopyrightText: 2014 Nicolás Alvarez <nicolas.alvarez@gmail.com>
SPDX-License-Identifier: LGPL-2.0-only
*/
#include "faceicontest.h"
#include <QApplication>
#include <QListWidget>
#include <QVBoxLayout>
#include <kuser.h>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
FaceIconTest *mainWin = new FaceIconTest();
mainWin->show();
return app.exec();
}
FaceIconTest::FaceIconTest()
{
QVBoxLayout *layout = new QVBoxLayout(this);
listWidget = new QListWidget(this);
layout->addWidget(listWidget);
const QList<KUser> users = KUser::allUsers();
for (const KUser &u : users) {
QPixmap pixmap(u.faceIconPath());
if (pixmap.isNull()) {
pixmap = QPixmap(QSize(48, 48));
pixmap.fill();
} else {
pixmap = pixmap.scaled(48, 48, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
QListWidgetItem *item = new QListWidgetItem(u.loginName(), listWidget);
item->setData(Qt::DecorationRole, pixmap);
}
}
#include "moc_faceicontest.cpp"
@@ -0,0 +1,22 @@
/*
SPDX-FileCopyrightText: 2014 Nicolás Alvarez <nicolas.alvarez@gmail.com>
SPDX-License-Identifier: LGPL-2.0-only
*/
#ifndef FACEICONTEST_H
#define FACEICONTEST_H
#include <QWidget>
class FaceIconTest : public QWidget
{
Q_OBJECT
public:
FaceIconTest();
private:
class QListWidget *listWidget;
};
#endif
@@ -0,0 +1,62 @@
/*
* SPDX-FileCopyrightText: 2024 Nicolas Fella <nicolas.fella@gmx.de>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick
import org.kde.coreaddons
Column {
height: 500
Text {
text: "formatByteSize(1234): %1".arg(Format.formatByteSize(1234))
}
Text {
text: "formatByteSize(1234, 2): %1".arg(Format.formatByteSize(1234, 2))
}
Text {
text: "formatDuration(12345678, FormatTypes.DefaultDuration): %1".arg(Format.formatDuration(12345678, FormatTypes.DefaultDuration))
}
Text {
text: "formatDuration(12345678, FormatTypes.InitialDuration): %1".arg(Format.formatDuration(12345678, FormatTypes.InitialDuration))
}
Text {
text: "formatDuration(12345678, FormatTypes.ShowMilliseconds): %1".arg(Format.formatDuration(12345678, FormatTypes.ShowMilliseconds))
}
Text {
text: "formatDuration(12345678, FormatTypes.HideSeconds): %1".arg(Format.formatDuration(12345678, FormatTypes.HideSeconds))
}
Text {
text: "formatDuration(12345678, FormatTypes.FoldHours): %1".arg(Format.formatDuration(12345678, FormatTypes.FoldHours))
}
Text {
text: "formatDuration(12345678, FormatTypes.InitialDuration | FormatTypes.HideSeconds): %1".arg(Format.formatDuration(12345678, FormatTypes.InitialDuration | FormatTypes.HideSeconds))
}
Text {
text: "formatDecimalDuration(6000): %1".arg(Format.formatDecimalDuration(6000))
}
Text {
text: "formatDecimalDuration(6123, 2): %1".arg(Format.formatDecimalDuration(6123, 2))
}
Text {
text: "formatSpelloutDuration(60001): %1".arg(Format.formatSpelloutDuration(60001))
}
Text {
text: "Format.formatRelativeDate(new Date(), Qt.LongFormat): %1".arg(Format.formatRelativeDate(new Date(), Qt.LongFormat))
}
}
@@ -0,0 +1,78 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
SPDX-License-Identifier: LGPL-2.0-only
*/
#include "kdirwatchtest.h"
#include <QCoreApplication>
#include <QStringList>
#include <QDebug>
// TODO debug crash when calling "./kdirwatchtest ./kdirwatchtest"
int main(int argc, char **argv)
{
// TODO port to QCommandLineArguments once it exists
// options.add("+[directory ...]", qi18n("Directory(ies) to watch"));
QCoreApplication a(argc, argv);
myTest testObject;
KDirWatch *dirwatch1 = KDirWatch::self();
KDirWatch *dirwatch2 = new KDirWatch;
testObject.connect(dirwatch1, &KDirWatch::dirty, &myTest::dirty);
testObject.connect(dirwatch1, &KDirWatch::created, &myTest::created);
testObject.connect(dirwatch1, &KDirWatch::deleted, &myTest::deleted);
// TODO port to QCommandLineArguments once it exists
const QStringList args = a.arguments();
for (int i = 1; i < args.count(); ++i) {
const QString arg = args.at(i);
if (!arg.startsWith("-")) {
qDebug() << "Watching: " << arg;
dirwatch2->addDir(arg);
}
}
QString home = QString(getenv("HOME")) + '/';
QString desk = home + "Desktop/";
qDebug() << "Watching: " << home;
dirwatch1->addDir(home);
qDebug() << "Watching file: " << home << "foo ";
dirwatch1->addFile(home + "foo");
qDebug() << "Watching: " << desk;
dirwatch1->addDir(desk);
QString test = home + "test/";
qDebug() << "Watching: (but skipped) " << test;
dirwatch1->addDir(test);
dirwatch1->startScan();
dirwatch2->startScan();
if (!dirwatch1->stopDirScan(home)) {
qDebug() << "stopDirscan: " << home << " error!";
}
if (!dirwatch1->restartDirScan(home)) {
qDebug() << "restartDirScan: " << home << "error!";
}
if (!dirwatch1->stopDirScan(test)) {
qDebug() << "stopDirScan: error";
}
KDirWatch::statistics();
delete dirwatch2;
KDirWatch::statistics();
return a.exec();
}
#include "moc_kdirwatchtest.cpp"
@@ -0,0 +1,40 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
SPDX-License-Identifier: LGPL-2.0-only
*/
#ifndef _KDIRWATCHTEST_H_
#define _KDIRWATCHTEST_H_
#include <QObject>
#include <stdio.h>
#include <stdlib.h>
#include "kdirwatch.h"
class myTest : public QObject
{
Q_OBJECT
public:
myTest()
{
}
public Q_SLOTS:
void dirty(const QString &a)
{
printf("Dirty: %s\n", a.toLocal8Bit().constData());
}
void created(const QString &f)
{
printf("Created: %s\n", f.toLocal8Bit().constData());
}
void deleted(const QString &f)
{
printf("Deleted: %s\n", f.toLocal8Bit().constData());
}
};
#endif
@@ -0,0 +1,131 @@
/*
SPDX-FileCopyrightText: 2006 Dirk Stoecker <kde@dstoecker.de>
SPDX-License-Identifier: LGPL-2.0-only
*/
#include "kdirwatchtest_gui.h"
#include <QApplication>
#include <QDir>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QTextBrowser>
#include <QVBoxLayout>
#include <kdirwatch.h>
#include <qplatformdefs.h>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
KDirWatchTest_GUI *mainWin = new KDirWatchTest_GUI();
mainWin->show();
return app.exec();
}
KDirWatchTest_GUI::KDirWatchTest_GUI()
: QWidget()
{
QPushButton *e;
QPushButton *f;
QVBoxLayout *lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
lay->addWidget(l1 = new QLineEdit(QLatin1String("Test 1"), this));
lay->addWidget(l2 = new QLineEdit(QLatin1String("Test 2"), this));
lay->addWidget(l3 = new QLineEdit(QLatin1String("Test 3"), this));
lay->addWidget(m_eventBrowser = new QTextBrowser(this));
lay->addWidget(d = new QLineEdit(QLatin1String("Status"), this));
lay->addWidget(e = new QPushButton(QLatin1String("new file"), this));
lay->addWidget(f = new QPushButton(QLatin1String("delete file"), this));
dir = QDir::currentPath();
file = dir + QLatin1String("/testfile_kdirwatchtest_gui");
w1 = new KDirWatch();
w1->setObjectName(QLatin1String("w1"));
w2 = new KDirWatch();
w2->setObjectName(QLatin1String("w2"));
w3 = new KDirWatch();
w3->setObjectName(QLatin1String("w3"));
connect(w1, &KDirWatch::dirty, this, &KDirWatchTest_GUI::slotDir1);
connect(w2, &KDirWatch::dirty, this, &KDirWatchTest_GUI::slotDir2);
connect(w3, &KDirWatch::dirty, this, &KDirWatchTest_GUI::slotDir3);
w1->addDir(dir);
w2->addDir(dir);
w3->addDir(dir);
KDirWatch *w4 = new KDirWatch(this);
w4->setObjectName(QLatin1String("w4"));
w4->addDir(dir, KDirWatch::WatchFiles | KDirWatch::WatchSubDirs);
connect(w1, &KDirWatch::dirty, this, &KDirWatchTest_GUI::slotDirty);
connect(w1, &KDirWatch::created, this, &KDirWatchTest_GUI::slotCreated);
connect(w1, &KDirWatch::deleted, this, &KDirWatchTest_GUI::slotDeleted);
KDirWatch *w5 = new KDirWatch(this);
w5->setObjectName(QLatin1String(QLatin1String("w5")));
w5->addFile(file);
connect(w5, &KDirWatch::dirty, this, &KDirWatchTest_GUI::slotDirty);
connect(w5, &KDirWatch::created, this, &KDirWatchTest_GUI::slotCreated);
connect(w5, &KDirWatch::deleted, this, &KDirWatchTest_GUI::slotDeleted);
lay->addWidget(new QLabel(QLatin1String("Directory = ") + dir, this));
lay->addWidget(new QLabel(QLatin1String("File = ") + file, this));
connect(e, &QPushButton::clicked, this, &KDirWatchTest_GUI::slotNewClicked);
connect(f, &QPushButton::clicked, this, &KDirWatchTest_GUI::slotDeleteClicked);
setMinimumWidth(800);
setMinimumHeight(400);
}
void KDirWatchTest_GUI::slotDir1(const QString &a)
{
l1->setText(QLatin1String("Test 1 changed ") + a + QLatin1String(" at ") + QTime::currentTime().toString());
}
void KDirWatchTest_GUI::slotDir2(const QString &a)
{
// This used to cause bug #119341, fixed now
#if 1
w2->stopDirScan(QLatin1String(a.toLatin1().constData()));
w2->restartDirScan(QLatin1String(a.toLatin1().constData()));
#endif
l2->setText(QLatin1String("Test 2 changed ") + a + QLatin1String(" at ") + QTime::currentTime().toString());
}
void KDirWatchTest_GUI::slotDir3(const QString &a)
{
l3->setText(QLatin1String("Test 3 changed ") + a + QLatin1String(" at )") + QTime::currentTime().toString());
}
void KDirWatchTest_GUI::slotDeleteClicked()
{
remove(file.toLatin1().constData());
d->setText(QLatin1String("Delete clicked at ") + QTime::currentTime().toString());
}
void KDirWatchTest_GUI::slotNewClicked()
{
fclose(QT_FOPEN(file.toLatin1().constData(), "wb"));
d->setText(QLatin1String("New clicked at ") + QTime::currentTime().toString());
}
void KDirWatchTest_GUI::slotDirty(const QString &path)
{
m_eventBrowser->append(QLatin1String("Dirty(") + sender()->objectName() + QLatin1String("): ") + path + QLatin1Char('\n'));
}
void KDirWatchTest_GUI::slotCreated(const QString &path)
{
m_eventBrowser->append(QLatin1String("Created(") + sender()->objectName() + QLatin1String("): ") + path + QLatin1Char('\n'));
}
void KDirWatchTest_GUI::slotDeleted(const QString &path)
{
m_eventBrowser->append(QLatin1String("Deleted(") + sender()->objectName() + QLatin1String("): ") + path + QLatin1Char('\n'));
}
#include "moc_kdirwatchtest_gui.cpp"
@@ -0,0 +1,40 @@
// krazy:excludeall=qclasses
/*
SPDX-FileCopyrightText: 2006 Dirk Stoecker <kde@dstoecker.de>
SPDX-License-Identifier: LGPL-2.0-only
*/
#ifndef KDIRWATCHTEST_GUI_H
#define KDIRWATCHTEST_GUI_H
#include <QDialog>
class QTextBrowser;
class KDirWatchTest_GUI : public QWidget
{
Q_OBJECT
public:
KDirWatchTest_GUI();
protected Q_SLOTS:
void slotNewClicked();
void slotDeleteClicked();
void slotDir1(const QString &path);
void slotDir2(const QString &path);
void slotDir3(const QString &path);
void slotDirty(const QString &);
void slotCreated(const QString &);
void slotDeleted(const QString &);
private:
class QLineEdit *d;
QString file, dir;
class KDirWatch *w1;
class KDirWatch *w2;
class KDirWatch *w3;
class QLineEdit *l1, *l2, *l3;
QTextBrowser *m_eventBrowser;
};
#endif
@@ -0,0 +1,83 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 1999 Waldo Bastian <bastian@kde.org>
SPDX-License-Identifier: LGPL-2.0-only
*/
#include <QList>
#include <QString>
#include "krandom.h"
#include "krandomsequence.h"
#include <stdio.h>
int main(/*int argc, char *argv[]*/)
{
long seed;
KRandomSequence seq;
seed = 2;
seq.setSeed(seed);
printf("Seed = %4ld :", seed);
for (int i = 0; i < 20; i++) {
printf("%3ld ", seq.getLong(100));
}
printf("\n");
seed = 0;
seq.setSeed(seed);
printf("Seed = %4ld :", seed);
for (int i = 0; i < 20; i++) {
printf("%3ld ", seq.getLong(100));
}
printf("\n");
seed = 0;
seq.setSeed(seed);
printf("Seed = %4ld :", seed);
for (int i = 0; i < 20; i++) {
printf("%3ld ", seq.getLong(100));
}
printf("\n");
seed = 2;
seq.setSeed(seed);
printf("Seed = %4ld :", seed);
for (int i = 0; i < 20; i++) {
printf("%3ld ", seq.getLong(100));
}
printf("\n");
seq.setSeed(KRandom::random());
QStringList list{
QLatin1String("A"),
QLatin1String("B"),
QLatin1String("C"),
QLatin1String("D"),
QLatin1String("E"),
QLatin1String("F"),
QLatin1String("G"),
};
auto printList = [&list]() {
for (const QString &str : std::as_const(list)) {
printf("%s", str.toLatin1().data());
}
printf("\n");
};
printList();
seq.randomize(list);
printList();
seq.randomize(list);
printList();
seq.randomize(list);
printList();
}
@@ -0,0 +1,47 @@
/*
SPDX-FileCopyrightText: 2021 Friedrich W. H. Kossebau <kossebau@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <KTextToHTML>
#include <QApplication>
#include <QHBoxLayout>
#include <QMainWindow>
#include <QTextBrowser>
#include <QTimer>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
auto *window = new QMainWindow;
auto *mainWidget = new QWidget;
window->setCentralWidget(mainWidget);
auto *layout = new QHBoxLayout;
mainWidget->setLayout(layout);
auto *plaintextEditor = new QTextEdit;
plaintextEditor->setAcceptRichText(false);
layout->addWidget(plaintextEditor);
auto *htmlView = new QTextBrowser;
layout->addWidget(htmlView);
auto *updateTimer = new QTimer(&app);
updateTimer->setSingleShot(true);
updateTimer->setInterval(1000);
QObject::connect(updateTimer, &QTimer::timeout, plaintextEditor, [plaintextEditor, htmlView]() {
const QString html = KTextToHTML::convertToHtml(plaintextEditor->toPlainText(), KTextToHTML::Options());
htmlView->setHtml(html);
});
QObject::connect(plaintextEditor, &QTextEdit::textChanged, updateTimer, qOverload<>(&QTimer::start));
window->show();
return app.exec();
}