mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 03:28:41 -07:00
Preselect name without extension when renaming files
And preselect the whole string for everything else.
This commit is contained in:
parent
9fa78c7b50
commit
ffc2193df9
4 changed files with 20 additions and 10 deletions
|
@ -48,7 +48,7 @@ AutoExpandableDialog::~AutoExpandableDialog()
|
|||
|
||||
QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, const QString &label,
|
||||
QLineEdit::EchoMode mode, const QString &text,
|
||||
bool *ok, Qt::InputMethodHints inputMethodHints)
|
||||
bool *ok, const bool excludeExtension, Qt::InputMethodHints inputMethodHints)
|
||||
{
|
||||
AutoExpandableDialog d(parent);
|
||||
d.setWindowTitle(title);
|
||||
|
@ -57,6 +57,16 @@ QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, con
|
|||
d.m_ui->textEdit->setEchoMode(mode);
|
||||
d.m_ui->textEdit->setInputMethodHints(inputMethodHints);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
bool res = d.exec();
|
||||
if (ok)
|
||||
*ok = res;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue