PDA

View Full Version : File Open dialog does not show mounted servers under Ubuntu



bnilsson
26th October 2010, 11:08
In my Ubuntu-10.04 Qt application I need to access files (and select directory) on connected servers, which I see as folder icons on my desktop. However, the open file/select directory dialog does not include these connections.
What should I do let them be visible in the dialogs?
I use
QFileDialog::getOpenFileName(this,tr("Open pattern file"),patternfilepath, tr("Pattern files Files (%1)").arg(pname));
and
QFileDialog::getExistingDirectory(this, tr("Open Directory"), "/home", patterndirpath,QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);

Are there dialog variants that will work better?

BN

wysota
26th October 2010, 11:30
What do you consider a "connected server"?

bnilsson
26th October 2010, 12:56
As you may know, at the top of the Ubuntu desktop, there is a menubar.
In this menubar there are Applications, Places and System menus.
In the Places menu, there is an item called "Connect to server...".
Activating this item will give a dialog where you can select SSH, FTP (with login), Public FTP, Windows share, WebDAV, Secure WebDAV and Custom Location.
I have so far used SSH and Windows share.
For both of these, after supplying the connection details and authentication in to the server, a folder symbol is created on the desktop, containing the files present on the server I am connected to.
In my application, this server symbol is not present in the File Open.. or Select Directory.. dialogs.

Please tell me if you need a more detailed explanation of the situation.

BN

wysota
26th October 2010, 13:03
As you may know, at the top of the Ubuntu desktop, there is a menubar.
I don't, I don't use Gnome.


Please tell me if you need a more detailed explanation of the situation.
Open a console, run "mount" and see if your "connected servers" are listed there. If so, there will be paths listed alongside them where the "connected servers" have been mounted. In Unix there is no concept or "drives" or "servers", there is a coherent filesystem tree starting with the root (/). Mounted devices (be it local or remote) become parts of the tree.

bnilsson
26th October 2010, 13:20
bnilsson@ubuntu:~$ mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
.host:/ on /mnt/hgfs type vmhgfs (rw,ttl=1)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
gvfs-fuse-daemon on /home/bnilsson/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=bnilsson)

I can also tell you that the native Ubuntu Application/Acessories/Text Editor does show the mounted server symbol in the file browser, while my Qt application does not.

wysota
26th October 2010, 13:51
There is no such thing as "native Ubuntu Application". It's an application that uses the Gnome filesystem abstraction. You can handle a similar thing in Qt as well if you implement it yourself but don't expect Qt to handle every possible abstraction of every possible system and solution in the world. You can reverse the situation and ask whether Gnome handles this situation in such a way instead of using someone else's "standard solution". I could ask why my GIMP doesn't handle KDE's "Places" container in its file dialogs.

bnilsson
26th October 2010, 14:04
So what you are saying is that Qt's implementation of file dialogs in Ubuntu is not working it is my problem to solve it?

wysota
26th October 2010, 14:15
What I'm saying is that if you need something extra they you have to implement it on your own. For static file dialogs Qt uses by default the desktop implementation of the dialog (so it should pick up what your desktop manager (Gnome+Metacity) offers). If you are not getting some functionality it might offer, you can't expect Qt to handle every possible case of calling the native dialog. You can always call the native dialog yourself with options and API the dialog offers.

bnilsson
26th October 2010, 14:47
Ok, I would think this feature is pretty darn basic...

However this is a real bonafide show-stopper for my application.
Any hints on how I can gather information on how I should proceed?

I would invite other readers to respond too, if possible.

wysota
26th October 2010, 15:06
So is your "connected server" in the list of mounted filesystems or not?

bnilsson
26th October 2010, 16:13
The line from 'mount'
gvfs-fuse-daemon on /home/bnilsson/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=bnilsson)
is related.

/home/bnilsson/.gvfs contains an item with the same name as the folder symbol on my desktop.
For a windows share on the server mc2-p007 it is called: bnilsson on mc2-p007
For a ssh mount on the server mc2-p007 it is called: sftp for bnilsson on mc2-p007

