Browse Source

Merge pull request #17281 from Chocobo1/creator

Fix filename not populated correctly
adaptive-webui-19844
Chocobo1 2 years ago committed by GitHub
parent
commit
b44bdd21cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/base/path.cpp
  2. 4
      src/gui/torrentcreatordialog.cpp

11
src/base/path.cpp

@ -115,6 +115,11 @@ Path Path::rootItem() const @@ -115,6 +115,11 @@ Path Path::rootItem() const
if (slashIndex == 0) // *nix absolute path
return createUnchecked(u"/"_qs);
#ifdef Q_OS_WIN
// should be `c:/` instead of `c:`
if (m_pathStr.at(slashIndex - 1) == u':')
return createUnchecked(m_pathStr.left(slashIndex + 1));
#endif
return createUnchecked(m_pathStr.left(slashIndex));
}
@ -127,6 +132,12 @@ Path Path::parentPath() const @@ -127,6 +132,12 @@ Path Path::parentPath() const
if (slashIndex == 0) // *nix absolute path
return (m_pathStr.size() == 1) ? Path() : createUnchecked(u"/"_qs);
#ifdef Q_OS_WIN
// should be `c:/` instead of `c:`
// Windows "drive letter" is limited to one alphabet
if ((slashIndex == 2) && (m_pathStr.at(1) == u':'))
return createUnchecked(m_pathStr.left(slashIndex + 1));
#endif
return createUnchecked(m_pathStr.left(slashIndex));
}

4
src/gui/torrentcreatordialog.cpp

@ -180,8 +180,8 @@ void TorrentCreatorDialog::onCreateButtonClicked() @@ -180,8 +180,8 @@ void TorrentCreatorDialog::onCreateButtonClicked()
}
// get save path
const Path savePath = m_storeLastSavePath.get(Utils::Fs::homePath() / Path(inputPath.filename() + u".torrent"));
Path destPath {QFileDialog::getSaveFileName(this, tr("Select where to save the new torrent"), savePath.data(), tr("Torrent Files (*.torrent)"))};
const Path lastSavePath = (m_storeLastSavePath.get(Utils::Fs::homePath()) / Path(inputPath.filename() + u".torrent"));
Path destPath {QFileDialog::getSaveFileName(this, tr("Select where to save the new torrent"), lastSavePath.data(), tr("Torrent Files (*.torrent)"))};
if (destPath.isEmpty())
return;
if (!destPath.hasExtension(TORRENT_FILE_EXTENSION))

Loading…
Cancel
Save