mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 11:38:50 -07:00
Improve detection of file extension string
This commit is contained in:
parent
17fa615bd3
commit
15a249eb54
2 changed files with 13 additions and 9 deletions
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "autoexpandabledialog.h"
|
||||
|
||||
#include "base/utils/fs.h"
|
||||
#include "ui_autoexpandabledialog.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
@ -57,12 +58,9 @@ QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, con
|
|||
d.m_ui->textEdit->selectAll();
|
||||
if (excludeExtension)
|
||||
{
|
||||
int lastDotIndex = text.lastIndexOf('.');
|
||||
if ((lastDotIndex > 3) && (text.mid(lastDotIndex - 4, 4).toLower() == ".tar"))
|
||||
lastDotIndex -= 4;
|
||||
// Select file name without extension, except dot files like .gitignore
|
||||
if (lastDotIndex > 0)
|
||||
d.m_ui->textEdit->setSelection(0, lastDotIndex);
|
||||
const QString extension = Utils::Fs::fileExtension(text);
|
||||
if (!extension.isEmpty())
|
||||
d.m_ui->textEdit->setSelection(0, (text.length() - extension.length() - 1));
|
||||
}
|
||||
|
||||
bool res = d.exec();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue