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,38 +1,100 @@ -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 2.5 as QQC2 -import QtQuick.Controls 1.3 as QQC PlasmaComponents.ToolButton { - id: keyboardButton + id: toolBtn 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 > toolBtn.implicitWidth ? keyboardMenu.largestWidth : toolBtn.implicitWidth + 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 + 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 @@ -1,58 +1,118 @@ /* - * Copyright 2016 David Edmundson - * - * 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 +* +* 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 PlasmaComponents.ToolButton { - id: root + id: toolBtn 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 Component.onCompleted: { 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 > toolBtn.implicitWidth ? sessionMenu.largestWidth : toolBtn.implicitWidth + 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 + 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 } } }