Adjust to new API

This commit is contained in:
Sebastian Kügler 2013-09-25 17:57:12 +02:00
commit 8c93578acf
77 changed files with 1578 additions and 597 deletions

View File

@ -1,10 +1,12 @@
plasma_install_package(config org.kde.example.configuration)
plasma_install_package(localegallery org.kde.example.locale)
plasma_install_package(notes org.kde.example.notes)
plasma_install_package(widgetgallery org.kde.example.widgetgallery)
plasma_install_package(qmltasks org.kde.example.tasks)
plasma_install_package(windowthumbnails org.kde.example.windowthumbnails)
plasma_install_package(conditionalloader org.kde.example.conditionalloader)
plasma_install_package(testcomponents org.kde.example.testcomponents)
plasma_install_package(testshaders org.kde.example.testshaders)
plasma_install_package(helloworld org.kde.examples.helloworld)
plasma_install_package(compactrepresentation org.kde.examples.compactrepresentation)
plasma_install_package(helloworld org.kde.example.helloworld)
plasma_install_package(compactrepresentation org.kde.example.compactrepresentation)

View File

@ -3,6 +3,7 @@ Comment=
Encoding=UTF-8
Keywords=
Name=hello world
Name[de]=Hallo Welt
Name[nl]=hallo wereld
Name[pt]=olá mundo
Name[pt_BR]=Olá mundo

View File

