Bugfix: wrong folder selection dialog behavior

Authored by trufanov on Mar 8 2017, 2:55 PM.

Description

Bugfix: wrong folder selection dialog behavior

REVIEW:129989

There are 2 problems with directory selection dialog.

  1. If you scan very first page you'll get SaveLocation dialog but if you press the "..." button in it to specify folder for scans - a file selection dialog will be opened. Not directory selection, but file selection. If you select a file in it - a directory selection dialog pop up just after you close previous one. So you'll get a second dialog. Your first file selection result will be overwritten by folder selection.
  2. If you choose for example "/tmp/" in directory selection dialog you'll get "/tmp" in the text box. Without trailing path separator. And resulted filename preview will be "/prefix-0001.png", not "/tmp/prefix-0001.png". If you didn't notice that and press ok you'll get an error as nothing can be saved to root. If you selected another folder you later may realize that your scans are in parent directory. Why? Bcs SkanLite doesn't check trailing path separator in directory path and believes that "/tmp" is a file tmp in the root folder. And Qt's directory selection dialogs always return directory name without trailing path separator in it.

I've fixed both problems.
Second one is easy, just if (!dir.endsWith(QDir::separator())) dir = dir.append(QDir::separator()); before proceeding with directory selection results.

First one is a bit awkward. There is a slot getDir() and 2 widgets connected to it. u_urlRequester from SaveLocation dialog and getDirButton from Settings dialog. the slot opens QFileDialog::getExistingDirectory(). It's fine for getDirButton which is a QButton. But u_urlRequester is a KUrlRequester and contains own button and launches own file selection dialog which is for files by default. That's obviously wrong.
There are notes in getDir() slot about // FIXME KF5. Seems to be this discussion. I believe it's irrelevant to this problem. Perhaps this problem is a former workaround for KF5 problem which is already disappeared.

All you need to fix this behavior is to disconnect KUrlRequester from getDir() which explicitly calls getExistingDirectory() and let it use it's own. We just need to switch it in directory selection mode with u_urlRequester->setMode(KFile::Directory);.

Details

Committed
trufanovMar 9 2017, 2:59 PM
Parents
R483:9f1e7b3596b1: fix DPI info in 16-bit PNG
Branches
Unknown
Tags
Unknown