lunedì 26 settembre 2011

Translating C++/Qml applications

I have spent a bit of time to understand how to translate qml applications since examples on the web are a different between each others.
Just a reminder, this is for compiled sofware using C++ and QDeclarativeView; for QML files loaded with QMLViewer there is no need since it's already set (and you just need to put qm files in a subdirectory).

Any translatable string in qml must be wrapped inside qsTr(), like this:

Than, assuming you have put all qml files in the same directory, you have to run lupdate to generate the ts file:


Now you have a ts file to open with QtLinguist. After you are done release it and put it in the translations subdir. To make the application locale-aware, we need to load the translation automatically at runtime. If we're using last QtSdk than we can implement a public function in the QmlApplicationViewer class, otherwise we can simply implement it in the main.cpp. This function must be called before the QDeclarativeView::showFullScreen() and QDeclarativeView::setSource() are called.


void QmlApplicationViewer::loadTranslator()
{
    QString locale = QLocale::system().name();
    QTranslator* translator = new QTranslator;
    qDebug()<<"Translating: "<<translator->load(QString("/opt/myproject/translations/myproject_") + locale + QString(".qm"));
    qApp->installTranslator(translator);
}

In this way the application will look for an available translation for the current set locale, and will load it if founf. Otherwise application will keep staying in source language. Coded in this way, to add a new translation is really simple: just add another qm file in the translations subdir.
This Subdir does not have to stay in the file system, it can be put in the resource file of the application.

sabato 10 settembre 2011

Internet Radio Player for Harmattan



Internet Radio Player is a software written in C++/Qt-QML to listen and manage streaming radios. Stations are saved in a sqlite3 database which gets created when application is run for the first time. Location of the database is /home/user/.config/internetradioplayer/stations.db and is kept when disintalling the application.


Features: 
  • 10band equalizer with several preconfigured presets.
  • Automatically add new stations into database when app is updated.
  • Can filter by station name, genre or country. Only one filter at time.
  • Shows station metadata (Artist, Title, StationName, Bitrare, Genre)
  • Favourites management.
  • Cronology Logging inside app and in a text file in Documents.
  • Current stations included in the database: 196
  • Has a savescreen window available for power saving mode.
  • Support for A2DP Bluetooth Control.
  • Uses Nokia Push Notifications to update stations.
  • Can show current track in standby screen.
  • DBus interface available for remote control.
  • Subscriber APIs available to retrieve status and current played track.


Available translations:
  • Italian.
  • German.

DBus interface allows the following operations: Toggle, Previous, Next. DBus shell commands to control from remote/ssh: 

  • dbus-send --type=method_call --dest=it.ggiovanni88.internetradioplayer /it/ggiovanni88/internetradioplayer it.ggiovanni88.internetradioplayer.toggle
  • dbus-send --type=method_call --dest=it.ggiovanni88.internetradioplayer /it/ggiovanni88/internetradioplayer it.ggiovanni88.internetradioplayer.prev
  • dbus-send --type=method_call --dest=it.ggiovanni88.internetradioplayer /it/ggiovanni88/internetradioplayer it.ggiovanni88.internetradioplayer.next


Available ContextKit properties for Subscriber APIs:

  • /InternetRadioPlayer/active
  • /InternetRadioPlayer/artist
  • /InternetRadioPlayer/title

















