Commit bc6e904b authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Copy kate sessions applet from kate repo

With this being located next to the KRunner plugin and Konsole plugin/applet,
we can more easily share the code.
parent 323ac0ff
......@@ -21,3 +21,4 @@ add_subdirectory(timer)
add_subdirectory(userswitcher)
add_subdirectory(weather)
add_subdirectory(webbrowser)
add_subdirectory(katesessions)
find_package(KF5Plasma ${KF5_DEP_VERSION} QUIET)
set_package_properties(KF5Plasma PROPERTIES PURPOSE "Required to build the sessionapplet addon")
find_package(Qt${QT_MAJOR_VERSION}Widgets ${QT_MIN_VERSION} QUIET)
set_package_properties(Qt5Widgets PROPERTIES PURPOSE "Required to build the sessionapplet addon")
if(NOT KF5Plasma_FOUND OR NOT Qt5Widgets_FOUND)
return()
endif()
kcoreaddons_add_plugin(plasma_engine_katesessions INSTALL_NAMESPACE "plasma/dataengine")
target_compile_definitions(plasma_engine_katesessions PRIVATE TRANSLATION_DOMAIN="plasma_applet_org.kde.plasma.katesessions")
target_link_libraries(
plasma_engine_katesessions
PRIVATE
KF5::I18n
KF5::Plasma
KF5::KIOGui
Qt::Widgets
)
target_sources(
plasma_engine_katesessions
PRIVATE
katesessionsengine.cpp
katesessionsmodel.cpp
katesessionsjob.cpp
katesessionsservice.cpp
)
plasma_install_package(applet org.kde.plasma.katesessions)
kcoreaddons_desktop_to_json(plasma_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 the clipboard applet:
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2014 Sebastian Kügler <sebas@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*********************************************************************/
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons
import org.kde.plasma.core 2.0 as PlasmaCore
PlasmaComponents.ListItem {
id: menuItem
signal itemSelected(string uuid)
signal newSession(string sessionname)
signal remove(string uuid)
property bool showInput: false
height: Math.max(Math.max(label.height, toolButtonsLayout.implicitHeight), sessionnameditlayout.implicitHeight) + PlasmaCore.Units.smallSpacing
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
if (TypeRole!=1)
menuItem.itemSelected(UuidRole);
else {
showInput=true;
}
}
onEntered: menuListView.currentIndex = index
onExited: menuListView.currentIndex = -1
Item {
id: label
height: iconItem.height
anchors {
left: parent.left
leftMargin: PlasmaCore.Units.smallSpacing
right: parent.right
verticalCenter: parent.verticalCenter
}
PlasmaComponents3.Label {
anchors {
left: parent.left
right: parent.right
rightMargin: PlasmaCore.Units.gridUnit * 2
leftMargin: PlasmaCore.Units.iconSizes.small + PlasmaCore.Units.smallSpacing * 2
verticalCenter: parent.verticalCenter
}
maximumLineCount: 1
text: DisplayRole.trim()
visible: !showInput // TypeRole: 0: Text, 1: Image, 2: Url
elide: Text.ElideRight
wrapMode: Text.Wrap
}
PlasmaCore.IconItem {
id: iconItem
width: PlasmaCore.Units.iconSizes.small
height: width
anchors.verticalCenter: parent.verticalCenter
source: DecorationRole
}
}
RowLayout {
id:sessionnameditlayout
visible:showInput
height: implicitHeight
anchors {
left: parent.left
right: parent.right
rightMargin: 0
leftMargin: PlasmaCore.Units.iconSizes.small + PlasmaCore.Units.smallSpacing * 2
verticalCenter: parent.verticalCenter
}
PlasmaComponents3.TextField {
id: sessionname
placeholderText: i18n("Session name")
clearButtonShown: true
Layout.fillWidth: true
}
PlasmaComponents3.ToolButton {
icon.name: "dialog-ok"
enabled: sessionname.text.replace(/^\s+|\s+$/g, '').length>0
onClicked: {menuItem.newSession(sessionname.text.replace(/^\s+|\s+$/g, '')); showInput=false;}
PlasmaComponents3.ToolTip {
text: i18n("Create new session and start Kate")
}
}
PlasmaComponents3.ToolButton {
icon.name: "dialog-cancel"
onClicked: showInput=false
PlasmaComponents3.ToolTip {
text: i18n("Cancel session creation")
}
}
}
RowLayout {
id: toolButtonsLayout
anchors {
right: label.right
verticalCenter: parent.verticalCenter
}
PlasmaComponents3.ToolButton {
icon.name: "edit-delete"
onClicked: menuItem.remove(UuidRole)
PlasmaComponents3.ToolTip {
text: i18n("Delete session")
}
}
Component.onCompleted: {
toolButtonsLayout.visible = Qt.binding(function () { return (TypeRole==2) && (menuListView.currentIndex == index); });
}
}
}
}
/********************************************************************
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org>
Based on the clipboard applet:
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*********************************************************************/
import QtQuick 2.0
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.components 2.0 as PlasmaComponents // for Highlight
PlasmaExtras.ScrollArea {
id: menu
property alias view: menuListView
property alias model: menuListView.model
signal itemSelected(string uuid)
signal remove(string uuid)
signal newSession(string sessionName)
ListView {
id: menuListView
focus: true
boundsBehavior: Flickable.StopAtBounds
interactive: contentHeight > height
highlight: PlasmaComponents.Highlight {
anchors.bottomMargin: -listMargins.bottom
y: 1
}
highlightMoveDuration: 0
highlightResizeDuration: 0
currentIndex: -1
delegate: KateSessionsItemDelegate {
width: menuListView.width
onItemSelected: menu.itemSelected(uuid)
onRemove: menu.remove(uuid)
onNewSession:menu.newSession(sessionname)
}
}
}
/********************************************************************
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Joseph Wenninger <jowenn@kde.org>
Based on the clipboard applet:
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2014 Kai Uwe Broulik <kde@privat.broulik.de>
SPDX-License-Identifier: GPL-2.0-or-later
*********************************************************************/
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
Item {
id: main
width: (Plasmoid.formFactor==PlasmaCore.Types.Planar)? PlasmaCore.Units.gridUnit * 14 : undefined
height: (Plasmoid.formFactor==PlasmaCore.Types.Planar)? PlasmaCore.Units.gridUnit * 16: undefined
Plasmoid.switchWidth: PlasmaCore.Units.gridUnit * 11
Plasmoid.switchHeight: PlasmaCore.Units.gridUnit * 11
Plasmoid.status: PlasmaCore.Types.ActiveStatus
Plasmoid.toolTipMainText: i18n("Kate Sessions")
Plasmoid.icon: "kate"
Component.onCompleted: {
plasmoid.removeAction("configure");
}
PlasmaCore.DataSource {
id: sessionsSource
property bool editing: false;
engine: "org.kde.plasma.katesessions"
connectedSources: "katesessions"
function serviceAction(uuid, op) {
const service = sessionsSource.serviceForSource(uuid);
var operation = service.operationDescription(op);
return service.startOperationCall(operation);
}
function newSession(sessionName) {
const service = sessionsSource.serviceForSource("");
var operation = service.operationDescription("newSession");
operation.sessionName = sessionName;
return service.startOperationCall(operation);
}
}
property var searchHeader: PlasmaExtras.PlasmoidHeading {
PlasmaComponents3.TextField {
id: filter
placeholderText: i18n("Search…")
clearButtonShown: true
anchors.fill: parent
}
}
Plasmoid.fullRepresentation: PlasmaComponents3.Page {
id: dialogItem
Layout.minimumWidth: PlasmaCore.Units.gridUnit * 12
Layout.minimumHeight: PlasmaCore.Units.gridUnit * 12
Layout.preferredWidth: PlasmaCore.Units.gridUnit * 16
Layout.preferredHeight: PlasmaCore.Units.gridUnit * 24
focus: true
header: searchHeader
property alias listMargins: listItemSvg.margins
PlasmaCore.FrameSvgItem {
id : listItemSvg
imagePath: "widgets/listitem"
prefix: "normal"
visible: false
}
Keys.onPressed: {
switch(event.key) {
case Qt.Key_Up: {
sessionsMenu.view.decrementCurrentIndex();
event.accepted = true;
break;
}
case Qt.Key_Down: {
sessionsMenu.view.incrementCurrentIndex();
event.accepted = true;
break;
}
case Qt.Key_Enter:
case Qt.Key_Return: {
if (sessionsMenu.view.currentIndex >= 0) {
const uuid = sessionsMenu.model.get(sessionsMenu.view.currentIndex).UuidRole
if (uuid) {
sessionsSource.serviceAction(uuid, "invoke")
sessionsMenu.view.currentIndex = 0
}
}
break;
}
case Qt.Key_Escape: {
if (filter.text == "") {
plasmoid.expanded = false;
} else {
filter.text = "";
}
event.accepted = true;
break;
}
default: { // forward key to filter
// filter.text += event.text wil break if the key is backspace
if (event.key == Qt.Key_Backspace && filter.text == "") {
return;
}
if (event.text != "" && !filter.activeFocus) {
sessionsMenu.view.currentIndex = -1
if (event.text == "v" && event.modifiers & Qt.ControlModifier) {
filter.paste();
} else {
filter.text = "";
filter.text += event.text;
}
filter.forceActiveFocus();
event.accepted = true;
}
}
}
}
ColumnLayout {
anchors.fill: parent
Menu {
id: sessionsMenu
model: PlasmaCore.SortFilterModel {
sourceModel: sessionsSource.models.katesessions
filterRole: "DisplayRole"
filterRegExp: filter.text
}
Layout.fillWidth: true
Layout.fillHeight: true
Layout.topMargin: PlasmaCore.Units.smallSpacing
onItemSelected: {
sessionsSource.serviceAction(uuid, "invoke")
plasmoid.expanded = false;
}
onRemove: sessionsSource.serviceAction(uuid, "remove")
onNewSession: sessionsSource.newSession(sessionName)
}
}
}
}
[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/Applet
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/katesessions.qml
X-Plasma-NotificationArea=true
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+
{
"KPlugin": {
"Authors": [
{
"Email": "jowenn@kde.org",
"Name": "Joseph Wenninger",
"Name[az]": "Joseph Wenninger",
"Name[ca@valencia]": "Joseph Wenninger",
"Name[ca]": "Joseph Wenninger",
"Name[cs]": "Joseph Wenninger",
"Name[de]": "Joseph Wenninger",
"Name[el]": "Joseph Wenninger",
"Name[en_GB]": "Joseph Wenninger",
"Name[es]": "Joseph Wenninger",
"Name[eu]": "Joseph Wenninger",
"Name[fi]": "Joseph Wenninger",
"Name[fr]": "Joseph Wenninger",
"Name[hu]": "Joseph Wenninger",
"Name[ia]": "Joseph Wenninger",
"Name[it]": "Joseph Wenninger",
"Name[ko]": "Joseph Wenninger",
"Name[my]": "ဂျိုးဆက်ဝမ်နင်ဂျာ",
"Name[nl]": "Joseph Wenninger",
"Name[pl]": "Joseph Wenninger",
"Name[pt]": "Joseph Wenninger",
"Name[pt_BR]": "Joseph Wenninger",
"Name[ru]": "Joseph Wenninger",
"Name[sl]": "Joseph Wenninger",
"Name[sv]": "Joseph Wenninger",
"Name[tr]": "Joseph Wenninger",
"Name[uk]": "Joseph Wenninger",
"Name[vi]": "Joseph Wenninger",
"Name[x-test]": "xxJoseph Wenningerxx",
"Name[zh_CN]": "Joseph Wenninger"
}
],
"Category": "Utilities",
"Description": "Kate Session Launcher",
"Description[az]": "Kate sessiya başladıcısı",
"Description[ca@valencia]": "Executador de la sessió del Kate",
"Description[ca]": "Llançador de la sessió del Kate",
"Description[cs]": "Spouštěč sezení Kate",
"Description[de]": "Kate-Sitzung starten",
"Description[el]": "Εκτελεστής συνεδρίας kate",
"Description[en_GB]": "Kate Session Launcher",
"Description[es]": "Lanzador de sesiones de Kate",
"Description[eu]": "Kate saioaren abiarazlea",
"Description[fi]": "Kate-istuntokäynnistin",
"Description[fr]": "Lanceur de sessions pour Kate",
"Description[hu]": "Kate munkamenet-indító",
"Description[ia]": "Lanceator de session de Kate",
"Description[it]": "Avviatore delle sessioni di Kate",
"Description[ko]": "Kate 세션 실행기",
"Description[my]": "ကိတ် ဆက်ရှင် လောင်ချာ",
"Description[nl]": "Kate sessiestarter",
"Description[pl]": "Uruchamia sesję Kate",
"Description[pt]": "Lançador de Sessões do Kate",
"Description[pt_BR]": "Lançador de sessões do Kate",
"Description[ru]": "Программа запуска сеанса Kate",
"Description[sl]": "Zaganjalnik seje Kate",
"Description[sv]": "Kate sessionsstart",
"Description[tr]": "Kate Oturum Başlatıcı",
"Description[uk]": "Запуск сеансів Kate",
"Description[vi]": "Trình khởi chạy phiên Kate",
"Description[x-test]": "xxKate Session Launcherxx",
"Description[zh_CN]": "Kate 会话启动器",
"Icon": "kate",
"Id": "org.kde.plasma.katesessions",
"License": "GPL-2.0+",
"Name": "Kate Sessions",
"Name[az]": "Kate sessiyaları",
"Name[ca@valencia]": "Sessions del Kate",
"Name[ca]": "Sessions del Kate",
"Name[cs]": "Sezení Kate",
"Name[de]": "Kate-Sitzungen",
"Name[el]": "Συνεδρίες kate",
"Name[en_GB]": "Kate Sessions",
"Name[es]": "Sesiones de Kate",
"Name[eu]": "Katen saioak",
"Name[fi]": "Kate-istunnot",
"Name[fr]": "Sessions de Kate",