Commit 5c8ce892 authored by pontaoski's avatar pontaoski 🌈
Browse files

[sddm-theme] Start moving from QQC1 to QQC2

Summary: Components that used QQC1 in `sddm-theme/` (excluding the symlinked `components` folder) have been changed to use QQC2.

Test Plan:
Ensure no loss of functionality, style, or bugs from the port of QQC1 to QQC2.

{F7256235}

Reviewers: #plasma, #vdg, davidedmundson, filipf

Reviewed By: #plasma, #vdg, davidedmundson, filipf

Subscribers: ndavis, GB_2, ngraham, filipf, davidedmundson, plasma-devel

Tags: #plasma

Maniphest Tasks: T10958

Differential Revision: https://phabricator.kde.org/D21815
parent e745c7c7
import QtQuick 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
import QtQuick.Controls.Styles 1.4 as QQCS
import QtQuick.Controls 1.3 as QQC
QQCS.MenuStyle {
frame: Rectangle {
color: PlasmaCore.ColorScope.backgroundColor
border.color: Qt.tint(PlasmaCore.ColorScope.textColor, Qt.rgba(color.r, color.g, color.b, 0.7))
border.width: 1
}
itemDelegate.label: QQC.Label {
height: contentHeight * 1.2
verticalAlignment: Text.AlignVCenter
color: styleData.selected ? PlasmaCore.ColorScope.highlightedTextColor : PlasmaCore.ColorScope.textColor
font.pointSize: config.fontSize
text: styleData.text
}
itemDelegate.background: Rectangle {
visible: styleData.selected
color: PlasmaCore.ColorScope.highlightColor
}
}
import QtQuick 2.2
import QtQuick 2.6
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 3.0 as PlasmaComponents
import QtQuick.Controls 1.3 as QQC
import QtQuick.Controls 2.5 as QQC2
import QtGraphicalEffects 1.0
PlasmaComponents.ToolButton {
id: keyboardButton
......@@ -11,28 +12,103 @@ PlasmaComponents.ToolButton {
property int currentIndex: -1
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Keyboard Layout: %1", instantiator.objectAt(currentIndex).shortName)
implicitWidth: minimumWidth
font.pointSize: config.fontSize
visible: menu.items.length > 1
visible: keyboardMenu.count > 1
Component.onCompleted: currentIndex = Qt.binding(function() {return keyboard.currentLayout});
menu: QQC.Menu {
onClicked: {
keyboardMenu.popup(x, y)
}
QQC2.Menu {
id: keyboardMenu
style: BreezeMenuStyle {}
property int largestWidth: 9999
Component.onCompleted: {
var trueWidth = 0;
for (var i = 0; i < keyboardMenu.count; i++) {
trueWidth = Math.max(trueWidth, keyboardMenu.itemAt(i).textWidth)
}
keyboardMenu.largestWidth = trueWidth
}
background: Rectangle {
implicitHeight: 40
implicitWidth: keyboardMenu.largestWidth > keyboardButton.implicitWidth ? keyboardMenu.largestWidth : keyboardButton.implicitWidth
color: PlasmaCore.ColorScope.backgroundColor
property color borderColor: PlasmaCore.Colorscope.textColor
border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3)
border.width: 1
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
radius: 8
samples: 8
horizontalOffset: 0
verticalOffset: 2
color: Qt.rgba(0, 0, 0, 0.3)
}
}
Instantiator {
id: instantiator
model: keyboard.layouts
onObjectAdded: keyboardMenu.insertItem(index, object)
onObjectAdded: keyboardMenu.addItem( object )
onObjectRemoved: keyboardMenu.removeItem( object )
delegate: QQC.MenuItem {
text: modelData.longName
delegate: QQC2.MenuItem {
id: menuItem
property string name: modelData.longName
property string shortName: modelData.shortName
onTriggered: {
keyboard.currentLayout = model.index
property real textWidth: text.contentWidth + 20
implicitWidth: text.contentWidth + 20
implicitHeight: Math.round(text.contentHeight * 1.6)
contentItem: QQC2.Label {
id: text
font.pointSize: config.fontSize
text: modelData.longName
color: menuItem.highlighted ? PlasmaCore.ColorScope.highlightedTextColor : PlasmaCore.ColorScope.textColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
background: Rectangle {
color: PlasmaCore.ColorScope.highlightColor
opacity: menuItem.highlighted ? 1 : 0
MouseArea {
anchors.fill: parent
hoverEnabled: true
onContainsMouseChanged: menuItem.highlighted = containsMouse
onClicked: {
keyboardMenu.dismiss()
keyboard.currentLayout = model.index
}
}
}
}
}
enter: Transition {
NumberAnimation {
property: "opacity"
from: 0
to: 1
duration: 150
}
}
exit: Transition {
NumberAnimation {
property: "opacity"
from: 1
to: 0
duration: 150
}
}
}
}
......@@ -20,7 +20,7 @@
import QtQuick 2.8
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.1
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
......
/*
* Copyright 2016 David Edmundson <davidedmundson@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.2
* Copyright 2016 David Edmundson <davidedmundson@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.6
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 3.0 as PlasmaComponents
import QtQuick.Controls 1.3 as QQC
import QtQuick.Controls 2.5 as QQC2
import QtGraphicalEffects 1.0
PlasmaComponents.ToolButton {
id: root
id: sessionButton
property int currentIndex: -1
implicitWidth: minimumWidth
visible: menu.items.length > 1
visible: sessionMenu.count > 1
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Desktop Session: %1", instantiator.objectAt(currentIndex).text || "")
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Desktop Session: %1", instantiator.objectAt(currentIndex).name || "Error")
font.pointSize: config.fontSize
......@@ -40,19 +39,94 @@ PlasmaComponents.ToolButton {
currentIndex = sessionModel.lastIndex
}
menu: QQC.Menu {
id: menu
style: BreezeMenuStyle {}
onClicked: {
sessionMenu.popup(x, y)
}
QQC2.Menu {
id: sessionMenu
property int largestWidth: 9999
Component.onCompleted: {
var trueWidth = 0;
for (var i = 0; i < sessionMenu.count; i++) {
trueWidth = Math.max(trueWidth, sessionMenu.itemAt(i).textWidth)
}
sessionMenu.largestWidth = trueWidth
}
background: Rectangle {
implicitHeight: 40
implicitWidth: sessionMenu.largestWidth > sessionButton.implicitWidth ? sessionMenu.largestWidth : sessionButton.implicitWidth
color: PlasmaCore.ColorScope.backgroundColor
property color borderColor: PlasmaCore.Colorscope.textColor
border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3)
border.width: 1
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
radius: 8
samples: 8
horizontalOffset: 0
verticalOffset: 2
color: Qt.rgba(0, 0, 0, 0.3)
}
}
Instantiator {
id: instantiator
model: sessionModel
onObjectAdded: menu.insertItem(index, object)
onObjectRemoved: menu.removeItem( object )
delegate: QQC.MenuItem {
text: model.name
onTriggered: {
root.currentIndex = model.index
onObjectAdded: sessionMenu.addItem( object )
onObjectRemoved: sessionMenu.removeItem( object )
delegate: QQC2.MenuItem {
id: menuItem
property string name: model.name
property real textWidth: text.contentWidth + 20
implicitWidth: text.contentWidth + 20
implicitHeight: Math.round(text.contentHeight * 1.6)
contentItem: QQC2.Label {
id: text
font.pointSize: config.fontSize
text: model.name
color: menuItem.highlighted ? PlasmaCore.ColorScope.highlightedTextColor : PlasmaCore.ColorScope.textColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
background: Rectangle {
color: PlasmaCore.ColorScope.highlightColor
opacity: menuItem.highlighted ? 1 : 0
MouseArea {
anchors.fill: parent
hoverEnabled: true
onContainsMouseChanged: menuItem.highlighted = containsMouse
onClicked: {
sessionMenu.dismiss()
sessionButton.currentIndex = model.index
}
}
}
}
}
enter: Transition {
NumberAnimation {
property: "opacity"
from: 0
to: 1
duration: 150
}
}
exit: Transition {
NumberAnimation {
property: "opacity"
from: 1
to: 0
duration: 150
}
}
}
......
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