Commit 241c3ae5 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

katesession: Remove Dataengine code

parent 4d7de3df
......@@ -2,6 +2,7 @@ plasma_install_package(activitypager org.kde.plasma.activitypager)
plasma_install_package(kickerdash org.kde.plasma.kickerdash)
plasma_install_package(konsoleprofiles/package org.kde.plasma.konsoleprofiles)
plasma_install_package(keyboardindicator org.kde.plasma.keyboardindicator)
plasma_install_package(katesessions org.kde.plasma.addons.katesessions)
add_subdirectory(binary-clock)
add_subdirectory(calculator)
......@@ -21,4 +22,3 @@ add_subdirectory(timer)
add_subdirectory(userswitcher)
add_subdirectory(weather)
add_subdirectory(webbrowser)
add_subdirectory(katesessions)
kcoreaddons_add_plugin(plasma_addons_engine_katesessions INSTALL_NAMESPACE "plasma/dataengine")
target_compile_definitions(plasma_addons_engine_katesessions PRIVATE TRANSLATION_DOMAIN="plasma_applet_org.kde.plasma.katesessions")
target_link_libraries(
plasma_addons_engine_katesessions
PRIVATE
KF5::I18n
KF5::Plasma
KF5::KIOGui
Qt::Widgets
)
target_sources(
plasma_addons_engine_katesessions
PRIVATE
katesessionsengine.cpp
katesessionsmodel.cpp
katesessionsjob.cpp
katesessionsservice.cpp
)
plasma_install_package(applet org.kde.plasma.addons.katesessions)
kcoreaddons_desktop_to_json(plasma_addons_engine_katesessions plasma-dataengine-katesessions.desktop)
install(FILES plasma-dataengine-katesessions.desktop DESTINATION ${KDE_INSTALL_KSERVICESDIR})
install(FILES org.kde.plasma.katesessions.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services)
#! /usr/bin/env bash
$XGETTEXT `find . -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.plasma.katesessions.pot
/********************************************************************
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org>
based on clipboard engine:
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*********************************************************************/
#include "katesessionsengine.h"
#include "katesessionsmodel.h"
#include "katesessionsservice.h"
#include <QDebug>
static const QString s_sessionsSourceName = QStringLiteral("katesessions");
KateSessionsEngine::KateSessionsEngine(QObject *parent, const QVariantList &args)
: Plasma::DataEngine(parent, args)
{
setData(s_sessionsSourceName, QStringLiteral("test_data"), QLatin1String("This is just for testing"));
setModel(s_sessionsSourceName, new KateSessionsModel(this));
}
KateSessionsEngine::~KateSessionsEngine()
{
}
Plasma::Service *KateSessionsEngine::serviceForSource(const QString &source)
{
qDebug() << "Creating KateSessionService";
Plasma::Service *service = new KateSessionsService(this, source);
service->setParent(this);
return service;
}
K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(org.kde.plasma.katesessions, KateSessionsEngine, "plasma-dataengine-katesessions.json")
#include "katesessionsengine.moc"
/********************************************************************
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org>
based on clipboard engine:
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*********************************************************************/
#ifndef KATESESSIONS_ENGINE_H
#define KATESESSIONS_ENGINE_H
#include <Plasma/DataEngine>
class KateSessionsEngine : public Plasma::DataEngine
{
Q_OBJECT
public:
KateSessionsEngine(QObject *parent, const QVariantList &args);
~KateSessionsEngine() override;
Plasma::Service *serviceForSource(const QString &source) override;
};
#endif
/********************************************************************
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org>
based on clipboard engine:
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
partly based on code:
SPDX-FileCopyrightText: 2008 Montel Laurent <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*********************************************************************/
#include "katesessionsjob.h"
#include "katesessionsengine.h"
#include <KIO/CommandLauncherJob>
#include <QDebug>
#include <QUrl>
static const QString s_sessionsSourceName = QStringLiteral("katesessions");
KateSessionsJob::KateSessionsJob(KateSessionsEngine *engine,
const QString &destination,
const QString &operation,
const QVariantMap &parameters,
QObject *parent)
: Plasma::ServiceJob(destination, operation, parameters, parent)
, m_engine(engine)
{
}
void KateSessionsJob::start()
{
qDebug() << "Job started:" << operationName() << " " << destination();
const QString operation = operationName();
// first check for operations not needing an item
if (operation == QLatin1String("newSession")) {
QString sessionName = parameters().value(QStringLiteral("sessionName")).toString();
if (sessionName.isEmpty()) {
setResult(false);
emitResult();
return;
}
// CHECK IF SESSION EXISTS
QStringList args;
args << QStringLiteral("-n") << QStringLiteral("--start") << sessionName;
auto job = new KIO::CommandLauncherJob(QStringLiteral("kate"), args);
job->start();
setResult(true);
emitResult();
return;
} else if (operation == QLatin1String("invoke")) {
QString dest = destination();
QStringList args;
if (dest == QLatin1String("_kate_noargs")) {
// do nothing
} else if (dest == QLatin1String("_kate_newsession")) {
args << QStringLiteral("--startanon");
} else {
dest.chop(12); // .katesession
args << QStringLiteral("-n") << QStringLiteral("--start") << QUrl::fromPercentEncoding(dest.toLatin1());
// args <<"-n"<< "--start"<<m_sessions[ id-3 ];
}
auto job = new KIO::CommandLauncherJob(QStringLiteral("kate"), args);
job->start();
setResult(true);
emitResult();
return;
} else if (operation == QLatin1String("remove")) {
qDebug() << operation << destination();
setResult(true);
emitResult();
return;
}
setResult(false);
emitResult();
}
/********************************************************************
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org>
based on clipboard engine:
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*********************************************************************/
#ifndef KATESESSIONSJOB_H
#define KATESESSIONSJOB_H
#include <Plasma/ServiceJob>
class KateSessionsEngine;
class KateSessionsJob : public Plasma::ServiceJob
{
Q_OBJECT
public:
KateSessionsJob(KateSessionsEngine *engine, const QString &destination, const QString &operation, const QVariantMap &parameters, QObject *parent = nullptr);
~KateSessionsJob() override = default;
void start() override;
private:
KateSessionsEngine *m_engine;
};
#endif
/***************************************************************************
* SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org> *
* SPDX-FileCopyrightText: 2008 Montel Laurent <montel@kde.org> *
* *
* SPDX-License-Identifier: GPL-2.0-or-later
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
***************************************************************************/
#include "katesessionsmodel.h"
#include <KDirWatch>
#include <KLocalizedString>
#include <KStringHandler>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QGraphicsGridLayout>
#include <QGraphicsLinearLayout>
#include <QGraphicsProxyWidget>
#include <QIcon>
#include <QListWidgetItem>
#include <QStandardPaths>
#include <QStyleOptionGraphicsItem>
#include <QTreeView>
#include <QVBoxLayout>
bool katesessions_compare_sessions(const QString &s1, const QString &s2)
{
return QString::localeAwareCompare(s1, s2) == -1;
}
KateSessionsModel::KateSessionsModel(QObject *parent)
: QStandardItemModel(parent) /*, m_config(0)*/
{
KDirWatch *dirwatch = new KDirWatch(this);
m_sessionsDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kate/sessions");
dirwatch->addDir(m_sessionsDir);
connect(dirwatch, &KDirWatch::dirty, this, &KateSessionsModel::slotUpdateSessionMenu);
slotUpdateSessionMenu();
}
KateSessionsModel::~KateSessionsModel()
{
}
void KateSessionsModel::slotUpdateSessionMenu()
{
clear();
m_sessions.clear();
m_fullList.clear();
initSessionFiles();
}
void KateSessionsModel::initSessionFiles()
{
QStandardItem *item = new QStandardItem();
item->setData(i18n("Start Kate (no arguments)"), Qt::DisplayRole);
item->setData(QIcon::fromTheme(QStringLiteral("kate")), Qt::DecorationRole);
item->setData(QStringLiteral("_kate_noargs"), Uuid);
item->setData(0, TypeRole);
m_fullList << item->data(Qt::DisplayRole).toString();
appendRow(item);
item = new QStandardItem();
item->setData(i18n("New Kate Session"), Qt::DisplayRole);
item->setData(QIcon::fromTheme(QStringLiteral("document-new")), Qt::DecorationRole);
qDebug() << QIcon::fromTheme(QStringLiteral("document-new"));
item->setData(QStringLiteral("_kate_newsession"), Uuid);
item->setData(1, TypeRole);
m_fullList << item->data(Qt::DisplayRole).toString();
appendRow(item);
QDir dir(m_sessionsDir, QStringLiteral("*.katesession"));
for (unsigned int i = 0; i < dir.count(); ++i) {
QString name = dir[i];
name.chop(12); // .katesession
m_sessions << QUrl::fromPercentEncoding(name.toLatin1());
}
std::sort(m_sessions.begin(), m_sessions.end(), katesessions_compare_sessions);
QLatin1String ext(".katesession");
for (QStringList::ConstIterator it = m_sessions.constBegin(); it != m_sessions.constEnd(); ++it) {
m_fullList << *it;
item = new QStandardItem();
item->setData(*it, Qt::DisplayRole);
item->setData(QString((*it) + ext), Uuid);
item->setData(QIcon::fromTheme(QStringLiteral("document-open")), Qt::DecorationRole);
item->setData(2, TypeRole);
appendRow(item);
}
}
QHash<int, QByteArray> KateSessionsModel::roleNames() const
{
QHash<int, QByteArray> hash;
hash.insert(Qt::DisplayRole, QByteArrayLiteral("DisplayRole"));
hash.insert(Qt::DecorationRole, QByteArrayLiteral("DecorationRole"));
hash.insert(Qt::UserRole + 3, QByteArrayLiteral("UuidRole"));
hash.insert(Qt::UserRole + 4, QByteArrayLiteral("TypeRole"));
return hash;
}
/***************************************************************************
* SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org> *
* SPDX-FileCopyrightText: 2008 Montel Laurent <montel@kde.org> *
* *
* SPDX-License-Identifier: GPL-2.0-or-later
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
***************************************************************************/
#ifndef _KATESESSIONSMODEL_H_
#define _KATESESSIONSMODEL_H_
/*
#include <plasma/popupapplet.h>
#include "ui_katesessionConfig.h"
*/
#include <QStandardItemModel>
class QModelIndex;
class KConfigDialog;
class QStringList;
class KateSessionsModel : public QStandardItemModel
{
Q_OBJECT
public:
KateSessionsModel(QObject *parent);
~KateSessionsModel() override;
QHash<int, QByteArray> roleNames() const override;
enum SpecificRoles { Uuid = Qt::UserRole + 3, TypeRole = Qt::UserRole + 4 };
protected Q_SLOTS:
// void slotOnItemClicked(const QModelIndex &index);
void slotUpdateSessionMenu();
// void slotSaveConfig();
protected:
void initSessionFiles();
/* void createConfigurationInterface(KConfigDialog *parent);
void configChanged();*/
private:
QStringList m_sessions;
QStringList m_fullList;
QString m_sessionsDir;
// KateSessionConfigInterface *m_config;
};
#endif
/********************************************************************
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org>
based on clipboard engine:
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*********************************************************************/
#include "katesessionsservice.h"
#include "katesessionsengine.h"
#include "katesessionsjob.h"
#include <QDebug>
KateSessionsService::KateSessionsService(KateSessionsEngine *engine, const QString &uuid)
: m_engine(engine)
, m_uuid(uuid)
{
setName(QStringLiteral("org.kde.plasma.katesessions"));
}
Plasma::ServiceJob *KateSessionsService::createJob(const QString &operation, QVariantMap &parameters)
{
qDebug() << "creating KateSessionsJob";
return new KateSessionsJob(m_engine, m_uuid, operation, parameters, this);
}
/********************************************************************
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org>
based on clipboard engine:
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*********************************************************************/
#ifndef KATESESSIONSSERVICE_H
#define KATESESSIONSSERVICE_H
#include <Plasma/Service>
class KateSessionsEngine;
class KateSessionsService : public Plasma::Service
{
Q_OBJECT
public:
KateSessionsService(KateSessionsEngine *engine, const QString &uuid);
~KateSessionsService() override = default;
protected:
Plasma::ServiceJob *createJob(const QString &operation, QVariantMap &parameters) override;
private:
KateSessionsEngine *m_engine;
QString m_uuid;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kcfg SYSTEM
"http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<kcfg>
<group name="newSession">
<entry name="sessionName" type="String">
<label>The name of the session to be created</label>
</entry>
</group>
<group name="invoke">
</group>
<group name="remove">
</group>
</kcfg>
[Desktop Entry]
Name=Kate Sessions
Name[ar]=جلسات كيت
Name[ast]=Sesiones de Kate
Name[az]=Kate sessiyaları
Name[ca]=Sessions del Kate
Name[ca@valencia]=Sessions del Kate
Name[cs]=Sezení Kate
Name[da]=Kate-sessioner
Name[de]=Kate-Sitzungen
Name[el]=Συνεδρίες Kate
Name[en_GB]=Kate Sessions
Name[es]=Sesiones de Kate
Name[et]=Kate seansid
Name[eu]=Katen saioak
Name[fi]=Kate-istunnot
Name[fr]=Sessions de Kate
Name[gl]=Sesións de Kate
Name[he]=הפעלות של Kate
Name[hu]=Kate munkamenetek
Name[ia]=Sessiones de Kate
Name[id]=Sesi Kate
Name[it]=Sessioni di Kate
Name[ko]=Kate 세션
Name[lt]=Kate sesijos
Name[my]=ကိတ် ဆက်ရှင်များ
Name[nb]=Kate-økter
Name[nl]=Kate-sessies
Name[nn]=Kate-økter
Name[pa]=ਕੇਟ ਸ਼ੈਸ਼ਨ
Name[pl]=Sesje Kate
Name[pt]=Sessões do Kate
Name[pt_BR]=Sessões do Kate
Name[ro]=Sesiuni Kate
Name[ru]=Сеансы Kate
Name[sk]=Sedenia Kate
Name[sl]=Seje programa Kate
Name[sr]=Кејтине сесије
Name[sr@ijekavian]=Кејтине сесије
Name[sr@ijekavianlatin]=Kateine sesije
Name[sr@latin]=Kateine sesije
Name[sv]=Kate-sessioner
Name[tr]=Kate Oturumları
Name[uk]=Сеанси Kate
Name[vi]=Các phiên Kate
Name[x-test]=xxKate Sessionsxx
Name[zh_CN]=Kate 会话
Name[zh_TW]=Kate 工作階段
Comment=Kate Session Launcher
Comment[ar]=مُطلق لجلسات «كيت»
Comment[ast]=Llanzador de sesiones de Kate
Comment[az]=Kate sessiya başladıcısı
Comment[bg]=Зареждане на сесии на Kate
Comment[bs]=Pokretač Kate sesija
Comment[ca]=Llançador de la sessió del Kate
Comment[ca@valencia]=Executador de la sessió del Kate
Comment[cs]=Spouštěč sezení Kate
Comment[da]=Kate sessionstarter
Comment[de]=Kate-Sitzung starten
Comment[el]=Εκτελεστής συνεδρίας Kate
Comment[en_GB]=Kate Session Launcher
Comment[es]=Lanzador de sesiones de Kate
Comment[et]=Kate seansi käivitaja
Comment[eu]=Kate-saioaren abiarazlea
Comment[fi]=Kate-istunnonkäynnistin
Comment[fr]=Lanceur de sessions pour Kate
Comment[ga]=Tosaitheoir Seisiúin Kate
Comment[gl]=Iniciador de sesións de Kate
Comment[he]=מפעיל הפעלות של Kate
Comment[hu]=Kate munkamenet-indító
Comment[ia]=Lanceator de session de Kate
Comment[id]=Peluncur Sesi Kate
Comment[is]=Kate seturæsir
Comment[it]=Avviatore delle sessioni di Kate
Comment[ja]=Kate のセッションを開始します
Comment[kk]=Kate сеанс жеккіші
Comment[km]=កម្មវិធី​ចាប់ផ្ដើម​សម័យ Kate
Comment[ko]=Kate 세션 실행기
Comment[lt]=Kate sesijų paleidiklis
Comment[lv]=Kate sesiju palaidējs
Comment[mr]=केट सत्र प्रक्षेपक
Comment[my]=ကိတ် ဆက်ရှင် လောင်ချာ
Comment[nb]=Kate øktstarter
Comment[nds]=Kate-Törnstarter
Comment[nl]=Kate sessiestarter
Comment[nn]=Start Kate-økter
Comment[pa]=ਕੇਟ ਸ਼ੈਸ਼ਨ ਲਾਂਚਰ
Comment[pl]=Uruchamia sesję Kate
Comment[pt]=Lançador de Sessões do Kate
Comment[pt_BR]=Lançamento de sessões do Kate
Comment[ro]=Lansator de sesiuni Kate
Comment[ru]=Программа запуска сеанса Kate
Comment[si]=Kate වාර ආරම්භකය
Comment[sk]=Spúšťač Kate sedenia
Comment[sl]=Zaganjalnik sej za Kate
Comment[sr]=Покретач Кејтиних сесија
Comment[sr@ijekavian]=Покретач Кејтиних сесија
Comment[sr@ijekavianlatin]=Pokretač Kateinih sesija
Comment[sr@latin]=Pokretač Kateinih sesija
Comment[sv]=Kate sessionsstart
Comment[tg]=Оғозкунандаи мониторинги Кейт
Comment[tr]=Kate Oturum Başlatıcı
Comment[ug]=Kate ئەڭگىمە قوزغاتقۇچ
Comment[uk]=Запуск сеансів Kate
Comment[vi]=Trình khởi chạy phiên Kate
Comment[x-test]=xxKate Session Launcherxx
Comment[zh_CN]=Kate 会话启动器
Comment[zh_TW]=Kate 工作階段啟動器
Type=Service
Icon=kate
X-KDE-ServiceTypes=Plasma/DataEngine
X-KDE-Library=plasma_engine_katesessions
X-KDE-PluginInfo-Author=Joseph Wenninger
X-KDE-PluginInfo-Email=jowenn@kde.org
X-KDE-PluginInfo-Name=org.kde.plasma.katesessions
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Category=Utilities
X-KDE-PluginInfo-License=GPL-2.0+
X-KDE-PluginInfo-EnabledByDefault=true
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