Wednesday, July 6, 2011
Verbosity
If this was a wall of text you would probably not have read it. "Brevity is the soul of wit." <- worth remembering for future writing.
Tuesday, June 7, 2011
Tutorial: Plasma+QML
In this tutorial I will attempt to teach you how to write a simple plasma widget using qml technology. I hope you find this informative! And I am sure some of the expert plasma widget developers will be able to offer some excellent additions to this tutorial in the comments! Before you start, I'd recommend you familiarize yourself with QML using this site: QDeclarative Introduction
(This post has some color coded sections, I am not sure that they will render properly on the planet, so if you feel you the color coding would help and you can't see it you may have to come to the blog itself.)
I. Setting Up
First thing is first, we need to setup the directory where we will be creating the widget.
Now we've set up the basic file structure for the widget. You'll notice there are only two editable items in what we've created, the .desktop file and the .qml file. The .desktop file will contain basic information about the plasma widget. The .qml file is where we will put the actual code for the widget. More complex plasma widgets will likely have more files in them.
II. metadata.desktop
Set the contents of the metadata.desktop file as follows.
The second block deals with what type of widget it is, where the main script is, how big the default widget size should be. If it was written in python it would say "X-Plasma-API=python"
The remaining blocks are mostly self explanatory please refer to techbase.kde.org for more information.
III. main.qml
Now to the meat and potates of the whole thing. What you all have been waiting for, the actual code that does something!
import Qt 4.7
import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
1. import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
IV. Testing
Now lets test this! Using a console go into the "plasma-qml" directory and enter the following command: plasmoidviewer
This should give you a preview of your plasmoid. If there is an error it will display that instead, read the error and find the offending code and fix it.
V. Installing
To install this we would go to the console. Inside the "plasma-qml" directory enter the following command: plasmapkg -i ./
Next run kbuildsycoca4 by entering the command in a console (I'm not sure if this always necessary).
Now you can add the Plasma-Qml widget like you would any other! Congratulations you have created and installed your first Plasma widget!
As an exercise try making a calculator widget.
IV. References
I used the following tutorials and this one is based on them. Please use them for more information. In general techbase.kde.org is your main resource for kde development.
Techbase Plamsa/QML
Techbase Plasma/Javascript
For more on QML examples
Update:
From Daker Fernandes Pinheiro: "It's important to let clear that once the Plasma Components http://codecereal.blogspot.com/2011/05/plasma-components.html is ready, the QWidgetProxy solution will be deprecated. These components must follow a common API: http://bugreports.qt.nokia.com/browse/QTCOMPONENTS-200. As I explain in the post, many of these items already can be used, and I'm planning to integrate the done components in master branch in a few weeks."
(This post has some color coded sections, I am not sure that they will render properly on the planet, so if you feel you the color coding would help and you can't see it you may have to come to the blog itself.)
I. Setting Up
First thing is first, we need to setup the directory where we will be creating the widget.
- Create a directory with the name of the widget we will call ours in this example "plasma-qml"
- Create a text file inside this directory called metadata.desktop
- Create a directory inside the plasma-qml directory called "contents"
- Create a directory inside "contents" called "ui
- Create a text file inside "ui" called "main.qml"
Now we've set up the basic file structure for the widget. You'll notice there are only two editable items in what we've created, the .desktop file and the .qml file. The .desktop file will contain basic information about the plasma widget. The .qml file is where we will put the actual code for the widget. More complex plasma widgets will likely have more files in them.
II. metadata.desktop
Set the contents of the metadata.desktop file as follows.
[Desktop Entry]The first block deals with the name, description, and icon of the plasmoid. This is important for what users will see when they are trying to add your plasmoid.
Name=Plasma-QML
Comment=A test widget for Plasma using QML
Icon=chronometer
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-DefaultSize=200,100
X-KDE-PluginInfo-Author=Ahmed Ghonim
X-KDE-PluginInfo-Email=zrchrn@gmail.com
X-KDE-PluginInfo-Website=zrchrn.blogspot.com
X-KDE-PluginInfo-Category=Examples
X-KDE-PluginInfo-Name=org.kde.Plasma-qml
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-ServiceTypes=Plasma/Applet
Type=Service
The second block deals with what type of widget it is, where the main script is, how big the default widget size should be. If it was written in python it would say "X-Plasma-API=python"
The remaining blocks are mostly self explanatory please refer to techbase.kde.org for more information.
III. main.qml
Now to the meat and potates of the whole thing. What you all have been waiting for, the actual code that does something!
import Qt 4.7
import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
Item {The main differences between this and the QML examples you read about are:
id: 'item'
PlasmaWidgets.PushButton {
id:btn1
anchors { left: parent.left
bottom: parent.bottom
top: parent.top
}
text: "This is a Button!"
onClicked: {print("hello Konsole") ; lbl.text= " hello label"}
}
PlasmaWidgets.Label {
id: lbl
anchors { right: parent.right
bottom: parent.bottom
top: parent.top
left: btn1.right
}
text: " This is a Label!"
}
}
1. import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
this line imports Plasma's graphicswidgets such as PushButtons and Labels so that we can use them in our widget.
2. PlasmaWidgets.PushButton (also PlasmaWidgets.Label) these aren't QML widgets so we must have the import line listed above to use these.
Please feel free to ask questions in the comments section about the rest of this code I feel that would be easier than attempting to explain it which would probably be better done in a QML specific tutorial and most of which has been adequately done in the linked QML tutorial. IV. Testing
Now lets test this! Using a console go into the "plasma-qml" directory and enter the following command: plasmoidviewer
This should give you a preview of your plasmoid. If there is an error it will display that instead, read the error and find the offending code and fix it.
V. Installing
To install this we would go to the console. Inside the "plasma-qml" directory enter the following command: plasmapkg -i ./
Next run kbuildsycoca4 by entering the command in a console (I'm not sure if this always necessary).
Now you can add the Plasma-Qml widget like you would any other! Congratulations you have created and installed your first Plasma widget!
As an exercise try making a calculator widget.
IV. References
I used the following tutorials and this one is based on them. Please use them for more information. In general techbase.kde.org is your main resource for kde development.
Techbase Plamsa/QML
Techbase Plasma/Javascript
For more on QML examples
Update:
From Daker Fernandes Pinheiro: "It's important to let clear that once the Plasma Components http://codecereal.blogspot.com/2011/05/plasma-components.html is ready, the QWidgetProxy solution will be deprecated. These components must follow a common API: http://bugreports.qt.nokia.com/browse/QTCOMPONENTS-200. As I explain in the post, many of these items already can be used, and I'm planning to integrate the done components in master branch in a few weeks."
Tuesday, May 24, 2011
Fedora 15
Fedora 15 is out! I highly recommend the KDE spin for those who like a simple, unbloated KDE based OS. http://spins.fedoraproject.org/kde/
Wednesday, May 11, 2011
I need a new distro version 2
Recently I've been surveying a lot of KDE distros. I tried a lot of live cds and looked at a lot of videos and screenshots. Things have changed a little bit since I last searched for a distro. People have started modifying KDE (KDESC?) a bit more from the defaults but not by much certainly nothing that compares to how much Gnome2/Kde3 were/are customized. In any case I eventually decided I had to settle on something. So I went to my s.o.p for distro selection. Make a list and use each distro long enough to decide if it was something I could use with minimal annoyance. Here are my findings so far.
OpenSuse:
I received a great many suggestions for OpenSuse and Arch Linux (and Chakra). I tried OpenSuse 11.4/Tumbleweed. I had many issues with OpenSuse 11.4 unfortunatly. I thought perhaps switching to Tumbleweed would fix them but no cigar. The one thing that sticks in my mind is that my ability to click would randomly stop (yes that is click on buttons). I could use keyboard shortcuts and buttons etc. would work then. Very odd, especially in light of OpenSuse 11.4 getting so much praise which I'm sure is well deserved. There were a lot of great things that I respect about OpenSuse and I certainly respect anyone's decision to use it. However I moved on.
My next distro was going to be Arch. I have a great many good memories of my time on Arch. Almost every thing I learned about Linux I learned using Arch. However I felt the time to set everything up and take care of all the little kinks might be too much so I decided to try Fedora ahead of Arch.
Fedora is my "alma matter" the first distro I ever installed, and in my opinion currently the best gnome distribution out there and given current my experience, I might even say it has the best KDE spin I've tried so far. It's not so much that it does anything special with KDE, it provides basic vanilla kde (though Fedora 15 has an awesome ksplash!). Perhaps that is the beauty in it, nice and simple (they don't even split the kde packages). So far no problems I was able to get to work with minimal setup time.
My reasons for leaving Kubuntu were initially based on the fact that ubuntu had managed to introduce a bug in natty that led to my laptop overheating. This issue managed to resolve itself soon after my decision to switch and the latest Kubuntu release is actually pretty good. However I decided to take the opportunity to try something new.
So it is that I'm currently sticking with Fedora and so far I am quite pleased. If that changes then I still have Arch, PCLinuxOS and Mageia.
OpenSuse:
I received a great many suggestions for OpenSuse and Arch Linux (and Chakra). I tried OpenSuse 11.4/Tumbleweed. I had many issues with OpenSuse 11.4 unfortunatly. I thought perhaps switching to Tumbleweed would fix them but no cigar. The one thing that sticks in my mind is that my ability to click would randomly stop (yes that is click on buttons). I could use keyboard shortcuts and buttons etc. would work then. Very odd, especially in light of OpenSuse 11.4 getting so much praise which I'm sure is well deserved. There were a lot of great things that I respect about OpenSuse and I certainly respect anyone's decision to use it. However I moved on.
My next distro was going to be Arch. I have a great many good memories of my time on Arch. Almost every thing I learned about Linux I learned using Arch. However I felt the time to set everything up and take care of all the little kinks might be too much so I decided to try Fedora ahead of Arch.
Fedora is my "alma matter" the first distro I ever installed, and in my opinion currently the best gnome distribution out there and given current my experience, I might even say it has the best KDE spin I've tried so far. It's not so much that it does anything special with KDE, it provides basic vanilla kde (though Fedora 15 has an awesome ksplash!). Perhaps that is the beauty in it, nice and simple (they don't even split the kde packages). So far no problems I was able to get to work with minimal setup time.
My reasons for leaving Kubuntu were initially based on the fact that ubuntu had managed to introduce a bug in natty that led to my laptop overheating. This issue managed to resolve itself soon after my decision to switch and the latest Kubuntu release is actually pretty good. However I decided to take the opportunity to try something new.
So it is that I'm currently sticking with Fedora and so far I am quite pleased. If that changes then I still have Arch, PCLinuxOS and Mageia.
Monday, May 2, 2011
KDE: Unity Setup
First some screens:
You are looking at a picture (within a picture) both showing my crude 10 minute implementation of Ubuntu's Unity layout by customizing plasma. There was 0 code involved here on my part. It get's basically similar functionality to unity (not everything obviously) and it has both a composited mode and a non-composited mode that you can switch seamlessly between as an added advantage. I think the Ubuntu team should have started with kde technology I feel it would have made their lives much easier and this is a platform that is powerful and would have saved a lot of effort.
How to-ish:
Basically you add the Window Menu bar widget to a panel. Then you move the panel to the top. You add a second panel to the left with a task bar widget in it. Tweak the size and make it autohide. Also, notice that the Title Bar disappeared in the full screen window. Well you can do that with any window manually but with a little handy work, you can actually have kwin hide the title bar when you maximize the window. (This is one of the areas that would require work to reach unity's level of functionality though as no window controls go into the panel.
- kate .kde/share/config/kwinrc
- add: BorderlessMaximizedWindows=true
Sunday, April 17, 2011
I need a new distro
At long last it is time to part with my Ubuntu/Kubuntu setup. As a result I am taking suggestions for a new distro.
My needs are:
-Binary Package management (no gentoo :( )
-It must be laptop friendly.
-It must not hate FGLRX
-I would like a vast package selection, again I'm not a fan of compiling everything from source.
+bonus for distros that are not too bulky and are very innovative.
Please also add some information on what makes that distro unique. I'm really looking for *stability* and performance, without the stagnation. I've considered debian stable but I don't know if kde 4.6 would be making it's way into back-ports (I'm really not familiar with debian processes). I'm not too optimistic about that as debian seems to be content with kde 4.4 in it's "unstable" repos.
My needs are:
-Binary Package management (no gentoo :( )
-It must be laptop friendly.
-It must not hate FGLRX
-I would like a vast package selection, again I'm not a fan of compiling everything from source.
+bonus for distros that are not too bulky and are very innovative.
Please also add some information on what makes that distro unique. I'm really looking for *stability* and performance, without the stagnation. I've considered debian stable but I don't know if kde 4.6 would be making it's way into back-ports (I'm really not familiar with debian processes). I'm not too optimistic about that as debian seems to be content with kde 4.4 in it's "unstable" repos.
Wednesday, April 6, 2011
Congratulations to the GNOME
Congratulations to the GNOME team for launching GNOME 3 today. I know it's been a long time comming for them. I'm sure this is just a first step for them on a long and hopefully successful journey. Once I try it I will try to post a detailed analysis of it (Much can be learned about KDE by looking at it's alternatives!) but today is for congratulations to a fellow Open Source project!
You can learn more about GNOME 3 here: http://www.gnome.org/gnome-3/
You can test it using the live Fedora CD here (or OpenSuse!) : http://www.gnome.org/getting-gnome/
Sadly, last I checked you cannot test GNOME 3 in virtual box.
For those of you who have tried it, lemme know what you think. What did you like, what did you hate?
You can learn more about GNOME 3 here: http://www.gnome.org/gnome-3/
You can test it using the live Fedora CD here (or OpenSuse!) : http://www.gnome.org/getting-gnome/
Sadly, last I checked you cannot test GNOME 3 in virtual box.
For those of you who have tried it, lemme know what you think. What did you like, what did you hate?
Subscribe to:
Posts (Atom)


