Commit a645d101 authored by Marco Martin's avatar Marco Martin

port logout screen to kpackage fileUrl

Summary: port the shutdown dialog to package::fileUrl, dropping the support for old custom themes

Test Plan: shutdown dialog work correctly both with normal and rcc kpackages

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9195
parent 1d04c6ef
......@@ -91,4 +91,3 @@ install(TARGETS kcheckrunning ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
########### install files ###############
install( FILES org.kde.KSMServerInterface.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR})
install( DIRECTORY themes/ DESTINATION ${KDE_INSTALL_DATADIR}/ksmserver/themes )
......@@ -109,7 +109,7 @@ void Greeter::init()
void Greeter::adoptScreen(QScreen* screen)
{
// TODO: last argument is the theme, maybe add command line option for it?
KSMShutdownDlg *w = new KSMShutdownDlg(nullptr, m_shutdownAllowed, m_choose, m_shutdownType, QString(), m_waylandPlasmaShell);
KSMShutdownDlg *w = new KSMShutdownDlg(nullptr, m_shutdownAllowed, m_choose, m_shutdownType, m_waylandPlasmaShell);
w->installEventFilter(this);
m_dialogs << w;
......
......@@ -76,10 +76,9 @@ Q_DECLARE_METATYPE(Solid::PowerManagement::SleepState)
KSMShutdownDlg::KSMShutdownDlg( QWindow* parent,
bool maysd, bool choose, KWorkSpace::ShutdownType sdtype,
const QString& theme, KWayland::Client::PlasmaShell *plasmaShell)
KWayland::Client::PlasmaShell *plasmaShell)
: QQuickView(parent),
m_result(false),
m_theme(theme),
m_waylandPlasmaShell(plasmaShell)
// this is a WType_Popup on purpose. Do not change that! Not
// having a popup here has severe side effects.
......@@ -156,21 +155,19 @@ void KSMShutdownDlg::init()
rootContext()->setContextProperty(QStringLiteral("screenGeometry"), screen()->geometry());
QString fileName;
if(m_theme.isEmpty()) {
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel"));
KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE");
const QString packageName = cg.readEntry("LookAndFeelPackage", QString());
if (!packageName.isEmpty()) {
package.setPath(packageName);
}
QString fileUrl;
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel"));
KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE");
const QString packageName = cg.readEntry("LookAndFeelPackage", QString());
if (!packageName.isEmpty()) {
package.setPath(packageName);
}
fileName = package.filePath("logoutmainscript");
} else
fileName = m_theme;
fileName = package.filePath("logoutmainscript");
if (QFile::exists(fileName)) {
//qCDebug(KSMSERVER) << "Using QML theme" << fileName;
setSource(QUrl::fromLocalFile(fileName));
setSource(package.fileUrl("logoutmainscript"));
} else {
qCWarning(KSMSERVER) << "Couldn't find a theme for the Shutdown dialog" << fileName;
return;
......
......@@ -58,7 +58,7 @@ class KSMShutdownDlg : public QQuickView
Q_OBJECT
public:
KSMShutdownDlg( QWindow* parent, bool maysd, bool choose, KWorkSpace::ShutdownType sdtype, const QString& theme, KWayland::Client::PlasmaShell *plasmaShell = nullptr );
KSMShutdownDlg( QWindow* parent, bool maysd, bool choose, KWorkSpace::ShutdownType sdtype, KWayland::Client::PlasmaShell *plasmaShell = nullptr );
void init();
bool result() const;
......@@ -91,7 +91,6 @@ private:
QString m_bootOption;
QStringList rebootOptions;
bool m_result : 1;
QString m_theme;
KWayland::Client::PlasmaShell *m_waylandPlasmaShell;
KWayland::Client::PlasmaShellSurface *m_shellSurface = nullptr;
};
......
/*
* Copyright 2011-2012 Lamarque V. Souza <Lamarque.Souza.ext@basyskom.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 Library 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.
*/
/**Documented API
Inherits:
PlasmaCore.FrameSvgItem
Imports:
QtQuick 2.0
org.kde.plasma.core
org.kde.kquickcontrolsaddons
Description:
A simple button with label at the bottom and icon at the top which uses the plasma theme.
Plasma theme is the theme which changes via the systemsetting - workspace appearence
- desktop theme.
Properties:
* string text:
This property holds the text label for the button.
For example, the ok button has text 'ok'.
The default value for this property is an empty string.
* font font:
This property holds the font used by the button label.
See also Qt documentation for font type.
* string iconSource:
This property holds the source url for the Button's icon.
The default value is an empty url, which displays no icon.
* int iconSize:
This property holds the icon size.
The default is use the natural image size.
Signals:
* onClicked:
This handler is called when there is a click.
**/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0
PlasmaCore.FrameSvgItem {
id: button
width: mainColumn.width
height: mainColumn.height
property alias text: labelElement.text
property alias font: labelElement.font
property string iconSource
property alias iconSize: iconElement.width
signal clicked()
PlasmaCore.Theme {
id: theme
}
Column {
id: mainColumn
QIconItem {
id: iconElement
icon: QIcon(iconSource)
height: width
MouseArea {
anchors.fill: parent
onClicked: button.clicked()
onPressed: button.state = "Pressed"
onReleased: button.state = "Normal"
}
}
Text {
id: labelElement
anchors.horizontalCenter: iconElement.horizontalCenter
horizontalAlignment: Text.AlignHCenter
color: theme.textColor
// Use theme.defaultFont in plasma-mobile and
// theme.font in plasma-desktop.
font.family: theme.defaultFont.family
font.bold: theme.defaultFont.bold
font.capitalization: theme.defaultFont.capitalization
font.italic: theme.defaultFont.italic
font.weight: theme.defaultFont.weight
font.underline: theme.defaultFont.underline
font.wordSpacing: theme.defaultFont.wordSpacing
}
}
states: [
State {
name: "Normal"
PropertyChanges { target: mainColumn; scale: 1.0}
},
State {
name: "Pressed"
PropertyChanges { target: mainColumn; scale: 0.9}
}
]
transitions: [
Transition {
NumberAnimation { properties: "scale"; duration: 50 }
}
]
}
/*
* Copyright 2011-2012 Lamarque V. Souza <Lamarque.Souza.ext@basyskom.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 Library 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
import org.kde.kquickcontrolsaddons 2.0
PlasmaCore.FrameSvgItem {
id: shutdownUi
property int iconSize: 96
property int realMarginTop: margins.top
property int realMarginBottom: margins.bottom
property int realMarginLeft: margins.left
property int realMarginRight: realMarginLeft
width: 3*realMarginLeft + dialog.width + 3*realMarginRight
height: 2*realMarginTop + dialog.height + 2*realMarginBottom
property int automaticallyDoSeconds: 5
imagePath: "dialogs/shutdowndialog"
signal logoutRequested()
signal haltRequested()
signal suspendRequested(int spdMethod)
signal rebootRequested()
signal rebootRequested2(int opt)
signal cancelRequested()
signal lockScreenRequested()
PlasmaCore.Theme {
id: theme
}
Component.onCompleted: {
if (margins.left == 0) {
realMarginTop = 9
realMarginBottom = 7
realMarginLeft = 12
realMarginRight = 12
}
//console.log("contour.qml: maysd("+maysd+") choose ("+choose+") ("+sdtype+")")
//console.log("contour.qml: defualtFont.pointSize == " + theme.defaultFont.pointSize)
}
Timer {
id: timer
repeat: true
running: true
interval: 1000
onTriggered: {
if (automaticallyDoSeconds <= 0) { // timeout is at 0, do selected action
running = false
sleepButton.clicked(null)
}
automaticallyDoLabel.text = i18ndp("ksmserver", "Sleeping in 1 second",
"Sleeping in %1 seconds", automaticallyDoSeconds)
--automaticallyDoSeconds;
}
}
Column {
id: dialog
spacing: 5
anchors {
centerIn: parent
}
Text {
id: automaticallyDoLabel
text: " "
// pixelSize does not work with PlasmaComponents.Label, so I am using a Text element here.
font.pixelSize: Math.max(12, theme.defaultFont.pointSize)
color: theme.textColor
anchors {
horizontalCenter: parent.horizontalCenter
}
}
Row {
id: iconRow
spacing: 3*realMarginLeft
ContourButton {
id: lockScreenButton
iconSource: "system-lock-screen"
iconSize: shutdownUi.iconSize
text: i18nd("ksmserver", "Lock")
font.pixelSize: 1.5*automaticallyDoLabel.font.pixelSize
onClicked: {
//console.log("contour.qml: lock screen requested")
timer.running = false
lockScreenRequested();
}
}
ContourButton {
id: sleepButton
iconSource: "system-suspend"
iconSize: shutdownUi.iconSize
text: i18n("ksmserver", "Sleep")
font.pixelSize: 1.5*automaticallyDoLabel.font.pixelSize
onClicked: {
//console.log("contour.qml: sleep requested")
timer.running = false
if (spdMethods.SuspendState) {
suspendRequested(2); // Solid::PowerManagement::SuspendState
} else if (spdMethods.StandbyState) {
suspendRequested(1); // Solid::PowerManagement::StandbyState
} else {
console.log("contour.qml: system does not support suspend")
}
}
}
ContourButton {
id: shutdownButton
iconSource: "system-shutdown"
iconSize: shutdownUi.iconSize
text: i18nd("ksmserver", "Turn off")
font.pixelSize: 1.5*automaticallyDoLabel.font.pixelSize
onClicked: {
//console.log("contour.qml turn off requested")
timer.running = false
haltRequested()
}
}
}
}
}
[Desktop Entry]
Encoding=UTF-8
Name=Contour
Name[bs]=Kontura
Name[ca]=Contour
Name[ca@valencia]=Contour
Name[cs]=Contour
Name[da]=Contour
Name[de]=Contour
Name[el]=Περίγραμμα
Name[en_GB]=Contour
Name[es]=Contour
Name[et]=Kontuur
Name[eu]=Contour
Name[fi]=Contour
Name[fr]=Contour
Name[gl]=Contour
Name[hu]=Körvonal
Name[ia]=Bordo
Name[id]=Kontur
Name[is]=Útjaðar
Name[it]=Contour
Name[ja]=Contour
Name[kk]=Контур
Name[km]=Contour
Name[ko]=Contour
Name[lt]=Kontūras
Name[mr]=कॉनटुर
Name[nb]=Kontur
Name[nds]=Ümreet
Name[nl]=Contour
Name[nn]=Kontur
Name[pa]=ਢਾਂਚਾ
Name[pl]=Kontur
Name[pt]=Contour
Name[pt_BR]=Contour
Name[ro]=Contur
Name[ru]=Контур
Name[sk]=Kontúra
Name[sl]=Obris
Name[sr]=Контура
Name[sr@ijekavian]=Контура
Name[sr@ijekavianlatin]=Kontura
Name[sr@latin]=Kontura
Name[sv]=Kontur
Name[tr]=Contour
Name[ug]=ئىزنا
Name[uk]=Контур
Name[x-test]=xxContourxx
Name[zh_CN]=Contour
Name[zh_TW]=輪廓
Comment=Plasma Active theme
Comment[ar]=سمة بلازما النشطة
Comment[bs]=Plazma aktivna tema
Comment[ca]=Tema Plasma Active
Comment[ca@valencia]=Tema Plasma Active
Comment[cs]=Motiv Plasma Active
Comment[da]=Tema til Plasma Active
Comment[de]=Plasma-Active-Design
Comment[el]=Ενεργό θέμα Plasma
Comment[en_GB]=Plasma Active theme
Comment[es]=Tema para Plasma Active
Comment[et]=Plasma Active'i teema
Comment[eu]=Plasma Active-ren gaia
Comment[fi]=Plasma Activen teema
Comment[fr]=Thème de Plasma Active
Comment[gl]=Tema de plasma active
Comment[he]=ערכת הנושא של Plasma Active
Comment[hu]=Plazma aktív téma
Comment[ia]=Thema de Plasma Active
Comment[id]=Tema Plasma Aktif
Comment[is]=Plasma Active þema
Comment[it]=Tema di Plasma Active
Comment[ja]=Plasma Active テーマ
Comment[kk]=Plasma Active нақышы
Comment[km]=រូបរាង​សកម្ម​ប្លាស្មា
Comment[ko]=Plasma Active 테마
Comment[lt]=Aktyvus Plasma apipavidalinimas
Comment[mr]=प्लाज्मा एक्टिव्ह शैली
Comment[nb]=Aktivt Plasma-tema
Comment[nds]=Plasma-Aktiev-Muster
Comment[nl]=Thema Plasma Active
Comment[nn]=Plasma Active-tema
Comment[pa]=ਪਲਾਜ਼ਮਾ ਐਕਟਿਵ ਥੀਮ
Comment[pl]=Wystrój Plazma Active
Comment[pt]=Tema do Plasma Active
Comment[pt_BR]=Tema do Plasma Active
Comment[ro]=Temă Plasma Active
Comment[ru]=Тема Plasma
Comment[sk]=Téma Plasma Active
Comment[sl]=Tema Plasma Active
Comment[sr]=Тема Плазма актива
Comment[sr@ijekavian]=Тема Плазма актива
Comment[sr@ijekavianlatin]=Tema Plasma aktiva
Comment[sr@latin]=Tema Plasma aktiva
Comment[sv]=Plasma aktivt tema
Comment[tr]=Plasma Active teması
Comment[uk]=Тема портативної Плазми
Comment[x-test]=xxPlasma Active themexx
Comment[zh_CN]=Plasma Active 主题
Comment[zh_TW]=Plasma Active 主題
Type=Service
X-KDE-PluginInfo-Author=Lamarque V. Souza
X-KDE-PluginInfo-Email=Lamarque.Souza.ext@basyskom.com
X-KDE-PluginInfo-Name=contour
X-KDE-PluginInfo-Version=0.9
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-API=declarativeappletscript
#X-Plasma-MainScript=main.qml
/*
Copyright (C) 2011-2012 Lamarque Souza <Lamarque.Souza.ext@basyskom.com>
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 02110-1301 USA.
*/
/**Documented API
Inherits:
PlasmaCore.FrameSvgItem
Imports:
QtQuick 2.0
org.kde.plasma.core
org.kde.kquickcontrolsaddons
Description:
A button with label and icon (at the right) which uses the plasma theme.
The button uses hover event to change the background on mouse over, supports tab stop
and context menu.
Plasma theme is the theme which changes via the systemsetting - workspace appearence
- desktop theme.
Properties:
* string text:
This property holds the text label for the button.
For example,the ok button has text 'ok'.
The default value for this property is an empty string.
* string iconSource:
This property holds the source url for the Button's icon.
The default value is an empty url, which displays no icon.
* bool smallButton:
Make the button use a different SVG element as background.
The default is false.
* bool menu:
Indicates if the button will have a context menu. The menu is created by
the parent.
The default value is false.
* ContextMenu contextMenu
This property holds the contextMenu element.
The default is a null Item.
* Item tabStopNext:
This property holds the next Item in a tab stop chain.
* Item tabStopBack:
This property holds the previous Item in a tab stop chain.
Signals:
* onClicked:
This handler is called when there is a click.
* onPressed:
This handler is called when there is a press.
* onPressAndHold:
This handler is called when there is a press and hold.
**/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0
PlasmaCore.FrameSvgItem {
id: button
property string text
property string iconSource
property bool smallButton: false
property bool menu: false
property ContextMenu contextMenu
property Item tabStopNext
property Item tabStopBack
property int accelKey: -1
height: theme.desktopFont.mSize.height + 22
signal clicked()
signal pressed()
signal pressAndHold()
// PlasmaCore.Theme {
// id: theme
// }
PlasmaCore.SvgItem {
id: background
anchors.fill: parent
svg: PlasmaCore.Svg {
imagePath: "dialogs/shutdowndialog"
}
elementId: "button-normal"
}
Text {
id: labelElement
font.pointSize: theme.desktopFont.pointSize
color: theme.textColor
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: theme.mSize(theme.defaultFont).width
}
onPaintedWidthChanged: {
button.width = Math.max(button.width, theme.mSize(theme.defaultFont).width + labelElement.width + 2*theme.mSize(theme.defaultFont).width + iconElement.width + theme.mSize(theme.defaultFont).width)
}
}
// visual part of the label accelerator implementation. See main.qml (Keys.onPressed) to see the code
// that actually triggers the action.
onTextChanged: {
var i = button.text.indexOf('&')
if (i > -1) {
var stringToReplace = button.text.substr(i, 2)
accelKey = stringToReplace.toUpperCase().charCodeAt(1)
labelElement.text = button.text.replace(stringToReplace, '<u>'+stringToReplace[1]+'</u>')
} else {
labelElement.text = button.text
}
}
QIconItem {
id: menuIconElement
// if textColor is closer to white than to black use "draw-triangle4", which is also close to white.
// Otherwise use "arrow-down", which is green. I have not found a black triangle icon.
icon: theme.textColor > "#7FFFFF" ? QIcon("draw-triangle4") : QIcon("arrow-down")
width: 6
height: width
visible: button.menu
anchors {