From 9543bd63f9e44f9769807f9d0d9a032a8954cedf Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 25 Sep 2010 09:11:06 +0000 Subject: [PATCH] Fix torrent addition dialog path editing --- src/torrentadditiondlg.cpp | 11 +++++++++-- src/torrentadditiondlg.h | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/torrentadditiondlg.cpp b/src/torrentadditiondlg.cpp index 6c1b898c8..c707d7b07 100644 --- a/src/torrentadditiondlg.cpp +++ b/src/torrentadditiondlg.cpp @@ -313,8 +313,8 @@ void torrentAdditionDialog::renameSelectedFile() { // Ask for new name bool ok; const QString new_name_last = QInputDialog::getText(this, tr("Rename the file"), - tr("New name:"), QLineEdit::Normal, - index.data().toString(), &ok); + tr("New name:"), QLineEdit::Normal, + index.data().toString(), &ok); if (ok && !new_name_last.isEmpty()) { if(!misc::isValidFileSystemName(new_name_last)) { QMessageBox::warning(this, tr("The file could not be renamed"), @@ -614,8 +614,15 @@ void torrentAdditionDialog::renameSelectedFile() { } } + void torrentAdditionDialog::restoreCursorPosition() { + savePathTxt->lineEdit()->setCursorPosition(cursor_pos); + } + void torrentAdditionDialog::updateSavePathCurrentText(QString path) { + Q_UNUSED(path); + cursor_pos = savePathTxt->lineEdit()->cursorPosition(); savePathTxt->setItemText(savePathTxt->currentIndex(), path); + QTimer::singleShot(0, this, SLOT(restoreCursorPosition())); path_history.replace(savePathTxt->currentIndex(), getCurrentTruncatedSavePath()); QString root_folder_or_file_name = ""; getCurrentTruncatedSavePath(&root_folder_or_file_name); diff --git a/src/torrentadditiondlg.h b/src/torrentadditiondlg.h index 2f9bd9bdb..289f69b8d 100644 --- a/src/torrentadditiondlg.h +++ b/src/torrentadditiondlg.h @@ -88,6 +88,9 @@ public slots: void updateSavePathCurrentText(QString path); void resetComboLabelIndex(QString text); +protected slots: + void restoreCursorPosition(); + signals: void torrentPaused(QTorrentHandle &h); @@ -108,6 +111,7 @@ private: bool is_magnet; int hidden_height; QStringList path_history; + int cursor_pos; }; #endif