@ -17,6 +17,7 @@
*/
import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
@ -36,10 +37,10 @@ Item {
anchors.fill: parent
spacing: 4
Row {
PlasmaComponents.Label {
QtControls.Label {
text: "Text Config value"
}
PlasmaComponents.TextField {
QtControls.TextField {
id: testConfigField
}
}

View File

@ -0,0 +1,34 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.0
import org.kde.plasma.configuration 2.0
ConfigModel {
ConfigCategory {
name: "General"
icon: "plasma"
source: "configGeneral.qml"
}
ConfigCategory {
name: "Other page"
icon: "konqueror"
source: "configSecondPage.qml"
}
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="General">
<entry name="Test" type="String">
<label>This is a test</label>
<default>test</default>
</entry>
<entry name="BoolTest" type="Bool">
<default>true</default>
</entry>
<entry name="IntTest" type="Int">
<default>1</default>
<min>-1</min>
<max>100</max>
</entry>
</group>
<group name="Group2">
<entry name="OtherTest" type="String">
<label>This is another test</label>
<default>test2</default>
</entry>
<entry name="EnumTest" type="Enum">
<default>Value2</default>
<choices>
<choice name="Value0"/>
<choice name="Value1"/>
<choice name="Value2"/>
<choice name="Value3"/>
<choice name="Value4"/>
<choice name="Value5"/>
<choice name="Value6"/>
</choices>
</entry>
</group>
</kcfg>

View File

@ -0,0 +1,57 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
Item {
id: iconsPage
width: childrenRect.width
height: childrenRect.height
implicitWidth: mainColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property alias cfg_Test: testConfigField.text
property alias cfg_BoolTest: testBoolConfigField.checked
Column {
id: pageColumn
anchors.fill: parent
spacing: 4
Row {
QtControls.Label {
text: "Text Config value"
}
QtControls.TextField {
id: testConfigField
}
}
Row {
QtControls.Label {
text: "Bool Config value"
}
QtControls.CheckBox {
id: testBoolConfigField
}
}
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright 2013 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.1
import QtQuick.Layouts 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
Item {
id: root
width: 100
height: 100
property int minimumWidth: units.gridUnit * 20
property int minimumHeight: column.implicitHeight
ColumnLayout {
id: column
anchors.centerIn: parent
PlasmaComponents.Label {
anchors.horizontalCenter: parent.horizontalCenter
text: i18n("String test")
}
PlasmaComponents.TextField {
text: plasmoid.configuration.Test
onTextChanged: plasmoid.configuration.Test = text
}
PlasmaComponents.CheckBox {
enabled: true
checked: plasmoid.configuration.BoolTest
text: i18n("Bool from config")
onCheckedChanged: plasmoid.configuration.BoolTest = checked
}
PlasmaComponents.Label {
anchors.horizontalCenter: parent.horizontalCenter
text: i18n("String from another group")
}
PlasmaComponents.TextField {
text: plasmoid.configuration.OtherTest
onTextChanged: plasmoid.configuration.OtherTest = text
}
PlasmaComponents.Label {
anchors.horizontalCenter: parent.horizontalCenter
text: i18n("Enum: displayed as int,\n written as string")
}
PlasmaComponents.TextField {
text: plasmoid.configuration.EnumTest
onTextChanged: plasmoid.configuration.EnumTest = text
}
PlasmaComponents.Label {
anchors.horizontalCenter: parent.horizontalCenter
text: i18n("Integer: minimum -1,\n maximum 100")
}
PlasmaComponents.TextField {
text: plasmoid.configuration.IntTest
onTextChanged: plasmoid.configuration.IntTest = text
}
}
}

View File

@ -0,0 +1,25 @@
[Desktop Entry]
Encoding=UTF-8
Keywords=
Name=Configuration test
Name[de]=Einrichtungstest
Name[nl]=Test van instellingen
Name[pt]=Teste de configuração
Name[pt_BR]=Teste de configuração
Name[sk]=Test nastavenia
Name[sv]=Inställningstest
Name[uk]=Перевірка налаштувань
Name[x-test]=xxConfiguration testxx
Type=Service
X-KDE-ServiceTypes=Plasma/Applet
X-Plasma-API=declarativeappletscript
X-KDE-ParentApp=
X-KDE-PluginInfo-Author=Marco Martin
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Email=mart@kde.org
X-KDE-PluginInfo-License=GPLv2+
X-KDE-PluginInfo-Name=org.kde.example.configuration
X-KDE-PluginInfo-Version=
X-KDE-PluginInfo-Website=
X-Plasma-MainScript=ui/main.qml

View File

@ -3,6 +3,7 @@ Comment=
Encoding=UTF-8
Keywords=
Name=hello world
Name[de]=Hallo Welt
Name[nl]=hallo wereld
Name[pt]=olá mundo
Name[pt_BR]=Olá mundo

View File

@ -1,12 +1,14 @@
[Desktop Entry]
Encoding=UTF-8
Name=Locale gallery
Name[nl]=Lokale galerij
Name[pt]=Galeria regional
Name[pt_BR]=Galeria regional
Name[sv]=Locale-galleri
Name[uk]=Галерея локалей
Name[x-test]=xxLocale galleryxx
Comment=gallery of KLocale QML Bindings
Comment[nl]=galerij van KLocale QML-bindingen
Comment[pt]=Galeria de Interfaces em QML do KLocale
Comment[pt_BR]=Galeria de interfaces em QML do KLocale
Comment[sv]=galleri av QML-bindningar för KLocale

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="General">
<entry name="Text" type="String">
<label>Notes text</label>
<default>Hello!</default>
</entry>
</group>
</kcfg>

View File

@ -0,0 +1,45 @@
/*
* Copyright 2013 Marco Martin <mart@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.
*/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
PlasmaCore.SvgItem {
property int minimumWidth: 150
property int minimumHeight: 150
svg: PlasmaCore.Svg("widgets/notes")
elementId: "yellow-notes"
Connections {
target: plasmoid
onExternalData: {
if (mimetype === "text/plain") {
noteText.text = data
}
}
}
PlasmaComponents.TextArea {
id: noteText
anchors.fill: parent
text: plasmoid.configuration.Text
onTextChanged: plasmoid.configuration.Text = text
}
}

View File

@ -0,0 +1,31 @@
[Desktop Entry]
Comment=Example on how to manage Drop data
Comment[nl]=Voorbeeld van hoe gegevens van Drop te beheren
Comment[pt]=Exemplo de gestão de dados do Drop
Comment[pt_BR]=Exemplo de gerenciamento de dados do Drop
Comment[sv]=Exempel på hur Släpp data hanteras
Comment[uk]=Приклад керування скинутими даними
Comment[x-test]=xxExample on how to manage Drop dataxx
Encoding=UTF-8
Keywords=
Name=Example notes
Name[nl]=Voorbeeldnotities
Name[pt]=Notas de exemplo
Name[pt_BR]=Notas de exemplo
Name[sv]=Exempelanteckningar
Name[uk]=Приклад нотаток
Name[x-test]=xxExample notesxx
Type=Service
Icon=knotes
X-KDE-ParentApp=
X-KDE-PluginInfo-Author=Marco Martin
X-KDE-PluginInfo-Category=Miscellaneous
X-KDE-PluginInfo-Email=mart@kde.org
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-Name=org.kde.example.notes
X-KDE-PluginInfo-Version=
X-KDE-PluginInfo-Website=
X-KDE-ServiceTypes=Plasma/Applet
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-DropMimeTypes=text/plain

View File

@ -1,11 +1,14 @@
[Desktop Entry]
Name=Now playing (QML)
Name[de]=Musiktitel-Anzeige (QML)
Name[nl]=Speelt nu (QML)
Name[pt]=Agora a tocar (QML)
Name[pt_BR]=Reproduzindo (QML)
Name[sv]=Spelar nu (QML)
Name[uk]=Зараз відтворюється (QML)
Name[x-test]=xxNow playing (QML)xx
Comment=A proof of concept media player controller qml
Comment[nl]=Een 'proof of concept' qml voor besturing van een mediaspeler
Comment[pt]=A prova de conceito de um QML com controlo de leitor multimédia
Comment[pt_BR]=A prova de conceito de um QML com controle de reprodutor multimídia
Comment[sv]=Ett koncept för styrning av mediaspelare i QML

View File

@ -1,11 +1,13 @@
[Desktop Entry]
Name=Poor Man's Tasks
Name[nl]=Taken van 'Poor Man'
Name[pt]=Tarefas Simples
Name[pt_BR]=Tarefas simples
Name[sv]=Fattigmans aktiviteter
Name[uk]=Задачі для початківців
Name[x-test]=xxPoor Man's Tasksxx
Comment=Example showing how to write your own tasks Widget
Comment[nl]=Voorbeeld die toont hoe u uw eigen taak-widget schrijft
Comment[pt]=Um exemplo que demonstra como criar o seu próprio item de tarefas
Comment[pt_BR]=Exemplo que mostra como criar seu próprio widget de tarefas
Comment[sv]=Exempel som visar hur man skriver en egen grafisk komponent för aktiviteter

View File

@ -1,12 +1,14 @@
[Desktop Entry]
Encoding=UTF-8
Name=Same game (QML)
Name[nl]=Zelfde spel (QML)
Name[pt]=Jogo de bolas (QML)
Name[pt_BR]=Jogo de bolas (QML)
Name[sv]=Samegame (QML)
Name[uk]=Та сама гра (QML)
Name[x-test]=xxSame game (QML)xx
Comment=The Same game QML Qt demo converted as plasmoid
Comment[nl]=De demo van QML Qt van 'Zelfde spel' geconverteerd als plasmoid
Comment[pt]=A demonstração do jogo Same Game do Qt em QML
Comment[pt_BR]=Demonstração do jogo Same Game do Qt em QML convertido como plasmoide
Comment[sv]=Samegame QML Qt-demonstrationen konverterad till Plasmoid

View File

@ -1,12 +1,14 @@
[Desktop Entry]
Encoding=UTF-8
Name=Widgets gallery
Name[nl]=Galerij van widgets
Name[pt]=Galeria de elementos
Name[pt_BR]=Galeria de widgets
Name[sv]=Grafiskt komponentgalleri
Name[uk]=Галерея віджетів
Name[x-test]=xxWidgets galleryxx
Comment=gallery of widgets done with Plasma QtComponents
Comment[nl]=galerij van widgets gemaakt met Plasma QtComponents
Comment[pt]=Uma galeria de elementos gráficos feita com o QtComponents do Plasma
Comment[pt_BR]=Galeria de widgets gráficos feita com o QtComponents do Plasma
Comment[sv]=galleri av grafiska komponenter skapade med Plasma Qt-komponenter

View File

@ -1,11 +1,13 @@
[Desktop Entry]
Name=Example window thumbnails list
Name[pt]=Lista de janelas de exemplo
Name[pt_BR]=Lista de janelas de exemplo
Name[sv]=Exempel på fönsterlista
Name[uk]=Приклад списку вікон
Name[x-test]=xxExample window listxx
Name[nl]=Voorbeeld van lijst met miniaturen van vensters
Name[pt]=Lista de miniaturas das janelas de exemplo
Name[pt_BR]=Lista de miniaturas das janelas de exemplo
Name[sv]=Exempel på miniatyrbilder av fönster
Name[uk]=Приклад списку мініатюр вікон
Name[x-test]=xxExample window thumbnails listxx
Comment=Example showing how to display window thumbnails
Comment[nl]=Voorbeeld van hoe miniaturen van vensters te tonen
Comment[pt]=Exemplo que demonstra como apresentar miniaturas das janelas
Comment[pt_BR]=Exemplo que demostra como apresentar as miniaturas das janelas
Comment[sv]=Exempel som visar hur miniatyrbilder av fönster visas

View File

@ -1,11 +1,14 @@
[Desktop Entry]
Name=Custom DataContainers
Name[de]=Benutzerdefinierte Datencontainer
Name[nl]=Aangepaste gegevenscontainers
Name[pt]=Contentores Personalizados
Name[pt_BR]=DataContainers personalizados
Name[sv]=Egen DataContainer
Name[uk]=Нетипові контейнери даних
Name[x-test]=xxCustom DataContainersxx
Comment=A demonstration of how to subclass DataContainer
Comment[nl]=Een demonstratie van hoe een subklasse toe te kennen aan een gegevenscontainer
Comment[pt]=Um demonstração de como usar a classe DataContainer
Comment[pt_BR]=Demonstração de como usar a subclasse DataContainer
Comment[sv]=En demonstration av hur en delklass av DataContainer skapas

View File

@ -8,6 +8,7 @@ Name[sv]=Enkelt exempel på DataEngine
Name[uk]=Простий приклад рушія даних
Name[x-test]=xxSimple DataEngine Examplexx
Comment=A very basic DataEngine implementation
Comment[nl]=Een erge basisimplementatie van een gegevens-engine
Comment[pt]=Uma implementação muito básica do DataEngine
Comment[pt_BR]=Implementação muito básica do DataEngine
Comment[sv]=En mycket grundläggande implementering av DataEngine

View File

@ -1,11 +1,14 @@
[Desktop Entry]
Name=Sources On Request
Name[de]=Ressourcen auf Anforderung
Name[nl]=Bronnen op verzoek
Name[pt]=Fontes a Pedido
Name[pt_BR]=Fontes a pedido
Name[sv]=Källor på begäran
Name[uk]=Джерела за запитом
Name[x-test]=xxSources On Requestxx
Comment=A DataEngine example showing how to respond to requests for source creation and updates
Comment[nl]=Een voorbeeld van een gegevens-engine die toont hoe te antwoorden op verzoeken voor aanmaken van een bron en bijwerken
Comment[pt]=Um exemplo de DataEngine que demonstra como responder a pedidos de criação e actualização da fonte
Comment[pt_BR]=Exemplo de DataEngine que demonstra como responder a solicitações de criação e atualização da fonte
Comment[sv]=Ett exempel på en DataEngine som visar hur man svara på en begäran om att skapa källor och uppdateringar

View File

@ -12,6 +12,7 @@ Icon=plasma-example-kpart-shell
Type=Application
X-DocPath=plasma-kpart-shell/index.html
GenericName=A KPart shell for Plasma
GenericName[nl]=Een KPart-shell voor Plasma
GenericName[pt]=Uma consola de KPart para o Plasma
GenericName[pt_BR]=Shell KPart para o Plasma
GenericName[sv]=Ett delprogramskal för Plasma

View File

@ -1,11 +1,13 @@
[Desktop Entry]
Name=Home Files
Name[nl]=Persoonlijke bestanden
Name[pt]=Ficheiros Pessoais
Name[pt_BR]=Arquivos pessoais
Name[sv]=Hemfiler
Name[uk]=Файли у домашній теці
Name[x-test]=xxHome Filesxx
Comment=Part of a tutorial demonstrating how to create Runner plugins
Comment[nl]=Deel van een inleiding die demonstreert hoe Runner-plug-ins te maken
Comment[pt]=Parte de um tutorial que demonstra como criar 'plugins' do Runner
Comment[pt_BR]=Parte de um tutorial que demonstra como criar plugins do Runner
Comment[sv]=Del av en handledning som demonstrerar hur insticksprogram till Runner skapas

View File

@ -71,6 +71,14 @@ WindowThumbnail::WindowThumbnail(QQuickItem* parent)
#endif
{
setFlag(ItemHasContents);
connect(this, &QQuickItem::windowChanged, [this](QQuickWindow *window) {
if (!window) {
return;
}
// restart the redirection, it might not have been active yet
stopRedirecting();
startRedirecting();
});
if (QGuiApplication *gui = dynamic_cast<QGuiApplication*>(QCoreApplication::instance())) {
m_xcb = (gui->platformName() == QStringLiteral("xcb"));
if (m_xcb) {
@ -111,6 +119,10 @@ void WindowThumbnail::setWinId(uint32_t winId)
// invalid Id, don't updated
return;
}
if (window() && winId == window()->winId()) {
// don't redirect to yourself
return;
}
stopRedirecting();
m_winId = winId;
startRedirecting();
@ -125,7 +137,7 @@ QSGNode *WindowThumbnail::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
node = new WindowTextureNode();
node->setFiltering(QSGTexture::Linear);
}
if (!m_xcb || m_winId == 0) {
if (!m_xcb || m_winId == 0 || (window() && window()->winId() == m_winId)) {
iconToTexture(node);
} else {
windowToTexture(node);
@ -347,7 +359,7 @@ void WindowThumbnail::stopRedirecting()
void WindowThumbnail::startRedirecting()
{
if (!m_xcb) {
if (!m_xcb || !window() || window()->winId() == m_winId) {
return;
}
#if HAVE_XCB_COMPOSITE

View File

@ -40,47 +40,47 @@ install(DIRECTORY qml/ DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/components)
#The platform specific stuff, overwrites a copy of the desktop one
#it does install some files on top of the old ones, has to be done file by file since if some component from the generic set is more recent than the specifc ones, it wouldn't be overwritten
install(TARGETS plasmacomponentsplugin DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(TARGETS plasmacomponentsplugin DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/BusyIndicator.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ButtonColumn.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ButtonGroup.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/Button.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ButtonRow.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/CheckBox.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/CommonDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/Dialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/Highlight.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/Label.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ListItem.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/Page.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/PageStack.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ProgressBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/QueryDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/RadioButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/SelectionDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/Slider.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/TabBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/TabButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/TabGroup.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
#install(FILES qml/TextArea.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
#install(FILES qml/TextField.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ToolBarLayout.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ToolBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/ToolButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(FILES qml/BusyIndicator.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/ButtonColumn.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/ButtonGroup.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/Button.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/ButtonRow.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/CheckBox.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/CommonDialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/Dialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/Highlight.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/Label.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/ListItem.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/Page.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/PageStack.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/ProgressBar.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/QueryDialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/RadioButton.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/SelectionDialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/Slider.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/TabBar.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/TabButton.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/TabGroup.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
#install(FILES qml/TextArea.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
#install(FILES qml/TextField.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/ToolBarLayout.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/ToolBar.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
install(FILES qml/ToolButton.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)
#Now install the private stuff!
install(FILES qml/private/DualStateButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/InlineDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/PageStack.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/TabGroup.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/ScrollBarDelegate.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/ScrollDecoratorDelegate.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/SectionScroller.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/AppManager.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/TabBarLayout.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/TextFieldFocus.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
install(FILES qml/private/DualStateButton.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
install(FILES qml/private/InlineDialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
install(FILES qml/private/PageStack.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
install(FILES qml/private/TabGroup.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
install(FILES qml/private/ScrollBarDelegate.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
install(FILES qml/private/ScrollDecoratorDelegate.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
install(FILES qml/private/SectionScroller.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
install(FILES qml/private/AppManager.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
install(FILES qml/private/TabBarLayout.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
install(FILES qml/private/TextFieldFocus.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private)
#install platform overrides
install(DIRECTORY platformcomponents/touch/ DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
install(DIRECTORY platformcomponents/touch/ DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components)

View File

@ -87,8 +87,6 @@ Item {
textInput.forceActiveFocus();
}
// Overriding QtQuick.Item activeFocus property.
property alias activeFocus: textInput.activeFocus
// TODO: fix default size
implicitWidth: theme.mSize(theme.defaultFont).width*12

View File

@ -93,6 +93,7 @@ Item {
id: label
text: dualButton.text
renderType: Text.NativeRendering
anchors {
top: parent.top
bottom: parent.bottom

View File

@ -29,20 +29,20 @@ class FallbackComponent : public QObject
{
Q_OBJECT
/**
* Prefix of the path
* This should be something like "plasma","kwin","plasmate",etc
* If the basePath is "plasma", it will be set for the data of plasma like,
* or it can be an absolute path
**/
Q_PROPERTY(QString basePath READ basePath WRITE setBasePath NOTIFY basePathChanged)
/**
* Prefix of the path
* This should be something like "plasma","kwin","plasmate",etc
* If the basePath is "plasma", it will be set for the data of plasma like,
* or it can be an absolute path
**/
Q_PROPERTY(QString basePath READ basePath WRITE setBasePath NOTIFY basePathChanged)
/**
* The possible candidates in order to have a complete path.
* basepath/candidate, where candidate is the first one in the list of candidates
* in order of importance that matches an existing file
**/
Q_PROPERTY(QStringList candidates READ candidates WRITE setCandidates NOTIFY candidatesChanged)
/**
* The possible candidates in order to have a complete path.
* basepath/candidate, where candidate is the first one in the list of candidates
* in order of importance that matches an existing file
**/
Q_PROPERTY(QStringList candidates READ candidates WRITE setCandidates NOTIFY candidatesChanged)
public:
FallbackComponent(QObject *parent = 0);

View File

@ -30,7 +30,7 @@ class KDeclarativeMouseEvent : public QObject
Q_PROPERTY(int y READ y)
Q_PROPERTY(int screenX READ screenX)
Q_PROPERTY(int screenY READ screenY)
Q_PROPERTY(Qt::MouseButton button READ button)
Q_PROPERTY(int button READ button)
Q_PROPERTY(Qt::MouseButtons buttons READ buttons)
Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers)
@ -52,7 +52,7 @@ public:
int y() const { return m_y; }
int screenX() const { return m_screenX; }
int screenY() const { return m_screenY; }
Qt::MouseButton button() const { return m_button; }
int button() const { return m_button; }
Qt::MouseButtons buttons() const { return m_buttons; }
Qt::KeyboardModifiers modifiers() const { return m_modifiers; }

View File

@ -33,7 +33,7 @@
#include <QUiLoader>
#include <kactioncollection.h>
#include <kcoreauthorized.h>
#include <kauthorized.h>
#include <kcolorscheme.h>
#include <kdesktopfile.h>
#include <QDebug>
@ -332,11 +332,12 @@ void Applet::setTitle(const QString &title) const
QString Applet::icon() const
{
if (!d->appletDescription.isValid()) {
return QString();
}
return d->icon;
}
return d->appletDescription.icon();
void Applet::setIcon(const QString &icon)
{
d->icon = icon;
}
KPluginInfo Applet::pluginInfo() const

View File

@ -282,10 +282,16 @@ class PLASMA_EXPORT Applet : public QObject
static Applet *loadPlasmoid(const QString &path, uint appletId = 0);
/**
* Returns the icon related to this applet
* @returns The icon name related to this applet
* By default is the one in the plasmoid desktop file
**/
QString icon() const;
/**
* Sets an icon name for this applet
* @param icon Freedesktop compatible icon name
*/
void setIcon(const QString &icon);
//ACTIONS

View File

@ -70,7 +70,7 @@ void PluginTest::listContainmentsOfType()
void PluginTest::loadDataEngine()
{
Plasma::DataEngine *engine = Plasma::PluginLoader::self()->loadDataEngine("time");
qDebug() << "ENgine loaded successfully" << engine->pluginInfo().name();
//qDebug() << "Engine loaded successfully" << engine->pluginInfo().name();
QVERIFY(engine != 0 || buildonly);
}

View File

@ -223,11 +223,24 @@ void ConfigLoaderHandler::addItem()
QDateTime::fromString(m_default), m_key);
} else if (m_type == "enum") {
m_key = (m_key.isEmpty()) ? m_name : m_key;
bool ok;
int value = m_default.toUInt(&ok);
//if is not an integer, try to find the string value among the registered choices
if (!ok) {
int i = 0;
foreach (const KConfigSkeleton::ItemEnum::Choice &choice, m_enumChoices) {
if (choice.name == m_default) {
value = i;
break;
}
++i;
}
}
KConfigSkeleton::ItemEnum *enumItem =
new KConfigSkeleton::ItemEnum(m_config->currentGroup(),
m_key, *d->newInt(),
m_enumChoices,
m_default.toUInt());
value);
m_config->addItem(enumItem, m_name);
item = enumItem;
} else if (m_type == "font") {

View File

@ -37,7 +37,7 @@
#include <qmimedatabase.h>
#include <QDebug>
#include <kcoreauthorized.h>
#include <kauthorized.h>
#include <klocalizedstring.h>
#include <kservicetypetrader.h>
@ -181,15 +181,15 @@ void Containment::restore(KConfigGroup &group)
setFormFactor((Plasma::Types::FormFactor)group.readEntry("formfactor", (int)d->formFactor));
setWallpaper(group.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaper));
//qDebug() << "setScreen from restore";
d->setScreen(group.readEntry("screen", d->screen));
d->activityId = group.readEntry("activityId", QString());
flushPendingConstraintsEvents();
restoreContents(group);
setImmutability((Types::ImmutabilityType)group.readEntry("immutability", (int)Types::Mutable));
//qDebug() << "setScreen from restore";
d->setScreen(group.readEntry("screen", d->screen));
KConfigGroup cfg = KConfigGroup(corona()->config(), "ActionPlugins");
cfg = KConfigGroup(&cfg, QString::number(containmentType()));

View File

@ -52,6 +52,11 @@ static PluginLoader *s_pluginLoader = 0;
class PluginLoaderPrivate
{
public:
PluginLoaderPrivate()
: packageRE("[^a-zA-Z0-9\\-_]")
{
}
static QSet<QString> knownCategories();
static QString parentAppConstraint(const QString &parentApp = QString());
@ -59,6 +64,7 @@ public:
QHash<QString, QWeakPointer<PackageStructure> > structures;
bool isDefaultLoader;
QString pluginDir;
QRegExp packageRE;
};
QSet<QString> PluginLoaderPrivate::s_customCategories;
@ -250,9 +256,7 @@ DataEngine *PluginLoader::loadDataEngine(const QString &name)
allArgs << offers.first()->storageId();
QString api = offers.first()->property("X-Plasma-API").toString();
if (api.isEmpty()) {
engine = KPluginTrader::createInstanceFromQuery<Plasma::DataEngine>("Plasma/DataEngine",
d->pluginDir,
constraint, 0);
engine = KPluginTrader::createInstanceFromQuery<Plasma::DataEngine>(d->pluginDir, "Plasma/DataEngine", constraint, 0);
} else {
engine = new DataEngine(KPluginInfo(offers.first()), 0);
}
@ -423,9 +427,8 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s
}
if (!specialization.isEmpty()) {
QRegExp re("[^a-zA-Z0-9\\-_]");
// check that the provided strings are safe to use in a ServiceType query
if (re.indexIn(specialization) == -1 && re.indexIn(packageFormat) == -1) {
if (d->packageRE.indexIn(specialization) == -1 && d->packageRE.indexIn(packageFormat) == -1) {
// FIXME: The query below is rather spepcific to script engines. generify if possible
const QString component = packageFormat.right(packageFormat.size() - packageFormat.lastIndexOf('/') - 1);
const QString constraint = QString("[X-Plasma-API] == '%1' and " "'%2' in [X-Plasma-ComponentTypes]").arg(specialization, component);
@ -708,8 +711,7 @@ KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp)
constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
}
list.append(KPluginTrader::self()->query(QStringLiteral("Plasma/DataEngine"),
d->pluginDir, constraint));
list.append(KPluginTrader::self()->query(d->pluginDir, "Plasma/DataEngine", constraint));
return list;
}

View File

@ -52,6 +52,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
q(applet),
immutability(Types::Mutable),
appletDescription(info ? *info : KPluginInfo(service)),
icon(appletDescription.isValid() ? appletDescription.icon() : QString()),
mainConfig(0),
pendingConstraints(Types::NoConstraint),
script(0),
@ -280,6 +281,8 @@ void AppletPrivate::setUiReady()
//if we are the containment and there is still some uncomplete applet, we're still incomplete
if (!c->d->loadingApplets.isEmpty()) {
return;
} else if (!uiReady) {
emit c->uiReadyChanged(true);
}
} else {
c = q->containment();

View File

@ -87,6 +87,7 @@ public:
// applet info we keep around in case its needed
KPluginInfo appletDescription;
QString customTitle;
QString icon;
// bookkeeping
KConfigGroup *mainConfig;

View File

@ -2,9 +2,11 @@ project(PlasmaQuick)
set(plasmaquick_LIB_SRC
plasmaquickview.cpp
configmodel.cpp
configview.cpp
containmentconfigview_p.cpp
currentcontainmentactionsmodel_p.cpp
private/configcategory_p.cpp
#private/containmentconfigview_p.cpp
#private/currentcontainmentactionsmodel_p.cpp
)
@ -12,9 +14,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
add_library(plasmaquick SHARED ${plasmaquick_LIB_SRC})
add_library(PlasmaQuick SHARED ${plasmaquick_LIB_SRC})
target_link_libraries(plasmaquick
target_link_libraries(PlasmaQuick
${Qt5Quick_LIBRARIES}
${Qt5Qml_LIBRARIES}
${KWindowSystem_LIBRARIES}
@ -26,19 +28,20 @@ target_link_libraries(plasmaquick
kdeclarative
)
set_target_properties(plasmaquick PROPERTIES
set_target_properties(PlasmaQuick PROPERTIES
VERSION 5.0.0
SOVERSION 5
)
install(TARGETS plasmaquick EXPORT PlasmaQuickTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS PlasmaQuick EXPORT PlasmaQuickTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
generate_export_header(plasmaquick)
generate_export_header(PlasmaQuick)
set(plasmaquick_LIB_INCLUDES
${CMAKE_CURRENT_BINARY_DIR}/plasmaquick_export.h
plasmaquickview.h
configview.h
configmodel.h
)
install(FILES ${plasmaquick_LIB_INCLUDES}

View File

@ -0,0 +1,247 @@
/*
* Copyright 2013 Marco Martin <mart@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 "private/configcategory_p.h"
#include "configview.h"
#include "configmodel.h"
#include "Plasma/Applet"
#include "Plasma/Containment"
//#include "plasmoid/wallpaperinterface.h"
#include "kdeclarative/configpropertymap.h"
#include <QDebug>
#include <QDir>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQmlContext>
#include <QQuickItem>
#include <KGlobal>
#include <KLocalizedString>
#include <kdeclarative/kdeclarative.h>
#include <Plasma/Corona>
#include <Plasma/PluginLoader>
//////////////////////////////ConfigModel
class ConfigModelPrivate
{
public:
ConfigModelPrivate(ConfigModel *model);
~ConfigModelPrivate();
ConfigModel *q;
QList<ConfigCategory*> categories;
QWeakPointer<Plasma::Applet> appletInterface;
void appendCategory(ConfigCategory *c);
void clear();
QVariant get(int row) const;
static ConfigCategory *categories_at(QQmlListProperty<ConfigCategory> *prop, int index);
static void categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o);
static int categories_count(QQmlListProperty<ConfigCategory> *prop);
static void categories_clear(QQmlListProperty<ConfigCategory> *prop);
};
ConfigModelPrivate::ConfigModelPrivate(ConfigModel *model)
: q(model)
{
}
ConfigModelPrivate::~ConfigModelPrivate()
{
}
ConfigCategory *ConfigModelPrivate::categories_at(QQmlListProperty<ConfigCategory> *prop, int index)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (!model || index >= model->d->categories.count() || index < 0) {
return 0;
} else {
return model->d->categories.at(index);
}
}
void ConfigModelPrivate::categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (!o || !model) {
return;
}
if (o->parent() == prop->object) {
o->setParent(0);
}
o->setParent(prop->object);
model->d->appendCategory(o);
}
int ConfigModelPrivate::categories_count(QQmlListProperty<ConfigCategory> *prop)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (model) {
return model->d->categories.count();
} else {
return 0;
}
}
void ConfigModelPrivate::categories_clear(QQmlListProperty<ConfigCategory> *prop)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (!model) {
return;
}
model->clear();
}
void ConfigModelPrivate::clear()
{
q->beginResetModel();
while (!categories.isEmpty()) {
categories.first()->setParent(0);
categories.pop_front();
}
q->endResetModel();
emit q->countChanged();
}
void ConfigModelPrivate::appendCategory(ConfigCategory *c)
{
q->beginInsertRows(QModelIndex(), categories.size(), categories.size());
categories.append(c);
q->endInsertRows();
emit q->countChanged();
}
QVariant ConfigModelPrivate::get(int row) const
{
QVariantMap value;
if (row < 0 || row >= categories.count()) {
return value;
}
value["name"] = categories.at(row)->name();
value["icon"] = categories.at(row)->icon();
value["pluginName"] = categories.at(row)->pluginName();
if (appletInterface) {
value["source"] = QUrl::fromLocalFile(appletInterface.data()->package().filePath("ui", categories.at(row)->source()));
} else {
value["source"] = categories.at(row)->source();
}
return value;
}
ConfigModel::ConfigModel(QObject *parent)
: QAbstractListModel(parent),
d(new ConfigModelPrivate(this))
{
QHash<int, QByteArray> roleNames;
roleNames[NameRole] = "name";
roleNames[IconRole] = "icon";
roleNames[SourceRole] = "source";
roleNames[PluginNameRole] = "pluginName";
setRoleNames(roleNames);
}
ConfigModel::~ConfigModel()
{
delete d;
}
int ConfigModel::rowCount(const QModelIndex &index) const
{
if (index.column() > 0) {
return 0;
}
return d->categories.count();
}
QVariant ConfigModel::data(const QModelIndex& index, int role) const
{
if (index.row() < 0 || index.row() >= d->categories.count()) {
return QVariant();
}
switch (role) {
case NameRole:
return d->categories.at(index.row())->name();
case IconRole:
return d->categories.at(index.row())->icon();
case SourceRole:
if (d->appletInterface) {
return QUrl::fromLocalFile(d->appletInterface.data()->package().filePath("ui", d->categories.at(index.row())->source()));
} else {
return d->categories.at(index.row())->source();
}
case PluginNameRole:
return d->categories.at(index.row())->pluginName();
default:
return QVariant();
}
}
QVariant ConfigModel::get(int row) const
{
return d->get(row);
}
void ConfigModel::appendCategory(const QString &iconName, const QString &name,
const QString &path, const QString &pluginName)
{
ConfigCategory *cat = new ConfigCategory(this);
cat->setIcon(iconName);
cat->setName(name);
cat->setSource(path);
cat->setPluginName(pluginName);
d->appendCategory(cat);
}
void ConfigModel::clear()
{
d->clear();
}
void ConfigModel::setApplet(Plasma::Applet *interface)
{
d->appletInterface = interface;
}
Plasma::Applet *ConfigModel::applet() const
{
return d->appletInterface.data();
}
QQmlListProperty<ConfigCategory> ConfigModel::categories()
{
return QQmlListProperty<ConfigCategory>(this, 0, ConfigModelPrivate::categories_append,
ConfigModelPrivate::categories_count,
ConfigModelPrivate::categories_at,
ConfigModelPrivate::categories_clear);
}
#include "moc_configmodel.cpp"

View File

@ -0,0 +1,103 @@
/*
* Copyright 2013 Marco Martin <mart@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 CONFIGMODEL_H
#define CONFIGMODEL_H
#include <QQmlListProperty>
#include <QAbstractListModel>
#include <plasmaquick/plasmaquick_export.h>
namespace Plasma {
class Applet;
}
class ConfigPropertyMap;
class ConfigCategoryPrivate;
class ConfigModelPrivate;
class ConfigCategory;
/**
* This model contains all the possible config categories for a dialog,
* such as categories of the config dialog for an Applet
* TODO: it should probably become an import instead of a library?
*/
class PLASMAQUICK_EXPORT ConfigModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QQmlListProperty<ConfigCategory> categories READ categories CONSTANT)
Q_CLASSINFO("DefaultProperty", "categories")
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
enum Roles {
NameRole = Qt::UserRole+1,
IconRole,
SourceRole,
PluginNameRole
};
ConfigModel(QObject *parent = 0);
~ConfigModel();
/**
* add a new category in the model
* @param ConfigCategory the new category
**/
void appendCategory(const QString &iconName, const QString &name,
const QString &path, const QString &pluginName);
/**
* clears the model
**/
void clear();
void setApplet(Plasma::Applet *interface);
Plasma::Applet *applet() const;
int count() {return rowCount();}
virtual int rowCount(const QModelIndex &index = QModelIndex()) const;
virtual QVariant data(const QModelIndex&, int) const;
/**
* @param row the row for which the data will be returned
* @raturn the data of the specified row
**/
Q_INVOKABLE QVariant get(int row) const;
/**
* @return the categories of the model
**/
QQmlListProperty<ConfigCategory> categories();
Q_SIGNALS:
/**
* emitted when the count is changed
**/
void countChanged();
private:
friend class ConfigModelPrivate;
ConfigModelPrivate *const d;
};
#endif // multiple inclusion guard

View File

@ -17,8 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "configview_p.h"
#include "private/configcategory_p.h"
#include "configview.h"
#include "configmodel.h"
#include "Plasma/Applet"
#include "Plasma/Containment"
//#include "plasmoid/wallpaperinterface.h"
@ -38,297 +39,6 @@
#include <Plasma/Corona>
#include <Plasma/PluginLoader>
///////////////////////ConfigCategory
ConfigCategory::ConfigCategory(QObject *parent)
: QObject(parent)
{
}
ConfigCategory::~ConfigCategory()
{}
QString ConfigCategory::name() const
{
return m_name;
}
void ConfigCategory::setName(const QString &name)
{
if (m_name == name) {
return;
}
m_name = name;
emit nameChanged();
}
QString ConfigCategory::icon() const
{
return m_icon;
}
void ConfigCategory::setIcon(const QString &icon)
{
if (m_icon == icon) {
return;
}
m_icon = icon;
emit iconChanged();
}
QString ConfigCategory::source() const
{
return m_source;
}
void ConfigCategory::setSource(const QString &source)
{
if (m_source == source) {
return;
}
m_source = source;
emit sourceChanged();
}
QString ConfigCategory::pluginName() const
{
return m_pluginName;
}
void ConfigCategory::setPluginName(const QString &name)
{
if (m_pluginName == name) {
return;
}
m_pluginName = name;
emit pluginNameChanged();
}
//////////////////////////////ConfigModel
class ConfigModelPrivate
{
public:
ConfigModelPrivate(ConfigModel *model);
~ConfigModelPrivate();
ConfigModel *q;
QList<ConfigCategory*> categories;
QWeakPointer<Plasma::Applet> appletInterface;
void appendCategory(ConfigCategory *c);
void clear();
QVariant get(int row) const;
static ConfigCategory *categories_at(QQmlListProperty<ConfigCategory> *prop, int index);
static void categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o);
static int categories_count(QQmlListProperty<ConfigCategory> *prop);
static void categories_clear(QQmlListProperty<ConfigCategory> *prop);
};
ConfigModelPrivate::ConfigModelPrivate(ConfigModel *model)
: q(model)
{
}
ConfigModelPrivate::~ConfigModelPrivate()
{
}
ConfigCategory *ConfigModelPrivate::categories_at(QQmlListProperty<ConfigCategory> *prop, int index)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (!model || index >= model->d->categories.count() || index < 0) {
return 0;
} else {
return model->d->categories.at(index);
}
}
void ConfigModelPrivate::categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (!o || !model) {
return;
}
if (o->parent() == prop->object) {
o->setParent(0);
}
o->setParent(prop->object);
model->appendCategory(o);
}
int ConfigModelPrivate::categories_count(QQmlListProperty<ConfigCategory> *prop)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (model) {
return model->d->categories.count();
} else {
return 0;
}
}
void ConfigModelPrivate::categories_clear(QQmlListProperty<ConfigCategory> *prop)
{
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
if (!model) {
return;
}
model->clear();
}
void ConfigModelPrivate::clear()
{
q->beginResetModel();
while (!categories.isEmpty()) {
categories.first()->setParent(0);
categories.pop_front();
}
q->endResetModel();
emit q->countChanged();
}
void ConfigModelPrivate::appendCategory(ConfigCategory *c)
{
q->beginInsertRows(QModelIndex(), categories.size(), categories.size());
categories.append(c);
q->endInsertRows();
emit q->countChanged();
}
QVariant ConfigModelPrivate::get(int row) const
{
QVariantMap value;
if (row < 0 || row >= categories.count()) {
return value;
}
value["name"] = categories.at(row)->name();
value["icon"] = categories.at(row)->icon();
value["pluginName"] = categories.at(row)->pluginName();
if (appletInterface) {
value["source"] = QUrl::fromLocalFile(appletInterface.data()->package().filePath("ui", categories.at(row)->source()));
} else {
value["source"] = categories.at(row)->source();
}
return value;
}
ConfigModel::ConfigModel(QObject *parent)
: QAbstractListModel(parent),
d(new ConfigModelPrivate(this))
{
QHash<int, QByteArray> roleNames;
roleNames[NameRole] = "name";
roleNames[IconRole] = "icon";
roleNames[SourceRole] = "source";
roleNames[PluginNameRole] = "pluginName";
setRoleNames(roleNames);
}
ConfigModel::~ConfigModel()
{
delete d;
}
int ConfigModel::rowCount(const QModelIndex &index) const
{
if (index.column() > 0) {
return 0;
}
return d->categories.count();
}
QVariant ConfigModel::data(const QModelIndex& index, int role) const
{
if (index.row() < 0 || index.row() >= d->categories.count()) {
return QVariant();
}
switch (role) {
case NameRole:
return d->categories.at(index.row())->name();
case IconRole:
return d->categories.at(index.row())->icon();
case SourceRole:
if (d->appletInterface) {
return QUrl::fromLocalFile(d->appletInterface.data()->package().filePath("ui", d->categories.at(index.row())->source()));
} else {
return d->categories.at(index.row())->source();
}
case PluginNameRole:
return d->categories.at(index.row())->pluginName();
default:
return QVariant();
}
}
QVariant ConfigModel::get(int row) const
{
return d->get(row);
}
void ConfigModel::appendCategory(ConfigCategory *c)
{
d->appendCategory(c);
}
void ConfigModel::clear()
{
d->clear();
}
void ConfigModel::setApplet(Plasma::Applet *interface)
{
d->appletInterface = interface;
}
Plasma::Applet *ConfigModel::applet() const
{
return d->appletInterface.data();
}
QQmlListProperty<ConfigCategory> ConfigModel::categories()
{
return QQmlListProperty<ConfigCategory>(this, 0, ConfigModel::categories_append,
ConfigModel::categories_count,
ConfigModel::categories_at,
ConfigModel::categories_clear);
}
ConfigCategory *ConfigModel::categories_at(QQmlListProperty<ConfigCategory> *prop, int index)
{
return ConfigModelPrivate::categories_at(prop, index);
}
void ConfigModel::categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o)
{
ConfigModelPrivate::categories_append(prop, o);
}
int ConfigModel::categories_count(QQmlListProperty<ConfigCategory> *prop)
{
return ConfigModelPrivate::categories_count(prop);
}
void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
{
ConfigModelPrivate::categories_clear(prop);
}
//////////////////////////////ConfigView

View File

@ -17,14 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CONFIGUILOADER_H
#define CONFIGUILOADER_H
#ifndef CONFIGVIEW_H
#define CONFIGVIEW_H
#include <QQuickView>
#include <QJSValue>
#include <QQmlListProperty>
#include <QStandardItemModel>
#include <plasmaquick/plasmaquick_export.h>
@ -32,78 +29,10 @@ namespace Plasma {
class Applet;
}
class ConfigPropertyMap;
class ConfigCategoryPrivate;
class ConfigModelPrivate;
class ConfigCategory;
class PLASMAQUICK_EXPORT ConfigModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QQmlListProperty<ConfigCategory> categories READ categories CONSTANT)
Q_CLASSINFO("DefaultProperty", "categories")
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
enum Roles {
NameRole = Qt::UserRole+1,
IconRole,
SourceRole,
PluginNameRole
};
ConfigModel(QObject *parent = 0);
~ConfigModel();
/**
* add a new category in the model
* @param ConfigCategory the new category
**/
void appendCategory(ConfigCategory *c);
/**
* clears the model
**/
void clear();
void setApplet(Plasma::Applet *interface);
Plasma::Applet *applet() const;
int count() {return rowCount();}
virtual int rowCount(const QModelIndex &index = QModelIndex()) const;
virtual QVariant data(const QModelIndex&, int) const;
/**
* @param row the row for which the data will be returned
* @raturn the data of the specified row
**/
Q_INVOKABLE QVariant get(int row) const;
/**
* @return the categories of the model
**/
QQmlListProperty<ConfigCategory> categories();
static ConfigCategory *categories_at(QQmlListProperty<ConfigCategory> *prop, int index);
static void categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o);
static int categories_count(QQmlListProperty<ConfigCategory> *prop);
static void categories_clear(QQmlListProperty<ConfigCategory> *prop);
Q_SIGNALS:
/**
* emitted when the count is changed
**/
void countChanged();
private:
friend class ConfigModelPrivate;
ConfigModelPrivate *const d;
};
class ConfigViewPrivate;
class ConfigModel;
class PLASMAQUICK_EXPORT ConfigView : public QQuickView
{
Q_OBJECT

View File

@ -17,7 +17,6 @@
*/
#include "plasmaquickview.h"
#include "containmentconfigview_p.h"
#include "configview.h"
#include <QDebug>
@ -35,7 +34,6 @@ public:
PlasmaQuickViewPrivate(Plasma::Corona *corona, PlasmaQuickView *view);
~PlasmaQuickViewPrivate();
void init();
void setContainment(Plasma::Containment *cont);
Plasma::Types::FormFactor formFactor() const;
Plasma::Types::Location location() const;
@ -58,31 +56,6 @@ PlasmaQuickViewPrivate::~PlasmaQuickViewPrivate()
{
}
void PlasmaQuickViewPrivate::init()
{
//FIXME: for some reason all windows must have alpha enable otherwise the ones that do won't paint.
//Probably is an architectural problem
QSurfaceFormat format;
format.setAlphaBufferSize(8);
q->setFormat(format);
q->setColor(Qt::transparent);
QObject::connect(q->screen(), &QScreen::virtualGeometryChanged,
q, &PlasmaQuickView::screenGeometryChanged);
if (!corona->package().isValid()) {
qWarning() << "Invalid home screen package";
}
q->setResizeMode(PlasmaQuickView::SizeRootObjectToView);
q->setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml")));
QObject::connect(corona, &Plasma::Corona::packageChanged,
q, &PlasmaQuickView::coronaPackageChanged);
}
void PlasmaQuickViewPrivate::setContainment(Plasma::Containment *cont)
{
if (containment.data() == cont) {
@ -129,7 +102,9 @@ void PlasmaQuickViewPrivate::setContainment(Plasma::Containment *cont)
if (graphicObject) {
qDebug() << "using as graphic containment" << graphicObject << containment.data();
//graphicObject->setProperty("visible", false);
//by resizing before adding, it will avoid some resizes in most cases
graphicObject->setProperty("width", q->width());
graphicObject->setProperty("height", q->height());
graphicObject->setProperty("drawWallpaper",
(cont->containmentType() == Plasma::Types::DesktopContainment ||
cont->containmentType() == Plasma::Types::CustomContainment));
@ -167,13 +142,8 @@ void PlasmaQuickViewPrivate::showConfigurationInterface(Plasma::Applet *applet)
return;
}
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(applet);
configView = new ConfigView(applet);
if (cont) {
configView = new ContainmentConfigView(cont);
} else {
configView = new ConfigView(applet);
}
configView.data()->init();
configView.data()->show();
}
@ -185,7 +155,24 @@ PlasmaQuickView::PlasmaQuickView(Plasma::Corona *corona, QWindow *parent)
: QQuickView(parent),
d(new PlasmaQuickViewPrivate(corona, this))
{
d->init();
QSurfaceFormat format;
format.setAlphaBufferSize(8);
setFormat(format);
setColor(Qt::transparent);
QObject::connect(screen(), &QScreen::virtualGeometryChanged,
this, &PlasmaQuickView::screenGeometryChanged);
if (!corona->package().isValid()) {
qWarning() << "Invalid home screen package";
}
setResizeMode(PlasmaQuickView::SizeRootObjectToView);
QObject::connect(corona, &Plasma::Corona::packageChanged,
this, &PlasmaQuickView::coronaPackageChanged);
}
PlasmaQuickView::~PlasmaQuickView()

View File

@ -0,0 +1,115 @@
/*
* Copyright 2013 Marco Martin <mart@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 "configcategory_p.h"
#include "configview.h"
#include "configmodel.h"
#include "Plasma/Applet"
#include "Plasma/Containment"
//#include "plasmoid/wallpaperinterface.h"
#include "kdeclarative/configpropertymap.h"
#include <QDebug>
#include <QDir>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQmlContext>
#include <QQuickItem>
#include <KGlobal>
#include <KLocalizedString>
#include <kdeclarative/kdeclarative.h>
#include <Plasma/Corona>
#include <Plasma/PluginLoader>
///////////////////////ConfigCategory
ConfigCategory::ConfigCategory(QObject *parent)
: QObject(parent)
{
}
ConfigCategory::~ConfigCategory()
{}
QString ConfigCategory::name() const
{
return m_name;
}
void ConfigCategory::setName(const QString &name)
{
if (m_name == name) {
return;
}
m_name = name;
emit nameChanged();
}
QString ConfigCategory::icon() const
{
return m_icon;
}
void ConfigCategory::setIcon(const QString &icon)
{
if (m_icon == icon) {
return;
}
m_icon = icon;
emit iconChanged();
}
QString ConfigCategory::source() const
{
return m_source;
}
void ConfigCategory::setSource(const QString &source)
{
if (m_source == source) {
return;
}
m_source = source;
emit sourceChanged();
}
QString ConfigCategory::pluginName() const
{
return m_pluginName;
}
void ConfigCategory::setPluginName(const QString &name)
{
if (m_pluginName == name) {
return;
}
m_pluginName = name;
emit pluginNameChanged();
}
#include "private/moc_configcategory_p.cpp"

View File

@ -17,11 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CONFIGUILOADER_P_H
#define CONFIGUILOADER_P_H
#ifndef CONFIGCATEGORY_P_H
#define CONFIGCATEGORY_P_H
#include <QObject>
//This class represents a single row item of the ConfigModel model in a QML friendly manner.
//the properties contains all the data needed to represent an icon in the sidebar of a configuration dialog, of applets or containments
class ConfigCategory : public QObject
{
Q_OBJECT

View File

@ -6,6 +6,7 @@ X-KDE-DBus-ModuleName=plaformstatus
X-KDE-Kded-autoload=true
X-KDE-Kded-load-on-demand=false
Name=Platform Status
Name[de]=Plattform-Status
Name[fr]=État de la plate-forme
Name[nl]=Status van platform
Name[pl]=Stan Platformy

View File

@ -15,6 +15,7 @@ include_directories(${KDE4_INCLUDE_DIR}/KDE ${PHONON_INCLUDES} ${CMAKE_CURRENT_S
set(declarative_appletscript_SRCS
declarative/packageaccessmanager.cpp
declarative/packageaccessmanagerfactory.cpp
declarative/packageurlinterceptor.cpp
plasmoid/appletinterface.cpp
plasmoid/containmentinterface.cpp
plasmoid/declarativeappletscript.cpp

View File

@ -3,6 +3,15 @@ Type=ServiceType
X-KDE-ServiceType=Plasma/Wallpaper
Comment=Plasma wallpaper
Comment[cs]=Tapeta Plasmy
Comment[de]=Plasma-Hintergrundbild
Comment[nl]=Plasma-bureaubladachtergrond
Comment[pt]=Papel de parede do Plasma
Comment[pt_BR]=Papel de parede do Plasma
Comment[sk]=Tapeta Plasma
Comment[sv]=Plasma skrivbordsunderlägg
Comment[uk]=Тло стільниці Плазми
Comment[x-test]=xxPlasma wallpaperxx
[PropertyDef::X-Plasma-FormFactors]
Type=QStringList

View File

@ -0,0 +1,112 @@
/*
* Copyright 2013 Marco Martin <notmart@gmail.com>
*
* 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 "packageurlinterceptor.h"
#include <QDebug>
#include <QQmlEngine>
#include <QFile>
#include <kdeclarative/kdeclarative.h>
PackageUrlInterceptor::PackageUrlInterceptor(QQmlEngine *engine, const Plasma::Package &p)
: QQmlAbstractUrlInterceptor(),
m_package(p),
m_engine(engine)
{
}
PackageUrlInterceptor::~PackageUrlInterceptor()
{
}
QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type)
{
//qDebug() << "Intercepted URL:" << path;
//TODO: security: permission for remote urls
if (!path.isLocalFile() ) {
return path;
}
//FIXME: probably needed for QmldirFile as well.
//at the moment a qt bug prevents intercept() working with qmldirs
//see https://codereview.qt-project.org/#change,61208
if (type != QQmlAbstractUrlInterceptor::QmldirFile) {
//asked a file inside a package: let's rewrite the url!
if (path.path().startsWith(m_package.path())) {
//qDebug() << "Found URL in package" << path;
//tries to isolate the relative path asked relative to the contentsPrefixPath: like ui/foo.qml
QString relativePath;
foreach (const QString &prefix, m_package.contentsPrefixPaths()) {
if (path.path().startsWith(m_package.path()+prefix)) {
//obtain a string in the form ui/foo/bar/baz.qml
relativePath = path.path().mid(QString(m_package.path()+prefix).length());
break;
}
}
//should never happen
Q_ASSERT(!relativePath.isEmpty());
QStringList components = relativePath.split("/");
//a path with less than 2 items should ever happen
Q_ASSERT(components.count() >= 2);
components.pop_front();
//obtain a string in the form foo/bar/baz.qml: ui/ gets discarded
QString filename = components.join("/");
//qDebug() << "Returning" << QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename));
return QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename));
//forbid to load random absolute paths
} else {
foreach (const QString &import, m_engine->importPathList()) {
//it's from an import, good
//TODO: implement imports whitelist?
if (path.path().startsWith(import)) {
qDebug() << "Found import, access granted" << path;
//check if there is a platform specific file that overrides this import
foreach (const QString &platform, KDeclarative::runtimePlatform()) {
qDebug() << "Trying" << platform;
//search for a platformqml/ path sibling of this import path
QString platformPath = import+"/../platformqml/"+platform+path.path().mid(import.length());
QFile f(platformPath);
qDebug() << "Found a platform specific file:" << QUrl::fromLocalFile(platformPath)<<f.exists();
if (f.exists()) {
return QUrl::fromLocalFile(platformPath);
}
}
return path;
}
}
qWarning() << "WARNING: Access denied for URL" << path;
}
}
return path;
}

View File

@ -0,0 +1,73 @@
/*
* Copyright 2013 Marco Martin <notmart@gmail.com>
*
* 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 PACKAGEURLINTERCEPTOR_H
#define PACKAGEURLINTERCEPTOR_H
#include "qqmlabstracturlinterceptor_p.h"
#include <Plasma/Package>
class QQmlEngine;
//depends from https://codereview.qt-project.org/#change,65626
class PackageUrlInterceptor: public QQmlAbstractUrlInterceptor
{
public:
PackageUrlInterceptor(QQmlEngine *engine, const Plasma::Package &p);
virtual ~PackageUrlInterceptor();
virtual QUrl intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type);
static inline QByteArray prefixForType(QQmlAbstractUrlInterceptor::DataType type, const QString &fileName)
{
switch (type) {
case QQmlAbstractUrlInterceptor::QmlFile:
return "ui";
case QQmlAbstractUrlInterceptor::JavaScriptFile:
return "scripts";
default:
break;
}
//failed by type, let's try by extension
const QString extension = fileName.mid(fileName.lastIndexOf(".") + 1).toLower();
if (extension == "svg" || extension == "svgz" ||
extension == "png" || extension == "gif" ||
extension == "jpg" || extension == "jpeg") {
return "images";
//FIXME: are those necessary? are they *always* catched by type?
} else if (extension == "js") {
return "scripts";
} else if (extension == "qml") {
return "ui";
//everything else, throw it in "data"
} else {
return "data";
}
}
private:
Plasma::Package m_package;
QQmlEngine *m_engine;
};
#endif

View File

@ -0,0 +1,66 @@
/****************************************************************************
**
** Copyright (C) 2013 Research In Motion.
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
//Private API for 5.1 (at least)
#ifndef QQMLABSTRACTURLINTERCEPTOR_H
#define QQMLABSTRACTURLINTERCEPTOR_H
#include <QtCore/qurl.h>
QT_BEGIN_NAMESPACE
class QQmlAbstractUrlInterceptor
{
Q_FLAGS(InterceptionPoint)
public:
enum DataType { //Matches QQmlDataBlob::Type
QmlFile = 0,
JavaScriptFile = 1,
QmldirFile = 2,
UrlString = 0x1000
};
QQmlAbstractUrlInterceptor() {}
virtual ~QQmlAbstractUrlInterceptor() {}
virtual QUrl intercept(const QUrl &path, DataType type) = 0;
};
QT_END_NAMESPACE
#endif

View File

@ -49,6 +49,7 @@
#include <kdeclarative/configpropertymap.h>
#include <kdeclarative/qmlobject.h>
#include "declarative/packageaccessmanagerfactory.h"
#include "declarative/packageurlinterceptor.h"
Q_DECLARE_METATYPE(AppletInterface*)
@ -112,6 +113,10 @@ void AppletInterface::init()
delete factory;
engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(m_appletScriptEngine->package()));
//Hook generic url resolution to the applet package as well
//TODO: same thing will have to be done for every qqmlengine: PackageUrlInterceptor is material for plasmaquick?
engine->setUrlInterceptor(new PackageUrlInterceptor(engine, m_appletScriptEngine->package()));
m_qmlObject->setSource(QUrl::fromLocalFile(m_appletScriptEngine->mainScript()));
if (!m_qmlObject->engine() || !m_qmlObject->engine()->rootContext() || !m_qmlObject->engine()->rootContext()->isValid() || m_qmlObject->mainComponent()->isError()) {
@ -138,7 +143,11 @@ void AppletInterface::init()
m_qmlObject->engine()->rootContext()->setContextProperty("plasmoid", this);
m_qmlObject->completeInitialization();
//initialize size, so an useless resize less
QVariantHash initialProperties;
initialProperties["width"] = width();
initialProperties["height"] = height();
m_qmlObject->completeInitialization(initialProperties);
qDebug() << "Graphic object created:" << applet() << applet()->property("graphicObject");
@ -212,21 +221,31 @@ QObject* AppletInterface::configuration() const
return m_configuration;
}
uint AppletInterface::id() const
{
return applet()->id();
}
QString AppletInterface::icon() const
{
return applet()->icon();
}
void AppletInterface::setIcon(const QString &icon)
{
if (applet()->icon() == icon) {
return;
}
applet()->setIcon(icon);
emit iconChanged();
}
QString AppletInterface::title() const
{
return applet()->title();
}
uint AppletInterface::id() const
{
return applet()->id();
}
void AppletInterface::setTitle(const QString &title)
{
if (applet()->title() == title) {
@ -634,7 +653,8 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o
void AppletInterface::compactRepresentationCheck()
{
if (!m_qmlObject->rootObject() || qobject_cast<ContainmentInterface *>(this)) {
if (width() <= 0 || height() <= 0 || !m_qmlObject->rootObject() ||
qobject_cast<ContainmentInterface *>(this)) {
return;
}
@ -648,7 +668,7 @@ void AppletInterface::compactRepresentationCheck()
minHint.setHeight(m_qmlObject->rootObject()->property("minimumHeight").toReal());
}
//TODO: completely arbitrary for now
//Make it an icon
if (width() < minHint.width() || height() < minHint.height()) {
m_expanded = false;
@ -686,12 +706,31 @@ void AppletInterface::compactRepresentationCheck()
//replace the full applet with the collapsed view
m_compactUiObject.data()->setProperty("visible", true);
m_compactUiObject.data()->setProperty("parent", QVariant::fromValue(this));
//set anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_compactUiObject.data(), "parent");
QQmlProperty prop(m_compactUiObject.data(), "anchors.fill");
prop.write(expr.evaluate());
{
//set anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_compactUiObject.data(), "parent");
QQmlProperty prop(m_compactUiObject.data(), "anchors.fill");
prop.write(expr.evaluate());
}
m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(m_compactUiObject.data()));
{
//reset all the anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), "anchors.fill=undefined;anchors.left=undefined;anchors.right=undefined;anchors.top=undefined;anchors.bottom=undefined;");
expr.evaluate();
}
KConfigGroup cg = applet()->config();
cg = KConfigGroup(&cg, "PopupApplet");
int width = cg.readEntry("DialogWidth", 0);
int height = cg.readEntry("DialogHeight", 0);
m_qmlObject->rootObject()->setProperty("width", width);
m_qmlObject->rootObject()->setProperty("height", height);
m_compactUiObject.data()->setProperty("applet", QVariant::fromValue(m_qmlObject->rootObject()));
//hook m_compactUiObject size hints to this size hint
@ -699,6 +738,13 @@ void AppletInterface::compactRepresentationCheck()
if (m_qmlObject->rootObject()) {
disconnect(m_qmlObject->rootObject(), 0, this, 0);
}
//resize of the root object means popup resize when iconified
connect(m_qmlObject->rootObject(), SIGNAL(widthChanged()),
this, SLOT(updatePopupSize()));
connect(m_qmlObject->rootObject(), SIGNAL(heightChanged()),
this, SLOT(updatePopupSize()));
if (m_compactUiObject.data()->property("minimumWidth").isValid()) {
connect(m_compactUiObject.data(), SIGNAL(minimumWidthChanged()),
this, SIGNAL(minimumWidthChanged()));
@ -741,6 +787,7 @@ void AppletInterface::compactRepresentationCheck()
emit expandedChanged();
//show the full UI
} else {
m_expanded = true;
emit expandedChanged();
@ -750,6 +797,11 @@ void AppletInterface::compactRepresentationCheck()
disconnect(m_compactUiObject.data(), 0, this, 0);
}
disconnect(m_qmlObject->rootObject(), SIGNAL(widthChanged()),
this, SLOT(updatePopupSize()));
disconnect(m_qmlObject->rootObject(), SIGNAL(heightChanged()),
this, SLOT(updatePopupSize()));
//Here we have to use the old connect syntax, because we don't have access to the class type
if (m_qmlObject->rootObject()->property("minimumWidth").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(minimumWidthChanged()),
@ -799,6 +851,14 @@ void AppletInterface::compactRepresentationCheck()
}
}
void AppletInterface::updatePopupSize()
{
KConfigGroup cg = applet()->config();
cg = KConfigGroup(&cg, "PopupApplet");
cg.writeEntry("DialogWidth", m_qmlObject->rootObject()->property("width").toInt());
cg.writeEntry("DialogHeight", m_qmlObject->rootObject()->property("height").toInt());
}
void AppletInterface::itemChange(ItemChange change, const ItemChangeData &value)
{
if (change == QQuickItem::ItemSceneChange) {

View File

@ -64,11 +64,10 @@ class AppletInterface : public QQuickItem
*/
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
//TODO: writable icon
/**
* Icon to represent the plasmoid
*/
Q_PROPERTY(QString icon READ icon CONSTANT)
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
/**
* Applet id: is unique in the whole Plasma session and will never change across restarts
@ -192,6 +191,7 @@ public:
Q_INVOKABLE QAction *action(QString name) const;
/**
* FIXME: remove?
* Retrieve the path of a file from the Plasmoid package
* @param fileName the package-recognized name, such as "mainscript"
* @returns the full absolute path of the file, if found, an empty string if not
@ -199,6 +199,7 @@ public:
Q_INVOKABLE QString file(const QString &fileName);
/**
* FIXME: remove?
* Retrieve the path of a file from the Plasmoid package
* @param fileType the type supported from the package, such as "ui", "config" or "image"
* @param filePath the name of the file, such as "foo.qml" or "bar.png"
@ -233,6 +234,7 @@ public:
//PROPERTY ACCESSORS-------------------------------------------------------------------
QString icon() const;
void setIcon(const QString &icon);
QString title() const;
void setTitle(const QString &title);
@ -281,10 +283,18 @@ public:
qreal implicitHeight() const;
Q_SIGNALS:
/**
* somebody else, usually the containment sent some data to the applet
* @param mimetype the mime type of the data such as text/plain
* @param data either the actual data or an URL representing it
*/
void externalData(const QString &mimetype, const QVariant &data);
void releaseVisualFocus();
void configNeedsSaving();
//PROPERTY change notifiers--------------
void iconChanged();
void titleChanged();
void formFactorChanged();
void locationChanged();
@ -317,6 +327,7 @@ protected Q_SLOTS:
private Q_SLOTS:
void compactRepresentationCheck();
void updatePopupSize();
private:
//Helper for minimumWidth etc.

View File

@ -55,7 +55,6 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
m_wallpaperInterface(0)
{
setAcceptedMouseButtons(Qt::AllButtons);
setFlag(QQuickItem::ItemAcceptsDrops);
qmlRegisterType<ContainmentInterface>();
@ -76,27 +75,17 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
connect(containment()->corona(), &Plasma::Corona::availableScreenRegionChanged,
this, &ContainmentInterface::availableScreenRegionChanged);
}
}
void ContainmentInterface::init()
{
AppletInterface::init();
foreach (QObject *appletObj, m_appletInterfaces) {
AppletInterface *applet = qobject_cast<AppletInterface *>(appletObj);
if (applet) {
if (!applet->qmlObject()) {
applet->init();
}
m_appletInterfaces << applet;
emit appletAdded(applet, 0, 0);
}
}
if (!m_appletInterfaces.isEmpty()) {
emit appletsChanged();
}
}
void ContainmentInterface::init()
{
AppletInterface::init();
if (m_qmlObject->rootObject()->property("minimumWidth").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(minimumWidthChanged()),
this, SIGNAL(minimumWidthChanged()));
@ -195,7 +184,7 @@ QVariantList ContainmentInterface::availableScreenRegion(int id) const
return regVal;
}
void ContainmentInterface::addApplet(const QString &plugin, const QVariantList &args, const QPoint &pos)
Plasma::Applet *ContainmentInterface::addApplet(const QString &plugin, const QVariantList &args, const QPoint &pos)
{
//HACK
//This is necessary to delay the appletAdded signal (of containmentInterface) AFTER the applet graphics object has been created
@ -211,6 +200,19 @@ void ContainmentInterface::addApplet(const QString &plugin, const QVariantList &
emit appletAdded(appletGraphicObject, pos.x(), pos.y());
emit appletsChanged();
return applet;
}
void ContainmentInterface::setAppletArgs(Plasma::Applet *applet, const QString &mimetype, const QString &data)
{
if (!applet) {
return;
}
AppletInterface *appletInterface = applet->property("graphicObject").value<AppletInterface *>();
if (appletInterface) {
emit appletInterface->externalData(mimetype, data);
}
}
void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y)
@ -309,24 +311,9 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y)
if (!selectedPlugin.isEmpty()) {
KTemporaryFile tempFile;
if (mimeData && tempFile.open()) {
//TODO: what should we do with files after the applet is done with them??
tempFile.setAutoRemove(false);
Plasma::Applet *applet = addApplet(selectedPlugin, QVariantList(), QPoint(x, y));
setAppletArgs(applet, pluginFormats[selectedPlugin], mimeData->data(pluginFormats[selectedPlugin]));
{
QDataStream stream(&tempFile);
QByteArray data = mimeData->data(pluginFormats[selectedPlugin]);
stream.writeRawData(data, data.size());
}
QVariantList args;
args << tempFile.fileName();
qDebug() << args;
tempFile.close();
addApplet(selectedPlugin, args, QPoint(x, y));
}
}
}
}
@ -394,10 +381,8 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
return;
}
QVariantList args;
args << tjob->url().url() << mimetype;
qDebug() << "Creating menu for:" << mimetype << posi << args;
qDebug() << "Creating menu for:" << mimetype << posi;
appletList << Plasma::PluginLoader::self()->listAppletInfoForMimeType(mimetype);
KPluginInfo::List wallpaperList;
@ -467,7 +452,8 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
m_wallpaperInterface->setUrl(tjob->url());
}
} else {
addApplet(actionsToApplets[choice], args, posi);
Plasma::Applet *applet = addApplet(actionsToApplets[choice], QVariantList(), posi);
setAppletArgs(applet, mimetype, tjob->url().toString());
}
clearDataForMimeJob(job);
@ -475,7 +461,8 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
}
} else {
// we can at least create an icon as a link to the URL
addApplet("org.kde.icon", args, posi);
Plasma::Applet *applet = addApplet("org.kde.icon", QVariantList(), posi);
setAppletArgs(applet, mimetype, tjob->url().toString());
}
}
@ -555,6 +542,24 @@ QString ContainmentInterface::activity() const
return containment()->activity();
}
QList<QObject*> ContainmentInterface::actions() const
{
//FIXME: giving directly a QList<QAction*> crashes
//use a multimap to sort by action type
QMultiMap<int, QObject*> actions;
foreach (QAction *a, containment()->actions()->actions()) {
if (a->isEnabled()) {
actions.insert(a->data().toInt(), a);
}
}
foreach (QAction *a, containment()->corona()->actions()->actions()) {
if (a->isEnabled()) {
actions.insert(a->data().toInt(), a);
}
}
return actions.values();
}

View File

@ -58,6 +58,11 @@ class ContainmentInterface : public AppletInterface
*/
Q_PROPERTY(QString activity READ activity NOTIFY activityChanged)
/**
* Actions associated to this containment or corona
*/
Q_PROPERTY(QList<QObject*> actions READ actions NOTIFY actionsChanged)
public:
ContainmentInterface(DeclarativeAppletScript *parent);
//Not for QML
@ -75,6 +80,8 @@ public:
QString activity() const;
QList<QObject*> actions() const;
/**
* FIXME: either a property or not accessible at all. Lock or unlock widgets
*/
@ -127,6 +134,7 @@ Q_SIGNALS:
void drawWallpaperChanged();
void containmentTypeChanged();
///void immutableChanged();
void actionsChanged();
protected Q_SLOTS:
void appletAddedForward(Plasma::Applet *applet);
@ -137,7 +145,8 @@ protected Q_SLOTS:
private:
void clearDataForMimeJob(KIO::Job *job);
void addApplet(const QString &plugin, const QVariantList &args, const QPoint &pos);
Plasma::Applet *addApplet(const QString &plugin, const QVariantList &args, const QPoint &pos);
void setAppletArgs(Plasma::Applet *applet, const QString &mimetype, const QString &data);
WallpaperInterface *m_wallpaperInterface;
QList<QObject *> m_appletInterfaces;

View File

@ -179,12 +179,10 @@ void WallpaperInterface::setAction(const QString &name, const QString &text, con
if (action) {
action->setText(text);
} else {
Q_ASSERT(!m_actions->action(name));
action = new QAction(text, this);
m_actions->addAction(name, action);
Q_ASSERT(!m_actions->actions().contains(name));
m_actions->addAction(name, action);
if (!m_actionSignals) {
m_actionSignals = new QSignalMapper(this);
connect(m_actionSignals, SIGNAL(mapped(QString)),

View File

@ -57,6 +57,8 @@ set(widgetexplorer_SRC
add_executable(plasma-shell
main.cpp
containmentconfigview.cpp
currentcontainmentactionsmodel.cpp
desktopview.cpp
panelview.cpp
panelconfigview.cpp
@ -79,7 +81,7 @@ target_link_libraries(plasma-shell
${KWindowSystem_LIBRARIES}
${KCoreAddons_LIBRARIES}
plasma
plasmaquick
PlasmaQuick
${Qt5Script_LIBRARIES}
${KDE4Support_LIBRARIES}
${Solid_LIBRARIES}

View File

@ -17,9 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "currentcontainmentactionsmodel_p.h"
#include "containmentconfigview_p.h"
#include "configview_p.h"
#include "currentcontainmentactionsmodel.h"
#include "containmentconfigview.h"
#include "configmodel.h"
#include <kdeclarative/configpropertymap.h>
@ -45,7 +45,7 @@ ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow
m_currentWallpaperConfig(0),
m_ownWallpaperConfig(0)
{
qmlRegisterType<QStandardItemModel>();
qmlRegisterType<QAbstractItemModel>();
engine()->rootContext()->setContextProperty("configDialog", this);
setCurrentWallpaper(cont->containment()->wallpaper());
@ -78,19 +78,14 @@ ConfigModel *ContainmentConfigView::containmentActionConfigModel()
foreach (const KPluginInfo &info, actions) {
pkg.setDefaultPackageRoot(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "plasma/containmentactions", QStandardPaths::LocateDirectory));
ConfigCategory *cat = new ConfigCategory(m_containmentActionConfigModel);
cat->setName(info.name());
cat->setIcon(info.icon());
cat->setSource(pkg.filePath("ui", "config.qml"));
cat->setPluginName(info.pluginName());
m_containmentActionConfigModel->appendCategory(cat);
m_containmentActionConfigModel->appendCategory(info.icon(), info.name(), pkg.filePath("ui", "config.qml"), info.pluginName());
}
}
return m_containmentActionConfigModel;
}
QStandardItemModel *ContainmentConfigView::currentContainmentActionsModel()
QAbstractItemModel *ContainmentConfigView::currentContainmentActionsModel()
{
if (!m_currentContainmentActionsModel) {
m_currentContainmentActionsModel = new CurrentContainmentActionsModel(m_containment, this);
@ -121,12 +116,7 @@ ConfigModel *ContainmentConfigView::wallpaperConfigModel()
if (!pkg.isValid()) {
continue;
}
ConfigCategory *cat = new ConfigCategory(m_wallpaperConfigModel);
cat->setName(pkg.metadata().name());
cat->setIcon(pkg.metadata().icon());
cat->setSource(pkg.filePath("ui", "config.qml"));
cat->setPluginName(package);
m_wallpaperConfigModel->appendCategory(cat);
m_wallpaperConfigModel->appendCategory(pkg.metadata().icon(), pkg.metadata().name(), pkg.filePath("ui", "config.qml"), package);
}
}
}
@ -191,4 +181,4 @@ void ContainmentConfigView::syncWallpaperObjects()
m_currentWallpaperConfig = static_cast<ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
}
#include "moc_containmentconfigview_p.cpp"
#include "private/moc_containmentconfigview.cpp"

View File

@ -28,15 +28,16 @@ namespace Plasma {
class Containment;
}
class QAbstractItemModel;
class ConfigPropertyMap;
class CurrentContainmentActionsModel;
//TODO: out of the library?
class ContainmentConfigView : public ConfigView
{
Q_OBJECT
Q_PROPERTY(ConfigModel *containmentActionConfigModel READ containmentActionConfigModel CONSTANT)
Q_PROPERTY(QStandardItemModel *currentContainmentActionsModel READ currentContainmentActionsModel CONSTANT)
Q_PROPERTY(QAbstractItemModel *currentContainmentActionsModel READ currentContainmentActionsModel CONSTANT)
Q_PROPERTY(ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT)
Q_PROPERTY(ConfigPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged)
Q_PROPERTY(QString currentWallpaper READ currentWallpaper WRITE setCurrentWallpaper NOTIFY currentWallpaperChanged)
@ -48,7 +49,7 @@ public:
virtual void init();
ConfigModel *containmentActionConfigModel();
QStandardItemModel *currentContainmentActionsModel();
QAbstractItemModel *currentContainmentActionsModel();
ConfigModel *wallpaperConfigModel();
QString currentWallpaper() const;
void setCurrentWallpaper(const QString &wallpaper);

View File

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "currentcontainmentactionsmodel_p.h"
#include "currentcontainmentactionsmodel.h"
#include <QMouseEvent>
@ -259,4 +259,4 @@ void CurrentContainmentActionsModel::save()
}
}
#include "moc_currentcontainmentactionsmodel_p.cpp"
#include "private/moc_currentcontainmentactionsmodel.cpp"

View File

@ -30,6 +30,8 @@ namespace Plasma {
class ContainmentActions;
}
//This model load the data about available containment actions plugins, such as context menus that can be loaded on mouse click
//TODO: out of the library?
class CurrentContainmentActionsModel : public QStandardItemModel
{
Q_OBJECT

View File

@ -17,20 +17,99 @@
*/
#include "desktopview.h"
#include "containmentconfigview.h"
#include "shellcorona.h"
#include "shellmanager.h"
#include <QQmlEngine>
#include <QQmlContext>
#include <QScreen>
#include <KWindowSystem>
#include <Plasma/Package>
DesktopView::DesktopView(ShellCorona *corona, QWindow *parent)
: PlasmaQuickView(corona, parent)
: PlasmaQuickView(corona, parent),
m_stayBehind(false),
m_fillScreen(false)
{
engine()->rootContext()->setContextProperty("desktop", this);
setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml")));
}
DesktopView::~DesktopView()
{
}
/*
bool DesktopView::stayBehind() const
{
return m_stayBehind;
}
void DesktopView::setStayBehind(bool stayBehind)
{
if (ShellManager::s_forceWindowed || stayBehind == m_stayBehind) {
return;
}
if (stayBehind) {
KWindowSystem::setType(winId(), NET::Desktop);
} else {
KWindowSystem::setType(winId(), NET::Normal);
}
m_stayBehind = stayBehind;
emit stayBehindChanged();
}
bool DesktopView::fillScreen() const
{
return m_fillScreen;
}
void DesktopView::setFillScreen(bool fillScreen)
{
if (ShellManager::s_forceWindowed || fillScreen == m_fillScreen) {
return;
}
resize(screen()->geometry().width(), screen()->geometry().height());
connect(screen(), &QScreen::geometryChanged, [=]{resize(screen()->geometry().width(), screen()->geometry().height());});
fillScreen = fillScreen;
emit fillScreenChanged();
}
void DesktopView::setDashboardShown(bool shown)
{
if (shown) {
if (m_stayBehind) {
KWindowSystem::setType(winId(), NET::Normal);
}
raise();
KWindowSystem::raiseWindow(winId());
QObject *wpGraphicObject = containment()->property("wallpaperGraphicsObject").value<QObject *>();
if (wpGraphicObject) {
wpGraphicObject->setProperty("opacity", 0.3);
}
} else {
if (m_stayBehind) {
KWindowSystem::setType(winId(), NET::Desktop);
}
lower();
KWindowSystem::lowerWindow(winId());
QObject *wpGraphicObject = containment()->property("wallpaperGraphicsObject").value<QObject *>();
if (wpGraphicObject) {
wpGraphicObject->setProperty("opacity", 1);
}
}
}
void DesktopView::showConfigurationInterface(Plasma::Applet *applet)
{
if (m_configView) {
@ -45,13 +124,13 @@ void DesktopView::showConfigurationInterface(Plasma::Applet *applet)
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(applet);
if (cont) {
m_configView = new PanelConfigView(cont, this);
m_configView = new ContainmentConfigView(cont);
} else {
m_configView = new ConfigView(applet);
}
m_configView.data()->init();
m_configView.data()->show();
}*/
}
#include "moc_desktopview.cpp"

View File

@ -29,19 +29,35 @@ class ShellCorona;
class DesktopView : public PlasmaQuickView
{
Q_OBJECT
Q_PROPERTY(bool stayBehind READ stayBehind WRITE setStayBehind NOTIFY stayBehindChanged)
Q_PROPERTY(bool fillScreen READ fillScreen WRITE setFillScreen NOTIFY fillScreenChanged)
public:
explicit DesktopView(ShellCorona *corona, QWindow *parent = 0);
virtual ~DesktopView();
bool stayBehind() const;
void setStayBehind(bool stayBehind);
bool fillScreen() const;
void setFillScreen(bool fillScreen);
void setDashboardShown(bool shown);
protected Q_SLOTS:
/**
* It will be called when the configuration is requested
*/
//virtual void showConfigurationInterface(Plasma::Applet *applet);
virtual void showConfigurationInterface(Plasma::Applet *applet);
Q_SIGNALS:
void stayBehindChanged();
void fillScreenChanged();
private:
QPointer<ConfigView> m_configView;
bool m_stayBehind : 1;
bool m_fillScreen : 1;
};
#endif // DESKTOVIEW_H

View File

@ -24,6 +24,7 @@
#include "shellmanager.h"
#include <QtQml/QQmlDebuggingEnabler>
#include <QDebug>
static const char description[] = "Plasma Shell";
static const char version[] = "2.0";
@ -38,9 +39,13 @@ int main(int argc, char** argv)
QCommandLineOption dbg = QCommandLineOption(QStringList() << QStringLiteral("d") << QStringLiteral("qmljsdebugger"),
QStringLiteral("Enable QML Javascript debugger"));
QCommandLineOption windowed = QCommandLineOption(QStringList() << QStringLiteral("w") << QStringLiteral("windowed"),
QStringLiteral("force a windowed view for desktop purposes"));
parser.addVersionOption();
parser.setApplicationDescription(description);
parser.addOption(dbg);
parser.addOption(windowed);
parser.process(app);
//enable the QML debugger only if --qmljsdebugger (or -d) is passed as a command line arg
@ -58,6 +63,8 @@ int main(int argc, char** argv)
// corona->processUpdateScripts();
// corona->checkScreens();
ShellManager::s_forceWindowed = parser.isSet(windowed);
ShellManager::instance();
return app.exec();

View File

@ -341,8 +341,6 @@ void PanelView::restore()
m_offset = qMax(0, m_offset);
}
m_maxLength = config().readEntry<int>("maxLength", -1);
m_minLength = config().readEntry<int>("minLength", -1);
m_alignment = (Qt::Alignment)config().readEntry<int>("alignment", Qt::AlignLeft);
setMinimumSize(QSize(-1, -1));
@ -350,6 +348,9 @@ void PanelView::restore()
setMaximumSize(screen()->size());
if (containment()->formFactor() == Plasma::Types::Vertical) {
m_maxLength = config().readEntry<int>("maxLength", screen()->size().height());
m_minLength = config().readEntry<int>("minLength", screen()->size().height());
const int maxSize = screen()->size().height() - m_offset;
m_maxLength = qBound<int>(MINSIZE, m_maxLength, maxSize);
m_minLength = qBound<int>(MINSIZE, m_minLength, maxSize);
@ -362,11 +363,14 @@ void PanelView::restore()
//Horizontal
} else {
m_maxLength = config().readEntry<int>("maxLength", screen()->size().width());
m_minLength = config().readEntry<int>("minLength", screen()->size().width());
const int maxSize = screen()->size().width() - m_offset;
m_maxLength = qBound<int>(MINSIZE, m_maxLength, maxSize);
m_minLength = qBound<int>(MINSIZE, m_minLength, maxSize);
resize(qBound<int>(MINSIZE, config().readEntry<int>("length", screen()->size().height()), maxSize),
resize(qBound<int>(MINSIZE, config().readEntry<int>("length", screen()->size().width()), maxSize),
config().readEntry<int>("thickness", 32));
setMinimumWidth(m_minLength);

View File

@ -27,7 +27,7 @@ Item {
id: main
property string shell : "org.kde.blank"
property bool willing : keyboards.count != 1
property bool willing : false
property int priority : 0
// This is not needed, but allows the

View File

@ -10,6 +10,7 @@ Encoding=UTF-8
Keywords=
Name=Blank Desktop
Name[cs]=Prázdná pracovní plocha
Name[de]=Leere Arbeitsfläche
Name[fi]=Tyhjä työpöytä
Name[nl]=Blanco bureaublad
Name[pt]=Ambiente de Trabalho em Branco

View File

@ -42,8 +42,17 @@ Item {
property Item compactRepresentation
onAppletChanged: {
applet.parent = appletParent
applet.anchors.fill = applet.parent
//if the applet size was restored to a stored size, or if is dragged from the desktop, restore popup size
if (applet.width > 0) {
popupWindow.mainItem.width = applet.width;
}
if (applet.height > 0) {
popupWindow.mainItem.height = applet.height;
}
applet.parent = appletParent;
applet.anchors.fill = applet.parent;
}
onCompactRepresentationChanged: {
compactRepresentation.parent = root
@ -62,8 +71,6 @@ Item {
width: applet && applet.implicitHeight > 0 ? applet.implicitHeight : theme.mSize(theme.defaultFont).width * 35
height: applet && applet.implicitHeight > 0 ? applet.implicitHeight : theme.mSize(theme.defaultFont).height * 25
onWidthChanged: applet.width = width
onHeightChanged: applet.height = height
}
onActiveWindowChanged: {

View File

@ -2,8 +2,7 @@
var panel = new Panel
panel.screen = 0
panel.location = 'top'
panel.addWidget("org.kde.testapplet")
panel.addWidget("org.kde.windowlist")
panel.addWidget("org.kde.taskmanager")
for (var i = 0; i < screenCount; ++i) {
var desktop = new Activity

View File

@ -26,7 +26,7 @@ Item {
id: main
property string shell : "org.kde.desktop"
property bool willing : keyboards.count == 1
property bool willing : true
property int priority : 1
// This is not needed, but allows the

View File

@ -24,7 +24,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore
Rectangle {
id: root
color: "black"
color: Qt.rgba(0, 0, 0, 0.2)
width: 1024
height: 768
@ -38,6 +38,8 @@ Rectangle {
}
Component.onCompleted: {
desktop.stayBehind = true;
desktop.fillScreen = true;
print("View QML loaded")
}
}

View File

@ -27,6 +27,7 @@
#include <QQmlContext>
#include <QTimer>
#include <KActionCollection>
#include <KLocalizedString>
#include <Plasma/Package>
#include <Plasma/PluginLoader>
@ -95,6 +96,17 @@ ShellCorona::ShellCorona(QObject *parent)
connect(d->scriptEngine, &WorkspaceScripting::ScriptEngine::print,
this, &ShellCorona::printScriptMessage);
QAction *dashboardAction = actions()->add<QAction>("show dashboard");
QObject::connect(dashboardAction, &QAction::triggered,
this, &ShellCorona::setDashboardShown);
dashboardAction->setText(i18n("Show Dashboard"));
dashboardAction->setAutoRepeat(true);
dashboardAction->setCheckable(true);
dashboardAction->setIcon(QIcon::fromTheme("dashboard-show"));
dashboardAction->setData(Plasma::Types::ControlAction);
dashboardAction->setShortcut(QKeySequence("ctrl+f12"));
dashboardAction->setShortcutContext(Qt::ApplicationShortcut);
}
ShellCorona::~ShellCorona()
@ -114,6 +126,7 @@ void ShellCorona::setShell(const QString &shell)
setPackage(package);
load();
//TODO: panel views should be synced here: either creating views for panels without, or deleting views for panels that don't have one anymore
}
QString ShellCorona::shell() const
@ -363,6 +376,7 @@ void ShellCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Contain
} else {
if (containment->isUiReady()) {
d->loadingDesktops.remove(containment);
checkLoadingDesktopsComplete();
} else {
d->loadingDesktops.insert(containment);
@ -383,6 +397,9 @@ void ShellCorona::handleContainmentAdded(Plasma::Containment* c)
{
connect(c, &Plasma::Containment::showAddWidgetsInterface,
this, &ShellCorona::showWidgetExplorer);
connect(c, &QObject::destroyed, [=] (QObject *o) {
d->loadingDesktops.remove(static_cast<Plasma::Containment *>(o));
});
}
void ShellCorona::showWidgetExplorer()
@ -412,6 +429,20 @@ void ShellCorona::syncAppConfig()
applicationConfig()->sync();
}
void ShellCorona::setDashboardShown(bool show)
{
qDebug() << "TODO: Toggling dashboard view";
QAction *dashboardAction = actions()->action("show dashboard");
if (dashboardAction) {
dashboardAction->setText(show ? i18n("Hide Dashboard") : i18n("Show Dashboard"));
}
foreach (DesktopView *view, d->views) {
view->setDashboardShown(show);
}
}
void ShellCorona::printScriptError(const QString &error)
{
qWarning() << error;

View File

@ -120,6 +120,7 @@ private Q_SLOTS:
void handleContainmentAdded(Plasma::Containment *c);
void showWidgetExplorer();
void syncAppConfig();
void setDashboardShown(bool show);
private:
class Private;

View File

@ -36,6 +36,8 @@ static const QString s_shellsDir(
QString(CMAKE_INSTALL_PREFIX) + "/" + DATA_INSTALL_DIR + "/" + "plasma/shells/");
static const QString s_shellLoaderPath = QString("/contents/loader.qml");
bool ShellManager::s_forceWindowed = false;
//
// ShellManager
//

View File

@ -22,6 +22,8 @@
#include <QObject>
class ShellManager: public QObject {
Q_OBJECT
public:
@ -30,6 +32,8 @@ public:
void loadHandlers();
static bool s_forceWindowed;
protected Q_SLOTS:
void registerHandler(QObject * handler);
void deregisterHandler(QObject * handler);

View File

@ -3,6 +3,7 @@
# kDebug() becomes qDebug() in cpp files
for FS in `find $PWD -name '*.h' -o -name '*.cpp'`; do
perl -p -i -e 's/\#include \<KDebug\>/\#include \<QDebug\>/g' $FS
perl -p -i -e 's/\#include \<KDebug\>/\#include \<QDebug\>/g' $FS
perl -p -i -e 's/\#include \<kdebug\.h\>/\#include \<QDebug\>/g' $FS
perl -p -i -e 's/kDebug\(\)/qDebug()/g' $FS

View File

@ -50,6 +50,7 @@ for FS in `find $PWD -name '*.h' -o -name '*.cpp'`; do
# Fix up includes
perl -p -i -e 's/\#include \<QtGui\/QQuickItem\>/\#include \<QtQuick\/QQuickItem\>/g' $FS
perl -p -i -e 's/\#include \<QtGui\/QMenu\>/\#include \<QtWidgets\/QMenu\>/g' $FS
perl -p -i -e 's/\#include \<QtGui\/QWidget\>/\#include \<QtWidgets\/QWidget\>/g' $FS
perl -p -i -e 's/\#include \<QtDeclarative\/QQuickItem\>/\#include \<QtQuick\/QQuickItem\>/g' $FS
perl -p -i -e 's/\#include \<QtDeclarative\/QQmlContext\>/\#include \<QtQml\/QQmlContext\>/g' $FS
perl -p -i -e 's/\#include \<QtDeclarative\/QQmlEngine\>/\#include \<QtQml\/QQmlEngine\>/g' $FS