commit
9f1271fa00
7 changed files with 331 additions and 14 deletions
@ -0,0 +1,60 @@ |
||||
/********************************************************************
|
||||
KSld - the KDE Screenlocker Daemon |
||||
This file is part of the KDE project. |
||||
|
||||
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org> |
||||
Copyright (C) 2014 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, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/ |
||||
|
||||
#include <KCModule> |
||||
|
||||
#include "../../../lookandfeelaccess/lookandfeelaccess.h" |
||||
|
||||
class QQuickWidget; |
||||
class QStandardItemModel; |
||||
|
||||
class ScreenLockerKcm : public KCModule |
||||
{ |
||||
Q_OBJECT |
||||
Q_PROPERTY(QStandardItemModel *lockerModel READ lockerModel CONSTANT) |
||||
Q_PROPERTY(QString selectedPlugin READ selectedPlugin WRITE setSelectedPlugin NOTIFY selectedPluginChanged) |
||||
|
||||
public: |
||||
enum Roles { |
||||
PluginNameRole = Qt::UserRole +1, |
||||
ScreenhotRole |
||||
}; |
||||
explicit ScreenLockerKcm(QWidget *parent = nullptr, const QVariantList& args = QVariantList()); |
||||
|
||||
QStandardItemModel *lockerModel(); |
||||
|
||||
QString selectedPlugin() const; |
||||
void setSelectedPlugin(const QString &plugin); |
||||
|
||||
public Q_SLOTS: |
||||
void load(); |
||||
void save() override; |
||||
void test(const QString &plugin); |
||||
|
||||
Q_SIGNALS: |
||||
void selectedPluginChanged(); |
||||
|
||||
private: |
||||
QStandardItemModel *m_model; |
||||
QString m_selectedPlugin; |
||||
QQuickWidget *m_quickWidget; |
||||
LookAndFeelAccess m_access; |
||||
}; |
||||
@ -0,0 +1,145 @@ |
||||
/* |
||||
Copyright (c) 2014 Marco Martin <mart@kde.org> |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Library General Public |
||||
License version 2 as published by the Free Software Foundation. |
||||
|
||||
This library 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 library; see the file COPYING.LIB. If not, write to |
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
Boston, MA 02110-1301, USA. |
||||
*/ |
||||
|
||||
import QtQuick 2.1 |
||||
import QtQuick.Layouts 1.1 |
||||
import QtQuick.Controls 1.0 as QtControls |
||||
import org.kde.kquickcontrolsaddons 2.0 |
||||
import QtQuick.Controls.Private 1.0 |
||||
//We need units from it |
||||
import org.kde.plasma.core 2.0 as PlasmaCore |
||||
import org.kde.plasma.components 2.0 as PlasmaComponents |
||||
|
||||
Rectangle { |
||||
width: units.gridUnit * 20 |
||||
height: units.gridUnit * 20 |
||||
color: syspal.window |
||||
|
||||
SystemPalette {id: syspal} |
||||
QtControls.ScrollView { |
||||
anchors.fill: parent |
||||
GridView { |
||||
id: grid |
||||
model: kcm.lockerModel |
||||
cellWidth: Math.floor(grid.width / Math.max(Math.floor(grid.width / (units.gridUnit*12)), 3)) |
||||
cellHeight: cellWidth / 1.6 |
||||
|
||||
delegate: Rectangle { |
||||
width: grid.cellWidth |
||||
height: grid.cellHeight |
||||
Connections { |
||||
target: kcm |
||||
onSelectedPluginChanged: { |
||||
if (kcm.selectedPlugin == model.pluginName) { |
||||
makeCurrentTimer.pendingIndex = index |
||||
} |
||||
} |
||||
} |
||||
Component.onCompleted: { |
||||
if (kcm.selectedPlugin == model.pluginName) { |
||||
makeCurrentTimer.pendingIndex = index |
||||
} |
||||
} |
||||
QIconItem { |
||||
id: icon |
||||
anchors.centerIn: parent |
||||
width: units.iconSizes.large |
||||
height: width |
||||
icon: "view-preview" |
||||
} |
||||
QtControls.Label { |
||||
anchors { |
||||
horizontalCenter: parent.horizontalCenter |
||||
top: icon.bottom |
||||
topMargin: units.gridUnit |
||||
} |
||||
color: "gray" |
||||
text: model.display |
||||
} |
||||
Image { |
||||
anchors.fill: parent |
||||
source: model.screenshot |
||||
} |
||||
Rectangle { |
||||
opacity: grid.currentIndex == index ? 1.0 : 0 |
||||
anchors.fill: parent |
||||
border.width: units.smallSpacing * 2 |
||||
border.color: syspal.highlight |
||||
color: "transparent" |
||||
Behavior on opacity { |
||||
PropertyAnimation { |
||||
duration: units.longDuration |
||||
easing.type: Easing.OutQuad |
||||
} |
||||
} |
||||
} |
||||
MouseArea { |
||||
anchors.fill: parent |
||||
hoverEnabled: true |
||||
onClicked: { |
||||
grid.currentIndex = index |
||||
kcm.selectedPlugin = model.pluginName |
||||
} |
||||
Timer { |
||||
interval: 1000 // FIXME TODO: Use platform value for tooltip activation delay. |
||||
|
||||
running: parent.containsMouse && !parent.pressedButtons |
||||
|
||||
onTriggered: { |
||||
Tooltip.showText(parent, Qt.point(parent.mouseX, parent.mouseY), model.display); |
||||
} |
||||
} |
||||
PlasmaComponents.ToolButton { |
||||
anchors { |
||||
top: parent.top |
||||
right: parent.right |
||||
margins: units.smallSpacing |
||||
} |
||||
visible: model.pluginName != "none" |
||||
iconSource: "media-playback-start" |
||||
tooltip: i18n("Test Screen Locker") |
||||
flat: false |
||||
onClicked: kcm.test(model.pluginName) |
||||
opacity: parent.containsMouse ? 1 : 0 |
||||
Behavior on opacity { |
||||
PropertyAnimation { |
||||
duration: units.longDuration |
||||
easing.type: Easing.OutQuad |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
/*list.setCurrentIndex doesn't work while the model is getting loaded, |
||||
* so list.currentIndex = index in a component.onCompleted of the delegate, |
||||
* doesn't work, restarting a timer when a delegate gets created, |
||||
* seems the only place where we can approximate "set the property when |
||||
* the view really is done loading"*/ |
||||
Timer { |
||||
id: makeCurrentTimer |
||||
interval: 0 |
||||
repeat: false |
||||
property int pendingIndex |
||||
onPendingIndexChanged: makeCurrentTimer.restart() |
||||
onTriggered: { |
||||
grid.currentIndex = pendingIndex |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,19 @@ |
||||
[Desktop Entry] |
||||
Name=Screen Locking |
||||
Comment=Screen Locking Themes |
||||
Icon=preferences-system |
||||
Encoding=UTF-8 |
||||
Keywords= |
||||
Type=Service |
||||
X-KDE-ParentApp= |
||||
X-KDE-PluginInfo-Author=Marco Martin |
||||
X-KDE-PluginInfo-Email=mart@kde.org |
||||
X-KDE-PluginInfo-License=GPL |
||||
X-KDE-PluginInfo-Name=screenlocker_kcm |
||||
X-KDE-PluginInfo-Version= |
||||
X-KDE-PluginInfo-Website= |
||||
X-KDE-ServiceTypes=Plasma/Generic |
||||
X-Plasma-API=declarativeappletscript |
||||
|
||||
X-Plasma-MainScript=ui/main.qml |
||||
X-Plasma-RemoteLocation= |
||||
|
After Width: | Height: | Size: 41 KiB |
Loading…
Reference in new issue