Reply
Thread Tools
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#1
Hi there,

I have a scenario like this:
- I've drawn a simple UI in Nokia QT Designer:


- I have a shell script wich does various file manipulations based on variables given

What I would like to do:
- convert that UI to native app which would launch my shell script with variables based on what's been chosen from drop down list's at the UI when hitting the "Apply changes" -button. In this case the command to be launched from the button would be:
/path/to/my/script/script.sh "Enable custom transitions" "Droid Sans" "Black"

I have zero knowledge on coding with anything else than PHP. I would highly appreciate if someone is intrested in helping me with the project

I think this could be done with Python(?) so I could later on easily edit the python "source" if I needed to add more options to the drop down lists?

Edit: and as bonus: this app should be launchable from N900's settings "application", not from program launcher menu.
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE

Last edited by d-iivil; 2010-07-16 at 08:09.
 

The Following User Says Thank You to d-iivil For This Useful Post:
Venemo's Avatar
Posts: 1,296 | Thanked: 1,773 times | Joined on Aug 2009 @ Budapest, Hungary
#2
Hello,

At the moment I can't write all the code for you, but I can give you some pointers about how to do it.
  • Install Nokia Qt SDK (1.0 final is the latest)
  • Install the newest Qt Creator snapshot from here:
    ftp://ftp.qt.nokia.com/qtcreator/snapshots/
    (The version in the SDK is quite crappy)
  • Launch the newly installed Qt Creator
  • Create a new Gui Application project
  • Set the Maemo 5 Qt 4.6 as build target
  • Add to it a class (or use the generated one) and copy-paste to its .ui file yours from the designer
  • If you wanna run your app on your device, install the "Mad Developer" package on it, set the USB driver to "usb_ether" (Etheret - USB networking), then plug it in your PC, select "PC Suite mode" (if usb_ether is selected, that will be used), and set up USB networking on your PC.
  • In Qt Creator, Tools/Options/Projects/Maemo device configurations -> set up a connection to your device.
    Type in its IP address, then the "developer" account, and type the password from the Mad Developer app's "developer password" button. Note that the password there is only valid until it is shown on the screen. If you connected with the password, you can generate and deploy an SSH key, and use that instead of the password.
  • Close the options dialog
  • Then, go to the "Projects" tab in the editor, and below the "Build steps", click on the arrow next to "Create Package", and check the "Skip packaging step" option
    - This will make it WAY faster to run your app.
  • Here is a tutorial about how to launch a process from a Qt app:
    http://wiki.forum.nokia.com/index.ph...Qt_for_Symbian
    (The tutorial has Symbian in its title, but it contains non-Symbian-specific code.)
  • For the shell scrips, you'll have to run "sh yourscript.sh" with QProcess
  • For generic C++ questions, you can search Google or ask on StackOverflow
  • If you want to make a .deb package, you can use Qt Creator's option to do so (but it is quite limited at the moment), or use MADDE and type "mad dpkg-buildpackage" into the command line (in your app's root folder)
  • There is a description somewhere in the Maemo Wiki about how to make it a Settings applet, but I couldn't find it now.

I know this was a very dense description, but I hope it will help!

Last edited by Venemo; 2010-07-16 at 08:39.
 

The Following 9 Users Say Thank You to Venemo For This Useful Post:
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#3
Originally Posted by Venemo View Post
Hello,

At the moment I can't write all the code for you, but I can give you some pointers about how to do it.
  • Install Nokia Qt SDK (1.0 final is the latest)
  • Install the newest Qt Creator snapshot from here:
    ftp://ftp.qt.nokia.com/qtcreator/snapshots/
    (The version in the SDK is quite crappy)
  • Launch the newly installed Qt Creator
  • Create a new Gui Application project
  • Set the Maemo 5 Qt 4.6 as build target
  • Add to it a class (or use the generated one) and copy-paste to its .ui file yours from the designer
  • If you wanna run your app on your device, install the "Mad Developer" package on it, set the USB driver to "usb_ether" (Etheret - USB networking), then plug it in your PC, select "PC Suite mode" (if usb_ether is selected, that will be used), and set up USB networking on your PC.
  • In Qt Creator, Tools/Options/Projects/Maemo device configurations
  • Then, go to the "Projects" tab in the editor, and below the "Build steps", click on the arrow next to "Create Package", and check the "Skip packaging step" option
    - This will make it WAY faster to run your app.
  • Here is a tutorial about how to launch a process from a Qt app:
    http://wiki.forum.nokia.com/index.ph...Qt_for_Symbian
    (The tutorial has Symbian in its title, but it contains non-Symbian-specific code.)
  • For the shell scrips, you'll have to run "sh yourscript.sh" with QProcess
  • For generic C++ questions, you can search Google or ask on StackOverflow
  • If you want to make a .deb package, you can use Qt Creator's option to do so (but it is quite limited at the moment), or use MADDE and type "mad dpkg-buildpackage" into the command line (in your app's root folder)
  • There is a description somewhere in the Maemo Wiki about how to make it a Settings applet, but I couldn't find it now.

I know this was a very dense description, but I hope it will help!
Thanks for these! At least now I know a bit more what to google for
Already got mad developer working with QT Creator.
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#4
Heh, well, got it running on the device.

Now the hardest part: how to make the buttons actually to do something :-P
Attached Images
  
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 

