Add the whole blog
This commit is contained in:
parent
0d2f58ce7a
commit
c4f23c1529
418 changed files with 15708 additions and 0 deletions
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
author: einar
|
||||
categories:
|
||||
- KDE
|
||||
- Linux
|
||||
comments: true
|
||||
date: "2014-01-04T08:03:18Z"
|
||||
slug: an-expedition-in-the-qml-realm
|
||||
tags:
|
||||
- KDE
|
||||
- Linux
|
||||
- plasma
|
||||
- QML
|
||||
title: An expedition in the QML realm
|
||||
disable_share: true
|
||||
wordpress_id: 1270
|
||||
---
|
||||
|
||||
Among the different widgets I use on my desktop, there is a small one which tells me my current public IP address. The reason I'm having it is due to the fact that my own ISP uses a NAT for almost all its customers (don't ask - long story) and so I need to keep tabs on my current IP, because it may have been blacklisted, and so on.
|
||||
|
||||
Up to now I was using [this plasmoid](http://kde-apps.org/content/show.php?content=147229) written in Python, but the code had several issues and used its own way of getting the public IP. However, I knew Plasma has **already** a way to give you your IP, that is the _geolocation _DataEngine. I thought of adjusting the current widget to use this engine, but then I thought "_What if I make one in QML?"_.
|
||||
|
||||
It turned out to be a rather easy task, which I accomplished in less than one hour, by reading up some documentation, examples and of course pestering people on IRC. ;)
|
||||
|
||||
All I needed to have the IP ready was
|
||||
|
||||
{{< highlight javascript >}}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: dataSource
|
||||
dataEngine: "geolocation"
|
||||
connectedSources: ['location']
|
||||
interval: 500
|
||||
|
||||
onNewData: {
|
||||
if (sourceName == 'location') {
|
||||
ipAddr.text = data.ip
|
||||
}
|
||||
}
|
||||
|
||||
{{< / highlight >}}
|
||||
|
||||
where `ipAddr` was a Text element.
|
||||
|
||||
And that's how is the final result (mimicking the other widget I took it from):
|
||||
|
||||

|
||||
|
||||
There are still a number of issues, for example getting the right size when started, and ensuring it's not resized to a too little size. But I was surprised that it was so easy.
|
||||
|
||||
Interested parties can grab it by cloning and installing:
|
||||
|
||||
{{< highlight bash >}}
|
||||
git clone https://git.dennogumi.org/kde/ip-address-viewer
|
||||
plasmapkg -i ip-address-viewer/
|
||||
{{< / highlight >}}
|
||||
|
||||
Suggestions on code quality are welcome.
|
Loading…
Add table
Add a link
Reference in a new issue