diff --git a/tabbox/qml/IconTabBox.qml b/tabbox/qml/IconTabBox.qml index 6f60113f53..0ed29720ce 100644 --- a/tabbox/qml/IconTabBox.qml +++ b/tabbox/qml/IconTabBox.qml @@ -27,14 +27,11 @@ Item { property alias count: iconsListView.count property alias margins: hoverItem.margins property alias currentItem: iconsListView.currentItem + property alias model: iconsListView.model + property alias currentIndex: iconsListView.currentIndex focus: true clip: true - - function setModel(model) { - iconsListView.model = model; - } - // just to get the margin sizes PlasmaCore.FrameSvgItem { id: hoverItem @@ -70,15 +67,12 @@ Item { anchors.fill: parent onClicked: { iconsListView.currentIndex = index; - iconsListView.currentIndexChanged(iconsListView.currentIndex); } } } } ListView { - signal currentIndexChanged(int index) id: iconsListView - objectName: "listView" orientation: ListView.Horizontal width: Math.min(parent.width, (iconSize + margins.left + margins.right) * count) height: iconSize + margins.top + margins.bottom @@ -106,10 +100,8 @@ Item { Keys.onPressed: { if (event.key == Qt.Key_Left) { iconsListView.decrementCurrentIndex(); - iconsListView.currentIndexChanged(iconsListView.currentIndex); } else if (event.key == Qt.Key_Right) { iconsListView.incrementCurrentIndex(); - iconsListView.currentIndexChanged(iconsListView.currentIndex); } } } diff --git a/tabbox/qml/clients/big_icons/contents/ui/main.qml b/tabbox/qml/clients/big_icons/contents/ui/main.qml index 8f5c262ae0..e36e1fa74e 100644 --- a/tabbox/qml/clients/big_icons/contents/ui/main.qml +++ b/tabbox/qml/clients/big_icons/contents/ui/main.qml @@ -20,93 +20,90 @@ along with this program. If not, see . import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.qtextracomponents 2.0 +import org.kde.kwin 2.0 as KWin -Item { - id: bigIconsTabBox - property int screenWidth : 0 - property int screenHeight : 0 - property int optimalWidth: (icons.iconSize + icons.margins.left + icons.margins.right) * icons.count + background.leftMargin + background.bottomMargin - property int optimalHeight: icons.iconSize + icons.margins.top + icons.margins.bottom + background.topMargin + background.bottomMargin + 40 - property bool canStretchX: false - property bool canStretchY: false - property string maskImagePath: background.maskImagePath - property double maskWidth: background.centerWidth - property double maskHeight: background.centerHeight - property int maskTopMargin: background.centerTopMargin - property int maskLeftMargin: background.centerLeftMargin - width: Math.min(Math.max(screenWidth * 0.3, optimalWidth), screenWidth * 0.9) - height: Math.min(Math.max(screenHeight * 0.05, optimalHeight), screenHeight * 0.5) +KWin.Switcher { + id: tabBox + currentIndex: icons.currentIndex - - function setModel(model) { - icons.setModel(model); - } - - function modelChanged() { - icons.modelChanged(); - } - - ShadowedSvgItem { - id: background - anchors.fill: parent - } - - IconTabBox { - id: icons - iconSize: 128 - height: iconSize + background.topMargin + icons.margins.top + icons.margins.bottom - anchors { - top: parent.top - left: parent.left - right: parent.right - topMargin: background.topMargin - rightMargin: background.rightMargin - leftMargin: background.leftMargin + PlasmaCore.Dialog { + id: dialog + location: PlasmaCore.Types.Floating + visible: tabBox.visible + windowFlags: Qt.X11BypassWindowManagerHint + onVisibleChanged: { + if (visible) { + dialog.x = tabBox.screenGeometry.x + tabBox.screenGeometry.width * 0.5 - dialogMainItem.width * 0.5; + dialog.y = tabBox.screenGeometry.y + tabBox.screenGeometry.height * 0.5 - dialogMainItem.height * 0.5; + } } - } - Item { - id: captionFrame - anchors { - top: icons.bottom - left: parent.left - right: parent.right - bottom: parent.bottom - leftMargin: background.leftMargin - rightMargin: background.rightMargin - bottomMargin: background.bottomMargin - } - Text { - function constrainWidth() { - if (textItem.width > textItem.maxWidth && textItem.width > 0 && textItem.maxWidth > 0) { - textItem.width = textItem.maxWidth; - } else { - textItem.width = undefined; + + mainItem: Item { + id: dialogMainItem + property int optimalWidth: (icons.iconSize + icons.margins.left + icons.margins.right) * icons.count + property int optimalHeight: icons.iconSize + icons.margins.top + icons.margins.bottom + 40 + property bool canStretchX: false + property bool canStretchY: false + width: Math.min(Math.max(tabBox.screenGeometry.width * 0.3, optimalWidth), tabBox.screenGeometry.width * 0.9) + height: Math.min(Math.max(tabBox.screenGeometry.height * 0.05, optimalHeight), tabBox.screenGeometry.height * 0.5) + + IconTabBox { + id: icons + model: tabBox.model + iconSize: 128 + height: iconSize + icons.margins.top + icons.margins.bottom + anchors { + top: parent.top + left: parent.left + right: parent.right + } + Connections { + target: tabBox + onCurrentIndexChanged: {icons.currentIndex = tabBox.currentIndex;} } } - function calculateMaxWidth() { - textItem.maxWidth = bigIconsTabBox.width - captionFrame.anchors.leftMargin - captionFrame.anchors.rightMargin - captionFrame.anchors.rightMargin; - } - id: textItem - property int maxWidth: 0 - text: icons.currentItem ? icons.currentItem.data.caption : "" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: theme.textColor - elide: Text.ElideMiddle - font { - bold: true - } - anchors { - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter - } - onTextChanged: textItem.constrainWidth() - Component.onCompleted: textItem.calculateMaxWidth() - Connections { - target: bigIconsTabBox - onWidthChanged: { - textItem.calculateMaxWidth(); - textItem.constrainWidth(); + Item { + id: captionFrame + anchors { + top: icons.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + Text { + function constrainWidth() { + if (textItem.width > textItem.maxWidth && textItem.width > 0 && textItem.maxWidth > 0) { + textItem.width = textItem.maxWidth; + } else { + textItem.width = undefined; + } + } + function calculateMaxWidth() { + textItem.maxWidth = dialogMainItem.width - captionFrame.anchors.leftMargin - captionFrame.anchors.rightMargin - captionFrame.anchors.rightMargin; + } + id: textItem + property int maxWidth: 0 + text: icons.currentItem ? icons.currentItem.data.caption : "" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: theme.textColor + elide: Text.ElideMiddle + font { + bold: true + } + anchors { + verticalCenter: parent.verticalCenter + horizontalCenter: parent.horizontalCenter + } + onTextChanged: textItem.constrainWidth() + Component.onCompleted: textItem.calculateMaxWidth() + Connections { + target: dialogMainItem + onWidthChanged: { + textItem.calculateMaxWidth(); + textItem.constrainWidth(); + } + } } } } diff --git a/tabbox/qml/clients/small_icons/contents/ui/main.qml b/tabbox/qml/clients/small_icons/contents/ui/main.qml index 70ee0cf760..544b0276cf 100644 --- a/tabbox/qml/clients/small_icons/contents/ui/main.qml +++ b/tabbox/qml/clients/small_icons/contents/ui/main.qml @@ -20,75 +20,72 @@ along with this program. If not, see . import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.qtextracomponents 2.0 +import org.kde.kwin 2.0 as KWin -Item { - id: smallIconsTabBox - property int screenWidth : 0 - property int screenHeight : 0 - property int optimalWidth: (icons.iconSize + icons.margins.left + icons.margins.right) * icons.count + background.leftMargin + background.bottomMargin - property int optimalHeight: icons.iconSize + icons.margins.top + icons.margins.bottom + background.topMargin + background.bottomMargin + 40 - property bool canStretchX: false - property bool canStretchY: false - property string maskImagePath: background.maskImagePath - property double maskWidth: background.centerWidth - property double maskHeight: background.centerHeight - property int maskTopMargin: background.centerTopMargin - property int maskLeftMargin: background.centerLeftMargin - width: Math.min(Math.max(screenWidth * 0.1, optimalWidth), screenWidth * 0.9) - height: Math.min(Math.max(screenHeight * 0.05, optimalHeight), screenHeight * 0.5) +KWin.Switcher { + id: tabBox + currentIndex: icons.currentIndex - - function setModel(model) { - icons.setModel(model); - } - - function modelChanged() { - icons.modelChanged(); - } - - ShadowedSvgItem { - id: background - anchors.fill: parent - } - - IconTabBox { - id: icons - iconSize: 16 - height: iconSize + background.topMargin + icons.margins.top + icons.margins.bottom - anchors { - top: parent.top - left: parent.left - right: parent.right - topMargin: background.topMargin - rightMargin: background.rightMargin - leftMargin: background.leftMargin - } - } - Item { - anchors { - top: icons.bottom - left: parent.left - right: parent.right - bottom: parent.bottom - leftMargin: background.leftMargin - rightMargin: background.rightMargin - bottomMargin: background.bottomMargin - } - Text { - id: textItem - text: icons.currentItem ? icons.currentItem.data.caption : "" - height: paintedHeight - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: theme.textColor - elide: Text.ElideMiddle - font { - bold: true + PlasmaCore.Dialog { + id: dialog + location: PlasmaCore.Types.Floating + visible: tabBox.visible + windowFlags: Qt.X11BypassWindowManagerHint + onVisibleChanged: { + if (visible) { + dialog.x = tabBox.screenGeometry.x + tabBox.screenGeometry.width * 0.5 - dialogMainItem.width * 0.5; + dialog.y = tabBox.screenGeometry.y + tabBox.screenGeometry.height * 0.5 - dialogMainItem.height * 0.5; } - anchors { - right: parent.right - left: parent.left - verticalCenter: parent.verticalCenter + } + + mainItem: Item { + id: dialogMainItem + property int optimalWidth: (icons.iconSize + icons.margins.left + icons.margins.right) * icons.count + property int optimalHeight: icons.iconSize + icons.margins.top + icons.margins.bottom + 40 + property bool canStretchX: false + property bool canStretchY: false + width: Math.min(Math.max(tabBox.screenGeometry.width * 0.1, optimalWidth), tabBox.screenGeometry.width * 0.9) + height: Math.min(Math.max(tabBox.screenGeometry.height * 0.05, optimalHeight), tabBox.screenGeometry.height * 0.5) + + IconTabBox { + id: icons + model: tabBox.model + iconSize: 16 + height: iconSize + icons.margins.top + icons.margins.bottom + anchors { + top: parent.top + left: parent.left + right: parent.right + } + Connections { + target: tabBox + onCurrentIndexChanged: {icons.currentIndex = tabBox.currentIndex;} + } + } + Item { + anchors { + top: icons.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + Text { + id: textItem + text: icons.currentItem ? icons.currentItem.data.caption : "" + height: paintedHeight + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: theme.textColor + elide: Text.ElideMiddle + font { + bold: true + } + anchors { + right: parent.right + left: parent.left + verticalCenter: parent.verticalCenter + } + } } } }