![]() |
Maemo5 & PyQT4 - Implementing an image-viewer.
I am working on developing a comic/image viewer frontend for an application I'm designing.
Now, what I'd like to end up with is similar to the built-in image viewer(at least, the actual "show image" part), but with some differences. I'm looking at: 1. Displaying an image with some text below it. Currently I'm using QTextBrowser, which seems to do the job. 2. Scaling of both text and image. I just need to be able to either set a % or get the current width and be able to set a pixel #. 2.5. Relatedly, I need to figure out how to get button presses of the zoom/volume keys. 3. Having portrait mode support(at least manually, through a setting). 4. Being able to slide your finger on the touchscreen to switch between images(Like how the built-in viewer does it). 5. long-press/right-click menu for whatever I end up using as my image/text viewer. How can I set this up? 6. Some sort of "multi-page" interface, like the image-viewer: You can click the "back" button in the upper right-hand corner to view another page(in that case, a list of images). In my case, it will be a QTreeWidget object. Can you guys point me to some pages, tutorials and or code-snippets that might help me with these things? Thanks, -RobbieThe1st |
Re: Maemo5 & PyQT4 - Implementing an image-viewer.
woah, lots of questions :) - i'm by no means an authority on anything pyqt but here goes!
1) Text Browser (Opening an HTML File, so it could assist in opening an image if you want!) Code:
self.textBrowser = QtGui.QTextBrowser(self.tab_4) But i assume you mean auto-rotate style repositioning. What you would need to do is to read the width and height and compare it to the current max width or height (800*420 without top bar) Another way, is to have a slide in menu like the new firefox 4 example- that way whats on your screen can stay it's normal size? :) 2.5. Relatedly, I need to figure out how to get button presses of the zoom/volume keys. I think 1up in the repos is pyqt and uses these keys - http://maemo.org/downloads/product/Maemo5/1up/ - if it is, might be worth downloading the code and taking a look :) My assumption, but i dont know how to map the hw keys, sorry! 3. Having portrait mode support(at least manually, through a setting). This relates to number two! - http://forums.internettablettalk.com...t=31940&page=3 - should help! 4. No idea, sorry! Well kinda, the healthcheck code reads in and detects screen location, if you can use that to detect movements of a specific type it should work :) Code:
def mouseMoveEvent(self, event): http://www.riverbankcomputing.co.uk/...tml/qmenu.html Code:
import sys 6. Check the healthcheck pages for multipage stuff, the tools page tools stuff mainly load up in new windows. Sorry typed it all a bit quick, as heading out! hope that helps! :) |
Re: Maemo5 & PyQT4 - Implementing an image-viewer.
@noobmonkey:
Thanks. 1. Yea, I have QTextBrowser code working, but I'm not sure it will let me do what I want(especially #2). 2. Thing is, some comics and images look fine scaled down to the resolution of the screen. Some don't. I intend to have an back-end option that will allow the user to select between scrolling(full-size) and scaled to the screen-size. Making it match the width, that's easily done. Its getting access to a function that allows me to scale the image onscreen to whatever dimensions I choose that's the issue. More importantly, I need to be able to scale the image [i]using a good[/url] scaling algorithm, just like with the image viewer. Nearest-neighbor etc. just won't do. Now, last I checked, I could add a pixel-width to the img in the HTML code I'm sending to QTextBrowser, but I'm not sure I could externally change it without reloading the whole code etc. This may be the best option, but I'm really wondering if there's a better widget. With 3, thanks for that. However, do you know of any -manual- rotation function? I'd like to be able to lock it in portrait mode based on a setting or two. 4. Alright, but there's got to be some sort of library for doing this; it seems kludgy to simply poll the cursor whenever the mouse "button" is down, and then try to extrapolate motion from that. 5. Yes, that's what I mean - I'm just slightly worried about content inside the QTextView(etc) overriding my menu - I'm trying to make the menu appear anywhere, not just where there's no image. 6. Alright, I'll see what I can do... |
Re: Maemo5 & PyQT4 - Implementing an image-viewer.
Quote:
This one is in python so you can just translate the others (In c++ i think) self.setAttribute(QtCore.Qt.WA_Maemo5AutoOrientati on, True) setAttribute(Qt::WA_Maemo5PortraitOrientation, true); setAttribute(Qt::WA_Maemo5LandscapeOrientation, true); An example in c ..... Code:
QRect screenGeometry = QApplication::desktop()->screenGeometry(); 5) Took me a while to get a normal menu working! I know you can position it depending on where they press , but i have no experience, if you come up with a good example post it for all to see in the wiki! :) But i'd definitley hunt through the repos for some example python apps that do it already! As soon as i get a bit of time i'll try and do some proper examples - just got back from hols and back to work monday, so frantically washing, cleaning etc! :P |
All times are GMT. The time now is 06:38. |
vBulletin® Version 3.8.8