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:
@@ -0,0 +1,49 @@
|
||||
include(ECMMarkAsTest)
|
||||
|
||||
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
|
||||
remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY)
|
||||
|
||||
macro(KIOWIDGETS_EXECUTABLE_TESTS)
|
||||
foreach(_testname ${ARGN})
|
||||
add_executable(${_testname} ${_testname}.cpp)
|
||||
target_link_libraries(${_testname}
|
||||
KF6::KIOCore
|
||||
KF6::KIOGui
|
||||
KF6::KIOWidgets
|
||||
KF6::KIOFileWidgets
|
||||
Qt6::Test
|
||||
KF6::WidgetsAddons
|
||||
KF6::IconThemes)
|
||||
ecm_mark_as_test(${_testname})
|
||||
endforeach()
|
||||
endmacro(KIOWIDGETS_EXECUTABLE_TESTS)
|
||||
|
||||
if (HAVE_QTDBUS)
|
||||
KIOWIDGETS_EXECUTABLE_TESTS(
|
||||
getalltest
|
||||
kdirlistertest_gui
|
||||
kdirmodeltest_gui
|
||||
kemailclientlauncherjobtest_gui
|
||||
kencodingfiledialogtest_gui
|
||||
kfilecustomdialogtest_gui
|
||||
kfilecustomdialogtest_gui_select_dir_mode
|
||||
kfilewidgettest_gui
|
||||
kfilewidgettest_saving_gui
|
||||
kioworkertest
|
||||
kmountpoint_debug
|
||||
kopenwithtest
|
||||
kpropertiesdialogtest
|
||||
kprotocolinfo_dumper
|
||||
kruntest
|
||||
ksycocaupdatetest
|
||||
kterminallauncherjobtest_gui
|
||||
kurlnavigatortest_gui
|
||||
kurlrequestertest_gui
|
||||
listjobtest
|
||||
openfilemanagerwindowtest
|
||||
previewtest
|
||||
${runapplication_EXE}
|
||||
)
|
||||
|
||||
add_subdirectory(messageboxworker)
|
||||
endif()
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <KService>
|
||||
#include <QMimeDatabase>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication::setApplicationName(QStringLiteral("getalltest"));
|
||||
QApplication k(argc, argv);
|
||||
|
||||
// for (int i = 0 ; i < 2 ; ++i ) { // test twice to see if they got deleted
|
||||
qDebug() << "All services";
|
||||
const KService::List services = KService::allServices();
|
||||
qDebug() << "got " << services.count() << " services";
|
||||
for (const KService::Ptr &s : services) {
|
||||
qDebug() << s->name() << " " << s->entryPath();
|
||||
}
|
||||
//}
|
||||
|
||||
qDebug() << "All mimeTypes";
|
||||
QMimeDatabase db;
|
||||
const QList<QMimeType> mimeTypes = db.allMimeTypes();
|
||||
qDebug() << "got " << mimeTypes.count() << " mimeTypes";
|
||||
for (const QMimeType &m : mimeTypes) {
|
||||
qDebug() << m.name();
|
||||
}
|
||||
|
||||
qDebug() << "done";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
This file is part of the KDE desktop environment
|
||||
SPDX-FileCopyrightText: 2001, 2002 Michael Brade <brade@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kdirlistertest_gui.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
KDirListerTest::KDirListerTest(QWidget *parent, const QUrl &initialUrl)
|
||||
: QWidget(parent)
|
||||
{
|
||||
lister = new KDirLister(this);
|
||||
debug = new PrintSignals;
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
|
||||
QPushButton *startH = new QPushButton(QStringLiteral("Start listing Home"), this);
|
||||
QPushButton *startR = new QPushButton(QStringLiteral("Start listing Root"), this);
|
||||
QPushButton *test = new QPushButton(QStringLiteral("Many"), this);
|
||||
QPushButton *startT = new QPushButton(QStringLiteral("tarfile"), this);
|
||||
|
||||
layout->addWidget(startH);
|
||||
layout->addWidget(startR);
|
||||
layout->addWidget(startT);
|
||||
layout->addWidget(test);
|
||||
resize(layout->sizeHint());
|
||||
|
||||
connect(startR, &QAbstractButton::clicked, this, &KDirListerTest::startRoot);
|
||||
connect(startH, &QAbstractButton::clicked, this, &KDirListerTest::startHome);
|
||||
connect(startT, &QAbstractButton::clicked, this, &KDirListerTest::startTar);
|
||||
connect(test, &QAbstractButton::clicked, this, &KDirListerTest::test);
|
||||
|
||||
connect(lister, &KCoreDirLister::started, debug, &PrintSignals::started);
|
||||
connect(lister, qOverload<>(&KDirLister::completed), debug, &PrintSignals::completed);
|
||||
connect(lister, &KCoreDirLister::listingDirCompleted, debug, &PrintSignals::listingDirCompleted);
|
||||
connect(lister, qOverload<>(&KDirLister::canceled), debug, &PrintSignals::canceled);
|
||||
connect(lister, &KCoreDirLister::listingDirCanceled, debug, &PrintSignals::listingDirCanceled);
|
||||
connect(lister, &KDirLister::redirection, debug, &PrintSignals::redirection);
|
||||
connect(lister, qOverload<>(&KDirLister::clear), debug, &PrintSignals::clear);
|
||||
connect(lister, &KCoreDirLister::newItems, debug, &PrintSignals::newItems);
|
||||
connect(lister, &KCoreDirLister::itemsDeleted, debug, &PrintSignals::itemsDeleted);
|
||||
connect(lister, &KCoreDirLister::refreshItems, debug, &PrintSignals::refreshItems);
|
||||
connect(lister, &KCoreDirLister::infoMessage, debug, &PrintSignals::infoMessage);
|
||||
connect(lister, &KCoreDirLister::percent, debug, &PrintSignals::percent);
|
||||
connect(lister, &KCoreDirLister::totalSize, debug, &PrintSignals::totalSize);
|
||||
connect(lister, &KCoreDirLister::processedSize, debug, &PrintSignals::processedSize);
|
||||
connect(lister, &KCoreDirLister::speed, debug, &PrintSignals::speed);
|
||||
|
||||
connect(lister, qOverload<>(&KDirLister::completed), this, &KDirListerTest::completed);
|
||||
|
||||
if (initialUrl.isValid()) {
|
||||
lister->openUrl(initialUrl, KDirLister::NoFlags);
|
||||
}
|
||||
}
|
||||
|
||||
KDirListerTest::~KDirListerTest()
|
||||
{
|
||||
}
|
||||
|
||||
void KDirListerTest::startHome()
|
||||
{
|
||||
QUrl home = QUrl::fromLocalFile(QDir::homePath());
|
||||
lister->openUrl(home, KDirLister::NoFlags);
|
||||
// lister->stop();
|
||||
}
|
||||
|
||||
void KDirListerTest::startRoot()
|
||||
{
|
||||
QUrl root = QUrl::fromLocalFile(QDir::rootPath());
|
||||
lister->openUrl(root, KDirLister::Keep | KDirLister::Reload);
|
||||
// lister->stop( root );
|
||||
}
|
||||
|
||||
void KDirListerTest::startTar()
|
||||
{
|
||||
QUrl root = QUrl::fromLocalFile(QDir::homePath() + QStringLiteral("/aclocal_1.tgz"));
|
||||
lister->openUrl(root, KDirLister::Keep | KDirLister::Reload);
|
||||
// lister->stop( root );
|
||||
}
|
||||
|
||||
void KDirListerTest::test()
|
||||
{
|
||||
QUrl home = QUrl::fromLocalFile(QDir::homePath());
|
||||
QUrl root = QUrl::fromLocalFile(QDir::rootPath());
|
||||
#ifdef Q_OS_WIN
|
||||
lister->openUrl(home, KDirLister::Keep);
|
||||
lister->openUrl(root, KDirLister::Keep | KDirLister::Reload);
|
||||
#else
|
||||
/* lister->openUrl( home, KDirLister::Keep );
|
||||
lister->openUrl( root, KDirLister::Keep | KDirLister::Reload );
|
||||
lister->openUrl( QUrl::fromLocalFile("file:/etc"), KDirLister::Keep | KDirLister::Reload );
|
||||
lister->openUrl( root, KDirLister::Keep | KDirLister::Reload );
|
||||
lister->openUrl( QUrl::fromLocalFile("file:/dev"), KDirLister::Keep | KDirLister::Reload );
|
||||
lister->openUrl( QUrl::fromLocalFile("file:/tmp"), KDirLister::Keep | KDirLister::Reload );
|
||||
lister->openUrl( QUrl::fromLocalFile("file:/usr/include"), KDirLister::Keep | KDirLister::Reload );
|
||||
lister->updateDirectory( QUrl::fromLocalFile("file:/usr/include") );
|
||||
lister->updateDirectory( QUrl::fromLocalFile("file:/usr/include") );
|
||||
lister->openUrl( QUrl::fromLocalFile("file:/usr/"), KDirLister::Keep | KDirLister::Reload );
|
||||
*/
|
||||
lister->openUrl(QUrl::fromLocalFile(QStringLiteral("/dev")), KDirLister::Keep | KDirLister::Reload);
|
||||
#endif
|
||||
}
|
||||
|
||||
void KDirListerTest::completed()
|
||||
{
|
||||
if (lister->url().toLocalFile() == QDir::rootPath()) {
|
||||
const KFileItem item = lister->findByUrl(QUrl::fromLocalFile(QDir::tempPath()));
|
||||
if (!item.isNull()) {
|
||||
qDebug() << "Found " << QDir::tempPath() << ": " << item.name();
|
||||
} else {
|
||||
qWarning() << QDir::tempPath() << " not found! Bug in findByURL?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication::setApplicationName(QStringLiteral("kdirlistertest"));
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.addHelpOption();
|
||||
parser.addPositionalArgument(QStringLiteral("URL"), QStringLiteral("URL to a directory to list."), QStringLiteral("[URL...]"));
|
||||
parser.process(app);
|
||||
QUrl url;
|
||||
if (!parser.positionalArguments().isEmpty()) {
|
||||
url = QUrl::fromUserInput(parser.positionalArguments().at(0));
|
||||
}
|
||||
|
||||
KDirListerTest *test = new KDirListerTest(nullptr, url);
|
||||
test->show();
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "moc_kdirlistertest_gui.cpp"
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
This file is part of the KDE desktop environment
|
||||
SPDX-FileCopyrightText: 2001, 2002 Michael Brade <brade@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef _KDIRLISTERTEST_GUI_H_
|
||||
#define _KDIRLISTERTEST_GUI_H_
|
||||
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
|
||||
#include <kdirlister.h>
|
||||
#include <kfileitem.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class PrintSignals : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PrintSignals()
|
||||
: QObject()
|
||||
{
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
void started(const QUrl &url)
|
||||
{
|
||||
cout << "*** started( " << url.url().toLocal8Bit().data() << " )" << endl;
|
||||
}
|
||||
void canceled()
|
||||
{
|
||||
cout << "canceled()" << endl;
|
||||
}
|
||||
void listingDirCanceled(const QUrl &url)
|
||||
{
|
||||
cout << "*** canceled( " << url.toDisplayString().toLocal8Bit().data() << " )" << endl;
|
||||
}
|
||||
void completed()
|
||||
{
|
||||
cout << "*** completed()" << endl;
|
||||
}
|
||||
void listingDirCompleted(const QUrl &url)
|
||||
{
|
||||
cout << "*** completed( " << url.toDisplayString().toLocal8Bit().data() << " )" << endl;
|
||||
}
|
||||
void redirection(const QUrl &src, const QUrl &dest)
|
||||
{
|
||||
cout << "*** redirection( " << src.toDisplayString().toLocal8Bit().data() << ", " << dest.toDisplayString().toLocal8Bit().data() << " )" << endl;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
cout << "*** clear()" << endl;
|
||||
}
|
||||
void newItems(const KFileItemList &items)
|
||||
{
|
||||
cout << "*** newItems: " << endl;
|
||||
for (auto it = items.cbegin(), itEnd = items.constEnd(); it != itEnd; ++it) {
|
||||
cout << (*it).name().toLocal8Bit().data() << endl;
|
||||
}
|
||||
}
|
||||
void itemsDeleted(const KFileItemList &)
|
||||
{
|
||||
cout << "*** itemsDeleted: " << endl;
|
||||
// TODO
|
||||
}
|
||||
void refreshItems(const QList<QPair<KFileItem, KFileItem>> &)
|
||||
{
|
||||
cout << "*** refreshItems: " << endl;
|
||||
// TODO
|
||||
}
|
||||
void infoMessage(const QString &msg)
|
||||
{
|
||||
cout << "*** infoMessage: " << msg.toLocal8Bit().data() << endl;
|
||||
}
|
||||
|
||||
void percent(int percent)
|
||||
{
|
||||
cout << "*** percent: " << percent << endl;
|
||||
}
|
||||
|
||||
void totalSize(KIO::filesize_t size)
|
||||
{
|
||||
cout << "*** totalSize: " << (long)size << endl;
|
||||
}
|
||||
|
||||
void processedSize(KIO::filesize_t size)
|
||||
{
|
||||
cout << "*** processedSize: " << (long)size << endl;
|
||||
}
|
||||
|
||||
void speed(int bytes_per_second)
|
||||
{
|
||||
cout << "*** speed: " << bytes_per_second << endl;
|
||||
}
|
||||
};
|
||||
|
||||
class KDirListerTest : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KDirListerTest(QWidget *parent = nullptr, const QUrl &url = {});
|
||||
~KDirListerTest() override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void startRoot();
|
||||
void startHome();
|
||||
void startTar();
|
||||
void test();
|
||||
void completed();
|
||||
|
||||
private:
|
||||
KDirLister *lister;
|
||||
PrintSignals *debug;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2006 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <kdirlister.h>
|
||||
#include <kdirmodel.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QListView>
|
||||
#include <QTreeView>
|
||||
#include <kfileitemdelegate.h>
|
||||
|
||||
// Test controller for making the view open up while expandToUrl lists subdirs
|
||||
class TreeController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TreeController(QTreeView *view, KDirModel *model)
|
||||
: QObject(view)
|
||||
, m_treeView(view)
|
||||
, m_model(model)
|
||||
{
|
||||
connect(model, &KDirModel::expand, this, &TreeController::slotExpand);
|
||||
}
|
||||
private Q_SLOTS:
|
||||
void slotExpand(const QModelIndex &index)
|
||||
{
|
||||
KFileItem item = m_model->itemForIndex(index);
|
||||
qDebug() << "slotListingCompleted" << item.url();
|
||||
m_treeView->setExpanded(index, true);
|
||||
|
||||
// The scrollTo call doesn't seem to work.
|
||||
// We probably need to delay this until everything's listed and layouted...
|
||||
m_treeView->scrollTo(index);
|
||||
}
|
||||
|
||||
private:
|
||||
QTreeView *m_treeView;
|
||||
KDirModel *m_model;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// options.add("+[directory ...]", qi18n("Directory(ies) to model"));
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
KDirModel *dirmodel = new KDirModel(nullptr);
|
||||
dirmodel->dirLister()->setDelayedMimeTypes(true);
|
||||
|
||||
#if 1
|
||||
QTreeView *treeView = new QTreeView(nullptr);
|
||||
treeView->setModel(dirmodel);
|
||||
treeView->setUniformRowHeights(true); // makes visualRect() much faster
|
||||
treeView->resize(500, 500);
|
||||
treeView->show();
|
||||
treeView->setItemDelegate(new KFileItemDelegate(treeView));
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
QListView *listView = new QListView(0);
|
||||
listView->setModel(dirmodel);
|
||||
listView->setUniformItemSizes(true); // true in list mode, not in icon mode.
|
||||
listView->show();
|
||||
listView->setItemDelegate(new KFileItemDelegate(listView));
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
QListView *iconView = new QListView(nullptr);
|
||||
iconView->setModel(dirmodel);
|
||||
iconView->setSelectionMode(QListView::ExtendedSelection);
|
||||
iconView->setViewMode(QListView::IconMode);
|
||||
iconView->show();
|
||||
iconView->setItemDelegate(new KFileItemDelegate(iconView));
|
||||
#endif
|
||||
|
||||
if (argc <= 1) {
|
||||
dirmodel->openUrl(QUrl(QStringLiteral("file:///")), KDirModel::ShowRoot);
|
||||
|
||||
const QUrl url = QUrl::fromLocalFile(QStringLiteral("/usr/share/applications"));
|
||||
dirmodel->expandToUrl(url);
|
||||
new TreeController(treeView, dirmodel);
|
||||
}
|
||||
|
||||
const int count = QCoreApplication::arguments().count() - 1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
QUrl u = QUrl::fromUserInput(QCoreApplication::arguments().at(i + 1));
|
||||
qDebug() << "Adding: " << u;
|
||||
dirmodel->dirLister()->openUrl(u, KDirLister::Keep);
|
||||
}
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
#include "kdirmodeltest_gui.moc"
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2021 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include <KEMailClientLauncherJob>
|
||||
#include <KIO/JobUiDelegate>
|
||||
#include <KIO/JobUiDelegateFactory>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
auto *job = new KEMailClientLauncherJob;
|
||||
job->setTo({QStringLiteral("David Faure <faure@kde.org>"), QStringLiteral("Another person <null@kde.org>")});
|
||||
job->setCc({QStringLiteral("CC me please <null@kde.org>")});
|
||||
job->setSubject(QStringLiteral("This is the test email's subject"));
|
||||
job->setBody(QStringLiteral("This email was created by kemailclientlauncherjobtest_gui in KIO."));
|
||||
const QStringList urls = app.arguments();
|
||||
QList<QUrl> attachments;
|
||||
std::transform(urls.cbegin(), urls.cend(), std::back_inserter(attachments), [](const QString &arg) {
|
||||
return QUrl::fromUserInput(arg, QDir::currentPath());
|
||||
});
|
||||
job->setAttachments(attachments);
|
||||
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, nullptr));
|
||||
job->start();
|
||||
|
||||
QObject::connect(job, &KJob::result, &app, [&]() {
|
||||
if (job->error()) {
|
||||
qWarning() << job->errorString();
|
||||
app.exit(1);
|
||||
} else {
|
||||
qDebug() << "Successfully started";
|
||||
app.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2013 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
#include <kencodingfiledialog.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
KEncodingFileDialog::Result result = KEncodingFileDialog::getOpenUrlsAndEncoding(QString(), QUrl(QStringLiteral("file:///etc/passwd")));
|
||||
qDebug() << result.fileNames << result.URLs << result.encoding;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Work sponsored by the LiMux project of the city of Munich
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include "kfilecustomdialog.h"
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication::setApplicationName(QStringLiteral("KFileCustomDialogTest_gui"));
|
||||
QApplication app(argc, argv);
|
||||
KFileCustomDialog dlg;
|
||||
QLabel *lab = new QLabel(QStringLiteral("foo"));
|
||||
dlg.setCustomWidget(lab);
|
||||
dlg.exec();
|
||||
|
||||
// Save dialog box
|
||||
KFileCustomDialog dlg2;
|
||||
dlg2.setOperationMode(KFileWidget::Saving);
|
||||
lab = new QLabel(QStringLiteral("Second"));
|
||||
dlg2.setCustomWidget(lab);
|
||||
dlg2.exec();
|
||||
|
||||
// Open dialog box
|
||||
KFileCustomDialog dlg3;
|
||||
dlg3.setOperationMode(KFileWidget::Opening);
|
||||
lab = new QLabel(QStringLiteral("Third"));
|
||||
dlg3.setCustomWidget(lab);
|
||||
dlg3.exec();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Work sponsored by the LiMux project of the city of Munich
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include "kfilecustomdialog.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication::setApplicationName(QStringLiteral("KFileCustomDialogTest_gui"));
|
||||
QApplication app(argc, argv);
|
||||
|
||||
KFileCustomDialog dlg;
|
||||
KFileWidget *fileWidget = dlg.fileWidget();
|
||||
fileWidget->setMode(KFile::Directory);
|
||||
dlg.setOperationMode(KFileWidget::Opening);
|
||||
dlg.setWindowTitle(QStringLiteral("Select folder"));
|
||||
|
||||
dlg.connect(dlg.fileWidget(), &KFileWidget::accepted, &app, [&dlg]() {
|
||||
qDebug() << "Selected dir URL:" << dlg.fileWidget()->selectedUrl();
|
||||
});
|
||||
dlg.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2015 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <KFileWidget>
|
||||
#include <QApplication>
|
||||
#include <QPushButton>
|
||||
#include <QUrl>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
KFileWidget *fileWidget = new KFileWidget(QUrl(QStringLiteral("kfiledialog:///OpenDialog")), nullptr);
|
||||
fileWidget->setMode(KFile::Files | KFile::ExistingOnly);
|
||||
fileWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
fileWidget->show();
|
||||
|
||||
app.connect(fileWidget, &KFileWidget::accepted, fileWidget, [&app, fileWidget]() {
|
||||
qDebug() << "accepted";
|
||||
fileWidget->accept();
|
||||
qDebug() << "Selected File:" << fileWidget->selectedFile();
|
||||
qDebug() << "Selected Url:" << fileWidget->selectedUrl();
|
||||
qDebug() << "Selected Files:" << fileWidget->selectedFiles();
|
||||
qDebug() << "Selected Urls:" << fileWidget->selectedUrls();
|
||||
app.exit();
|
||||
});
|
||||
|
||||
QObject::connect(fileWidget, &KFileWidget::destroyed, &app, &QApplication::quit);
|
||||
|
||||
fileWidget->okButton()->show();
|
||||
QObject::connect(fileWidget->okButton(), &QPushButton::clicked, fileWidget, &KFileWidget::slotOk);
|
||||
|
||||
fileWidget->cancelButton()->show();
|
||||
QObject::connect(fileWidget->cancelButton(), &QPushButton::clicked, &app, &QApplication::quit);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2019 Méven Car <meven.car@kdemail.net>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <KFileWidget>
|
||||
#include <QApplication>
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QPushButton>
|
||||
#include <QUrl>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// Do some args
|
||||
QCommandLineParser parser;
|
||||
parser.addOption(QCommandLineOption(QStringLiteral("multiple"), QStringLiteral("Allows multiple files selection")));
|
||||
parser.addPositionalArgument(QStringLiteral("folder"), QStringLiteral("The initial folder"));
|
||||
parser.process(app);
|
||||
QStringList posargs = parser.positionalArguments();
|
||||
|
||||
QUrl folder = QUrl(QStringLiteral("kfiledialog:///SaveDialog"));
|
||||
if (!posargs.isEmpty()) {
|
||||
folder = QUrl::fromUserInput(posargs.at(0));
|
||||
}
|
||||
qDebug() << "Starting at" << folder;
|
||||
KFileWidget *fileWidget = new KFileWidget(folder);
|
||||
fileWidget->setOperationMode(KFileWidget::Saving);
|
||||
if (parser.isSet(QStringLiteral("multiple"))) {
|
||||
fileWidget->setMode(KFile::Files);
|
||||
} else {
|
||||
fileWidget->setMode(KFile::File);
|
||||
}
|
||||
fileWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
fileWidget->okButton()->show();
|
||||
fileWidget->cancelButton()->show();
|
||||
app.connect(fileWidget->okButton(), &QPushButton::clicked, fileWidget, &KFileWidget::slotOk);
|
||||
app.connect(fileWidget->cancelButton(), &QPushButton::clicked, fileWidget, [&app, fileWidget]() {
|
||||
qDebug() << "canceled";
|
||||
fileWidget->slotCancel();
|
||||
app.exit();
|
||||
});
|
||||
|
||||
app.connect(fileWidget, &KFileWidget::accepted, fileWidget, [&app, fileWidget]() {
|
||||
qDebug() << "accepted";
|
||||
fileWidget->accept();
|
||||
qDebug() << "Selected File:" << fileWidget->selectedFile();
|
||||
qDebug() << "Selected Url:" << fileWidget->selectedUrl();
|
||||
qDebug() << "Selected Files:" << fileWidget->selectedFiles();
|
||||
qDebug() << "Selected Urls:" << fileWidget->selectedUrls();
|
||||
app.exit();
|
||||
});
|
||||
|
||||
fileWidget->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,548 @@
|
||||
/*
|
||||
This file is or will be part of KDE desktop environment
|
||||
SPDX-FileCopyrightText: 1999 Matt Koss <koss@miesto.sk>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include "kioworkertest.h"
|
||||
|
||||
#include "../src/utils_p.h"
|
||||
|
||||
#include <kio/copyjob.h>
|
||||
#include <kio/deletejob.h>
|
||||
#include <kio/listjob.h>
|
||||
#include <kio/mimetypejob.h>
|
||||
#include <kio/mkdirjob.h>
|
||||
#include <kio/simplejob.h>
|
||||
#include <kio/statjob.h>
|
||||
#include <kio/transferjob.h>
|
||||
#include <kprotocolinfo.h>
|
||||
|
||||
// QT_STAT_LNK on Windows
|
||||
#include "kioglobal_p.h"
|
||||
|
||||
#include <KJobUiDelegate>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QGroupBox>
|
||||
#include <QLayout>
|
||||
#include <QLocale>
|
||||
#include <QMessageBox>
|
||||
#include <QStatusBar>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <qplatformdefs.h>
|
||||
|
||||
using namespace KIO;
|
||||
|
||||
KioWorkerTest::KioWorkerTest(QString src, QString dest, uint op, uint pr)
|
||||
: QMainWindow(nullptr)
|
||||
{
|
||||
job = nullptr;
|
||||
|
||||
main_widget = new QWidget(this);
|
||||
QBoxLayout *topLayout = new QVBoxLayout(main_widget);
|
||||
|
||||
QGridLayout *grid = new QGridLayout();
|
||||
topLayout->addLayout(grid);
|
||||
|
||||
grid->setRowStretch(0, 1);
|
||||
grid->setRowStretch(1, 1);
|
||||
|
||||
grid->setColumnStretch(0, 1);
|
||||
grid->setColumnStretch(1, 100);
|
||||
|
||||
lb_from = new QLabel(QStringLiteral("From:"), main_widget);
|
||||
grid->addWidget(lb_from, 0, 0);
|
||||
|
||||
le_source = new QLineEdit(main_widget);
|
||||
grid->addWidget(le_source, 0, 1);
|
||||
le_source->setText(src);
|
||||
|
||||
lb_to = new QLabel(QStringLiteral("To:"), main_widget);
|
||||
grid->addWidget(lb_to, 1, 0);
|
||||
|
||||
le_dest = new QLineEdit(main_widget);
|
||||
grid->addWidget(le_dest, 1, 1);
|
||||
le_dest->setText(dest);
|
||||
|
||||
// Operation groupbox & buttons
|
||||
opButtons = new QButtonGroup(main_widget);
|
||||
QGroupBox *box = new QGroupBox(QStringLiteral("Operation"), main_widget);
|
||||
topLayout->addWidget(box, 10);
|
||||
connect(opButtons, &QButtonGroup::buttonClicked, this, &KioWorkerTest::changeOperation);
|
||||
|
||||
QBoxLayout *hbLayout = new QHBoxLayout(box);
|
||||
|
||||
rbList = new QRadioButton(QStringLiteral("List"), box);
|
||||
opButtons->addButton(rbList);
|
||||
hbLayout->addWidget(rbList, 5);
|
||||
|
||||
rbListRecursive = new QRadioButton(QStringLiteral("ListRecursive"), box);
|
||||
opButtons->addButton(rbListRecursive);
|
||||
hbLayout->addWidget(rbListRecursive, 5);
|
||||
|
||||
rbStat = new QRadioButton(QStringLiteral("Stat"), box);
|
||||
opButtons->addButton(rbStat);
|
||||
hbLayout->addWidget(rbStat, 5);
|
||||
|
||||
rbGet = new QRadioButton(QStringLiteral("Get"), box);
|
||||
opButtons->addButton(rbGet);
|
||||
hbLayout->addWidget(rbGet, 5);
|
||||
|
||||
rbPut = new QRadioButton(QStringLiteral("Put"), box);
|
||||
opButtons->addButton(rbPut);
|
||||
hbLayout->addWidget(rbPut, 5);
|
||||
|
||||
rbCopy = new QRadioButton(QStringLiteral("Copy"), box);
|
||||
opButtons->addButton(rbCopy);
|
||||
hbLayout->addWidget(rbCopy, 5);
|
||||
|
||||
rbMove = new QRadioButton(QStringLiteral("Move"), box);
|
||||
opButtons->addButton(rbMove);
|
||||
hbLayout->addWidget(rbMove, 5);
|
||||
|
||||
rbDelete = new QRadioButton(QStringLiteral("Delete"), box);
|
||||
opButtons->addButton(rbDelete);
|
||||
hbLayout->addWidget(rbDelete, 5);
|
||||
|
||||
rbMkdir = new QRadioButton(QStringLiteral("Mkdir"), box);
|
||||
opButtons->addButton(rbMkdir);
|
||||
hbLayout->addWidget(rbMkdir, 5);
|
||||
|
||||
rbMimetype = new QRadioButton(QStringLiteral("Mimetype"), box);
|
||||
opButtons->addButton(rbMimetype);
|
||||
hbLayout->addWidget(rbMimetype, 5);
|
||||
|
||||
QAbstractButton *b = opButtons->buttons()[op];
|
||||
b->setChecked(true);
|
||||
changeOperation(b);
|
||||
|
||||
// Progress groupbox & buttons
|
||||
progressButtons = new QButtonGroup(main_widget);
|
||||
box = new QGroupBox(QStringLiteral("Progress dialog mode"), main_widget);
|
||||
topLayout->addWidget(box, 10);
|
||||
connect(progressButtons, &QButtonGroup::buttonClicked, this, &KioWorkerTest::changeProgressMode);
|
||||
|
||||
hbLayout = new QHBoxLayout(box);
|
||||
|
||||
rbProgressNone = new QRadioButton(QStringLiteral("None"), box);
|
||||
progressButtons->addButton(rbProgressNone);
|
||||
hbLayout->addWidget(rbProgressNone, 5);
|
||||
|
||||
rbProgressDefault = new QRadioButton(QStringLiteral("Default"), box);
|
||||
progressButtons->addButton(rbProgressDefault);
|
||||
hbLayout->addWidget(rbProgressDefault, 5);
|
||||
|
||||
rbProgressStatus = new QRadioButton(QStringLiteral("Status"), box);
|
||||
progressButtons->addButton(rbProgressStatus);
|
||||
hbLayout->addWidget(rbProgressStatus, 5);
|
||||
|
||||
b = progressButtons->buttons()[pr];
|
||||
b->setChecked(true);
|
||||
changeProgressMode(b);
|
||||
|
||||
// statusbar progress widget
|
||||
statusTracker = new KStatusBarJobTracker(statusBar());
|
||||
|
||||
// run & stop buttons
|
||||
hbLayout = new QHBoxLayout();
|
||||
topLayout->addLayout(hbLayout);
|
||||
hbLayout->setParent(topLayout);
|
||||
|
||||
pbStart = new QPushButton(QStringLiteral("&Start"), main_widget);
|
||||
pbStart->setFixedSize(pbStart->sizeHint());
|
||||
connect(pbStart, &QAbstractButton::clicked, this, &KioWorkerTest::startJob);
|
||||
hbLayout->addWidget(pbStart, 5);
|
||||
|
||||
pbStop = new QPushButton(QStringLiteral("Sto&p"), main_widget);
|
||||
pbStop->setFixedSize(pbStop->sizeHint());
|
||||
pbStop->setEnabled(false);
|
||||
connect(pbStop, &QAbstractButton::clicked, this, &KioWorkerTest::stopJob);
|
||||
hbLayout->addWidget(pbStop, 5);
|
||||
|
||||
// close button
|
||||
close = new QPushButton(QStringLiteral("&Close"), main_widget);
|
||||
close->setFixedSize(close->sizeHint());
|
||||
connect(close, &QAbstractButton::clicked, this, &KioWorkerTest::slotQuit);
|
||||
|
||||
topLayout->addWidget(close, 5);
|
||||
|
||||
main_widget->setMinimumSize(main_widget->sizeHint());
|
||||
setCentralWidget(main_widget);
|
||||
}
|
||||
|
||||
void KioWorkerTest::slotQuit()
|
||||
{
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
void KioWorkerTest::changeOperation(QAbstractButton *b)
|
||||
{
|
||||
// only two urls for copy and move
|
||||
bool enab = rbCopy->isChecked() || rbMove->isChecked();
|
||||
|
||||
le_dest->setEnabled(enab);
|
||||
|
||||
selectedOperation = opButtons->buttons().indexOf(b);
|
||||
}
|
||||
|
||||
void KioWorkerTest::changeProgressMode(QAbstractButton *b)
|
||||
{
|
||||
progressMode = progressButtons->buttons().indexOf(b);
|
||||
|
||||
if (progressMode == ProgressStatus) {
|
||||
statusBar()->show();
|
||||
} else {
|
||||
statusBar()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void KioWorkerTest::startJob()
|
||||
{
|
||||
QUrl sCurrent(QUrl::fromLocalFile(QDir::currentPath()));
|
||||
QString sSrc(le_source->text());
|
||||
QUrl src = QUrl(sCurrent).resolved(QUrl(sSrc));
|
||||
|
||||
if (!src.isValid()) {
|
||||
QMessageBox::critical(this, QStringLiteral("KioWorker Error Message"), QStringLiteral("Source URL is malformed"));
|
||||
return;
|
||||
}
|
||||
|
||||
QString sDest(le_dest->text());
|
||||
QUrl dest = QUrl(sCurrent).resolved(QUrl(sDest));
|
||||
|
||||
if (!dest.isValid() && (selectedOperation == Copy || selectedOperation == Move)) {
|
||||
QMessageBox::critical(this, QStringLiteral("KioWorker Error Message"), QStringLiteral("Destination URL is malformed"));
|
||||
return;
|
||||
}
|
||||
|
||||
pbStart->setEnabled(false);
|
||||
|
||||
KIO::JobFlags observe = DefaultFlags;
|
||||
if (progressMode != ProgressDefault) {
|
||||
observe = HideProgressInfo;
|
||||
}
|
||||
|
||||
switch (selectedOperation) {
|
||||
case List: {
|
||||
KIO::ListJob *listJob = KIO::listDir(src);
|
||||
job = listJob;
|
||||
connect(listJob, &KIO::ListJob::entries, this, &KioWorkerTest::slotEntries);
|
||||
break;
|
||||
}
|
||||
|
||||
case ListRecursive: {
|
||||
KIO::ListJob *listJob = KIO::listRecursive(src);
|
||||
job = listJob;
|
||||
connect(listJob, &KIO::ListJob::entries, this, &KioWorkerTest::slotEntries);
|
||||
break;
|
||||
}
|
||||
|
||||
case Stat:
|
||||
job = KIO::stat(src);
|
||||
break;
|
||||
|
||||
case Get: {
|
||||
KIO::TransferJob *tjob = KIO::get(src, KIO::Reload);
|
||||
job = tjob;
|
||||
connect(tjob, &KIO::TransferJob::data, this, &KioWorkerTest::slotData);
|
||||
break;
|
||||
}
|
||||
|
||||
case Put: {
|
||||
putBuffer = 0;
|
||||
KIO::TransferJob *tjob = KIO::put(src, -1, KIO::Overwrite);
|
||||
tjob->setTotalSize(48 * 1024 * 1024);
|
||||
job = tjob;
|
||||
connect(tjob, &TransferJob::dataReq, this, &KioWorkerTest::slotDataReq);
|
||||
break;
|
||||
}
|
||||
|
||||
case Copy:
|
||||
job = KIO::copy(src, dest, observe);
|
||||
break;
|
||||
|
||||
case Move:
|
||||
job = KIO::move(src, dest, observe);
|
||||
break;
|
||||
|
||||
case Delete:
|
||||
job = KIO::del(src, observe);
|
||||
break;
|
||||
|
||||
case Mkdir:
|
||||
job = KIO::mkdir(src);
|
||||
break;
|
||||
|
||||
case Mimetype:
|
||||
job = KIO::mimetype(src);
|
||||
break;
|
||||
}
|
||||
|
||||
statusBar()->addWidget(statusTracker->widget(job), 0);
|
||||
|
||||
connect(job, &KJob::result, this, &KioWorkerTest::slotResult);
|
||||
|
||||
if (progressMode == ProgressStatus) {
|
||||
statusTracker->registerJob(job);
|
||||
}
|
||||
|
||||
pbStop->setEnabled(true);
|
||||
}
|
||||
|
||||
void KioWorkerTest::slotResult(KJob *_job)
|
||||
{
|
||||
if (_job->error()) {
|
||||
_job->uiDelegate()->showErrorMessage();
|
||||
} else if (selectedOperation == Stat) {
|
||||
UDSEntry entry = static_cast<KIO::StatJob *>(_job)->statResult();
|
||||
printUDSEntry(entry);
|
||||
} else if (selectedOperation == Mimetype) {
|
||||
qDebug() << "MIME type is " << static_cast<KIO::MimetypeJob *>(_job)->mimetype();
|
||||
}
|
||||
|
||||
if (job == _job) {
|
||||
job = nullptr;
|
||||
}
|
||||
|
||||
pbStart->setEnabled(true);
|
||||
pbStop->setEnabled(false);
|
||||
|
||||
// statusBar()->removeWidget( statusTracker->widget(job) );
|
||||
}
|
||||
|
||||
void KioWorkerTest::printUDSEntry(const KIO::UDSEntry &entry)
|
||||
{
|
||||
// It's rather rare to iterate that way, usually you'd use numberValue/stringValue directly.
|
||||
// This is just to print out all that we got
|
||||
|
||||
QDateTime timestamp;
|
||||
|
||||
const QList<uint> keys = entry.fields();
|
||||
for (auto it = keys.cbegin(); it != keys.cend(); ++it) {
|
||||
switch (*it) {
|
||||
case KIO::UDSEntry::UDS_FILE_TYPE: {
|
||||
mode_t mode = (mode_t)entry.numberValue(*it);
|
||||
qDebug() << "File Type : " << mode;
|
||||
if (Utils::isDirMask(mode)) {
|
||||
qDebug() << "is a dir";
|
||||
}
|
||||
if (Utils::isLinkMask(mode)) {
|
||||
qDebug() << "is a link";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KIO::UDSEntry::UDS_ACCESS:
|
||||
qDebug() << "Access permissions : " << (mode_t)(entry.numberValue(*it));
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_USER:
|
||||
qDebug() << "User : " << (entry.stringValue(*it));
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_GROUP:
|
||||
qDebug() << "Group : " << (entry.stringValue(*it));
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_LOCAL_USER_ID:
|
||||
qDebug() << "User id : " << (entry.numberValue(*it));
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_LOCAL_GROUP_ID:
|
||||
qDebug() << "Group id : " << (entry.numberValue(*it));
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_NAME:
|
||||
qDebug() << "Name : " << (entry.stringValue(*it));
|
||||
// m_strText = decodeFileName( it.value().toString() );
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_URL:
|
||||
qDebug() << "URL : " << (entry.stringValue(*it));
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_MIME_TYPE:
|
||||
qDebug() << "MimeType : " << (entry.stringValue(*it));
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_LINK_DEST:
|
||||
qDebug() << "LinkDest : " << (entry.stringValue(*it));
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_SIZE:
|
||||
qDebug() << "Size: " << KIO::convertSize(entry.numberValue(*it));
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_CREATION_TIME:
|
||||
timestamp = QDateTime::fromSecsSinceEpoch(entry.numberValue(*it));
|
||||
qDebug() << "CreationTime: " << QLocale().toString(timestamp, QLocale::ShortFormat);
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_MODIFICATION_TIME:
|
||||
timestamp = QDateTime::fromSecsSinceEpoch(entry.numberValue(*it));
|
||||
qDebug() << "ModificationTime: " << QLocale().toString(timestamp, QLocale::ShortFormat);
|
||||
break;
|
||||
case KIO::UDSEntry::UDS_ACCESS_TIME:
|
||||
timestamp = QDateTime::fromSecsSinceEpoch(entry.numberValue(*it));
|
||||
qDebug() << "AccessTime: " << QLocale().toString(timestamp, QLocale::ShortFormat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KioWorkerTest::slotEntries(KIO::Job *job, const KIO::UDSEntryList &list)
|
||||
{
|
||||
QUrl url = static_cast<KIO::ListJob *>(job)->url();
|
||||
KProtocolInfo::ExtraFieldList extraFields = KProtocolInfo::extraFields(url);
|
||||
UDSEntryList::ConstIterator it = list.begin();
|
||||
for (; it != list.end(); ++it) {
|
||||
// For each file...
|
||||
QString name = (*it).stringValue(KIO::UDSEntry::UDS_NAME);
|
||||
qDebug() << name;
|
||||
|
||||
KProtocolInfo::ExtraFieldList::Iterator extraFieldsIt = extraFields.begin();
|
||||
const QList<uint> fields = it->fields();
|
||||
QList<uint>::ConstIterator it2 = fields.begin();
|
||||
for (; it2 != fields.end(); it2++) {
|
||||
if (*it2 >= UDSEntry::UDS_EXTRA && *it2 <= UDSEntry::UDS_EXTRA_END) {
|
||||
if (extraFieldsIt != extraFields.end()) {
|
||||
QString column = (*extraFieldsIt).name;
|
||||
// QString type = (*extraFieldsIt).type;
|
||||
qDebug() << " Extra data (" << column << ") :" << it->stringValue(*it2);
|
||||
++extraFieldsIt;
|
||||
} else {
|
||||
qDebug() << " Extra data (UNDEFINED) :" << it->stringValue(*it2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KioWorkerTest::slotData(KIO::Job *, const QByteArray &data)
|
||||
{
|
||||
if (data.size() == 0) {
|
||||
qDebug() << "Data: <End>";
|
||||
} else {
|
||||
qDebug() << "Data: \"" << QString::fromUtf8(data) << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
void KioWorkerTest::slotDataReq(KIO::Job *, QByteArray &data)
|
||||
{
|
||||
/* clang-format off */
|
||||
const char *fileDataArray[] = {
|
||||
"Hello world\n",
|
||||
"This is a test file\n",
|
||||
"You can safely delete it.\n",
|
||||
"BIG\n",
|
||||
"BIG1\n",
|
||||
"BIG2\n",
|
||||
"BIG3\n",
|
||||
"BIG4\n",
|
||||
"BIG5\n",
|
||||
nullptr
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
const char *fileData = fileDataArray[putBuffer++];
|
||||
|
||||
if (!fileData) {
|
||||
qDebug() << "DataReq: <End>";
|
||||
return;
|
||||
}
|
||||
if (!strncmp(fileData, "BIG", 3)) {
|
||||
data.fill(0, 8 * 1024 * 1024);
|
||||
} else {
|
||||
data = QByteArray(fileData, strlen(fileData));
|
||||
}
|
||||
qDebug() << "DataReq: \"" << fileData << "\"";
|
||||
QThread::sleep(1); // want to see progress info...
|
||||
}
|
||||
|
||||
void KioWorkerTest::stopJob()
|
||||
{
|
||||
qDebug() << "KioWorkerTest::stopJob()";
|
||||
job->kill();
|
||||
job = nullptr;
|
||||
|
||||
pbStop->setEnabled(false);
|
||||
pbStart->setEnabled(true);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char version[] = "v0.0.0 0000"; // :-)
|
||||
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationVersion(QString::fromLatin1(version));
|
||||
|
||||
uint op = KioWorkerTest::Copy;
|
||||
uint pr = 0;
|
||||
QString src;
|
||||
QString dest;
|
||||
QString operation;
|
||||
{
|
||||
QCommandLineParser parser;
|
||||
parser.addVersionOption();
|
||||
parser.setApplicationDescription(QStringLiteral("Test for KIO workers"));
|
||||
parser.addHelpOption();
|
||||
parser.addOption(
|
||||
QCommandLineOption(QStringList() << QStringLiteral("s") << QStringLiteral("src"), QStringLiteral("Source URL"), QStringLiteral("url")));
|
||||
parser.addOption(
|
||||
QCommandLineOption(QStringList() << QStringLiteral("d") << QStringLiteral("dest"), QStringLiteral("Destination URL"), QStringLiteral("url")));
|
||||
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("o") << QStringLiteral("operation"),
|
||||
QStringLiteral("Operation (list,listrecursive,stat,get,put,copy,move,del,mkdir)"),
|
||||
QStringLiteral("operation")));
|
||||
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("p") << QStringLiteral("progress"),
|
||||
QStringLiteral("Progress Type (none,default,status)"),
|
||||
QStringLiteral("progress"),
|
||||
QStringLiteral("default")));
|
||||
parser.process(app);
|
||||
|
||||
src = parser.value(QStringLiteral("src"));
|
||||
dest = parser.value(QStringLiteral("dest"));
|
||||
|
||||
operation = parser.value(QStringLiteral("operation"));
|
||||
if (operation == QLatin1String("list")) {
|
||||
op = KioWorkerTest::List;
|
||||
} else if (operation == QLatin1String("listrecursive")) {
|
||||
op = KioWorkerTest::ListRecursive;
|
||||
} else if (operation == QLatin1String("stat")) {
|
||||
op = KioWorkerTest::Stat;
|
||||
} else if (operation == QLatin1String("get")) {
|
||||
op = KioWorkerTest::Get;
|
||||
} else if (operation == QLatin1String("put")) {
|
||||
op = KioWorkerTest::Put;
|
||||
} else if (operation == QLatin1String("copy")) {
|
||||
op = KioWorkerTest::Copy;
|
||||
} else if (operation == QLatin1String("move")) {
|
||||
op = KioWorkerTest::Move;
|
||||
} else if (operation == QLatin1String("del")) {
|
||||
op = KioWorkerTest::Delete;
|
||||
} else if (operation == QLatin1String("mkdir")) {
|
||||
op = KioWorkerTest::Mkdir;
|
||||
} else if (!operation.isEmpty()) {
|
||||
qWarning("Unknown operation, see --help");
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString progress = parser.value(QStringLiteral("progress"));
|
||||
if (progress == QLatin1String("none")) {
|
||||
pr = KioWorkerTest::ProgressNone;
|
||||
} else if (progress == QLatin1String("default")) {
|
||||
pr = KioWorkerTest::ProgressDefault;
|
||||
} else if (progress == QLatin1String("status")) {
|
||||
pr = KioWorkerTest::ProgressStatus;
|
||||
} else {
|
||||
qWarning("Unknown progress mode, see --help");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
KioWorkerTest *test = new KioWorkerTest(src, dest, op, pr);
|
||||
if (!operation.isEmpty()) {
|
||||
QTimer::singleShot(100, test, SLOT(startJob()));
|
||||
}
|
||||
test->show();
|
||||
test->resize(test->sizeHint());
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "moc_kioworkertest.cpp"
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
This file is or will be part of KDE desktop environment
|
||||
SPDX-FileCopyrightText: 1999 Matt Koss <koss@miesto.sk>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#ifndef _KIOWORKERTEST_H
|
||||
#define _KIOWORKERTEST_H
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMainWindow>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include "kio/global.h"
|
||||
#include <kio/simplejob.h>
|
||||
#include <kio/udsentry.h>
|
||||
|
||||
#include <KStatusBarJobTracker>
|
||||
|
||||
class KioWorkerTest : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KioWorkerTest(QString src, QString dest, uint op, uint pr);
|
||||
|
||||
~KioWorkerTest() override
|
||||
{
|
||||
if (job) {
|
||||
job->kill(KJob::Quietly); // kill the job quietly
|
||||
}
|
||||
}
|
||||
|
||||
enum Operations {
|
||||
List = 0,
|
||||
ListRecursive,
|
||||
Stat,
|
||||
Get,
|
||||
Put,
|
||||
Copy,
|
||||
Move,
|
||||
Delete,
|
||||
Mkdir,
|
||||
Mimetype
|
||||
};
|
||||
|
||||
enum ProgressModes {
|
||||
ProgressNone = 0,
|
||||
ProgressDefault,
|
||||
ProgressStatus
|
||||
};
|
||||
|
||||
protected:
|
||||
void printUDSEntry(const KIO::UDSEntry &entry);
|
||||
|
||||
// info stuff
|
||||
QLabel *lb_from;
|
||||
QLineEdit *le_source;
|
||||
|
||||
QLabel *lb_to;
|
||||
QLineEdit *le_dest;
|
||||
|
||||
// operation stuff
|
||||
QButtonGroup *opButtons;
|
||||
|
||||
QRadioButton *rbList;
|
||||
QRadioButton *rbListRecursive;
|
||||
QRadioButton *rbStat;
|
||||
QRadioButton *rbGet;
|
||||
QRadioButton *rbPut;
|
||||
QRadioButton *rbCopy;
|
||||
QRadioButton *rbMove;
|
||||
QRadioButton *rbDelete;
|
||||
QRadioButton *rbMkdir;
|
||||
QRadioButton *rbMimetype;
|
||||
|
||||
// progress stuff
|
||||
QButtonGroup *progressButtons;
|
||||
|
||||
QRadioButton *rbProgressNone;
|
||||
QRadioButton *rbProgressDefault;
|
||||
QRadioButton *rbProgressStatus;
|
||||
|
||||
QPushButton *pbStart;
|
||||
QPushButton *pbStop;
|
||||
|
||||
QPushButton *close;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void changeOperation(QAbstractButton *b);
|
||||
void changeProgressMode(QAbstractButton *b);
|
||||
|
||||
void startJob();
|
||||
void stopJob();
|
||||
|
||||
void slotResult(KJob *);
|
||||
void slotEntries(KIO::Job *, const KIO::UDSEntryList &);
|
||||
void slotData(KIO::Job *, const QByteArray &data);
|
||||
void slotDataReq(KIO::Job *, QByteArray &data);
|
||||
|
||||
void slotQuit();
|
||||
|
||||
private:
|
||||
KIO::Job *job;
|
||||
QWidget *main_widget;
|
||||
|
||||
KStatusBarJobTracker *statusTracker;
|
||||
|
||||
int selectedOperation;
|
||||
int progressMode;
|
||||
int putBuffer;
|
||||
};
|
||||
|
||||
#endif // _KIOWORKERTEST_H
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2002, 2003 Stephan Kulow <coolo@kde.org>
|
||||
SPDX-FileCopyrightText: 2003 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
#include <kmountpoint.h>
|
||||
|
||||
// This is a test program for KMountPoint
|
||||
|
||||
// Call it with either a device path or a mount point.
|
||||
// It will try both, so obviously one will fail.
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
QUrl url;
|
||||
if (argc > 1) {
|
||||
url = QUrl::fromUserInput(QString::fromUtf8(argv[1]));
|
||||
} else {
|
||||
url = QUrl::fromLocalFile(QDir::currentPath());
|
||||
}
|
||||
|
||||
const KMountPoint::List mountPoints = KMountPoint::currentMountPoints();
|
||||
|
||||
KMountPoint::Ptr mp = mountPoints.findByDevice(url.toLocalFile());
|
||||
if (!mp) {
|
||||
qDebug() << "no mount point for device" << url << "found";
|
||||
} else {
|
||||
qDebug() << mp->mountPoint() << "is the mount point for device" << url;
|
||||
}
|
||||
|
||||
mp = mountPoints.findByPath(url.toLocalFile());
|
||||
if (!mp) {
|
||||
qDebug() << "no mount point for path" << url << "found";
|
||||
} else {
|
||||
qDebug() << mp->mountPoint() << "is the mount point for path" << url;
|
||||
qDebug() << url << "is probably" << (mp->probablySlow() ? "slow" : "normal") << "mounted";
|
||||
}
|
||||
|
||||
url = QUrl::fromLocalFile(QDir::homePath());
|
||||
|
||||
mp = mountPoints.findByPath(url.toLocalFile());
|
||||
if (!mp) {
|
||||
qDebug() << "no mount point for path" << url << "found";
|
||||
} else {
|
||||
qDebug() << mp->mountPoint() << "is the mount point for path" << url;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2002 Dirk Mueller <mueller@kde.org>
|
||||
SPDX-FileCopyrightText: 2003 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
#include <kopenwithdialog.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication::setApplicationName(QStringLiteral("kopenwithdialogtest"));
|
||||
QApplication app(argc, argv);
|
||||
QList<QUrl> list;
|
||||
|
||||
list += QUrl(QStringLiteral("file:///tmp/testfile.txt"));
|
||||
|
||||
// Test with one URL
|
||||
KOpenWithDialog *dlg = new KOpenWithDialog(list, QString(), QString());
|
||||
if (dlg->exec()) {
|
||||
qDebug() << "Dialog ended successfully\ntext: " << dlg->text();
|
||||
} else {
|
||||
qDebug() << "Dialog was canceled.";
|
||||
}
|
||||
delete dlg;
|
||||
|
||||
// Test with two URLs
|
||||
list += QUrl(QStringLiteral("http://www.kde.org/index.html"));
|
||||
dlg = new KOpenWithDialog(list, QString(), QString(), nullptr);
|
||||
if (dlg->exec()) {
|
||||
qDebug() << "Dialog ended successfully\ntext: " << dlg->text();
|
||||
} else {
|
||||
qDebug() << "Dialog was canceled.";
|
||||
}
|
||||
delete dlg;
|
||||
|
||||
// Test with a MIME type
|
||||
QString mimetype = QStringLiteral("text/plain");
|
||||
dlg = new KOpenWithDialog(mimetype, QStringLiteral("kwrite"), nullptr);
|
||||
if (dlg->exec()) {
|
||||
qDebug() << "Dialog ended successfully\ntext: " << dlg->text();
|
||||
} else {
|
||||
qDebug() << "Dialog was canceled.";
|
||||
}
|
||||
delete dlg;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <kpropertiesdialog.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
if (argc <= 1) {
|
||||
qWarning() << "Expected argument: [url], the path or url to the file/dir for which to show properties";
|
||||
return 1;
|
||||
}
|
||||
const QUrl u = QUrl::fromUserInput(QString::fromLatin1(argv[1]), QDir::currentPath());
|
||||
|
||||
{
|
||||
KPropertiesDialog dlg(u);
|
||||
QObject::connect(&dlg, &KPropertiesDialog::applied, []() {
|
||||
qDebug() << "applied";
|
||||
});
|
||||
QObject::connect(&dlg, &KPropertiesDialog::canceled, []() {
|
||||
qDebug() << "canceled";
|
||||
});
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2015 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <KProtocolInfo>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
qDebug() << KProtocolInfo::protocols();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2002 David Faure <faure@kde.org>
|
||||
SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include "kruntest.h"
|
||||
|
||||
#include <KIO/ApplicationLauncherJob>
|
||||
#include <KIO/JobUiDelegate>
|
||||
#include <KIO/JobUiDelegateFactory>
|
||||
#include <KIO/OpenUrlJob>
|
||||
|
||||
#include <KService>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QPushButton>
|
||||
#include <QTest> // QFINDTESTDATA
|
||||
|
||||
#include <QDir>
|
||||
#include <qplatformdefs.h>
|
||||
|
||||
static const int s_maxJobs = 100;
|
||||
|
||||
static KIO::OpenUrlJob *jobArray[s_maxJobs];
|
||||
|
||||
static const char testFile[] = "kruntest.cpp";
|
||||
|
||||
static const struct {
|
||||
const char *text;
|
||||
const char *expectedResult;
|
||||
const char *exec;
|
||||
const char *url;
|
||||
} s_tests[] = {
|
||||
{"run(kwrite, no url)", "should work normally", "kwrite", nullptr},
|
||||
{"run(kwrite, file url)", "should work normally", "kwrite", testFile},
|
||||
{"run(kwrite, remote url)", "should work normally", "kwrite", "http://www.kde.org"},
|
||||
{"run(doesnotexit, no url)", "should show error message", "doesnotexist", nullptr},
|
||||
{"run(doesnotexit, file url)", "should show error message", "doesnotexist", testFile},
|
||||
{"run(doesnotexit, remote url)", "should use kioexec and show error message", "doesnotexist", "http://www.kde.org"},
|
||||
{"run(not-executable-desktopfile)", "should ask for confirmation", "nonexec", nullptr},
|
||||
{"run(missing lib, no url)",
|
||||
"should show error message (remove libqca-qt5.so.2 for this, e.g. by editing LD_LIBRARY_PATH if qca is in its own prefix)",
|
||||
"qcatool-qt5",
|
||||
nullptr},
|
||||
{"run(missing lib, file url)",
|
||||
"should show error message (remove libqca-qt5.so.2 for this, e.g. by editing LD_LIBRARY_PATH if qca is in its own prefix)",
|
||||
"qcatool-qt5",
|
||||
testFile},
|
||||
{"run(missing lib, remote url)",
|
||||
"should show error message (remove libqca-qt5.so.2 for this, e.g. by editing LD_LIBRARY_PATH if qca is in its own prefix)",
|
||||
"qcatool-qt5",
|
||||
"http://www.kde.org"},
|
||||
};
|
||||
|
||||
Receiver::Receiver()
|
||||
{
|
||||
QVBoxLayout *lay = new QVBoxLayout(this);
|
||||
QPushButton *btn = new QPushButton(QStringLiteral("Press here to terminate"), this);
|
||||
lay->addWidget(btn);
|
||||
connect(btn, &QPushButton::clicked, qApp, &QApplication::quit);
|
||||
|
||||
start = new QPushButton(QStringLiteral("Launch OpenUrlJobs"), this);
|
||||
lay->addWidget(start);
|
||||
connect(start, &QAbstractButton::clicked, this, &Receiver::slotStart);
|
||||
|
||||
stop = new QPushButton(QStringLiteral("Stop those OpenUrlJobs"), this);
|
||||
stop->setEnabled(false);
|
||||
lay->addWidget(stop);
|
||||
connect(stop, &QAbstractButton::clicked, this, &Receiver::slotStop);
|
||||
|
||||
QPushButton *launchOne = new QPushButton(QStringLiteral("Launch one http OpenUrlJob"), this);
|
||||
lay->addWidget(launchOne);
|
||||
connect(launchOne, &QAbstractButton::clicked, this, &Receiver::slotLaunchOne);
|
||||
|
||||
for (uint i = 0; i < sizeof(s_tests) / sizeof(*s_tests); ++i) {
|
||||
QHBoxLayout *hbox = new QHBoxLayout;
|
||||
lay->addLayout(hbox);
|
||||
QPushButton *button = new QPushButton(QString::fromUtf8(s_tests[i].text), this);
|
||||
button->setProperty("testNumber", i);
|
||||
hbox->addWidget(button);
|
||||
QLabel *label = new QLabel(QString::fromUtf8(s_tests[i].expectedResult), this);
|
||||
hbox->addWidget(label);
|
||||
connect(button, &QAbstractButton::clicked, this, [this, button]() {
|
||||
slotLaunchTest(button);
|
||||
});
|
||||
hbox->addStretch();
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
show();
|
||||
}
|
||||
|
||||
void Receiver::slotLaunchTest(QPushButton *sender)
|
||||
{
|
||||
const int testNumber = sender->property("testNumber").toInt();
|
||||
QList<QUrl> urls;
|
||||
if (s_tests[testNumber].url) {
|
||||
QString urlStr = QString::fromUtf8(s_tests[testNumber].url);
|
||||
if (urlStr == QLatin1String(testFile)) {
|
||||
urlStr = QFINDTESTDATA(testFile);
|
||||
}
|
||||
urls << QUrl::fromUserInput(urlStr);
|
||||
}
|
||||
KService::Ptr service;
|
||||
if (QByteArray(s_tests[testNumber].exec) == "nonexec") {
|
||||
const QString desktopFile = QFINDTESTDATA("../src/kioworkers/trash/kcmtrash.desktop");
|
||||
if (desktopFile.isEmpty()) {
|
||||
qWarning() << "kcmtrash.desktop not found!";
|
||||
}
|
||||
const QString dest = QStringLiteral("kcmtrash.desktop");
|
||||
QFile::remove(dest);
|
||||
bool ok = QFile::copy(desktopFile, dest);
|
||||
if (!ok) {
|
||||
qWarning() << "Failed to copy" << desktopFile << "to" << dest;
|
||||
}
|
||||
service = KService::Ptr(new KService(QDir::currentPath() + QLatin1Char('/') + dest));
|
||||
} else {
|
||||
service = KService::Ptr(new KService(QStringLiteral("Some Name"), QString::fromLatin1(s_tests[testNumber].exec), QString()));
|
||||
}
|
||||
auto *job = new KIO::ApplicationLauncherJob(service, this);
|
||||
job->setUrls(urls);
|
||||
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
|
||||
job->start();
|
||||
}
|
||||
|
||||
void Receiver::slotStop()
|
||||
{
|
||||
for (int i = 0; i < s_maxJobs; i++) {
|
||||
qDebug() << "deleting job" << i;
|
||||
delete jobArray[i];
|
||||
}
|
||||
start->setEnabled(true);
|
||||
stop->setEnabled(false);
|
||||
}
|
||||
|
||||
void Receiver::slotStart()
|
||||
{
|
||||
for (int i = 0; i < s_maxJobs; i++) {
|
||||
qDebug() << "creating testjob" << i;
|
||||
jobArray[i] = new KIO::OpenUrlJob(QUrl::fromLocalFile(QDir::tempPath()));
|
||||
jobArray[i]->setAutoDelete(false);
|
||||
jobArray[i]->start();
|
||||
}
|
||||
start->setEnabled(false);
|
||||
stop->setEnabled(true);
|
||||
}
|
||||
|
||||
void Receiver::slotLaunchOne()
|
||||
{
|
||||
auto *job = new KIO::OpenUrlJob(QUrl(QStringLiteral("http://www.kde.org")));
|
||||
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
|
||||
job->start();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication::setApplicationName(QStringLiteral("kruntest"));
|
||||
QApplication app(argc, argv);
|
||||
|
||||
Receiver receiver;
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "moc_kruntest.cpp"
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2002 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#ifndef _kruntest_h
|
||||
#define _kruntest_h
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QPushButton;
|
||||
class Receiver : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Receiver();
|
||||
~Receiver() override
|
||||
{
|
||||
}
|
||||
public Q_SLOTS:
|
||||
void slotStart();
|
||||
void slotStop();
|
||||
void slotLaunchOne();
|
||||
void slotLaunchTest(QPushButton *sender);
|
||||
|
||||
private:
|
||||
QPushButton *start;
|
||||
QPushButton *stop;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <kbuildsycocaprogressdialog.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication::setApplicationName(QStringLiteral("whatever"));
|
||||
QApplication k(argc, argv);
|
||||
|
||||
KBuildSycocaProgressDialog::rebuildKSycoca(nullptr);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2021 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include <KIO/JobUiDelegateFactory>
|
||||
#include <KTerminalLauncherJob>
|
||||
|
||||
#include <KService>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QStandardPaths>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QString command;
|
||||
if (argc > 1) {
|
||||
command = QString::fromLocal8Bit(argv[1]);
|
||||
}
|
||||
|
||||
auto *job = new KTerminalLauncherJob(command);
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert(QStringLiteral("MYVAR"), QStringLiteral("myvalue")); // for interactive testing that it was set
|
||||
job->setProcessEnvironment(env);
|
||||
job->setWorkingDirectory(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)); // for testing
|
||||
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, nullptr));
|
||||
job->start();
|
||||
|
||||
QObject::connect(job, &KJob::result, &app, [&]() {
|
||||
if (job->error()) {
|
||||
qWarning() << job->errorString();
|
||||
app.exit(1);
|
||||
} else {
|
||||
qDebug() << "Successfully started";
|
||||
app.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2015 David Edmundson <davidedmundson@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <KFilePlacesModel>
|
||||
#include <KUrlNavigator>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication::setApplicationName(QStringLiteral("kurlnavigatortest"));
|
||||
QApplication app(argc, argv);
|
||||
|
||||
KUrlNavigator urlNavigator(new KFilePlacesModel, QUrl::fromLocalFile(QDir::homePath()), nullptr);
|
||||
urlNavigator.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
This file is part of the KDE project.
|
||||
SPDX-FileCopyrightText: 2001 Carsten Pfeiffer <pfeiffer@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <kurlrequester.h>
|
||||
#include <kurlrequesterdialog.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
QUrl url = KUrlRequesterDialog::getUrl(QUrl(QStringLiteral("ftp://ftp.kde.org")));
|
||||
qDebug() << "Selected url:" << url;
|
||||
|
||||
KUrlRequester *req = new KUrlRequester();
|
||||
KEditListWidget *el = new KEditListWidget(req->customEditor());
|
||||
el->setWindowTitle(QStringLiteral("Test"));
|
||||
el->show();
|
||||
|
||||
KUrlRequester *req1 = new KUrlRequester();
|
||||
req1->setWindowTitle(QStringLiteral("AAAAAAAAAAAA"));
|
||||
req1->show();
|
||||
|
||||
KUrlComboRequester *comboReq = new KUrlComboRequester();
|
||||
comboReq->setWindowTitle(QStringLiteral("KUrlComboRequester"));
|
||||
comboReq->show();
|
||||
|
||||
auto *mimeFilterReq = new KUrlRequester();
|
||||
mimeFilterReq->setMimeTypeFilters({QStringLiteral("text/x-c++src")});
|
||||
mimeFilterReq->setWindowTitle(QStringLiteral("MimeFilter"));
|
||||
mimeFilterReq->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2014 Frank Reininghaus <frank78ac@googlemail.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <kio/listjob.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
qWarning() << "Expected a path or URL.";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
quint64 entriesListed = 0;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
QUrl url = QUrl::fromUserInput(QString::fromLocal8Bit(argv[i]), QDir::currentPath());
|
||||
qDebug() << "Starting listJob for the URL:" << url;
|
||||
|
||||
KIO::ListJob *job = KIO::listDir(url, KIO::HideProgressInfo);
|
||||
job->setUiDelegate(nullptr);
|
||||
job->addMetaData(QStringLiteral("details"), QString::number(KIO::StatDefaultDetails));
|
||||
|
||||
QObject::connect(job, &KIO::ListJob::entries, [&entriesListed](KIO::Job *, const KIO::UDSEntryList &entries) {
|
||||
entriesListed += entries.size();
|
||||
qDebug() << "Listed" << entriesListed << "files.";
|
||||
});
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
# SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
add_library(kiomessagebox MODULE)
|
||||
set_target_properties(kiomessagebox PROPERTIES OUTPUT_NAME "messagebox")
|
||||
|
||||
target_sources(kiomessagebox PRIVATE
|
||||
messageboxworker.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(kiomessagebox
|
||||
KF6::KIOCore
|
||||
)
|
||||
|
||||
# Uncomment to deploy
|
||||
# install(TARGETS kiomessagebox DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf6/kio)
|
||||
@@ -0,0 +1,11 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
|
||||
# KIO worker to test messageboxes manually
|
||||
|
||||
Enable the installation in CMakeLists.txt, then build and install.
|
||||
|
||||
Open the URL messagebox:/ in Dolphin. That will list directories named by the enums.
|
||||
Click a directory to enter it (list its content), that will instead trigger the respective warning and a redirect to the root dir.
|
||||
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#include "messageboxworker.h"
|
||||
|
||||
// KF
|
||||
#include <KIO/UDSEntry>
|
||||
// Qt
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QMap>
|
||||
#include <QUrl>
|
||||
|
||||
// Pseudo plugin class to embed meta data
|
||||
class KIOPluginForMetaData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.kde.kio.worker.messagebox" FILE "messageboxworker.json")
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
int Q_DECL_EXPORT kdemain(int argc, char **argv);
|
||||
}
|
||||
|
||||
int kdemain(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setApplicationName(QStringLiteral("kiomessagebox"));
|
||||
|
||||
MessageBoxWorker worker(argv[2], argv[3]);
|
||||
worker.dispatchLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
const QString kdeOrgCertChain = QStringLiteral(
|
||||
"-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIHJDCCBgygAwIBAgIQYxPG9R/EMYOGtmoK3J5ByDANBgkqhkiG9w0BAQsFADCB\n"
|
||||
"jzELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0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VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB\n"
|
||||
"L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG\n"
|
||||
"jjxDah2nGN59PRbxYvnKkKj9\n"
|
||||
"-----END CERTIFICATE-----\n");
|
||||
|
||||
static const QMap<int, QString> typeNames = {
|
||||
{KIO::WorkerBase::QuestionTwoActions, QStringLiteral("QuestionTwoActions")},
|
||||
{KIO::WorkerBase::WarningTwoActions, QStringLiteral("WarningTwoActions")},
|
||||
{KIO::WorkerBase::WarningContinueCancel, QStringLiteral("WarningContinueCancel")},
|
||||
{KIO::WorkerBase::WarningTwoActionsCancel, QStringLiteral("WarningTwoActionsCancel")},
|
||||
{KIO::WorkerBase::Information, QStringLiteral("Information")},
|
||||
{KIO::WorkerBase::WarningContinueCancelDetailed, QStringLiteral("WarningContinueCancelDetailed")},
|
||||
};
|
||||
|
||||
static constexpr int messageBoxList = -1;
|
||||
static constexpr int noMessageBoxType = -2;
|
||||
|
||||
static QString buttonCodeToDisplayString(int buttonCode)
|
||||
{
|
||||
switch (buttonCode) {
|
||||
case KIO::WorkerBase::Ok:
|
||||
return QStringLiteral("Ok");
|
||||
case KIO::WorkerBase::Cancel:
|
||||
return QStringLiteral("Cancel");
|
||||
case KIO::WorkerBase::PrimaryAction:
|
||||
return QStringLiteral("PrimaryAction");
|
||||
case KIO::WorkerBase::SecondaryAction:
|
||||
return QStringLiteral("SecondaryAction");
|
||||
case KIO::WorkerBase::Continue:
|
||||
return QStringLiteral("Continue");
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
return QString();
|
||||
};
|
||||
}
|
||||
|
||||
int messageBoxType(const QUrl &url)
|
||||
{
|
||||
QString path = url.adjusted(QUrl::StripTrailingSlash).path();
|
||||
if (path.startsWith(QLatin1Char('/'))) {
|
||||
path.remove(0, 1);
|
||||
}
|
||||
if (path.isEmpty()) {
|
||||
return messageBoxList;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
const int type = path.toInt(&ok);
|
||||
if (ok && typeNames.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
return noMessageBoxType;
|
||||
}
|
||||
|
||||
KIO::UDSEntry typeDirEntry(int messageBoxType)
|
||||
{
|
||||
KIO::UDSEntry entry;
|
||||
entry.reserve(4);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_NAME, QString::number(messageBoxType));
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_DISPLAY_NAME, typeNames.value(messageBoxType));
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
return entry;
|
||||
}
|
||||
|
||||
KIO::UDSEntry rootDirEntry()
|
||||
{
|
||||
KIO::UDSEntry entry;
|
||||
|
||||
entry.reserve(3);
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_NAME, QStringLiteral("."));
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("inode/directory"));
|
||||
entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MessageBoxWorker::MessageBoxWorker(const QByteArray &pool_socket, const QByteArray &app_socket)
|
||||
: KIO::WorkerBase("messagebox", pool_socket, app_socket)
|
||||
{
|
||||
}
|
||||
|
||||
MessageBoxWorker::~MessageBoxWorker() = default;
|
||||
|
||||
KIO::WorkerResult MessageBoxWorker::get(const QUrl &url)
|
||||
{
|
||||
return KIO::WorkerResult::fail(KIO::ERR_DOES_NOT_EXIST, url.path());
|
||||
}
|
||||
|
||||
KIO::WorkerResult MessageBoxWorker::stat(const QUrl &url)
|
||||
{
|
||||
const int type = ::messageBoxType(url);
|
||||
|
||||
if (type == ::noMessageBoxType) {
|
||||
return KIO::WorkerResult::fail(KIO::ERR_DOES_NOT_EXIST, QStringLiteral("No such path."));
|
||||
}
|
||||
|
||||
// is root directory?
|
||||
if (type == ::messageBoxList) {
|
||||
statEntry(rootDirEntry());
|
||||
return KIO::WorkerResult::pass();
|
||||
}
|
||||
|
||||
// type dir
|
||||
statEntry(typeDirEntry(type));
|
||||
return KIO::WorkerResult::pass();
|
||||
}
|
||||
|
||||
KIO::WorkerResult MessageBoxWorker::listDir(const QUrl &url)
|
||||
{
|
||||
const int type = ::messageBoxType(url);
|
||||
|
||||
if (type == ::noMessageBoxType) {
|
||||
return KIO::WorkerResult::fail(KIO::ERR_DOES_NOT_EXIST, QStringLiteral("No such directory."));
|
||||
}
|
||||
if (type == messageBoxList) {
|
||||
const QList<int> items = typeNames.keys();
|
||||
|
||||
// report number of expected entries
|
||||
totalSize(1 + items.size());
|
||||
// own dir
|
||||
listEntry(rootDirEntry());
|
||||
// type dirs
|
||||
for (const auto &item : items) {
|
||||
listEntry(typeDirEntry(item));
|
||||
}
|
||||
|
||||
return KIO::WorkerResult::pass();
|
||||
}
|
||||
|
||||
// trigger the respective messagebox, then redirect to root dir
|
||||
if (type == WarningContinueCancelDetailed) {
|
||||
setMetaData(QStringLiteral("privilege_conf_details"), QStringLiteral("Some details"));
|
||||
sendMetaData();
|
||||
}
|
||||
const int reply = messageBox(QStringLiteral("Message in a box."),
|
||||
static_cast<MessageBoxType>(type),
|
||||
typeNames.value(type),
|
||||
QStringLiteral("Primary"),
|
||||
QStringLiteral("Secondary"));
|
||||
qDebug() << "MESSAGEBOX REPLY" << buttonCodeToDisplayString(reply);
|
||||
|
||||
redirection(QUrl(QStringLiteral("messagebox:")));
|
||||
return KIO::WorkerResult::pass();
|
||||
}
|
||||
|
||||
#include "messageboxworker.moc"
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef MESSAGEBOXWORKER_H
|
||||
#define MESSAGEBOXWORKER_H
|
||||
|
||||
// KF
|
||||
#include <KIO/WorkerBase>
|
||||
|
||||
// See README
|
||||
class MessageBoxWorker : public KIO::WorkerBase
|
||||
{
|
||||
public:
|
||||
MessageBoxWorker(const QByteArray &pool_socket, const QByteArray &app_socket);
|
||||
~MessageBoxWorker() override;
|
||||
|
||||
public: // KIO::WorkerBase API
|
||||
KIO::WorkerResult get(const QUrl &url) override;
|
||||
KIO::WorkerResult stat(const QUrl &url) override;
|
||||
KIO::WorkerResult listDir(const QUrl &url) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"KDE-KIO-Protocols": {
|
||||
"messagebox": {
|
||||
"ExtraNames": [
|
||||
],
|
||||
"input": "none",
|
||||
"listing": [
|
||||
"Name",
|
||||
"Type"
|
||||
],
|
||||
"output": "filesystem",
|
||||
"protocol": "messagebox",
|
||||
"reading": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
SPDX-FileCopyrightText: none
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2020 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QList>
|
||||
#include <QUrl>
|
||||
|
||||
#include <KIO/OpenFileManagerWindowJob>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication::setApplicationName(QStringLiteral("openfilemanagerwindowtest"));
|
||||
QApplication app(argc, argv);
|
||||
#ifndef Q_OS_WINDOWS
|
||||
const QList<QUrl> urls{QUrl(QStringLiteral("file:///etc/fstab")), QUrl(QStringLiteral("file:///etc/passwd"))};
|
||||
#else
|
||||
const QList<QUrl> urls{QUrl(QStringLiteral("file:///c:/windows/notepad.exe")), QUrl(QStringLiteral("file:///c:/windows/explorer.exe"))};
|
||||
#endif
|
||||
|
||||
auto *job = new KIO::OpenFileManagerWindowJob();
|
||||
job->setHighlightUrls(urls);
|
||||
job->start();
|
||||
|
||||
QObject::connect(job, &KJob::result, job, [&](KJob *job) {
|
||||
app.exit(job->error());
|
||||
});
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
|
||||
#include "previewtest.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KIconLoader>
|
||||
#include <KSharedConfig>
|
||||
#include <QDebug>
|
||||
#include <kio/previewjob.h>
|
||||
#include <kurlrequester.h>
|
||||
|
||||
PreviewTest::PreviewTest()
|
||||
: QWidget()
|
||||
{
|
||||
QGridLayout *layout = new QGridLayout(this);
|
||||
m_url = new KUrlRequester(this);
|
||||
|
||||
QString path;
|
||||
KIconLoader().loadMimeTypeIcon(QStringLiteral("video-x-generic"), KIconLoader::Desktop, 256, KIconLoader::DefaultState, QStringList(), &path);
|
||||
|
||||
m_url->setText(path);
|
||||
layout->addWidget(m_url, 0, 0);
|
||||
QPushButton *btn = new QPushButton(QStringLiteral("Generate"), this);
|
||||
connect(btn, &QAbstractButton::clicked, this, &PreviewTest::slotGenerate);
|
||||
layout->addWidget(btn, 0, 1);
|
||||
|
||||
const KConfigGroup globalConfig(KSharedConfig::openConfig(), QStringLiteral("PreviewSettings"));
|
||||
const QStringList enabledPlugins =
|
||||
globalConfig.readEntry("Plugins",
|
||||
QStringList() << QStringLiteral("directorythumbnail") << QStringLiteral("imagethumbnail") << QStringLiteral("jpegthumbnail"));
|
||||
|
||||
m_plugins = new QLineEdit(this);
|
||||
layout->addWidget(m_plugins, 1, 0, 1, 2);
|
||||
m_plugins->setText(enabledPlugins.join(QStringLiteral("; ")));
|
||||
|
||||
m_preview = new QLabel(this);
|
||||
m_preview->setMinimumSize(400, 300);
|
||||
layout->addWidget(m_preview, 2, 0, 1, 2);
|
||||
}
|
||||
|
||||
void PreviewTest::slotGenerate()
|
||||
{
|
||||
KFileItemList items;
|
||||
items.append(KFileItem(m_url->url()));
|
||||
|
||||
QStringList enabledPlugins;
|
||||
const QStringList splittedText = m_plugins->text().split(QLatin1Char(';'));
|
||||
for (const QString &plugin : splittedText) {
|
||||
enabledPlugins << plugin.trimmed();
|
||||
}
|
||||
|
||||
KIO::PreviewJob *job = KIO::filePreview(items, QSize(m_preview->width(), m_preview->height()), &enabledPlugins);
|
||||
connect(job, &KJob::result, this, &PreviewTest::slotResult);
|
||||
connect(job, &KIO::PreviewJob::gotPreview, this, &PreviewTest::slotPreview);
|
||||
connect(job, &KIO::PreviewJob::failed, this, &PreviewTest::slotFailed);
|
||||
}
|
||||
|
||||
void PreviewTest::slotResult(KJob *)
|
||||
{
|
||||
qDebug() << "PreviewTest::slotResult(...)";
|
||||
}
|
||||
|
||||
void PreviewTest::slotPreview(const KFileItem &, const QPixmap &pix)
|
||||
{
|
||||
qDebug() << "PreviewTest::slotPreview()";
|
||||
m_preview->setPixmap(pix);
|
||||
}
|
||||
|
||||
void PreviewTest::slotFailed()
|
||||
{
|
||||
qDebug() << "PreviewTest::slotFailed()";
|
||||
m_preview->setText(QStringLiteral("failed"));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
PreviewTest *w = new PreviewTest;
|
||||
w->show();
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "moc_previewtest.cpp"
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef PREVIEWTEST_H
|
||||
#define PREVIEWTEST_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLineEdit;
|
||||
class QLabel;
|
||||
|
||||
class KFileItem;
|
||||
class KJob;
|
||||
class KUrlRequester;
|
||||
|
||||
class PreviewTest : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PreviewTest();
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotGenerate();
|
||||
void slotResult(KJob *);
|
||||
void slotPreview(const KFileItem &, const QPixmap &);
|
||||
void slotFailed();
|
||||
|
||||
private:
|
||||
KUrlRequester *m_url;
|
||||
QLineEdit *m_plugins;
|
||||
QLabel *m_preview;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 1999 Waldo Bastian <bastian@kde.org>
|
||||
SPDX-FileCopyrightText: 2009, 2020 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include <KIO/ApplicationLauncherJob>
|
||||
#include <KIO/JobUiDelegateFactory>
|
||||
|
||||
#include <KService>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QString serviceId = QStringLiteral("org.kde.kwrite");
|
||||
if (argc > 1) {
|
||||
serviceId = QString::fromLocal8Bit(argv[1]);
|
||||
}
|
||||
QList<QUrl> urls;
|
||||
if (argc > 2) {
|
||||
urls << QUrl::fromUserInput(QString::fromLocal8Bit(argv[2]));
|
||||
}
|
||||
|
||||
KService::Ptr service = KService::serviceByDesktopName(serviceId);
|
||||
if (!service) {
|
||||
service = KService::serviceByStorageId(serviceId + QLatin1String(".desktop"));
|
||||
if (!service) {
|
||||
qWarning() << "Service not found" << serviceId;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(service);
|
||||
job->setUrls(urls);
|
||||
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, nullptr));
|
||||
job->start();
|
||||
|
||||
QObject::connect(job, &KJob::result, &app, [&]() {
|
||||
if (job->error()) {
|
||||
app.exit(1);
|
||||
} else {
|
||||
qDebug() << "Started. pid=" << job->pid();
|
||||
}
|
||||
});
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user