Preselect name without extension when renaming files

And preselect the whole string for everything else.
This commit is contained in:
thalieht 2018-09-05 16:55:21 +03:00
parent 9fa78c7b50
commit ffc2193df9
4 changed files with 20 additions and 10 deletions

View file

@ -685,8 +685,9 @@ void PropertiesWidget::renameSelectedFile()
// Ask for new name
bool ok = false;
QString newName = AutoExpandableDialog::getText(this, tr("Renaming"), tr("New name:"), QLineEdit::Normal, modelIndex.data().toString(), &ok)
.trimmed();
const bool isFile = (m_propListModel->itemType(modelIndex) == TorrentContentModelItem::FileType);
QString newName = AutoExpandableDialog::getText(this, tr("Renaming"), tr("New name:"), QLineEdit::Normal
, modelIndex.data().toString(), &ok, isFile).trimmed();
if (!ok) return;
if (newName.isEmpty() || !Utils::Fs::isValidFileSystemName(newName)) {
@ -696,8 +697,7 @@ void PropertiesWidget::renameSelectedFile()
return;
}
if (m_propListModel->itemType(modelIndex) == TorrentContentModelItem::FileType) {
// renaming a file
if (isFile) {
const int fileIndex = m_propListModel->getFileIndex(modelIndex);
if (newName.endsWith(QB_EXT))