mirror of
https://github.com/transmission/transmission
synced 2025-02-22 06:00:41 +00:00
Use native separators for path button and free space label tooltips. Improve path button dialog initial directory/file selection.
This commit is contained in:
parent
829cbffaf7
commit
5ada708756
2 changed files with 19 additions and 3 deletions
|
@ -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 ();
|
||||
}
|
||||
|
|
|
@ -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)));
|
||||
|
||||
|
|
Loading…
Reference in a new issue