plasma: drop layout templates support

since plasma-default-layoutrc can be used to setup the desktop
there is no reason to wrap the first launch around Javascript code
This commit is contained in:
Ivailo Monev 2015-01-17 13:57:35 +00:00
parent efce4a75e1
commit 772d9ff219
18 changed files with 200 additions and 571 deletions

View file

@ -57,18 +57,5 @@ install(FILES data/plasma.desktop data/plasma-desktop.desktop DESTINATION ${AUTO
install(FILES data/plasma-shell-desktop.kcfg DESTINATION ${KCFG_INSTALL_DIR})
install(FILES data/plasma-themes.knsrc DESTINATION ${CONFIG_INSTALL_DIR})
install(FILES data/plasma-desktop.notifyrc DESTINATION ${DATA_INSTALL_DIR}/plasma-desktop)
install(FILES data/layouts/00-defaultLayout.js DESTINATION ${DATA_INSTALL_DIR}/plasma-desktop/init)
install(FILES data/plasma-desktop-js.xml DESTINATION ${DATA_INSTALL_DIR}/katepart/syntax/)
MACRO(INSTALL_PLASMA_JAVASCRIPT_TEMPLATE dir addonPrefix)
configure_file(${dir}/metadata.desktop ${CMAKE_CURRENT_BINARY_DIR}/plasma-layout-${addonPrefix}.desktop COPYONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plasma-layout-${addonPrefix}.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(FILES ${dir}/metadata.desktop DESTINATION ${DATA_INSTALL_DIR}/plasma/layout-templates/${addonPrefix}/)
install(FILES ${dir}/contents/layout.js DESTINATION ${DATA_INSTALL_DIR}/plasma/layout-templates/${addonPrefix}/contents/)
ENDMACRO(INSTALL_PLASMA_JAVASCRIPT_TEMPLATE)
INSTALL_PLASMA_JAVASCRIPT_TEMPLATE(data/layouts/org.kde.plasma-desktop.defaultPanel org.kde.plasma-desktop.defaultPanel)
INSTALL_PLASMA_JAVASCRIPT_TEMPLATE(data/layouts/org.kde.plasma-desktop.findWidgets org.kde.plasma-desktop.findWidgets)
INSTALL_PLASMA_JAVASCRIPT_TEMPLATE(data/layouts/org.kde.plasma-desktop.desktopIcons org.kde.plasma-desktop.desktopIcons)
INSTALL_PLASMA_JAVASCRIPT_TEMPLATE(data/layouts/org.kde.plasma-desktop.SaL org.kde.plasma-desktop.SaL)
install(FILES data/plasma-default-layoutrc DESTINATION ${DATA_INSTALL_DIR}/plasma-desktop/)

View file

@ -1,18 +0,0 @@
loadTemplate("org.kde.plasma-desktop.defaultPanel")
for (var i = 0; i < screenCount; ++i) {
var desktop = new Activity
desktop.screen = i
desktop.wallpaperPlugin = 'image'
desktop.wallpaperMode = 'SingleImage'
//Create more panels for other screens
if (i > 0){
var panel = new Panel
panel.screen = i
panel.location = 'bottom'
panel.height = screenGeometry(i).height > 1024 ? 35 : 27
var tasks = panel.addWidget("tasks")
tasks.writeConfig("showOnlyCurrentScreen", true);
}
}

View file

@ -1,3 +0,0 @@
var activity = new Activity("sal")
activity.name = i18n("Search and Launch")

View file

@ -1,75 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Search and Launch
Name[ar]=ابحث و شغل
Name[ast]=Guetar y executar
Name[bg]=Търсене и стартиране
Name[bs]=Traženje i pokretanje
Name[ca]=Cerca i llançament
Name[ca@valencia]=Cerca i llançament
Name[cs]=Vyhledat a spustit
Name[da]=Søg og start
Name[de]=Suchen und ausführen
Name[el]=Αναζήτηση και εκτέλεση
Name[en_GB]=Search and Launch
Name[es]=Buscar y ejecutar
Name[et]=Otsimine ja käivitamine
Name[eu]=Bilatu eta abiarazi
Name[fi]=Etsi ja käynnistä
Name[fr]=Rechercher et lancer
Name[ga]=Cuardaigh agus Tosaigh
Name[gl]=Buscar e executar
Name[he]=חיפוש והפעלה
Name[hi]=
Name[hr]=Pretraži i pokreni
Name[hu]=Keresés és indítás
Name[ia]=Cerca e lancea
Name[is]=Leit að forritum og ræsing
Name[ja]=
Name[kk]=Іздеу және жегу
Name[km]=
Name[kn]=
Name[ko]=
Name[lt]=Rasti ir paleisti
Name[lv]=Meklēt un palaist
Name[mr]=
Name[nb]=Søk og start
Name[nds]=Söken un opropen
Name[nl]=Zoeken en starten
Name[nn]=Søk og køyr
Name[pa]=
Name[pl]=Znajdź i uruchom
Name[pt]=Pesquisa e Lançamento
Name[pt_BR]=Pesquisa e execução
Name[ro]=Căutare și lansare
Name[ru]=Поиск и запуск
Name[sk]=Hľadať a spustiť
Name[sl]=Iskanje in zaganjanje
Name[sr]=Тражење и покретање
Name[sr@ijekavian]=Тражење и покретање
Name[sr@ijekavianlatin]=Traženje i pokretanje
Name[sr@latin]=Traženje i pokretanje
Name[sv]=Sök och starta
Name[th]=
Name[tr]=Ara ve Çalıştır
Name[ug]=ئىزدەش ۋە ئىجرا قىلىش
Name[uk]=Пошук і запуск
Name[wa]=Trover ey enonder
Name[x-test]=xxSearch and Launchxx
Name[zh_CN]=
Name[zh_TW]=
Icon=edit-find
Type=Service
ServiceTypes=Plasma/LayoutTemplate
X-Plasma-Shell=plasma-desktop
X-Plasma-ContainmentCategories=desktop
X-Plasma-ContainmentLayout-ShowAsExisting=true
X-KDE-PluginInfo-Author=Kevin Ottens
X-KDE-PluginInfo-Email=ervin@kde.org
X-KDE-PluginInfo-Name=org.kde.plasma-desktop.SaL
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,38 +0,0 @@
var panel = new Panel
var panelScreen = panel.screen
var freeEdges = {"bottom": true, "top": true, "left": true, "right": true}
for (i = 0; i < panelIds.length; ++i) {
var tmpPanel = panelById(panelIds[i])
if (tmpPanel.screen == panelScreen) {
// Ignore the new panel
if (tmpPanel.id != panel.id) {
freeEdges[tmpPanel.location] = false;
}
}
}
if (freeEdges["bottom"] == true) {
panel.location = "bottom";
} else if (freeEdges["top"] == true) {
panel.location = "top";
} else if (freeEdges["left"] == true) {
panel.location = "left";
} else if (freeEdges["right"] == true) {
panel.location = "right";
} else {
// There is no free edge, so leave the default value
panel.location = "top";
}
panel.height = screenGeometry(panel.screen).height > 1024 ? 35 : 27
panel.addWidget("launcher")
pager = panel.addWidget("pager")
pager.writeConfig("hideWhenSingleDesktop", "true")
tasks = panel.addWidget("tasks")
panel.addWidget("systemtray")
panel.addWidget("digital-clock")
tasks.currentConfigGroup = new Array("Launchers")
tasks.writeConfig("browser", "preferred://browser, , , ")
tasks.writeConfig("filemanager", "preferred://filemanager, , , ")

View file

@ -1,76 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Default Panel
Name[ar]=اللوحة المبدئية
Name[ast]=Panel predetermináu
Name[bg]=Подразбиращ се панел
Name[bs]=Podrazumijevani panel
Name[ca]=Plafó per omissió
Name[ca@valencia]=Plafó per omissió
Name[cs]=Výchozí panel
Name[da]=Standardpanel
Name[de]=Standard-Kontrollleiste
Name[el]=Προκαθορισμένος πίνακας
Name[en_GB]=Default Panel
Name[es]=Panel predeterminado
Name[et]=Vaikimisi paneel
Name[eu]=Panel lehenetsia
Name[fi]=Oletuspaneeli
Name[ga]=Painéal Réamhshocraithe
Name[gl]=Panel predeterminado
Name[gu]=
Name[he]=לוח ברירת מחדל
Name[hi]=ि
Name[hr]=Zadani panel
Name[hu]=Alapértelmezett panel
Name[ia]=Pannello predefinite
Name[id]=Panel Standar
Name[is]=Sjálfgefið spjald
Name[it]=Pannello predefinito
Name[kk]=Әдетті панель
Name[km]=
Name[kn]=ಿಿ (ಿ) ಿ ()
Name[ko]=
Name[lt]=Numatytas skydelis
Name[lv]=Noklusētais panelis
Name[mr]=
Name[nb]=Standardpanel
Name[nds]=Standardpaneel
Name[nl]=Standaard paneel
Name[pa]=ਿ
Name[pl]=Domyślny panel
Name[pt]=Painel Predefinido
Name[pt_BR]=Painel padrão
Name[ro]=Panou implicit
Name[ru]=Стандартная панель
Name[si]=
Name[sk]=Štandardný panel
Name[sl]=Privzeti pult
Name[sr]=Подразумевани панел
Name[sr@ijekavian]=Подразумијевани панел
Name[sr@ijekavianlatin]=Podrazumijevani panel
Name[sr@latin]=Podrazumevani panel
Name[sv]=Standardpanel
Name[tg]=Панели стандартӣ
Name[th]=
Name[tr]=Öntanımlı Panel
Name[ug]=كۆڭۈلدىكى تاختا
Name[uk]=Типова панель
Name[vi]=Thanh điu khin mc đnh
Name[wa]=Sicriftôr prémetou
Name[x-test]=xxDefault Panelxx
Name[zh_CN]=
Name[zh_TW]=
Type=Service
ServiceTypes=Plasma/LayoutTemplate
X-Plasma-Shell=plasma-desktop
X-Plasma-ContainmentCategories=panel
X-KDE-PluginInfo-Author=Aaron Seigo
X-KDE-PluginInfo-Email=aseigo@kde.org
X-KDE-PluginInfo-Name=org.kde.plasma-desktop.defaultPanel
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,3 +0,0 @@
var activity = new Activity("folderview")
activity.name = i18n("Desktop Icons")

View file

@ -1,70 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Desktop Icons
Name[ar]=أيقونات سطح المكتب
Name[bg]=Настолни икони
Name[bs]=sesije radne površi
Name[ca]=Icones de l'escriptori
Name[ca@valencia]=Icones de l'escriptori
Name[cs]=Ikony na ploše
Name[da]=Skrivebordsikoner
Name[de]=Arbeitsflächen-Symbole
Name[el]=Εικονίδια επιφάνειας εργασίας
Name[en_GB]=Desktop Icons
Name[es]=Iconos de escritorio
Name[et]=Töölauaikoonid
Name[eu]=Mahaigaineko ikonoak
Name[fi]=Työpöytäkuvakkeet
Name[fr]=Icônes du bureau
Name[ga]=Deilbhíní Deisce
Name[gl]=Iconas no escritorio
Name[he]=סמלים של שולחן עבודה
Name[hr]=Ikone radne površine
Name[hu]=Asztali ikonok
Name[ia]=Icones de scriptorio
Name[is]=Táknmyndir á skjáborði
Name[kk]=Үстел таңбашасы
Name[km]=
Name[ko]=
Name[lt]=Darbastalio ženkliukai
Name[lv]=Darbvirsmas ikonas
Name[mr]= ि
Name[nb]=Skrivebordsikoner
Name[nds]=Schriefdischlüttbiller
Name[nl]=Pictogrammen op bureaublad
Name[pa]=
Name[pl]=Ikony pulpitu
Name[pt]=Ícones do Ecrã
Name[pt_BR]=Ícones da área de trabalho
Name[ro]=Pictograme de birou
Name[ru]=Значки на рабочем столе
Name[sk]=Ikony plochy
Name[sl]=Ikone na namizju
Name[sr]=Иконе површи
Name[sr@ijekavian]=Иконе површи
Name[sr@ijekavianlatin]=Ikone površi
Name[sr@latin]=Ikone površi
Name[sv]=Skrivbordsikoner
Name[tr]=Masaüstü Simgeleri
Name[ug]=ئۈستەلئۈستى سىنبەلگىسى
Name[uk]=Піктограми на стільниці
Name[vi]=Biu tưng màn hình nn
Name[wa]=Imådjetes do scribanne
Name[x-test]=xxDesktop Iconsxx
Name[zh_CN]=
Name[zh_TW]=
Icon=user-desktop
Type=Service
ServiceTypes=Plasma/LayoutTemplate
X-Plasma-Shell=plasma-desktop
X-Plasma-ContainmentCategories=desktop
X-Plasma-ContainmentLayout-ShowAsExisting=true
X-KDE-PluginInfo-Author=Kevin Ottens
X-KDE-PluginInfo-Email=ervin@kde.org
X-KDE-PluginInfo-Name=org.kde.plasma-desktop.desktopIcons
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,25 +0,0 @@
function findWidgetsIn(containment, type, callback)
{
var widgetIds = containment.widgetIds
for (id in widgetIds) {
var widget = containment.widgetById(widgetIds[id])
if (widget.type == type) {
print("Found a " + type + " tray with id " + widget.id + " in " + containment.type + " with id " + containment.id)
if (callback) {
callback(widget, containment)
}
}
}
}
this.findWidgets = function(type, callback)
{
for (i in panelIds) {
findWidgetsIn(panelById(panelIds[i]), type, callback)
}
for (i in activityIds) {
findWidgetsIn(activityById(activityIds[i]), type, callback)
}
}

View file

@ -1,71 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Find Widgets
Name[ar]=جد الودجات
Name[ast]=Guetar componentes
Name[bg]=Откриване на джаджи
Name[bs]=Traženje grafičkih kontrola
Name[ca]=Cerca estris
Name[ca@valencia]=Cerca estris
Name[cs]=Najít widgety
Name[da]=Find widgets
Name[de]=Miniprogramme suchen
Name[el]=Εύρεση συστατικών
Name[en_GB]=Find Widgets
Name[es]=Buscar componentes
Name[et]=Vidinate otsimine
Name[eu]=Bilatu trepetak
Name[fi]=Etsi sovelmia
Name[fr]=Trouver des composants graphiques
Name[ga]=Aimsigh Giuirléidí
Name[gl]=Buscar widgets
Name[he]=מציאת ווידג׳טים
Name[hi]=ि
Name[hr]=Nađi widgete
Name[hu]=Widgetek keresése
Name[ia]=Trova Widgets
Name[is]=Finna græjur
Name[ja]=
Name[kk]=Виджеттерді іздеу
Name[km]=
Name[ko]=
Name[lt]=Rasti valdiklių
Name[lv]=Atrast sīkrīkus
Name[mr]=ि
Name[nb]=Finn skjermelementer
Name[nds]=Lüttprogrammen söken
Name[nl]=Widgets zoeken
Name[pa]=ਿ
Name[pl]=Znajdź elementy interfejsu
Name[pt]=Procurar Elementos
Name[pt_BR]=Localizar widgets
Name[ro]=Caută controale
Name[ru]=Поиск виджетов
Name[sk]=Nájsť widgety
Name[sl]=Najdi gradnike
Name[sr]=Тражење виџета
Name[sr@ijekavian]=Тражење виџета
Name[sr@ijekavianlatin]=Traženje vidžeta
Name[sr@latin]=Traženje vidžeta
Name[sv]=Sök efter grafiska komponenter
Name[th]=
Name[tr]=Araçları Bul
Name[ug]=Widget ئىزدە
Name[uk]=Пошук віджетів
Name[vi]=Tìm widget
Name[wa]=Trover ahesses
Name[x-test]=xxFind Widgetsxx
Name[zh_CN]=
Name[zh_TW]=
Type=Service
ServiceTypes=Plasma/LayoutTemplate
X-Plasma-Shell=plasma-desktop
X-KDE-PluginInfo-Author=Aaron Seigo
X-KDE-PluginInfo-Email=aseigo@kde.org
X-KDE-PluginInfo-Name=org.kde.plasma-desktop.findWidgets
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -0,0 +1,197 @@
[Containments][1]
activity=
activityId=
desktop=-1
formfactor=2
geometry=0,-41,1024,35
immutability=1
lastDesktop=-1
lastScreen=0
location=4
plugin=panel
screen=0
zvalue=0
[Containments][1][ActionPlugins]
RightButton;NoModifier=contextmenu
[Containments][1][Applets][10]
geometry=76,3,32,32
immutability=1
plugin=icon
zvalue=0
[Containments][1][Applets][10][Configuration]
Url=file:///share/applications/kde4/konqbrowser.desktop
[Containments][1][Applets][10][LayoutInformation]
Order=3
[Containments][1][Applets][11]
geometry=36,3,32,32
immutability=1
plugin=icon
zvalue=0
[Containments][1][Applets][11][Configuration]
Url=file:///share/applications/kde4/konsole.desktop
[Containments][1][Applets][11][LayoutInformation]
Order=1
[Containments][1][Applets][23]
geometry=0,3,32,32
immutability=1
plugin=launcher
zvalue=0
[Containments][1][Applets][23][LayoutInformation]
Order=0
[Containments][1][Applets][23][Shortcuts]
global=
[Containments][1][Applets][3]
geometry=72,3,0,32
immutability=1
plugin=pager
zvalue=0
[Containments][1][Applets][3][Configuration]
currentDesktopSelected=0
displayedText=2
hideWhenSingleDesktop=true
showWindowIcons=false
[Containments][1][Applets][3][LayoutInformation]
Order=2
[Containments][1][Applets][4]
geometry=112,3,710,32
immutability=1
plugin=tasks
zvalue=0
[Containments][1][Applets][4][Configuration]
forceRows=false
groupWhenFull=true
groupingStrategy=0
highlightWindows=false
maxRows=2
showOnlyCurrentDesktop=true
showOnlyCurrentScreen=false
showOnlyMinimized=false
showToolTip=true
sortingStrategy=2
[Containments][1][Applets][4][Configuration][Launchers]
Items=preferred://filemanager?wmClass=%20
filemanager=preferred://filemanager, , ,\s
[Containments][1][Applets][4][LayoutInformation]
Order=4
[Containments][1][Applets][5]
geometry=826,3,106,32
immutability=1
plugin=systemtray
zvalue=0
[Containments][1][Applets][5][Configuration]
DefaultAppletsAdded=true
[Containments][1][Applets][5][Configuration][Applets][8]
geometry=0,0,24,24
immutability=1
plugin=notifier
zvalue=0
[Containments][1][Applets][5][Configuration][Applets][8][PopupApplet]
DialogHeight=346
DialogWidth=302
[Containments][1][Applets][5][Configuration][Applets][9]
geometry=0,0,24,24
immutability=1
plugin=org.kde.notifications
zvalue=0
[Containments][1][Applets][5][Configuration][Applets][9][PopupApplet]
DialogHeight=102
DialogWidth=372
[Containments][1][Applets][5][Configuration][Shortcuts]
SystemTray-Klipper-5=Ctrl+Alt+V
[Containments][1][Applets][5][LayoutInformation]
Order=5
[Containments][1][Applets][6]
geometry=936,3,64,32
immutability=1
plugin=digital-clock
zvalue=0
[Containments][1][Applets][6][Configuration]
timezone=Local
[Containments][1][Applets][6][LayoutInformation]
Order=6
[Containments][1][Configuration]
maximumSize=1024,35
minimumSize=1024,35
[Containments][20]
ActionPluginsSource=Global
activity=
activityId=
desktop=-1
formfactor=0
geometry=-16777215,-16777215,800,600
immutability=1
lastDesktop=-1
lastScreen=-1
location=0
plugin=desktopDashboard
screen=-1
wallpaperplugin=image
wallpaperpluginmode=SingleImage
zvalue=0
[Containments][7]
ActionPluginsSource=Global
activity=Desktop
activityId=
desktop=-1
formfactor=0
geometry=0,0,1024,768
immutability=1
lastDesktop=-1
lastScreen=0
location=0
plugin=desktop
screen=0
wallpaperplugin=image
wallpaperpluginmode=SingleImage
zvalue=0
[Containments][7][Wallpaper][image]
slideTimer=10
slidepaths=
userswallpapers=
wallpaper=/share/wallpapers/Ariya/
wallpapercolor=0,0,0
wallpaperposition=0
[Containments][7][Wallpaper][org.kde.wallpaper-qml]
color=0,0,0,0
packageName=org.kde.haenau
[Containments][7][Wallpaper][pattern]
BackgroundColor=0,0,0
ForegroundColor=255,255,255
Pattern=lineage.png
[General]
immutability=1

View file

@ -45,15 +45,11 @@
#include <kephal/screens.h>
#include <scripting/layouttemplatepackagestructure.h>
#include "panelview.h"
#include "plasmaapp.h"
#include "plasma-shell-desktop.h"
#include "scripting/desktopscriptengine.h"
static const QString s_panelTemplatesPath("plasma-layout-templates/panels/*");
DesktopCorona::DesktopCorona(QObject *parent)
: Plasma::Corona(parent),
m_addPanelAction(0),
@ -129,9 +125,8 @@ void DesktopCorona::checkAddPanelAction(const QStringList &sycocaChanges)
KPluginInfo::List panelContainmentPlugins = Plasma::Containment::listContainmentsOfType("panel");
const QString constraint = QString("[X-Plasma-Shell] == '%1' and 'panel' ~in [X-Plasma-ContainmentCategories]")
.arg(KGlobal::mainComponent().componentName());
KService::List templates = KServiceTypeTrader::self()->query("Plasma/LayoutTemplate", constraint);
if (panelContainmentPlugins.count() + templates.count() == 1) {
if (panelContainmentPlugins.count() == 1) {
m_addPanelAction = new QAction(i18n("Add Panel"), this);
m_addPanelAction->setData(Plasma::AbstractToolBox::AddTool);
connect(m_addPanelAction, SIGNAL(triggered(bool)), this, SLOT(addPanel()));
@ -405,15 +400,7 @@ void DesktopCorona::populateAddPanelsMenu()
}
}
const QString constraint = QString("[X-Plasma-Shell] == '%1' and 'panel' in [X-Plasma-ContainmentCategories]")
.arg(KGlobal::mainComponent().componentName());
KService::List templates = KServiceTypeTrader::self()->query("Plasma/LayoutTemplate", constraint);
foreach (const KService::Ptr &service, templates) {
sorted.insert(service->name(), qMakePair(emptyInfo, service));
}
QMapIterator<QString, QPair<KPluginInfo, KService::Ptr> > it(sorted);
Plasma::PackageStructure::Ptr templateStructure(new WorkspaceScripting::LayoutTemplatePackageStructure);
while (it.hasNext()) {
it.next();
QPair<KPluginInfo, KService::Ptr> pair = it.value();
@ -425,18 +412,6 @@ void DesktopCorona::populateAddPanelsMenu()
}
action->setData(plugin.pluginName());
} else {
//FIXME: proper names
KPluginInfo info(pair.second);
const QString path = KStandardDirs::locate("data", templateStructure->defaultPackageRoot() + '/' + info.pluginName() + '/');
if (!path.isEmpty()) {
Plasma::Package package(path, templateStructure);
const QString scriptFile = package.filePath("mainscript");
if (!scriptFile.isEmpty()) {
QAction *action = m_addPanelsMenu->addAction(info.name());
action->setData(QString::fromLatin1("plasma-desktop-template:%1").arg(scriptFile));
}
}
}
}
}
@ -453,9 +428,7 @@ void DesktopCorona::addPanel()
void DesktopCorona::addPanel(QAction *action)
{
const QString plugin = action->data().toString();
if (plugin.startsWith("plasma-desktop-template:")) {
evaluateScripts(QStringList() << plugin.right(plugin.length() - qstrlen("plasma-desktop-template:")), false);
} else if (!plugin.isEmpty()) {
if (!plugin.isEmpty()) {
addPanel(plugin);
}
}

View file

@ -50,7 +50,6 @@
#include "plasmaapp.h"
#include "scripting/desktopscriptengine.h"
#include "scripting/layouttemplatepackagestructure.h"
//TODO:
// use text editor KPart for syntax highlighting?
@ -340,67 +339,6 @@ void InteractiveConsole::loadScriptFromUrl(const KUrl &url)
}
}
void InteractiveConsole::populateTemplatesMenu()
{
m_snippetsMenu->clear();
QMap<QString, KService::Ptr> sorted;
const QString constraint = QString("[X-Plasma-Shell] == '%1'")
.arg(KGlobal::mainComponent().componentName());
KService::List templates = KServiceTypeTrader::self()->query("Plasma/LayoutTemplate", constraint);
foreach (const KService::Ptr &service, templates) {
sorted.insert(service->name(), service);
}
QMapIterator<QString, KService::Ptr> it(sorted);
Plasma::PackageStructure::Ptr templateStructure(new WorkspaceScripting::LayoutTemplatePackageStructure);
while (it.hasNext()) {
it.next();
KPluginInfo info(it.value());
const QString path = KStandardDirs::locate("data", templateStructure->defaultPackageRoot() + '/' + info.pluginName() + '/');
if (!path.isEmpty()) {
Plasma::Package package(path, templateStructure);
const QString scriptFile = package.filePath("mainscript");
if (!scriptFile.isEmpty()) {
QAction *action = m_snippetsMenu->addAction(info.name());
action->setData(info.pluginName());
}
}
}
}
void InteractiveConsole::loadTemplate(QAction *action)
{
Plasma::PackageStructure::Ptr templateStructure(new WorkspaceScripting::LayoutTemplatePackageStructure);
const QString pluginName = action->data().toString();
const QString path = KStandardDirs::locate("data", templateStructure->defaultPackageRoot() + '/' + pluginName + '/');
if (!path.isEmpty()) {
Plasma::Package package(path, templateStructure);
const QString scriptFile = package.filePath("mainscript");
if (!scriptFile.isEmpty()) {
loadScriptFromUrl(KUrl(scriptFile));
}
}
}
void InteractiveConsole::useTemplate(QAction *action)
{
QString code("var template = loadTemplate('" + action->data().toString() + "')");
if (m_editorPart) {
const QList<KTextEditor::View *> views = m_editorPart->views();
if (views.isEmpty()) {
m_editorPart->insertLines(m_editorPart->lines(), QStringList() << code);
} else {
KTextEditor::Cursor cursor = views.at(0)->cursorPosition();
m_editorPart->insertLines(cursor.line(), QStringList() << code);
cursor.setLine(cursor.line() + 1);
views.at(0)->setCursorPosition(cursor);
}
} else {
m_editor->insertPlainText(code);
}
}
void InteractiveConsole::scriptFileDataRecvd(KIO::Job *job, const QByteArray &data)
{
Q_ASSERT(m_editor);

View file

@ -83,9 +83,6 @@ private Q_SLOTS:
void saveScriptUrlSelected(int result);
void openScriptUrlSelected(int result);
void loadScriptFromUrl(const KUrl &url);
void populateTemplatesMenu();
void loadTemplate(QAction *);
void useTemplate(QAction *);
void modeChanged();
private:

View file

@ -1,6 +1,5 @@
set(plasma_kpartscripting_SRCS
scripting/layouttemplatepackagestructure.cpp
scripting/rect.cpp
scripting/scriptengine.cpp
scripting/widget.cpp

View file

@ -1,42 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* 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 Library 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 "layouttemplatepackagestructure.h"
namespace PlasmaKPartScripting
{
LayoutTemplatePackageStructure::LayoutTemplatePackageStructure(QObject *parent)
: Plasma::PackageStructure(parent)
{
setServicePrefix("plasma-layout-template");
setDefaultPackageRoot("plasma/layout-templates");
addFileDefinition("mainscript", "layout.js", "Main Script File");
setRequired("mainscript", true);
}
LayoutTemplatePackageStructure::~LayoutTemplatePackageStructure()
{
}
}
#include "layouttemplatepackagestructure.moc"

View file

@ -1,40 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* 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 Library 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 TEMPLATETEMPLATEPACKAGE_H
#define TEMPLATETEMPLATEPACKAGE_H
#include <Plasma/PackageStructure>
namespace PlasmaKPartScripting
{
class LayoutTemplatePackageStructure : public Plasma::PackageStructure
{
Q_OBJECT
public:
LayoutTemplatePackageStructure(QObject *parent = 0);
~LayoutTemplatePackageStructure();
};
}
#endif

View file

@ -35,7 +35,6 @@
#include <Plasma/Theme>
#include "widget.h"
#include "layouttemplatepackagestructure.h"
QScriptValue constructQRectFClass(QScriptEngine *engine);