init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
allhaileris
2026-02-16 15:50:16 +03:00
commit afb81b8278
13816 changed files with 3689732 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG QUIET OPTIONAL_COMPONENTS Widgets)
if(NOT TARGET Qt${QT_MAJOR_VERSION}::Widgets)
message(STATUS "Qt${QT_MAJOR_VERSION}Widgets not found, examples will not be built.")
return()
endif()
add_executable(kdirwatchtest_gui kdirwatchtest_gui.cpp)
target_link_libraries(kdirwatchtest_gui Qt${QT_MAJOR_VERSION}::Widgets KF5::CoreAddons)
add_executable(faceicontest faceicontest.cpp)
target_link_libraries(faceicontest Qt${QT_MAJOR_VERSION}::Widgets KF5::CoreAddons)
add_executable(texttohtmltest ktexttohtmltest.cpp)
target_link_libraries(texttohtmltest Qt${QT_MAJOR_VERSION}::Widgets KF5::CoreAddons)

View File

@@ -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"

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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();
}