Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement showing stderr as the tooltip #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<entry name="waitForCompletion" type="bool">
<default>true</default>
</entry>
<entry name="tooltipRichText" type="bool">
<default>false</default>
</entry>
<entry name="fontSize" type="int">
<default>16</default>
</entry>
Expand Down
6 changes: 6 additions & 0 deletions package/contents/ui/config/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ConfigPage {

property alias cfg_command: command.text
property alias cfg_waitForCompletion: waitForCompletion.checked
property alias cfg_tooltipRichText: tooltipRichText.checked
property alias cfg_interval: interval.value

ConfigSection {
Expand Down Expand Up @@ -41,6 +42,11 @@ ConfigPage {
text: i18n("Wait for completion")
enabled: false
}

CheckBox {
id: tooltipRichText
text: i18n("Parse stderr (ToolTip) as HTML")
}
}

ConfigSection {
Expand Down
12 changes: 12 additions & 0 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ Item {
id: config
property bool active: !!command
property bool waitForCompletion: plasmoid.configuration.waitForCompletion
property bool tooltipRichText: plasmoid.configuration.tooltipRichText
property int interval: Math.max(1000, plasmoid.configuration.interval)
property string command: plasmoid.configuration.command || 'sleep 2 && echo "Test: $(date +%s)"'
}

property string outputText: ''
property string tooltipText: ''
Connections {
target: executable
onExited: {
widget.outputText = stdout.replace('\n', ' ').trim()
widget.tooltipText = stderr;
if (config.waitForCompletion) {
timer.restart()
}
Expand Down Expand Up @@ -89,6 +92,15 @@ Item {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}

PlasmaCore.ToolTipArea {
anchors.fill: parent
icon: 'utilities-terminal'
mainText: widget.outputText
subText: widget.tooltipText
textFormat: config.tooltipRichText ? Text.RichText : Text.PlainText
}

}

}