diff --git a/sddm-theme/BreezeMenuStyle.qml b/sddm-theme/BreezeMenuStyle.qml deleted file mode 100644 --- a/sddm-theme/BreezeMenuStyle.qml +++ /dev/null @@ -1,25 +0,0 @@ -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 - } -} diff --git a/sddm-theme/KeyboardButton.qml b/sddm-theme/KeyboardButton.qml --- a/sddm-theme/KeyboardButton.qml +++ b/sddm-theme/KeyboardButton.qml @@ -1,37 +1,105 @@ -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 -PlasmaComponents.ToolButton { - id: keyboardButton +Item { + id: root + implicitHeight: toolBtn.implicitHeight + implicitWidth: toolBtn.implicitWidth + + PlasmaComponents.ToolButton { + id: toolBtn - property int currentIndex: -1 + property int currentIndex: -1 - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Keyboard Layout: %1", instantiator.objectAt(currentIndex).shortName) - implicitWidth: minimumWidth - font.pointSize: config.fontSize + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Keyboard Layout: %1", instantiator.objectAt(currentIndex).shortName) + + 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 { + Component.onCompleted: currentIndex = Qt.binding(function() {return keyboard.currentLayout}); + + 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 + color: PlasmaCore.ColorScope.backgroundColor + border.color: Qt.tint(PlasmaCore.ColorScope.textColor, Qt.rgba(color.r, color.g, color.b, 0.7)) + border.width: 1 + } + 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: text.contentHeight * 1.6 + + contentItem: QQC2.Label { + id: text + text: modelData.longName + font: menuItem.font + color: PlasmaCore.ColorScope.textColor + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight } + + background: Rectangle { + color: menuItem.highlighted ? PlasmaCore.ColorScope.highlightColor : "transparent" + 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 } } } diff --git a/sddm-theme/Main.qml b/sddm-theme/Main.qml --- a/sddm-theme/Main.qml +++ b/sddm-theme/Main.qml @@ -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 diff --git a/sddm-theme/SessionButton.qml b/sddm-theme/SessionButton.qml --- a/sddm-theme/SessionButton.qml +++ b/sddm-theme/SessionButton.qml @@ -17,42 +17,109 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -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 -PlasmaComponents.ToolButton { +Item { id: root - property int currentIndex: -1 + implicitHeight: toolBtn.implicitHeight + implicitWidth: toolBtn.implicitWidth + + PlasmaComponents.ToolButton { + id: toolBtn + property int currentIndex: -1 - implicitWidth: minimumWidth + visible: sessionMenu.count > 1 - visible: menu.items.length > 1 + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Desktop Session: %1", instantiator.objectAt(currentIndex).name || "Error") - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Desktop Session: %1", instantiator.objectAt(currentIndex).text || "") + font.pointSize: config.fontSize - font.pointSize: config.fontSize - - Component.onCompleted: { - currentIndex = sessionModel.lastIndex + Component.onCompleted: { + currentIndex = sessionModel.lastIndex + } + + onClicked: { + sessionMenu.popup(x, y) + } } - - menu: QQC.Menu { - id: menu - style: BreezeMenuStyle {} + + 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 + color: PlasmaCore.ColorScope.backgroundColor + border.color: Qt.tint(PlasmaCore.ColorScope.textColor, Qt.rgba(color.r, color.g, color.b, 0.7)) + border.width: 1 + } + 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: text.contentHeight * 1.6 + + contentItem: QQC2.Label { + id: text + text: model.name + font: menuItem.font + color: PlasmaCore.ColorScope.textColor + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight } + + background: Rectangle { + color: menuItem.highlighted ? PlasmaCore.ColorScope.highlightColor : "transparent" + MouseArea { + anchors.fill: parent + hoverEnabled: true + onContainsMouseChanged: menuItem.highlighted = containsMouse + onClicked: { + sessionMenu.dismiss() + toolBtn.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 } } }