Browse Source

Better fix for save path editing issues in torrent addition dialog

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
328e4fd860
  1. 22
      src/torrentadditiondlg.cpp
  2. 6
      src/torrentadditiondlg.h

22
src/torrentadditiondlg.cpp

@ -30,7 +30,8 @@
#include "torrentadditiondlg.h" #include "torrentadditiondlg.h"
torrentAdditionDialog::torrentAdditionDialog(GUI *parent, QBtSession* _BTSession) : QDialog((QWidget*)parent), old_label(""), hidden_height(0), cursor_pos(-1) { torrentAdditionDialog::torrentAdditionDialog(GUI *parent, QBtSession* _BTSession) :
QDialog((QWidget*)parent), old_label(""), hidden_height(0) {
setupUi(this); setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
connect(this, SIGNAL(torrentPaused(QTorrentHandle&)), parent->getTransferList(), SLOT(pauseTorrent(QTorrentHandle&))); connect(this, SIGNAL(torrentPaused(QTorrentHandle&)), parent->getTransferList(), SLOT(pauseTorrent(QTorrentHandle&)));
@ -250,8 +251,8 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) {
loadSavePathHistory(); loadSavePathHistory();
// Connect slots // Connect slots
connect(savePathTxt, SIGNAL(editTextChanged(QString)), this, SLOT(updateDiskSpaceLabels())); connect(savePathTxt->lineEdit(), SIGNAL(editingFinished()), this, SLOT(updateDiskSpaceLabels()));
connect(savePathTxt, SIGNAL(editTextChanged(QString)), this, SLOT(updateSavePathCurrentText(QString))); connect(savePathTxt->lineEdit(), SIGNAL(editingFinished()), this, SLOT(updateSavePathCurrentText()));
if(nbFiles == 1) { if(nbFiles == 1) {
// Update properties model whenever the file path is edited // Update properties model whenever the file path is edited
connect(savePathTxt, SIGNAL(editTextChanged(QString)), this, SLOT(renameTorrentNameInModel(QString))); connect(savePathTxt, SIGNAL(editTextChanged(QString)), this, SLOT(renameTorrentNameInModel(QString)));
@ -643,18 +644,9 @@ void torrentAdditionDialog::renameSelectedFile() {
} }
} }
void torrentAdditionDialog::restoreCursorPosition() { void torrentAdditionDialog::updateSavePathCurrentText() {
savePathTxt->lineEdit()->setCursorPosition(cursor_pos); qDebug("updateSavePathCurrentText() - ENTER");
cursor_pos = -1; savePathTxt->setItemText(savePathTxt->currentIndex(), savePathTxt->currentText());
}
void torrentAdditionDialog::updateSavePathCurrentText(QString path) {
if(cursor_pos >= 0)
return;
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()); path_history.replace(savePathTxt->currentIndex(), getCurrentTruncatedSavePath());
QString root_folder_or_file_name = ""; QString root_folder_or_file_name = "";
getCurrentTruncatedSavePath(&root_folder_or_file_name); getCurrentTruncatedSavePath(&root_folder_or_file_name);

6
src/torrentadditiondlg.h

@ -86,12 +86,9 @@ public slots:
void saveTruncatedPathHistory(); void saveTruncatedPathHistory();
void loadSavePathHistory(); void loadSavePathHistory();
void updateLabelInSavePath(QString label); void updateLabelInSavePath(QString label);
void updateSavePathCurrentText(QString path); void updateSavePathCurrentText();
void resetComboLabelIndex(QString text); void resetComboLabelIndex(QString text);
protected slots:
void restoreCursorPosition();
signals: signals:
void torrentPaused(QTorrentHandle &h); void torrentPaused(QTorrentHandle &h);
@ -112,7 +109,6 @@ private:
bool is_magnet; bool is_magnet;
int hidden_height; int hidden_height;
QStringList path_history; QStringList path_history;
int cursor_pos;
}; };
#endif #endif

Loading…
Cancel
Save