Verified Commit 56c2a37d authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Do not use deprecated KNewStuff QWidgets components

parent d4feb744
......@@ -41,7 +41,6 @@
#include <kauthaction.h>
#include <kauthexecutejob.h>
#include <KNewStuff3/KNSCore/Engine>
#include <KNewStuff3/KNSCore/EntryInternal>
#include <KIO/CopyJob>
......@@ -73,7 +72,6 @@ KCMPlymouth::KCMPlymouth(QObject *parent, const QVariantList &args)
KCMPlymouth::~KCMPlymouth()
{
delete m_newStuffDialog.data();
}
void KCMPlymouth::reloadModel()
......@@ -126,33 +124,20 @@ void KCMPlymouth::reloadModel()
emit selectedPluginIndexChanged();
}
void KCMPlymouth::getNewStuff(QQuickItem *ctx)
void KCMPlymouth::onChangedEntriesChanged(const QQmlListReference &changedEntries)
{
if (!m_newStuffDialog) {
m_newStuffDialog = new KNS3::DownloadDialog(QLatin1String("plymouth.knsrc"));
m_newStuffDialog->setWindowTitle(i18n("Download New Boot Splash Screens"));
m_newStuffDialog->setWindowModality(Qt::WindowModal);
m_newStuffDialog->winId(); // so it creates the windowHandle();
connect(m_newStuffDialog.data(), &KNS3::DownloadDialog::accepted, this, &KCMPlymouth::reloadModel);
connect(m_newStuffDialog.data(), &KNS3::DownloadDialog::finished, m_newStuffDialog.data(), &KNS3::DownloadDialog::deleteLater);
connect(m_newStuffDialog->engine(), &KNSCore::Engine::signalEntryChanged, this, [=](const KNSCore::EntryInternal &entry) {
if (!entry.isValid() || entry.status() != KNS3::Entry::Installed) {
return;
}
static QStringList alreadyCopiedThumbnails;
for (int i = 0; i < changedEntries.count(); ++i) {
auto entry = qobject_cast<KNSCore::EntryWrapper *>(changedEntries.at(i))->entry();
if (entry.isValid() && entry.status() == KNS3::Entry::Installed && !alreadyCopiedThumbnails.contains(entry.uniqueId())) {
alreadyCopiedThumbnails.append(entry.uniqueId());
KIO::file_copy(QUrl(entry.previewUrl(KNSCore::EntryInternal::PreviewBig1)),
QUrl::fromLocalFile(QString(entry.installedFiles().constFirst() + QStringLiteral(".png"))),
-1,
KIO::Overwrite | KIO::HideProgressInfo);
});
}
if (ctx && ctx->window()) {
m_newStuffDialog->windowHandle()->setTransientParent(ctx->window());
}
}
m_newStuffDialog->show();
reloadModel();
}
QStandardItemModel *KCMPlymouth::themesModel()
......
......@@ -21,10 +21,9 @@
#ifndef _KCM_PLYMOUTH_H
#define _KCM_PLYMOUTH_H
#include <KNewStuff3/KNSCore/EntryWrapper>
#include <QDir>
#include <KNewStuff3/KNS3/DownloadDialog>
#include <KQuickAddons/ConfigModule>
class QQuickItem;
......@@ -59,7 +58,7 @@ public:
void setBusy(const bool &busy);
Q_INVOKABLE void reloadModel();
Q_INVOKABLE void getNewStuff(QQuickItem *ctx);
Q_INVOKABLE void onChangedEntriesChanged(const QQmlListReference &changedEntries);
Q_INVOKABLE void uninstall(const QString &plugin);
public Q_SLOTS:
......@@ -80,7 +79,6 @@ private:
QStandardItemModel *m_model;
QString m_selectedPlugin;
bool m_busy = false;
QPointer<KNS3::DownloadDialog> m_newStuffDialog;
};
#endif
......@@ -23,6 +23,7 @@ import QtQuick.Window 2.2
import QtQuick.Controls 2.3 as QtControls
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kcm 1.1 as KCM
import org.kde.newstuff 1.62 as NewStuff
KCM.GridViewKCM {
KCM.ConfigModule.quickHelp: i18n("This module lets you choose the Plymouth boot splash screen.")
......@@ -73,13 +74,14 @@ KCM.GridViewKCM {
indeterminate: true
}
QtControls.Button {
id: getNewButton
NewStuff.Button {
id: newStuffButton
Layout.alignment: Qt.AlignRight
enabled: !kcm.busy
text: i18n("Get New Boot Splash Screens...")
icon.name: "get-hot-new-stuff"
enabled: !kcm.busy
onClicked: kcm.getNewStuff(this)
configFile: "plymouth.knsrc"
onChangedEntriesChanged: kcm.onChangedEntriesChanged(newStuffButton.changedEntries);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment