Closed bkrith closed 7 years ago
Hello! Thanks for your feedback :). Not showing title is weird, I wonder what version of the widget you currently have. Did you build it yourself or have you installed it from KDE store? Anyway I've just created a new version (1.7.0). Please try it from KDE store or from here. If it is still not working, report back, I'm sure we'll resolve this :).
Hi! Thanks for your reply! I tried both kde store and github versions.. nothing! I tried the newest master but nothing also! Before any installation I remove completely anything from the applet. Buttons, mouse actions and tooltip working! Also the text Plasma Desktop shows when im in desktop but no window title. I dont know what is wrong.. in compiling i use "cmake make sudo make install" which output has no errors! I change in main.qml the line(s) where you set the window title text and set it to simple plain text like "Hello World!" (I used also the function i18n) but nothing again. Not showing even simple text but tooltip working (no sense for me! if tooltip works, title must works also.. but not). (Sorry for my english) Thank you for your time!
ps. also no icon
I searched little the code and I found that the delegate Item cant see model:activeWindowModel because also this is the same problem with icon. Also tooltip and buttons not working if i dont unlock/lock widgets! Im thinking this is a problem of qt version..
That would explain a lot. But I've never stumbled on such problems. I'll also try installing Kubuntu to virtualbox and see what happens.
I cant manage to get model works... I make a fix for my situation and I pass data via global variant. This is the code (I dont understand QML and I cant find any tutorial for plasmoids).. ` /*
Item { id: main
property bool vertical: (plasmoid.formFactor == PlasmaCore.Types.Vertical)
property double horizontalScreenWidthPercent: plasmoid.configuration.horizontalScreenWidthPercent
property double buttonSize: plasmoid.configuration.buttonSize
property bool autoFillWidth: plasmoid.configuration.autoFillWidth
property double widthForHorizontalPanel: (Screen.width * horizontalScreenWidthPercent + plasmoid.configuration.widthFineTuning) - ((!controlButtonsArea.visible && buttonsStandalone && plasmoid.configuration.buttonsDynamicWidth) ? controlButtonsArea.width : 0)
anchors.fill: parent
Layout.fillWidth: plasmoid.configuration.autoFillWidth
Layout.preferredWidth: autoFillWidth ? -1 : (vertical ? parent.width : (widthForHorizontalPanel > 0 ? widthForHorizontalPanel : 0.0001))
Layout.minimumWidth: Layout.preferredWidth
Layout.maximumWidth: Layout.preferredWidth
Layout.preferredHeight: parent === null ? 0 : vertical ? Math.min(theme.defaultFont.pointSize * 4, parent.width) : parent.height
Layout.minimumHeight: Layout.preferredHeight
Layout.maximumHeight: Layout.preferredHeight
property int textType: plasmoid.configuration.textType
property int fitText: plasmoid.configuration.fitText
property int tooltipTextType: plasmoid.configuration.tooltipTextType
property string tooltipText: ''
property string titleText: ''
property bool windowIconOnTheRight: plasmoid.configuration.windowIconOnTheRight
property double iconAndTextSpacing: plasmoid.configuration.iconAndTextSpacing
property bool slidingIconAndText: plasmoid.configuration.slidingIconAndText
property double fontPixelSize: theme.defaultFont.pixelSize * plasmoid.configuration.fontSizeScale
property bool fontBold: plasmoid.configuration.boldFontWeight
property string fontFamily: plasmoid.configuration.fontFamily
property bool noWindowVisible: true
property bool currentWindowMaximized: false
property bool canShowButtonsAccordingMaximized: showButtonOnlyWhenMaximized ? currentWindowMaximized : true
property int controlButtonsSpacing: plasmoid.configuration.controlButtonsSpacing
property int bp: plasmoid.configuration.buttonsPosition;
property bool buttonsVerticalCenter: plasmoid.configuration.buttonsVerticalCenter
property bool showControlButtons: plasmoid.configuration.showControlButtons
property bool showButtonOnlyWhenMaximized: plasmoid.configuration.showButtonOnlyWhenMaximized
property bool showMinimize: showControlButtons && plasmoid.configuration.showMinimize
property bool showMaximize: showControlButtons && plasmoid.configuration.showMaximize
property bool showPinToAllDesktops: showControlButtons && plasmoid.configuration.showPinToAllDesktops
property string buttonOrder: plasmoid.configuration.buttonOrder
property bool doubleClickMaximizes: plasmoid.configuration.doubleClickMaximizes
property int leftClickAction: plasmoid.configuration.leftClickAction
property string chosenLeftClickSource: leftClickAction === 1 ? shortcutDS.presentWindows : leftClickAction === 2 ? shortcutDS.presentWindowsAll : leftClickAction === 3 ? shortcutDS.presentWindowsClass : ''
property bool middleClickClose: plasmoid.configuration.middleClickAction === 1
property bool middleClickFullscreen: plasmoid.configuration.middleClickAction === 2
property bool wheelUpMaximizes: plasmoid.configuration.wheelUpMaximizes
property bool wheelDownMinimizes: plasmoid.configuration.wheelDownAction === 1
property bool wheelDownUnmaximizes: plasmoid.configuration.wheelDownAction === 2
property bool buttonsStandalone: showControlButtons && plasmoid.configuration.buttonsStandalone
property bool doNotHideControlButtons: showControlButtons && plasmoid.configuration.doNotHideControlButtons
property bool textColorLight: ((theme.textColor.r + theme.textColor.g + theme.textColor.b) / 3) > 0.5
property bool mouseHover: false
property bool isActiveWindowPinned: false
property bool isActiveWindowMaximized: false
property bool appmenuNextToIconAndText: plasmoid.configuration.appmenuNextToIconAndText
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
// Variant to pass through activeTask
property variant firstTask: activeTask()
//
// MODEL
//
TaskManager.TasksModel {
id: tasksModel
sortMode: TaskManager.TasksModel.SortVirtualDesktop
groupMode: TaskManager.TasksModel.GroupDisabled
// Its not need it but I left them
virtualDesktop: virtualDesktopInfo.currentDesktop
screenGeometry: plasmoid.screenGeometry
onActiveTaskChanged: {
activeWindowModel.sourceModel = tasksModel
updateActiveWindowInfo()
updateTooltip() // Also update here
}
}
// Also I left them
TaskManager.VirtualDesktopInfo {
id: virtualDesktopInfo
}
// should return always one item
PlasmaCore.SortFilterModel {
id: activeWindowModel
filterRole: 'IsActive'
filterRegExp: 'true'
sourceModel: tasksModel
onDataChanged: {
updateActiveWindowInfo()
updateTooltip()
}
}
function activeTask() {
return activeWindowModel.get(0) || {}
}
onTooltipTextTypeChanged: updateTooltip()
function updateTooltip() {
if (tooltipTextType === 1) {
tooltipText = replaceTitle(firstTask.display || '')
} else if (tooltipTextType === 2) {
tooltipText = firstTask.AppName || ''
} else {
tooltipText = ''
}
updateTitle() // With tooltip I update the Title also
}
// Function for update Title
function updateTitle() {
if (textType === 1 && firstTask.AppName) {
titleText = firstTask.AppName
} else if (firstTask.display){
titleText = replaceTitle(firstTask.display)
} else {
titleText = i18n('Plasma Desktop')
}
}
function updateActiveWindowInfo() {
firstTask = activeTask()
noWindowVisible = activeWindowModel.count === 0 || firstTask.IsActive !== true
currentWindowMaximized = !noWindowVisible && firstTask.IsMaximized === true
isActiveWindowPinned = firstTask.VirtualDesktop === -1
}
function toggleMaximized() {
tasksModel.requestToggleMaximized(tasksModel.activeTask);
}
function toggleMinimized() {
tasksModel.requestToggleMinimized(tasksModel.activeTask);
}
function toggleClose() {
tasksModel.requestClose(tasksModel.activeTask);
}
function toggleFullscreen() {
tasksModel.requestToggleFullScreen(tasksModel.activeTask);
}
function togglePinToAllDesktops() {
tasksModel.requestVirtualDesktop(tasksModel.activeTask, 0);
}
function setMaximized(maximized) {
if ((maximized && !activeTask().IsMaximized)
|| (!maximized && activeTask().IsMaximized)) {
print('toggle maximized')
toggleMaximized()
}
}
function setMinimized() {
if (!activeTask().IsMinimized) {
toggleMinimized()
}
}
PlasmaComponents.Label {
id: noWindowText
property double noWindowTextMargin: (parent.height - implicitHeight) / 2
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: noWindowTextMargin
anchors.left: parent.left
text: i18n('Plasma Desktop')
font.pixelSize: fontPixelSize
font.pointSize: -1
font.weight: fontBold ? Font.Bold : theme.defaultFont.weight
font.family: fontFamily || theme.defaultFont.family
width: parent.width - noWindowTextMargin * 2
elide: Text.ElideRight
visible: noWindowVisible && plasmoid.configuration.showWindowTitle && !appmenu.visible
}
//
// ACTIVE WINDOW INFO
//
ListView {
id: activeWindowListView
// I keep the model because without it I have no data change
model:activeWindowModel
anchors.top: parent.top
anchors.bottom: parent.bottom
property double appmenuOffsetLeft: (bp === 0 || bp === 2) ? appmenu.appmenuOffsetWidth : 0
property double appmenuOffsetRight: (bp === 1 || bp === 3) ? appmenu.appmenuOffsetWidth : 0
anchors.left: parent.left
anchors.leftMargin: buttonsStandalone && (bp === 0 || bp === 2) && (!slidingIconAndText || controlButtonsArea.mouseInWidget || doNotHideControlButtons) && (canShowButtonsAccordingMaximized || !slidingIconAndText) ? controlButtonsArea.width + appmenuOffsetLeft : 0 + appmenuOffsetLeft
anchors.right: parent.right
anchors.rightMargin: buttonsStandalone && (bp === 1 || bp === 3) && (!slidingIconAndText || controlButtonsArea.mouseInWidget || doNotHideControlButtons) && (canShowButtonsAccordingMaximized || !slidingIconAndText) ? controlButtonsArea.width + appmenuOffsetRight : 0 + appmenuOffsetRight
Behavior on anchors.leftMargin {
NumberAnimation {
duration: 150
easing.type: Easing.Linear
}
}
Behavior on anchors.rightMargin {
NumberAnimation {
duration: 150
easing.type: Easing.Linear
}
}
width: parent.width - anchors.leftMargin - anchors.rightMargin
visible: !noWindowVisible
opacity: appmenu.visible && !appmenuNextToIconAndText ? 0.2 : 1
// I removed the delegate Item
Item {
width: parent.width
height: main.height
property double iconMargin: (plasmoid.configuration.showWindowIcon ? iconItem.width : 0)
// window icon
PlasmaCore.IconItem {
id: iconItem
anchors.left: parent.left
anchors.leftMargin: windowIconOnTheRight ? parent.width - iconItem.width : 5 // 5: Extra margin for buttons - icons
width: parent.height
height: parent.height
source: firstTask.decoration
visible: plasmoid.configuration.showWindowIcon
}
// window title
PlasmaComponents.Label {
id: windowTitleText
property double properWidth: parent.width - (plasmoid.configuration.showWindowIcon ? iconItem.width : 0) - plasmoid.configuration.iconAndTextSpacing - 5 // 5: Extra margin for buttons - icons
property double properHeight: parent.height
property bool noElide: fitText === 2 || (fitText === 1 && mouseHover)
property int allowFontSizeChange: 3
property int minimumPixelSize: 8
anchors.left: parent.left
anchors.leftMargin: windowIconOnTheRight ? 0 : (plasmoid.configuration.showWindowIcon ? iconItem.width : 0) + plasmoid.configuration.iconAndTextSpacing + 5 // 5: Extra margin for buttons - icons
anchors.top: parent.top
anchors.bottom: parent.bottom
verticalAlignment: Text.AlignVCenter
text: titleText // I pass the title text like tooltip text
wrapMode: Text.Wrap
width: properWidth
elide: noElide ? Text.ElideNone : Text.ElideRight
visible: plasmoid.configuration.showWindowTitle
font.pixelSize: fontPixelSize
font.pointSize: -1
font.weight: fontBold ? Font.Bold : theme.defaultFont.weight
font.family: fontFamily || theme.defaultFont.family
onTextChanged: {
font.pixelSize = fontPixelSize
allowFontSizeChange = 3
}
onNoElideChanged: {
font.pixelSize = fontPixelSize
allowFontSizeChange = 3
}
onPaintedHeightChanged: {
if (allowFontSizeChange > 0 && noElide && paintedHeight > properHeight) {
var newPixelSize = (properHeight / paintedHeight) * fontPixelSize
font.pixelSize = newPixelSize < minimumPixelSize ? minimumPixelSize : newPixelSize
}
allowFontSizeChange--
}
}
}
}
function replaceTitle(title) {
if (!plasmoid.configuration.useWindowTitleReplace) {
return title
}
return title.replace(new RegExp(plasmoid.configuration.replaceTextRegex), plasmoid.configuration.replaceTextReplacement);
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onEntered: {
mouseHover = true
controlButtonsArea.mouseInWidget = showControlButtons && !noWindowVisible
}
onExited: {
mouseHover = false
controlButtonsArea.mouseInWidget = false
}
onWheel: {
if (wheel.angleDelta.y > 0) {
if (wheelUpMaximizes) {
setMaximized(true)
}
} else {
if (wheelDownMinimizes) {
setMinimized()
} else if (wheelDownUnmaximizes) {
setMaximized(false)
}
}
}
onDoubleClicked: {
if (doubleClickMaximizes && mouse.button == Qt.LeftButton) {
toggleMaximized()
}
}
onClicked: {
if (chosenLeftClickSource !== '' && !doubleClickMaximizes && mouse.button == Qt.LeftButton) {
shortcutDS.connectedSources.push(chosenLeftClickSource)
controlButtonsArea.mouseInWidget = false
return
}
if (mouse.button == Qt.MiddleButton) {
if (middleClickFullscreen) {
toggleFullscreen()
} else if (middleClickClose) {
toggleClose()
}
}
}
PlasmaCore.ToolTipArea {
anchors.fill: parent
active: tooltipTextType > 0
interactive: true
location: plasmoid.location
mainItem: Row {
spacing: 0
Layout.minimumWidth: fullText.width + units.largeSpacing
Layout.minimumHeight: childrenRect.height
Layout.maximumWidth: Layout.minimumWidth
Layout.maximumHeight: Layout.minimumHeight
Item {
width: units.largeSpacing / 2
height: 2
}
PlasmaComponents.Label {
id: fullText
text: tooltipText
}
}
}
AppMenu {
id: appmenu
}
ListView {
id: controlButtonsArea
property bool mouseInWidget: false
property double controlButtonsHeight: parent.height * buttonSize
orientation: ListView.Horizontal
visible: showControlButtons && (doNotHideControlButtons || mouseInWidget) && (currentWindowMaximized || !showButtonOnlyWhenMaximized) && !noWindowVisible
spacing: controlButtonsSpacing
height: buttonsVerticalCenter ? parent.height : controlButtonsHeight
width: controlButtonsHeight + ((controlButtonsModel.count - 1) * (controlButtonsHeight + controlButtonsSpacing))
anchors.top: parent.top
anchors.left: parent.left
anchors.leftMargin: (bp === 1 || bp === 3) ? parent.width - width : 0
anchors.topMargin: (bp === 2 || bp === 3) ? parent.height - height : 0
model: controlButtonsModel
delegate: ControlButton { }
}
}
ListModel {
id: controlButtonsModel
}
function addButton(preparedArray, buttonName) {
if (buttonName === 'close') {
preparedArray.push({
iconName: 'close',
windowOperation: 'close'
});
} else if (buttonName === 'maximize' && showMaximize) {
preparedArray.push({
iconName: 'maximize',
windowOperation: 'toggleMaximized'
});
} else if (buttonName === 'minimize' && showMinimize) {
preparedArray.push({
iconName: 'minimize',
windowOperation: 'toggleMinimized'
});
} else if (buttonName === 'pin' && showPinToAllDesktops) {
preparedArray.push({
iconName: 'pin',
windowOperation: 'togglePinToAllDesktops'
});
}
}
function initializeControlButtonsModel() {
var preparedArray = []
buttonOrder.split('|').forEach(function (buttonName) {
addButton(preparedArray, buttonName);
});
controlButtonsModel.clear()
if (bp === 1 || bp === 3) {
for (var i = preparedArray.length - 1; i >= 0; i--) {
controlButtonsModel.append(preparedArray[i])
}
} else {
for (var i = 0; i < preparedArray.length; i++) {
controlButtonsModel.append(preparedArray[i])
}
}
}
function performActiveWindowAction(windowOperation) {
if (bp === 4 || !controlButtonsArea.visible) {
return;
}
if (windowOperation === 'close') {
toggleClose()
} else if (windowOperation === 'toggleMaximized') {
toggleMaximized()
} else if (windowOperation === 'toggleMinimized') {
toggleMinimized()
} else if (windowOperation === 'togglePinToAllDesktops') {
togglePinToAllDesktops()
}
}
function action_close() {
toggleClose()
}
function action_maximise() {
toggleMaximized()
}
function action_minimise() {
toggleMinimized()
}
function action_pinToAllDesktops() {
togglePinToAllDesktops()
}
Component.onCompleted: {
initializeControlButtonsModel()
plasmoid.setAction('close', i18n('Close'), 'window-close');
plasmoid.setAction('maximise', i18n('Toggle Maximise'), 'arrow-up-double');
plasmoid.setAction('minimise', i18n('Minimise'), 'draw-arrow-down');
plasmoid.setAction('pinToAllDesktops', i18n('Pin To All Desktops'), 'window-pin');
}
onShowMaximizeChanged: initializeControlButtonsModel()
onShowMinimizeChanged: initializeControlButtonsModel()
onShowPinToAllDesktopsChanged: initializeControlButtonsModel()
onBpChanged: initializeControlButtonsModel()
onButtonOrderChanged: initializeControlButtonsModel()
PlasmaCore.DataSource {
id: shortcutDS
engine: 'executable'
property string presentWindows: 'qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Expose"'
property string presentWindowsAll: 'qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "ExposeAll"'
property string presentWindowsClass: 'qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "ExposeClass"'
connectedSources: []
onNewData: {
connectedSources.length = 0
}
}
} `
But I keep the problem with lock/unlock widgets to make it works! When desktop start the plasmoid works but without updates.. for example if I open dolphin in home folder change title to "home - dolphin".. if navigate to documents the title stays "home - dolphin". I must deactivate and activate again the window to see the change. If I do any action from "cashew" like lock, unlock, configure desktop, lock screen, etc. then the plasmoid works perfectely! The active task from tasksmodel not refreshed! Do you have any idea what's going on?
Thank you very much for your support! Kubuntu WAS fresh install and I had this weird issue.. so, I get on with manjaro now! all parts - components in EXACTLY same versions and your plasmoid is AMAZING! I updated all the system to the newer versions and continues working perfectely!!!
Thank you again for your amazing work and tell me if you need any help in any way with this project or a new!
bkrith@hotmail.com
Thanks a lot! Sorry that I'm quite slow to respond. I actually installed Kubuntu 16.10 to Virtualbox and was able to replicate your issue. But since you resolved that by installing Manjaro, I'll postpone working on this compatibility (I mean using mostly code you've provided:)) for later and try to do some feature work instead. Anyway thanks for your help offer, greek translation and positive words - all appreciated!
Hi, I just start using kde after 10 years away. And I'm trying to use the plasmoid but title is not there.. buttons and mouse actions working perfect but no title. (I have enable title from the options). I did something in wrong way or what? I'm in Kubuntu 16.10 plasma 5.8.5 kde 5.28.0 qt 5.6.1. Btw is very useful applet! Thanks for your work!