Commit c9025c9a authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Implement a new strategy to get a fallback theme

It's pretty bad if the lockscreen greeter can't find the lookandfeel's
lock screen, so introduce a qrc file with a default simple lock screen that
we can fallback to.
parent 8851cafd
......@@ -11,6 +11,7 @@ set(kscreenlocker_greet_SRCS
greeterapp.cpp
main.cpp )
qt5_add_resources(kscreenlocker_greet_SRCS fallbacktheme.qrc)
kconfig_add_kcfg_files(kscreenlocker_greet_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../kcfg/kscreensaversettings.kcfgc)
add_executable(kscreenlocker_greet ${kscreenlocker_greet_SRCS})
......
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>fallbacktheme/AccelButton.qml</file>
<file>fallbacktheme/SessionSwitching.qml</file>
<file>fallbacktheme/LockScreen.qml</file>
<file>fallbacktheme/Greeter.qml</file>
</qresource>
</RCC>
/********************************************************************
KSld - the KDE Screenlocker Daemon
This file is part of the KDE project.
Copyright (C) 2011 Aaron Seigo <aseigo@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, see <http://www.gnu.org/licenses/>.
*********************************************************************/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
PlasmaComponents.Button {
property string label
property string normalLabel
property string accelLabel
text: parent.showAccel ? accelLabel : normalLabel
property int accelKey: -1
onLabelChanged: {
var i = label.indexOf('&');
if (i < 0) {
accelLabel = '<u>' + label[0] + '</u>' + label.substring(1, label.length);
accelKey = label[0].toUpperCase().charCodeAt(0);
normalLabel = label
} else {
var stringToReplace = label.substr(i, 2);
accelKey = stringToReplace.toUpperCase().charCodeAt(1);
accelLabel = label.replace(stringToReplace, '<u>' + stringToReplace[1] + '</u>');
normalLabel = label.replace(stringToReplace, stringToReplace[1]);
}
}
}
/********************************************************************
KSld - the KDE Screenlocker Daemon
This file is part of the KDE project.
Copyright (C) 2011 Martin Gräßlin <mgraesslin@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, see <http://www.gnu.org/licenses/>.
*********************************************************************/
import QtQuick 2.0
import QtQuick.Layouts 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kscreenlocker 1.0
Item {
id: root
signal switchUserClicked()
signal canceled()
property alias notification: message.text
property bool switchUserEnabled
property bool capsLockOn
implicitWidth: layoutItem.width + theme.mSize(theme.defaultFont).width * 4 + 12
implicitHeight: layoutItem.height + 12
anchors {
fill: parent
margins: 6
}
Column {
id: layoutItem
anchors.centerIn: parent
spacing: theme.mSize(theme.defaultFont).height/2
PlasmaComponents.Label {
id: message
text: ""
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
Behavior on opacity {
NumberAnimation {
duration: 250
}
}
opacity: text == "" ? 0 : 1
}
PlasmaComponents.Label {
id: capsLockMessage
text: i18n("Warning: Caps Lock on")
anchors.horizontalCenter: parent.horizontalCenter
opacity: capsLockOn ? 1 : 0
height: capsLockOn ? paintedHeight : 0
font.bold: true
Behavior on opacity {
NumberAnimation {
duration: 250
}
}
}
PlasmaComponents.Label {
id: lockMessage
text: kscreenlocker_userName.length == 0 ? i18n("The session is locked") : i18n("The session has been locked by %1", kscreenlocker_userName)
anchors.horizontalCenter: parent.horizontalCenter
}
RowLayout {
anchors.horizontalCenter: parent.horizontalCenter
PlasmaComponents.Label {
text: i18n("Password:")
}
PlasmaComponents.TextField {
id: password
enabled: !authenticator.graceLocked
echoMode: TextInput.Password
focus: true
Keys.onEnterPressed: authenticator.tryUnlock(password.text)
Keys.onReturnPressed: authenticator.tryUnlock(password.text)
Keys.onEscapePressed: password.text = ""
}
}
PlasmaComponents.ButtonRow {
id: buttonRow
property bool showAccel: false
exclusive: false
spacing: theme.mSize(theme.defaultFont).width / 2
anchors.horizontalCenter: parent.horizontalCenter
AccelButton {
id: switchUser
label: i18n("&Switch Users")
iconSource: "fork"
visible: switchUserEnabled
onClicked: switchUserClicked()
}
AccelButton {
id: unlock
label: i18n("Un&lock")
iconSource: "object-unlocked"
enabled: !authenticator.graceLocked
onClicked: authenticator.tryUnlock(password.text)
}
}
}
Keys.onPressed: {
var alt = (event.modifiers & Qt.AltModifier);
buttonRow.showAccel = alt;
if (alt) {
// focus munging is needed otherwise the greet (QWidget)
// eats all the key events, even if root is added to forwardTo
// qml property of greeter
// greeter.focus = false;
root.forceActiveFocus();
var buttons = [switchUser, unlock]
for (var b = 0; b < buttons.length; ++b) {
if (event.key == buttons[b].accelKey) {
buttonRow.showAccel = false;
buttons[b].clicked();
break;
}
}
}
}
Keys.onReleased: {
buttonRow.showAccel = (event.modifiers & Qt.AltModifier)
}
Connections {
target: authenticator
onFailed: {
root.notification = i18n("Unlocking failed");
}
onGraceLockedChanged: {
if (!authenticator.graceLocked) {
root.notification = "";
password.selectAll();
password.focus = true;
}
}
onMessage: function(text) {
root.notification = text;
}
onError: function(text) {
root.notification = text;
}
}
}
/********************************************************************
KSld - the KDE Screenlocker Daemon
This file is part of the KDE project.
Copyright (C) 2011 Martin Gräßlin <mgraesslin@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, see <http://www.gnu.org/licenses/>.
*********************************************************************/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0
import org.kde.kscreenlocker 1.0
import org.kde.plasma.components 2.0 as PlasmaComponents
Item {
id: lockScreen
signal unlockRequested()
property alias capsLockOn: unlockUI.capsLockOn
property bool locked: false
// if there's no image, have a near black background
Rectangle {
width: parent.width
height: parent.height
color: "#111"
}
Image {
id: background
anchors.fill: parent
source: theme.wallpaperPathForSize(parent.width, parent.height)
smooth: true
}
PlasmaCore.FrameSvgItem {
id: dialog
visible: lockScreen.locked
anchors.centerIn: parent
imagePath: "widgets/background"
width: mainStack.currentPage.implicitWidth + margins.left + margins.right
height: mainStack.currentPage.implicitHeight + margins.top + margins.bottom
Behavior on height {
enabled: mainStack.currentPage != null
NumberAnimation {
duration: 250
}
}
Behavior on width {
enabled: mainStack.currentPage != null
NumberAnimation {
duration: 250
}
}
PlasmaComponents.PageStack {
id: mainStack
clip: true
anchors {
fill: parent
leftMargin: dialog.margins.left
topMargin: dialog.margins.top
rightMargin: dialog.margins.right
bottomMargin: dialog.margins.bottom
}
initialPage: unlockUI
}
}
Greeter {
id: unlockUI
switchUserEnabled: userSessionsUI.switchUserSupported
Connections {
onAccepted: lockScreen.unlockRequested()
onSwitchUserClicked: { mainStack.push(userSessionsUI); userSessionsUI.forceActiveFocus(); }
}
}
function returnToLogin() {
mainStack.pop();
unlockUI.resetFocus();
}
// TODO: loader
SessionSwitching {
id: userSessionsUI
visible: false
Connections {
onCancel: returnToLogin()
onActivateSession: returnToLogin()
onStartNewSession: returnToLogin()
}
}
}
/********************************************************************
KSld - the KDE Screenlocker Daemon
This file is part of the KDE project.
Copyright (C) 2011 Martin Gräßlin <mgraesslin@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, see <http://www.gnu.org/licenses/>.
*********************************************************************/
import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kscreenlocker 1.0
Item {
property alias switchUserSupported: sessions.switchUserSupported
implicitWidth: theme.mSize(theme.defaultFont).width * 55
implicitHeight: theme.mSize(theme.defaultFont).height * 25
signal activateSession()
signal startNewSession()
signal cancel()
Sessions {
id: sessions
}
anchors {
fill: parent
margins: 6
}
PlasmaExtras.ScrollArea {
anchors {
left: parent.left
right: parent.right
bottom: buttonRow.top
bottomMargin: 5
}
height: parent.height - explainText.implicitHeight - buttonRow.height - 10
ListView {
model: sessions.model
id: userSessionsView
anchors.fill: parent
delegate: PlasmaComponents.ListItem {
content: PlasmaComponents.Label {
text: i18nc("thesession name and the location where the session is running (what vt)", "%1 (%2)", session, location)
}
}
highlight: PlasmaComponents.Highlight {
hover: true
width: parent.width
}
focus: true
MouseArea {
anchors.fill: parent
onClicked: userSessionsView.currentIndex = userSessionsView.indexAt(mouse.x, mouse.y)
onDoubleClicked: {
sessions.activateSession(userSessionsView.indexAt(mouse.x, mouse.y));
activateSession();
}
}
}
}
PlasmaComponents.Label {
id: explainText
text: i18n("The current session will be hidden " +
"and a new login screen or an existing session will be displayed.\n" +
"An F-key is assigned to each session; " +
"F%1 is usually assigned to the first session, " +
"F%2 to the second session and so on. " +
"You can switch between sessions by pressing " +
"Ctrl, Alt and the appropriate F-key at the same time. " +
"Additionally, the KDE Panel and Desktop menus have " +
"actions for switching between sessions.",
7, 8)
wrapMode: Text.Wrap
anchors {
top: parent.top
left: parent.left
right: parent.right
}
}
PlasmaComponents.ButtonRow {
id: buttonRow
exclusive: false
spacing: theme.mSize(theme.defaultFont).width / 2
property bool showAccel: false
AccelButton {
id: activateSession
label: i18n("Activate")
iconSource: "fork"
onClicked: {
sessions.activateSession(userSessionsView.currentIndex);
activateSession();
}
}
AccelButton {
id: newSession
label: i18n("Start New Session")
iconSource: "fork"
visible: sessions.startNewSessionSupported
onClicked: {
sessions.startNewSession();
startNewSession();
}
}
AccelButton {
id: cancelSession
label: i18n("Cancel")
iconSource: "dialog-cancel"
onClicked: cancel()
}
anchors.bottom: parent.bottom
anchors.horizontalCenter: userSessionsUI.horizontalCenter
}
Keys.onPressed: {
var alt = (event.modifiers & Qt.AltModifier);
buttonRow.showAccel = alt;
if (alt) {
var buttons = [activateSession, newSession, cancelSession];
for (var b = 0; b < buttons.length; ++b) {
if (event.key == buttons[b].accelKey) {
buttonRow.showAccel = false;
buttons[b].clicked();
break;
}
}
}
}
Keys.onReleased: {
buttonRow.showAccel = (event.modifiers & Qt.AltModifier)
}
}
......@@ -108,12 +108,12 @@ void UnlockApp::initialize()
m_package = Plasma::PluginLoader::self()->loadPackage("Plasma/LookAndFeel");
m_package.setPath("org.kde.lookandfeel");
m_mainQmlPath = m_package.filePath("lockscreenmainscript");
m_mainQmlPath = QUrl::fromLocalFile(m_package.filePath("lockscreenmainscript"));
if (m_mainQmlPath.isEmpty()) {
m_package.setPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QStringLiteral("ksmserver/screenlocker/") + QString::fromLatin1(DEFAULT_MAIN_PACKAGE)));
m_mainQmlPath = m_package.filePath("mainscript");
m_mainQmlPath = QUrl::fromLocalFile(m_package.filePath("mainscript"));
}
installEventFilter(this);
......@@ -128,8 +128,8 @@ void UnlockApp::viewStatusChanged(const QQuickView::Status &status)
m_package.setPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QStringLiteral("ksmserver/screenlocker/") + QString::fromLatin1(DEFAULT_MAIN_PACKAGE)));
m_mainQmlPath = m_package.filePath("mainscript");
view->setSource(QUrl::fromLocalFile(m_mainQmlPath));
m_mainQmlPath = QUrl("qrc:/fallbacktheme/LockScreen.qml");
view->setSource(m_mainQmlPath);
}
}
}
......@@ -164,7 +164,7 @@ void UnlockApp::desktopResized()
context->setContextProperty(QStringLiteral("kscreenlocker_userName"), fullName.isEmpty() ? user.loginName() : fullName);
context->setContextProperty(QStringLiteral("authenticator"), m_authenticator);
view->setSource(QUrl::fromLocalFile(m_mainQmlPath));
view->setSource(m_mainQmlPath);
view->setResizeMode(QQuickView::SizeRootObjectToView);
QQmlProperty lockProperty(view->rootObject(), QStringLiteral("locked"));
......
......@@ -68,7 +68,7 @@ private:
void capsLocked();
void shareEvent(QEvent *e, QQuickView *from);
QString m_mainQmlPath;
QUrl m_mainQmlPath;
QList<QQuickView*> m_views;
QTimer *m_resetRequestIgnoreTimer;
QTimer *m_delayedLockTimer;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment