PDA

View Full Version : Open/Save dialog with images preview



mchara
25th October 2007, 07:01
Hi all there...

I need a dialog to open/save images in my application, i want it to be as close to native windows open/save dialogs as possible but with preview of currently selected image area on the right side.

Windows dialogs can't be reused because they are modal on the level of application & method that calls then returns after dialog is closed.
It's teoretically possible to start dialog in separate thread and reparent it to own widget, but i think it's bad idea - lots of work and unsure effects...

So... i've decided to design custom dialog, and I found some difficulties with comboBox that selects current drive/directory.
First: it contains desktop, my documents, my network places, drives via my computer, recent files ect... I want to use QDirModel with drives only(at least for now), but I'd like to make this combobox as similar as possible to native original in final version, and have no idea how to do it.
Second: Original comboBox is hierarchical, so i think i must write own comboBox that uses treeView instead of built-in list, unless anybody knows better approach to do this...

I think it's quite common components that should be written as good as possible to be reusable so ANY suggestions & ideas are welcome...

wysota
25th October 2007, 08:40
Windows dialogs can't be reused because they are modal on the level of application & method that calls then returns after dialog is closed.

And what is wrong with that? Qt uses the native Windows dialog with success...

mchara
25th October 2007, 09:05
It would be ok, if i would need only to use it, but i need a custom dialog with preview of images and i tougth that native windows dialog could be used as a part of custom dialog...

Mentioned reasons makes it useless as a components of own dialog, winapi allows to use it as is, but haven't any methods to create a dialog and do anything with it...

wysota
25th October 2007, 09:12
Doesn't Windows provide a native dialog with previews? I recall seing it very often in different apps, but I'm not sure if it is a system dialog or manually extended one.

mchara
25th October 2007, 09:26
I've searched about this, but i didn't found anything useful, so there's no native dialog with preview, or i've searched it wrong...
anyhow dialog you could see quite often, is as i think, a component that is a part of borland's environments(C++Builder, Delphi)...

Besides: if it would be native dialog, trolls would surely make it available from QFileDialog is some way...

mchara
26th October 2007, 10:01
Hi there,

I found QFileItemProvider can return myComputer, Desktop, Trash, Network ect. icons.
I also found SHGetSpecialFolderLocation method in winapi that returns real locations of virtual folders mentioned above.

I nearly finished custom comboBox that shows overridden QTreeView instead of internal items list (QTreeView can show items in hierarchy), TreeView currently uses QDirModel and shows drives only, so with those new information i think the best direction would be a custom ModelView that reproduces the structure of windows virtual folders on 2 topmost levels and attaches real QDirModel as children of proper items.

Does anyone knows better aproach or do u think it's good idea?

mchara
1st November 2007, 17:33
Hi again, i found that native dialog allows to show itself with additional custom dialog embedded(it's rather difficult & low level so i think i won't waste my time for it). Bigger problem for me is the fact that native dialog is not storing state(size, current view etc.) so thumbnails view that have to be turned on each time dialog is opened is rather useless...
I think i have no choice & have to implement own thumbnails view generating mechanism for my dialog. I'm a bit unconcerned that custom dialog won't have explorer's features such as drag&drop, rename/delete/new folder, but it's not open file dialog is for, so i'll have to live without it...

pherthyl
1st November 2007, 18:57
Hi again, i found that native dialog allows to show itself with additional custom dialog embedded(it's rather difficult & low level so i think i won't waste my time for it). Bigger problem for me is the fact that native dialog is not storing state(size, current view etc.) so thumbnails view that have to be turned on each time dialog is opened is rather useless...
I think i have no choice & have to implement own thumbnails view generating mechanism for my dialog. I'm a bit unconcerned that custom dialog won't have explorer's features such as drag&drop, rename/delete/new folder, but it's not open file dialog is for, so i'll have to live without it...
I would avoid designing a custom dialog if at all possible. Like you said, you will lose consistency with every other dialog in the system, also lots of potential for bugs.

Have you investigated using the native open dialog with QFileDialog and listening for the filesSelected signal? You could just position a preview window beside the open dialog and show the currently selected image. Not as pretty as having it integrated into the dialog, but it should be very easy to implement.

mchara
5th November 2007, 07:25
Have you investigated using the native open dialog with QFileDialog and listening for the filesSelected signal? You could just position a preview window beside the open dialog and show the currently selected image.

The thing is that QFileDialog isn't a native dialog - it's customized to, but by trolls(besides it's weak in my opinion), native dialog can be called by QFileDialog from a static method, but it's not emitting anything.
Qt won't help because this behavior is determined by winApi.

I know that I'm loosing lots of goodies by customizing fileDialog, but my application work's on images only so it's a priority to have preview or thumbnails & native dialog opens always in list mode. Imagine that on each file you're opening file dialog, changing view to thumbnails and picking a file then... thumbnails view that can't be set to default is useless, nobody will change it every opened file, in other hand soft for image processing that have no functionality that shows what you are actually opening - i already have one (written view years ago) and i'm ill when i'm using it... it's a priority and it seems that i can't achieve it without sacrificing some native functionalities.

Native dialog is great, there's no discussion here, but it's not supporting applications that are meant to work with images.

In addition, note that windows won't generate thumbnails for all formats supported by qt...

On the margin: I already done custom dialog with scalable preview(that can be turned off), with mode that allows to open multiple files, and thumbnails view (with cache, xml file per directory with generated thumbnails & timestamps, thumbnails generating thread). It fits to my app better than native dialog & it have minimal assumed functionality (maybe it will be enhanced...)so i think problem is solved, at least temporary, but i'm still interested about your opinions...