<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dragly &#187; Programming</title>
	<atom:link href="http://dragly.org/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://dragly.org</link>
	<description>It was about time I started writing my own tutorials to share some of the knowledge I&#039;ve picked up from around.</description>
	<lastBuildDate>Wed, 25 Jan 2012 18:57:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Nanoparticles available for Android and Mac OS X</title>
		<link>http://dragly.org/2012/01/18/nanoparticles-available-for-android-and-mac-os-x/</link>
		<comments>http://dragly.org/2012/01/18/nanoparticles-available-for-android-and-mac-os-x/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 06:58:40 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=618</guid>
		<description><![CDATA[As mentioned in the post about Nanoparticles for Android being just around the corner, I have been able to port Nanoparticles by using the Qt port for Android enabled by the Necessitas project. That&#8217;s why you can download Nanoparticles from &#8230; <a href="http://dragly.org/2012/01/18/nanoparticles-available-for-android-and-mac-os-x/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://dragly.org/wp-content/uploads/2011/05/Screenshot-1.png" rel="lightbox[618]"><img class="alignright size-medium wp-image-501" title="Screenshot-1" src="http://dragly.org/wp-content/uploads/2011/05/Screenshot-1-300x212.png" alt="" width="300" height="212" /></a><br />
As mentioned in the post about Nanoparticles for Android <a title="Nanoparticles for Android is just around the corner" href="http://dragly.org/2012/01/07/nanoparticles-for-android-is-just-around-the-corner/">being just around the corner</a>, I have been able to port Nanoparticles by using the Qt port for Android enabled by the <a href="http://sourceforge.net/p/necessitas/home/">Necessitas</a> project.</p>
<p>That&#8217;s why you can download Nanoparticles from Android market right now:</p>
<p><a href="https://market.android.com/details?id=org.dragly.nanoparticles">Download Nanoparticles from Android Market</a></p>
<p>In addition, I have been working on a Mac OS X port. This is still somewhat in an early stage, but should work on most machines. You can <a href="http://dragly.org/source/nanoparticles/download/">download the Mac OS X port for free here</a>.</p>
<p>Both these version include the new party mode with new particles and new game rules. This should give you many more hours of fun particle-based gameplay.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2012/01/18/nanoparticles-available-for-android-and-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploy Qt applications for Mac OS X</title>
		<link>http://dragly.org/2012/01/13/deploy-qt-applications-for-mac-os-x/</link>
		<comments>http://dragly.org/2012/01/13/deploy-qt-applications-for-mac-os-x/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 11:55:08 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[dmg]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[qmake]]></category>
		<category><![CDATA[qt]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=606</guid>
		<description><![CDATA[This turned out to be really simple. I was trying to create a Mac OS X version of my game, Nanoparticles, and was having trouble with some flicker when running a QGraphicsView with OpenGL. The solution turned out to simply &#8230; <a href="http://dragly.org/2012/01/13/deploy-qt-applications-for-mac-os-x/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This turned out to be really simple. I was trying to create a Mac OS X version of my game, Nanoparticles, and was having trouble with some flicker when running a QGraphicsView with OpenGL. The solution turned out to simply be to <a href="https://bugreports.qt.nokia.com/browse/QTBUG-23619">disable some style sheet settings</a> that I didn&#8217;t need.</p>
<p>After this I wanted to create a nice .dmg file for easy deployment on Mac OS X. Thankfully, this process is not hard either. I found this through the <a href="http://developer.qt.nokia.com/doc/qt-4.8/deployment-mac.html">Qt Documentation</a>, but it is actually simpler than it seems thanks to the macdeployqt tool. This is mentioned on the page, but I decided to give a more thorough walk through on how to use the tool here:</p>
<ol>
<li>Build your application</li>
<li>In the build directory, run
<pre class="brush:shell">macdeployqt yourappname.app -dmg</pre>
<p>macdeployqt is found in the ~/Library/QtSDK/Desktop/Qt/474/gcc/bin folder (if that is where you installed Qt)</li>
<li>You should now have a nice yourappname.dmg file in the build directory. Open this up and check that your application runs from there.</li>
<li>If everything is working fine, you can do some prettifying of your .dmg file by opening it up using the Disk Utility and converting it to a Read/Write disk image.</li>
<li>Open your Read/Write disk image and create a shortcut to your Applications folder. This could either be done by dragging the Applications folder while holding the command key or by creating a symbolic link in terminal:
<pre class="brush:shell">ln -s /Applications ./Applications</pre>
</li>
<li>Edit the icon size, background image, etc. by clicking Command + J to open the View Options. Also, use View -&gt; Hide Toolbar and Hide Sidebar to hide the excessive toolbars from the disk image.</li>
<li>Close the image and use Disk Utility to convert it back to a compressed disk image.</li>
<li>Distribute your .dmg file.</li>
</ol>
<p>If you need more details about the process and how deployment is performed, have a look in the <a href="http://developer.qt.nokia.com/doc/qt-4.8/deployment-mac.html">Qt Docs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2012/01/13/deploy-qt-applications-for-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nanoparticles for Android is just around the corner</title>
		<link>http://dragly.org/2012/01/07/nanoparticles-for-android-is-just-around-the-corner/</link>
		<comments>http://dragly.org/2012/01/07/nanoparticles-for-android-is-just-around-the-corner/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 02:41:30 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=593</guid>
		<description><![CDATA[Thanks to the great work of Bogdan Vatra and the Qt Developers working on Lighthouse, I have finally been able to create a running version of Nanoparticles on Android. Their efforts have led to the Necessitas project, a very user &#8230; <a href="http://dragly.org/2012/01/07/nanoparticles-for-android-is-just-around-the-corner/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Thanks to the great work of <a href="http://www.behindkde.org/node/925">Bogdan Vatra</a> and the <a href="http://qt.nokia.com">Qt Developers working on Lighthouse</a>, I have finally been able to create a running version of <a title="Nanoparticles" href="http://dragly.org/source/nanoparticles/">Nanoparticles</a> on Android. Their efforts have led to the <a href="http://sourceforge.net/p/necessitas/home/necessitas/">Necessitas project</a>, a very user friendly and working port of Qt to Android.</p>
<p>I&#8217;ve only had a HTC Magic with no OpenGL capabilities available for testing, but still the game is running pretty good. This is giving me perhaps too high hopes about how it will perform on a stronger device, such as a Samsung Galaxy SII. I&#8217;ll try to get hold of a device like that soon.</p>
<p>In addition I&#8217;ve moved almost all the UI code in Nanoparticles over to QML. This finally makes the menus and game logic separated and also has made it a lot easier to add some transitions and user feedback to the UI elements.</p>
<p>I&#8217;ve only got a early alpha version ready at the moment, but I&#8217;ll probably need a lot of help testing how the game runs on different devices and setups. I will post back here as soon as I&#8217;ve got something for you to play with. Maybe I&#8217;ll even push it to Android Market in a not so distant future for early testing.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2012/01/07/nanoparticles-for-android-is-just-around-the-corner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RewriteRule in .htaccess not working for cURL</title>
		<link>http://dragly.org/2011/11/01/rewriterule-in-htaccess-not-working-for-curl/</link>
		<comments>http://dragly.org/2011/11/01/rewriterule-in-htaccess-not-working-for-curl/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 22:43:58 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=563</guid>
		<description><![CDATA[For some strange reason I have experienced on one server that the RewriteRule in .htaccess is not working for cURL via the command line. The fix has been to add a User-Agent line to the header of the cURL command, &#8230; <a href="http://dragly.org/2011/11/01/rewriterule-in-htaccess-not-working-for-curl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For some strange reason I have experienced on one server that the RewriteRule in .htaccess is not working for cURL via the command line. The fix has been to add a User-Agent line to the header of the cURL command, like this:</p>
<pre class="brush:shell">curl --head --header "User-Agent: blablabla" http://dragly.org/</pre>
<p>I have no idea why this happens, but I was pointed to this solution in a forum which I forgot to bookmark. I hope this might help you out if you should run into the same problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2011/11/01/rewriterule-in-htaccess-not-working-for-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nanoparticles available for Nokia N9</title>
		<link>http://dragly.org/2011/10/11/nanoparticles-available-for-nokia-n9/</link>
		<comments>http://dragly.org/2011/10/11/nanoparticles-available-for-nokia-n9/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 11:07:23 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[available]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[n9]]></category>
		<category><![CDATA[nanoparticles]]></category>
		<category><![CDATA[nokia]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=555</guid>
		<description><![CDATA[Finally the N9 is here. And so is Nanoparticles for the Nokia N9. You can over to Nokia Store to get a copy right now: Download Nanoparticles You can read more about Nanoparticles and download it for other platforms on &#8230; <a href="http://dragly.org/2011/10/11/nanoparticles-available-for-nokia-n9/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Finally the N9 is here. And so is <a href="http://dragly.org/source/nanoparticles/">Nanoparticles</a> for the Nokia N9. You can over to Nokia Store to get a copy right now:</p>
<p><a href="http://store.ovi.com/content/128233">Download Nanoparticles</a></p>
<p>You can read more about Nanoparticles and download it for other platforms on <a href="http://dragly.org/source/nanoparticles/">this page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2011/10/11/nanoparticles-available-for-nokia-n9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get things done with todo.txt</title>
		<link>http://dragly.org/2011/10/07/how-to-get-things-done-with-todo-txt/</link>
		<comments>http://dragly.org/2011/10/07/how-to-get-things-done-with-todo-txt/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 16:59:47 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[Efficiency]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=534</guid>
		<description><![CDATA[The simple answer to how you get things done is to actually do them. However, to do things in an organized manner is more easily said than done. Why? Because it is way too easy to drift away with less &#8230; <a href="http://dragly.org/2011/10/07/how-to-get-things-done-with-todo-txt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The simple answer to how you get things done is to actually do them. However, to do things in an organized manner is more easily said than done. Why? Because it is way too easy to drift away with less important stuff when you&#8217;re supposed to do anything you have to.</p>
<p>What solved my problem: <a href="http://todotxt.com">Todo.txt</a>. Why?</p>
<p>The solution for me has always been to have a todo list that I can look up whenever I&#8217;m wondering about what to do next. It is way too hard to stay focused on a task if I have to remind myself about what&#8217;s next all the time. Leaving later tasks in an organized list makes it possible for me to avoid these constant reminders and let me focus peacefully on one task at a time, knowing that I won&#8217;t forget the next important task.</p>
<p>However, keeping such a list can introduce another problem to solve: How can I store the list in an easily accessible place that makes it easy to review it, cross things off it, list only one project at a time and maybe only the top priorities?</p>
<p>The best option for availability is to have the list on a whiteboard next to my computer, but that reveals several problems. The whiteboard will be way too small no matter how large a whiteboard I buy, and it will not be easily synchronized. In other words, I will most likely need something that runs on my computer.</p>
<p>Several applications are available for this purpose, but I have yet to find one that works well on all my systems with synchronization. I&#8217;ve tried to set up manual synchronization of folders using services like Dropbox, Ubuntu One and SpiderOak, but after Getting Things Gnome on my laptop wrote over all my changes from my desktop and Tasque failed on me while syncing via Remember The Milk, I decided to go back to the good old &#8220;todo.txt&#8221; file in a folder on my computer.</p>
<p>This works fine, but it lacks some options to sort tasks after priority or project. However, there is a beautiful script application that has come to the rescue for me. Visit <a href="http://todotxt.com">todo.txt</a> to see what I&#8217;m talking about.</p>
<p>It&#8217;s basically a simple script that lets you keep your todo-list in a file for compatibility and availability between systems, while giving you the options to view, add and delete tasks via the command line.</p>
<p>This solves all problems with syncing and availability. Now I can leave the syncing to a system such as Ubuntu One without worrying about compatibility between my phone and my computer, and even be able to view, add and delete tasks without ever leaving the terminal.</p>
<p>And should I ever be on a system without the todo.txt script, I can always open the file in vim or view it with cat.</p>
<h3>Task lists from code comments</h3>
<p>What about task lists from code comments? I often leave comments in LaTeX-files, code files and Python scripts like this:</p>
<pre class="brush:cpp">// TODO: Make a cup of coffee</pre>
<p>Well, as I said, I&#8217;ve often got a terminal open when working on anything, so the best solution for me would be never to leave the terminal:</p>
<pre class="brush:shell">cat &lt;&lt;anyfileyoulike&gt;&gt; | grep TODO</pre>
<p>This simply lists all the TODO-comments in my code or text file, so that I can easily review the ones that are not yet done. Simple as that.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2011/10/07/how-to-get-things-done-with-todo-txt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling locked screen event in Qt for Maemo</title>
		<link>http://dragly.org/2011/05/30/handling-locked-screen-event-in-qt-for-maemo/</link>
		<comments>http://dragly.org/2011/05/30/handling-locked-screen-event-in-qt-for-maemo/#comments</comments>
		<pubDate>Mon, 30 May 2011 11:07:28 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[N900]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[dbus]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[lock]]></category>
		<category><![CDATA[maemo]]></category>
		<category><![CDATA[pause]]></category>
		<category><![CDATA[qt]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[state]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=482</guid>
		<description><![CDATA[If you want to pause an application to save battery power when the screen is turned off, you can do this by listening for the locked screen event in Qt for Maemo. However, this is not made easily available through &#8230; <a href="http://dragly.org/2011/05/30/handling-locked-screen-event-in-qt-for-maemo/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you want to pause an application to save battery power when the screen is turned off, you can do this by listening for the locked screen event in Qt for Maemo. However, this is not made easily available through a wrapper function (that I know of), so in this case we&#8217;ll need to resort to listening for the right DBus call. (Thanks to Diph from Maemo.org for <a href="http://talk.maemo.org/showthread.php?p=791167">providing the recipe to make this possible</a>.)</p>
<p>First of all, you&#8217;ll need to enable dbus in your project (.pro) file:</p>
<pre class="brush:shell">maemo5 {
    CONFIG += qdbus
}</pre>
<p>Next up, in your .h file you should add the following to import the DBus headers:</p>
<pre class="brush:shell">#ifdef Q_WS_MAEMO_5
#include &lt;QtDBus/QtDBus&gt;
#endif</pre>
<p>And you&#8217;ll need to add a slot for the screen state change:</p>
<p><span id="more-482"></span></p>
<pre class="brush:cpp">class GameView : public QGraphicsView
{
    Q_OBJECT
public:
    explicit GameView();

public slots:
#ifdef Q_WS_MAEMO_5
    void screenChange(const QDBusMessage &amp;message);
#endif

...

}</pre>
<p>Then, in your .cpp file you&#8217;ll need to load the Maemo DBus definitions and create a connection. Do this outside any function to have it statically available.</p>
<pre class="brush:cpp">#ifdef Q_WS_MAEMO_5
#include &lt;mce/dbus-names.h&gt;
#include &lt;mce/mode-names.h&gt;

static QDBusConnection dBusConnection = QDBusConnection::systemBus();
#endif</pre>
<p>Next up, in the constructor of your class, we&#8217;ll set up the necessary DBus connection and interface:</p>
<pre class="brush:cpp">GameView::GameView()
{
#ifdef Q_WS_MAEMO_5
    dBusInterface = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH,
                                       MCE_REQUEST_IF, dBusConnection, this);

    dBusConnection.connect(MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
                           MCE_DISPLAY_SIG, this, SLOT(screenChange(const QDBusMessage &amp;)));
#endif
}</pre>
<p>And finally, we&#8217;ll need to fill the function screenChange with something useful. The example below is from my <a title="Nanoparticles" href="http://dragly.org/source/nanoparticles/">Nanoparticles game</a> and simply pauses the game whenever the screen is locked.</p>
<pre class="brush:cpp">#ifdef Q_WS_MAEMO_5
void GameView::screenChange(const QDBusMessage &amp;message)
{
    QString state = message.arguments().at(0).toString();
    if (!state.isEmpty()) {
        if (state == MCE_DISPLAY_OFF_STRING)
            gameScene.pauseGame();
    }
}
#endif</pre>
<p>If you need to check the screen state during startup, have a look at the extra functions <a href="http://talk.maemo.org/showthread.php?p=791167">that Diph mentions</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2011/05/30/handling-locked-screen-event-in-qt-for-maemo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling application minimization in Maemo with Qt</title>
		<link>http://dragly.org/2011/05/26/handling-application-minimization-in-maemo-with-qt/</link>
		<comments>http://dragly.org/2011/05/26/handling-application-minimization-in-maemo-with-qt/#comments</comments>
		<pubDate>Thu, 26 May 2011 11:47:41 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[N900]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[maemo]]></category>
		<category><![CDATA[maemo5]]></category>
		<category><![CDATA[minimize]]></category>
		<category><![CDATA[qt]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=476</guid>
		<description><![CDATA[When you are developing with Qt on Maemo you might want to minimize or detect minimization of your application to the dashboard. Qt lacks clean functions for these use cases, but thankfully it&#8217;s still very easy to accomplish them. Minimizing &#8230; <a href="http://dragly.org/2011/05/26/handling-application-minimization-in-maemo-with-qt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When you are developing with Qt on Maemo you might want to minimize or detect minimization of your application to the dashboard. Qt lacks clean functions for these use cases, but thankfully it&#8217;s still very easy to accomplish them.</p>
<h3>Minimizing the application</h3>
<p>First of all, to minimize your application you&#8217;ll need to add the following CONFIG line to your project file (the .pro file):</p>
<pre class="brush:shell">maemo5 {
    CONFIG += qdbus
}</pre>
<p>Then, in your .cpp or .h file, you&#8217;ll need to include the QtDBus headers:</p>
<pre class="brush:cpp">#ifdef Q_WS_MAEMO_5
#include &lt;QtDBus/QtDBus&gt;
#endif</pre>
<p>You may of course skip the #ifdef statements if you&#8217;d like DBus for other systems as well, but here I&#8217;d like to make this exception only for Maemo. Now, anywhere in your application you may add the following lines to minimize to Maemo&#8217;s dashboard:</p>
<p><span id="more-476"></span></p>
<pre class="brush:cpp">QDBusConnection connection = QDBusConnection::sessionBus();
QDBusMessage message = QDBusMessage::createSignal("/","com.nokia.hildon_desktop","exit_app_view");
connection.send(message);</pre>
<p>This could for example be placed inside a signal that is emitted when the users pushes a dashboard button.</p>
<h3>Detecting minimization</h3>
<p>If you&#8217;d like to detect if the user pressed CTRL + Backspace or any other button to minimize the application, you may do so by adding a changeEvent function to your top-most window. Inside you check the event-&gt;type() against QEvent::ActivationChange and test the isActiveWindow() at the same time. Here is an example from the Nanoparticles game:</p>
<pre class="brush:cpp">void GameView::changeEvent(QEvent *event) {
#ifdef Q_WS_MAEMO_5
    if(event-&gt;type()==QEvent::ActivationChange) {
        if(!isActiveWindow()) {
            gameScene.pauseGame();
        }
    }
#endif
}</pre>
<p>Whenever the game is minimized now, the game is automatically paused to avoid background rendering. The game uses OpenGL to render everything, so this saves the battery drastically.</p>
<p>Enjoy your minimized applications!</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2011/05/26/handling-application-minimization-in-maemo-with-qt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading local gems in cPanel shared host</title>
		<link>http://dragly.org/2011/04/25/loading-local-gems-in-cpanel-shared-host/</link>
		<comments>http://dragly.org/2011/04/25/loading-local-gems-in-cpanel-shared-host/#comments</comments>
		<pubDate>Sun, 24 Apr 2011 22:08:15 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[ProISP]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[redmine]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=447</guid>
		<description><![CDATA[I had some trouble today figuring out why my Redmine installation wouldn&#8217;t start running on my shared server. I received the following error in my log/mongrel.log file: ** Starting Rails with production environment... Missing the i18n 0.4.2 gem. Please `gem &#8230; <a href="http://dragly.org/2011/04/25/loading-local-gems-in-cpanel-shared-host/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had some trouble today figuring out why my Redmine installation wouldn&#8217;t start running on my shared server. I received the following error in my log/mongrel.log file:</p>
<pre class="brush:plain">** Starting Rails with production environment...
Missing the i18n 0.4.2 gem. Please `gem install -v=0.4.2 i18n`</pre>
<p>Now, I had finally gotten rid of this problem while using SSH by running</p>
<pre class="brush:shell">export GEM_PATH=/home/&lt;my username&gt;/ruby/gems</pre>
<p>in terminal (or adding it to .bashrc), resulting in successful rake commands and running the server with WEBrick. However, Mongrel seemed to have serious issues with loading the gems in my local files.</p>
<p>This should be solved by adding</p>
<pre class="brush:ruby">ENV['GEM_PATH']= "/home/&lt;my username&gt;/ruby/gems:/usr/lib/ruby/gems/1.8"</pre>
<p>to the environment.rb file, but it did not. Apparently this is because Mongrel loads rubygems by itself, ignoring any environment variables set after this. Therefore, the below fine hack by Rui Lopez found <a href="http://rubyforge.org/pipermail/mongrel-users/2007-February/002885.html">on this page</a>, became necessary:</p>
<pre class="brush:ruby">ENV['GEM_PATH']= "/home/&lt;my username&gt;/ruby/gems:/usr/lib/ruby/gems/1.8"
require 'rubygems'; Gem.clear_paths;
Gem.instance_variable_set(:@searcher, nil)</pre>
<p>As Rui puts it himself:</p>
<blockquote>
<pre>[This] clears the internal cache used by rubygems, and forces it to
re-read the GEM_PATH env. variable.</pre>
</blockquote>
<p>As he also points out, it might not be the cleanest hack, but it works. And that makes me happy.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2011/04/25/loading-local-gems-in-cpanel-shared-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trafikanten on Maemo</title>
		<link>http://dragly.org/2010/09/21/trafikanten-on-maemo/</link>
		<comments>http://dragly.org/2010/09/21/trafikanten-on-maemo/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 18:42:54 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[N900]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[maemo]]></category>
		<category><![CDATA[qt]]></category>

		<guid isPermaLink="false">http://dragly.org/?p=354</guid>
		<description><![CDATA[Update: The package was pushed to Extras testing on 2nd of October. It was delayed because Maemo&#8217;s package repository would not import the new package due to some trouble with the version numbering. There has been missing a native application &#8230; <a href="http://dragly.org/2010/09/21/trafikanten-on-maemo/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://dragly.org/wp-content/uploads/2010/09/Screenshot-20100921-202228.png" rel="lightbox[354]"><img class="size-medium wp-image-355 alignright" title="Screenshot-20100921-202228" src="http://dragly.org/wp-content/uploads/2010/09/Screenshot-20100921-202228-300x180.png" alt="" width="300" height="180" /></a><strong>Update:</strong> <span style="font-style: italic">The package was pushed to Extras testing on 2nd of October. It was delayed because Maemo&#8217;s package repository would not import the new package due to some trouble with the version numbering.</span></p>
<p>There has been missing a native application to access information from Trafikanten on the Nokia N900. Instead it has been necessary to use the mobile version of their websites or maybe even the full version. Even though this is a pretty quick and workable solution, there are several benefits of having a native application available. One that becomes very obvious is the use of GPS to find all nearest bus stops or train stations.</p>
<p>I decided to give it a try in June this year and started by releasing some early versions of what is now named &#8220;Journey Planner for Norway&#8221; (which is &#8220;Reiseplanlegger&#8221; in Norwegian). During the summer of 2010 I have been trying to improve the application over several iterations, and feel that it has now come to a point where it is usable and stable enough to get the infamous &#8220;Version 1.0&#8243; attached to it.</p>
<p>The application is now finding its way through to the Extras-devel catalogue for Maemo and will be pushed upwards through Extras-testing before it hopefully hits Extras within two or three weeks. In the meantime you might either be a bit careless and enable Extras-devel to use the bleeding edge 1.0 version or head over to <a href="http://maemo.org/downloads/product/Maemo5/trafikanten/">Maemo Downloads to fetch the beta</a> which will be automatically updated to 1.0 whenever it is ready.</p>
<p>Below you can check out some more screenshots of the application in action:</p>

<a href='http://dragly.org/2010/09/21/trafikanten-on-maemo/screenshot-20100921-202228/' title='Screenshot-20100921-202228'><img width="150" height="150" src="http://dragly.org/wp-content/uploads/2010/09/Screenshot-20100921-202228-150x150.png" class="attachment-thumbnail" alt="Screenshot-20100921-202228" title="Screenshot-20100921-202228" /></a>
<a href='http://dragly.org/2010/09/21/trafikanten-on-maemo/screenshot-20100921-202446/' title='Screenshot-20100921-202446'><img width="150" height="150" src="http://dragly.org/wp-content/uploads/2010/09/Screenshot-20100921-202446-150x150.png" class="attachment-thumbnail" alt="Screenshot-20100921-202446" title="Screenshot-20100921-202446" /></a>
<a href='http://dragly.org/2010/09/21/trafikanten-on-maemo/screenshot-20100921-202853-2/' title='Screenshot-20100921-202853'><img width="150" height="150" src="http://dragly.org/wp-content/uploads/2010/09/Screenshot-20100921-2028531-150x150.png" class="attachment-thumbnail" alt="Screenshot-20100921-202853" title="Screenshot-20100921-202853" /></a>
<a href='http://dragly.org/2010/09/21/trafikanten-on-maemo/screenshot-20100921-203030/' title='Screenshot-20100921-203030'><img width="150" height="150" src="http://dragly.org/wp-content/uploads/2010/09/Screenshot-20100921-203030-150x150.png" class="attachment-thumbnail" alt="Screenshot-20100921-203030" title="Screenshot-20100921-203030" /></a>
<a href='http://dragly.org/2010/09/21/trafikanten-on-maemo/screenshot-20100921-203038/' title='Screenshot-20100921-203038'><img width="150" height="150" src="http://dragly.org/wp-content/uploads/2010/09/Screenshot-20100921-203038-150x150.png" class="attachment-thumbnail" alt="Screenshot-20100921-203038" title="Screenshot-20100921-203038" /></a>
<a href='http://dragly.org/2010/09/21/trafikanten-on-maemo/screenshot-20100921-203304/' title='Screenshot-20100921-203304'><img width="150" height="150" src="http://dragly.org/wp-content/uploads/2010/09/Screenshot-20100921-203304-150x150.png" class="attachment-thumbnail" alt="Screenshot-20100921-203304" title="Screenshot-20100921-203304" /></a>

<p>The application is developed in C++ using <a href="http://qt.nokia.com">Qt</a> with the Qt Mobility libraries. It should not be too hard to port it to Symbian as well, so I will give that a shot in the future. Symbian users does however already have an option to use the Java application &#8220;<a href="http://tegelsrud.com/trafikantenjava/">Trafikanten Sanntid</a>&#8221; made by Håvard Tegelsrud.</p>
<p>And of course, you can <a href="http://github.com/dragly/trafikanten-maemo">check out the source code here</a>. The application is licensed with the GNU GPLv3 license.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2010/09/21/trafikanten-on-maemo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