BN

wysota
26th October 2010, 16:17
So it's not mounted thus it gets mounted once you actually first access it or it's only accessible from gnome's file dialogs. If you run a file dialog from your Qt apps, do you get the standard gtk file dialog as for other apps on your system or do you get a custom Qt-based dialog?

bnilsson
26th October 2010, 16:56
So it's not mounted thus it gets mounted once you actually first access it or it's only accessible from gnome's file dialogs. If you run a file dialog from your Qt apps, do you get the standard gtk file dialog as for other apps on your system or do you get a custom Qt-based dialog?

As far as I can tell it is native. It looks the same as in other Ubuntu apps with an Open File menu the except that in the left column for "Places" there is nothing inbetween "File system" and "Floppy drive", where my "server" symbol is placed in the other apps.
Maybe this information is meningless for you since you don't run Ubuntu, but this is what I see.

wysota
26th October 2010, 17:23
Trust me, the fact that you are using Ubuntu has nothing to do with this. I can install Gnome with gvfs on my Mandriva and have a similar behaviour. If the dialog doesn't contain the "places" part then either Qt does it on purpose because of some reason or there is a Gnome-originated reason for not showing the places container.

bnilsson
26th October 2010, 18:33
If the dialog doesn't contain the "places" part then either Qt does it on purpose because of some reason or there is a Gnome-originated reason for not showing the places container.

I want to point out that the "Places " section is NOT missing from the File Dialog, it is only the "server" item in the "Places" list that is not there.

wysota
26th October 2010, 18:42
Whatever...

bnilsson
27th October 2010, 08:18
Qt does it on purpose because of some reason or there is a Gnome-originated reason for not showing the places container.

You cannot be serious...

Added after 13 minutes:

A workaround for the time being:

mkdir servers
ln -s .gvfs servers

I can open the "server" folder and then find my files.
But I still it is a bug/flaw in the QFileDialog. You can argue about secret reasons, but this is my standpoint.

wysota
27th October 2010, 10:18
I don't argue about "secret reasons", Qt is open-source - take its source code and check it out yourself. Do you expect me to do that for you? Qt uses Gnome's file dialog - it just calls a function from some Gnome library, it doesn't "delete" the entries from the dialog and it doesn't try to "mimic" the original dialog.

bnilsson
27th October 2010, 13:51
Well, it seems this discussion has reached a dead end.
I filed a bug report, we'll se what happens next. Maybe someone will take care of it.

Chiz
10th January 2011, 10:51
I'm using WinXP. I have mounted disks from our local server on fedora. I set to mount them on system startup. Your code works good at my app.
In My Computer I have three mounted disks and in QFileDialog they displayed properly.

bnilsson
10th January 2011, 13:44
The problem arises when accessing a remote server from a Ubuntu platform. On Windows or Mac, remote server volumes are visible in the QFileDialog file browser.
The operating system on the remote server (in your case fedora) seems not important in this case.

wysota
10th January 2011, 14:11
The problem arises when accessing a remote server from a Ubuntu platform. On Windows or Mac, remote server volumes are visible in the QFileDialog file browser.
The operating system on the remote server (in your case fedora) seems not important in this case.

Hmm... is it possible that the scope of the visibility of the "mounted servers" in Gnome is adjustable? I mean that one application can see them and the other doesn't? That's the case with KDE's "Places" feature (a place can be global or local to an app), maybe in Gnome it is somehow similar?

bnilsson
10th January 2011, 14:35
I now realize I forgot to report that I got the answer of the true cause of the problem.
Below is the response from "Qt bugreports" on this issue.

This is a deeper problem. It happens that QFile by design cannot handle virtual file systems, which is what Gnome uses underneath. Therefore the file dialog explicitly hides the remotes to avoid showing something that will not be usable.

Seems you were right all the time, wysota.
My apologies.

However, my workaround

ln -s .gvfs servers works fine, virtual file systems or not. I can then open the folder "servers" and access my mounted volumes from there. Maybe the access methods I use is a special case which works anyway.

wysota
10th January 2011, 14:37
I think you need to open the folder "servers" prior to accessing it with QFile. I mean you can't do:

QFile file("~/servers/someserver/x/y/z");
before accessing the bare "servers" directory first, right? The latter will probably mount (as in Unix mount) the server and then anyone can use it as it is part of the real filesystem.

bnilsson
10th January 2011, 15:09
I am not sure I follow you, I "communicate" with the file system by QFileDialog only, and browse to the file I want, and supply the output QString to the QFile functions I use.
Unless I make this "server" symlink there is nothing to browse to.
I create the "server" symlink once in my home folder, and it is always there since. If I do "Connect to server" in the "Places" menu it gets a content, otherwise not.
The folder "server" is actually ~/.gvfs, (which might mean 'gnome virtual file system'?)
Actually, I never explicitly checked the content of the string received from
QString fileName = QFileDialog::getOpenFileNameafter I have selected a file in a remote volume, so I do not know how it is expressed, abnd if there are any potential problems.
But yes, the server needs to be mounted before it can be accessed by QFileDialog thru its mountpoint in the ~/.gvfs.

wysota
10th January 2011, 15:21
I am not sure I follow you, I "communicate" with the file system by QFileDialog only, and browse to the file I want, and supply the output QString to the QFile functions I use.
Unless I make this "server" symlink there is nothing to browse to.
No, it's not what I mean. I don't use Gnome on a daily basis so I don't know exactly how the file dialog from it looks like but I guess it probably has a field where you can enter the directory path you want to browse. Now my guess is that if you enter some subdirectory of your "server" symlink without going explicitly through the "server" directory (like you do when browsing by clicking on directories in the list) your workaround will not work because there will be nothing "under" '~/server'. The same way it will not work when explicitly assigning a path to a QFile without the use of QFileDialog (like when accessing a "recent" file or some other setting that was stored some time in the past).

Your workaround is probably similar to clicking on the .gvfs entry directly, after all a soft-link is just an alias to some other inode.

bnilsson
10th January 2011, 15:58
Well, communication is difficult sometimes.
The symlink "servers" is created by me, and represents ~/.gvfs, just because "dot-files" are normally hidden by the gui, and thus also to QFileDialog.
And the workaround does actually work, this is the way I use it now. It's just too bad I need a 'hack' like this...

wysota
10th January 2011, 16:28
The symlink "servers" is created by me, and represents ~/.gvfs,
I understand that.

just because "dot-files" are normally hidden by the gui, and thus also to QFileDialog.
You can instruct QFileDialog to show them.


And the workaround does actually work, this is the way I use it now. It's just too bad I need a 'hack' like this...
It works because of the way you use it. If this software is just for you then that's not a problem. But if you intend others to use it, their way of doing things might be different than yours and your workaround may fail (even on the same computer system).

bnilsson
10th January 2011, 17:34
You can instruct QFileDialog to show them.Great! How do I do this?
Apparently, I must have missed this item in the Assistant docs.

wysota
10th January 2011, 22:16
Hmm... I thought there was an API for it but apparently there is none. Anyway, when the gnome dialog is open you can right click it and check "show hidden files".

totem
10th January 2011, 22:34
Hmm... I thought there was an API for it but apparently there is none. Anyway, when the gnome dialog is open you can right click it and check "show hidden files".

what about QFileDialog::setFilter ( ... | QDir::Hidden | .. ) ?

bnilsson
11th January 2011, 09:36
what about QFileDialog::setFilter ( ... | QDir::Hidden | .. ) ?
Tried that, and it doesn't seem to work reliably.
I think "right-click show hidden files" in the dialog is overriding it.
Anyway, I was ignorant about the "right-click show hidden files" method, this seems to solve the issue.

Thanks for all your assistance.