Use native separators for path button and free space label tooltips. Improve path button dialog initial directory/file selection.

This commit is contained in:
Mike Gelfand 2015-04-15 00:08:24 +00:00
parent 829cbffaf7
commit 5ada708756
2 changed files with 19 additions and 3 deletions

View File

@ -7,6 +7,8 @@
* $Id$
*/
#include <QDir>
#include <libtransmission/transmission.h>
#include <libtransmission/variant.h>
@ -98,7 +100,7 @@ FreespaceLabel::onSessionExecuted (int64_t tag, const QString& result, tr_varian
const char * path = 0;
tr_variantDictFindStr (arguments, TR_KEY_path, &path, &len);
str = QString::fromUtf8 (path, len);
setToolTip (str);
setToolTip (QDir::toNativeSeparators (str));
myTimer.start ();
}

View File

@ -8,6 +8,7 @@
*/
#include <QApplication>
#include <QDir>
#include <QFileDialog>
#include <QFileIconProvider>
#include <QFileInfo>
@ -63,7 +64,7 @@ TrPathButton::setPath (const QString& path)
if (myPath == path)
return;
myPath = Utils::removeTrailingDirSeparator (path);
myPath = QDir::toNativeSeparators (Utils::removeTrailingDirSeparator (path));
updateAppearance ();
@ -114,7 +115,20 @@ TrPathButton::onClicked ()
dialog->setOption (QFileDialog::ShowDirsOnly);
if (!myNameFilter.isEmpty ())
dialog->setNameFilter (myNameFilter);
dialog->selectFile (myPath);
const QFileInfo pathInfo (myPath);
if (!myPath.isEmpty () && pathInfo.exists ())
{
if (pathInfo.isDir ())
{
dialog->setDirectory (pathInfo.absoluteFilePath ());
}
else
{
dialog->setDirectory (pathInfo.absolutePath ());
dialog->selectFile (pathInfo.fileName ());
}
}
connect (dialog, SIGNAL (fileSelected (QString)), this, SLOT (onFileSelected (QString)));