Changelog:
  • 0.0.4 (12-09-2011)
    • Initial release.
  • 0.0.5 (18-09-2011)
    • Added resource policy configuration file (volume can be set using volume keys within the app).
    • Stations can be  sorted by Name, Genre or Country.
  • 0.0.6 (23-09-2011)
    • Added new stations.
    • Added live filtering in the stations page.
    • Program automatically adds default stations upon software update.
    • Added italian translation.
  • 0.0.7 (04-10-2011)
    • Added splashscreen.
    • Changed view header.
    • Added favourites management.
    • Some minor improvements in the UI.
    • "Back" button no longer closes the application when in Main Page.
    • Added more stations. 
    • Implemented 10bands equalizer.
    • Added "placeholder" label in cronology page and favourites page: it will be shown when there is no entries.
  • 0.0.8 (23-10-2011)
    • Improved Main Page UI.
    • Menus get closed when changing page.
    • Added support for stations sending album art as metadata (Like RadioParadise.com).
    • Multimedia controls refear to last used list: as default they refear to all stations list, but when playing a station from favourite list they refear to the last ones.
    • Selecting a station will play a vibration feedback and will bring to main page.
    • Equalizer is disabled by default when running app for the first time.
    • Added a validator not to allow user to include char ' in station fields.
    • Added options to show status bar in portrait/landscape
  • 1.0.1 (04-11-2011)
    • Fixed some utf-8 encoding.
    • Added more stations.
    • Added resource policy support.
    • Player works in silent profile.
    • Volume can be set when application is in background or device is locked, when playing.
    • Playback resumes after interruptions (calls, messages etc).
  • 1.0.2 (23-11-2011)
    • It's now possible to create menu shortcuts within the application. Tap and hold on a station in Stations Page and pick "Create menu shortcut" or "Remove menu shortcut". Shortcuts open the application and directly play the selected stream.
    • Added option to play last heard station at application startup.
    • Back button in Main Page has a "disabled" look.
    • Removed lyrics support.
    • Added an info banner when player encountered an error.
  • 1.0.3 (12-01-2012)
    • UI Layout redesigned.
    • Improved the name filtering.
    • Added genre and country filtering.
    • Fixed a bug with TextField.
    • Removed Light theme, StatusBar visibility option and Landscape Mode.
  • 1.0.4 (14-01-2012)
    • Added a savescreen window.
  • 1.0.5 (14-01-2012)
    • Implemented A2DP bluetooth control.
  • 1.0.7 (27-03-2012)
    • Added Nokia Push Notifications support.
  • 1.2.1 (20-04-2012)
    • Added more stations.
    • Sevaral improvements to UI.
  • 1.3.0 (26-06-2012)
    • Added more stations.
    • New feature: showing current song on standby screen.
  • 1.4.0 (12-08-2012)
    • Added more stations.
    • Added German and Italian translations.
    • Fixed support for Nokia Push Notifications and standby screen plugin for PR1.3 devices.
    • Added DBus interface support (you can control Internet Radio Player from ssh with dbus commands).
    • Added Subscriber APIs support (information about player status and current played track can be retrieved from 3rd part softwares).
  • 1.4.1 (29-08-2012)
    • Added more stations.
    • Some UI minor changes.
    • No more possible to share already included default stations.
    • Added theme colour for PR1.3.

sabato 23 luglio 2011

Packed Media Widget 0.0.1 for N900

I have coded an homescreen widget to control Multimedia player, SomePlayer and InternetRadioPlayer, all at once.




It's made of 8buttons, in a 2x4 grid. The ones on the right are the control ones, and the ones on the left, hidden, are used to change the player to affect or to start it.

Starting from the bottom, the context buttons are: Multimedia, SomePlayer, InternetRadioPlayer and "start".
To use the widget, first a context button must be pressed since  at widget startup there is no context chosen.
"Start" button behaves differently based on the chosen context:

  • For Multimedia, it "plays" the song. It's a play, not a resume, so the song will be restarted.
  • For Someplayer, it checks if the player is running, and it does it in case it's not.
  • For InternetRadioPlayer, it starts the player if not running, or it shows it if hidden.
Widget is highly customizabled, from sizes to colours.




venerdì 15 luglio 2011

InternetRadioPlayer version 1.0.3

I have released version 1.0.3 of InternetRadioPlayer.
It can be hidden instead of closed to keep playing radios and can save a list of favourites stations.

sabato 11 giugno 2011

InternetRadioPlayer for N900

Internet Radio Player is a stand-alone player for streaming radios. It includes an sqlite database to store your stations, which includes more than 80stations as default. Stations can be filtered and/or sorted by name, country and genre. Metadata of streamed stations are shown and a log of played tracks is kept within the cronology and a text log in documents. This program supports a2dp bluetooth profile, so you can manage the playback with your bluetooth headset. When played track changes, system-wide notification can be played, depending on user choice. Player can be set to hide itself instead of closing, to keep hearing the music in background: to make the program to show, just click on the icon in menu; this behavior can be set in settings window. D-bus implementation is set for playback controls.
Program is free and it includes advertisement powered by Inner-Active.








Changelog:

  • 0.0.1
    • Initial Release
  • 1.0.3
    • Added ability to get favourite stations. Press ctrl+a to add the highlighted station into favourite list, or ctrl+d to delete it from list.
    • Added option to hide player instead of closing, it's enabled by default.
    • Lists can be sorted by name, genre and country, aside being able to be filtered aswell.
    • Added support to dbus, only one method by now to get window visible when hidden.
  • 1.1.2 (24-09-11)
    • Added more stations
    • Fixed minor bugs

lunedì 6 giugno 2011

PSAutolock 0.0.4 version

An update for PSAutolock, added a dependency and solved the root access someone encountered.

venerdì 27 maggio 2011