The Following User Says Thank You to d-iivil For This Useful Post:
Nathraiben's Avatar
Posts: 267 | Thanked: 408 times | Joined on May 2010 @ Austria
#5
Not sure whether I should post this, as right now I'm trying to blow the "embrace the future - develop with QT" - but coming from PHP, using Python and PyQt might indeed be the easier way to do it.

That would require to:
  • Download and install Eric (if on Linux - don't know what the Win-only bunch are using)
  • Err... well, that's pretty much it for preparations
  • Test-run your application by SSH-ing, use folder-sharing or simply copying your scripts to the device and simply run it with "python path/to/app.py" - Python doesn't need compiling.
  • For packaging, just follow the instructions on this wiki page and you're done.

Again, if you want to be future prove, go with C++ and Qt, but if you want to keep it easy (and maemo-only), Python and PyQt would do the trick without much hassle, especially when you're coming from a PHP background.
 

The Following User Says Thank You to Nathraiben For This Useful Post:
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#6
Originally Posted by Nathraiben View Post
Not sure whether I should post this, as right now I'm trying to blow the "embrace the future - develop with QT" - but coming from PHP, using Python and PyQt might indeed be the easier way to do it.

That would require to:
  • Download and install Eric (if on Linux - don't know what the Win-only bunch are using)
  • Err... well, that's pretty much it for preparations
  • Test-run your application by SSH-ing, use folder-sharing or simply copying your scripts to the device and simply run it with "python path/to/app.py" - Python doesn't need compiling.
  • For packaging, just follow the instructions on this wiki page and you're done.

Again, if you want to be future prove, go with C++ and Qt, but if you want to keep it easy (and maemo-only), Python and PyQt would do the trick without much hassle, especially when you're coming from a PHP background.
Yeah, Python would be easy to edit on the go and test new things because it does not need compiling. Including it to the deb-package would not be a problem also (I want to include that with my theme-package). Right now I'm just using that shell script and Zenity to display dialogs, but it's kind of... well.. not that user friendly since Zenity dialogs aren't hildonized completely etc.

Good thing seems to be that I can use the .ui -file with QT Creator and PyQT4.
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
Nathraiben's Avatar
Posts: 267 | Thanked: 408 times | Joined on May 2010 @ Austria
#7
Originally Posted by D-Iivil View Post
Heh, well, got it running on the device.

Now the hardest part: how to make the buttons actually to do something :-P
Okay, first the obligatory warning: I'm pretty new to Qt, so I might be spouting a lot of nonsense, but here's how I got it to work:

In the constructor of your window widget, connect the "clicked" event of your button:

Code:
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hello()));
Note:
"ui" is the... well, UI defined by "ui(new Ui::MyWindowName)" in the constructor
"pushButton" is the name of your button
"hello()" is the name of a slot created in the next step


In the header file of the window widget, add the definition for a new slot (inside the class definition) :

Code:
protected slots:
        void hello();

Back in the implementation file of your window widget, define a function for that slot:

Code:
void MainWindow::hello()
{
    //Do whatever should be done when pressing the button
}

Just don't call the spot hello - that was obviously taken from my inevitable first Hello World app.
 

The Following 2 Users Say Thank You to Nathraiben For This Useful Post:
Nathraiben's Avatar
Posts: 267 | Thanked: 408 times | Joined on May 2010 @ Austria
#8
Originally Posted by D-Iivil View Post
Good thing seems to be that I can use the .ui -file with QT Creator and PyQT4.
True, .ui files being usable with any of the Qt bindings is quite the blessing. And I was astonished how easy it is to work with them both in Eric (simply right-click and choose "Compile Form" to generate the .py file, then right-click and choose "Generate Dialog Code" to automatically generate everything you need for even-handling with a nice choose-your-events dialog) and in the QT SDK (no generating of event handlers, as far as I know, but at least fully automatic generation of the .cpp and .h upon saving the .ui file).
 
Posts: 353 | Thanked: 263 times | Joined on Dec 2009 @ Finland
#9
If you want to run your shell script in the button handler, you need to use function int QProcess::execute ( const QString & program, const QStringList & arguments ).

In above example from Nathraiben you would call it in function hello like this:
Code:
void MainWindow::hello()
{
    QStringList arguments;
    arguments << "Enable custom transitions" << "Droid Sans" << "Black";
    QProcess::execute("/path/to/my/script/script.sh", arguments);
}
__________________
My Maemo5 projects:
mSpede - Speed testing game | Them Bloody Ducks - 2D duck hunting game | Maetronome - A simple metronome app | CuteMPC - MPD client
 

The Following 2 Users Say Thank You to TNiga For This Useful Post:
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#10
Originally Posted by TNiga View Post
If you want to run your shell script in the button handler, you need to use function int QProcess::execute ( const QString & program, const QStringList & arguments ).

In above example from Nathraiben you would call it in function hello like this:
Code:
void MainWindow::hello()
{
    QStringList arguments;
    arguments << "Enable custom transitions" << "Droid Sans" << "Black";
    QProcess::execute("/path/to/my/script/script.sh", arguments);
}
Thanks for this, but how do I put the input from those select boxes as arguments?

And in which part of my project I should put these:
Code:
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hello()));
Code:
void MainWindow::hello()
{
    QStringList arguments;
    arguments << "Enable custom transitions" << "Droid Sans" << "Black";
    QProcess::execute("/path/to/my/script/script.sh", arguments);
}
I have these:
Forms:
- mainwindow-ui

Headers.
- mainwindow.h

Sources:
- main.cpp
- mainwindow.cpp
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 

The Following User Says Thank You to d-iivil For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 19:06.