Several fixes to the merge request

This commit is contained in:
Christophe Dumez 2011-09-21 17:48:39 +03:00
parent c25f51e866
commit 7bd19f7696
3 changed files with 37 additions and 52 deletions

View file

@ -229,14 +229,6 @@ public:
setValue("Preferences/Downloads/AppendLabel", b);
}
bool rememberLastLocation() const {
return value(QString::fromUtf8("Preferences/Downloads/RememberLastLocation"), false).toBool();
}
void setRememberLastLocation(bool b) {
setValue("Preferences/Downloads/RememberLastLocation", b);
}
QString lastLocationPath() const {
return value(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), QString()).toString();
}

View file

@ -87,18 +87,8 @@ torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) :
// Important: as a default, it inserts at the bottom which is not desirable
savePathTxt->setInsertPolicy(QComboBox::InsertAtCurrent);
//torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch);
QString lastLocation = pref.lastLocationPath();
checkLastFolder->setChecked(pref.rememberLastLocation());
//lastLocation will always have '/' as separator since it is saved in
//::on_OkButton_clicked() after the conversion is done.
if (pref.rememberLastLocation() && !lastLocation.isEmpty() && QFile(lastLocation).exists())
defaultSavePath = lastLocation;
else
{
defaultSavePath = pref.getSavePath();
//In case of the LastLocationPath doesn't exist anymore, empty the string
pref.setLastLocationPath(QString());
}
appendLabelToSavePath = pref.appendTorrentLabel();
QString display_path = defaultSavePath.replace("\\", "/");
@ -613,6 +603,7 @@ void torrentAdditionDialog::savePiecesPriorities(){
}
void torrentAdditionDialog::on_OkButton_clicked(){
Preferences pref;
qDebug() << "void torrentAdditionDialog::on_OkButton_clicked() - ENTER";
if(savePathTxt->currentText().trimmed().isEmpty()){
QMessageBox::critical(0, tr("Empty save path"), tr("Please enter a save path"));
@ -691,6 +682,11 @@ void torrentAdditionDialog::on_OkButton_clicked(){
}
// Save path history
saveTruncatedPathHistory();
// Set as default save path if necessary
if (checkLastFolder->isChecked())
pref.setSavePath(getCurrentTruncatedSavePath());
// Check if savePath exists
if(!savePath.exists()){
if(!savePath.mkpath(savePath.path())){
@ -698,14 +694,7 @@ void torrentAdditionDialog::on_OkButton_clicked(){
return;
}
}
//Save last location path
{//limit the scope of pref
Preferences pref;
bool isChecked = checkLastFolder->isChecked();
if (pref.rememberLastLocation() != isChecked) pref.setRememberLastLocation(isChecked);
if (pref.rememberLastLocation() && save_path != pref.lastLocationPath())
pref.setLastLocationPath(save_path);
}
// save filtered files
if(!is_magnet && t->num_files() > 1)
savePiecesPriorities();

View file

@ -29,8 +29,8 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="savePathLbl">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@ -43,6 +43,8 @@
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="savePathTxt">
<property name="sizePolicy">
@ -65,6 +67,15 @@
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkLastFolder">
<property name="text">
<string>Set as default save path</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -281,13 +292,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkLastFolder">
<property name="text">
<string>Remember last used folder</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<property name="spacing">