Browse Source

- Remember last save directory in torrent addition dialog

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
e9ab599260
  1. 3
      src/GUI.cpp
  2. 25
      src/torrentAddition.h

3
src/GUI.cpp

@ -1112,13 +1112,14 @@ void GUI::askForTorrents(){ @@ -1112,13 +1112,14 @@ void GUI::askForTorrents(){
}
}
// Save last dir to remember it
lastDirFile.open(QIODevice::WriteOnly | QIODevice::Text);
if(lastDirFile.open(QIODevice::WriteOnly | QIODevice::Text)){
QStringList top_dir = pathsList.at(0).split(QDir::separator());
top_dir.removeLast();
lastDirFile.write(top_dir.join(QDir::separator()).toUtf8());
lastDirFile.close();
}
}
}
// Scan the first level of the directory for torrent files
// and add them to download list

25
src/torrentAddition.h

@ -62,12 +62,19 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ @@ -62,12 +62,19 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
actionUnselect->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/remove.png")));
connect(actionSelect, SIGNAL(triggered()), this, SLOT(selectItems()));
connect(actionUnselect, SIGNAL(triggered()), this, SLOT(unselectItems()));
//TODO: Remember last entered path
QString home = QDir::homePath();
if(home[home.length()-1] != QDir::separator()){
home += QDir::separator();
}
savePathTxt->setText(home+"qBT_dir");
QString dirPath = home+"qBT_dir";
QFile lastDirFile(misc::qBittorrentPath()+"lastDirTorrentAdd.txt");
// Load remembered last dir
if(lastDirFile.exists()){
lastDirFile.open(QIODevice::ReadOnly | QIODevice::Text);
dirPath=lastDirFile.readLine();
lastDirFile.close();
}
savePathTxt->setText(dirPath);
}
void showLoad(QString filePath, bool fromScanDir=false, QString from_url=QString::null){
@ -135,7 +142,13 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ @@ -135,7 +142,13 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
public slots:
void on_browseButton_clicked(){
QString dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath());
QString dir;
QDir saveDir(savePathTxt->text());
if(saveDir.exists()){
dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), savePathTxt->text());
}else{
dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath());
}
if(!dir.isNull()){
savePathTxt->setText(dir);
}
@ -234,6 +247,12 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ @@ -234,6 +247,12 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
savepath_file.write(savePath.path().toUtf8());
savepath_file.close();
// Save last dir to remember it
QFile lastDirFile(misc::qBittorrentPath()+"lastDirTorrentAdd.txt");
if(lastDirFile.open(QIODevice::WriteOnly | QIODevice::Text)){
lastDirFile.write(savePathTxt->text().toUtf8());
lastDirFile.close();
}
// Create .incremental file if necessary
if(checkIncrementalDL->isChecked()){
QFile incremental_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".incremental");

Loading…
Cancel
Save